From patchwork Tue Nov 25 12:00:06 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 414642 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 2C508140187 for ; Tue, 25 Nov 2014 23:00:29 +1100 (AEDT) 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=Kdt6xUhIhLgIXcPsQBgTQcGHgo3/snk2d0cs/ABHExI p5edPSGdzVnXLU1ds0/peXtBtr64sQyx2sksTvzTloTdKxs5zVCM4R/Pv0J03MUg 0hd/49WjwqN6XsIBY6ekzU73i7+kxHg2mIIPszahDtk8zm1u+wZbsqfHYPlu22TU = 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=YDW1z3prrxkWlgQ0VtBYhL5aTIU=; b=nACe0mRxWQR0ht4HJ 9MHoWnjf9pzPfRh615+YcMIVOQst22nABuYRXvaaYDf1AfdK2/yl1Mt/W5R+Vc0b 0cC2k7zYwmPe4KsJCcIU99s2STmo2/P8NMBVbpCGpbeW8fglaDxMkrhenMZt+Qze s6NLoATLUgZKNkef8I5gwQbFyg= Received: (qmail 8069 invoked by alias); 25 Nov 2014 12:00:19 -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 8020 invoked by uid 89); 25 Nov 2014 12:00:16 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.2 required=5.0 tests=AWL, BAYES_00, SPF_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: aserp1040.oracle.com Received: from aserp1040.oracle.com (HELO aserp1040.oracle.com) (141.146.126.69) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Tue, 25 Nov 2014 12:00:14 +0000 Received: from ucsinet21.oracle.com (ucsinet21.oracle.com [156.151.31.93]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id sAPC0ARD029538 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 25 Nov 2014 12:00:11 GMT Received: from aserz7022.oracle.com (aserz7022.oracle.com [141.146.126.231]) by ucsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id sAPC0848008259 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); Tue, 25 Nov 2014 12:00:09 GMT Received: from abhmp0003.oracle.com (abhmp0003.oracle.com [141.146.116.9]) by aserz7022.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id sAPC08OG003580; Tue, 25 Nov 2014 12:00:08 GMT Received: from [192.168.1.4] (/79.33.94.236) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 25 Nov 2014 04:00:08 -0800 Message-ID: <54746F46.3050303@oracle.com> Date: Tue, 25 Nov 2014 13:00:06 +0100 From: Paolo Carlini User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 MIME-Version: 1.0 To: "gcc-patches@gcc.gnu.org" CC: Jason Merrill Subject: [C++ Patch] PR 63786 X-IsSubscribed: yes Hi, we are crashing on this kind of invalid code because we don't early check the case with check_for_bare_parameter_packs. Tested x86_64-linux. Thanks, Paolo. ////////////////////// /cp 2014-11-25 Paolo Carlini PR c++/63786 * parser.c (cp_parser_label_for_labeled_statement): Check the case with check_for_bare_parameter_packs. /testsuite 2014-11-25 Paolo Carlini PR c++/63786 * g++.dg/cpp0x/variadic163.C: New. Index: cp/parser.c =================================================================== --- cp/parser.c (revision 218039) +++ cp/parser.c (working copy) @@ -9820,6 +9820,8 @@ cp_parser_label_for_labeled_statement (cp_parser* cp_lexer_consume_token (parser->lexer); /* Parse the constant-expression. */ expr = cp_parser_constant_expression (parser); + if (check_for_bare_parameter_packs (expr)) + expr = error_mark_node; ellipsis = cp_lexer_peek_token (parser->lexer); if (ellipsis->type == CPP_ELLIPSIS) @@ -9826,8 +9828,9 @@ cp_parser_label_for_labeled_statement (cp_parser* { /* Consume the `...' token. */ cp_lexer_consume_token (parser->lexer); - expr_hi = - cp_parser_constant_expression (parser); + expr_hi = cp_parser_constant_expression (parser); + if (check_for_bare_parameter_packs (expr_hi)) + expr_hi = error_mark_node; /* We don't need to emit warnings here, as the common code will do this for us. */ Index: testsuite/g++.dg/cpp0x/variadic163.C =================================================================== --- testsuite/g++.dg/cpp0x/variadic163.C (revision 0) +++ testsuite/g++.dg/cpp0x/variadic163.C (working copy) @@ -0,0 +1,21 @@ +// PR c++/63786 +// { dg-do compile { target c++11 } } +// { dg-options "" } + +template +int f(int i) { + switch (i) { + case Is: // { dg-error "not expanded" } + return 0; + } + + switch (i) { + case 0 ...Is: // { dg-error "not expanded" } + return 0; + } + return 0; +} + +int main() { + f<1,2,3>(1); +}