From c2922bf8df232fd30adff7ee4314fdbe1f73db87 Mon Sep 17 00:00:00 2001 From: Luc Van Oostenryck Date: Mon, 7 Oct 2019 06:24:25 +0200 Subject: struct-attr: prepare to handle attributes at the end of struct definitions (1) Type attributes for struct can be placed either just after the keyword 'struct' or after the '}' ending its definition but this later case is currently ignored. Prepare the handling of this by factoring the code common to both cases in a single place. Signed-off-by: Luc Van Oostenryck --- parse.c | 10 +++++----- validation/parsing/enum-attr.c | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/parse.c b/parse.c index d6343f0e..41d3eb1f 100644 --- a/parse.c +++ b/parse.c @@ -745,12 +745,10 @@ static struct token *struct_union_enum_specifier(enum type type, if (sym->symbol_list) error_die(token->pos, "redefinition of %s", show_typename (sym)); sym->pos = *repos; - token = parse(token->next, sym); - token = expect(token, '}', "at end of struct-union-enum-specifier"); // Mark the structure as needing re-examination sym->examined = 0; - sym->endpos = token->pos; + goto end; } return token; } @@ -764,9 +762,11 @@ static struct token *struct_union_enum_specifier(enum type type, sym = alloc_symbol(token->pos, type); set_current_scope(sym); // used by dissect - token = parse(token->next, sym); ctx->ctype.base_type = sym; - token = expect(token, '}', "at end of specifier"); +end: + token = parse(token->next, sym); + token = expect(token, '}', "at end of specifier"); + sym->endpos = token->pos; return token; diff --git a/validation/parsing/enum-attr.c b/validation/parsing/enum-attr.c index a962d8b4..8d851a16 100644 --- a/validation/parsing/enum-attr.c +++ b/validation/parsing/enum-attr.c @@ -21,9 +21,9 @@ enum bad { parsing/enum-attr.c:10:15: error: typename in expression parsing/enum-attr.c:10:15: error: undefined identifier '__attribute__' parsing/enum-attr.c:10:15: error: bad constant expression type -parsing/enum-attr.c:10:22: error: Expected } at end of struct-union-enum-specifier +parsing/enum-attr.c:10:22: error: Expected } at end of specifier parsing/enum-attr.c:10:22: error: got 33 -parsing/enum-attr.c:14:18: error: Expected } at end of struct-union-enum-specifier +parsing/enum-attr.c:14:18: error: Expected } at end of specifier parsing/enum-attr.c:14:18: error: got __attribute__ * check-error-end */ -- cgit 1.2.3-korg