From 62e00e94746f4ec3c3205ddff90f78c2e06f88a4 Mon Sep 17 00:00:00 2001 From: Dirk Mueller Date: Wed, 14 Mar 2007 19:33:17 +0000 Subject: c-common.h (empty_body_warning): Rename to empty_if_body_warning. 2007-03-14 Dirk Mueller * 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 --- gcc/c-common.c | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) (limited to 'gcc/c-common.c') diff --git a/gcc/c-common.c b/gcc/c-common.c index f82a84b..36b87eb 100644 --- a/gcc/c-common.c +++ b/gcc/c-common.c @@ -1056,26 +1056,23 @@ strict_aliasing_warning (tree otype, tree type, tree expr) block. */ void -empty_body_warning (tree inner_then, tree inner_else) +empty_if_body_warning (tree inner_then, tree inner_else) { - if (warn_empty_body) - { - if (TREE_CODE (inner_then) == STATEMENT_LIST - && STATEMENT_LIST_TAIL (inner_then)) - inner_then = STATEMENT_LIST_TAIL (inner_then)->stmt; + if (TREE_CODE (inner_then) == STATEMENT_LIST + && STATEMENT_LIST_TAIL (inner_then)) + inner_then = STATEMENT_LIST_TAIL (inner_then)->stmt; - if (inner_else && TREE_CODE (inner_else) == STATEMENT_LIST - && STATEMENT_LIST_TAIL (inner_else)) - inner_else = STATEMENT_LIST_TAIL (inner_else)->stmt; + if (inner_else && TREE_CODE (inner_else) == STATEMENT_LIST + && STATEMENT_LIST_TAIL (inner_else)) + inner_else = STATEMENT_LIST_TAIL (inner_else)->stmt; - if (IS_EMPTY_STMT (inner_then) && !inner_else) - warning (OPT_Wempty_body, "%Hempty body in an if-statement", - EXPR_LOCUS (inner_then)); + if (IS_EMPTY_STMT (inner_then) && !inner_else) + warning (OPT_Wempty_body, "%Hsuggest braces around empty body " + "in an % statement", EXPR_LOCUS (inner_then)); - if (inner_else && IS_EMPTY_STMT (inner_else)) - warning (OPT_Wempty_body, "%Hempty body in an else-statement", - EXPR_LOCUS (inner_else)); - } + else if (inner_else && IS_EMPTY_STMT (inner_else)) + warning (OPT_Wempty_body, "%Hsuggest braces around empty body " + "in an % statement", EXPR_LOCUS (inner_else)); } /* Warn for unlikely, improbable, or stupid DECL declarations -- cgit v1.1