This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[patch] Fix PR c++/27716: ICE with invalid assignment
- From: Volker Reichelt <reichelt at igpm dot rwth-aachen dot de>
- To: gcc-patches at gcc dot gnu dot org
- Date: Mon, 22 May 2006 12:04:10 +0200 (CEST)
- Subject: [patch] Fix PR c++/27716: ICE with invalid assignment
The C++ frontend stumbles over the following invalid code snippet since
GCC 3.4.5:
int foo()
{
return i ""= i;
}
bug.cc: In function 'int foo()':
bug.cc:3: error: 'i' was not declared in this scope
bug.cc:3: error: expected ';' before string constant
bug.cc:3: error: assignment of read-only location
bug.cc:3: internal compiler error: tree check: expected class 'type', have 'exceptional' (error_mark) in build_modify_expr, at cp/typeck.c:5720
Please submit a full bug report, [etc.]
The following patch fixes the ICE by checking the operands of
build_modify_expr with error_operand_p instead of just checking
for error_mark_nodes.
Bootstrapped and regtested on x86_64-unknown-linux-gnu.
Ok for mainline, 4.1 branch, and 4.0 branch?
Regards,
Volker
:ADDPATCH C++:
2006-05-22 Volker Reichelt <reichelt@igpm.rwth-aachen.de>
PR c++/27716
* typeck.c (build_modify_expr): Test arguments for error_operand_p.
===================================================================
--- gcc/gcc/cp/typeck.c (revision 113772)
+++ gcc/gcc/cp/typeck.c (working copy)
@@ -5466,7 +5466,7 @@ build_modify_expr (tree lhs, enum tree_code
bool plain_assign = (modifycode == NOP_EXPR);
/* Avoid duplicate error messages from operands that had errors. */
- if (lhs == error_mark_node || rhs == error_mark_node)
+ if (error_operand_p (lhs) || error_operand_p (rhs))
return error_mark_node;
/* Handle control structure constructs used as "lvalues". */
===================================================================
2006-05-22 Volker Reichelt <reichelt@igpm.rwth-aachen.de>
PR c++/27716
* g++.dg/other/assign1.C: New test.
===================================================================
--- gcc/gcc/testsuite/g++.dg/other/assign1.C 2005-08-29 00:25:44 +0200
+++ gcc/gcc/testsuite/g++.dg/other/assign1.C 2006-05-15 14:26:23 +0200
@@ -0,0 +1,7 @@
+// PR c++/27716
+// { dg-do compile }
+
+int foo()
+{
+ return i ""= i; // { dg-error "not declared|string constant" }
+}
===================================================================