Commit 940ff66d by Jakub Jelinek Committed by Jakub Jelinek

c-typeck.c (struct constructor_stack): Add range_stack member.

	* c-typeck.c (struct constructor_stack): Add range_stack member.
	(really_start_incremental_init): Clear it.
	(push_init_level): Save constructor_range_stack and clear it if
	pushing explicit braces.
	(pop_init_level): abort if constructor_range_stack is non-zero at
	explicit closing brace.  Restore saved constructor_range_stack if
	not implicit.

	* gcc.dg/gnu99-init-1.c: Add 3 more designated range initializer
	tests.

From-SVN: r39302
parent de1b33dd
2001-01-27 Jakub Jelinek <jakub@redhat.com>
* c-typeck.c (struct constructor_stack): Add range_stack member.
(really_start_incremental_init): Clear it.
(push_init_level): Save constructor_range_stack and clear it if
pushing explicit braces.
(pop_init_level): abort if constructor_range_stack is non-zero at
explicit closing brace. Restore saved constructor_range_stack if
not implicit.
2001-01-27 Alexandre Oliva <aoliva@redhat.com> 2001-01-27 Alexandre Oliva <aoliva@redhat.com>
* expr.c (emit_move_insn): Add REG_EQUAL note when constant loaded * expr.c (emit_move_insn): Add REG_EQUAL note when constant loaded
......
...@@ -4954,6 +4954,8 @@ static int designator_errorneous; ...@@ -4954,6 +4954,8 @@ static int designator_errorneous;
structuring in the initializer, including the outermost one. It structuring in the initializer, including the outermost one. It
saves the values of most of the variables above. */ saves the values of most of the variables above. */
struct constructor_range_stack;
struct constructor_stack struct constructor_stack
{ {
struct constructor_stack *next; struct constructor_stack *next;
...@@ -4965,12 +4967,13 @@ struct constructor_stack ...@@ -4965,12 +4967,13 @@ struct constructor_stack
tree unfilled_fields; tree unfilled_fields;
tree bit_index; tree bit_index;
tree elements; tree elements;
int offset;
struct init_node *pending_elts; struct init_node *pending_elts;
int offset;
int depth; int depth;
/* If nonzero, this value should replace the entire /* If nonzero, this value should replace the entire
constructor at this level. */ constructor at this level. */
tree replacement_value; tree replacement_value;
struct constructor_range_stack *range_stack;
char constant; char constant;
char simple; char simple;
char implicit; char implicit;
...@@ -5159,6 +5162,7 @@ really_start_incremental_init (type) ...@@ -5159,6 +5162,7 @@ really_start_incremental_init (type)
p->depth = constructor_depth; p->depth = constructor_depth;
p->replacement_value = 0; p->replacement_value = 0;
p->implicit = 0; p->implicit = 0;
p->range_stack = 0;
p->outer = 0; p->outer = 0;
p->incremental = constructor_incremental; p->incremental = constructor_incremental;
p->next = 0; p->next = 0;
...@@ -5272,6 +5276,7 @@ push_init_level (implicit) ...@@ -5272,6 +5276,7 @@ push_init_level (implicit)
p->outer = 0; p->outer = 0;
p->incremental = constructor_incremental; p->incremental = constructor_incremental;
p->next = constructor_stack; p->next = constructor_stack;
p->range_stack = 0;
constructor_stack = p; constructor_stack = p;
constructor_constant = 1; constructor_constant = 1;
...@@ -5282,6 +5287,8 @@ push_init_level (implicit) ...@@ -5282,6 +5287,8 @@ push_init_level (implicit)
constructor_pending_elts = 0; constructor_pending_elts = 0;
if (!implicit) if (!implicit)
{ {
p->range_stack = constructor_range_stack;
constructor_range_stack = 0;
designator_depth = 0; designator_depth = 0;
designator_errorneous = 0; designator_errorneous = 0;
} }
...@@ -5404,6 +5411,9 @@ pop_init_level (implicit) ...@@ -5404,6 +5411,9 @@ pop_init_level (implicit)
pop any inner levels that didn't have explicit braces. */ pop any inner levels that didn't have explicit braces. */
while (constructor_stack->implicit) while (constructor_stack->implicit)
process_init_element (pop_init_level (1)); process_init_element (pop_init_level (1));
if (constructor_range_stack)
abort ();
} }
p = constructor_stack; p = constructor_stack;
...@@ -5531,6 +5541,8 @@ pop_init_level (implicit) ...@@ -5531,6 +5541,8 @@ pop_init_level (implicit)
constructor_incremental = p->incremental; constructor_incremental = p->incremental;
constructor_pending_elts = p->pending_elts; constructor_pending_elts = p->pending_elts;
constructor_depth = p->depth; constructor_depth = p->depth;
if (!p->implicit)
constructor_range_stack = p->range_stack;
RESTORE_SPELLING_DEPTH (constructor_depth); RESTORE_SPELLING_DEPTH (constructor_depth);
constructor_stack = p->next; constructor_stack = p->next;
......
2001-01-27 Jakub Jelinek <jakub@redhat.com>
* gcc.dg/gnu99-init-1.c: Add 3 more designated range initializer
tests.
2001-01-25 Jeffrey Oldham <oldham@codesourcery.com> 2001-01-25 Jeffrey Oldham <oldham@codesourcery.com>
* gcc.c-torture/execute/ieee/20000320-1.c (main): For MIPS, change * gcc.c-torture/execute/ieee/20000320-1.c (main): For MIPS, change
......
...@@ -19,6 +19,11 @@ struct H m = { .J = {}, 3 }; ...@@ -19,6 +19,11 @@ struct H m = { .J = {}, 3 };
struct I { int J; int K[3]; int L; }; struct I { int J; int K[3]; int L; };
struct M { int N; struct I O[3]; int P; }; struct M { int N; struct I O[3]; int P; };
struct M n[] = { [0 ... 5].O[1 ... 2].K[0 ... 1] = 4, 5, 6, 7 }; struct M n[] = { [0 ... 5].O[1 ... 2].K[0 ... 1] = 4, 5, 6, 7 };
struct M o[] = { [0 ... 5].O = { [1 ... 2].K[0 ... 1] = 4 },
[5].O[2].K[2] = 5, 6, 7 };
struct M p[] = { [0 ... 5].O[1 ... 2].K = { [0 ... 1] = 4 },
[5].O[2].K[2] = 5, 6, 7 };
int q[3][3] = { [0 ... 1] = { [1 ... 2] = 23 }, [1][2] = 24 };
int main (void) int main (void)
{ {
...@@ -58,5 +63,15 @@ int main (void) ...@@ -58,5 +63,15 @@ int main (void)
} }
if (n[5].O[2].K[2] != 5 || n[5].O[2].L != 6 || n[5].P != 7) if (n[5].O[2].K[2] != 5 || n[5].O[2].L != 6 || n[5].P != 7)
abort (); abort ();
if (memcmp (n, o, sizeof (n)) || sizeof (n) != sizeof (o))
abort ();
if (memcmp (n, p, sizeof (n)) || sizeof (n) != sizeof (p))
abort ();
if (q[0][0] || q[0][1] != 23 || q[0][2] != 23)
abort ();
if (q[1][0] || q[1][1] != 23 || q[1][2] != 24)
abort ();
if (q[2][0] || q[2][1] || q[2][2])
abort ();
exit (0); exit (0);
} }
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