This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
C++ patch: bug 17041
- From: "Joseph S. Myers" <jsm at polyomino dot org dot uk>
- To: gcc-patches at gcc dot gnu dot org
- Date: Wed, 18 Aug 2004 18:12:23 +0000 (UTC)
- Subject: C++ patch: bug 17041
This patch fixes bug 17041, inappropriate -Wparentheses warnings in
the presence of templates.
It's still the case that this warning would better be handled at
parser level for both C and C++ rather than using the present
TREE_NO_WARNING kludge, but fixing this particular bug was
straightforward.
Bootstrapped with no regressions on i686-pc-linux-gnu. OK to commit?
--
Joseph S. Myers http://www.srcf.ucam.org/~jsm28/gcc/
jsm@polyomino.org.uk (personal mail)
jsm28@gcc.gnu.org (Bugzilla assignments and CCs)
2004-08-18 Joseph S. Myers <jsm@polyomino.org.uk>
PR c++/17041
* pt.c (tsubst_copy, tsubst_copy_and_build): Copy TREE_NO_WARNING
from input for MODOP_EXPR.
2004-08-18 Joseph S. Myers <jsm@polyomino.org.uk>
PR c++/17041
* g++.dg/Wparentheses-3.C: New test.
diff -rupN GCC.orig/gcc/cp/pt.c GCC/gcc/cp/pt.c
--- GCC.orig/gcc/cp/pt.c 2004-08-16 20:29:01.000000000 +0000
+++ GCC/gcc/cp/pt.c 2004-08-17 16:47:14.000000000 +0000
@@ -7657,6 +7657,7 @@ tsubst_copy (tree t, tree args, tsubst_f
(code, tsubst_copy (TREE_OPERAND (t, 0), args, complain, in_decl),
tsubst_copy (TREE_OPERAND (t, 1), args, complain, in_decl),
tsubst_copy (TREE_OPERAND (t, 2), args, complain, in_decl));
+ TREE_NO_WARNING (r) = TREE_NO_WARNING (t);
return r;
}
@@ -8321,10 +8322,14 @@ tsubst_copy_and_build (tree t,
return cxx_sizeof_or_alignof_expr (op1, TREE_CODE (t));
case MODOP_EXPR:
- return build_x_modify_expr
- (RECUR (TREE_OPERAND (t, 0)),
- TREE_CODE (TREE_OPERAND (t, 1)),
- RECUR (TREE_OPERAND (t, 2)));
+ {
+ tree r = build_x_modify_expr
+ (RECUR (TREE_OPERAND (t, 0)),
+ TREE_CODE (TREE_OPERAND (t, 1)),
+ RECUR (TREE_OPERAND (t, 2)));
+ TREE_NO_WARNING (r) = TREE_NO_WARNING (t);
+ return r;
+ }
case ARROW_EXPR:
op1 = tsubst_non_call_postfix_expression (TREE_OPERAND (t, 0),
diff -rupN GCC.orig/gcc/testsuite/g++.dg/warn/Wparentheses-3.C GCC/gcc/testsuite/g++.dg/warn/Wparentheses-3.C
--- GCC.orig/gcc/testsuite/g++.dg/warn/Wparentheses-3.C 1970-01-01 00:00:00.000000000 +0000
+++ GCC/gcc/testsuite/g++.dg/warn/Wparentheses-3.C 2004-08-17 16:44:07.000000000 +0000
@@ -0,0 +1,13 @@
+// Test that -Wparentheses does not give bogus warnings in the
+// presence of templates. Bug 17041.
+
+// { dg-do compile }
+// { dg-options "-Wparentheses" }
+
+template<int> struct A
+{
+ int i;
+ A() { if ((i = 0)) ; }
+};
+
+A<0> a;