From patchwork Mon Nov 21 00:10:45 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 126673 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 9A3E9B7105 for ; Mon, 21 Nov 2011 11:11:10 +1100 (EST) Received: (qmail 16600 invoked by alias); 21 Nov 2011 00:11:06 -0000 Received: (qmail 16573 invoked by uid 22791); 21 Nov 2011 00:11:00 -0000 X-SWARE-Spam-Status: No, hits=-7.2 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, 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; Mon, 21 Nov 2011 00:10:47 +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 pAL0AlRc019983 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Sun, 20 Nov 2011 19:10:47 -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 pAL0AkCD024365 for ; Sun, 20 Nov 2011 19:10:46 -0500 Received: from [0.0.0.0] (ovpn-113-155.phx2.redhat.com [10.3.113.155]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id pAL0AjGU024984 for ; Sun, 20 Nov 2011 19:10:46 -0500 Message-ID: <4EC99705.4030904@redhat.com> Date: Sun, 20 Nov 2011 19:10:45 -0500 From: Jason Merrill User-Agent: Mozilla/5.0 (X11; Linux i686; rv:8.0) Gecko/20111112 Thunderbird/8.0 MIME-Version: 1.0 To: gcc-patches List Subject: C++ PATCH to diagnostic location for default template arguments 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 It seems to me that when we give diagnostics during substitution of a default template argument, the source location should be the definition of the default argument, not the call site; when we get there we will have already said that the call didn't find a match, and are explaining why the template isn't a match. Tested x86_64-pc-linux-gnu, applying to trunk. commit 1031c69cc4844896d0345831ab4ad068bef889f5 Author: Jason Merrill Date: Fri Nov 18 23:25:03 2011 -0500 * pt.c (type_unification_real): Set input_location during default arg instantiation. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 2b02fa4..3232527 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -15218,9 +15218,13 @@ type_unification_real (tree tparms, { tree parm = TREE_VALUE (TREE_VEC_ELT (tparms, i)); tree arg = TREE_PURPOSE (TREE_VEC_ELT (tparms, i)); + location_t save_loc = input_location; + if (DECL_P (parm)) + input_location = DECL_SOURCE_LOCATION (parm); arg = tsubst_template_arg (arg, targs, complain, NULL_TREE); arg = convert_template_argument (parm, arg, targs, complain, i, NULL_TREE); + input_location = save_loc; if (arg == error_mark_node) return 1; else diff --git a/gcc/testsuite/g++.dg/cpp0x/sfinae11.C b/gcc/testsuite/g++.dg/cpp0x/sfinae11.C index 25902cb..2e8408d 100644 --- a/gcc/testsuite/g++.dg/cpp0x/sfinae11.C +++ b/gcc/testsuite/g++.dg/cpp0x/sfinae11.C @@ -12,7 +12,8 @@ inline void f1( T& x ) noexcept( noexcept( declval().foo() ) ) // { dg-error } template< class T, - bool Noexcept = noexcept( declval().foo() ) + bool Noexcept = noexcept( declval().foo() ) // { dg-error "no member|not convert" } + > inline void f2( T& x ) noexcept( Noexcept ) { @@ -51,7 +52,6 @@ int main() // static_assert( noexcept( f3(y) ), "shall be ill-formed(OK)." ); noexcept( f1(z) ); // { dg-message "required" } - static_assert( noexcept( f2(z) ), "shall be ill-formed." ); // { dg-error "no match|could not convert" } - // { dg-error "no member" "" { target *-*-* } 54 } + static_assert( noexcept( f2(z) ), "shall be ill-formed." ); // { dg-error "no match" } noexcept( f3(z) ); // { dg-message "required" } } diff --git a/gcc/testsuite/g++.dg/template/unify11.C b/gcc/testsuite/g++.dg/template/unify11.C index 25606dc..85bdbbc 100644 --- a/gcc/testsuite/g++.dg/template/unify11.C +++ b/gcc/testsuite/g++.dg/template/unify11.C @@ -6,9 +6,10 @@ struct A { }; -template +template // { dg-error "is not a" } typename S::A -foo (S c, T t, U u) // { dg-message "note" } +foo (S c, T t, U u) { } @@ -20,8 +21,7 @@ struct B C (U t) { A a; - A b = foo (this, a, t); // { dg-error "(no matching function|is not a)" } - // { dg-message "candidate" "candidate note" { target *-*-* } 23 } + A b = foo (this, a, t); // { dg-error "no matching function" } } } c; B () : c (A ()) diff --git a/libstdc++-v3/testsuite/20_util/bind/ref_neg.cc b/libstdc++-v3/testsuite/20_util/bind/ref_neg.cc index f5a08c2..d2441a3 100644 --- a/libstdc++-v3/testsuite/20_util/bind/ref_neg.cc +++ b/libstdc++-v3/testsuite/20_util/bind/ref_neg.cc @@ -29,8 +29,12 @@ int inc(int& i) { return ++i; } void test01() { const int dummy = 0; - std::bind(&inc, _1)(0); // { dg-error "no match|rvalue" } - std::bind(&inc, std::ref(dummy))(); // { dg-error "no match|const" } + std::bind(&inc, _1)(0); // { dg-error "no match" } + // { dg-error "rvalue|const" "" { target *-*-* } 1199 } + // { dg-error "rvalue|const" "" { target *-*-* } 1212 } + // { dg-error "rvalue|const" "" { target *-*-* } 1226 } + // { dg-error "rvalue|const" "" { target *-*-* } 1240 } + std::bind(&inc, std::ref(dummy))(); // { dg-error "no match" } } struct Inc