aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Mitchell <mark@codesourcery.com>2004-05-28 22:35:50 +0000
committerMark Mitchell <mmitchel@gcc.gnu.org>2004-05-28 22:35:50 +0000
commitc1cca8d4eb0613a59efae32be160a5d907a9f757 (patch)
treed7752dce6835b6a0c7641ac819b1894315e25a16
parent763ee179ed8e563ffb863f8977d9c5a31cdbf0a9 (diff)
downloadgcc-c1cca8d4eb0613a59efae32be160a5d907a9f757.zip
gcc-c1cca8d4eb0613a59efae32be160a5d907a9f757.tar.gz
gcc-c1cca8d4eb0613a59efae32be160a5d907a9f757.tar.bz2
re PR c++/15083 (spurious "statement has no effect" warning)
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
-rw-r--r--gcc/cp/ChangeLog14
-rw-r--r--gcc/cp/decl2.c1
-rw-r--r--gcc/cp/init.c1
-rw-r--r--gcc/cp/name-lookup.c4
-rw-r--r--gcc/cp/typeck.c3
-rw-r--r--gcc/testsuite/ChangeLog11
-rw-r--r--gcc/testsuite/g++.dg/expr/ptrmem4.C16
-rw-r--r--gcc/testsuite/g++.dg/template/operator3.C10
-rw-r--r--gcc/testsuite/g++.dg/warn/noeffect6.C14
9 files changed, 70 insertions, 4 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index c436ce7..6fe8517 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -5,6 +5,20 @@
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
* parser.c (cp_parser_simple_type_specifier): Call
maybe_note_name_used_in_class.
diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c
index 7f9e000..296bf23 100644
--- a/gcc/cp/decl2.c
+++ b/gcc/cp/decl2.c
@@ -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;
}
diff --git a/gcc/cp/init.c b/gcc/cp/init.c
index 8cf0019..1c00356 100644
--- a/gcc/cp/init.c
+++ b/gcc/cp/init.c
@@ -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;
}
diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c
index ad8003d..30a4d7e 100644
--- a/gcc/cp/name-lookup.c
+++ b/gcc/cp/name-lookup.c
@@ -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;
diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index fb00f58..2570868 100644
--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -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;
}
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 53b52bf..8c3e963 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -13,6 +13,17 @@
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
* g++.dg/lookup/redecl1.C: New test.
* g++.old-deja/g++.benjamin/tem04.C: Add error marker.
diff --git a/gcc/testsuite/g++.dg/expr/ptrmem4.C b/gcc/testsuite/g++.dg/expr/ptrmem4.C
new file mode 100644
index 0000000..0803c9e
--- /dev/null
+++ b/gcc/testsuite/g++.dg/expr/ptrmem4.C
@@ -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
index 0000000..45292cd
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/operator3.C
@@ -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
index 0000000..ca6baba
--- /dev/null
+++ b/gcc/testsuite/g++.dg/warn/noeffect6.C
@@ -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>();
+}