re PR c++/51064 (False Positive for -Wparentheses)

/cp
2012-01-04  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/51064
	* pt.c (tsubst_copy_and_build): Maybe set TREE_NO_WARNING on
	the tree returned by build_x_binary_op.

/testsuite
2012-01-04  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/51064
	* g++.dg/warn/Wparentheses-26.C: New.

From-SVN: r182880
This commit is contained in:
Paolo Carlini 2012-01-04 16:39:53 +00:00 committed by Paolo Carlini
parent e2b30a4441
commit a10bf1f989
4 changed files with 54 additions and 12 deletions

View File

@ -1,3 +1,9 @@
2012-01-04 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/51064
* pt.c (tsubst_copy_and_build): Maybe set TREE_NO_WARNING on
the tree returned by build_x_binary_op.
2012-01-03 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/51738

View File

@ -13563,18 +13563,23 @@ tsubst_copy_and_build (tree t,
case GT_EXPR:
case MEMBER_REF:
case DOTSTAR_EXPR:
return build_x_binary_op
(TREE_CODE (t),
RECUR (TREE_OPERAND (t, 0)),
(TREE_NO_WARNING (TREE_OPERAND (t, 0))
? ERROR_MARK
: TREE_CODE (TREE_OPERAND (t, 0))),
RECUR (TREE_OPERAND (t, 1)),
(TREE_NO_WARNING (TREE_OPERAND (t, 1))
? ERROR_MARK
: TREE_CODE (TREE_OPERAND (t, 1))),
/*overload=*/NULL,
complain);
{
tree r = build_x_binary_op
(TREE_CODE (t),
RECUR (TREE_OPERAND (t, 0)),
(TREE_NO_WARNING (TREE_OPERAND (t, 0))
? ERROR_MARK
: TREE_CODE (TREE_OPERAND (t, 0))),
RECUR (TREE_OPERAND (t, 1)),
(TREE_NO_WARNING (TREE_OPERAND (t, 1))
? ERROR_MARK
: TREE_CODE (TREE_OPERAND (t, 1))),
/*overload=*/NULL,
complain);
if (EXPR_P (r) && TREE_NO_WARNING (t))
TREE_NO_WARNING (r) = TREE_NO_WARNING (t);
return r;
}
case SCOPE_REF:
return tsubst_qualified_id (t, args, complain, in_decl, /*done=*/true,

View File

@ -1,3 +1,8 @@
2012-01-04 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/51064
* g++.dg/warn/Wparentheses-26.C: New.
2012-01-04 Mikael Morin <mikael@gcc.gnu.org>
* gfortran.dg/elemental_optional_args_2.f90: New test.

View File

@ -0,0 +1,26 @@
// PR c++/51064
// { dg-options "-Wparentheses" }
template<int i, int j = ((i + 7) >> 3)> class foo1 { };
typedef foo1<10> bar1;
template<int i, int j = (i + 7 >> 3)> class foo2 { };
typedef foo2<10> bar2; // { dg-warning "suggest parentheses around '\\+'" }
template<int i, int j = (100 >> (i + 2))> class foo3 { };
typedef foo3<3> bar3;
template<int i, int j = (100 >> i + 2)> class foo4 { };
typedef foo4<3> bar4; // { dg-warning "suggest parentheses around '\\+'" }
template<int i, int j = (i + 7) | 3> class foo5 { };
typedef foo5<10> bar5;
template<int i, int j = i + 7 | 3> class foo6 { };
typedef foo6<10> bar6; // { dg-warning "suggest parentheses around arithmetic" }
template<int i, int j = 3 | (i + 7)> class foo7 { };
typedef foo7<10> bar7;
template<int i, int j = 3 | i + 7> class foo8 { };
typedef foo8<10> bar8; // { dg-warning "suggest parentheses around arithmetic" }