From patchwork Thu Feb 20 03:00:10 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adam Butcher X-Patchwork-Id: 322045 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 2133F2C00C0 for ; Thu, 20 Feb 2014 14:00:36 +1100 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id; q=dns; s=default; b=uU9JREaTfcij UW7k3B8fMEEgg0TRDo+x/odh9itTW+F362lzmian7ZAeHREhX6yViDbO1BImdKAL cLE7LTOuDeAVlnudpDJr/xCH0TEcixolxZakV702iplBm/X2+/mViN/nNgP5ihCp HTtCyqAvJBerbrzexZtp6pazi0DSX3k= 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:from :to:cc:subject:date:message-id; s=default; bh=bhm+6KoDLQbF7yyJe2 m+A1+eDqs=; b=VOq/x2OrEaXkyXhFv0KY7qp6J8hjW2WxHJTftlnshl2excERex f4eT7Y7B7xBrwqfWNQUHaZRVexCCFN0Ds5TVHwBdS0teW7zmZ7Nxr+OjyUMRn1ol YqDsja91EAVKNG7fr686LshsgXDW5mq4fmXagxasmqmDwuV5EI/mSCy+I= Received: (qmail 8183 invoked by alias); 20 Feb 2014 03:00:28 -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 8134 invoked by uid 89); 20 Feb 2014 03:00:24 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.6 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, KAM_COUK, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=no version=3.3.2 X-Spam-User: qpsmtpd, 2 recipients X-HELO: mail-we0-f176.google.com Received: from mail-we0-f176.google.com (HELO mail-we0-f176.google.com) (74.125.82.176) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Thu, 20 Feb 2014 03:00:23 +0000 Received: by mail-we0-f176.google.com with SMTP id q58so999867wes.21 for ; Wed, 19 Feb 2014 19:00:20 -0800 (PST) X-Received: by 10.180.9.51 with SMTP id w19mr9772wia.27.1392865220090; Wed, 19 Feb 2014 19:00:20 -0800 (PST) Received: from xtorus.lan (munkyhouse.force9.co.uk. [84.92.244.81]) by mx.google.com with ESMTPSA id f1sm664176wik.1.2014.02.19.19.00.18 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 19 Feb 2014 19:00:19 -0800 (PST) From: Adam Butcher To: gcc-patches@gcc.gnu.org Cc: Jason Merrill , Volker Reichelt , Adam Butcher Subject: [PATCH] Fix PR c++/60065. Date: Thu, 20 Feb 2014 03:00:10 +0000 Message-Id: <1392865210-1632-1-git-send-email-adam@jessamine.co.uk> PR c++/60065 * parser.c (cp_parser_parameter_declaration_list): Use current_template_parms and scope check as predicate for inspecting current function template parameter list length rather than num_template_parameter_lists. PR c++/60065 * g++.dg/cpp1y/pr60065.C: New testcase. --- gcc/cp/parser.c | 20 +++++++++++++++++--- gcc/testsuite/g++.dg/cpp1y/pr60065.C | 8 ++++++++ 2 files changed, 25 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/g++.dg/cpp1y/pr60065.C diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 68573f1..0b88bd3 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -18241,15 +18241,29 @@ cp_parser_parameter_declaration_list (cp_parser* parser, bool *is_error) = parser->in_unbraced_linkage_specification_p; parser->in_unbraced_linkage_specification_p = false; + /* Determine whether this parameter list applies to a function template + currently being declared to support extending the template with generic + type parameters. */ + bool declaring_template_p = false; + if (current_template_parms) + { + cp_binding_level *maybe_tmpl_scope = current_binding_level->level_chain; + while (maybe_tmpl_scope && maybe_tmpl_scope->kind == sk_class) + maybe_tmpl_scope = maybe_tmpl_scope->level_chain; + if (maybe_tmpl_scope && maybe_tmpl_scope->kind == sk_template_parms) + declaring_template_p = true; + } + /* Look for more parameters. */ while (true) { cp_parameter_declarator *parameter; tree decl = error_mark_node; bool parenthesized_p = false; - int template_parm_idx = (parser->num_template_parameter_lists? - TREE_VEC_LENGTH (INNERMOST_TEMPLATE_PARMS - (current_template_parms)) : 0); + int template_parm_idx = + ((declaring_template_p || parser->fully_implicit_function_template_p)? + TREE_VEC_LENGTH (INNERMOST_TEMPLATE_PARMS + (current_template_parms)) : 0); /* Parse the parameter. */ parameter diff --git a/gcc/testsuite/g++.dg/cpp1y/pr60065.C b/gcc/testsuite/g++.dg/cpp1y/pr60065.C new file mode 100644 index 0000000..2aaa1e3 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/pr60065.C @@ -0,0 +1,8 @@ +// PR c++/60065 +// { dg-do compile } +// { dg-options "-std=c++1y" } + +template void foo(auto... x); +template void foo2(auto... x); +template void foo3(auto... x, auto y, auto... z); +template void foo4(auto... x, auto y, auto... z);