From patchwork Tue May 24 14:02:39 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Thomas Schwinge X-Patchwork-Id: 625673 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 3rDcZ40JsBz9t7K for ; Wed, 25 May 2016 00:03:07 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=Fcz9UA26; 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:from :to:subject:in-reply-to:references:date:message-id:mime-version :content-type:content-transfer-encoding; q=dns; s=default; b=Qgc wFzhguHFSSuciOeImRQn9TvWYx9D/jnXTZW05D0SEB43xu1yGEegxcJUygAdWcQ3 7BUttzfVqmfFPqv2064RLUxsN9uRJc+Bj8kPPfIrgIxAFU7hYq++zwu0oIPdRS86 Re9t+WuQpGaauLMk7nGw47bffnpsqdGbtIFgOgZA= 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:subject:in-reply-to:references:date:message-id:mime-version :content-type:content-transfer-encoding; s=default; bh=6mgrGDpCs ENZZKB99bKES0ekwsE=; b=Fcz9UA26MJZZ0id1qTvybX5nvsimij4qtKt8x2zHU 2vscrjz95zzSxGSfFVwLpHDOBKQD8Q2z5FPgkWkqCtRS0ZFu8uc5CgPMCI1y4J+0 WPduyaX7zmKwe/kVlU68EhVc5t04a+pLkbHTLdrEpC+rYGumZizxqWSZaxy2ReKh K4= Received: (qmail 82878 invoked by alias); 24 May 2016 14:03:01 -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 82833 invoked by uid 89); 24 May 2016 14:02:57 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=sum X-HELO: relay1.mentorg.com Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Tue, 24 May 2016 14:02:47 +0000 Received: from nat-ies.mentorg.com ([192.94.31.2] helo=SVR-IES-FEM-01.mgc.mentorg.com) by relay1.mentorg.com with esmtp id 1b5Cux-0003sl-Sf from Thomas_Schwinge@mentor.com ; Tue, 24 May 2016 07:02:44 -0700 Received: from hertz.schwinge.homeip.net (137.202.0.76) by SVR-IES-FEM-01.mgc.mentorg.com (137.202.0.104) with Microsoft SMTP Server id 14.3.224.2; Tue, 24 May 2016 15:02:42 +0100 From: Thomas Schwinge To: Jakub Jelinek , Subject: Re: Tighten syntax checking for OpenACC routine construct in C In-Reply-To: <20160524085453.GD28550@tucnak.redhat.com> References: <87eg8ru9do.fsf@hertz.schwinge.homeip.net> <20160524085453.GD28550@tucnak.redhat.com> User-Agent: Notmuch/0.9-101-g81dad07 (http://notmuchmail.org) Emacs/24.4.1 (x86_64-pc-linux-gnu) Date: Tue, 24 May 2016 16:02:39 +0200 Message-ID: <87bn3vtuyo.fsf@hertz.schwinge.homeip.net> MIME-Version: 1.0 Hi! On Tue, 24 May 2016 10:54:53 +0200, Jakub Jelinek wrote: > On Tue, May 24, 2016 at 10:51:15AM +0200, Thomas Schwinge wrote: > > OK for trunk? > Ok. Committed without changes in r236639: commit c9d624bd2672463771546e73bf3d6446d64e43c0 Author: tschwinge Date: Tue May 24 14:00:39 2016 +0000 Tighten syntax checking for OpenACC routine construct in C gcc/c/ * c-parser.c (c_parser_oacc_routine): Tighten syntax checks. gcc/testsuite/ * c-c++-common/goacc/routine-5.c: Add tests. * g++.dg/goacc/routine-2.C: Remove duplicate tests. * gfortran.dg/goacc/routine-6.f90: Add tests. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@236639 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/c/ChangeLog | 4 ++++ gcc/c/c-parser.c | 19 +++++++++---------- gcc/testsuite/ChangeLog | 6 ++++++ gcc/testsuite/c-c++-common/goacc/routine-5.c | 21 +++++++++++++++++---- gcc/testsuite/g++.dg/goacc/routine-2.C | 6 ------ gcc/testsuite/gfortran.dg/goacc/routine-6.f90 | 7 +++++++ 6 files changed, 43 insertions(+), 20 deletions(-) Grüße Thomas diff --git gcc/c/ChangeLog gcc/c/ChangeLog index 9bb5ec1..3d69cd5 100644 --- gcc/c/ChangeLog +++ gcc/c/ChangeLog @@ -1,3 +1,7 @@ +2016-05-24 Thomas Schwinge + + * c-parser.c (c_parser_oacc_routine): Tighten syntax checks. + 2016-05-24 Richard Biener PR middle-end/70434 diff --git gcc/c/c-parser.c gcc/c/c-parser.c index c2c8314..1bc5eed 100644 --- gcc/c/c-parser.c +++ gcc/c/c-parser.c @@ -13983,25 +13983,24 @@ c_parser_oacc_routine (c_parser *parser, enum pragma_context context) c_parser_consume_token (parser); c_token *token = c_parser_peek_token (parser); - if (token->type == CPP_NAME && (token->id_kind == C_ID_ID || token->id_kind == C_ID_TYPENAME)) { decl = lookup_name (token->value); if (!decl) - { - error_at (token->location, "%qE has not been declared", - token->value); - decl = error_mark_node; - } + error_at (token->location, "%qE has not been declared", + token->value); + c_parser_consume_token (parser); } else c_parser_error (parser, "expected function name"); - if (token->type != CPP_CLOSE_PAREN) - c_parser_consume_token (parser); - - c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, 0); + if (!decl + || !c_parser_require (parser, CPP_CLOSE_PAREN, "expected %<)%>")) + { + c_parser_skip_to_pragma_eol (parser, false); + return; + } } /* Build a chain of clauses. */ diff --git gcc/testsuite/ChangeLog gcc/testsuite/ChangeLog index 586202e..361fbbd 100644 --- gcc/testsuite/ChangeLog +++ gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2016-05-24 Thomas Schwinge + + * c-c++-common/goacc/routine-5.c: Add tests. + * g++.dg/goacc/routine-2.C: Remove duplicate tests. + * gfortran.dg/goacc/routine-6.f90: Add tests. + 2016-05-24 Richard Biener PR tree-optimization/71253 diff --git gcc/testsuite/c-c++-common/goacc/routine-5.c gcc/testsuite/c-c++-common/goacc/routine-5.c index 2a9db90..1efd154 100644 --- gcc/testsuite/c-c++-common/goacc/routine-5.c +++ gcc/testsuite/c-c++-common/goacc/routine-5.c @@ -38,13 +38,26 @@ namespace g {} #pragma acc routine /* { dg-error "not followed by" "" { target c++ } } */ using namespace g; -#pragma acc routine (g) /* { dg-error "does not refer to" "" { target c++ } } */ +#pragma acc routine (g) /* { dg-error "does not refer to a function" "" { target c++ } } */ -#endif +#endif /* __cplusplus */ -#pragma acc routine (a) /* { dg-error "does not refer to" } */ +#pragma acc routine (a) /* { dg-error "does not refer to a function" } */ -#pragma acc routine (c) /* { dg-error "does not refer to" } */ +#pragma acc routine (c) /* { dg-error "does not refer to a function" } */ + + +#pragma acc routine () vector /* { dg-error "expected (function name|unqualified-id) before .\\). token" } */ + +#pragma acc routine (+) /* { dg-error "expected (function name|unqualified-id) before .\\+. token" } */ + + +extern void R1(void); +extern void R2(void); +#pragma acc routine (R1, R2, R3) worker /* { dg-error "expected .\\). before .,. token" } */ +#pragma acc routine (R1 R2 R3) worker /* { dg-error "expected .\\). before .R2." } */ +#pragma acc routine (R1) worker +#pragma acc routine (R2) worker void Bar (); diff --git gcc/testsuite/g++.dg/goacc/routine-2.C gcc/testsuite/g++.dg/goacc/routine-2.C index 2d16466..ea7c9bf 100644 --- gcc/testsuite/g++.dg/goacc/routine-2.C +++ gcc/testsuite/g++.dg/goacc/routine-2.C @@ -14,15 +14,9 @@ one() int incr (int); float incr (float); -int inc; #pragma acc routine (incr) /* { dg-error "names a set of overloads" } */ -#pragma acc routine (increment) /* { dg-error "has not been declared" } */ - -#pragma acc routine (inc) /* { dg-error "does not refer to a function" } */ - -#pragma acc routine (+) /* { dg-error "expected unqualified-id before '.' token" } */ int sum (int, int); diff --git gcc/testsuite/gfortran.dg/goacc/routine-6.f90 gcc/testsuite/gfortran.dg/goacc/routine-6.f90 index 10951ee..10943cf 100644 --- gcc/testsuite/gfortran.dg/goacc/routine-6.f90 +++ gcc/testsuite/gfortran.dg/goacc/routine-6.f90 @@ -29,6 +29,13 @@ program main !$acc routine (subr1) ! { dg-error "invalid function name" } external :: subr2 !$acc routine (subr2) + + external :: R1, R2 + !$acc routine (R1 R2 R3) ! { dg-error "Syntax error in \\!\\\$ACC ROUTINE \\( NAME \\) at \\(1\\), expecting .\\). after NAME" } + !$acc routine (R1, R2, R3) ! { dg-error "Syntax error in \\!\\\$ACC ROUTINE \\( NAME \\) at \\(1\\), expecting .\\). after NAME" } + !$acc routine (R1) + !$acc routine (R2) + !$acc parallel !$acc loop do i = 1, n