From 775e3ea067f4a25ba7629047c3f035dd632bc9f3 Mon Sep 17 00:00:00 2001 From: Matthias Braun Date: Tue, 18 Dec 2007 00:49:55 +0000 Subject: [PATCH] fix problems with local anonymous declarations [r18793] --- ast2firm.c | 3 +++ parser.c | 7 ++++--- parsetest/cp_error008.c | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/ast2firm.c b/ast2firm.c index 05e9157..4cc9da6 100644 --- a/ast2firm.c +++ b/ast2firm.c @@ -3110,6 +3110,9 @@ static ir_node *compound_statement_to_firm(compound_statement_t *compound) static void create_local_declaration(declaration_t *declaration) { + if(declaration->symbol == NULL) + return; + type_t *type = skip_typeref(declaration->type); switch ((storage_class_tag_t) declaration->storage_class) { diff --git a/parser.c b/parser.c index e1a6ac8..fd62ec3 100644 --- a/parser.c +++ b/parser.c @@ -2326,7 +2326,9 @@ static declaration_t *internal_record_declaration( check_type_of_main(declaration, &type->function); } - declaration_t *const previous_declaration = get_declaration(symbol, namespc); + assert(declaration->symbol != NULL); + declaration_t *previous_declaration = get_declaration(symbol, namespc); + assert(declaration != previous_declaration); if (previous_declaration != NULL) { if (previous_declaration->parent_scope == scope) { @@ -2442,7 +2444,6 @@ warn_redundant_declaration: } assert(declaration->parent_scope == NULL); - assert(declaration->symbol != NULL); assert(scope != NULL); declaration->parent_scope = scope; @@ -2649,7 +2650,7 @@ static void parse_declaration(parsed_declaration_func finished_declaration) parse_declaration_specifiers(&specifiers); if(token.type == ';') { - parse_anonymous_declaration_rest(&specifiers, finished_declaration); + parse_anonymous_declaration_rest(&specifiers, append_declaration); } else { declaration_t *declaration = parse_declarator(&specifiers, /*may_be_abstract=*/false); parse_declaration_rest(declaration, &specifiers, finished_declaration); diff --git a/parsetest/cp_error008.c b/parsetest/cp_error008.c index 22fdf82..28689a9 100644 --- a/parsetest/cp_error008.c +++ b/parsetest/cp_error008.c @@ -5,7 +5,7 @@ int FirstOne(long long arg1) long long d; }; - union doub xx; + union doub x; x.d = arg1; return x.i[2]; } -- 2.20.1