Omit semantic tests in parse_compound_declarators(), which do not apply to (anonymous...
authorChristoph Mallon <christoph.mallon@gmx.de>
Thu, 11 Dec 2008 21:15:40 +0000 (21:15 +0000)
committerChristoph Mallon <christoph.mallon@gmx.de>
Thu, 11 Dec 2008 21:15:40 +0000 (21:15 +0000)
[r24547]

parser.c

index 261ba6e..d570caf 100644 (file)
--- a/parser.c
+++ b/parser.c
@@ -6514,54 +6514,54 @@ static void parse_compound_declarators(compound_t *compound,
                        entity->declaration.storage_class          = STORAGE_CLASS_NONE;
                        entity->declaration.modifiers              = specifiers->modifiers;
                        entity->declaration.type                   = type;
+                       append_entity(&compound->members, entity);
                } else {
                        entity = parse_declarator(specifiers,
                                        DECL_MAY_BE_ABSTRACT | DECL_CREATE_COMPOUND_MEMBER);
                        assert(entity->kind == ENTITY_COMPOUND_MEMBER);
 
+                       /* make sure we don't define a symbol multiple times */
+                       symbol_t *symbol = entity->base.symbol;
+                       if (symbol != NULL) {
+                               entity_t *prev = find_compound_entry(compound, symbol);
+                               if (prev != NULL) {
+                                       errorf(&entity->base.source_position,
+                                                       "multiple declarations of symbol '%Y' (declared %P)",
+                                                       symbol, &prev->base.source_position);
+                               }
+                       }
+
                        if (token.type == ':') {
                                source_position_t source_position = *HERE;
                                next_token();
                                expression_t *size = parse_constant_expression();
 
-                               type_t *type = entity->declaration.type;
+                               type_t *type          = entity->declaration.type;
                                type_t *bitfield_type = make_bitfield_type(type, size,
                                                &source_position, entity->base.symbol);
                                entity->declaration.type = bitfield_type;
-                       }
-               }
-
-               /* make sure we don't define a symbol multiple times */
-               symbol_t *symbol = entity->base.symbol;
-               if (symbol != NULL) {
-                       entity_t *prev = find_compound_entry(compound, symbol);
-
-                       if (prev != NULL) {
-                               errorf(&entity->base.source_position,
-                                      "multiple declarations of symbol '%Y' (declared %P)",
-                                      symbol, &prev->base.source_position);
-                       }
-               }
-
-               append_entity(&compound->members, entity);
-
-               type_t *orig_type = entity->declaration.type;
-               type_t *type      = skip_typeref(orig_type);
-               if (is_type_function(type)) {
-                       errorf(&entity->base.source_position,
-                                       "compound member '%Y' must not have function type '%T'",
-                                       entity->base.symbol, orig_type);
-               } else if (is_type_incomplete(type)) {
-                       /* §6.7.2.1:16 flexible array member */
-                       if (is_type_array(type) &&
-                                       token.type == ';'   &&
-                                       look_ahead(1)->type == '}') {
-                               compound->has_flexible_member = true;
                        } else {
-                               errorf(&entity->base.source_position,
-                                               "compound member '%Y' has incomplete type '%T'",
-                                               entity->base.symbol, orig_type);
+                               type_t *orig_type = entity->declaration.type;
+                               type_t *type      = skip_typeref(orig_type);
+                               if (is_type_function(type)) {
+                                       errorf(&entity->base.source_position,
+                                                       "compound member '%Y' must not have function type '%T'",
+                                                       entity->base.symbol, orig_type);
+                               } else if (is_type_incomplete(type)) {
+                                       /* §6.7.2.1:16 flexible array member */
+                                       if (is_type_array(type) &&
+                                                       token.type == ';'   &&
+                                                       look_ahead(1)->type == '}') {
+                                               compound->has_flexible_member = true;
+                                       } else {
+                                               errorf(&entity->base.source_position,
+                                                               "compound member '%Y' has incomplete type '%T'",
+                                                               entity->base.symbol, orig_type);
+                                       }
+                               }
                        }
+
+                       append_entity(&compound->members, entity);
                }
 
                if (token.type != ',')