From: Manuel López-Ibáñez Date: Tue, 4 Aug 2009 23:51:07 +0000 (+0000) Subject: re PR c++/36069 (Strange "warning: suggest parentheses around assignment used as... X-Git-Tag: releases/gcc-4.5.0~4179 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=69fb98321197c0223455e69dbab1525637e46fc5;p=thirdparty%2Fgcc.git 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 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 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 970b6dc51524..3e86ab387635 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2009-08-05 Manuel López-Ibáñez + + PR c++/36069 + * typeck.c (convert_for_assignment): Do not warn for any boolean + variant. Use explicit location. + 2009-08-04 Dodji Seketeli PR c++/39987 diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index ef69f1d94664..de42af409da0 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 0d4378cfc0ab..77238de44b5b 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2009-08-05 Manuel López-Ibáñez + + PR c++/36069 + * g++.dg/warn/pr36069.C: New. + 2009-08-04 Dodji Seketeli 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 000000000000..efb35c25716a --- /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; +}