* 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
2017-06-27 Nathan Sidwell <nathan@acm.org>
+ * 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.
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. */
/* 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,
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
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. */
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. */
return false;
gcc_assert (COMPLETE_TYPE_P (type));
- dtor = CLASSTYPE_DESTRUCTORS (type);
+ dtor = CLASSTYPE_DESTRUCTOR (type);
return (dtor && DECL_VIRTUAL_P (dtor));
}
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);
#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)
/* 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)) \
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
&& 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))
/* 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. */
/* 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
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]:
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;
/* 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))