From b2cf76f3a58d065122d2ae94bf55510551ff27f4 Mon Sep 17 00:00:00 2001 From: Nathan Sidwell Date: Tue, 27 Jun 2017 17:27:49 +0000 Subject: [PATCH] cp-tree.h (CLASSTYPE_DESTRUCTORS): Rename to ... * cp-tree.h (CLASSTYPE_DESTRUCTORS): Rename to ... (CLASSTYPE_DESTRUCTOR): ... this. * class.c (accessible_nvdtor_p) maybe_warn_about_overly_private_class, add_implicitly_declared_members, clone_constructors_and_destructors, type_has_virtual_destructor): Adjust for CLASSTYPE_DESTRUCTOR. (deduce_noexcept_on_destructors): Absorb into ... (check_bases_and_members): ... here. * except.c (dtor_nothrow): Adjust for CLASSTYPE_DESTRUCTOR. * init.c (build_delete): Likewise. * parser.c (cp_parser_lookup_name): Likewise. * pt.c (check_explicit_specialization): Likewise. * rtti.c (emit_support_tinfos): Likewise. * search.c (lookup_fnfields_idx_nolazy): Likewise. (--This line, and those below, will be ignored-- M cp/cp-tree.h M cp/search.c M cp/init.c M cp/class.c M cp/rtti.c M cp/except.c M cp/ChangeLog M cp/pt.c M cp/parser.c From-SVN: r249701 --- gcc/cp/ChangeLog | 16 ++++++++++++++++ gcc/cp/class.c | 47 +++++++++++++++-------------------------------- gcc/cp/cp-tree.h | 6 ++---- gcc/cp/except.c | 2 +- gcc/cp/init.c | 5 ++--- gcc/cp/parser.c | 10 ++++++---- gcc/cp/pt.c | 2 +- gcc/cp/rtti.c | 2 +- gcc/cp/search.c | 2 +- 9 files changed, 45 insertions(+), 47 deletions(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 0a911515b8f..bd223196162 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,21 @@ 2017-06-27 Nathan Sidwell + * cp-tree.h (CLASSTYPE_DESTRUCTORS): Rename to ... + (CLASSTYPE_DESTRUCTOR): ... this. + * class.c (accessible_nvdtor_p, + maybe_warn_about_overly_private_class, + add_implicitly_declared_members, + clone_constructors_and_destructors, type_has_virtual_destructor): + Adjust for CLASSTYPE_DESTRUCTOR. + (deduce_noexcept_on_destructors): Absorb into ... + (check_bases_and_members): ... here. + * except.c (dtor_nothrow): Adjust for CLASSTYPE_DESTRUCTOR. + * init.c (build_delete): Likewise. + * parser.c (cp_parser_lookup_name): Likewise. + * pt.c (check_explicit_specialization): Likewise. + * rtti.c (emit_support_tinfos): Likewise. + * search.c (lookup_fnfields_idx_nolazy): Likewise. + Kill IDENTIFIER_TEMPLATE. * cp-tree.h (lang_identifier): Remove class_template_info field. (IDENTIFIER_TEMPLATE): Delete. diff --git a/gcc/cp/class.c b/gcc/cp/class.c index 1243f33605f..833eb94b466 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -1711,7 +1711,7 @@ inherit_targ_abi_tags (tree t) static bool accessible_nvdtor_p (tree t) { - tree dtor = CLASSTYPE_DESTRUCTORS (t); + tree dtor = CLASSTYPE_DESTRUCTOR (t); /* An implicitly declared destructor is always public. And, if it were virtual, we would have created it by now. */ @@ -2220,7 +2220,7 @@ maybe_warn_about_overly_private_class (tree t) /* Even if some of the member functions are non-private, the class won't be useful for much if all the constructors or destructors are private: such an object can never be created or destroyed. */ - fn = CLASSTYPE_DESTRUCTORS (t); + fn = CLASSTYPE_DESTRUCTOR (t); if (fn && TREE_PRIVATE (fn)) { warning (OPT_Wctor_dtor_privacy, @@ -3366,18 +3366,17 @@ add_implicitly_declared_members (tree t, tree* access_decls, int cant_have_const_cctor, int cant_have_const_assignment) { - bool move_ok = false; + /* Destructor. */ + if (!CLASSTYPE_DESTRUCTOR (t)) + /* In general, we create destructors lazily. */ + CLASSTYPE_LAZY_DESTRUCTOR (t) = 1; - if (cxx_dialect >= cxx11 && !CLASSTYPE_DESTRUCTORS (t) + bool move_ok = false; + if (cxx_dialect >= cxx11 && CLASSTYPE_LAZY_DESTRUCTOR (t) && !TYPE_HAS_COPY_CTOR (t) && !TYPE_HAS_COPY_ASSIGN (t) && !type_has_move_constructor (t) && !type_has_move_assign (t)) move_ok = true; - /* Destructor. */ - if (!CLASSTYPE_DESTRUCTORS (t)) - /* In general, we create destructors lazily. */ - CLASSTYPE_LAZY_DESTRUCTOR (t) = 1; - /* [class.ctor] If there is no user-declared constructor for a class, a default @@ -5015,8 +5014,9 @@ clone_constructors_and_destructors (tree t) we no longer need to know that. */ for (ovl_iterator iter (CLASSTYPE_CONSTRUCTORS (t)); iter; ++iter) clone_function_decl (*iter, /*update_methods=*/true); - for (ovl_iterator iter (CLASSTYPE_DESTRUCTORS (t)); iter; ++iter) - clone_function_decl (*iter, /*update_methods=*/true); + + if (tree dtor = CLASSTYPE_DESTRUCTOR (t)) + clone_function_decl (dtor, /*update_methods=*/true); } /* Deduce noexcept for a destructor DTOR. */ @@ -5029,24 +5029,6 @@ deduce_noexcept_on_destructor (tree dtor) noexcept_deferred_spec); } -/* For each destructor in T, deduce noexcept: - - 12.4/3: A declaration of a destructor that does not have an - exception-specification is implicitly considered to have the - same exception-specification as an implicit declaration (15.4). */ - -static void -deduce_noexcept_on_destructors (tree t) -{ - /* If for some reason we don't have a CLASSTYPE_METHOD_VEC, we bail - out now. */ - if (!CLASSTYPE_METHOD_VEC (t)) - return; - - for (ovl_iterator iter (CLASSTYPE_DESTRUCTORS (t)); iter; ++iter) - deduce_noexcept_on_destructor (*iter); -} - /* Subroutine of set_one_vmethod_tm_attributes. Search base classes of TYPE for virtual functions which FNDECL overrides. Return a mask of the tm attributes found therein. */ @@ -5460,7 +5442,7 @@ type_has_virtual_destructor (tree type) return false; gcc_assert (COMPLETE_TYPE_P (type)); - dtor = CLASSTYPE_DESTRUCTORS (type); + dtor = CLASSTYPE_DESTRUCTOR (type); return (dtor && DECL_VIRTUAL_P (dtor)); } @@ -5851,10 +5833,11 @@ check_bases_and_members (tree t) of potential interest. */ check_bases (t, &cant_have_const_ctor, &no_const_asn_ref); - /* Deduce noexcept on destructors. This needs to happen after we've set + /* Deduce noexcept on destructor. This needs to happen after we've set triviality flags appropriately for our bases. */ if (cxx_dialect >= cxx11) - deduce_noexcept_on_destructors (t); + if (tree dtor = CLASSTYPE_DESTRUCTOR (t)) + deduce_noexcept_on_destructor (dtor); /* Check all the method declarations. */ check_methods (t); diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 1c7a08d2b83..f82b1b6ae10 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -2145,11 +2145,11 @@ struct GTY(()) lang_type { #define CLASSTYPE_CONSTRUCTORS(NODE) \ ((*CLASSTYPE_METHOD_VEC (NODE))[CLASSTYPE_CONSTRUCTOR_SLOT]) -/* A FUNCTION_DECL for the destructor for NODE. These are the +/* A FUNCTION_DECL for the destructor for NODE. This is the destructors that take an in-charge parameter. If CLASSTYPE_LAZY_DESTRUCTOR is true, then this entry will be NULL until the destructor is created with lazily_declare_fn. */ -#define CLASSTYPE_DESTRUCTORS(NODE) \ +#define CLASSTYPE_DESTRUCTOR(NODE) \ (CLASSTYPE_METHOD_VEC (NODE) \ ? (*CLASSTYPE_METHOD_VEC (NODE))[CLASSTYPE_DESTRUCTOR_SLOT] \ : NULL_TREE) @@ -2179,11 +2179,9 @@ struct GTY(()) lang_type { /* The type corresponding to NODE when NODE is used as a base class, i.e., NODE without virtual base classes or tail padding. */ - #define CLASSTYPE_AS_BASE(NODE) (LANG_TYPE_CLASS_CHECK (NODE)->as_base) /* True iff NODE is the CLASSTYPE_AS_BASE version of some type. */ - #define IS_FAKE_BASE_TYPE(NODE) \ (TREE_CODE (NODE) == RECORD_TYPE \ && TYPE_CONTEXT (NODE) && CLASS_TYPE_P (TYPE_CONTEXT (NODE)) \ diff --git a/gcc/cp/except.c b/gcc/cp/except.c index 9e41ec451af..208e52a405b 100644 --- a/gcc/cp/except.c +++ b/gcc/cp/except.c @@ -218,7 +218,7 @@ dtor_nothrow (tree type) if (CLASSTYPE_LAZY_DESTRUCTOR (type)) lazily_declare_fn (sfk_destructor, type); - return TREE_NOTHROW (CLASSTYPE_DESTRUCTORS (type)); + return TREE_NOTHROW (CLASSTYPE_DESTRUCTOR (type)); } /* Build up a call to __cxa_end_catch, to destroy the exception object diff --git a/gcc/cp/init.c b/gcc/cp/init.c index b6f6b4f21a0..14335388a50 100644 --- a/gcc/cp/init.c +++ b/gcc/cp/init.c @@ -4580,8 +4580,7 @@ build_delete (tree otype, tree addr, special_function_kind auto_delete, && MAYBE_CLASS_TYPE_P (type) && !CLASSTYPE_FINAL (type) && TYPE_POLYMORPHIC_P (type)) { - tree dtor; - dtor = CLASSTYPE_DESTRUCTORS (type); + tree dtor = CLASSTYPE_DESTRUCTOR (type); if (!dtor || !DECL_VINDEX (dtor)) { if (CLASSTYPE_PURE_VIRTUALS (type)) @@ -4671,7 +4670,7 @@ build_delete (tree otype, tree addr, special_function_kind auto_delete, /* If the destructor is non-virtual, there is no deleting variant. Instead, we must explicitly call the appropriate `operator delete' here. */ - else if (!DECL_VIRTUAL_P (CLASSTYPE_DESTRUCTORS (type)) + else if (!DECL_VIRTUAL_P (CLASSTYPE_DESTRUCTOR (type)) && auto_delete == sfk_deleting_destructor) { /* We will use ADDR multiple times so we must save it. */ diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 573b97a658f..2ff6afdbf64 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -25679,12 +25679,14 @@ cp_parser_lookup_name (cp_parser *parser, tree name, /* If that's not a class type, there is no destructor. */ if (!type || !CLASS_TYPE_P (type)) return error_mark_node; + if (CLASSTYPE_LAZY_DESTRUCTOR (type)) lazily_declare_fn (sfk_destructor, type); - if (!CLASSTYPE_DESTRUCTORS (type)) - return error_mark_node; - /* If it was a class type, return the destructor. */ - return CLASSTYPE_DESTRUCTORS (type); + + if (tree dtor = CLASSTYPE_DESTRUCTOR (type)) + return dtor; + + return error_mark_node; } /* By this point, the NAME should be an ordinary identifier. If diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 43f9ca8b39e..c724e27b4a1 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -2884,7 +2884,7 @@ check_explicit_specialization (tree declarator, int is_constructor = DECL_CONSTRUCTOR_P (decl); if (is_constructor ? !TYPE_HAS_USER_CONSTRUCTOR (ctype) - : !CLASSTYPE_DESTRUCTORS (ctype)) + : !CLASSTYPE_DESTRUCTOR (ctype)) { /* From [temp.expl.spec]: diff --git a/gcc/cp/rtti.c b/gcc/cp/rtti.c index ff72ce538b2..d73b1bcfa97 100644 --- a/gcc/cp/rtti.c +++ b/gcc/cp/rtti.c @@ -1556,7 +1556,7 @@ emit_support_tinfos (void) bltn_type = TREE_TYPE (bltn_type); if (!COMPLETE_TYPE_P (bltn_type)) return; - tree dtor = CLASSTYPE_DESTRUCTORS (bltn_type); + tree dtor = CLASSTYPE_DESTRUCTOR (bltn_type); if (!dtor || DECL_EXTERNAL (dtor)) return; diff --git a/gcc/cp/search.c b/gcc/cp/search.c index 2630150bfe6..d7895a05593 100644 --- a/gcc/cp/search.c +++ b/gcc/cp/search.c @@ -1592,7 +1592,7 @@ lookup_fnfields_idx_nolazy (tree type, tree name) /* and destructors are second. */ if (name == dtor_identifier) { - fn = CLASSTYPE_DESTRUCTORS (type); + fn = CLASSTYPE_DESTRUCTOR (type); return fn ? CLASSTYPE_DESTRUCTOR_SLOT : -1; } if (IDENTIFIER_CONV_OP_P (name)) -- 2.30.2