summaryrefslogtreecommitdiff
path: root/gcc/stmt.c
diff options
context:
space:
mode:
authornathan <nathan@138bc75d-0d04-0410-961f-82ee72b054a4>2003-08-16 13:32:11 +0000
committernathan <nathan@138bc75d-0d04-0410-961f-82ee72b054a4>2003-08-16 13:32:11 +0000
commit00fa9079fff8eb65ddbd0dab17e3ec4e6e3bd611 (patch)
tree0432e7399477735a910c874de61c6edf041c4dbe /gcc/stmt.c
parent0785e435c4757f7248b96902a01350c7b2060c32 (diff)
downloadgcc-00fa9079fff8eb65ddbd0dab17e3ec4e6e3bd611.tar.gz
PR c++/11512
* stmt.c (expand_expr_stmt_value): Don't warn about any void typed expression. cp: PR c++/11512 * cvt.c (convert_to_void): Indicate which side of conditional has no effects, and rhs of comma operator. Test for no sideeffect expressions here and always build a convert expr. * init.c (expand_default_init): Convert the init to void. * typeck.c (build_x_compound_expr): Do not check for side effects here. (build_compound_expr): Do not convert lhs when building a template. testsuite: PR C++/11512 * g++.dg/template/warn1.C: New. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@70505 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/stmt.c')
-rw-r--r--gcc/stmt.c14
1 files changed, 5 insertions, 9 deletions
diff --git a/gcc/stmt.c b/gcc/stmt.c
index 81661873c2c..defbb70df21 100644
--- a/gcc/stmt.c
+++ b/gcc/stmt.c
@@ -2152,17 +2152,13 @@ expand_expr_stmt_value (tree exp, int want_value, int maybe_last)
except for last statement in ({...}) where they may be useful. */
if (! want_value
&& (expr_stmts_for_value == 0 || ! maybe_last)
- && exp != error_mark_node)
+ && exp != error_mark_node
+ && warn_unused_value)
{
- if (! TREE_SIDE_EFFECTS (exp))
- {
- if (warn_unused_value
- && !(TREE_CODE (exp) == CONVERT_EXPR
- && VOID_TYPE_P (TREE_TYPE (exp))))
- warning ("%Hstatement with no effect", &emit_locus);
- }
- else if (warn_unused_value)
+ if (TREE_SIDE_EFFECTS (exp))
warn_if_unused_value (exp);
+ else if (!VOID_TYPE_P (TREE_TYPE (exp)))
+ warning ("%Hstatement with no effect", &emit_locus);
}
/* If EXP is of function type and we are expanding statements for