From patchwork Tue May 16 17:38:09 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Sidwell X-Patchwork-Id: 763087 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3wS4Rm6BbFz9s0g for ; Wed, 17 May 2017 03:38:26 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="LIn9I0Ir"; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=WEnejYYaYfkJ7z5ZNy2l4cj79BWM4SBgsSieM60JoQluuKdFOY R7+BGL3yvHDPl2cznct+ev1pKpawQlVNMkeYM2EOK0ZKtA/3F2RuhpuO7R42NPmi WCMPNzBr52FMD1N+sm2dna8i49CbbN1KEx499AOlPvzhrxftr8a8Z5kbM= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to :from:subject:message-id:date:mime-version:content-type; s= default; bh=j36IvqV9uNs+U8OKm1394ipCV20=; b=LIn9I0Irw1PyA5h+QHBc RjVdYsUCmszH1sfjwyPd4OAaJRLo8WTwbmpHIXZrFGtKxl50FPj+mnfo4/lOIfPp +gYALY3kSWiuzHrLWoJvUVGMB7ag3Rc36A4z8WYsBRebBTXn74rPSl4SVfdScn+U TzQedmOhwf3nbITQuj1fATk= Received: (qmail 25533 invoked by alias); 16 May 2017 17:38:14 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 25516 invoked by uid 89); 16 May 2017 17:38:13 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-10.6 required=5.0 tests=BAYES_00, FREEMAIL_FROM, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-yw0-f173.google.com Received: from mail-yw0-f173.google.com (HELO mail-yw0-f173.google.com) (209.85.161.173) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 16 May 2017 17:38:10 +0000 Received: by mail-yw0-f173.google.com with SMTP id l14so56606884ywk.1 for ; Tue, 16 May 2017 10:38:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:to:from:subject:message-id:date :user-agent:mime-version:content-language; bh=Yw9l/Bp59KnaQQwyqO8ColIHkgKaqDz3LxV6ffr0Q7k=; b=Z8Ud9Kp7tDcp3ACRhk5mLvm++5piold5CJWIV6+2pCj8+qMQxGJ+hswR67RZRaUV8G 6Aw9VMD0OI67hs6Ne+jvQhg3YNgL+5/khQBpOGNmJoYUOpXO8jKXroCtPUUjoVpgQ9ZN PEXi/L+N/CoLqvERjVxcKqnF7p+ayV32voWDZ+TW2pr6OOqU1aid8L4hJQP+rj7BxzC4 cHB7DtX/LQviksrg8i0jD4UhjgHQWv+0k54Z0e+sEzbpur0KUD5eSUPMA7/Uj/J4NSBs cyXrHQXE3gB4gTxQeb7H9tiVPEyAeM7DQHBLJDFenZQd8YPrG4IAjACFj/QtnWJUXAJ5 lAsA== X-Gm-Message-State: AODbwcBokWUusK0hISGKsaGrpipy4nZwyTR1RC0kc+T/pwKmLVpGN9/X BJJJqX4N4mkB+A== X-Received: by 10.129.152.68 with SMTP id p65mr10416226ywg.1.1494956291437; Tue, 16 May 2017 10:38:11 -0700 (PDT) Received: from ?IPv6:2620:10d:c0a3:20fb:f6d0:5ac5:64cd:f102? ([2620:10d:c091:200::7:4a1a]) by smtp.googlemail.com with ESMTPSA id e62sm7403371ywa.62.2017.05.16.10.38.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 16 May 2017 10:38:10 -0700 (PDT) To: GCC Patches From: Nathan Sidwell Subject: [C++ PATCH] Overload iterators #2 Message-ID: Date: Tue, 16 May 2017 13:38:09 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.1.0 MIME-Version: 1.0 This patch converts more pieces to use {ovl,lkp}_iterator. Also a few places OVL_FIRST should now be being used. I don't think anything here is particularly obscure. nathan 2017-05-16 Nathan Sidwell * call.c (build_user_type_conversion_1): Use OVL_FIRST. (print_error_for_call_faulure): Use OVL_NAME. (build_op_call_1): Use ovl_iterator. (add_candidates): Use OVL_FIRST & lkp_iterator. (build_op_delete_call): Use MAYBE_BASELINK_FUNCTIONS & lkp_iterator. * class.c (deduce_noexcept_on_destructors): Use ovl_iterator. (type_has_user_nondefault_constructor, in_class_defaulted_default_constructor, type_has_user_provided_constructor, type_has_user_provided_or_explicit_constructor, type_has_non_user_provided_default_constructor, vbase_has_user_provided_move_assign, type_has_move_constructor, type_has_move_assign, type_has_user_declared_move_constructor, type_has_user_declared_move_assign, type_build_ctor_call, type_build_dtor_call, type_requires_array_cookie, explain_non_literal_class): Likewise. (finish_struct): Use lkp_iterator. (resolve_address_of_overloaded_function): Use OVL_NAME, lkp_iterator. (note_name_declared_in_class): Use OVL_NAME. * cxx-pretty-print.c (pp_cxx_unqualified_id): Use OVL_FIRST. (pp_cxx_qualified_id, cxx_pretty_printer::id_expression, cxx_pretty_printer::expression): Likewise. * decl2.c (check_classfn): Use ovl_iterator. * pt.c (retrieve_specialization): Use ovl_iterator. * tree.c (cp_tree_equal): Use lkp_iterator. (type_has_nontrivial_copy_init): Use ovl_iterator. Index: call.c =================================================================== --- call.c (revision 248119) +++ call.c (working copy) @@ -3783,8 +3783,8 @@ build_user_type_conversion_1 (tree totyp /* We should never try to call the abstract or base constructor from here. */ - gcc_assert (!DECL_HAS_IN_CHARGE_PARM_P (OVL_CURRENT (ctors)) - && !DECL_HAS_VTT_PARM_P (OVL_CURRENT (ctors))); + gcc_assert (!DECL_HAS_IN_CHARGE_PARM_P (OVL_FIRST (ctors)) + && !DECL_HAS_VTT_PARM_P (OVL_FIRST (ctors))); args = make_tree_vector_single (expr); if (BRACE_ENCLOSED_INITIALIZER_P (expr)) @@ -4172,7 +4172,7 @@ print_error_for_call_failure (tree fn, v targs = TREE_OPERAND (fn, 1); fn = TREE_OPERAND (fn, 0); } - tree name = DECL_NAME (OVL_CURRENT (fn)); + tree name = OVL_NAME (fn); location_t loc = location_of (name); if (targs) name = lookup_template_function (name, targs); @@ -4449,16 +4449,15 @@ build_op_call_1 (tree obj, vec *fn_args; - fn = OVL_CURRENT (fns); + fn = *iter; if (check_converting && DECL_NONCONVERTING_P (fn)) continue; @@ -6201,8 +6199,7 @@ build_op_delete_call (enum tree_code cod if (fn == error_mark_node) return NULL_TREE; - if (BASELINK_P (fn)) - fn = BASELINK_FUNCTIONS (fn); + fn = MAYBE_BASELINK_FUNCTIONS (fn); /* "If the lookup finds the two-parameter form of a usual deallocation function (3.7.4.2) and that function, considered as a placement @@ -6221,10 +6218,10 @@ build_op_delete_call (enum tree_code cod the usual deallocation function, so we shouldn't complain about using the operator delete (void *, size_t). */ if (DECL_CLASS_SCOPE_P (fn)) - for (t = BASELINK_P (fns) ? BASELINK_FUNCTIONS (fns) : fns; - t; t = OVL_NEXT (t)) + for (lkp_iterator iter (MAYBE_BASELINK_FUNCTIONS (fns)); + iter; ++iter) { - tree elt = OVL_CURRENT (t); + tree elt = *iter; if (usual_deallocation_fn_p (elt) && FUNCTION_ARG_CHAIN (elt) == void_list_node) goto ok; @@ -6263,10 +6260,9 @@ build_op_delete_call (enum tree_code cod allocation function. If the lookup finds a single matching deallocation function, that function will be called; otherwise, no deallocation function will be called." */ - for (t = BASELINK_P (fns) ? BASELINK_FUNCTIONS (fns) : fns; - t; t = OVL_NEXT (t)) + for (lkp_iterator iter (MAYBE_BASELINK_FUNCTIONS (fns)); iter; ++iter) { - tree elt = OVL_CURRENT (t); + tree elt = *iter; if (usual_deallocation_fn_p (elt)) { if (!fn) Index: class.c =================================================================== --- class.c (revision 248119) +++ class.c (working copy) @@ -5069,8 +5069,8 @@ deduce_noexcept_on_destructors (tree t) if (!CLASSTYPE_METHOD_VEC (t)) return; - for (tree fns = CLASSTYPE_DESTRUCTORS (t); fns; fns = OVL_NEXT (fns)) - deduce_noexcept_on_destructor (OVL_CURRENT (fns)); + for (ovl_iterator iter (CLASSTYPE_DESTRUCTORS (t)); iter; ++iter) + deduce_noexcept_on_destructor (*iter); } /* Subroutine of set_one_vmethod_tm_attributes. Search base classes @@ -5230,14 +5230,12 @@ default_ctor_p (tree fn) bool type_has_user_nondefault_constructor (tree t) { - tree fns; - if (!TYPE_HAS_USER_CONSTRUCTOR (t)) return false; - for (fns = CLASSTYPE_CONSTRUCTORS (t); fns; fns = OVL_NEXT (fns)) + for (ovl_iterator iter (CLASSTYPE_CONSTRUCTORS (t)); iter; ++iter) { - tree fn = OVL_CURRENT (fns); + tree fn = *iter; if (!DECL_ARTIFICIAL (fn) && (TREE_CODE (fn) == TEMPLATE_DECL || (skip_artificial_parms_for (fn, DECL_ARGUMENTS (fn)) @@ -5257,9 +5255,9 @@ in_class_defaulted_default_constructor ( if (!TYPE_HAS_USER_CONSTRUCTOR (t)) return NULL_TREE; - for (tree fns = CLASSTYPE_CONSTRUCTORS (t); fns; fns = OVL_NEXT (fns)) + for (ovl_iterator iter (CLASSTYPE_CONSTRUCTORS (t)); iter; ++iter) { - tree fn = OVL_CURRENT (fns); + tree fn = *iter; if (DECL_DEFAULTED_IN_CLASS_P (fn) && default_ctor_p (fn)) @@ -5288,8 +5286,6 @@ user_provided_p (tree fn) bool type_has_user_provided_constructor (tree t) { - tree fns; - if (!CLASS_TYPE_P (t)) return false; @@ -5300,8 +5296,8 @@ type_has_user_provided_constructor (tree if (!CLASSTYPE_METHOD_VEC (t)) return false; - for (fns = CLASSTYPE_CONSTRUCTORS (t); fns; fns = OVL_NEXT (fns)) - if (user_provided_p (OVL_CURRENT (fns))) + for (ovl_iterator iter (CLASSTYPE_CONSTRUCTORS (t)); iter; ++iter) + if (user_provided_p (*iter)) return true; return false; @@ -5312,8 +5308,6 @@ type_has_user_provided_constructor (tree bool type_has_user_provided_or_explicit_constructor (tree t) { - tree fns; - if (!CLASS_TYPE_P (t)) return false; @@ -5324,9 +5318,9 @@ type_has_user_provided_or_explicit_const if (!CLASSTYPE_METHOD_VEC (t)) return false; - for (fns = CLASSTYPE_CONSTRUCTORS (t); fns; fns = OVL_NEXT (fns)) + for (ovl_iterator iter (CLASSTYPE_CONSTRUCTORS (t)); iter; ++iter) { - tree fn = OVL_CURRENT (fns); + tree fn = *iter; if (user_provided_p (fn) || DECL_NONCONVERTING_P (fn)) return true; } @@ -5341,16 +5335,14 @@ type_has_user_provided_or_explicit_const bool type_has_non_user_provided_default_constructor (tree t) { - tree fns; - if (!TYPE_HAS_DEFAULT_CONSTRUCTOR (t)) return false; if (CLASSTYPE_LAZY_DEFAULT_CTOR (t)) return true; - for (fns = CLASSTYPE_CONSTRUCTORS (t); fns; fns = OVL_NEXT (fns)) + for (ovl_iterator iter (CLASSTYPE_CONSTRUCTORS (t)); iter; ++iter) { - tree fn = OVL_CURRENT (fns); + tree fn = *iter; if (TREE_CODE (fn) == FUNCTION_DECL && default_ctor_p (fn) && !user_provided_p (fn)) @@ -5369,11 +5361,11 @@ bool vbase_has_user_provided_move_assign (tree type) { /* Does the type itself have a user-provided move assignment operator? */ - for (tree fns - = lookup_fnfields_slot_nolazy (type, cp_assignment_operator_id (NOP_EXPR)); - fns; fns = OVL_NEXT (fns)) + for (ovl_iterator iter (lookup_fnfields_slot_nolazy + (type, cp_assignment_operator_id (NOP_EXPR))); + iter; ++iter) { - tree fn = OVL_CURRENT (fns); + tree fn = *iter; if (move_fn_p (fn) && user_provided_p (fn)) return true; } @@ -5503,8 +5495,6 @@ type_has_virtual_destructor (tree type) bool type_has_move_constructor (tree t) { - tree fns; - if (CLASSTYPE_LAZY_MOVE_CTOR (t)) { gcc_assert (COMPLETE_TYPE_P (t)); @@ -5514,8 +5504,8 @@ type_has_move_constructor (tree t) if (!CLASSTYPE_METHOD_VEC (t)) return false; - for (fns = CLASSTYPE_CONSTRUCTORS (t); fns; fns = OVL_NEXT (fns)) - if (move_fn_p (OVL_CURRENT (fns))) + for (ovl_iterator iter (CLASSTYPE_CONSTRUCTORS (t)); iter; ++iter) + if (move_fn_p (*iter)) return true; return false; @@ -5526,17 +5516,16 @@ type_has_move_constructor (tree t) bool type_has_move_assign (tree t) { - tree fns; - if (CLASSTYPE_LAZY_MOVE_ASSIGN (t)) { gcc_assert (COMPLETE_TYPE_P (t)); lazily_declare_fn (sfk_move_assignment, t); } - for (fns = lookup_fnfields_slot_nolazy (t, cp_assignment_operator_id (NOP_EXPR)); - fns; fns = OVL_NEXT (fns)) - if (move_fn_p (OVL_CURRENT (fns))) + for (ovl_iterator iter (lookup_fnfields_slot_nolazy + (t, cp_assignment_operator_id (NOP_EXPR))); + iter; ++iter) + if (move_fn_p (*iter)) return true; return false; @@ -5550,17 +5539,15 @@ type_has_move_assign (tree t) bool type_has_user_declared_move_constructor (tree t) { - tree fns; - if (CLASSTYPE_LAZY_MOVE_CTOR (t)) return false; if (!CLASSTYPE_METHOD_VEC (t)) return false; - for (fns = CLASSTYPE_CONSTRUCTORS (t); fns; fns = OVL_NEXT (fns)) + for (ovl_iterator iter (CLASSTYPE_CONSTRUCTORS (t)); iter; ++iter) { - tree fn = OVL_CURRENT (fns); + tree fn = *iter; if (move_fn_p (fn) && !DECL_ARTIFICIAL (fn)) return true; } @@ -5574,15 +5561,14 @@ type_has_user_declared_move_constructor bool type_has_user_declared_move_assign (tree t) { - tree fns; - if (CLASSTYPE_LAZY_MOVE_ASSIGN (t)) return false; - for (fns = lookup_fnfields_slot_nolazy (t, cp_assignment_operator_id (NOP_EXPR)); - fns; fns = OVL_NEXT (fns)) + for (ovl_iterator iter (lookup_fnfields_slot_nolazy + (t, cp_assignment_operator_id (NOP_EXPR))); + iter; ++iter) { - tree fn = OVL_CURRENT (fns); + tree fn = *iter; if (move_fn_p (fn) && !DECL_ARTIFICIAL (fn)) return true; } @@ -5615,10 +5601,11 @@ type_build_ctor_call (tree t) return false; /* A user-declared constructor might be private, and a constructor might be trivial but deleted. */ - for (tree fns = lookup_fnfields_slot (inner, complete_ctor_identifier); - fns; fns = OVL_NEXT (fns)) + for (ovl_iterator iter + (lookup_fnfields_slot (inner, complete_ctor_identifier)); + iter; ++iter) { - tree fn = OVL_CURRENT (fns); + tree fn = *iter; if (!DECL_ARTIFICIAL (fn) || DECL_DELETED_FN (fn)) return true; @@ -5642,10 +5629,11 @@ type_build_dtor_call (tree t) return false; /* A user-declared destructor might be private, and a destructor might be trivial but deleted. */ - for (tree fns = lookup_fnfields_slot (inner, complete_dtor_identifier); - fns; fns = OVL_NEXT (fns)) + for (ovl_iterator iter + (lookup_fnfields_slot (inner, complete_dtor_identifier)); + iter; ++iter) { - tree fn = OVL_CURRENT (fns); + tree fn = *iter; if (!DECL_ARTIFICIAL (fn) || DECL_DELETED_FN (fn)) return true; @@ -5707,16 +5695,13 @@ type_requires_array_cookie (tree type) if (!fns || fns == error_mark_node) return false; /* Loop through all of the functions. */ - for (fns = BASELINK_FUNCTIONS (fns); fns; fns = OVL_NEXT (fns)) + for (lkp_iterator iter (BASELINK_FUNCTIONS (fns)); iter; ++iter) { - tree fn; - tree second_parm; + tree fn = *iter; - /* Select the current function. */ - fn = OVL_CURRENT (fns); /* See if this function is a one-argument delete function. If it is, then it will be the usual deallocation function. */ - second_parm = TREE_CHAIN (TYPE_ARG_TYPES (TREE_TYPE (fn))); + tree second_parm = TREE_CHAIN (TYPE_ARG_TYPES (TREE_TYPE (fn))); if (second_parm == void_list_node) return false; /* Do not consider this function if its second argument is an @@ -5808,26 +5793,23 @@ explain_non_literal_class (tree t) "default constructor, and has no constexpr constructor that " "is not a copy or move constructor", t); if (type_has_non_user_provided_default_constructor (t)) - { - /* Note that we can't simply call locate_ctor because when the - constructor is deleted it just returns NULL_TREE. */ - tree fns; - for (fns = CLASSTYPE_CONSTRUCTORS (t); fns; fns = OVL_NEXT (fns)) - { - tree fn = OVL_CURRENT (fns); - tree parms = TYPE_ARG_TYPES (TREE_TYPE (fn)); + /* Note that we can't simply call locate_ctor because when the + constructor is deleted it just returns NULL_TREE. */ + for (ovl_iterator iter (CLASSTYPE_CONSTRUCTORS (t)); iter; ++iter) + { + tree fn = *iter; + tree parms = TYPE_ARG_TYPES (TREE_TYPE (fn)); - parms = skip_artificial_parms_for (fn, parms); + parms = skip_artificial_parms_for (fn, parms); - if (sufficient_parms_p (parms)) - { - if (DECL_DELETED_FN (fn)) - maybe_explain_implicit_delete (fn); - else - explain_invalid_constexpr_fn (fn); - break; - } - } + if (sufficient_parms_p (parms)) + { + if (DECL_DELETED_FN (fn)) + maybe_explain_implicit_delete (fn); + else + explain_invalid_constexpr_fn (fn); + break; + } } } else @@ -7508,8 +7490,8 @@ finish_struct (tree t, tree attributes) { tree fn = strip_using_decl (x); if (is_overloaded_fn (fn)) - for (; fn; fn = OVL_NEXT (fn)) - add_method (t, OVL_CURRENT (fn), x); + for (lkp_iterator iter (fn); iter; ++iter) + add_method (t, *iter, true); } /* Remember current #pragma pack value. */ @@ -8165,7 +8147,7 @@ resolve_address_of_overloaded_function ( if (complain & tf_error) error ("cannot resolve overloaded function %qD based on" " conversion to type %qT", - DECL_NAME (OVL_FUNCTION (overload)), target_type); + OVL_NAME (overload), target_type); return error_mark_node; } @@ -8183,9 +8165,9 @@ resolve_address_of_overloaded_function ( if we're just going to throw them out anyhow. But, of course, we can only do this when we don't *need* a template function. */ if (!template_only) - for (tree fns = overload; fns; fns = OVL_NEXT (fns)) + for (lkp_iterator iter (overload); iter; ++iter) { - tree fn = OVL_CURRENT (fns); + tree fn = *iter; if (TREE_CODE (fn) == TEMPLATE_DECL) /* We're not looking for templates just yet. */ @@ -8214,7 +8196,6 @@ resolve_address_of_overloaded_function ( { tree target_arg_types; tree target_ret_type; - tree fns; tree *args; unsigned int nargs, ia; tree arg; @@ -8230,9 +8211,9 @@ resolve_address_of_overloaded_function ( args[ia] = TREE_VALUE (arg); nargs = ia; - for (fns = overload; fns; fns = OVL_NEXT (fns)) + for (lkp_iterator iter (overload); iter; ++iter) { - tree fn = OVL_CURRENT (fns); + tree fn = *iter; tree instantiation; tree targs; @@ -8309,8 +8290,7 @@ resolve_address_of_overloaded_function ( if (complain & tf_error) { error ("no matches converting function %qD to type %q#T", - DECL_NAME (OVL_CURRENT (overload)), - target_type); + OVL_NAME (overload), target_type); print_candidates (overload); } @@ -8337,8 +8317,7 @@ resolve_address_of_overloaded_function ( if (complain & tf_error) { error ("converting overloaded function %qD to type %q#T is ambiguous", - DECL_NAME (OVL_FUNCTION (overload)), - target_type); + OVL_NAME (overload), target_type); /* Since print_candidates expects the functions in the TREE_VALUE slot, we flip them here. */ @@ -8750,7 +8729,7 @@ note_name_declared_in_class (tree name, permerror (input_location, "declaration of %q#D", decl); permerror (location_of ((tree) n->value), "changes meaning of %qD from %q#D", - DECL_NAME (OVL_CURRENT (decl)), (tree) n->value); + OVL_NAME (decl), (tree) n->value); } } Index: cxx-pretty-print.c =================================================================== --- cxx-pretty-print.c (revision 248119) +++ cxx-pretty-print.c (working copy) @@ -141,7 +141,7 @@ pp_cxx_unqualified_id (cxx_pretty_printe break; case OVERLOAD: - t = OVL_CURRENT (t); + t = OVL_FIRST (t); /* FALLTHRU */ case VAR_DECL: case PARM_DECL: @@ -281,7 +281,7 @@ pp_cxx_qualified_id (cxx_pretty_printer FIXME: This is probably the wrong pretty-printing for conversion functions and some function templates. */ case OVERLOAD: - t = OVL_CURRENT (t); + t = OVL_FIRST (t); /* FALLTHRU */ case FUNCTION_DECL: if (DECL_FUNCTION_MEMBER_P (t)) @@ -350,7 +350,7 @@ void cxx_pretty_printer::id_expression (tree t) { if (TREE_CODE (t) == OVERLOAD) - t = OVL_CURRENT (t); + t = OVL_FIRST (t); if (DECL_P (t) && DECL_CONTEXT (t)) pp_cxx_qualified_id (this, t); else @@ -1066,7 +1066,7 @@ cxx_pretty_printer::expression (tree t) break; case OVERLOAD: - t = OVL_CURRENT (t); + t = OVL_FIRST (t); /* FALLTHRU */ case VAR_DECL: case PARM_DECL: Index: decl2.c =================================================================== --- decl2.c (revision 248119) +++ decl2.c (working copy) @@ -608,18 +608,12 @@ check_classfn (tree ctype, tree function if (ix >= 0) { vec *methods = CLASSTYPE_METHOD_VEC (ctype); - tree fndecls, fndecl = 0; - bool is_conv_op; - const char *format = NULL; - for (fndecls = (*methods)[ix]; - fndecls; fndecls = OVL_NEXT (fndecls)) + for (ovl_iterator iter ((*methods)[ix]); iter; ++iter) { - tree p1, p2; - - fndecl = OVL_CURRENT (fndecls); - p1 = TYPE_ARG_TYPES (TREE_TYPE (function)); - p2 = TYPE_ARG_TYPES (TREE_TYPE (fndecl)); + tree fndecl = *iter; + tree p1 = TYPE_ARG_TYPES (TREE_TYPE (function)); + tree p2 = TYPE_ARG_TYPES (TREE_TYPE (fndecl)); /* We cannot simply call decls_match because this doesn't work for static member functions that are pretending to @@ -662,49 +656,47 @@ check_classfn (tree ctype, tree function && (!DECL_TEMPLATE_SPECIALIZATION (function) || (DECL_TI_TEMPLATE (function) == DECL_TI_TEMPLATE (fndecl)))) - break; - } - if (fndecls) - { - if (pushed_scope) - pop_scope (pushed_scope); - return OVL_CURRENT (fndecls); + { + if (pushed_scope) + pop_scope (pushed_scope); + return fndecl; + } } - + error_at (DECL_SOURCE_LOCATION (function), "prototype for %q#D does not match any in class %qT", function, ctype); - is_conv_op = DECL_CONV_FN_P (fndecl); + + const char *format = NULL; + tree first = OVL_FIRST ((*methods)[ix]); + bool is_conv_op = DECL_CONV_FN_P (first); + tree prev = NULL_TREE; if (is_conv_op) ix = CLASSTYPE_FIRST_CONVERSION_SLOT; - fndecls = (*methods)[ix]; - while (fndecls) + do { - fndecl = OVL_CURRENT (fndecls); - fndecls = OVL_NEXT (fndecls); - - if (!fndecls && is_conv_op) + ovl_iterator iter ((*methods)[ix++]); + if (is_conv_op && !DECL_CONV_FN_P (*iter)) + break; + for (; iter; ++iter) { - if (methods->length () > (size_t) ++ix) + if (prev) { - fndecls = (*methods)[ix]; - if (!DECL_CONV_FN_P (OVL_CURRENT (fndecls))) - { - fndecls = NULL_TREE; - is_conv_op = false; - } + if (!format) + format = N_("candidates are: %+#D"); + error (format, prev); + format = " %+#D"; } - else - is_conv_op = false; + prev = *iter; } - if (format) - format = " %+#D"; - else if (fndecls) - format = N_("candidates are: %+#D"); - else + } + while (is_conv_op && size_t (ix) < methods->length ()); + if (prev) + { + if (!format) format = N_("candidate is: %+#D"); - error (format, fndecl); + error (format, prev); } } else if (!COMPLETE_TYPE_P (ctype)) Index: pt.c =================================================================== --- pt.c (revision 248119) +++ pt.c (working copy) @@ -1187,31 +1187,25 @@ retrieve_specialization (tree tmpl, tree if (optimize_specialization_lookup_p (tmpl)) { - tree class_template; - tree class_specialization; - vec *methods; - tree fns; - int idx; - /* The template arguments actually apply to the containing class. Find the class specialization with those arguments. */ - class_template = CLASSTYPE_TI_TEMPLATE (DECL_CONTEXT (tmpl)); - class_specialization + tree class_template = CLASSTYPE_TI_TEMPLATE (DECL_CONTEXT (tmpl)); + tree class_specialization = retrieve_specialization (class_template, args, 0); if (!class_specialization) return NULL_TREE; /* Now, find the appropriate entry in the CLASSTYPE_METHOD_VEC for the specialization. */ - idx = class_method_index_for_fn (class_specialization, tmpl); + int idx = class_method_index_for_fn (class_specialization, tmpl); if (idx == -1) return NULL_TREE; /* Iterate through the methods with the indicated name, looking for the one that has an instance of TMPL. */ - methods = CLASSTYPE_METHOD_VEC (class_specialization); - for (fns = (*methods)[idx]; fns; fns = OVL_NEXT (fns)) + vec *methods = CLASSTYPE_METHOD_VEC (class_specialization); + for (ovl_iterator iter ((*methods)[idx]); iter; ++iter) { - tree fn = OVL_CURRENT (fns); + tree fn = *iter; if (DECL_TEMPLATE_INFO (fn) && DECL_TI_TEMPLATE (fn) == tmpl /* using-declarations can add base methods to the method vec, and we don't want those here. */ Index: tree.c =================================================================== --- tree.c (revision 248119) +++ tree.c (working copy) @@ -3403,9 +3403,16 @@ cp_tree_equal (tree t1, tree t2) return same_type_p (PTRMEM_CST_CLASS (t1), PTRMEM_CST_CLASS (t2)); case OVERLOAD: - if (OVL_FUNCTION (t1) != OVL_FUNCTION (t2)) - return false; - return cp_tree_equal (OVL_CHAIN (t1), OVL_CHAIN (t2)); + { + /* Two overloads. Must be exactly the same set of decls. */ + lkp_iterator first (t1); + lkp_iterator second (t2); + + for (; first && second; ++first, ++second) + if (*first != *second) + return false; + return !(first || second); + } case TRAIT_EXPR: if (TRAIT_EXPR_KIND (t1) != TRAIT_EXPR_KIND (t2)) @@ -3682,9 +3689,9 @@ type_has_nontrivial_copy_init (const_tre } if (!saw_non_deleted && CLASSTYPE_METHOD_VEC (t)) - for (tree fns = CLASSTYPE_CONSTRUCTORS (t); fns; fns = OVL_NEXT (fns)) + for (ovl_iterator iter (CLASSTYPE_CONSTRUCTORS (t)); iter; ++iter) { - tree fn = OVL_CURRENT (fns); + tree fn = *iter; if (copy_fn_p (fn)) { saw_copy = true;