aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/parser.c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2008-11-12 23:18:03 +0100
committerJakub Jelinek <jakub@gcc.gnu.org>2008-11-12 23:18:03 +0100
commit084eb83032ac2d343ac2e7d2b355ac0b12a02659 (patch)
tree60277d5e6bb370c59d9ff52ffd5e37282c1fdd45 /gcc/cp/parser.c
parent6b20f353f6c35385c5e473672ed373e4470df908 (diff)
downloadgcc-084eb83032ac2d343ac2e7d2b355ac0b12a02659.zip
gcc-084eb83032ac2d343ac2e7d2b355ac0b12a02659.tar.gz
gcc-084eb83032ac2d343ac2e7d2b355ac0b12a02659.tar.bz2
re PR c++/36478 (warning not emitted when code expanded from macro)
PR c++/36478 Revert: 2007-05-07 Mike Stump <mrs@apple.com> * doc/invoke.texi (Warning Options): Document that -Wempty-body also checks for and while statements in C++. Revert: 2007-05-07 Mike Stump <mrs@apple.com> * parser.c (check_empty_body): Add. (cp_parser_iteration_statement): Add call to check_empty_body. * g++.old-deja/g++.mike/empty.C: Remove. From-SVN: r141810
Diffstat (limited to 'gcc/cp/parser.c')
-rw-r--r--gcc/cp/parser.c44
1 files changed, 0 insertions, 44 deletions
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index ec9624e..ba8759c 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -7427,48 +7427,6 @@ cp_parser_condition (cp_parser* parser)
return cp_parser_expression (parser, /*cast_p=*/false);
}
-/* We check for a ) immediately followed by ; with no whitespacing
- between. This is used to issue a warning for:
-
- while (...);
-
- and:
-
- for (...);
-
- as the semicolon is probably extraneous.
-
- On parse errors, the next token might not be a ), so do nothing in
- that case. */
-
-static void
-check_empty_body (cp_parser* parser, const char* type)
-{
- cp_token *token;
- cp_token *close_paren;
- expanded_location close_loc;
- expanded_location semi_loc;
-
- close_paren = cp_lexer_peek_token (parser->lexer);
- if (close_paren->type != CPP_CLOSE_PAREN)
- return;
-
- close_loc = expand_location (close_paren->location);
- token = cp_lexer_peek_nth_token (parser->lexer, 2);
-
- if (token->type != CPP_SEMICOLON
- || (token->flags & PREV_WHITE))
- return;
-
- semi_loc = expand_location (token->location);
- if (close_loc.line == semi_loc.line
- && close_loc.column+1 == semi_loc.column)
- warning (OPT_Wempty_body,
- "suggest a space before %<;%> or explicit braces around empty "
- "body in %<%s%> statement",
- type);
-}
-
/* Parse an iteration-statement.
iteration-statement:
@@ -7511,7 +7469,6 @@ cp_parser_iteration_statement (cp_parser* parser)
/* Parse the condition. */
condition = cp_parser_condition (parser);
finish_while_stmt_cond (condition, statement);
- check_empty_body (parser, "while");
/* Look for the `)'. */
cp_parser_require (parser, CPP_CLOSE_PAREN, "%<)%>");
/* Parse the dependent statement. */
@@ -7573,7 +7530,6 @@ cp_parser_iteration_statement (cp_parser* parser)
if (cp_lexer_next_token_is_not (parser->lexer, CPP_CLOSE_PAREN))
expression = cp_parser_expression (parser, /*cast_p=*/false);
finish_for_expr (expression, statement);
- check_empty_body (parser, "for");
/* Look for the `)'. */
cp_parser_require (parser, CPP_CLOSE_PAREN, "%<)%>");