re PR c/14069 (This input file lets gcc crash)
authorJakub Jelinek <jakub@redhat.com>
Mon, 22 Mar 2004 15:28:06 +0000 (16:28 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Mon, 22 Mar 2004 15:28:06 +0000 (16:28 +0100)
PR c/14069
* c-decl.c (finish_struct): Change type of incorrect flexible array
field into error_mark_node.

* gcc.dg/20040322-1.c: New test.

From-SVN: r79832

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

index f3f09dbf01c06a973553b8f758ca79772b5ea9e9..9e06227a2862575286493bc812271762deb8bb3f 100644 (file)
@@ -1,3 +1,9 @@
+2004-03-22  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c/14069
+       * c-decl.c (finish_struct): Change type of incorrect flexible array
+       field into error_mark_node.
+
 2004-03-22  Andrew Pinski  <pinskia@physics.uc.edu>
 
        PR target/14580
index 46f352b3a62637c75dba2b6181bd86bd1432e86d..46863ed531affd7305f06e35975eae4391811986 100644 (file)
@@ -5018,11 +5018,20 @@ finish_struct (tree t, tree fieldlist, tree attributes)
          && TYPE_MAX_VALUE (TYPE_DOMAIN (TREE_TYPE (x))) == NULL_TREE)
        {
          if (TREE_CODE (t) == UNION_TYPE)
-           error ("%Jflexible array member in union", x);
+           {
+             error ("%Jflexible array member in union", x);
+             TREE_TYPE (x) = error_mark_node;
+           }
          else if (TREE_CHAIN (x) != NULL_TREE)
-           error ("%Jflexible array member not at end of struct", x);
+           {
+             error ("%Jflexible array member not at end of struct", x);
+             TREE_TYPE (x) = error_mark_node;
+           }
          else if (! saw_named_field)
-           error ("%Jflexible array member in otherwise empty struct", x);
+           {
+             error ("%Jflexible array member in otherwise empty struct", x);
+             TREE_TYPE (x) = error_mark_node;
+           }
        }
 
       if (pedantic && TREE_CODE (t) == RECORD_TYPE
index 89b16aeedc9e5d041956e0a0a2a27149eafd07b9..359124ca2c854c405cb30a1886dfe6cebf6a9eaa 100644 (file)
@@ -1,3 +1,8 @@
+2004-03-22  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c/14069
+       * gcc.dg/20040322-1.c: New test.
+
 2004-03-22  Eric Botcazou  <ebotcazou@libertysurf.fr>
 
        * gcc.dg/ultrasp2.c: Do not pass -m64.  Remove redundant lines.
diff --git a/gcc/testsuite/gcc.dg/20040322-1.c b/gcc/testsuite/gcc.dg/20040322-1.c
new file mode 100644 (file)
index 0000000..af5e0b4
--- /dev/null
@@ -0,0 +1,4 @@
+/* PR c/14069 */
+/* { dg-do compile } */
+struct S { int a; char b[]; char *c; }; /* { dg-error "error" "flexible array member not" } */
+struct S s = { .b = "foo", .c = .b }; /* { dg-error "error" "parse error before" } */