]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c/14069 (This input file lets gcc crash)
authorJakub Jelinek <jakub@redhat.com>
Thu, 1 Apr 2004 16:20:27 +0000 (18:20 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Thu, 1 Apr 2004 16:20:27 +0000 (18:20 +0200)
PR c/14069
* c-decl.c (finish_struct): Change type of incorrect flexible array
field into error_mark_node.

Backport from mainline:
2003-04-07  J"orn Rennecke  <joern.rennecke@superh.com>

* c-typeck.c (output_init_element): Check for type == error_mark_node.

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

Backport from mainline:
2003-04-07  J"orn Rennecke  <joern.rennecke@superh.com>

* gcc.dg/noncompile/init-4.c: New test.

From-SVN: r80299

gcc/ChangeLog
gcc/c-decl.c
gcc/c-typeck.c
gcc/testsuite/ChangeLog

index 5f0017c34ac2763d47b8efe0260d4e863d4364c6..6d7b7bbebaf5835f0822a16952d03d8ed0c9274e 100644 (file)
@@ -1,3 +1,14 @@
+2004-04-01  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c/14069
+       * c-decl.c (finish_struct): Change type of incorrect flexible array
+       field into error_mark_node.
+
+       Backport from mainline:
+       2003-04-07  J"orn Rennecke  <joern.rennecke@superh.com>
+
+       * c-typeck.c (output_init_element): Check for type == error_mark_node.
+
 2004-04-01  Alan Modra  <amodra@bigpond.net.au>
 
        * dwarf2out.c (DEBUG_STR_SECTION_FLAGS): Heed flag_merge_constants.
index 5cb5270084dff95ae990304cd43fecbb5423f0b6..543a67480ab74476c1eadc69b1d9ea13f4c3853d 100644 (file)
@@ -5320,12 +5320,21 @@ finish_struct (t, fieldlist, attributes)
          && TYPE_MAX_VALUE (TYPE_DOMAIN (TREE_TYPE (x))) == NULL_TREE)
        {
          if (TREE_CODE (t) == UNION_TYPE)
-           error_with_decl (x, "flexible array member in union");
+           {
+             error_with_decl (x, "flexible array member in union");
+             TREE_TYPE (x) = error_mark_node;
+           }
          else if (TREE_CHAIN (x) != NULL_TREE)
-           error_with_decl (x, "flexible array member not at end of struct");
+           {
+             error_with_decl (x, "flexible array member not at end of struct");
+             TREE_TYPE (x) = error_mark_node;
+           }
          else if (! saw_named_field)
-           error_with_decl (x, "flexible array member in otherwise empty struct");
-       }
+           {
+             error_with_decl (x, "flexible array member in otherwise empty struct");
+             TREE_TYPE (x) = error_mark_node;
+           }
+       }
 
       if (pedantic && TREE_CODE (t) == RECORD_TYPE
          && flexible_array_type_p (TREE_TYPE (x)))
index a3d45cc7f18c3d9d437ed7a37cd9d63b93eea26a..12faaa7115c091ee1fe4235e18d5f2dda18d0347 100644 (file)
@@ -6241,6 +6241,11 @@ output_init_element (value, type, field, pending)
      tree value, type, field;
      int pending;
 {
+  if (type == error_mark_node)
+    {
+      constructor_erroneous = 1;
+      return;
+    }
   if (TREE_CODE (TREE_TYPE (value)) == FUNCTION_TYPE
       || (TREE_CODE (TREE_TYPE (value)) == ARRAY_TYPE
          && !(TREE_CODE (value) == STRING_CST
index c600736706c9ea578ec0c7f82a0617548c37a789..f3d3cd84eb42b1690bc08a08a0ec0aa3949f2f51 100644 (file)
@@ -1,3 +1,13 @@
+2004-03-27  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c/14069
+       * gcc.dg/20040322-1.c: New test.
+
+       Backport from mainline:
+       2003-04-07  J"orn Rennecke  <joern.rennecke@superh.com>
+
+       * gcc.dg/noncompile/init-4.c: New test.
+
 2004-03-25  Eric Botcazou  <ebotcazou@libertysurf.fr>
 
        * gcc.dg/20040127-1.c: New test.