Hi,I just wanted to upload the attached files to gcc bugzilla entry #39028, but I always hit a bugzilla bug. Could you please attach these files to the bug for me?
Thank you. Regards Stephan
commit a9f24d7b25568b3fde13ae406deb1aeeacf45e23 Author: Stephan Springl <stephan-...@springl.homeip.net> Date: Thu Jan 29 20:00:31 2009 +0100 fix diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 5baf5f5..e5bc7f7 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -153,6 +153,13 @@ typedef struct cp_token_cache GTY(()) cp_token * GTY ((skip)) last; } cp_token_cache; +enum cp_scope_begin +{ + cp_scope_begin_do, + cp_scope_begin_try, + cp_scope_begin_dont +}; + /* Prototypes. */ static cp_lexer *cp_lexer_new_main @@ -1639,7 +1646,7 @@ static void cp_parser_label_for_labeled_statement static tree cp_parser_expression_statement (cp_parser *, tree); static tree cp_parser_compound_statement - (cp_parser *, tree, bool); + (cp_parser *, tree, enum cp_scope_begin); static void cp_parser_statement_seq_opt (cp_parser *, tree); static tree cp_parser_selection_statement @@ -3243,7 +3250,7 @@ cp_parser_primary_expression (cp_parser *parser, /* Start the statement-expression. */ expr = begin_stmt_expr (); /* Parse the compound-statement. */ - cp_parser_compound_statement (parser, expr, false); + cp_parser_compound_statement (parser, expr, cp_scope_begin_do); /* Finish up. */ expr = finish_stmt_expr (expr, false); } @@ -6959,7 +6966,7 @@ cp_parser_statement (cp_parser* parser, tree in_statement_expr, } /* Anything that starts with a `{' must be a compound-statement. */ else if (token->type == CPP_OPEN_BRACE) - statement = cp_parser_compound_statement (parser, NULL, false); + statement = cp_parser_compound_statement (parser, NULL, cp_scope_begin_do); /* CPP_PRAGMA is a #pragma inside a function body, which constitutes a statement all its own. */ else if (token->type == CPP_PRAGMA) @@ -7143,22 +7150,25 @@ cp_parser_expression_statement (cp_parser* parser, tree in_statement_expr) static tree cp_parser_compound_statement (cp_parser *parser, tree in_statement_expr, - bool in_try) + enum cp_scope_begin scope_begin) { - tree compound_stmt; + tree compound_stmt = NULL_TREE; /* Consume the `{'. */ if (!cp_parser_require (parser, CPP_OPEN_BRACE, "%<{%>")) return error_mark_node; /* Begin the compound-statement. */ - compound_stmt = begin_compound_stmt (in_try ? BCS_TRY_BLOCK : 0); + if (scope_begin != cp_scope_begin_dont) + compound_stmt = begin_compound_stmt (scope_begin == cp_scope_begin_try ? + BCS_TRY_BLOCK : 0); /* If the next keyword is `__label__' we have a label declaration. */ while (cp_lexer_next_token_is_keyword (parser->lexer, RID_LABEL)) cp_parser_label_declaration (parser); /* Parse an (optional) statement-seq. */ cp_parser_statement_seq_opt (parser, in_statement_expr); /* Finish the compound-statement. */ - finish_compound_stmt (compound_stmt); + if (scope_begin != cp_scope_begin_dont) + finish_compound_stmt (compound_stmt); /* Consume the `}'. */ cp_parser_require (parser, CPP_CLOSE_BRACE, "%<}%>"); @@ -7812,7 +7822,7 @@ cp_parser_implicitly_scoped_statement (cp_parser* parser, bool *if_p) } /* if a compound is opened, we simply parse the statement directly. */ else if (cp_lexer_next_token_is (parser->lexer, CPP_OPEN_BRACE)) - statement = cp_parser_compound_statement (parser, NULL, false); + statement = cp_parser_compound_statement (parser, NULL, cp_scope_begin_do); /* If the token is not a `{', then we must take special action. */ else { @@ -7840,13 +7850,7 @@ cp_parser_already_scoped_statement (cp_parser* parser) if (cp_lexer_next_token_is_not (parser->lexer, CPP_OPEN_BRACE)) cp_parser_statement (parser, NULL_TREE, false, NULL); else - { - /* Avoid calling cp_parser_compound_statement, so that we - don't create a new scope. Do everything else by hand. */ - cp_parser_require (parser, CPP_OPEN_BRACE, "%<{%>"); - cp_parser_statement_seq_opt (parser, NULL_TREE); - cp_parser_require (parser, CPP_CLOSE_BRACE, "%<}%>"); - } + cp_parser_compound_statement (parser, NULL, cp_scope_begin_dont); } /* Declarations [gram.dcl.dcl] */ @@ -14464,7 +14468,7 @@ cp_parser_default_argument (cp_parser *parser, bool template_parm_p) static void cp_parser_function_body (cp_parser *parser) { - cp_parser_compound_statement (parser, NULL, false); + cp_parser_compound_statement (parser, NULL, cp_scope_begin_do); } /* Parse a ctor-initializer-opt followed by a function-body. Return @@ -16374,7 +16378,7 @@ cp_parser_try_block (cp_parser* parser) cp_parser_require_keyword (parser, RID_TRY, "%<try%>"); try_block = begin_try_block (); - cp_parser_compound_statement (parser, NULL, true); + cp_parser_compound_statement (parser, NULL, cp_scope_begin_try); finish_try_block (try_block); cp_parser_handler_seq (parser); finish_handler_sequence (try_block); @@ -16451,7 +16455,7 @@ cp_parser_handler (cp_parser* parser) declaration = cp_parser_exception_declaration (parser); finish_handler_parms (declaration, handler); cp_parser_require (parser, CPP_CLOSE_PAREN, "%<)%>"); - cp_parser_compound_statement (parser, NULL, false); + cp_parser_compound_statement (parser, NULL, cp_scope_begin_do); finish_handler (handler); } @@ -20027,7 +20031,7 @@ cp_parser_objc_try_catch_finally_statement (cp_parser *parser) { /* NB: The @try block needs to be wrapped in its own STATEMENT_LIST node, lest it get absorbed into the surrounding block. */ stmt = push_stmt_list (); - cp_parser_compound_statement (parser, NULL, false); + cp_parser_compound_statement (parser, NULL, cp_scope_begin_do); objc_begin_try_stmt (location, pop_stmt_list (stmt)); while (cp_lexer_next_token_is_keyword (parser->lexer, RID_AT_CATCH)) @@ -20044,7 +20048,7 @@ cp_parser_objc_try_catch_finally_statement (cp_parser *parser) { /*attrlist=*/NULL); cp_parser_require (parser, CPP_CLOSE_PAREN, "%<)%>"); objc_begin_catch_clause (parm); - cp_parser_compound_statement (parser, NULL, false); + cp_parser_compound_statement (parser, NULL, cp_scope_begin_do); objc_finish_catch_clause (); } @@ -20055,7 +20059,7 @@ cp_parser_objc_try_catch_finally_statement (cp_parser *parser) { /* NB: The @finally block needs to be wrapped in its own STATEMENT_LIST node, lest it get absorbed into the surrounding block. */ stmt = push_stmt_list (); - cp_parser_compound_statement (parser, NULL, false); + cp_parser_compound_statement (parser, NULL, cp_scope_begin_do); objc_build_finally_clause (location, pop_stmt_list (stmt)); } @@ -20084,7 +20088,7 @@ cp_parser_objc_synchronized_statement (cp_parser *parser) { /* NB: The @synchronized block needs to be wrapped in its own STATEMENT_LIST node, lest it get absorbed into the surrounding block. */ stmt = push_stmt_list (); - cp_parser_compound_statement (parser, NULL, false); + cp_parser_compound_statement (parser, NULL, cp_scope_begin_do); return objc_build_synchronized (location, lock, pop_stmt_list (stmt)); } diff --git a/gcc/testsuite/g++.dg/ext/label8.C b/gcc/testsuite/g++.dg/ext/label8.C index 1f6175d..f7704ee 100644 --- a/gcc/testsuite/g++.dg/ext/label8.C +++ b/gcc/testsuite/g++.dg/ext/label8.C @@ -11,12 +11,41 @@ int f (void) { __label__ d; d:; - if (0) + do { + __label__ a; __label__ e; __label__ f; f:; e:; + a:; + } while (0); + for (; 0;) + { + __label__ a; + __label__ g; + __label__ h; + h:; + g:; + a:; + } + if (0) + { + __label__ a; + __label__ i; + __label__ j; + j:; + i:; + a:; + } + while (0) + { + __label__ a; + __label__ k; + __label__ l; + l:; + k:; + a:; } } }
commit 27a7db3a184dce084396228a58f983c284a1e7d3 Author: Stephan Springl <stephan-...@springl.homeip.net> Date: Thu Jan 29 20:55:23 2009 +0100 fix 1 diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 5baf5f5..c0a51b5 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -7844,6 +7844,9 @@ cp_parser_already_scoped_statement (cp_parser* parser) /* Avoid calling cp_parser_compound_statement, so that we don't create a new scope. Do everything else by hand. */ cp_parser_require (parser, CPP_OPEN_BRACE, "%<{%>"); + /* If the next keyword is `__label__' we have a label declaration. */ + while (cp_lexer_next_token_is_keyword (parser->lexer, RID_LABEL)) + cp_parser_label_declaration (parser); cp_parser_statement_seq_opt (parser, NULL_TREE); cp_parser_require (parser, CPP_CLOSE_BRACE, "%<}%>"); } diff --git a/gcc/testsuite/g++.dg/ext/label8.C b/gcc/testsuite/g++.dg/ext/label8.C index 1f6175d..f7704ee 100644 --- a/gcc/testsuite/g++.dg/ext/label8.C +++ b/gcc/testsuite/g++.dg/ext/label8.C @@ -11,12 +11,41 @@ int f (void) { __label__ d; d:; - if (0) + do { + __label__ a; __label__ e; __label__ f; f:; e:; + a:; + } while (0); + for (; 0;) + { + __label__ a; + __label__ g; + __label__ h; + h:; + g:; + a:; + } + if (0) + { + __label__ a; + __label__ i; + __label__ j; + j:; + i:; + a:; + } + while (0) + { + __label__ a; + __label__ k; + __label__ l; + l:; + k:; + a:; } } }
void c (void) { for (;;) {__label__ l; goto l; l:;} while (1) {__label__ l; goto l; l:;} if (1) {__label__ l; goto l; l:;} do {__label__ l; goto l; l:;} while (1); {__label__ l; goto l; l:;} }