OSDN Git Service

2009-08-05 Manuel López-Ibáñez <manu@gcc.gnu.org>
authormanu <manu@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 4 Aug 2009 23:51:07 +0000 (23:51 +0000)
committermanu <manu@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 4 Aug 2009 23:51:07 +0000 (23:51 +0000)
PR c++/36069
cp/
* typeck.c (convert_for_assignment): Do not warn for any boolean
variant. Use explicit location.
testsuite/
* g++.dg/warn/pr36069.C: New.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@150471 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cp/ChangeLog
gcc/cp/typeck.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/warn/pr36069.C [new file with mode: 0644]

index 970b6dc..3e86ab3 100644 (file)
@@ -1,3 +1,9 @@
+2009-08-05  Manuel López-Ibáñez  <manu@gcc.gnu.org>
+
+       PR c++/36069
+       * typeck.c (convert_for_assignment): Do not warn for any boolean
+       variant. Use explicit location.
+
 2009-08-04  Dodji Seketeli  <dodji@redhat.com>
 
        PR c++/39987
index ef69f1d..de42af4 100644 (file)
@@ -6790,11 +6790,14 @@ convert_for_assignment (tree type, tree rhs,
       && type == boolean_type_node
       && TREE_CODE (rhs) == MODIFY_EXPR
       && !TREE_NO_WARNING (rhs)
-      && TREE_TYPE (rhs) != boolean_type_node
+      && TREE_CODE (TREE_TYPE (rhs)) != BOOLEAN_TYPE
       && (complain & tf_warning))
     {
-      warning (OPT_Wparentheses,
-              "suggest parentheses around assignment used as truth value");
+      location_t loc = EXPR_HAS_LOCATION (rhs) 
+       ? EXPR_LOCATION (rhs) : input_location;
+
+      warning_at (loc, OPT_Wparentheses,
+                 "suggest parentheses around assignment used as truth value");
       TREE_NO_WARNING (rhs) = 1;
     }
 
index 0d4378c..77238de 100644 (file)
@@ -1,3 +1,8 @@
+2009-08-05  Manuel López-Ibáñez  <manu@gcc.gnu.org>
+
+       PR c++/36069
+       * g++.dg/warn/pr36069.C: New.
+
 2009-08-04  Dodji Seketeli  <dodji@redhat.com>
 
        PR c++/39987
diff --git a/gcc/testsuite/g++.dg/warn/pr36069.C b/gcc/testsuite/g++.dg/warn/pr36069.C
new file mode 100644 (file)
index 0000000..efb35c2
--- /dev/null
@@ -0,0 +1,16 @@
+// PR c++/36069 Strange "warning: suggest parentheses around
+// assignment used as truth value" with volatile/non volatile bools
+// { dg-do compile }
+// { dg-options "-Wparentheses" }
+struct foo {
+  bool a;
+  volatile bool b,c;  
+  foo() { a = b = c = false; } // { dg-bogus "parentheses" }
+};
+
+int main() {
+  bool a;
+  volatile bool b,c;
+  a = b = c = false; // { dg-bogus "parentheses" }
+  foo A;
+}