This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [v3] Suppress warning
- From: "Joseph S. Myers" <jsm at polyomino dot org dot uk>
- To: Falk Hueffner <hueffner at informatik dot uni-tuebingen dot de>
- Cc: Paolo Carlini <pcarlini at suse dot de>, "'gcc-patches at gcc dot gnu dot org'" <gcc-patches at gcc dot gnu dot org>
- Date: Fri, 20 Aug 2004 14:48:16 +0000 (UTC)
- Subject: Re: [v3] Suppress warning
- References: <4125D314.1020904@suse.de> <871xi2p014.fsf@informatik.uni-tuebingen.de>
On Fri, 20 Aug 2004, Falk Hueffner wrote:
> > - while (__n >>= 1)
> > + while ((__n >>= 1))
>
> Looks more like a bug to me than an improvement. Why would one want a
> warning for the first case?
You don't want it (and don't get it outside templates). I'm testing the
following patch. Results in about 8 hours.
--
Joseph S. Myers http://www.srcf.ucam.org/~jsm28/gcc/
jsm@polyomino.org.uk (personal mail)
jsm28@gcc.gnu.org (Bugzilla assignments and CCs)
cp:
2004-08-20 Joseph S. Myers <jsm@polyomino.org.uk>
PR c++/17120
* pt.c (tsubst_copy_and_build): Avoid clearing TREE_NO_WARNING for
MODOP_EXPR.
testsuite:
2004-08-20 Joseph S. Myers <jsm@polyomino.org.uk>
PR c++/17120
* g++.dg/warn/Wparentheses-4.C: New test.
diff -rupN GCC.orig/gcc/cp/pt.c GCC/gcc/cp/pt.c
--- GCC.orig/gcc/cp/pt.c 2004-08-20 14:24:51.000000000 +0000
+++ GCC/gcc/cp/pt.c 2004-08-20 14:28:51.000000000 +0000
@@ -8353,7 +8353,8 @@ 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);
+ if (TREE_NO_WARNING (t))
+ TREE_NO_WARNING (r) = TREE_NO_WARNING (t);
return r;
}
diff -rupN GCC.orig/gcc/testsuite/g++.dg/warn/Wparentheses-4.C GCC/gcc/testsuite/g++.dg/warn/Wparentheses-4.C
--- GCC.orig/gcc/testsuite/g++.dg/warn/Wparentheses-4.C 1970-01-01 00:00:00.000000000 +0000
+++ GCC/gcc/testsuite/g++.dg/warn/Wparentheses-4.C 2004-08-20 14:47:03.000000000 +0000
@@ -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<typename _Tp>
+ inline _Tp
+ cmath_power(_Tp __x, unsigned int __n)
+ {
+ while (__n >>= 1)
+ ;
+ return __x;
+ }
+
+int main()
+{
+ cmath_power(1.0, 3);
+}