This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
C++ PATCH: PR 10278
- From: Mark Mitchell <mark at codesourcery dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Mon, 31 Mar 2003 13:43:01 -0800
- Subject: C++ PATCH: PR 10278
- Reply-to: mark at codesourcery dot com
This patch is the mainline version of the fix for PR c++/10278.
Tested on i686-pc-linux-gnu, applied on the mainline.
--
Mark Mitchell
CodeSourcery, LLC
mark at codesourcery dot com
2003-03-31 Mark Mitchell <mark at codesourcery dot com>
PR c++/10278
* c-common.c (finish_label_address_expr): Handle the
error_mark_node.
2003-03-31 Mark Mitchell <mark at codesourcery dot com>
PR c++/10278
* g++.dg/parse/crash2.C: New test.
Index: c-common.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-common.c,v
retrieving revision 1.406
diff -c -5 -p -r1.406 c-common.c
*** c-common.c 22 Mar 2003 03:28:32 -0000 1.406
--- c-common.c 31 Mar 2003 20:47:06 -0000
*************** c_add_case_label (cases, cond, low_value
*** 4210,4221 ****
(splay_tree_value) case_label);
return case_label;
}
! /* Finish an expression taking the address of LABEL. Returns an
! expression for the address. */
tree
finish_label_address_expr (label)
tree label;
{
--- 4210,4221 ----
(splay_tree_value) case_label);
return case_label;
}
! /* Finish an expression taking the address of LABEL (an
! IDENTIFIER_NODE). Returns an expression for the address. */
tree
finish_label_address_expr (label)
tree label;
{
*************** finish_label_address_expr (label)
*** 4226,4235 ****
--- 4226,4238 ----
if (c_language == clk_cplusplus)
pedwarn ("ISO C++ forbids taking the address of a label");
else
pedwarn ("ISO C forbids taking the address of a label");
}
+
+ if (label == error_mark_node)
+ return error_mark_node;
label = lookup_label (label);
if (label == NULL_TREE)
result = null_pointer_node;
else
Index: testsuite/g++.dg/parse/crash2.C
===================================================================
RCS file: testsuite/g++.dg/parse/crash2.C
diff -N testsuite/g++.dg/parse/crash2.C
*** /dev/null 1 Jan 1970 00:00:00 -0000
--- testsuite/g++.dg/parse/crash2.C 31 Mar 2003 20:47:48 -0000
***************
*** 0 ****
--- 1,7 ----
+ /* { dg-do compile } */
+ int main(void)
+ {
+ char x, y;
+ if ('A' == x) && ('B' == y)) { } /* { dg-error "" } */
+ if (x == 'A') && (y == 'B')) { } /* { dg-error "" } */
+ }