Commit 0dae2d92 by Ian Lance Taylor Committed by Ian Lance Taylor

cvt.c (convert_to_void): Only warn about COND_EXPR if neither the second nor…

cvt.c (convert_to_void): Only warn about COND_EXPR if neither the second nor third operand has side effects.

cp/:
	* cvt.c (convert_to_void): Only warn about COND_EXPR if neither
	the second nor third operand has side effects.
testsuite/:
	* g++.dg/warn/Wunused-16.C: New testcase.

From-SVN: r148950
parent 98f80e91
2009-06-25 Ian Lance Taylor <iant@google.com>
* cvt.c (convert_to_void): Only warn about COND_EXPR if neither
the second nor third operand has side effects.
2009-06-25 Ian Lance Taylor <iant@google.com>
* parser.c (cp_parser_binary_expression): Increment
c_inhibit_evaluation_warnings while parsing the right hand side of
"true || x" or "false && x".
......
......@@ -828,11 +828,12 @@ convert_to_void (tree expr, const char *implicit, tsubst_flags_t complain)
/* The two parts of a cond expr might be separate lvalues. */
tree op1 = TREE_OPERAND (expr,1);
tree op2 = TREE_OPERAND (expr,2);
bool side_effects = TREE_SIDE_EFFECTS (op1) || TREE_SIDE_EFFECTS (op2);
tree new_op1 = convert_to_void
(op1, (implicit && !TREE_SIDE_EFFECTS (op2)
(op1, (implicit && !side_effects
? "second operand of conditional" : NULL), complain);
tree new_op2 = convert_to_void
(op2, (implicit && !TREE_SIDE_EFFECTS (op1)
(op2, (implicit && !side_effects
? "third operand of conditional" : NULL), complain);
expr = build3 (COND_EXPR, TREE_TYPE (new_op1),
......
2009-06-25 Ian Lance Taylor <iant@google.com>
* g++.dg/warn/Wunused-16.C: New testcase.
2009-06-25 Ian Lance Taylor <iant@google.com>
* g++.dg/warn/skip-2.C: New testcase.
2009-06-25 Steve Ellcey <sje@cup.hp.com>
......
// { dg-do compile }
// { dg-options "-Wunused-value" }
extern void f1();
void
f(bool b)
{
b ? f1(), 0 : 0; // { dg-bogus "has no effect" }
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment