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
This commit is contained in:
Mark Mitchell 2004-05-28 22:35:50 +00:00 committed by Mark Mitchell
parent 763ee179ed
commit c1cca8d4eb
9 changed files with 70 additions and 4 deletions

View 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

View 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;
}

View 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;
}

View 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;

View 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;
}

View File

@ -11,6 +11,17 @@
* 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

View File

@ -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;
}

View File

@ -0,0 +1,10 @@
// PR c++/15640
struct A {
void foo(void);
};
template <int> void bar() {
A a;
a + a.foo; // { dg-error "" }
}

View File

@ -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>();
}