From: Nathan Sidwell Date: Fri, 21 Jul 2017 18:11:23 +0000 (+0000) Subject: Remove special CDtor METHOD_VEC slots. X-Git-Tag: upstream/12.2.0~38049 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2401ffc3fe5f79e7a1087d8f98f5e3b8bbb1e379;p=platform%2Fupstream%2Fgcc.git Remove special CDtor METHOD_VEC slots. * cp-tree.h (CLASSTYPE_CONSTRUCTOR_SLOT, CLASSTYPE_DESTRUCTOR_SLOT): Delete. (CLASSTYPE_CONSTRUCTORS): Use lookup_fnfields_slot_nolazy. (CLASSTYPE_DESTRUCTOR): Likewise. * class (add_method): Don't use special cdtor slots. * search.c (lookup_fnfields_idx_nolazy): Likewise. (look_for_overrides_here): Use lookup_fnfields_slot. * semantics (classtype_has_nothrow_assign_or_copy_p): Likewise. From-SVN: r250437 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 7adedbe..9dd5575 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,15 @@ 2017-07-21 Nathan Sidwell + Remove special CDtor METHOD_VEC slots. + * cp-tree.h (CLASSTYPE_CONSTRUCTOR_SLOT, + CLASSTYPE_DESTRUCTOR_SLOT): Delete. + (CLASSTYPE_CONSTRUCTORS): Use lookup_fnfields_slot_nolazy. + (CLASSTYPE_DESTRUCTOR): Likewise. + * class (add_method): Don't use special cdtor slots. + * search.c (lookup_fnfields_idx_nolazy): Likewise. + (look_for_overrides_here): Use lookup_fnfields_slot. + * semantics (classtype_has_nothrow_assign_or_copy_p): Likewise. + * call.c (add_candidates): Move decls to initialization. Don't use !!. diff --git a/gcc/cp/class.c b/gcc/cp/class.c index eac6649..508570b 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -1039,50 +1039,39 @@ add_method (tree type, tree method, bool via_using) we're going to end up with an assignment operator at some point as well. */ vec_alloc (method_vec, 8); - /* Create slots for constructors and destructors. */ - method_vec->quick_push (NULL_TREE); - method_vec->quick_push (NULL_TREE); CLASSTYPE_METHOD_VEC (type) = method_vec; } /* Maintain TYPE_HAS_USER_CONSTRUCTOR, etc. */ grok_special_member_properties (method); - /* Constructors and destructors go in special slots. */ - if (DECL_MAYBE_IN_CHARGE_CONSTRUCTOR_P (method)) - slot = CLASSTYPE_CONSTRUCTOR_SLOT; - else if (DECL_MAYBE_IN_CHARGE_DESTRUCTOR_P (method)) - slot = CLASSTYPE_DESTRUCTOR_SLOT; - else - { - tree m; + tree m; - insert_p = true; - /* See if we already have an entry with this name. */ - for (slot = CLASSTYPE_FIRST_CONVERSION_SLOT; - vec_safe_iterate (method_vec, slot, &m); - ++slot) + insert_p = true; + /* See if we already have an entry with this name. */ + for (slot = CLASSTYPE_FIRST_CONVERSION_SLOT; + vec_safe_iterate (method_vec, slot, &m); + ++slot) + { + m = OVL_FIRST (m); + if (template_conv_p) { - m = OVL_FIRST (m); - if (template_conv_p) - { - if (TREE_CODE (m) == TEMPLATE_DECL - && DECL_TEMPLATE_CONV_FN_P (m)) - insert_p = false; - break; - } - if (conv_p && !DECL_CONV_FN_P (m)) - break; - if (DECL_NAME (m) == DECL_NAME (method)) - { - insert_p = false; - break; - } - if (complete_p - && !DECL_CONV_FN_P (m) - && DECL_NAME (m) > DECL_NAME (method)) - break; + if (TREE_CODE (m) == TEMPLATE_DECL + && DECL_TEMPLATE_CONV_FN_P (m)) + insert_p = false; + break; } + if (conv_p && !DECL_CONV_FN_P (m)) + break; + if (DECL_NAME (m) == DECL_NAME (method)) + { + insert_p = false; + break; + } + if (complete_p + && !DECL_CONV_FN_P (m) + && DECL_NAME (m) > DECL_NAME (method)) + break; } current_fns = insert_p ? NULL_TREE : (*method_vec)[slot]; @@ -1256,7 +1245,7 @@ add_method (tree type, tree method, bool via_using) if (conv_p) TYPE_HAS_CONVERSION (type) = 1; - else if (slot >= CLASSTYPE_FIRST_CONVERSION_SLOT && !complete_p) + else if (!complete_p && !IDENTIFIER_CDTOR_P (DECL_NAME (method))) push_class_level_binding (DECL_NAME (method), current_fns); if (insert_p) diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index a76906d..115cdaf 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -2148,29 +2148,21 @@ struct GTY(()) lang_type { and the RECORD_TYPE for the class template otherwise. */ #define CLASSTYPE_DECL_LIST(NODE) (LANG_TYPE_CLASS_CHECK (NODE)->decl_list) -/* The slot in the CLASSTYPE_METHOD_VEC where constructors go. */ -#define CLASSTYPE_CONSTRUCTOR_SLOT 0 - -/* The slot in the CLASSTYPE_METHOD_VEC where destructors go. */ -#define CLASSTYPE_DESTRUCTOR_SLOT 1 - /* The first slot in the CLASSTYPE_METHOD_VEC where conversion operators can appear. */ -#define CLASSTYPE_FIRST_CONVERSION_SLOT 2 +#define CLASSTYPE_FIRST_CONVERSION_SLOT 0 /* A FUNCTION_DECL or OVERLOAD for the constructors for NODE. These are the constructors that take an in-charge parameter. */ #define CLASSTYPE_CONSTRUCTORS(NODE) \ - ((*CLASSTYPE_METHOD_VEC (NODE))[CLASSTYPE_CONSTRUCTOR_SLOT]) + (lookup_fnfields_slot_nolazy (NODE, ctor_identifier)) /* 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_DESTRUCTOR(NODE) \ - (CLASSTYPE_METHOD_VEC (NODE) \ - ? (*CLASSTYPE_METHOD_VEC (NODE))[CLASSTYPE_DESTRUCTOR_SLOT] \ - : NULL_TREE) + (lookup_fnfields_slot_nolazy (NODE, dtor_identifier)) /* A dictionary of the nested user-defined-types (class-types, or enums) found within this class. This table includes nested member class diff --git a/gcc/cp/search.c b/gcc/cp/search.c index 40caf70..04a229e 100644 --- a/gcc/cp/search.c +++ b/gcc/cp/search.c @@ -1590,18 +1590,6 @@ lookup_fnfields_idx_nolazy (tree type, tree name) if (GATHER_STATISTICS) n_calls_lookup_fnfields_1++; - /* Constructors are first... */ - if (name == ctor_identifier) - { - fn = CLASSTYPE_CONSTRUCTORS (type); - return fn ? CLASSTYPE_CONSTRUCTOR_SLOT : -1; - } - /* and destructors are second. */ - if (name == dtor_identifier) - { - fn = CLASSTYPE_DESTRUCTOR (type); - return fn ? CLASSTYPE_DESTRUCTOR_SLOT : -1; - } if (IDENTIFIER_CONV_OP_P (name)) return lookup_conversion_operator (type, TREE_TYPE (name)); @@ -2428,37 +2416,26 @@ look_for_overrides (tree type, tree fndecl) tree look_for_overrides_here (tree type, tree fndecl) { - int ix; + tree ovl = lookup_fnfields_slot (type, DECL_NAME (fndecl)); - /* If there are no methods in TYPE (meaning that only implicitly - declared methods will ever be provided for TYPE), then there are - no virtual functions. */ - if (!CLASSTYPE_METHOD_VEC (type)) - return NULL_TREE; - - if (DECL_MAYBE_IN_CHARGE_DESTRUCTOR_P (fndecl)) - ix = CLASSTYPE_DESTRUCTOR_SLOT; - else - ix = lookup_fnfields_1 (type, DECL_NAME (fndecl)); - if (ix >= 0) - for (ovl_iterator iter ((*CLASSTYPE_METHOD_VEC (type))[ix]); iter; ++iter) - { - tree fn = *iter; + for (ovl_iterator iter (ovl); iter; ++iter) + { + tree fn = *iter; - if (!DECL_VIRTUAL_P (fn)) - /* Not a virtual. */; - else if (DECL_CONTEXT (fn) != type) - /* Introduced with a using declaration. */; - else if (DECL_STATIC_FUNCTION_P (fndecl)) - { - tree btypes = TYPE_ARG_TYPES (TREE_TYPE (fn)); - tree dtypes = TYPE_ARG_TYPES (TREE_TYPE (fndecl)); - if (compparms (TREE_CHAIN (btypes), dtypes)) - return fn; - } - else if (same_signature_p (fndecl, fn)) - return fn; - } + if (!DECL_VIRTUAL_P (fn)) + /* Not a virtual. */; + else if (DECL_CONTEXT (fn) != type) + /* Introduced with a using declaration. */; + else if (DECL_STATIC_FUNCTION_P (fndecl)) + { + tree btypes = TYPE_ARG_TYPES (TREE_TYPE (fn)); + tree dtypes = TYPE_ARG_TYPES (TREE_TYPE (fndecl)); + if (compparms (TREE_CHAIN (btypes), dtypes)) + return fn; + } + else if (same_signature_p (fndecl, fn)) + return fn; + } return NULL_TREE; } diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index ddb84f2..743adbc 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -9083,15 +9083,7 @@ classtype_has_nothrow_assign_or_copy_p (tree type, bool assign_p) if (assign_p) fns = lookup_fnfields_slot (type, cp_assignment_operator_id (NOP_EXPR)); else if (TYPE_HAS_COPY_CTOR (type)) - { - /* If construction of the copy constructor was postponed, create - it now. */ - if (CLASSTYPE_LAZY_COPY_CTOR (type)) - lazily_declare_fn (sfk_copy_constructor, type); - if (CLASSTYPE_LAZY_MOVE_CTOR (type)) - lazily_declare_fn (sfk_move_constructor, type); - fns = CLASSTYPE_CONSTRUCTORS (type); - } + fns = lookup_fnfields_slot (type, ctor_identifier); bool saw_copy = false; for (ovl_iterator iter (fns); iter; ++iter)