From: jsm28 Date: Sat, 21 Aug 2004 00:19:17 +0000 (+0000) Subject: cp: X-Git-Tag: upstream/4.9.2~68588 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=35ca1541341c7d56f384c40ecab0a87c65cbc3e0;p=platform%2Fupstream%2Flinaro-gcc.git 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@86351 138bc75d-0d04-0410-961f-82ee72b054a4 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 9897a9f..2b794f0 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2004-08-21 Joseph S. Myers + + PR c++/17120 + * pt.c (tsubst_copy_and_build): Avoid clearing TREE_NO_WARNING for + MODOP_EXPR. + 2004-08-20 Kriang Lerdsuwanakij * pt.c (register_specialization): Check DECL_TEMPLATE_SPECIALIZATION diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index dd88b98..8ee4be9 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -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; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 6e395b0..d096a1b 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2004-08-21 Joseph S. Myers + + PR c++/17120 + * g++.dg/warn/Wparentheses-4.C: New test. + 2004-08-20 Mark Mitchell * gcc.dg/darwin-longlong.c: Include . diff --git a/gcc/testsuite/g++.dg/warn/Wparentheses-4.C b/gcc/testsuite/g++.dg/warn/Wparentheses-4.C new file mode 100644 index 0000000..2048ed7 --- /dev/null +++ b/gcc/testsuite/g++.dg/warn/Wparentheses-4.C @@ -0,0 +1,19 @@ +// 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 + inline _Tp + cmath_power(_Tp __x, unsigned int __n) + { + while (__n >>= 1) + ; + return __x; + } + +int main() +{ + cmath_power(1.0, 3); +}