re PR c++/15083 (spurious "statement has no effect" warning)
authorMark Mitchell <mark@codesourcery.com>
Fri, 28 May 2004 22:35:50 +0000 (22:35 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Fri, 28 May 2004 22:35:50 +0000 (22:35 +0000)
PR c++/15083
* decl2.c (delete_sanity): Set TREE_SIDE_EFFECTS on a DELETE_EXPR,
even in a templat.e
* init.c (build_new): Likewise.

PR c++/15640
* name-lookup.c (arg_assoc): Robustify.

PR c++/15471
* typeck.c (unary_complex_lvalue): Use context_for_name_lookup
when determining the scope to use for a pointer to member.

PR c++/15083
* g++.dg/warn/noeffect5.C: New test.

PR c++/15471
* g++.dg/expr/ptrmem4.C: New test.

PR c++/15640
* g++.dg/template/operator3.C: New test.

From-SVN: r82391

gcc/cp/ChangeLog
gcc/cp/decl2.c
gcc/cp/init.c
gcc/cp/name-lookup.c
gcc/cp/typeck.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/expr/ptrmem4.C [new file with mode: 0644]
gcc/testsuite/g++.dg/template/operator3.C [new file with mode: 0644]
gcc/testsuite/g++.dg/warn/noeffect6.C [new file with mode: 0644]

index c436ce7559103d63c31ea62ccea1b484f403a5c4..6fe851774a5cce90eebeda04c88a0c2f6ffa32e0 100644 (file)
@@ -3,6 +3,20 @@
        * decl.c (cp_make_fname_decl): Free return value from
        fname_as_string.
 
+2004-05-28  Mark Mitchell  <mark@codesourcery.com>
+
+       PR c++/15083
+       * decl2.c (delete_sanity): Set TREE_SIDE_EFFECTS on a DELETE_EXPR,
+       even in a templat.e
+       * init.c (build_new): Likewise.
+
+       PR c++/15640
+       * name-lookup.c (arg_assoc): Robustify.
+
+       PR c++/15471
+       * typeck.c (unary_complex_lvalue): Use context_for_name_lookup
+       when determining the scope to use for a pointer to member.
+
 2004-05-28  Mark Mitchell  <mark@codesourcery.com>
 
        PR c++/14668
index 7f9e000f66324534a8ce15e9676b6f8acfc8602e..296bf23b1f9d5f629c674da185e9af0a4a00deee 100644 (file)
@@ -451,6 +451,7 @@ delete_sanity (tree exp, tree size, bool doing_vec, int use_global_delete)
       t = build_min (DELETE_EXPR, void_type_node, exp, size);
       DELETE_EXPR_USE_GLOBAL (t) = use_global_delete;
       DELETE_EXPR_USE_VEC (t) = doing_vec;
+      TREE_SIDE_EFFECTS (t) = 1;
       return t;
     }
 
index 8cf0019cfab249d4f986e39c697c98cd2f0809b3..1c003566108f05570478a0f08b264b0b0a4021c9 100644 (file)
@@ -1788,6 +1788,7 @@ build_new (tree placement, tree decl, tree init, int use_global_new)
       rval = build_min (NEW_EXPR, build_pointer_type (type), 
                        placement, t, init);
       NEW_EXPR_USE_GLOBAL (rval) = use_global_new;
+      TREE_SIDE_EFFECTS (rval) = 1;
       return rval;
     }
 
index ad8003da91ba8e9a86ff735dd1a59d0be8350d61..30a4d7efba8e3a5c417d9fe0c29e1f58607bbd04 100644 (file)
@@ -4464,10 +4464,8 @@ arg_assoc (struct arg_lookup *k, tree n)
        if (arg_assoc_template_arg (k, TREE_VEC_ELT (args, ix)) == 1)
          return true;
     }
-  else
+  else if (TREE_CODE (n) == OVERLOAD)
     {
-      my_friendly_assert (TREE_CODE (n) == OVERLOAD, 980715);
-      
       for (; n; n = OVL_CHAIN (n))
        if (arg_assoc_type (k, TREE_TYPE (OVL_FUNCTION (n))))
          return true;
index fb00f58d815d1e55257441f4add440667563a174..2570868f56c99b12e73e4cad476f42f316c6c8bf 100644 (file)
@@ -4209,7 +4209,8 @@ unary_complex_lvalue (enum tree_code code, tree arg)
              return error_mark_node;
            }
 
-         type = build_ptrmem_type (DECL_FIELD_CONTEXT (t), TREE_TYPE (t));
+         type = build_ptrmem_type (context_for_name_lookup (t), 
+                                   TREE_TYPE (t));
          t = make_ptrmem_cst (type, TREE_OPERAND (arg, 1));
          return t;
        }
index 53b52bf058f3a87582c28f036cb6b084225c32b2..8c3e963f6ade4d725c7f59250d56ffc2cdeeb7ac 100644 (file)
 
        * gcc.dg/altivec-15.c: New test.
 
+2004-05-28  Mark Mitchell  <mark@codesourcery.com>
+
+       PR c++/15083
+       * g++.dg/warn/noeffect6.C: New test.
+
+       PR c++/15471
+       * g++.dg/expr/ptrmem4.C: New test.
+
+       PR c++/15640
+       * g++.dg/template/operator3.C: New test.
+
 2004-05-28  Mark Mitchell  <mark@codesourcery.com>
 
        PR c++/14668
diff --git a/gcc/testsuite/g++.dg/expr/ptrmem4.C b/gcc/testsuite/g++.dg/expr/ptrmem4.C
new file mode 100644 (file)
index 0000000..0803c9e
--- /dev/null
@@ -0,0 +1,16 @@
+// PR c++/15471
+// { dg-do run }
+
+struct myclass { 
+  unsigned a; 
+  union { 
+    unsigned x; 
+  }; 
+}; 
+int main () {
+  myclass foo;
+  unsigned myclass::* member = &myclass::x; 
+  if (&(foo.*member) != &foo.x)
+    return 1;
+}
diff --git a/gcc/testsuite/g++.dg/template/operator3.C b/gcc/testsuite/g++.dg/template/operator3.C
new file mode 100644 (file)
index 0000000..45292cd
--- /dev/null
@@ -0,0 +1,10 @@
+// PR c++/15640
+
+struct A {
+  void foo(void);
+};
+
+template <int> void bar() {
+  A a;
+  a + a.foo; // { dg-error "" }
+}
diff --git a/gcc/testsuite/g++.dg/warn/noeffect6.C b/gcc/testsuite/g++.dg/warn/noeffect6.C
new file mode 100644 (file)
index 0000000..ca6baba
--- /dev/null
@@ -0,0 +1,14 @@
+// { dg-options "-Wall" }
+// PR c++/15083
+
+extern "C" int printf(const char*,...);
+struct Counter {
+  Counter(){printf("Hello World.\n");}
+};
+template< typename T >
+void resetData() {
+  new Counter();
+}
+int main() {
+  resetData<int>();
+}