]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c/59351 (ICE on empty compound literal with -pedantic)
authorMarek Polacek <polacek@redhat.com>
Tue, 3 Dec 2013 11:57:31 +0000 (11:57 +0000)
committerMarek Polacek <mpolacek@gcc.gnu.org>
Tue, 3 Dec 2013 11:57:31 +0000 (11:57 +0000)
PR c/59351
c/
* c-decl.c (build_compound_literal): Allow compound literals with
empty initial value.
testsuite/
* gcc.dg/pr59351.c: New test.

From-SVN: r205627

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

index 42b0bb7db8e18d67c3978c1ccf105aee73ceac72..b97e65ec2494eadd2354db0a0e25d2b53a03f91b 100644 (file)
@@ -1,3 +1,9 @@
+2013-12-03  Marek Polacek  <polacek@redhat.com>
+
+       PR c/59351
+       * c-decl.c (build_compound_literal): Allow compound literals with
+       empty initial value.
+
 2013-12-02  Joseph Myers  <joseph@codesourcery.com>
 
        PR c/58235
index 27be7fc1b031ba6d42e0c973cef967c0f5b74482..3ebc002560eb0f65cfa22245dca8acee18ef61c1 100644 (file)
@@ -4693,7 +4693,9 @@ build_compound_literal (location_t loc, tree type, tree init, bool non_const)
     {
       int failure = complete_array_type (&TREE_TYPE (decl),
                                         DECL_INITIAL (decl), true);
-      gcc_assert (!failure);
+      /* If complete_array_type returns 3, it means that the
+         initial value of the compound literal is empty.  Allow it.  */
+      gcc_assert (failure == 0 || failure == 3);
 
       type = TREE_TYPE (decl);
       TREE_TYPE (DECL_INITIAL (decl)) = type;
index c34641f1a17c50aa6b7fd8c896c9dc5293faeab9..60019c9c8a58daca38dfbc47bcda9a90a64bd0cf 100644 (file)
@@ -1,3 +1,8 @@
+2013-12-03  Marek Polacek  <polacek@redhat.com>
+
+       PR c/59351
+       * gcc.dg/pr59351.c: New test.
+
 2013-12-03  Chung-Ju Wu  <jasonwucj@gmail.com>
 
        * gcc.dg/20020312-2.c: Add __nds32__ case.
diff --git a/gcc/testsuite/gcc.dg/pr59351.c b/gcc/testsuite/gcc.dg/pr59351.c
new file mode 100644 (file)
index 0000000..384058f
--- /dev/null
@@ -0,0 +1,8 @@
+/* { dg-do compile } */
+/* { dg-options "-std=c99 -Wpedantic" } */
+
+unsigned int
+foo (void)
+{
+  return sizeof ((int[]) {}); /* { dg-warning "ISO C forbids empty initializer braces" } */
+}