diff options
author | mmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-07-06 01:23:54 +0000 |
---|---|---|
committer | mmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-07-06 01:23:54 +0000 |
commit | 62116ec373e786a0b9dcb16c8afbd62fa2f45006 (patch) | |
tree | 17dc867104325855fe255d6858ff0978e0b8936c /gcc/cp/call.c | |
parent | c07054e9cb2002971dbefcf713d5dd3ee131bfc4 (diff) | |
download | gcc-62116ec373e786a0b9dcb16c8afbd62fa2f45006.tar.gz |
PR c++/32245
* init.c (build_zero_init): Always build an initializer for
non-static storage.
* typeck2.c (build_functional_cast): Use build_zero_init.
PR c++/32251
* init.c (build_new_1): Always pass the allocation function to
build_op_delete_call.
* call.c (build_op_delete_call): Handle operator delete with a
variable-argument list. Do not issue an error when no matching
deallocation function is available for a new operator.
PR c++/31992
* cp-tree.h (any_value_dependent_elements_p): Declare it.
* decl.c (value_dependent_init_p): New function.
(cp_finish_decl): Use it.
* pt.c (value_dependent_expression_p): Use
any_value_dependent_elements_p.
* parser.c (cp_parser_primary_expression): Add comment about
treating dependent qualified names as integral
constant-expressions.
PR c++/32245
* g++.dg/init/ptrmem4.C: New test.
PR c++/32251
* g++.dg/init/new21.C: Likewise.
PR c++/31992
* g++.dg/template/static30.C: Likewise.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@126399 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cp/call.c')
-rw-r--r-- | gcc/cp/call.c | 32 |
1 files changed, 24 insertions, 8 deletions
diff --git a/gcc/cp/call.c b/gcc/cp/call.c index 86d5fbccd10..82f8666c42e 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -4062,8 +4062,12 @@ build_new_op (enum tree_code code, int flags, tree arg1, tree arg2, tree arg3, GLOBAL_P is true if the delete-expression should not consider class-specific delete operators. PLACEMENT is the corresponding placement new call, or NULL_TREE. - If PLACEMENT is non-NULL, then ALLOC_FN is the allocation function - called to perform the placement new. */ + + If this call to "operator delete" is being generated as part to + deallocate memory allocated via a new-expression (as per [expr.new] + which requires that if the initialization throws an exception then + we call a deallocation function), then ALLOC_FN is the allocation + function. */ tree build_op_delete_call (enum tree_code code, tree addr, tree size, @@ -4151,9 +4155,13 @@ build_op_delete_call (enum tree_code code, tree addr, tree size, if (!a && !t) break; } - /* On the second pass, the second argument must be - "size_t". */ + /* On the second pass, look for a function with exactly two + arguments: "void *" and "size_t". */ else if (pass == 1 + /* For "operator delete(void *, ...)" there will be + no second argument, but we will not get an exact + match above. */ + && t && same_type_p (TREE_VALUE (t), size_type_node) && TREE_CHAIN (t) == void_list_node) break; @@ -4201,10 +4209,18 @@ build_op_delete_call (enum tree_code code, tree addr, tree size, } } - /* If we are doing placement delete we do nothing if we don't find a - matching op delete. */ - if (placement) - return NULL_TREE; + /* [expr.new] + + If no unambiguous matching deallocation function can be found, + propagating the exception does not cause the object's memory to + be freed. */ + if (alloc_fn) + { + if (!placement) + warning (0, "no corresponding deallocation function for `%D'", + alloc_fn); + return NULL_TREE; + } error ("no suitable %<operator %s%> for %qT", operator_name_info[(int)code].name, type); |