From patchwork Thu Apr 10 13:56:00 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Zamyatin, Igor" X-Patchwork-Id: 338132 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 3D2961400E9 for ; Thu, 10 Apr 2014 23:56:31 +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:content-type :content-transfer-encoding:mime-version; q=dns; s=default; b=jSA 63bpMK5FIhdG1ug8y4mk4c0l9BNGRIQyFQ4PYTUPloyIF4MoAEFaE/ZR27skjLSn A9YV6Bfvv7dmA9CfLETZt+q5gVItcSKqWunA87Ijj0h2Yg25Oc/meVcS+Qw/Rd5b GTRKYE5Q6Eghut1YhB6FqSqUaxS4ONrdQAiuT3i8= 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:content-type :content-transfer-encoding:mime-version; s=default; bh=z8M0nKfY9 iEX/ZyC1dw+Ka26nQ0=; b=gCzIzwVqpWb92k6YHjDM/O01shHRg1Zc7N8DOuaDZ 8ya71g80ZWRO/gBKPsZsW3O0OLSqo3V7L6WiTYhD+DmE7lWzg76gopOWCYtlpVbs 5/Kn/nIadYm8AEKGCdmwwpNRkfkVA45LZ5xo91/W5QGqCvnwaN5GQLJEIGDGDakG ls= Received: (qmail 21752 invoked by alias); 10 Apr 2014 13:56:24 -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 21651 invoked by uid 89); 10 Apr 2014 13:56:24 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=2.4 required=5.0 tests=AWL, BAYES_00, BODY_8BITS, GARBLED_BODY, MIME_CHARSET_FARAWAY, RP_MATCHES_RCVD, SPF_PASS autolearn=no version=3.3.2 X-HELO: mga02.intel.com Received: from mga02.intel.com (HELO mga02.intel.com) (134.134.136.20) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 10 Apr 2014 13:56:23 +0000 Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga101.jf.intel.com with ESMTP; 10 Apr 2014 06:56:19 -0700 X-ExtLoop1: 1 Received: from irsmsx103.ger.corp.intel.com ([163.33.3.157]) by orsmga002.jf.intel.com with ESMTP; 10 Apr 2014 06:56:17 -0700 Received: from irsmsx108.ger.corp.intel.com (163.33.3.3) by IRSMSX103.ger.corp.intel.com (163.33.3.157) with Microsoft SMTP Server (TLS) id 14.3.123.3; Thu, 10 Apr 2014 14:56:01 +0100 Received: from irsmsx103.ger.corp.intel.com ([169.254.3.172]) by IRSMSX108.ger.corp.intel.com ([163.33.3.3]) with mapi id 14.03.0123.003; Thu, 10 Apr 2014 14:56:01 +0100 From: "Zamyatin, Igor" To: "GCC Patches (gcc-patches@gcc.gnu.org)" CC: "Iyer, Balaji V" , "Jakub Jelinek (jakub@redhat.com)" Subject: [PATCH, PR60189, Cilk+] Fix for ICE with incorrect Cilk_sync usage Date: Thu, 10 Apr 2014 13:56:00 +0000 Message-ID: <0EFAB2BDD0F67E4FB6CCC8B9F87D7569429DBFEF@IRSMSX103.ger.corp.intel.com> MIME-Version: 1.0 X-IsSubscribed: yes Hi! This fixes ICE on inappropriate usage of Cilk_sync keyword. Bootstrapped/regtested on x86_64. Ok for trunk? Thanks, Igor gcc/ChangeLog: 2014-04-10  Igor Zamyatin  PR c++/60189 * cp/parser.c (cp_parser_postfix_expression): Make sure only semicolon can go after Cilk_sync. gcc/testsuite/ChangeLog: 2014-04-10  Igor Zamyatin  PR c++/60189 * c-c++-common/cilk-plus/CK/invalid_sync.cс: New test. diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 7bea3d2..95f9c93 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -5835,20 +5835,33 @@ 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; +      { +       cp_lexer_consume_token (parser->lexer); +       if (flag_cilkplus) +         { +           token = cp_lexer_peek_token (parser->lexer); +           if (token->type != CPP_SEMICOLON) +             { +               error_at (token->location, "%<_Cilk_sync%> must be followed" +                         " by semicolon"); +               postfix_expression = error_mark_node; +               break; +             } +           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%>"); +           postfix_expression = error_mark_node; +         } +       break; +      }      case RID_BUILTIN_SHUFFLE:        { diff --git a/gcc/testsuite/c-c++-common/cilk-plus/CK/invalid_sync.сc b/gcc/testsuite/c-c++-common/cilk-plus/CK/invalid_sync.cс new file mode 100644 index 0000000..e7bec68 --- /dev/null +++ b/gcc/testsuite/c-c++-common/cilk-plus/CK/invalid_sync.cс @@ -0,0 +1,9 @@ +/* PR c/60189 */ +/* { dg-do compile } */ +/* { dg-options "-fcilkplus" } */ + +int main (void) +{ +    _Cilk_sync return; /* { dg-error " '_Cilk_sync' must be followed by semicolon" } */ +    return 0; +}