[C PATCH] Fix ICE on invalid (PR c/54355)
Jakub Jelinek
jakub@redhat.com
Fri Aug 24 21:24:00 GMT 2012
Hi!
When the c_parser_declaration_or_fndef call has been added for error
handling of invalid label followed by decl, the comments for the two
arguments were swapped, and I believe nested needs to be passed as true,
this is inside of another function. Testing revealed that empty_ok=true
is also desirable, for the 20031223-1.c testcase.
Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
2012-08-23 Jakub Jelinek <jakub@redhat.com>
PR c/54355
* c-decl.c (c_parser_label): Pass true as nested and fix up comments
for nested and empty_ok arguments in the call to
c_parser_declaration_or_fndef.
* gcc.dg/pr54355.c: New test.
--- gcc/c/c-parser.c.jj 2012-08-17 17:42:25.315617706 +0200
+++ gcc/c/c-parser.c 2012-08-24 20:38:57.445151457 +0200
@@ -4327,7 +4327,7 @@ c_parser_label (c_parser *parser)
"a declaration is not a statement");
c_parser_declaration_or_fndef (parser, /*fndef_ok*/ false,
/*static_assert_ok*/ true,
- /*nested*/ true, /*empty_ok*/ false,
+ /*empty_ok*/ true, /*nested*/ true,
/*start_attr_ok*/ true, NULL);
}
}
--- gcc/testsuite/gcc.dg/pr54355.c.jj 2012-08-24 12:14:25.973223541 +0200
+++ gcc/testsuite/gcc.dg/pr54355.c 2012-08-24 12:14:25.973223541 +0200
@@ -0,0 +1,11 @@
+/* PR c/54355 */
+/* { dg-do compile } */
+
+void
+foo (int i)
+{
+ switch (i)
+ {
+ case 0: T x > /* { dg-error "(label|unknown type|expected)" } */
+ }
+} /* { dg-error "expected" } */
Jakub
More information about the Gcc-patches
mailing list