From patchwork Fri Aug 24 18:57:20 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 179880 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]) by ozlabs.org (Postfix) with SMTP id C0BDD2C00D2 for ; Sat, 25 Aug 2012 04:57:50 +1000 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1346439471; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Message-ID:Date:From:User-Agent:MIME-Version:To:Subject: Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:Sender:Delivered-To; bh=kmTS/NP ypv78rHaO2AR6rKIc8r4=; b=Ui2rKmso44mSo4juCUP9wxzE/C/eKg8kkw0suVA hP5mWuVgDgYgjmoE7Sa64scXNhFMI3tb6xumniIhuC4+su2xtwCQE4VpMPvq3Whb VDot4V8RmULBkqCjnMp1BPbofiui2/VZmfkW6iOIF7T6d5yhMREqHHbJC0iuVPV+ MXY4= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:Message-ID:Date:From:User-Agent:MIME-Version:To:Subject:Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=OOnKXfzT+Bh3/ilShUg3nJXoAqp3GthRjwnHicae6rACj3zLghFF0NIrQU1S+Z jiOELMpx95nsXmkkyMBsifJ9GdoYPeR9bFMbW/tT7HzU8cLh9xIvsbd40hgF4HYv knADYEzF7ur6+bzxJ4JrVRCX9QNOHuZoUB05myy3kzCmY=; Received: (qmail 20672 invoked by alias); 24 Aug 2012 18:57:43 -0000 Received: (qmail 20338 invoked by uid 22791); 24 Aug 2012 18:57:41 -0000 X-SWARE-Spam-Status: No, hits=-6.4 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, RCVD_IN_DNSWL_HI, RCVD_IN_HOSTKARMA_W, RP_MATCHES_RCVD, SPF_HELO_PASS X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 24 Aug 2012 18:57:22 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q7OIvLav017051 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 24 Aug 2012 14:57:21 -0400 Received: from [10.3.113.29] (ovpn-113-29.phx2.redhat.com [10.3.113.29]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q7OIvKcI011730 for ; Fri, 24 Aug 2012 14:57:21 -0400 Message-ID: <5037CE90.9020703@redhat.com> Date: Fri, 24 Aug 2012 14:57:20 -0400 From: Jason Merrill User-Agent: Mozilla/5.0 (X11; Linux i686; rv:14.0) Gecko/20120717 Thunderbird/14.0 MIME-Version: 1.0 To: gcc-patches List Subject: C++ PATCH to remove get_bindings special case 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 While looking at another issue, I found the special case in get_bindings for unifying the template with itself odd; the places where we have been using it can just use coerce_template_parms instead. Tested x86_64-pc-linux-gnu, applying to trunk. commit 521c93c5aef7a96f9506ade3fb4759ac1cc7fdc0 Author: Jason Merrill Date: Sun Aug 12 22:13:51 2012 -0400 * pt.c (resolve_overloaded_unification): Use coerce_template_parms instead of get_bindings. (resolve_nondeduced_context): Likewise. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 580a3d4..eff0b4d 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -15246,10 +15246,12 @@ resolve_overloaded_unification (tree tparms, if (TREE_CODE (fn) != TEMPLATE_DECL) continue; - ++processing_template_decl; - subargs = get_bindings (fn, DECL_TEMPLATE_RESULT (fn), - expl_subargs, /*check_ret=*/false); - if (subargs && !any_dependent_template_arguments_p (subargs)) + subargs = coerce_template_parms (DECL_INNERMOST_TEMPLATE_PARMS (fn), + expl_subargs, NULL_TREE, tf_none, + /*require_all_args=*/true, + /*use_default_args=*/true); + if (subargs != error_mark_node + && !any_dependent_template_arguments_p (subargs)) { elem = tsubst (TREE_TYPE (fn), subargs, tf_none, NULL_TREE); if (try_one_overload (tparms, targs, tempargs, parm, @@ -15262,7 +15264,6 @@ resolve_overloaded_unification (tree tparms, } else if (subargs) ++ok; - --processing_template_decl; } /* If no templates (or more than one) are fully resolved by the explicit arguments, this template-id is a non-deduced context; it @@ -15367,10 +15368,12 @@ resolve_nondeduced_context (tree orig_expr) if (TREE_CODE (fn) != TEMPLATE_DECL) continue; - ++processing_template_decl; - subargs = get_bindings (fn, DECL_TEMPLATE_RESULT (fn), - expl_subargs, /*check_ret=*/false); - if (subargs && !any_dependent_template_arguments_p (subargs)) + subargs = coerce_template_parms (DECL_INNERMOST_TEMPLATE_PARMS (fn), + expl_subargs, NULL_TREE, tf_none, + /*require_all_args=*/true, + /*use_default_args=*/true); + if (subargs != error_mark_node + && !any_dependent_template_arguments_p (subargs)) { elem = instantiate_template (fn, subargs, tf_none); if (elem == error_mark_node) @@ -15384,7 +15387,6 @@ resolve_nondeduced_context (tree orig_expr) ++good; } } - --processing_template_decl; } if (good == 1) { @@ -15435,6 +15437,9 @@ try_one_overload (tree tparms, tree tempargs; int i; + if (arg == error_mark_node) + return 0; + /* [temp.deduct.type] A template-argument can be deduced from a pointer to function or pointer to member function argument if the set of overloaded functions does not contain function templates and at most @@ -17129,40 +17134,13 @@ get_bindings (tree fn, tree decl, tree explicit_args, bool check_rettype) { int ntparms = DECL_NTPARMS (fn); tree targs = make_tree_vec (ntparms); - tree decl_type; + tree decl_type = TREE_TYPE (decl); tree decl_arg_types; tree *args; unsigned int nargs, ix; tree arg; - /* Substitute the explicit template arguments into the type of DECL. - The call to fn_type_unification will handle substitution into the - FN. */ - decl_type = TREE_TYPE (decl); - if (explicit_args && decl == DECL_TEMPLATE_RESULT (fn)) - { - tree tmpl; - tree converted_args; - - if (DECL_TEMPLATE_INFO (decl)) - tmpl = DECL_TI_TEMPLATE (decl); - else - /* We can get here for some invalid specializations. */ - return NULL_TREE; - - converted_args - = coerce_template_parms (DECL_INNERMOST_TEMPLATE_PARMS (tmpl), - explicit_args, NULL_TREE, - tf_none, - /*require_all_args=*/false, - /*use_default_args=*/false); - if (converted_args == error_mark_node) - return NULL_TREE; - - decl_type = tsubst (decl_type, converted_args, tf_none, NULL_TREE); - if (decl_type == error_mark_node) - return NULL_TREE; - } + gcc_assert (decl != DECL_TEMPLATE_RESULT (fn)); /* Never do unification on the 'this' parameter. */ decl_arg_types = skip_artificial_parms_for (decl,