re PR c/84721 (ICE in c_push_function_context, at c-decl.c:9667)
authorJakub Jelinek <jakub@redhat.com>
Tue, 6 Mar 2018 20:57:30 +0000 (21:57 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 6 Mar 2018 20:57:30 +0000 (21:57 +0100)
PR c/84721
* c-parser.c (add_debug_begin_stmt): Don't add DEBUG_BEGIN_STMT if
!building_stmt_list_p ().

* gcc.dg/pr84721.c: New test.

From-SVN: r258302

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

index f0fd33e9790d584f074899156dee5e5961fe60c5..599ffa2cbe32724d05ebe6240ae912b7e8c895c8 100644 (file)
@@ -1,3 +1,9 @@
+2018-03-06  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c/84721
+       * c-parser.c (add_debug_begin_stmt): Don't add DEBUG_BEGIN_STMT if
+       !building_stmt_list_p ().
+
 2018-02-13  Richard Sandiford  <richard.sandiford@linaro.org>
 
        PR c/84305
index 5e3512a9127ca163a21b1b3e1e6688e23dbe6f1b..945838cde59bba9e48fdcad53047b4d4e0800992 100644 (file)
@@ -1654,7 +1654,8 @@ static void c_finish_oacc_routine (struct oacc_routine_data *, tree, bool);
 static void
 add_debug_begin_stmt (location_t loc)
 {
-  if (!MAY_HAVE_DEBUG_MARKER_STMTS)
+  /* Don't add DEBUG_BEGIN_STMTs outside of functions, see PR84721.  */
+  if (!MAY_HAVE_DEBUG_MARKER_STMTS || !building_stmt_list_p ())
     return;
 
   tree stmt = build0 (DEBUG_BEGIN_STMT, void_type_node);
index c78c70bc931706efb620a809b95813fb69150413..9221074cfa0111e9cfed01b7c03f7bcfa6ad3903 100644 (file)
@@ -1,5 +1,8 @@
 2018-03-06  Jakub Jelinek  <jakub@redhat.com>
 
+       PR c/84721
+       * gcc.dg/pr84721.c: New test.
+
        PR target/84710
        * gcc.dg/pr84710.c: New test.
 
diff --git a/gcc/testsuite/gcc.dg/pr84721.c b/gcc/testsuite/gcc.dg/pr84721.c
new file mode 100644 (file)
index 0000000..3ebf3a6
--- /dev/null
@@ -0,0 +1,6 @@
+/* PR c/84721 */
+/* { dg-do compile } */
+/* { dg-options "-g -O2" } */
+
+int a[({ int b })];            /* { dg-error "braced-group within expression allowed only inside a function" } */
+int c[({ int d () {}; })];     /* { dg-error "braced-group within expression allowed only inside a function" } */