aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRichard Stallman <rms@gnu.org>1993-09-08 09:56:15 +0000
committerRichard Stallman <rms@gnu.org>1993-09-08 09:56:15 +0000
commit91fa3c30b74fe0a7dec2c0c5bae6adf0308da097 (patch)
tree409e63c7f573f68def4a61866bbe98edafae3493 /gcc
parent90b5a681ce9b838fa2b3075d4a2a8de18d5eee60 (diff)
downloadgcc-91fa3c30b74fe0a7dec2c0c5bae6adf0308da097.zip
gcc-91fa3c30b74fe0a7dec2c0c5bae6adf0308da097.tar.gz
gcc-91fa3c30b74fe0a7dec2c0c5bae6adf0308da097.tar.bz2
(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
Diffstat (limited to 'gcc')
-rw-r--r--gcc/c-typeck.c32
1 files changed, 27 insertions, 5 deletions
diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c
index e215b22..40207c4 100644
--- a/gcc/c-typeck.c
+++ b/gcc/c-typeck.c
@@ -5413,8 +5413,14 @@ push_init_level (implicit)
if (TREE_CODE (constructor_type) == RECORD_TYPE
|| TREE_CODE (constructor_type) == UNION_TYPE)
{
- constructor_type = TREE_TYPE (constructor_fields);
- push_member_name (IDENTIFIER_POINTER (DECL_NAME (constructor_fields)));
+ /* Don't die if there are extra init elts at the end. */
+ 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)
{
@@ -5425,8 +5431,15 @@ push_init_level (implicit)
/* Turn off constructor_incremental if type is a struct with bitfields. */
check_init_type_bitfields (constructor_type);
- if (TREE_CODE (constructor_type) == RECORD_TYPE
- || TREE_CODE (constructor_type) == UNION_TYPE)
+ if (constructor_type == 0)
+ {
+ 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_unfilled_fields = constructor_fields;
@@ -5495,7 +5508,9 @@ pop_init_level (implicit)
}
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. */
output_pending_init_elements (1);
@@ -5554,6 +5569,8 @@ pop_init_level (implicit)
output_constant (constructor, size);
}
}
+ else if (constructor_type == 0)
+ ;
else if (! constructor_incremental)
{
if (constructor_erroneous)
@@ -6051,6 +6068,11 @@ process_init_element (value)
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,
pop them now. */
while (constructor_stack->implicit)