From a30efae8b9de7699ea70dbf48291466ab2dcd5c6 Mon Sep 17 00:00:00 2001 From: Gabriel Dos Reis Date: Fri, 9 Sep 2005 23:07:55 +0000 Subject: [PATCH] parser.c (cp_parser_translation_unit): Simplify. * parser.c (cp_parser_translation_unit): Simplify. The while-block was actually executed at most once. From-SVN: r104115 --- gcc/cp/ChangeLog | 5 +++++ gcc/cp/parser.c | 57 ++++++++++++++++++++++-------------------------- 2 files changed, 31 insertions(+), 31 deletions(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 7aa392f7464f..012b6e20fcfa 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2005-09-09 Gabriel Dos Reis + + * parser.c (cp_parser_translation_unit): Simplify. The while-block + was actually executed at most once. + 2005-09-09 Richard Henderson PR debug/20998 diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index e979e939b10c..a8a2c4963e7b 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -2656,39 +2656,34 @@ cp_parser_translation_unit (cp_parser* parser) declarator_obstack_base = obstack_next_free (&declarator_obstack); } - while (true) + cp_parser_declaration_seq_opt (parser); + + /* If there are no tokens left then all went well. */ + if (cp_lexer_next_token_is (parser->lexer, CPP_EOF)) { - cp_parser_declaration_seq_opt (parser); - - /* If there are no tokens left then all went well. */ - if (cp_lexer_next_token_is (parser->lexer, CPP_EOF)) - { - /* Get rid of the token array; we don't need it any more. */ - cp_lexer_destroy (parser->lexer); - parser->lexer = NULL; - - /* This file might have been a context that's implicitly extern - "C". If so, pop the lang context. (Only relevant for PCH.) */ - if (parser->implicit_extern_c) - { - pop_lang_context (); - parser->implicit_extern_c = false; - } - - /* Finish up. */ - finish_translation_unit (); - - success = true; - break; - } - else - { - cp_parser_error (parser, "expected declaration"); - success = false; - break; - } + /* Get rid of the token array; we don't need it any more. */ + cp_lexer_destroy (parser->lexer); + parser->lexer = NULL; + + /* This file might have been a context that's implicitly extern + "C". If so, pop the lang context. (Only relevant for PCH.) */ + if (parser->implicit_extern_c) + { + pop_lang_context (); + parser->implicit_extern_c = false; + } + + /* Finish up. */ + finish_translation_unit (); + + success = true; } - + else + { + cp_parser_error (parser, "expected declaration"); + success = false; + } + /* Make sure the declarator obstack was fully cleaned up. */ gcc_assert (obstack_next_free (&declarator_obstack) == declarator_obstack_base); -- 2.47.2