summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>2009-06-25 19:07:49 +0000
committerian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>2009-06-25 19:07:49 +0000
commit7e34c19db3b5b4f7d78b366f20cae896108a6a2f (patch)
tree6dd494a0b52b156fce06810ff15c4cbbaf141216
parent6dd536b9916f8e66cd1e6c29b2f18942f30d9f2d (diff)
downloadppe42-gcc-7e34c19db3b5b4f7d78b366f20cae896108a6a2f.tar.gz
ppe42-gcc-7e34c19db3b5b4f7d78b366f20cae896108a6a2f.zip
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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@148950 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/cp/ChangeLog5
-rw-r--r--gcc/cp/cvt.c5
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/g++.dg/warn/Wunused-16.C9
4 files changed, 21 insertions, 2 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 4e1f61080c5..e651c1d9ddd 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,10 @@
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".
diff --git a/gcc/cp/cvt.c b/gcc/cp/cvt.c
index dfd0ea81e75..88ae05a0e61 100644
--- a/gcc/cp/cvt.c
+++ b/gcc/cp/cvt.c
@@ -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),
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index cf0a4d9cccc..bf0fd4a1981 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,9 @@
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>
diff --git a/gcc/testsuite/g++.dg/warn/Wunused-16.C b/gcc/testsuite/g++.dg/warn/Wunused-16.C
new file mode 100644
index 00000000000..c9e57f79b54
--- /dev/null
+++ b/gcc/testsuite/g++.dg/warn/Wunused-16.C
@@ -0,0 +1,9 @@
+// { dg-do compile }
+// { dg-options "-Wunused-value" }
+
+extern void f1();
+void
+f(bool b)
+{
+ b ? f1(), 0 : 0; // { dg-bogus "has no effect" }
+}
OpenPOWER on IntegriCloud