From patchwork Wed Jan 11 16:45:43 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 135427 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 F13FFB6F13 for ; Thu, 12 Jan 2012 03:46:14 +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=1326905175; h=Comment: DomainKey-Signature:Received: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=qeA5fb2 bQLCYEB5EH7PhpwOPsh4=; b=I8F+QjB88KdaBNtLNFIvEkua65KHEJd+eKgFLhR 2vKbhYZNJHvviRyIaUVlWpGPBnxgpWnbD84eFx5oYF6bdKKh5nZRKDFTHzkV7Zdj A47WUg5A4aeDfGvrEGHkvbawACVVOmcHxUw5eOn+NsfFOWUq+tclqIPZrkz698wT bnuE= 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: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=HjRhmawcaM/XMiyGMqR5PBIZDxeeYIr+fZbPMmHL0j+z9/SWcbwbuVUdoZAPaB MlMR8RNDX5LAFiBH6/mb9UKcswxIO1qPOqshUguWDF7L7Dgk47k+2z/CUL28ivA6 ABlRvPnbpt4sLvocAy9DWHxBS6Q9tBdaJT/j/spTdiOnM=; Received: (qmail 16362 invoked by alias); 11 Jan 2012 16:46:03 -0000 Received: (qmail 16304 invoked by uid 22791); 11 Jan 2012 16:46:00 -0000 X-SWARE-Spam-Status: No, hits=-6.6 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, SPF_HELO_PASS, TW_DF, T_RP_MATCHES_RCVD 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; Wed, 11 Jan 2012 16:45:45 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q0BGjj7C023165 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 11 Jan 2012 11:45:45 -0500 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id q0BGjicx024357 for ; Wed, 11 Jan 2012 11:45:44 -0500 Received: from [0.0.0.0] (ovpn-113-115.phx2.redhat.com [10.3.113.115]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id q0BGjhNY000384 for ; Wed, 11 Jan 2012 11:45:44 -0500 Message-ID: <4F0DBCB7.4090704@redhat.com> Date: Wed, 11 Jan 2012 11:45:43 -0500 From: Jason Merrill User-Agent: Mozilla/5.0 (X11; Linux i686; rv:9.0) Gecko/20111222 Thunderbird/9.0 MIME-Version: 1.0 To: gcc-patches List Subject: C++ PATCH for c++/51613 (accepts-invalid with ambiguous template instantiation) 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 Simple thinko; when copy/pasting this loop from elsewhere we needed to change decls_match to same_type_p since here we're just dealing with types. Tested x86_64-pc-linux-gnu, applying to trunk. commit 32ca2088d87e3a3204cc28f4d7fa543d5616f8b6 Author: Jason Merrill Date: Wed Jan 11 09:05:31 2012 -0500 PR c++/51613 * pt.c (resolve_overloaded_unification): Compare types with same_type_p, not decls_match. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index bc3dd97..ac72b6d 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -15471,7 +15471,7 @@ resolve_overloaded_unification (tree tparms, elem = tsubst (TREE_TYPE (fn), subargs, tf_none, NULL_TREE); if (try_one_overload (tparms, targs, tempargs, parm, elem, strict, sub_strict, addr_p, explain_p) - && (!goodfn || !decls_match (goodfn, elem))) + && (!goodfn || !same_type_p (goodfn, elem))) { goodfn = elem; ++good; diff --git a/gcc/testsuite/g++.dg/template/explicit-args5.C b/gcc/testsuite/g++.dg/template/explicit-args5.C new file mode 100644 index 0000000..d6c9a57 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/explicit-args5.C @@ -0,0 +1,24 @@ +// PR c++/51613 + +template +void apply(F f, T t) +{ + f(t); +} + +template +void multi(T) +{ +} + +template +void multi(T*) +{ +} + +int main() +{ + apply(&multi, 7); // { dg-error "no match" } + + return 0; +} commit a03d5b81f06edbe8b919baa4791f2d52ef223582 Author: Jason Merrill Date: Wed Jan 11 09:05:49 2012 -0500 * decl.c (decls_match): Assert that the arguments are decls. diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 7daac5f..ef43dbf 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -952,6 +952,8 @@ decls_match (tree newdecl, tree olddecl) interested in their types. */ return 0; + gcc_assert (DECL_P (newdecl)); + if (TREE_CODE (newdecl) == FUNCTION_DECL) { tree f1 = TREE_TYPE (newdecl);