From: Mark Mitchell Date: Wed, 18 Nov 1998 17:58:33 +0000 (+0000) Subject: cp-tree.h (PTRMEM_CST_CLASS): Fix typo. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=94e098d11228f5c3caade657a9f8254336494fb6;p=gcc.git cp-tree.h (PTRMEM_CST_CLASS): Fix typo. * cp-tree.h (PTRMEM_CST_CLASS): Fix typo. (global_delete_fndecl): New variable. * decl.c (global_delete_fndecl): Define it. (init_decl_processing): Set it. * init.c (build_builtin_delete_call): Use it. * tree.c (mapcar): Recursively call mapcar for the type of EXPR nodes. From-SVN: r23699 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 7f2dd8924bd..5f56a0333db 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,13 @@ +1998-11-18 Mark Mitchell + + * cp-tree.h (PTRMEM_CST_CLASS): Fix typo. + (global_delete_fndecl): New variable. + * decl.c (global_delete_fndecl): Define it. + (init_decl_processing): Set it. + * init.c (build_builtin_delete_call): Use it. + * tree.c (mapcar): Recursively call mapcar for the type of EXPR + nodes. + 1998-11-18 Jason Merrill * decl.c (cplus_expand_expr_stmt): Always complain about unresolved diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 99cb2d9ecd9..340d9925d4d 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -1623,9 +1623,9 @@ extern int flag_new_for_scope; /* For a pointer-to-member constant `X::Y' this is the RECORD_TYPE for `X'. */ -#define PTRMEM_CST_CLASS(NODE) \ - (TYPE_PTRMEM_P (TREE_TYPE (NODE)) \ - ? TYPE_OFFSET_BASETYPE (TREE_TYPE (NODE)) \ +#define PTRMEM_CST_CLASS(NODE) \ + (TYPE_PTRMEM_P (TREE_TYPE (NODE)) \ + ? TYPE_OFFSET_BASETYPE (TREE_TYPE (TREE_TYPE (NODE))) \ : TYPE_PTRMEMFUNC_OBJECT_TYPE (TREE_TYPE (NODE))) /* For a pointer-to-member constant `X::Y' this is the _DECL for @@ -2060,6 +2060,10 @@ extern tree null_node; extern tree anonymous_namespace_name; +/* The FUNCTION_DECL for the default `::operator delete'. */ + +extern tree global_delete_fndecl; + /* in pt.c */ /* These values are used for the `STRICT' parameter to type_unfication and diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 9feae32cd50..8980c110c3e 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -374,6 +374,10 @@ tree ctor_label; tree abort_fndecl; +/* A FUNCTION_DECL for the default `::operator delete'. */ + +tree global_delete_fndecl; + extern rtx cleanup_label, return_label; /* If original DECL_RESULT of current function was a register, @@ -6325,7 +6329,8 @@ init_decl_processing () (void_ftype_ptr, build_tree_list (NULL_TREE, NULL_TREE)); auto_function (ansi_opname[(int) NEW_EXPR], newtype, NOT_BUILT_IN); auto_function (ansi_opname[(int) VEC_NEW_EXPR], newtype, NOT_BUILT_IN); - auto_function (ansi_opname[(int) DELETE_EXPR], deltype, NOT_BUILT_IN); + global_delete_fndecl + = auto_function (ansi_opname[(int) DELETE_EXPR], deltype, NOT_BUILT_IN); auto_function (ansi_opname[(int) VEC_DELETE_EXPR], deltype, NOT_BUILT_IN); } diff --git a/gcc/cp/init.c b/gcc/cp/init.c index c7df0b0af44..76271b77271 100644 --- a/gcc/cp/init.c +++ b/gcc/cp/init.c @@ -1862,11 +1862,9 @@ static tree build_builtin_delete_call (addr) tree addr; { - tree BID = get_first_fn - (IDENTIFIER_GLOBAL_VALUE (ansi_opname[(int) DELETE_EXPR])); - - assemble_external (BID); - return build_call (BID, void_type_node, build_expr_list (NULL_TREE, addr)); + assemble_external (global_delete_fndecl); + return build_call (global_delete_fndecl, + void_type_node, build_expr_list (NULL_TREE, addr)); } /* Generate a C++ "new" expression. DECL is either a TREE_LIST diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index efbf6b24782..a94d9f7db9f 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -1935,6 +1935,7 @@ mapcar (t, func) case COMPONENT_REF: case CLEANUP_POINT_EXPR: t = copy_node (t); + TREE_TYPE (t) = mapcar (TREE_TYPE (t), func); TREE_OPERAND (t, 0) = mapcar (TREE_OPERAND (t, 0), func); return t; diff --git a/gcc/testsuite/g++.old-deja/g++.other/delete3.C b/gcc/testsuite/g++.old-deja/g++.other/delete3.C new file mode 100644 index 00000000000..eb56350371b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/delete3.C @@ -0,0 +1,38 @@ +#include + +int i; + +extern "C" void printf(const char*, ...); + +template +struct map { + ~map (); +}; + +template +map::~map () +{} + +struct SomeClass { }; + +void* operator new(size_t numBytes, SomeClass&, const nothrow_t&) throw() +{ + return operator new(numBytes, nothrow); +} + +void operator delete(void* pMemory, SomeClass&, const nothrow_t&) throw() +{ + i = 7; + return operator delete(pMemory); +} + +int +main() +{ + map< int, int>* pMap = new map< int, int>; + + delete pMap; + + if (i == 7) + return 1; +}