re PR c++/17041 (Erroneous "suggest parentheses around assignment used as truth value...
authorJoseph Myers <jsm@polyomino.org.uk>
Thu, 19 Aug 2004 08:01:50 +0000 (09:01 +0100)
committerJoseph Myers <jsm28@gcc.gnu.org>
Thu, 19 Aug 2004 08:01:50 +0000 (09:01 +0100)
PR c++/17041
* pt.c (tsubst_copy, tsubst_copy_and_build): Copy TREE_NO_WARNING
from input for MODOP_EXPR.

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

From-SVN: r86241

gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/warn/Wparentheses-3.C [new file with mode: 0644]

index eb271e5b2b6a2f4e1797487464393ffd2740542a..5ce9af30f2a9a756e9766e6d502b21f3772ffed8 100644 (file)
@@ -1,3 +1,9 @@
+2004-08-19  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  Mark Mitchell  <mark@codesourcery.com>
 
        * pt.c (dependent_template_p): Fix typo in commment.
index 4107d1ca1c6d43ca0546b4ea8e8301a329761abf..f4e9362ff1b1eb95d6fa54882a28ea4ed60b6104 100644 (file)
@@ -7667,6 +7667,7 @@ tsubst_copy (tree t, tree args, tsubst_flags_t complain, tree in_decl)
          (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;
       }
 
@@ -8331,10 +8332,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),
index 007f3dc36a262253334cce1a49a6810e83745f17..02c9cc83f1a745e29d67a3d7b4d7724b9b2a674c 100644 (file)
@@ -1,3 +1,8 @@
+2004-08-19  Joseph S. Myers  <jsm@polyomino.org.uk>
+
+       PR c++/17041
+       * g++.dg/Wparentheses-3.C: New test.
+
 2004-08-19  Dorit Naishlos  <dorit@il.ibm.com>
 
        * gcc.dg/vect/vect-1.c: Remove xfail from i?86-*-* x86_64-*-* due
diff --git a/gcc/testsuite/g++.dg/warn/Wparentheses-3.C b/gcc/testsuite/g++.dg/warn/Wparentheses-3.C
new file mode 100644 (file)
index 0000000..8781953
--- /dev/null
@@ -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;