From patchwork Tue Feb 26 04:21:35 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 223108 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 E5B762C0089 for ; Tue, 26 Feb 2013 15:21:50 +1100 (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=1362457311; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Message-ID:Date:From:User-Agent:MIME-Version:To:Subject: References:In-Reply-To:Content-Type:Mailing-List:Precedence: List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender: Delivered-To; bh=n7u+6J7uQmJ4qB+2qz+4/IUqChc=; b=pgW9FMgPNKysXQk Vuw9tTawd/9NhIJ7WDn2NaCoukdHZPnBjSP6eV9IZyzk6dDObrhrdVZwX7xCu++e /vWaQUJvNqIk4z9lwhhZLzqaXoTHmTLVrgqe/wBpfmque/OeJfh5vhYDIySnP4ch flz+VhEeUmk2ek/C5VoHvXmx1Aa0= 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:References:In-Reply-To:Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=GvDDURQa4e+hCvgbD10SwLCqwzi1JiMbtn3lwXuk2UQOSBO5og9Mrw7qSfeTy2 EWqxg0FX/P/ALQVEPHLxRtIcXGYHHR+u6eDs547100moBKgcu92Zumu5fAB6nQZJ RQu4ZLA690we4fPtxhjzJblFhPS3QfgyYC8fgdDOe2GPc=; Received: (qmail 21439 invoked by alias); 26 Feb 2013 04:21:44 -0000 Received: (qmail 21430 invoked by uid 22791); 26 Feb 2013 04:21:43 -0000 X-SWARE-Spam-Status: No, hits=-7.4 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, KHOP_SPAMHAUS_DROP, KHOP_THREADED, RCVD_IN_DNSWL_HI, RCVD_IN_HOSTKARMA_W, RP_MATCHES_RCVD, SPF_HELO_PASS, TW_FN 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; Tue, 26 Feb 2013 04:21:36 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r1Q4LaPk014245 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 25 Feb 2013 23:21:36 -0500 Received: from [10.3.113.106] (ovpn-113-106.phx2.redhat.com [10.3.113.106]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r1Q4LZZF024583 for ; Mon, 25 Feb 2013 23:21:36 -0500 Message-ID: <512C384F.6000905@redhat.com> Date: Mon, 25 Feb 2013 23:21:35 -0500 From: Jason Merrill User-Agent: Mozilla/5.0 (X11; Linux i686; rv:21.0) Gecko/20100101 Thunderbird/21.0a2 MIME-Version: 1.0 To: gcc-patches List Subject: Re: C++ PATCH for c++/56377 (missing template binding in diagnostic context) References: <5127C3AF.8040804@redhat.com> In-Reply-To: <5127C3AF.8040804@redhat.com> 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 On 02/22/2013 02:14 PM, Jason Merrill wrote: > When we go to tsubst with explicit_args, we should put them in the tinst > level. OK, that minimal change wasn't enough; we need to delay pushing until we know what arguments we have to work with. Tested x86_64-pc-linux-gnu, applying to trunk. commit 1e712888d97aee95b315f4a2c90f19e412d9dbd3 Author: Jason Merrill Date: Mon Feb 25 16:26:04 2013 -0500 PR c++/56377 * pt.c (fn_type_unification): Wait to call push_tinst_level until we know what args we're looking at. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 5ff0821..9b7fc3a 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -14900,19 +14900,6 @@ fn_type_unification (tree fn, tree tinst; tree r = error_mark_node; - /* Adjust any explicit template arguments before entering the - substitution context. */ - if (explicit_targs) - { - explicit_targs - = (coerce_template_parms (tparms, explicit_targs, NULL_TREE, - complain, - /*require_all_args=*/false, - /*use_default_args=*/false)); - if (explicit_targs == error_mark_node) - return error_mark_node; - } - /* In C++0x, it's possible to have a function template whose type depends on itself recursively. This is most obvious with decltype, but can also occur with enumeration scope (c++/48969). So we need to catch infinite @@ -14926,13 +14913,7 @@ fn_type_unification (tree fn, This is, of course, not reentrant. */ if (excessive_deduction_depth) return error_mark_node; - tinst = build_tree_list (fn, targs); - if (!push_tinst_level (tinst)) - { - excessive_deduction_depth = true; - ggc_free (tinst); - return error_mark_node; - } + tinst = build_tree_list (fn, NULL_TREE); ++deduction_depth; push_deferring_access_checks (dk_deferred); @@ -14962,6 +14943,16 @@ fn_type_unification (tree fn, location_t loc = input_location; bool incomplete = false; + /* Adjust any explicit template arguments before entering the + substitution context. */ + explicit_targs + = (coerce_template_parms (tparms, explicit_targs, NULL_TREE, + complain, + /*require_all_args=*/false, + /*use_default_args=*/false)); + if (explicit_targs == error_mark_node) + goto fail; + /* Substitute the explicit args into the function type. This is necessary so that, for instance, explicitly declared function arguments can match null pointed constants. If we were given @@ -15008,14 +14999,19 @@ fn_type_unification (tree fn, } } + TREE_VALUE (tinst) = explicit_targs; + if (!push_tinst_level (tinst)) + { + excessive_deduction_depth = true; + goto fail; + } processing_template_decl += incomplete; input_location = DECL_SOURCE_LOCATION (fn); - TREE_VALUE (tinst) = explicit_targs; fntype = tsubst (TREE_TYPE (fn), explicit_targs, complain | tf_partial, NULL_TREE); - TREE_VALUE (tinst) = targs; input_location = loc; processing_template_decl -= incomplete; + pop_tinst_level (); if (fntype == error_mark_node) goto fail; @@ -15051,11 +15047,9 @@ fn_type_unification (tree fn, callers must be ready to deal with unification failures in any event. */ - pop_tinst_level (); ok = !type_unification_real (DECL_INNERMOST_TEMPLATE_PARMS (fn), targs, parms, args, nargs, /*subr=*/0, strict, flags, explain_p); - push_tinst_level (tinst); if (!ok) goto fail; @@ -15096,7 +15090,15 @@ fn_type_unification (tree fn, the corresponding deduced argument values. If the substitution results in an invalid type, as described above, type deduction fails. */ + TREE_VALUE (tinst) = targs; + if (!push_tinst_level (tinst)) + { + excessive_deduction_depth = true; + goto fail; + } decl = instantiate_template (fn, targs, complain); + pop_tinst_level (); + if (decl == error_mark_node) goto fail; @@ -15141,7 +15143,6 @@ fn_type_unification (tree fn, excessive_deduction_depth = false; } - pop_tinst_level (); /* We can't free this if a pending_template entry or last_error_tinst_level is pointing at it. */ if (last_pending_template == old_last_pend