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/cp | |
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/cp')
-rw-r--r-- | gcc/cp/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/cp/semantics.c | 11 |
2 files changed, 14 insertions, 2 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index e324712..1409d2b 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2007-03-14 Dirk Mueller <dmueller@suse.de> + + * cp/semantics.c (c_finish_if_stmt): Call empty_if_body_warning. + (finish_do_body): Warn about empty body in do/while statement. + 2007-03-14 Manuel Lopez-Ibanez <manu@gcc.gnu.org> * class.c (warn_hidden): Add OPT_Woverloaded_virtual to warning. diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index e016b0a..e260353 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -701,7 +701,7 @@ finish_if_stmt (tree if_stmt) TREE_CHAIN (if_stmt) = NULL; add_stmt (do_poplevel (scope)); finish_stmt (); - empty_body_warning (THEN_CLAUSE (if_stmt), ELSE_CLAUSE (if_stmt)); + empty_if_body_warning (THEN_CLAUSE (if_stmt), ELSE_CLAUSE (if_stmt)); } /* Begin a while-statement. Returns a newly created WHILE_STMT if @@ -754,7 +754,14 @@ begin_do_stmt (void) void finish_do_body (tree do_stmt) { - DO_BODY (do_stmt) = pop_stmt_list (DO_BODY (do_stmt)); + tree body = DO_BODY (do_stmt) = pop_stmt_list (DO_BODY (do_stmt)); + + if (TREE_CODE (body) == STATEMENT_LIST && STATEMENT_LIST_TAIL (body)) + body = STATEMENT_LIST_TAIL (body)->stmt; + + if (IS_EMPTY_STMT (body)) + warning (OPT_Wempty_body, + "suggest explicit braces around empty body in %<do%> statement"); } /* Finish a do-statement, which may be given by DO_STMT, and whose |