aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/decl.c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2020-10-29 16:27:01 +0100
committerJakub Jelinek <jakub@redhat.com>2020-10-29 16:27:01 +0100
commit815baade9a07d361b1daa1dcfbbda2a79f3ebb52 (patch)
treed009f7c200116f53e11dd3b94f040f55efe1b358 /gcc/cp/decl.c
parent40749db75caff2fed7b7053e0d1868feaa21bcb4 (diff)
downloadgcc-815baade9a07d361b1daa1dcfbbda2a79f3ebb52.zip
gcc-815baade9a07d361b1daa1dcfbbda2a79f3ebb52.tar.gz
gcc-815baade9a07d361b1daa1dcfbbda2a79f3ebb52.tar.bz2
c++: Diagnose constexpr delete [] new int; and delete new int[N]; [PR95808]
This patch diagnoses delete [] new int; and delete new int[1]; in constexpr contexts by remembering IDENTIFIER_OVL_OP_FLAGS (DECL_NAME (fun)) & OVL_OP_FLAG_VEC from the operator new and checking it at operator delete time. 2020-10-29 Jakub Jelinek <jakub@redhat.com> PR c++/95808 * cp-tree.h (enum cp_tree_index): Add CPTI_HEAP_VEC_UNINIT_IDENTIFIER and CPTI_HEAP_VEC_IDENTIFIER. (heap_vec_uninit_identifier, heap_vec_identifier): Define. * decl.c (initialize_predefined_identifiers): Initialize those identifiers. * constexpr.c (cxx_eval_call_expression): Reject array allocations deallocated with non-array deallocation or non-array allocations deallocated with array deallocation. (non_const_var_error): Handle heap_vec_uninit_identifier and heap_vec_identifier too. (cxx_eval_constant_expression): Handle also heap_vec_uninit_identifier and in that case during initialization replace it with heap_vec_identifier. (find_heap_var_refs): Handle heap_vec_uninit_identifier and heap_vec_identifier too. * g++.dg/cpp2a/constexpr-new15.C: New test.
Diffstat (limited to 'gcc/cp/decl.c')
-rw-r--r--gcc/cp/decl.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index ee3c353..39f56b8 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -4245,6 +4245,8 @@ initialize_predefined_identifiers (void)
{"heap uninit", &heap_uninit_identifier, cik_normal},
{"heap ", &heap_identifier, cik_normal},
{"heap deleted", &heap_deleted_identifier, cik_normal},
+ {"heap [] uninit", &heap_vec_uninit_identifier, cik_normal},
+ {"heap []", &heap_vec_identifier, cik_normal},
{NULL, NULL, cik_normal}
};