From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 101427 invoked by alias); 10 May 2017 20:57:32 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 100949 invoked by uid 89); 10 May 2017 20:57:32 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-yw0-f178.google.com Received: from mail-yw0-f178.google.com (HELO mail-yw0-f178.google.com) (209.85.161.178) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 10 May 2017 20:57:30 +0000 Received: by mail-yw0-f178.google.com with SMTP id 203so4028993ywe.0 for ; Wed, 10 May 2017 13:57:33 -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=sJAkyAIH9vtcxd9BXMai6HqOVrhVhwlGMe47KSJ1Urk=; b=sNKO689E69zWBYzOEIpDgWRddIhWyMFut7IYmQ4FJHwMns/3GvPX/nY5SvoF/XhC0b Ne3dZOETKpwo8mnQmKT85GE6uUgEa+bh/aLWNmeCAowW9M/kgwjhSCejumzg6pjB3v7F +iBnRuyZgzYlVxK5G/uSWMysMxCva43dlPIuTnQW4+wAMSbrfEudIF78S+u8+5xKj/Nn k3xWOAabfIovR7bt+XgWFnxIysP7lkTAWkFf/BN9bWg5xmR78nELBYL6a3uq74wt8pIB AJn4JCeTvW5efmuIKVxfS5MTQaDuHYp2yxXhYtuevRrz6unwOjO0SwXG6WYrAMC72A4r fYxA== X-Gm-Message-State: AODbwcBvi0Q6pN2CjTYnIlFSXOErx85Hr8ny7dRmdRc0xyH1wn9AV2t1 bRZq1ebbOUcOFA== X-Received: by 10.13.196.129 with SMTP id g123mr6445447ywd.21.1494449851731; Wed, 10 May 2017 13:57:31 -0700 (PDT) Received: from ?IPv6:2620:10d:c0a1:1102:b9b0:1beb:d21c:b3f4? ([2620:10d:c091:180::a343]) by smtp.googlemail.com with ESMTPSA id b74sm65377ywa.25.2017.05.10.13.57.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 May 2017 13:57:31 -0700 (PDT) To: GCC Patches From: Nathan Sidwell Subject: [C++ PATCH] address of overload Message-ID: <7299e46d-23de-54cd-d2e6-cee6a2bbf95e@acm.org> Date: Wed, 10 May 2017 21:18:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.1.0 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------8A2ECDFA54C00D5E24A8BF84" X-SW-Source: 2017-05/txt/msg00832.txt.bz2 This is a multi-part message in MIME format. --------------8A2ECDFA54C00D5E24A8BF84 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-length: 334 We were gratuitously checking for an overload before using OVL_CURRENT, and then unilaterally using OVL_CURRENT on the result of that. I also simplify taking the address of an overloaded fn by using'for (tree fn ...) idiom. And strip out another unneeded anticipated decl stripping. Applied to trunk. nathan -- Nathan Sidwell --------------8A2ECDFA54C00D5E24A8BF84 Content-Type: text/x-patch; name="addr.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="addr.diff" Content-length: 2940 2017-05-10 Nathan Sidwell * class.c (handle_using_decl): Always use OVL_CURRENT. (resolve_address_of_overloaded_function): Move iterator decl into for scope. Don't strip anticipated decls here. Index: class.c =================================================================== --- class.c (revision 247863) +++ class.c (working copy) @@ -1359,8 +1359,7 @@ handle_using_decl (tree using_decl, tree tf_warning_or_error); if (old_value) { - if (is_overloaded_fn (old_value)) - old_value = OVL_CURRENT (old_value); + old_value = OVL_CURRENT (old_value); if (DECL_P (old_value) && DECL_CONTEXT (old_value) == t) /* OK */; @@ -1384,7 +1383,7 @@ handle_using_decl (tree using_decl, tree { error ("%q+D invalid in %q#T", using_decl, t); error (" because of local method %q+#D with same name", - OVL_CURRENT (old_value)); + old_value); return; } } @@ -8184,39 +8183,29 @@ 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) - { - tree fns; - - for (fns = overload; fns; fns = OVL_NEXT (fns)) - { - tree fn = OVL_CURRENT (fns); - - if (TREE_CODE (fn) == TEMPLATE_DECL) - /* We're not looking for templates just yet. */ - continue; + for (tree fns = overload; fns; fns = OVL_NEXT (fns)) + { + tree fn = OVL_CURRENT (fns); - if ((TREE_CODE (TREE_TYPE (fn)) == METHOD_TYPE) - != is_ptrmem) - /* We're looking for a non-static member, and this isn't - one, or vice versa. */ - continue; + if (TREE_CODE (fn) == TEMPLATE_DECL) + /* We're not looking for templates just yet. */ + continue; - /* Ignore functions which haven't been explicitly - declared. */ - if (DECL_ANTICIPATED (fn)) - continue; + if ((TREE_CODE (TREE_TYPE (fn)) == METHOD_TYPE) != is_ptrmem) + /* We're looking for a non-static member, and this isn't + one, or vice versa. */ + continue; - /* In C++17 we need the noexcept-qualifier to compare types. */ - if (flag_noexcept_type) - maybe_instantiate_noexcept (fn); - - /* See if there's a match. */ - tree fntype = static_fn_type (fn); - if (same_type_p (target_fn_type, fntype) - || fnptr_conv_p (target_fn_type, fntype)) - matches = tree_cons (fn, NULL_TREE, matches); - } - } + /* In C++17 we need the noexcept-qualifier to compare types. */ + if (flag_noexcept_type) + maybe_instantiate_noexcept (fn); + + /* See if there's a match. */ + tree fntype = static_fn_type (fn); + if (same_type_p (target_fn_type, fntype) + || fnptr_conv_p (target_fn_type, fntype)) + matches = tree_cons (fn, NULL_TREE, matches); + } /* Now, if we've already got a match (or matches), there's no need to proceed to the template functions. But, if we don't have a --------------8A2ECDFA54C00D5E24A8BF84--