aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRichard Henderson <rth@redhat.com>2004-03-25 16:46:53 -0800
committerRichard Henderson <rth@gcc.gnu.org>2004-03-25 16:46:53 -0800
commit0066ef9ce4ea5377b154cdc10ef6626033ede8b8 (patch)
tree9a46770d8a2c14576bec5d2d58aa5ebf0959fcd5 /gcc
parent8bd22a3ceb375d5d8bae67a527c390f4116e59dc (diff)
downloadgcc-0066ef9ce4ea5377b154cdc10ef6626033ede8b8.zip
gcc-0066ef9ce4ea5377b154cdc10ef6626033ede8b8.tar.gz
gcc-0066ef9ce4ea5377b154cdc10ef6626033ede8b8.tar.bz2
re PR c/11527 (If an array "designated intializer" in a struct causes a segv.)
PR 11527 * c-typeck.c (pop_init_level): Emit pending init elements earlier rather than later. * gcc.dg/gnu89-init-3.c: New. From-SVN: r79978
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/c-typeck.c8
-rw-r--r--gcc/testsuite/gcc.dg/gnu89-init-3.c18
3 files changed, 28 insertions, 4 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index c83ca7c..c06551f 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2004-03-25 Richard Henderson <rth@redhat.com>
+
+ PR 11527
+ * c-typeck.c (pop_init_level): Emit pending init elements earlier
+ rather than later.
+
2004-03-25 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* builtins.c (fold_builtin): Fix error in last change.
diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c
index 2e57ba7..2a40258 100644
--- a/gcc/c-typeck.c
+++ b/gcc/c-typeck.c
@@ -4655,6 +4655,10 @@ pop_init_level (int implicit)
abort ();
}
+ /* Now output all pending elements. */
+ constructor_incremental = 1;
+ output_pending_init_elements (1);
+
p = constructor_stack;
/* Error for initializing a flexible array member, or a zero-length
@@ -4709,10 +4713,6 @@ pop_init_level (int implicit)
}
}
- /* Now output all pending elements. */
- constructor_incremental = 1;
- output_pending_init_elements (1);
-
/* Pad out the end of the structure. */
if (p->replacement_value)
/* If this closes a superfluous brace pair,
diff --git a/gcc/testsuite/gcc.dg/gnu89-init-3.c b/gcc/testsuite/gcc.dg/gnu89-init-3.c
new file mode 100644
index 0000000..bd4283e
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/gnu89-init-3.c
@@ -0,0 +1,18 @@
+/* PR 11527 */
+/* { dg-do compile } */
+/* { dg-options "-std=gnu89" } */
+
+typedef struct smrdd_memory_blocks_s
+{
+ int blocks;
+ int block[];
+} smrdd_memory_blocks_t;
+
+const smrdd_memory_blocks_t smrdd_memory_blocks =
+{
+ 3,
+ {
+ [5] = 5,
+ [1] = 2,
+ }
+};