aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@google.com>2007-01-23 21:46:51 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2007-01-23 21:46:51 +0000
commita99e5cb4d8364de480cbad919100b74ce7b0d378 (patch)
tree15e3da15ba1cd60e0a23fb47dab5b5cfbd247c17
parent38fbab2a179ffa334abe76d60771662d7e07287f (diff)
downloadgcc-a99e5cb4d8364de480cbad919100b74ce7b0d378.zip
gcc-a99e5cb4d8364de480cbad919100b74ce7b0d378.tar.gz
gcc-a99e5cb4d8364de480cbad919100b74ce7b0d378.tar.bz2
typeck.c (convert_for_assignment): Only warn about a = b = c when converting to bool.
cp/: * typeck.c (convert_for_assignment): Only warn about a = b = c when converting to bool. testsuite/: * g++.dg/warn/Wparentheses-24.C: New test. From-SVN: r121087
-rw-r--r--gcc/cp/ChangeLog5
-rw-r--r--gcc/cp/typeck.c6
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/g++.dg/warn/Wparentheses-24.C14
4 files changed, 27 insertions, 2 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 906aabf..65366bb 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,8 @@
+2007-01-23 Ian Lance Taylor <iant@google.com>
+
+ * typeck.c (convert_for_assignment): Only warn about a = b = c
+ when converting to bool.
+
2007-01-23 Roger Sayle <roger@eyesopen.com>
* call.c (null_ptr_cst_p): Replace use of TREE_CONSTANT_OVERFLOW with
diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index fa58a57..709d25b 100644
--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -6380,11 +6380,13 @@ convert_for_assignment (tree type, tree rhs,
errtype);
}
- /* If -Wparentheses, warn about a = b = c when a has type bool. */
+ /* If -Wparentheses, warn about a = b = c when a has type bool and b
+ does not. */
if (warn_parentheses
&& type == boolean_type_node
&& TREE_CODE (rhs) == MODIFY_EXPR
- && !TREE_NO_WARNING (rhs))
+ && !TREE_NO_WARNING (rhs)
+ && TREE_TYPE (rhs) != boolean_type_node)
{
warning (OPT_Wparentheses,
"suggest parentheses around assignment used as truth value");
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 11b3bda..81f1370 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2007-01-23 Ian Lance Taylor <iant@google.com>
+
+ * g++.dg/warn/Wparentheses-24.C: New test.
+
2007-01-23 Richard Guenther <rguenther@suse.de>
PR testsuite/30560
diff --git a/gcc/testsuite/g++.dg/warn/Wparentheses-24.C b/gcc/testsuite/g++.dg/warn/Wparentheses-24.C
new file mode 100644
index 0000000..4019d3d
--- /dev/null
+++ b/gcc/testsuite/g++.dg/warn/Wparentheses-24.C
@@ -0,0 +1,14 @@
+// { dg-do compile }
+// { dg-options "-Wparentheses" }
+
+extern int foo (int);
+
+bool a, b, c;
+
+bool
+bar ()
+{
+ c = a = b;
+ foo (0);
+ return a = b;
+}