re PR c++/36069 (Strange "warning: suggest parentheses around assignment used as…

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
parent f9fc1a02
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> 2009-08-04 Dodji Seketeli <dodji@redhat.com>
PR c++/39987 PR c++/39987
......
...@@ -6790,11 +6790,14 @@ convert_for_assignment (tree type, tree rhs, ...@@ -6790,11 +6790,14 @@ convert_for_assignment (tree type, tree rhs,
&& type == boolean_type_node && type == boolean_type_node
&& TREE_CODE (rhs) == MODIFY_EXPR && TREE_CODE (rhs) == MODIFY_EXPR
&& !TREE_NO_WARNING (rhs) && !TREE_NO_WARNING (rhs)
&& TREE_TYPE (rhs) != boolean_type_node && TREE_CODE (TREE_TYPE (rhs)) != BOOLEAN_TYPE
&& (complain & tf_warning)) && (complain & tf_warning))
{ {
warning (OPT_Wparentheses, location_t loc = EXPR_HAS_LOCATION (rhs)
"suggest parentheses around assignment used as truth value"); ? EXPR_LOCATION (rhs) : input_location;
warning_at (loc, OPT_Wparentheses,
"suggest parentheses around assignment used as truth value");
TREE_NO_WARNING (rhs) = 1; TREE_NO_WARNING (rhs) = 1;
} }
......
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> 2009-08-04 Dodji Seketeli <dodji@redhat.com>
PR c++/39987 PR c++/39987
......
// 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;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment