From patchwork Thu Feb 9 16:59:34 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Polacek X-Patchwork-Id: 726221 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 3vK47X1sCfz9s7N for ; Fri, 10 Feb 2017 03:59:51 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="HRQQy3Px"; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:mime-version:content-type; q=dns; s= default; b=giIQtDofQRKz2upsDg93H/HLtLDvDJYMeuJcKIjkckt1u/cmV6wED AFyC3WxIxjdwXkUUYkNmGCH5jtgTWO7F8r8HcUwWaxxd4GuAR6kdI8zH+Y1mgUU6 kXBFLLrnZW9KU9hoIzPTE+jOaiGoK1YtDBI++7BqNhKAfWcVyUV1pQ= 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:date :from:to:subject:message-id:mime-version:content-type; s= default; bh=lD6ezfy9qdASPZjgs46JMxwkBh4=; b=HRQQy3PxI65UFCYFroEr fOIoBu07WL6HTxQb61/NAoqVqFLUjV9p826sUUkMNuZAV78giO+IBkcYnPy2SoX9 bY+NU96cJyvyLEx479noQlXHltp1PqosNLvu5EAPPM5IVrl4/5oQytlPWeyv+IeY IHiojTVy81IP4QbQUM6PQ0o= Received: (qmail 48003 invoked by alias); 9 Feb 2017 16:59:41 -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 47988 invoked by uid 89); 9 Feb 2017 16:59:41 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:4054 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 09 Feb 2017 16:59:39 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id EB62F2B7845 for ; Thu, 9 Feb 2017 16:59:38 +0000 (UTC) Received: from redhat.com (ovpn-204-37.brq.redhat.com [10.40.204.37]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v19GxZcf005083 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Thu, 9 Feb 2017 11:59:38 -0500 Date: Thu, 9 Feb 2017 17:59:34 +0100 From: Marek Polacek To: GCC Patches , Jakub Jelinek Subject: [PATCH] Fix ice-on-invalid with #pragma omp ordered (PR c/79428) Message-ID: <20170209165934.GN13736@redhat.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.7.1 (2016-10-04) As discussed in the PR, this changes a call to c_parser_skip_until_found into c_parser_skip_to_pragma_eol to avoid crashing on an assert in c_parser_consume_token (CPP_PRAGMA_EOLs shouldn't be consumed in that way). Bootstrapped/regtested on x86_64-linux, ok for trunk? 2017-02-09 Marek Polacek PR c/79428 * c-parser.c (c_parser_omp_ordered): Call c_parser_skip_to_pragma_eol instead of c_parser_skip_until_found. * c-c++-common/cilk-plus/CK/pr79428-4.c: New test. * c-c++-common/cilk-plus/CK/pr79428-7.c: New test. * c-c++-common/goacc/pr79428-1.c: New test. * c-c++-common/gomp/pr79428-2.c: New test. * c-c++-common/gomp/pr79428-5.c: New test. * c-c++-common/gomp/pr79428-6.c: New test. * c-c++-common/pr79428-3.c: New test. Marek diff --git gcc/c/c-parser.c gcc/c/c-parser.c index 5c152ab..ce2ef0f 100644 --- gcc/c/c-parser.c +++ gcc/c/c-parser.c @@ -15460,7 +15460,7 @@ c_parser_omp_ordered (c_parser *parser, enum pragma_context context, if (context != pragma_stmt && context != pragma_compound) { c_parser_error (parser, "expected declaration specifiers"); - c_parser_skip_until_found (parser, CPP_PRAGMA_EOL, NULL); + c_parser_skip_to_pragma_eol (parser, false); return false; } diff --git gcc/testsuite/c-c++-common/cilk-plus/CK/pr79428-4.c gcc/testsuite/c-c++-common/cilk-plus/CK/pr79428-4.c index e69de29..cd4d406 100644 --- gcc/testsuite/c-c++-common/cilk-plus/CK/pr79428-4.c +++ gcc/testsuite/c-c++-common/cilk-plus/CK/pr79428-4.c @@ -0,0 +1,3 @@ +/* PR c/79428 */ +/* { dg-options "-fcilkplus" } */ +#pragma cilk grainsize /* { dg-error "must be inside a function" } */ diff --git gcc/testsuite/c-c++-common/cilk-plus/CK/pr79428-7.c gcc/testsuite/c-c++-common/cilk-plus/CK/pr79428-7.c index e69de29..bc36f51 100644 --- gcc/testsuite/c-c++-common/cilk-plus/CK/pr79428-7.c +++ gcc/testsuite/c-c++-common/cilk-plus/CK/pr79428-7.c @@ -0,0 +1,3 @@ +/* PR c/79428 */ +/* { dg-options "-fcilkplus" } */ +#pragma simd /* { dg-error "must be inside a function" } */ diff --git gcc/testsuite/c-c++-common/goacc/pr79428-1.c gcc/testsuite/c-c++-common/goacc/pr79428-1.c index e69de29..cf4aeaf 100644 --- gcc/testsuite/c-c++-common/goacc/pr79428-1.c +++ gcc/testsuite/c-c++-common/goacc/pr79428-1.c @@ -0,0 +1,6 @@ +/* PR c/79428 */ +/* { dg-options "-fopenacc" } */ +void +foo () +{ +#pragma acc routine /* { dg-error ".#pragma acc routine. must be at file scope|expected" } */ diff --git gcc/testsuite/c-c++-common/gomp/pr79428-2.c gcc/testsuite/c-c++-common/gomp/pr79428-2.c index e69de29..a26c462 100644 --- gcc/testsuite/c-c++-common/gomp/pr79428-2.c +++ gcc/testsuite/c-c++-common/gomp/pr79428-2.c @@ -0,0 +1,7 @@ +/* PR c/79428 */ +/* { dg-options "-fopenmp" } */ +void +foo () +{ +#pragma omp sections +#pragma omp section /* { dg-error "'#pragma omp section' may only be used in '#pragma omp sections' construct|not allowed|expected" } */ diff --git gcc/testsuite/c-c++-common/gomp/pr79428-5.c gcc/testsuite/c-c++-common/gomp/pr79428-5.c index e69de29..4f2127b 100644 --- gcc/testsuite/c-c++-common/gomp/pr79428-5.c +++ gcc/testsuite/c-c++-common/gomp/pr79428-5.c @@ -0,0 +1,3 @@ +/* PR c/79428 */ +/* { dg-options "-fopenmp" } */ +#pragma omp ordered /* { dg-error "expected declaration specifiers before end of line" } */ diff --git gcc/testsuite/c-c++-common/gomp/pr79428-6.c gcc/testsuite/c-c++-common/gomp/pr79428-6.c index e69de29..7e833e2 100644 --- gcc/testsuite/c-c++-common/gomp/pr79428-6.c +++ gcc/testsuite/c-c++-common/gomp/pr79428-6.c @@ -0,0 +1,3 @@ +/* PR c/79428 */ +/* { dg-options "-fopenmp" } */ +#pragma omp target /* { dg-error "expected declaration specifiers before end of line" } */ diff --git gcc/testsuite/c-c++-common/pr79428-3.c gcc/testsuite/c-c++-common/pr79428-3.c index e69de29..ec7077d 100644 --- gcc/testsuite/c-c++-common/pr79428-3.c +++ gcc/testsuite/c-c++-common/pr79428-3.c @@ -0,0 +1,3 @@ +/* PR c/79428 */ +int i; +#pragma GCC pch_preprocess /* { dg-error "'#pragma GCC pch_preprocess' must be first" } */