diff options
author | nathan <nathan@138bc75d-0d04-0410-961f-82ee72b054a4> | 2017-09-05 20:13:10 +0000 |
---|---|---|
committer | nathan <nathan@138bc75d-0d04-0410-961f-82ee72b054a4> | 2017-09-05 20:13:10 +0000 |
commit | c682337fd9f6440773d69602a74453a622cbeca2 (patch) | |
tree | 8b7422026ce0fcbd3ad25011ec8c5e4cbe41eeee /gcc/cp/class.c | |
parent | 724582b924ed8a42880dc5c4f9a07c4ee8fad198 (diff) | |
download | gcc-c682337fd9f6440773d69602a74453a622cbeca2.tar.gz |
* class.c (add_method): Move slot search and insertion to ...
* name-lookup.c (get_method_slot): ... this new function.
(lookup_fnfields_slot_nolazy): Cope with NULL slot.
* name-lookup.h (get_method_slot): Declare.
* decl.c (cxx_init_decl_processinng): Give conv_op_marker a more
realistic type.
(grok_special_member_properties): Set
TYPE_HAS_CONVERSION. Expicitly look at DECL_NAME for specialness.
Improve TYPE_HAS_CONSTEXPR_CTOR setting.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@251737 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cp/class.c')
-rw-r--r-- | gcc/cp/class.c | 78 |
1 files changed, 4 insertions, 74 deletions
diff --git a/gcc/cp/class.c b/gcc/cp/class.c index 9e740dbbfb7..d04c2acd25b 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -1011,57 +1011,12 @@ add_method (tree type, tree method, bool via_using) if (method == error_mark_node) return false; - vec<tree, va_gc> *method_vec = CLASSTYPE_METHOD_VEC (type); - if (!method_vec) - { - /* Make a new method vector. We start with 8 entries. */ - vec_alloc (method_vec, 8); - CLASSTYPE_METHOD_VEC (type) = method_vec; - } - /* Maintain TYPE_HAS_USER_CONSTRUCTOR, etc. */ grok_special_member_properties (method); - bool insert_p = true; - tree method_name = DECL_NAME (method); - bool complete_p = COMPLETE_TYPE_P (type); - bool conv_p = IDENTIFIER_CONV_OP_P (method_name); - - if (conv_p) - method_name = conv_op_identifier; - - /* See if we already have an entry with this name. */ - unsigned slot; - tree m; - for (slot = 0; vec_safe_iterate (method_vec, slot, &m); ++slot) - { - m = DECL_NAME (OVL_FIRST (m)); - if (m == method_name) - { - insert_p = false; - break; - } - if (complete_p && m > method_name) - break; - } - tree current_fns = insert_p ? NULL_TREE : (*method_vec)[slot]; + tree *slot = get_method_slot (type, DECL_NAME (method)); + tree current_fns = *slot; - tree conv_marker = NULL_TREE; - if (conv_p) - { - /* For conversion operators, we prepend a dummy overload - pointing at conv_op_marker. That function's DECL_NAME is - conv_op_identifier, so we can use identifier equality to - locate it. */ - if (current_fns) - { - gcc_checking_assert (OVL_FUNCTION (current_fns) == conv_op_marker); - conv_marker = current_fns; - current_fns = OVL_CHAIN (current_fns); - } - else - conv_marker = ovl_make (conv_op_marker, NULL_TREE); - } gcc_assert (!DECL_EXTERN_C_P (method)); /* Check to see if we've already got this method. */ @@ -1209,36 +1164,11 @@ add_method (tree type, tree method, bool via_using) current_fns = ovl_insert (method, current_fns, via_using); - if (conv_p) - { - TYPE_HAS_CONVERSION (type) = 1; - /* Prepend the marker function. */ - OVL_CHAIN (conv_marker) = current_fns; - current_fns = conv_marker; - } - else if (!complete_p && !IDENTIFIER_CDTOR_P (DECL_NAME (method))) + if (!DECL_CONV_FN_P (method) && !COMPLETE_TYPE_P (type)) push_class_level_binding (DECL_NAME (method), current_fns); - if (insert_p) - { - bool reallocated; + *slot = current_fns; - /* We only expect to add few methods in the COMPLETE_P case, so - just make room for one more method in that case. */ - if (complete_p) - reallocated = vec_safe_reserve_exact (method_vec, 1); - else - reallocated = vec_safe_reserve (method_vec, 1); - if (reallocated) - CLASSTYPE_METHOD_VEC (type) = method_vec; - if (slot == method_vec->length ()) - method_vec->quick_push (current_fns); - else - method_vec->quick_insert (slot, current_fns); - } - else - /* Replace the current slot. */ - (*method_vec)[slot] = current_fns; return true; } |