diff options
author | Jakub Jelinek <jakub@redhat.com> | 2019-11-02 00:26:17 +0100 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2019-11-02 00:26:17 +0100 |
commit | 8412b939d1cf375c8e478e39a5ac9d7260e4c23c (patch) | |
tree | fa30aa009dcb3b40d9e2996606c4f8ec9635d72e /gcc/cp/init.c | |
parent | 8a8ce49e0f3983e1b72f490a59ded92bca053c71 (diff) | |
download | gcc-8412b939d1cf375c8e478e39a5ac9d7260e4c23c.zip gcc-8412b939d1cf375c8e478e39a5ac9d7260e4c23c.tar.gz gcc-8412b939d1cf375c8e478e39a5ac9d7260e4c23c.tar.bz2 |
PR c++/91369 - Implement P0784R7: constexpr new
PR c++/91369 - Implement P0784R7: constexpr new
* cp-tree.h (CALL_FROM_NEW_OR_DELETE_P): Define.
* init.c (build_new_1, build_vec_delete_1, build_delete): Set
CALL_FROM_NEW_OR_DELETE_P on the CALL_EXPR to allocator functions.
* constexpr.c (is_std_allocator_allocate): Only allow
global replaceable allocator functions if CALL_FROM_NEW_OR_DELETE_P
or in std::allocate<T>::{,de}allocate.
(potential_constant_expression_1): Likewise.
* g++.dg/cpp2a/constexpr-new6.C: New test.
* g++.dg/cpp2a/constexpr-new7.C: New test.
From-SVN: r277732
Diffstat (limited to 'gcc/cp/init.c')
-rw-r--r-- | gcc/cp/init.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/gcc/cp/init.c b/gcc/cp/init.c index 1c51e26..f86cf55 100644 --- a/gcc/cp/init.c +++ b/gcc/cp/init.c @@ -3404,6 +3404,10 @@ build_new_1 (vec<tree, va_gc> **placement, tree type, tree nelts, } } + tree alloc_call_expr = extract_call_expr (alloc_call); + if (TREE_CODE (alloc_call_expr) == CALL_EXPR) + CALL_FROM_NEW_OR_DELETE_P (alloc_call_expr) = 1; + if (cookie_size) alloc_call = maybe_wrap_new_for_constexpr (alloc_call, elt_type, cookie_size); @@ -4046,6 +4050,10 @@ build_vec_delete_1 (tree base, tree maxindex, tree type, /*placement=*/NULL_TREE, /*alloc_fn=*/NULL_TREE, complain); + + tree deallocate_call_expr = extract_call_expr (deallocate_expr); + if (TREE_CODE (deallocate_call_expr) == CALL_EXPR) + CALL_FROM_NEW_OR_DELETE_P (deallocate_call_expr) = 1; } body = loop; @@ -4955,6 +4963,13 @@ build_delete (tree otype, tree addr, special_function_kind auto_delete, if (!deleting) return expr; + if (do_delete) + { + tree do_delete_call_expr = extract_call_expr (do_delete); + if (TREE_CODE (do_delete_call_expr) == CALL_EXPR) + CALL_FROM_NEW_OR_DELETE_P (do_delete_call_expr) = 1; + } + if (do_delete && !TREE_SIDE_EFFECTS (expr)) expr = do_delete; else if (do_delete) |