Commit 0066ef9c by Richard Henderson Committed by Richard Henderson

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
parent 8bd22a3c
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> 2004-03-25 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* builtins.c (fold_builtin): Fix error in last change. * builtins.c (fold_builtin): Fix error in last change.
......
...@@ -4655,6 +4655,10 @@ pop_init_level (int implicit) ...@@ -4655,6 +4655,10 @@ pop_init_level (int implicit)
abort (); abort ();
} }
/* Now output all pending elements. */
constructor_incremental = 1;
output_pending_init_elements (1);
p = constructor_stack; p = constructor_stack;
/* Error for initializing a flexible array member, or a zero-length /* Error for initializing a flexible array member, or a zero-length
...@@ -4709,10 +4713,6 @@ pop_init_level (int implicit) ...@@ -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. */ /* Pad out the end of the structure. */
if (p->replacement_value) if (p->replacement_value)
/* If this closes a superfluous brace pair, /* If this closes a superfluous brace pair,
......
/* 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,
}
};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment