From patchwork Tue May 20 14:10:04 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Zamyatin, Igor" X-Patchwork-Id: 350726 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 7521A140083 for ; Wed, 21 May 2014 00:11:41 +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:from :to:cc:subject:date:message-id:references:in-reply-to :content-type:content-transfer-encoding:mime-version; q=dns; s= default; b=OQhJr9bG1dqnMQeGOROA0tFwxzhPa1W4iDnWvLr7t/V9iF9dS2Y1J xUnVhFxvaINg7tfXLETp/pes5wnFvSdbCe27Ju7Rg3/Z7+0gaCTikWZQGu7fKKeM f5prrjwh/6N+98peowzBgXx9PsW0gH7ss422IFnNV2RWt9909MY0vw= 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:references:in-reply-to :content-type:content-transfer-encoding:mime-version; s=default; bh=DoA34YflxDRTL7/gLxJFzcuDNQs=; b=LV+hfByomj6nFml3dIcJq1Dw1Giw 1APc7a8B5E97s6mHMaknm5DXPp+so3D6+v4oBeWFft7lRlNBuc6MRLvFrNhXdPM/ W8kOxCe+hsG8QrubYvOndWWtnowu6SiP2DHGWOYHVefeDbxcGRwbmIWg6L/gKoZe A2jBd1Y/tS+nOaA= Received: (qmail 18546 invoked by alias); 20 May 2014 14:11:34 -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 18533 invoked by uid 89); 20 May 2014 14:11:33 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=AWL, BAYES_00, MIME_BASE64_BLANKS, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mga14.intel.com Received: from mga14.intel.com (HELO mga14.intel.com) (192.55.52.115) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 20 May 2014 14:11:27 +0000 Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga103.fm.intel.com with ESMTP; 20 May 2014 07:07:26 -0700 X-ExtLoop1: 1 Received: from irsmsx102.ger.corp.intel.com ([163.33.3.155]) by fmsmga001.fm.intel.com with ESMTP; 20 May 2014 07:11:24 -0700 Received: from irsmsx153.ger.corp.intel.com (163.33.192.75) by IRSMSX102.ger.corp.intel.com (163.33.3.155) with Microsoft SMTP Server (TLS) id 14.3.123.3; Tue, 20 May 2014 15:10:06 +0100 Received: from irsmsx103.ger.corp.intel.com ([169.254.3.183]) by IRSMSX153.ger.corp.intel.com ([169.254.9.50]) with mapi id 14.03.0123.003; Tue, 20 May 2014 15:10:05 +0100 From: "Zamyatin, Igor" To: 'Jason Merrill' CC: "'GCC Patches (gcc-patches@gcc.gnu.org)'" , "Iyer, Balaji V" Subject: RE: [PATCH, PR60189, Cilk+] Fix for ICE with incorrect Cilk_sync usage Date: Tue, 20 May 2014 14:10:04 +0000 Message-ID: <0EFAB2BDD0F67E4FB6CCC8B9F87D7569564312ED@IRSMSX103.ger.corp.intel.com> References: <0EFAB2BDD0F67E4FB6CCC8B9F87D7569429DBFEF@IRSMSX103.ger.corp.intel.com> <0EFAB2BDD0F67E4FB6CCC8B9F87D7569429DC138@IRSMSX103.ger.corp.intel.com> <20140410142731.GF1817@tucnak.redhat.com> <5348027F.1050407@redhat.com> <0EFAB2BDD0F67E4FB6CCC8B9F87D7569429E0533@IRSMSX103.ger.corp.intel.com> <534B6054.1070800@redhat.com> <0EFAB2BDD0F67E4FB6CCC8B9F87D7569429EE571@IRSMSX101.ger.corp.intel.com> <534C1F71.5040508@redhat.com> <0EFAB2BDD0F67E4FB6CCC8B9F87D7569429FC4CC@IRSMSX103.ger.corp.intel.com> <0EFAB2BDD0F67E4FB6CCC8B9F87D756942A58124@IRSMSX101.ger.corp.intel.com> In-Reply-To: <0EFAB2BDD0F67E4FB6CCC8B9F87D756942A58124@IRSMSX101.ger.corp.intel.com> MIME-Version: 1.0 X-IsSubscribed: yes Please look then on the following patch. Regtested successfully on x86_64. Is it ok for trunk and 4.9? gcc/cp/ChangeLog: 2014-05-20 Igor Zamyatin PR c/60189 * parser.c (cp_parser_postfix_expression): Move handling of cilk_sync from here to... (cp_parser_statement): ...here. Make sure only semicolon can go after Cilk_sync. gcc/testsuite/ChangeLog: 2014-05-20 Igor Zamyatin PR c++/60189 * c-c++-common/cilk-plus/CK/invalid_sync.cс: New test. Thanks, Igor > -----Original Message----- > From: Zamyatin, Igor > Sent: Tuesday, May 13, 2014 12:28 AM > To: 'Jason Merrill'; 'Jakub Jelinek' > Cc: 'GCC Patches (gcc-patches@gcc.gnu.org)'; Iyer, Balaji V > Subject: RE: [PATCH, PR60189, Cilk+] Fix for ICE with incorrect Cilk_sync usage > > Ping. Should I prepare the patch? > > Thanks, > Igor > > > > -----Original Message---- > > > From: Jason Merrill [mailto:jason@redhat.com] > > > Sent: Monday, April 14, 2014 9:49 PM > > > To: Zamyatin, Igor; Jakub Jelinek > > > Cc: GCC Patches (gcc-patches@gcc.gnu.org); Iyer, Balaji V > > > Subject: Re: [PATCH, PR60189, Cilk+] Fix for ICE with incorrect > > > Cilk_sync usage > > > > > > Oh, I see where the problem is coming from. Cilk_sync is a > > > statement, but it's being parsed as an expression. Let's move it to > > cp_parser_statement. > > > > Something like this (better to put new code in separate routine?)? > > > > diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index bb59e3b..3105d6c > > 100644 > > --- a/gcc/cp/parser.c > > +++ b/gcc/cp/parser.c > > @@ -5835,20 +5835,6 @@ cp_parser_postfix_expression (cp_parser > > *parser, bool address_p, bool cast_p, > > } > > break; > > } > > - > > - case RID_CILK_SYNC: > > - if (flag_cilkplus) > > - { > > - tree sync_expr = build_cilk_sync (); > > - SET_EXPR_LOCATION (sync_expr, > > - cp_lexer_peek_token (parser->lexer)->location); > > - finish_expr_stmt (sync_expr); > > - } > > - else > > - error_at (token->location, "-fcilkplus must be enabled to use" > > - " %<_Cilk_sync%>"); > > - cp_lexer_consume_token (parser->lexer); > > - break; > > > > case RID_BUILTIN_SHUFFLE: > > { > > @@ -9404,6 +9390,24 @@ cp_parser_statement (cp_parser* parser, tree > > in_statement_expr, > > statement = cp_parser_jump_statement (parser); > > break; > > > > + case RID_CILK_SYNC: > > + cp_lexer_consume_token (parser->lexer); > > + if (flag_cilkplus) > > + { > > + tree sync_expr = build_cilk_sync (); > > + SET_EXPR_LOCATION (sync_expr, > > + token->location); > > + statement = finish_expr_stmt (sync_expr); > > + } > > + else > > + { > > + error_at (token->location, "-fcilkplus must be enabled to use" > > + " %<_Cilk_sync%>"); > > + statement = error_mark_node; > > + } > > + cp_parser_require (parser, CPP_SEMICOLON, RT_SEMICOLON); > > + break; > > + > > /* Objective-C++ exception-handling constructs. */ > > case RID_AT_TRY: > > case RID_AT_CATCH: > > > > Thanks, > > Igor > > > > > > > > Jason diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 0c9e113..814f323 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -5845,20 +5845,6 @@ cp_parser_postfix_expression (cp_parser *parser, bool address_p, bool cast_p, } break; } - - case RID_CILK_SYNC: - if (flag_cilkplus) - { - tree sync_expr = build_cilk_sync (); - SET_EXPR_LOCATION (sync_expr, - cp_lexer_peek_token (parser->lexer)->location); - finish_expr_stmt (sync_expr); - } - else - error_at (token->location, "-fcilkplus must be enabled to use" - " %<_Cilk_sync%>"); - cp_lexer_consume_token (parser->lexer); - break; case RID_BUILTIN_SHUFFLE: { @@ -9414,6 +9400,24 @@ cp_parser_statement (cp_parser* parser, tree in_statement_expr, statement = cp_parser_jump_statement (parser); break; + case RID_CILK_SYNC: + cp_lexer_consume_token (parser->lexer); + if (flag_cilkplus) + { + tree sync_expr = build_cilk_sync (); + SET_EXPR_LOCATION (sync_expr, + token->location); + statement = finish_expr_stmt (sync_expr); + } + else + { + error_at (token->location, "-fcilkplus must be enabled to use" + " %<_Cilk_sync%>"); + statement = error_mark_node; + } + cp_parser_require (parser, CPP_SEMICOLON, RT_SEMICOLON); + break; + /* Objective-C++ exception-handling constructs. */ case RID_AT_TRY: case RID_AT_CATCH: diff --git a/gcc/testsuite/c-c++-common/cilk-plus/CK/invalid_sync.cc b/gcc/testsuite/c-c++-common/cilk-plus/CK/invalid_sync.cc new file mode 100644 index 0000000..cf1caf1 --- /dev/null +++ b/gcc/testsuite/c-c++-common/cilk-plus/CK/invalid_sync.cc @@ -0,0 +1,9 @@ +/* PR c/60189 */ +/* { dg-do compile } */ +/* { dg-options "-fcilkplus" } */ + +int main (void) +{ + _Cilk_sync return; /* { dg-error " expected ';' before 'return'" } */ + return 0; +}