From patchwork Wed Jun 5 00:34:00 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 248876 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 0DA922C009E for ; Wed, 5 Jun 2013 10:34:14 +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=B2eQMb1+HYWKR/ViHcQ++EmNM8YtqxfYZfrYQ4gObSE WYN7+fNZf+rmLv/xT6SeZw4XcTDTIlf84HZPqyOuekUf1WZrg2mYtC7skpUNCO5t jms7MeE48kkxzg8onU8Jn9MRPuL6zh5yRN1ue5nlaPMuU+l2P9Qrm1L9RPvbhHqE = 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=qcCOj/2IYl1v4xoPrDgnbWKUFZ8=; b=YCPkul09k89JYyMsb L6M/IoTmDbrJ5cCZOj4S0kqufxprAyAOSyoVp89IbuCBM5fl/iDGVX4Q12Lw87v4 N4BUtfNKtnS+GJtsCfo5N10XE3B6dCr/8qucCopfox7MD3n1i4w1nX7paOUjkEl2 ++hidpaGMjX3CoAbvaZ6/whjuU= Received: (qmail 19884 invoked by alias); 5 Jun 2013 00:34:08 -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 19874 invoked by uid 89); 5 Jun 2013 00:34:08 -0000 X-Spam-SWARE-Status: No, score=-5.6 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_MED, RCVD_IN_HOSTKARMA_NO, RP_MATCHES_RCVD, SPF_PASS, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from userp1040.oracle.com (HELO userp1040.oracle.com) (156.151.31.81) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Wed, 05 Jun 2013 00:34:07 +0000 Received: from ucsinet22.oracle.com (ucsinet22.oracle.com [156.151.31.94]) by userp1040.oracle.com (Sentrion-MTA-4.3.1/Sentrion-MTA-4.3.1) with ESMTP id r550Y2lj031314 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 5 Jun 2013 00:34:03 GMT Received: from userz7021.oracle.com (userz7021.oracle.com [156.151.31.85]) by ucsinet22.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r550Y3qC011553 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 5 Jun 2013 00:34:04 GMT Received: from abhmt117.oracle.com (abhmt117.oracle.com [141.146.116.69]) by userz7021.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r550Y3Cx010070; Wed, 5 Jun 2013 00:34:03 GMT Received: from poldo4.casa (/79.47.194.228) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 04 Jun 2013 17:34:03 -0700 Message-ID: <51AE8778.8080901@oracle.com> Date: Wed, 05 Jun 2013 02:34:00 +0200 From: Paolo Carlini User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130510 Thunderbird/17.0.6 MIME-Version: 1.0 To: "gcc-patches@gcc.gnu.org" CC: Jason Merrill Subject: [C++ Patch] PR 51908 X-Virus-Found: No Hi, this ICE on valid happens in the cp_parser_abort_tentative_parse called at the end of cp_parser_decltype_expr. I started seriously looking into it when I noticed that a variant of the testcase not using variadic templates is fine, thus I concentrated on cp_parser_parameter_declaration and noticed an inconsistency in the following comment and the code implementing it: /* After seeing a decl-specifier-seq, if the next token is not a - "(", there is no possibility that the code is a valid + "(" nor '...', there is no possibility that the code is a valid expression. Therefore, if parsing tentatively, we commit at this point. */ clearly in the case at issue of decl-specifier-seq followed by ellipsis we may be parsing a perfectly valid declaration. Tested x86_64-linux, as usual. Thanks, Paolo. //////////////////////// /cp 2013-06-05 Paolo Carlini PR c++/51908 * parser.c (cp_parser_parameter_declaration): Do not commit to tentative parse after a decl-specifier-seq followed by ellipsis. /testsuite 2013-06-05 Paolo Carlini PR c++/51908 * g++.dg/cpp0x/variadic144.C: New. Index: cp/parser.c =================================================================== --- cp/parser.c (revision 199675) +++ cp/parser.c (working copy) @@ -17887,7 +17887,7 @@ cp_parser_parameter_declaration (cp_parser *parser parser->default_arg_ok_p = false; /* After seeing a decl-specifier-seq, if the next token is not a - "(", there is no possibility that the code is a valid + "(" nor '...', there is no possibility that the code is a valid expression. Therefore, if parsing tentatively, we commit at this point. */ if (!parser->in_template_argument_list_p @@ -17901,7 +17901,8 @@ cp_parser_parameter_declaration (cp_parser *parser && !parser->in_type_id_in_expr_p && cp_parser_uncommitted_to_tentative_parse_p (parser) && cp_lexer_next_token_is_not (parser->lexer, CPP_OPEN_BRACE) - && cp_lexer_next_token_is_not (parser->lexer, CPP_OPEN_PAREN)) + && cp_lexer_next_token_is_not (parser->lexer, CPP_OPEN_PAREN) + && cp_lexer_next_token_is_not (parser->lexer, CPP_ELLIPSIS)) cp_parser_commit_to_tentative_parse (parser); /* Parse the declarator. */ declarator_token_start = token; Index: testsuite/g++.dg/cpp0x/variadic144.C =================================================================== --- testsuite/g++.dg/cpp0x/variadic144.C (revision 0) +++ testsuite/g++.dg/cpp0x/variadic144.C (working copy) @@ -0,0 +1,8 @@ +// PR c++/51908 +// { dg-do compile { target c++11 } } + +struct foo +{ + template + operator decltype(static_cast(nullptr)) () const; +};