From patchwork Tue Jul 30 17:52:57 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 263457 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 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "localhost", Issuer "www.qmailtoaster.com" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 2263E2C00BC for ; Wed, 31 Jul 2013 03:53:22 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:cc:subject:content-type; q=dns; s=default; b=MLV9okWYXz2H9wjn3cJunJNJqXXHbyoqvj75n7bdziD P+gT1pHqWvsjQqkGyUF68PKQAb5D46thGbu9GXfxSnijxFkmvvK88OlDVhL8wPFF LJeCwssFXVSKvgf65/pdN5/i3Bn9o/mZojoRbvyEeTvKSk5lCKiZGkRGeuRb7e5s = 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 :message-id:date:from:mime-version:to:cc:subject:content-type; s=default; bh=MS+Oqd+LM27FLRslRoRrLyKefAA=; b=YRI1HZSXAjdRrFz+M r8hSpf2+kGHFtTteXPu2luluXtzKaeBWaPgvmyjb7dE5T0fD8gZQKV63m03UR9WN HEtc6M4gH/mJgiBkBlCY+LyYRTc7Z5ExIGLWLZ4CN7T3vvuHaAlEo3PPDyTQBBvd 14JZUqhQBL5pybpq6HSHXFS1RU= Received: (qmail 29399 invoked by alias); 30 Jul 2013 17:53:14 -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 29389 invoked by uid 89); 30 Jul 2013 17:53:14 -0000 X-Spam-SWARE-Status: No, score=-4.9 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_MED, RCVD_IN_HOSTKARMA_NO, RCVD_IN_HOSTKARMA_W, RDNS_NONE, SPF_PASS, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from Unknown (HELO aserp1040.oracle.com) (141.146.126.69) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Tue, 30 Jul 2013 17:53:09 +0000 Received: from acsinet22.oracle.com (acsinet22.oracle.com [141.146.126.238]) by aserp1040.oracle.com (Sentrion-MTA-4.3.1/Sentrion-MTA-4.3.1) with ESMTP id r6UHr0Ip031619 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 30 Jul 2013 17:53:01 GMT Received: from aserz7022.oracle.com (aserz7022.oracle.com [141.146.126.231]) by acsinet22.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r6UHr05P021747 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 30 Jul 2013 17:53:00 GMT Received: from abhmt114.oracle.com (abhmt114.oracle.com [141.146.116.66]) by aserz7022.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r6UHr0nd021723; Tue, 30 Jul 2013 17:53:00 GMT Received: from poldo4.casa (/79.25.197.131) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 30 Jul 2013 10:52:59 -0700 Message-ID: <51F7FD79.6060103@oracle.com> Date: Tue, 30 Jul 2013 19:52:57 +0200 From: Paolo Carlini User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130620 Thunderbird/17.0.7 MIME-Version: 1.0 To: "gcc-patches@gcc.gnu.org" CC: Jason Merrill Subject: [C++ Patch] PR 57673 X-Virus-Found: No Hi, we currently fail to parse this rather simple NSDMI usage (note that wrapping the whole initializer in parentheses works around the problem because cp_parser_cache_group handles the special case). Simply detecting that we are parsing an ellipsis in an nsdmi and not ending the main while loop in that case appears to work fine. If we think we must be stricter we may consider keeping memory that the previous token was a sizeof or... something else. Tested x86_64-linux. Thanks, Paolo. //////////////////////// /cp 2013-07-30 Paolo Carlini PR c++/57673 * parser.c (cp_parser_cache_defarg): In an NSDMI don't stop when token->type == CPP_ELLIPSIS. /testsuite 2013-07-30 Paolo Carlini PR c++/57673 * g++.dg/cpp0x/nsdmi-sizeof.C: New. Index: cp/parser.c =================================================================== --- cp/parser.c (revision 201343) +++ cp/parser.c (working copy) @@ -24145,7 +24145,9 @@ cp_parser_cache_defarg (cp_parser *parser, bool ns case CPP_SEMICOLON: case CPP_CLOSE_BRACE: case CPP_CLOSE_SQUARE: - if (depth == 0) + if (depth == 0 + /* Handle correctly int n = sizeof ... ( p ); */ + && !(nsdmi && token->type == CPP_ELLIPSIS)) done = true; /* Update DEPTH, if necessary. */ else if (token->type == CPP_CLOSE_PAREN Index: testsuite/g++.dg/cpp0x/nsdmi-sizeof.C =================================================================== --- testsuite/g++.dg/cpp0x/nsdmi-sizeof.C (revision 0) +++ testsuite/g++.dg/cpp0x/nsdmi-sizeof.C (working copy) @@ -0,0 +1,7 @@ +// PR c++/57673 +// { dg-do compile { target c++11 } } + +template< int ... p > +struct d { + int n = sizeof ... ( p ); +};