From patchwork Thu Aug 6 01:30:32 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 504452 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]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id B65FB1402AB for ; Thu, 6 Aug 2015 11:30:57 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=X5lWRL6i; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=Re6Yv6iYUIa6mgJMMP9c+Wtu+jMNoshjmgBvuQYnISq/ZIDGj2 pTqkx5LMWYrDQZ9Z5Wkl8sgGSntbTQ7aaJn1wZga5I76Tkk4CwDrDHIP/IcEkH7A EnBSPnJK6rgS6FvH7iWnQcZB/53vXHMt3VhVEnXY4jYzEqZHKW8UldO6M= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to :from:subject:message-id:date:mime-version:content-type; s= default; bh=ZJYli1gVbfZYVQzrnbMuJ0VuOFQ=; b=X5lWRL6isyDNbBaH61RY iwpyKYxOFzBZLMtKltlhqC1AROTDPo60uxT9bk4i38gF3pPuUVBJT/NtQ4plm3kZ 84nRRDzWd8ZgtsgEtIGQkTPwP3r51XpyYwANHMAAsZ0xD3j37Tjmj8IGwrC1TAFc b9Th/CA8BBLMlt3NQQ73Zn8= Received: (qmail 24598 invoked by alias); 6 Aug 2015 01:30:49 -0000 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 Received: (qmail 24587 invoked by uid 89); 6 Aug 2015 01:30:49 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.1 required=5.0 tests=AWL, BAYES_40, KAM_LAZY_DOMAIN_SECURITY, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=no version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Thu, 06 Aug 2015 01:30:39 +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 (Postfix) with ESMTPS id BEF2036B1B5 for ; Thu, 6 Aug 2015 01:30:37 +0000 (UTC) Received: from [10.10.116.24] ([10.10.116.24]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t761UaE3007733 for ; Wed, 5 Aug 2015 21:30:37 -0400 To: gcc-patches List From: Jason Merrill Subject: 2 C++ cleanup PATCHes Message-ID: <55C2B8B8.20307@redhat.com> Date: Wed, 5 Aug 2015 21:30:32 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 1) While working on 66260, it struck me as odd that finish_id_expression had its own code for determining whether an id-expression is dependent, rather than using type_dependent_expression_p. So this patch tears out a bunch of code and replaces it with a call; t_d_e_p already handled everything except a TEMPLATE_ID_EXPR with an IDENTIFIER_NODE as its lhs. I also needed to tweak handling of CONST_DECLs so that we return them unchanged even if there is an explicit scope. 2) When we reject an explicit specialization because there is no template that matches it, it would be friendly to print a list of the candidates considered. Tested x86_64-pc-linux-gnu, applying to trunk. commit a54cb70add522cfa4c10cc1efc39108db7a7d60f Author: Jason Merrill Date: Wed Aug 5 17:03:08 2015 -0400 * pt.c (determine_specialization): Print candidates after 'no match' error. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 5f28f1b..08fb2ff 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -1952,6 +1952,8 @@ determine_specialization (tree template_id, b = b->level_chain) ++header_count; + tree orig_fns = fns; + if (variable_template_p (fns)) { tree parms = INNERMOST_TEMPLATE_PARMS (DECL_TEMPLATE_PARMS (fns)); @@ -2168,6 +2170,8 @@ determine_specialization (tree template_id, inform (input_location, "saw %d %%>, need %d for " "specializing a member function template", header_count, template_count + 1); + else + print_candidates (orig_fns); return error_mark_node; } else if ((templates && TREE_CHAIN (templates)) diff --git a/gcc/testsuite/g++.dg/template/spec39.C b/gcc/testsuite/g++.dg/template/spec39.C new file mode 100644 index 0000000..9e4f8be --- /dev/null +++ b/gcc/testsuite/g++.dg/template/spec39.C @@ -0,0 +1,3 @@ +template void f(T); // { dg-message "void f" } +template <> int f(int); // { dg-error "does not match" } +