Commit 91fa3c30 by Richard Stallman

(push_init_level): Diagnose extra brace group at end of record.

(push_init_level): Diagnose extra brace group at end
of record.  Set constructor_type to 0.
(pop_init_level): Don't output anything if constructor_type is 0.
(process_init_element): Do nothing if constructor_type is 0.

From-SVN: r5279
parent 90b5a681
...@@ -5413,8 +5413,14 @@ push_init_level (implicit) ...@@ -5413,8 +5413,14 @@ push_init_level (implicit)
if (TREE_CODE (constructor_type) == RECORD_TYPE if (TREE_CODE (constructor_type) == RECORD_TYPE
|| TREE_CODE (constructor_type) == UNION_TYPE) || TREE_CODE (constructor_type) == UNION_TYPE)
{ {
constructor_type = TREE_TYPE (constructor_fields); /* Don't die if there are extra init elts at the end. */
push_member_name (IDENTIFIER_POINTER (DECL_NAME (constructor_fields))); if (constructor_fields == 0)
constructor_type = 0;
else
{
constructor_type = TREE_TYPE (constructor_fields);
push_member_name (IDENTIFIER_POINTER (DECL_NAME (constructor_fields)));
}
} }
else if (TREE_CODE (constructor_type) == ARRAY_TYPE) else if (TREE_CODE (constructor_type) == ARRAY_TYPE)
{ {
...@@ -5425,8 +5431,15 @@ push_init_level (implicit) ...@@ -5425,8 +5431,15 @@ push_init_level (implicit)
/* Turn off constructor_incremental if type is a struct with bitfields. */ /* Turn off constructor_incremental if type is a struct with bitfields. */
check_init_type_bitfields (constructor_type); check_init_type_bitfields (constructor_type);
if (TREE_CODE (constructor_type) == RECORD_TYPE if (constructor_type == 0)
|| TREE_CODE (constructor_type) == UNION_TYPE) {
error_init ("extra brace group at end of initializer%s",
" for `%s'", NULL);
constructor_fields = 0;
constructor_unfilled_fields = 0;
}
else if (TREE_CODE (constructor_type) == RECORD_TYPE
|| TREE_CODE (constructor_type) == UNION_TYPE)
{ {
constructor_fields = TYPE_FIELDS (constructor_type); constructor_fields = TYPE_FIELDS (constructor_type);
constructor_unfilled_fields = constructor_fields; constructor_unfilled_fields = constructor_fields;
...@@ -5495,7 +5508,9 @@ pop_init_level (implicit) ...@@ -5495,7 +5508,9 @@ pop_init_level (implicit)
} }
p = constructor_stack; p = constructor_stack;
size = int_size_in_bytes (constructor_type);
if (constructor_type != 0)
size = int_size_in_bytes (constructor_type);
/* Now output all pending elements. */ /* Now output all pending elements. */
output_pending_init_elements (1); output_pending_init_elements (1);
...@@ -5554,6 +5569,8 @@ pop_init_level (implicit) ...@@ -5554,6 +5569,8 @@ pop_init_level (implicit)
output_constant (constructor, size); output_constant (constructor, size);
} }
} }
else if (constructor_type == 0)
;
else if (! constructor_incremental) else if (! constructor_incremental)
{ {
if (constructor_erroneous) if (constructor_erroneous)
...@@ -6051,6 +6068,11 @@ process_init_element (value) ...@@ -6051,6 +6068,11 @@ process_init_element (value)
return; return;
} }
/* Ignore elements of a brace group if it is entirely superfluous
and has already been diagnosed. */
if (constructor_type == 0)
return;
/* If we've exhausted any levels that didn't have braces, /* If we've exhausted any levels that didn't have braces,
pop them now. */ pop them now. */
while (constructor_stack->implicit) while (constructor_stack->implicit)
......
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