re PR c++/11517 (g++ fails to properly convert pointer expressions in conditional expressions.)
PR c++/11517 * call.c (build_conditional_expr): Use perform_implicit_conversion and error_operand_p. Robustify. * typeck.c (build_unary_op): Use perform_implicit_conversion. PR c++/11517 * g++.dg/expr/cond2.C: New test. From-SVN: r69715
This commit is contained in:
parent
a08cb3a374
commit
6cf4d1bca0
|
@ -1,3 +1,10 @@
|
||||||
|
2003-07-23 Mark Mitchell <mark@codesourcery.com>
|
||||||
|
|
||||||
|
PR c++/11517
|
||||||
|
* call.c (build_conditional_expr): Use perform_implicit_conversion
|
||||||
|
and error_operand_p. Robustify.
|
||||||
|
* typeck.c (build_unary_op): Use perform_implicit_conversion.
|
||||||
|
|
||||||
2003-07-23 Nathan Sidwell <nathan@codesourcery.com>
|
2003-07-23 Nathan Sidwell <nathan@codesourcery.com>
|
||||||
|
|
||||||
PR c++/10953
|
PR c++/10953
|
||||||
|
|
|
@ -3072,16 +3072,13 @@ build_conditional_expr (tree arg1, tree arg2, tree arg3)
|
||||||
|
|
||||||
The first expr ession is implicitly converted to bool (clause
|
The first expr ession is implicitly converted to bool (clause
|
||||||
_conv_). */
|
_conv_). */
|
||||||
arg1 = cp_convert (boolean_type_node, arg1);
|
arg1 = perform_implicit_conversion (boolean_type_node, arg1);
|
||||||
|
|
||||||
/* If something has already gone wrong, just pass that fact up the
|
/* If something has already gone wrong, just pass that fact up the
|
||||||
tree. */
|
tree. */
|
||||||
if (arg1 == error_mark_node
|
if (error_operand_p (arg1)
|
||||||
|| arg2 == error_mark_node
|
|| error_operand_p (arg2)
|
||||||
|| arg3 == error_mark_node
|
|| error_operand_p (arg3))
|
||||||
|| TREE_TYPE (arg1) == error_mark_node
|
|
||||||
|| TREE_TYPE (arg2) == error_mark_node
|
|
||||||
|| TREE_TYPE (arg3) == error_mark_node)
|
|
||||||
return error_mark_node;
|
return error_mark_node;
|
||||||
|
|
||||||
/* [expr.cond]
|
/* [expr.cond]
|
||||||
|
@ -3333,6 +3330,8 @@ build_conditional_expr (tree arg1, tree arg2, tree arg3)
|
||||||
{
|
{
|
||||||
result_type = composite_pointer_type (arg2_type, arg3_type, arg2,
|
result_type = composite_pointer_type (arg2_type, arg3_type, arg2,
|
||||||
arg3, "conditional expression");
|
arg3, "conditional expression");
|
||||||
|
if (result_type == error_mark_node)
|
||||||
|
return error_mark_node;
|
||||||
arg2 = perform_implicit_conversion (result_type, arg2);
|
arg2 = perform_implicit_conversion (result_type, arg2);
|
||||||
arg3 = perform_implicit_conversion (result_type, arg3);
|
arg3 = perform_implicit_conversion (result_type, arg3);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3663,7 +3663,7 @@ build_unary_op (enum tree_code code, tree xarg, int noconvert)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TRUTH_NOT_EXPR:
|
case TRUTH_NOT_EXPR:
|
||||||
arg = cp_convert (boolean_type_node, arg);
|
arg = perform_implicit_conversion (boolean_type_node, arg);
|
||||||
val = invert_truthvalue (arg);
|
val = invert_truthvalue (arg);
|
||||||
if (arg != error_mark_node)
|
if (arg != error_mark_node)
|
||||||
return val;
|
return val;
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
2003-07-23 Mark Mitchell <mark@codesourcery.com>
|
2003-07-23 Mark Mitchell <mark@codesourcery.com>
|
||||||
|
|
||||||
|
PR c++/11517
|
||||||
|
* g++.dg/expr/cond2.C: New test.
|
||||||
|
|
||||||
PR optimization/10679
|
PR optimization/10679
|
||||||
* g++.dg/opt/inline4.C: New test.
|
* g++.dg/opt/inline4.C: New test.
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
struct Term { };
|
||||||
|
struct Boolean : Term {
|
||||||
|
explicit Boolean(bool);
|
||||||
|
};
|
||||||
|
struct IsZero : Term {
|
||||||
|
Term *eval();
|
||||||
|
};
|
||||||
|
Term*
|
||||||
|
IsZero::eval()
|
||||||
|
{
|
||||||
|
return true ? new Boolean(false) : this; // { dg-error "" }
|
||||||
|
}
|
Loading…
Reference in New Issue