re PR c/88701 (Internal compiler error for valid program using compound literal with...
authorJakub Jelinek <jakub@redhat.com>
Mon, 7 Jan 2019 22:55:48 +0000 (23:55 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Mon, 7 Jan 2019 22:55:48 +0000 (23:55 +0100)
PR c/88701
* c-decl.c (build_compound_literal): If not TREE_STATIC, only pushdecl
if current_function_decl is non-NULL.

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

From-SVN: r267667

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

index 5ee4b66c51363bc969d06b1b3435df85322a27be..7cffd900c274ecedf103a7f4132ad8752ad6bbe2 100644 (file)
@@ -1,3 +1,9 @@
+2019-01-07  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c/88701
+       * c-decl.c (build_compound_literal): If not TREE_STATIC, only pushdecl
+       if current_function_decl is non-NULL.
+
 2019-01-07  Joseph Myers  <joseph@codesourcery.com>
 
        PR c/88720
index 5c7232f3657a6edf99de753d9e1de22ec68f3ff4..57049f8007322b6ca32e5ad4feb202c77160ffaf 100644 (file)
@@ -5438,7 +5438,7 @@ build_compound_literal (location_t loc, tree type, tree init, bool non_const,
       pushdecl (decl);
       rest_of_decl_compilation (decl, 1, 0);
     }
-  else
+  else if (current_function_decl)
     pushdecl (decl);
 
   if (non_const)
index ebc96a331bc47e86f3a87ca3e64a22de6bd5e68b..72e9d8e47aa7ad5302080ca0267d0c23a5cfbacc 100644 (file)
@@ -1,3 +1,8 @@
+2019-01-07  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c/88701
+       * gcc.dg/pr88701.c: New test.
+
 2019-01-07  Joseph Myers  <joseph@codesourcery.com>
 
        PR c/88720
diff --git a/gcc/testsuite/gcc.dg/pr88701.c b/gcc/testsuite/gcc.dg/pr88701.c
new file mode 100644 (file)
index 0000000..7aa846d
--- /dev/null
@@ -0,0 +1,18 @@
+/* PR c/88701 */
+/* { dg-do compile } */
+/* { dg-options "-std=c99 -pedantic-errors" } */
+
+void foo (int [(int (*)[1]) { 0 } == 0]);
+void bar (int n, int [(int (*)[n]) { 0 } == 0]);
+
+int
+baz (int a[(int (*)[1]) { 0 } == 0])
+{
+  return a[0];
+}
+
+int
+qux (int n, int a[(int (*)[n]) { 0 } == 0])
+{
+  return a[0] + n;
+}