diff options
author | jason <jason@138bc75d-0d04-0410-961f-82ee72b054a4> | 2014-12-15 18:31:40 +0000 |
---|---|---|
committer | jason <jason@138bc75d-0d04-0410-961f-82ee72b054a4> | 2014-12-15 18:31:40 +0000 |
commit | d1856d2c87b844afb0e31f7aa9502745b3446189 (patch) | |
tree | 7d781cbe68124e8fc1d4fd6541d6318c1962a1be /gcc/cp/decl2.c | |
parent | 6334270bd15a644a20976bc0813650a84d273534 (diff) | |
download | gcc-d1856d2c87b844afb0e31f7aa9502745b3446189.tar.gz |
N3778: Sized Deallocation
gcc/c-family/
* c.opt (-fsized-deallocation, -Wc++14-compat): New.
(-Wsized-deallocation): New.
* c-opts.c (c_common_post_options): -fsized-deallocation defaults
to on in C++14 and up.
gcc/cp/
* call.c (non_placement_deallocation_fn_p): A global sized
operator delete is not a usual deallocation function until C++14.
(build_op_delete_call): Choose the global sized op delete if we
know the size.
* cp-tree.h: Declare non_placement_deallocation_fn_p.
(enum cp_tree_index): Remove CPTI_GLOBAL_DELETE_FNDECL.
(global_delete_fndecl): Remove.
* decl.c (cxx_init_decl_processing): Also declare sized op deletes.
(grok_op_properties): Warn about sized dealloc without the flag.
* init.c (build_builtin_delete_call): Remove.
(build_vec_delete_1, build_delete): Don't call it.
* decl2.c (maybe_warn_sized_delete): New.
(cp_write_global_declarations): Call it.
libstdc++-v3/
* libsupc++/del_ops.cc: New.
* libsupc++/del_opvs.cc: New.
* libsupc++/Makefile.am: Add them.
* libsupc++/Makefile.in: Regenerate.
* config/abi/pre/gnu.ver: Export _ZdlPvm and _ZdaPvm.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@218755 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cp/decl2.c')
-rw-r--r-- | gcc/cp/decl2.c | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index f3b94a93dc5..07bdd92de93 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -4308,6 +4308,47 @@ dump_tu (void) } } +/* Check the deallocation functions for CODE to see if we want to warn that + only one was defined. */ + +static void +maybe_warn_sized_delete (enum tree_code code) +{ + tree sized = NULL_TREE; + tree unsized = NULL_TREE; + + for (tree ovl = IDENTIFIER_GLOBAL_VALUE (ansi_opname (code)); + ovl; ovl = OVL_NEXT (ovl)) + { + tree fn = OVL_CURRENT (ovl); + /* We're only interested in usual deallocation functions. */ + if (!non_placement_deallocation_fn_p (fn)) + continue; + if (FUNCTION_ARG_CHAIN (fn) == void_list_node) + unsized = fn; + else + sized = fn; + } + if (DECL_INITIAL (unsized) && !DECL_INITIAL (sized)) + warning_at (DECL_SOURCE_LOCATION (unsized), OPT_Wsized_deallocation, + "the program should also define %qD", sized); + else if (!DECL_INITIAL (unsized) && DECL_INITIAL (sized)) + warning_at (DECL_SOURCE_LOCATION (sized), OPT_Wsized_deallocation, + "the program should also define %qD", unsized); +} + +/* Check the global deallocation functions to see if we want to warn about + defining unsized without sized (or vice versa). */ + +static void +maybe_warn_sized_delete () +{ + if (!flag_sized_deallocation || !warn_sized_deallocation) + return; + maybe_warn_sized_delete (DELETE_EXPR); + maybe_warn_sized_delete (VEC_DELETE_EXPR); +} + /* This routine is called at the end of compilation. Its job is to create all the code needed to initialize and destroy the global aggregates. We do the destruction @@ -4638,6 +4679,8 @@ cp_write_global_declarations (void) FOR_EACH_VEC_SAFE_ELT (no_linkage_decls, i, decl) no_linkage_error (decl); + maybe_warn_sized_delete (); + /* Then, do the Objective-C stuff. This is where all the Objective-C module stuff gets generated (symtab, class/protocol/selector lists etc). This must be done after C++ |