re PR c++/2136 (g++ seems to disregard '::' in '::delete')

PR c++/2136
        * init.c (build_delete): Check access for a member op delete here.
        * decl2.c (delete_sanity): Not here.

From-SVN: r51079
This commit is contained in:
Jason Merrill 2002-03-20 14:50:24 -05:00 committed by Jason Merrill
parent 3a307de431
commit e3fe84e5dc
4 changed files with 32 additions and 15 deletions

View File

@ -1,3 +1,9 @@
2002-03-20 Jason Merrill <jason@redhat.com>
PR c++/2136
* init.c (build_delete): Check access for a member op delete here.
* decl2.c (delete_sanity): Not here.
2002-03-19 Jason Merrill <jason@redhat.com>
PR c++/5118

View File

@ -1142,21 +1142,8 @@ delete_sanity (exp, size, doing_vec, use_global_delete)
return build_vec_delete (t, maxindex, sfk_deleting_destructor,
use_global_delete);
else
{
if (IS_AGGR_TYPE (TREE_TYPE (type))
&& TYPE_GETS_REG_DELETE (TREE_TYPE (type)))
{
/* Only do access checking here; we'll be calling op delete
from the destructor. */
tree tmp = build_op_delete_call (DELETE_EXPR, t, size_zero_node,
LOOKUP_NORMAL, NULL_TREE);
if (tmp == error_mark_node)
return error_mark_node;
}
return build_delete (type, t, sfk_deleting_destructor,
LOOKUP_NORMAL, use_global_delete);
}
return build_delete (type, t, sfk_deleting_destructor,
LOOKUP_NORMAL, use_global_delete);
}
/* Report an error if the indicated template declaration is not the

View File

@ -3192,6 +3192,14 @@ build_delete (type, addr, auto_delete, flags, use_global_delete)
/* Call the complete object destructor. */
auto_delete = sfk_complete_destructor;
}
else if (auto_delete == sfk_deleting_destructor
&& TYPE_GETS_REG_DELETE (type))
{
/* Make sure we have access to the member op delete, even though
we'll actually be calling it from the destructor. */
build_op_delete_call (DELETE_EXPR, addr, c_sizeof_nowarn (type),
LOOKUP_NORMAL, NULL_TREE);
}
expr = build_dtor_call (build_indirect_ref (addr, NULL),
auto_delete, flags);

View File

@ -0,0 +1,16 @@
// PR c++/2136
// Test that overloaded op new and delete don't prevent us from using the
// global versions with an explicit scope.
#include <stddef.h>
struct A {
void *operator new (size_t, float);
void operator delete (void *, float);
};
int main ()
{
A *p = ::new A;
::delete p;
}