From e3549c2ccb4c41304d643dd12c3e2cce7ff03ef3 Mon Sep 17 00:00:00 2001 From: Christoph Mallon Date: Mon, 17 Nov 2008 10:53:01 +0000 Subject: [PATCH] Merge semantic_compound() into parse_compound_declarators(). [r23722] --- parser.c | 44 ++++++++++++++++++-------------------------- 1 file changed, 18 insertions(+), 26 deletions(-) diff --git a/parser.c b/parser.c index 4b61108..a33a328 100644 --- a/parser.c +++ b/parser.c @@ -6142,40 +6142,33 @@ static void parse_compound_declarators(compound_t *compound, append_entity(&compound->members, entity); - if (token.type != ',') - break; - next_token(); - } - expect(';'); - -end_error: - ; -} - -static void semantic_compound(compound_t *compound) -{ - entity_t *entity = compound->members.entities; - for ( ; entity != NULL; entity = entity->base.next) { - assert(entity->kind == ENTITY_COMPOUND_MEMBER); - type_t *orig_type = entity->declaration.type; type_t *type = skip_typeref(orig_type); - if (is_type_function(type)) { - errorf(HERE, - "compound member '%Y' must not have function type '%T'", - entity->base.symbol, orig_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) && entity->base.next == NULL) { + /* §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(HERE, - "compound member '%Y' has incomplete type '%T'", - entity->base.symbol, orig_type); + errorf(&entity->base.source_position, + "compound member '%Y' has incomplete type '%T'", + entity->base.symbol, orig_type); } } + + if (token.type != ',') + break; + next_token(); } + expect(';'); + +end_error: + ; } static void parse_compound_type_entries(compound_t *compound) @@ -6194,7 +6187,6 @@ static void parse_compound_type_entries(compound_t *compound) parse_compound_declarators(compound, &specifiers); } - semantic_compound(compound); rem_anchor_token('}'); next_token(); -- 2.20.1