re PR c/71853 (ICE on an ill-formed case statement in c_do_switch_warnings)
authorMarek Polacek <polacek@redhat.com>
Fri, 29 Jul 2016 17:34:55 +0000 (17:34 +0000)
committerMarek Polacek <mpolacek@gcc.gnu.org>
Fri, 29 Jul 2016 17:34:55 +0000 (17:34 +0000)
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

gcc/c/ChangeLog
gcc/c/c-parser.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/noncompile/pr71853.c [new file with mode: 0644]

index 89ca5aa81ec132e609b46f2ff44640b7697ed93d..ec680d3cce6dc715d3d0f5bc6871d74a1fed2a62 100644 (file)
@@ -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  <jakub@redhat.com>
 
        PR c/71969
index a86cae29940f188fe0443560c5aa3051e181cb3b..cc689121226b6e8859384927c359024fd63b0fea 100644 (file)
@@ -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;
index e2388b1fddd567bc160998e3efea9a15bdb6513a..dbe2a3ae08867687443427c86183b2e7b3425031 100644 (file)
@@ -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  <ubizjak@gmail.com>
 
        * 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 (file)
index 0000000..673b6c5
--- /dev/null
@@ -0,0 +1,9 @@
+/* PR c/71853 */
+/* { dg-do compile } */
+
+void f (void)
+{
+  case (0) { /* { dg-error "expected" } */
+    switch 0: { } /* { dg-error "expected" } */
+  }
+}