From: Mark Mitchell Date: Fri, 28 May 2004 22:35:50 +0000 (+0000) Subject: re PR c++/15083 (spurious "statement has no effect" warning) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=c1cca8d4eb0613a59efae32be160a5d907a9f757;p=gcc.git 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 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index c436ce75591..6fe851774a5 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -3,6 +3,20 @@ * decl.c (cp_make_fname_decl): Free return value from fname_as_string. +2004-05-28 Mark Mitchell + + 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 PR c++/14668 diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index 7f9e000f663..296bf23b1f9 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 8cf0019cfab..1c003566108 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 ad8003da91b..30a4d7efba8 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 fb00f58d815..2570868f56c 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 53b52bf058f..8c3e963f6ad 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -11,6 +11,17 @@ * gcc.dg/altivec-15.c: New test. +2004-05-28 Mark Mitchell + + 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 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 index 00000000000..0803c9e632b --- /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 00000000000..45292cd954f --- /dev/null +++ b/gcc/testsuite/g++.dg/template/operator3.C @@ -0,0 +1,10 @@ +// PR c++/15640 + +struct A { + void foo(void); +}; + +template 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 00000000000..ca6baba8122 --- /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(); +}