From patchwork Thu Dec 4 12:54:25 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 417756 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 9A18A1400D2 for ; Thu, 4 Dec 2014 23:54:40 +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:references :in-reply-to:content-type; q=dns; s=default; b=EPH1L30A6dMGt2C7T tpGPn2LXFn8d81nnaIJ7AC7FXmBpGDRBobi0bF8wHcQa5Nn/fyrjhuZyYEYauXWx 1Cmd6i9Q5J6oF+anw+QryG+ss3Y+YHky599cor6NjErB/0PdO06IHFTmiLZbTKL4 aMJOL66cAZ9aJTWBbIW8HXBuHM= 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:references :in-reply-to:content-type; s=default; bh=NAyPMjUrJPm5A4OE9uLa0xq 2ovI=; b=Qd3hRo/oEfUF5RxQYFdGW1WMSrIW1Ofz8ZtDOpFl/K8ZnCTEamGFWRI gh9lQv3cpdTU3SNgFzSyO63xvIB/BmMBFSxxKDy9iiSurZF7qzQUB1IidPjZ1y3c lVSiCu8GE2BcvRXKnOtG3ccvWOO07yJ+YSJZBxcwzlv5GqvA1i5c= Received: (qmail 28239 invoked by alias); 4 Dec 2014 12:54:33 -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 28220 invoked by uid 89); 4 Dec 2014 12:54:33 -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: userp1040.oracle.com Received: from userp1040.oracle.com (HELO userp1040.oracle.com) (156.151.31.81) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Thu, 04 Dec 2014 12:54:32 +0000 Received: from acsinet21.oracle.com (acsinet21.oracle.com [141.146.126.237]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id sB4CsTQi009334 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 4 Dec 2014 12:54:30 GMT Received: from aserz7022.oracle.com (aserz7022.oracle.com [141.146.126.231]) by acsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id sB4CsSIV025677 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); Thu, 4 Dec 2014 12:54:29 GMT Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by aserz7022.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id sB4CsS8H010073; Thu, 4 Dec 2014 12:54:28 GMT Received: from [192.168.1.4] (/80.181.47.237) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 04 Dec 2014 04:54:28 -0800 Message-ID: <54805981.6050501@oracle.com> Date: Thu, 04 Dec 2014 13:54:25 +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: Re: [C++ Patch] PR 63985 References: <548058C1.1050106@oracle.com> In-Reply-To: <548058C1.1050106@oracle.com> X-IsSubscribed: yes ... oops, sent the wrong patch. See the below instead. Paolo. /////////////////// Index: cp/parser.c =================================================================== --- cp/parser.c (revision 218348) +++ cp/parser.c (working copy) @@ -10841,6 +10841,7 @@ cp_parser_for_init_statement (cp_parser* parser, t { bool is_range_for = false; bool saved_colon_corrects_to_scope_p = parser->colon_corrects_to_scope_p; + location_t loc = cp_lexer_peek_token (parser->lexer)->location; if (cp_lexer_next_token_is (parser->lexer, CPP_NAME) && cp_lexer_nth_token_is (parser->lexer, 2, CPP_COLON)) @@ -10881,6 +10882,8 @@ cp_parser_for_init_statement (cp_parser* parser, t "-std=c++11 or -std=gnu++11"); *decl = error_mark_node; } + else if (*decl == error_mark_node) + error_at (loc, "invalid declaration in range-based % loop"); } else /* The ';' is not consumed yet because we told Index: testsuite/g++.dg/cpp0x/range-for29.C =================================================================== --- testsuite/g++.dg/cpp0x/range-for29.C (revision 0) +++ testsuite/g++.dg/cpp0x/range-for29.C (working copy) @@ -0,0 +1,10 @@ +// PR c++/63985 +// { dg-require-effective-target c++11 } + +int main() +{ + int arr; + for (int i = 5: arr) // { dg-error "invalid declaration" } + return 1; + return 0; +}