------- Comment #4 from hjl dot tools at gmail dot com 2008-09-30 16:10 ------- http://gcc.gnu.org/ml/gcc-patches/2008-08/msg01620.html
makes nested_if uninitialized for g++.dg/warn/Wparentheses-3.C: --- gcc/cp/parser.c (revision 138452) +++ gcc/cp/parser.c (working copy) @@ -7120,7 +7120,17 @@ cp_parser_selection_statement (cp_parser /* Parse the then-clause. */ in_statement = parser->in_statement; parser->in_statement |= IN_IF_STMT; - cp_parser_implicitly_scoped_statement (parser, &nested_if); + if (cp_lexer_next_token_is (parser->lexer, CPP_SEMICOLON)) + { + location_t loc = cp_lexer_peek_token (parser->lexer)->location; + add_stmt (build_empty_stmt ()); + cp_lexer_consume_token (parser->lexer); + if (!cp_lexer_next_token_is_keyword (parser->lexer, RID_ELSE)) + warning (OPT_Wempty_body, "%Hsuggest braces around " + "empty body in an %<if%> statement", &loc); + } + else + cp_parser_implicitly_scoped_statement (parser, &nested_if); parser->in_statement = in_statement; I saw this bug on Linux/ia32 and Linux/ia64. This patch: --- ./parser.c.foo 2008-09-30 08:41:24.000000000 -0700 +++ ./parser.c 2008-09-30 09:06:05.000000000 -0700 @@ -7163,6 +7163,7 @@ cp_parser_selection_statement (cp_parser if (!cp_lexer_next_token_is_keyword (parser->lexer, RID_ELSE)) warning_at (loc, OPT_Wempty_body, "suggest braces around " "empty body in an %<if%> statement"); + nested_if = false; } else cp_parser_implicitly_scoped_statement (parser, &nested_if); works for me. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37683