OSDN Git Service

* cp-tree.h (PTRMEM_CST_CLASS): Fix typo.
authormmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 18 Nov 1998 17:58:33 +0000 (17:58 +0000)
committermmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 18 Nov 1998 17:58:33 +0000 (17:58 +0000)
(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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@23699 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cp/ChangeLog
gcc/cp/cp-tree.h
gcc/cp/decl.c
gcc/cp/init.c
gcc/cp/tree.c
gcc/testsuite/g++.old-deja/g++.other/delete3.C [new file with mode: 0644]

index 7f2dd89..5f56a03 100644 (file)
@@ -1,3 +1,13 @@
+1998-11-18  Mark Mitchell  <mark@markmitchell.com>
+
+       * 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  <jason@yorick.cygnus.com>
 
        * decl.c (cplus_expand_expr_stmt): Always complain about unresolved
index 99cb2d9..340d992 100644 (file)
@@ -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
index 9feae32..8980c11 100644 (file)
@@ -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);
   }
 
index c7df0b0..76271b7 100644 (file)
@@ -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));
 }
 \f
 /* Generate a C++ "new" expression. DECL is either a TREE_LIST
index efbf6b2..a94d9f7 100644 (file)
@@ -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 (file)
index 0000000..eb56350
--- /dev/null
@@ -0,0 +1,38 @@
+#include <new>
+
+int i;
+
+extern "C" void printf(const char*, ...);
+
+template <class T, class U> 
+struct map {
+  ~map ();
+};
+
+template <class T, class U>
+map<T, U>::~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;
+}