diff options
author | Manuel López-Ibáñez <manu@gcc.gnu.org> | 2009-08-04 23:51:07 +0000 |
---|---|---|
committer | Manuel López-Ibáñez <manu@gcc.gnu.org> | 2009-08-04 23:51:07 +0000 |
commit | 69fb98321197c0223455e69dbab1525637e46fc5 (patch) | |
tree | 87cf43e047f319f07a7a6834529d8e73431e3cc3 | |
parent | f9fc1a02d7cadbbb9aba35776150929c9cb7dcb9 (diff) | |
download | gcc-69fb98321197c0223455e69dbab1525637e46fc5.zip gcc-69fb98321197c0223455e69dbab1525637e46fc5.tar.gz gcc-69fb98321197c0223455e69dbab1525637e46fc5.tar.bz2 |
re PR c++/36069 (Strange "warning: suggest parentheses around assignment used as truth value" with volatile/non volatile bools)
2009-08-05 Manuel López-Ibáñez <manu@gcc.gnu.org>
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.
From-SVN: r150471
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/typeck.c | 9 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/warn/pr36069.C | 16 |
4 files changed, 33 insertions, 3 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 970b6dc..3e86ab3 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -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 diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index ef69f1d..de42af4 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -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; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 0d4378c..77238de 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -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 index 0000000..efb35c2 --- /dev/null +++ b/gcc/testsuite/g++.dg/warn/pr36069.C @@ -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; +} |