re PR c/35447 (ICE with broken statement expression)
authorJoseph Myers <joseph@codesourcery.com>
Wed, 18 Feb 2009 00:38:28 +0000 (00:38 +0000)
committerJoseph Myers <jsm28@gcc.gnu.org>
Wed, 18 Feb 2009 00:38:28 +0000 (00:38 +0000)
PR c/35447
* c-parser.c (c_parser_compound_statement): Always enter and leave
a scope.

testsuite:
* gcc.dg/noncompile/pr35447-1.c: New test.

From-SVN: r144256

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

index ca77fc468a3e25ef1fb7f4ad6220d73c1c23464d..17869d7b11c0bf1bedfcd7a45b1888b21ada9393 100644 (file)
@@ -1,3 +1,9 @@
+2009-02-18  Joseph Myers  <joseph@codesourcery.com>
+
+       PR c/35447
+       * c-parser.c (c_parser_compound_statement): Always enter and leave
+       a scope.
+
 2009-02-17  John David Anglin  <dave.anglin@nrc-cnrc.gc.ca>
 
        PR target/34587
index 9aef031a8eb6d7a426283ddc6774443283d36d5f..6dfcb60159724c8c496c7327d56345b7b30608b6 100644 (file)
@@ -3307,7 +3307,13 @@ c_parser_compound_statement (c_parser *parser)
 {
   tree stmt;
   if (!c_parser_require (parser, CPP_OPEN_BRACE, "expected %<{%>"))
-    return error_mark_node;
+    {
+      /* Ensure a scope is entered and left anyway to avoid confusion
+        if we have just prepared to enter a function body.  */
+      stmt = c_begin_compound_stmt (true);
+      c_end_compound_stmt (stmt, true);
+      return error_mark_node;
+    }
   stmt = c_begin_compound_stmt (true);
   c_parser_compound_statement_nostart (parser);
   return c_end_compound_stmt (stmt, true);
index 3cbc3e79229034325e12b10f7626bedd4fb6e61c..055c2b19d12a81131f0f5090d0c2e58cf03bad5f 100644 (file)
@@ -1,3 +1,8 @@
+2009-02-18  Joseph Myers  <joseph@codesourcery.com>
+
+       PR c/35447
+       * gcc.dg/noncompile/pr35447-1.c: New test.
+
 2009-02-18  Jakub Jelinek  <jakub@redhat.com>
 
        PR tree-optimization/36922
diff --git a/gcc/testsuite/gcc.dg/noncompile/pr35447-1.c b/gcc/testsuite/gcc.dg/noncompile/pr35447-1.c
new file mode 100644 (file)
index 0000000..9c31e9b
--- /dev/null
@@ -0,0 +1,7 @@
+/* ICE arising from preparing to enter a scope for a nested function
+   but never doing so.  PR 35447.  */
+
+void foo()
+{
+  ({ int i().; }); /* { dg-error "expected" } */
+} /* { dg-error "expected" } */