From patchwork Sat Jan 4 09:54:58 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adam Butcher X-Patchwork-Id: 307100 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 3F6F32C00BD for ; Mon, 6 Jan 2014 15:16:18 +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=NmExQCVZOKXh f5rR9YEda18Zb4ZownUEJR7ClfMBcD2K27H1qn0ovKJc01MIY08i+3mHJUzgmSvb nUS7Q5Xqc6Ris5oARrRZwJamXcV2WLoua2FbZN9s+H+2CQbj7ZaKWf+md6CoB09h 2wsDtxSsCji2EarnqGgghOmYGiFIOUY= 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=RTMboFThafs+wRFgdU 53pmBBWLE=; b=ZBZEGX7G5Dbp7eV8Mu0fXTODwbxmoi28tx7CQjUsHrC5Lwfeh4 HZWWK3kecl3xBCBReVjqwqCERyQkWW2YeV75jhX5EYMlVAxpYDvByiuTfmD8Mib3 hAv88Sg1LqiicthKslywwf6/M25r5Huw0YtPdxlRqyHKlNMZFZAANaWvw= Received: (qmail 7273 invoked by alias); 6 Jan 2014 04:16:11 -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 7254 invoked by uid 89); 6 Jan 2014 04:16:09 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.9 required=5.0 tests=AWL, BAYES_00, DATE_IN_PAST_24_48, 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-wi0-f175.google.com Received: from mail-wi0-f175.google.com (HELO mail-wi0-f175.google.com) (209.85.212.175) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Mon, 06 Jan 2014 04:16:09 +0000 Received: by mail-wi0-f175.google.com with SMTP id hi5so2344251wib.14 for ; Sun, 05 Jan 2014 20:16:05 -0800 (PST) X-Received: by 10.194.57.243 with SMTP id l19mr1530359wjq.54.1388981765753; Sun, 05 Jan 2014 20:16:05 -0800 (PST) Received: from xtorus.lan (munkyhouse.force9.co.uk. [84.92.244.81]) by mx.google.com with ESMTPSA id po3sm41561730wjc.3.2014.01.05.20.16.04 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 05 Jan 2014 20:16:05 -0800 (PST) From: Adam Butcher To: gcc-patches@gcc.gnu.org Cc: Jason Merrill , Volker Reichelt , Adam Butcher Subject: [PATCH] Fix PR c++/59638 Date: Sat, 4 Jan 2014 09:54:58 +0000 Message-Id: <1388829298-14606-1-git-send-email-adam@jessamine.co.uk> * cp/parser.c (cp_parser_init_declarator): Undo fully implicit template parameter list when declarator is not a function. * g++.dg/cpp1y/pr59638.C: New testcase. --- gcc/cp/parser.c | 8 ++++++++ gcc/testsuite/g++.dg/cpp1y/pr59638.C | 16 ++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 gcc/testsuite/g++.dg/cpp1y/pr59638.C diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 0e013b9..991588d 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -16784,6 +16784,14 @@ cp_parser_init_declarator (cp_parser* parser, warning (OPT_Wattributes, "attributes after parenthesized initializer ignored"); + /* Declarations involving function parameter lists containing implicit + template parameters will have been made into implicit templates. If they + do not turn out to be actual function declarations then finish the + template declaration here. */ + if (parser->fully_implicit_function_template_p) + if (!function_declarator_p (declarator)) + finish_fully_implicit_template (parser, /*member_decl_opt=*/0); + /* For an in-class declaration, use `grokfield' to create the declaration. */ if (member_p) diff --git a/gcc/testsuite/g++.dg/cpp1y/pr59638.C b/gcc/testsuite/g++.dg/cpp1y/pr59638.C new file mode 100644 index 0000000..cd9dcdf --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/pr59638.C @@ -0,0 +1,16 @@ +// { dg-do compile } +// { dg-options "-std=gnu++1y" } + +// PR c++/59638 + + +void (*a)(auto); // { dg-error "template declaration" } + +void (*b)(auto) = 0; // { dg-error "template declaration" } + +typedef void (*f)(auto); // { dg-error "template declaration" } + +struct A +{ + int i; +};