Commit bcf9a914 by Joseph Myers Committed by Joseph Myers

re PR c++/17120 (warning: suggest parentheses around assignment used as truth value)

cp:
	PR c++/17120
	* pt.c (tsubst_copy_and_build): Avoid clearing TREE_NO_WARNING for
	MODOP_EXPR.

testsuite:
	* g++.dg/warn/Wparentheses-4.C: New test.

From-SVN: r86351
parent 596cfbb6
2004-08-21 Joseph S. Myers <jsm@polyomino.org.uk>
PR c++/17120
* pt.c (tsubst_copy_and_build): Avoid clearing TREE_NO_WARNING for
MODOP_EXPR.
2004-08-20 Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net>
* pt.c (register_specialization): Check DECL_TEMPLATE_SPECIALIZATION
......
......@@ -8353,7 +8353,14 @@ tsubst_copy_and_build (tree t,
(RECUR (TREE_OPERAND (t, 0)),
TREE_CODE (TREE_OPERAND (t, 1)),
RECUR (TREE_OPERAND (t, 2)));
TREE_NO_WARNING (r) = TREE_NO_WARNING (t);
/* TREE_NO_WARNING must be set if either the expression was
parenthesized or it uses an operator such as >>= rather
than plain assignment. In the former case, it was already
set and must be copied. In the latter case,
build_x_modify_expr sets it and it must not be reset
here. */
if (TREE_NO_WARNING (t))
TREE_NO_WARNING (r) = TREE_NO_WARNING (t);
return r;
}
......
2004-08-21 Joseph S. Myers <jsm@polyomino.org.uk>
PR c++/17120
* g++.dg/warn/Wparentheses-4.C: New test.
2004-08-20 Mark Mitchell <mark@codesourcery.com>
* gcc.dg/darwin-longlong.c: Include <stdlib.h>.
......
// Test that -Wparentheses does not give bogus warnings in the
// presence of templates for non-plain assignment. Bug 17120.
// { dg-do compile }
// { dg-options "-Wparentheses" }
template<typename _Tp>
inline _Tp
cmath_power(_Tp __x, unsigned int __n)
{
while (__n >>= 1)
;
return __x;
}
int main()
{
cmath_power(1.0, 3);
}
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