From: Marek Polacek Date: Fri, 29 Jul 2016 17:34:55 +0000 (+0000) Subject: re PR c/71853 (ICE on an ill-formed case statement in c_do_switch_warnings) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=efd0786f218626c25adde976a9f83121b0c45342;p=gcc.git re PR c/71853 (ICE on an ill-formed case statement in c_do_switch_warnings) PR c/71853 * c-parser.c (c_parser_switch_statement): Initialize ce.original_type to error node for invalid code. * gcc.dg/noncompile/pr71853.c: New test. From-SVN: r238884 --- diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index 89ca5aa81ec..ec680d3cce6 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -3,6 +3,10 @@ PR c/71742 * c-decl.c (finish_struct): Rephrase an error message. + PR c/71853 + * c-parser.c (c_parser_switch_statement): Initialize ce.original_type + to error node for invalid code. + 2016-07-29 Jakub Jelinek PR c/71969 diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c index a86cae29940..cc689121226 100644 --- a/gcc/c/c-parser.c +++ b/gcc/c/c-parser.c @@ -5661,6 +5661,7 @@ c_parser_switch_statement (c_parser *parser, bool *if_p) { switch_cond_loc = UNKNOWN_LOCATION; expr = error_mark_node; + ce.original_type = error_mark_node; } c_start_case (switch_loc, switch_cond_loc, expr, explicit_cast_p); save_break = c_break_label; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index e2388b1fddd..dbe2a3ae088 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -5,6 +5,9 @@ * gcc.dg/c99-flex-array-1.c: Likewise. * gcc.dg/c99-flex-array-typedef-1.c: Likewise. + PR c/71853 + * gcc.dg/noncompile/pr71853.c: New test. + 2016-07-29 Uros Bizjak * gcc.dg/pr59833.c: Use dg-add-options ieee. diff --git a/gcc/testsuite/gcc.dg/noncompile/pr71853.c b/gcc/testsuite/gcc.dg/noncompile/pr71853.c new file mode 100644 index 00000000000..673b6c54615 --- /dev/null +++ b/gcc/testsuite/gcc.dg/noncompile/pr71853.c @@ -0,0 +1,9 @@ +/* PR c/71853 */ +/* { dg-do compile } */ + +void f (void) +{ + case (0) { /* { dg-error "expected" } */ + switch 0: { } /* { dg-error "expected" } */ + } +}