summaryrefslogtreecommitdiffstats
path: root/gcc/cp/call.c
diff options
context:
space:
mode:
authormmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>2001-02-14 06:32:15 +0000
committermmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>2001-02-14 06:32:15 +0000
commitb429d3ee1b1dc11f93cbcac2625e2054afd3be43 (patch)
treed96b4a0445eaddd41c2f31bdde78ca4bce589951 /gcc/cp/call.c
parentf78457c18e74ccf5683c88a96988e8ef276c42fc (diff)
downloadppe42-gcc-b429d3ee1b1dc11f93cbcac2625e2054afd3be43.tar.gz
ppe42-gcc-b429d3ee1b1dc11f93cbcac2625e2054afd3be43.zip
* cp-tree.h (CLASSTYPE_DESTRUCTORS): Fix typo in comment.
* call.c (build_op_delete_call): Simplify to remove duplicate code. * class.c (clone_function_decl): Don't build the deleting variant of a non-virtual destructor. * decl.c (finish_destructor_body): Don't call delete if this is a non-virtual destructor. * init.c (build_delete): Explicitly call `operator delete' when deleting an object with a non-virtual destructor. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@39659 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cp/call.c')
-rw-r--r--gcc/cp/call.c64
1 files changed, 31 insertions, 33 deletions
diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index 7cb34bd1724..11cb6404054 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -3547,6 +3547,7 @@ build_op_delete_call (code, addr, size, flags, placement)
int flags;
{
tree fn, fns, fnname, fntype, argtypes, args, type;
+ int pass;
if (addr == error_mark_node)
return error_mark_node;
@@ -3595,48 +3596,45 @@ build_op_delete_call (code, addr, size, flags, placement)
args = NULL_TREE;
}
- argtypes = tree_cons (NULL_TREE, ptr_type_node, argtypes);
- fntype = build_function_type (void_type_node, argtypes);
-
/* Strip const and volatile from addr. */
addr = cp_convert (ptr_type_node, addr);
- fn = instantiate_type (fntype, fns, itf_no_attributes);
-
- if (fn != error_mark_node)
+ /* We make two tries at finding a matching `operator delete'. On
+ the first pass, we look for an one-operator (or placement)
+ operator delete. If we're not doing placement delete, then on
+ the second pass we look for a two-argument delete. */
+ for (pass = 0; pass < (placement ? 1 : 2); ++pass)
{
- if (TREE_CODE (fns) == TREE_LIST)
- /* Member functions. */
- enforce_access (type, fn);
- return build_function_call (fn, tree_cons (NULL_TREE, addr, args));
- }
-
- /* If we are doing placement delete we do nothing if we don't find a
- matching op delete. */
- if (placement)
- return NULL_TREE;
+ if (pass == 0)
+ argtypes = tree_cons (NULL_TREE, ptr_type_node, argtypes);
+ else
+ /* Normal delete; now try to find a match including the size
+ argument. */
+ argtypes = tree_cons (NULL_TREE, ptr_type_node,
+ tree_cons (NULL_TREE, sizetype,
+ void_list_node));
- /* Normal delete; now try to find a match including the size argument. */
- argtypes = tree_cons (NULL_TREE, ptr_type_node,
- tree_cons (NULL_TREE, sizetype, void_list_node));
- fntype = build_function_type (void_type_node, argtypes);
+ fntype = build_function_type (void_type_node, argtypes);
+ fn = instantiate_type (fntype, fns, itf_no_attributes);
- fn = instantiate_type (fntype, fns, itf_no_attributes);
+ if (fn != error_mark_node)
+ {
+ /* Member functions. */
+ if (BASELINK_P (fns))
+ enforce_access (type, fn);
- if (fn != error_mark_node)
- {
- if (BASELINK_P (fns))
- /* Member functions. */
- enforce_access (type, fn);
- return build_function_call
- (fn, tree_cons (NULL_TREE, addr,
- build_tree_list (NULL_TREE, size)));
+ if (pass == 0)
+ args = tree_cons (NULL_TREE, addr, args);
+ else
+ args = tree_cons (NULL_TREE, addr,
+ build_tree_list (NULL_TREE, size));
+ return build_function_call (fn, args);
+ }
}
- /* finish_function passes LOOKUP_SPECULATIVELY if we're in a
- destructor, in which case the error should be deferred
- until someone actually tries to delete one of these. */
- if (flags & LOOKUP_SPECULATIVELY)
+ /* If we are doing placement delete we do nothing if we don't find a
+ matching op delete. */
+ if (placement)
return NULL_TREE;
cp_error ("no suitable `operator delete' for `%T'", type);
OpenPOWER on IntegriCloud