diff options
author | Dirk Mueller <dmueller@suse.de> | 2007-03-14 19:33:17 +0000 |
---|---|---|
committer | Dirk Mueller <mueller@gcc.gnu.org> | 2007-03-14 19:33:17 +0000 |
commit | 62e00e94746f4ec3c3205ddff90f78c2e06f88a4 (patch) | |
tree | 6eaa29a86e707ec20730717f602d38ed322cf784 /gcc/c-parser.c | |
parent | adea5e16e4e86438f97cfdd3fabb5654c45f9d61 (diff) | |
download | gcc-62e00e94746f4ec3c3205ddff90f78c2e06f88a4.zip gcc-62e00e94746f4ec3c3205ddff90f78c2e06f88a4.tar.gz gcc-62e00e94746f4ec3c3205ddff90f78c2e06f88a4.tar.bz2 |
c-common.h (empty_body_warning): Rename to empty_if_body_warning.
2007-03-14 Dirk Mueller <dmueller@suse.de>
* c-common.h (empty_body_warning): Rename to empty_if_body_warning.
* c-common.c (empty_if_body_warning): Rephrase diagnostic message.
* c-parser.c (c_parser_if_body): Always add an empty statement in case
of empty body.
* c-parser.c (c_parser_do_statement): Warn about empty body in
do/while statement.
* c-typeck (c_finish_if_stmt): Call empty_if_body_warning.
* doc/invoke.texi (-Wempty-body): Update documentation.
* cp/semantics.c (c_finish_if_stmt): Call empty_if_body_warning.
(finish_do_body): Warn about empty body in do/while statement.
* g++.dg/warn/do-empty.C: New.
* gcc.dg/do-empty.c: New.
* gcc.dg/if-empty-1.c: Update.
* gcc.dg/20001116-1.c: Update.
* gcc.dg/pr23165.c: Update.
From-SVN: r122928
Diffstat (limited to 'gcc/c-parser.c')
-rw-r--r-- | gcc/c-parser.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/gcc/c-parser.c b/gcc/c-parser.c index 665b494..b1f40a4 100644 --- a/gcc/c-parser.c +++ b/gcc/c-parser.c @@ -3844,7 +3844,7 @@ c_parser_if_body (c_parser *parser, bool *if_p) && c_parser_peek_2nd_token (parser)->type == CPP_COLON)) c_parser_label (parser); *if_p = c_parser_next_token_is_keyword (parser, RID_IF); - if (warn_empty_body && c_parser_next_token_is (parser, CPP_SEMICOLON)) + if (c_parser_next_token_is (parser, CPP_SEMICOLON)) add_stmt (build_empty_stmt ()); c_parser_statement_after_labels (parser); return c_end_compound_stmt (block, flag_isoc99); @@ -3953,6 +3953,9 @@ c_parser_do_statement (c_parser *parser) location_t loc; gcc_assert (c_parser_next_token_is_keyword (parser, RID_DO)); c_parser_consume_token (parser); + if (c_parser_next_token_is (parser, CPP_SEMICOLON)) + warning (OPT_Wempty_body, + "suggest braces around empty body in %<do%> statement"); block = c_begin_compound_stmt (flag_isoc99); loc = c_parser_peek_token (parser)->location; save_break = c_break_label; |