re PR c/9799 (mismatching structure initializer with nested flexible array member...
authorEric Botcazou <ebotcazou@libertysurf.fr>
Wed, 5 Mar 2003 08:37:57 +0000 (09:37 +0100)
committerEric Botcazou <ebotcazou@gcc.gnu.org>
Wed, 5 Mar 2003 08:37:57 +0000 (08:37 +0000)
PR c/9799
* c-typeck.c (push_init_level): Add sanity check.

From-SVN: r63831

gcc/ChangeLog
gcc/c-typeck.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/compile/20030305-1.c [new file with mode: 0644]

index 4d30aba002be0785f7bf77372b0b3fb403292071..c2f7841329ad256bc61c29788be3c0d0276b9966 100644 (file)
@@ -1,3 +1,8 @@
+2003-03-05  Eric Botcazou  <ebotcazou@libertysurf.fr>
+
+       PR c/9799
+       * c-typeck.c (push_init_level): Add sanity check.
+
 Wed Mar  5 02:04:04 CET 2003  Jan Hubicka  <jh@suse.cz>
 
        * toplev.c (rest_of_compilation):  Deffer RTL compilation only when
index 8302a9678f03589af8046e1ed33981fd6901e7c2..52105ac84ecef8a6a705bc43bfeec65c5278e51e 100644 (file)
@@ -5273,6 +5273,7 @@ push_init_level (implicit)
          && constructor_fields == 0)
        process_init_element (pop_init_level (1));
       else if (TREE_CODE (constructor_type) == ARRAY_TYPE
+              && constructor_max_index 
               && tree_int_cst_lt (constructor_max_index, constructor_index))
        process_init_element (pop_init_level (1));
       else
index b67b566c858a40368bc0dfdfbf7b23f5e21b3f2b..006017276a4f49de7db54f7d62b8cbe5e0b98050 100644 (file)
@@ -1,3 +1,7 @@
+2003-03-05  Eric Botcazou  <ebotcazou@libertysurf.fr>
+
+       * gcc.c-torture/compile/20030305-1.c
+
 Wed Mar  5 02:05:19 CET 2003  Jan Hubicka  <jh@suse.cz>
 
        * gcc.dg/i386-local.c: New.
diff --git a/gcc/testsuite/gcc.c-torture/compile/20030305-1.c b/gcc/testsuite/gcc.c-torture/compile/20030305-1.c
new file mode 100644 (file)
index 0000000..2f60819
--- /dev/null
@@ -0,0 +1,18 @@
+/* PR c/9799 */
+/* Verify that GCC doesn't crash on excess elements
+   in initializer for a flexible array member.  */
+
+typedef struct {
+    int aaa;
+} s1_t;
+
+typedef struct {
+    int bbb;
+    s1_t s1_array[];
+} s2_t;
+
+static s2_t s2_array[]= {
+    { 1, 4 },
+    { 2, 5 },
+    { 3, 6 }
+};