This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
C++ PATCH: PR 11517
- From: Mark Mitchell <mark at codesourcery dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Wed, 23 Jul 2003 11:46:52 -0700
- Subject: C++ PATCH: PR 11517
- Reply-to: mark at codesourcery dot com
This patch fixes an ICE-on-invalid regression on the mainline.
I zapped a couple more uses of the old bad "cp_convert" routine as
well. Lots more to go, sadly...
Tested on i686-pc-linux-gnu, applied on the mainline.
--
Mark Mitchell
CodeSourcery, LLC
mark@codesourcery.com
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 Mark Mitchell <mark@codesourcery.com>
PR c++/11517
* g++.dg/expr/cond2.C: New test.
Index: cp/call.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/call.c,v
retrieving revision 1.412
diff -c -5 -p -r1.412 call.c
*** cp/call.c 22 Jul 2003 23:30:10 -0000 1.412
--- cp/call.c 23 Jul 2003 18:39:03 -0000
*************** build_conditional_expr (tree arg1, tree
*** 3070,3089 ****
/* [expr.cond]
The first expr ession is implicitly converted to bool (clause
_conv_). */
! arg1 = cp_convert (boolean_type_node, arg1);
/* If something has already gone wrong, just pass that fact up the
tree. */
! if (arg1 == error_mark_node
! || arg2 == error_mark_node
! || arg3 == error_mark_node
! || TREE_TYPE (arg1) == error_mark_node
! || TREE_TYPE (arg2) == error_mark_node
! || TREE_TYPE (arg3) == error_mark_node)
return error_mark_node;
/* [expr.cond]
If either the second or the third operand has type (possibly
--- 3070,3086 ----
/* [expr.cond]
The first expr ession is implicitly converted to bool (clause
_conv_). */
! arg1 = perform_implicit_conversion (boolean_type_node, arg1);
/* If something has already gone wrong, just pass that fact up the
tree. */
! if (error_operand_p (arg1)
! || error_operand_p (arg2)
! || error_operand_p (arg3))
return error_mark_node;
/* [expr.cond]
If either the second or the third operand has type (possibly
*************** build_conditional_expr (tree arg1, tree
*** 3331,3340 ****
--- 3328,3339 ----
|| (TYPE_PTRMEM_P (arg2_type) && TYPE_PTRMEM_P (arg3_type))
|| (TYPE_PTRMEMFUNC_P (arg2_type) && TYPE_PTRMEMFUNC_P (arg3_type)))
{
result_type = composite_pointer_type (arg2_type, arg3_type, arg2,
arg3, "conditional expression");
+ if (result_type == error_mark_node)
+ return error_mark_node;
arg2 = perform_implicit_conversion (result_type, arg2);
arg3 = perform_implicit_conversion (result_type, arg3);
}
if (!result_type)
Index: cp/typeck.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/typeck.c,v
retrieving revision 1.484
diff -c -5 -p -r1.484 typeck.c
*** cp/typeck.c 22 Jul 2003 23:30:22 -0000 1.484
--- cp/typeck.c 23 Jul 2003 18:39:07 -0000
*************** build_unary_op (enum tree_code code, tre
*** 3661,3671 ****
else if (!noconvert)
arg = default_conversion (arg);
break;
case TRUTH_NOT_EXPR:
! arg = cp_convert (boolean_type_node, arg);
val = invert_truthvalue (arg);
if (arg != error_mark_node)
return val;
errstring = "in argument to unary !";
break;
--- 3661,3671 ----
else if (!noconvert)
arg = default_conversion (arg);
break;
case TRUTH_NOT_EXPR:
! arg = perform_implicit_conversion (boolean_type_node, arg);
val = invert_truthvalue (arg);
if (arg != error_mark_node)
return val;
errstring = "in argument to unary !";
break;
Index: testsuite/g++.dg/expr/cond2.C
===================================================================
RCS file: testsuite/g++.dg/expr/cond2.C
diff -N testsuite/g++.dg/expr/cond2.C
*** /dev/null 1 Jan 1970 00:00:00 -0000
--- testsuite/g++.dg/expr/cond2.C 23 Jul 2003 18:39:08 -0000
***************
*** 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 "" }
+ }