From patchwork Tue Jan 14 15:10:06 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Schwinge X-Patchwork-Id: 310758 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 E6C822C0082 for ; Wed, 15 Jan 2014 02:10:30 +1100 (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:in-reply-to:references :mime-version:content-type; q=dns; s=default; b=C8LkiVBLXpqFKDQc tpH7tGwggwInrTSN9lVo+an0e7wdaebTkMbN5tTYQ3rTtnNgypxZxAv3b2ZHcVWX m3yHeNyA6c1xI8mvuKvmhdvpycas5zAKbVSDpmKPX0RsTi9LhhGjtmmnQr8F544u wBrFqXVvlHalAftzQVcSJLL/gWU= 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:in-reply-to:references :mime-version:content-type; s=default; bh=AZOQCnBPaSg55WJ5qm9MoK Xf8pA=; b=tNkkmmaR3I5bC2wnj1wMdDjF1lO3teGkvw0wUbiunGLnZxQdIblI2C wAWmV21AzMYUGmp385w7S44caUeUS9t8Aqof5Fm6qkrXSuR1SsqIcte8O6PtlERG gJSN56eAsz3xBkkywL8slfsvBfyj9+gSlbdhpv3hzCQxHcBKw1V1A= Received: (qmail 10851 invoked by alias); 14 Jan 2014 15:10:23 -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 10839 invoked by uid 89); 14 Jan 2014 15:10:23 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.3 required=5.0 tests=AWL, BAYES_00 autolearn=ham version=3.3.2 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 ESMTP; Tue, 14 Jan 2014 15:10:21 +0000 Received: from svr-orw-exc-10.mgc.mentorg.com ([147.34.98.58]) by relay1.mentorg.com with esmtp id 1W35dB-0002Ff-O8 from Thomas_Schwinge@mentor.com ; Tue, 14 Jan 2014 07:10:17 -0800 Received: from SVR-ORW-FEM-02.mgc.mentorg.com ([147.34.96.206]) by SVR-ORW-EXC-10.mgc.mentorg.com with Microsoft SMTPSVC(6.0.3790.4675); Tue, 14 Jan 2014 07:10:17 -0800 Received: from build5-lucid-cs (147.34.91.1) by svr-orw-fem-02.mgc.mentorg.com (147.34.96.168) with Microsoft SMTP Server id 14.2.247.3; Tue, 14 Jan 2014 07:10:16 -0800 Received: by build5-lucid-cs (Postfix, from userid 49978) id C5622321AF0; Tue, 14 Jan 2014 07:10:16 -0800 (PST) From: To: , CC: Thomas Schwinge Subject: [gomp4 4/6] C front end infrastructure for OpenACC clauses parsing. Date: Tue, 14 Jan 2014 16:10:06 +0100 Message-ID: <1389712208-416-4-git-send-email-thomas@codesourcery.com> In-Reply-To: <1389712208-416-3-git-send-email-thomas@codesourcery.com> References: <87ppnuvbv6.fsf@schwinge.name> <1389712208-416-1-git-send-email-thomas@codesourcery.com> <1389712208-416-2-git-send-email-thomas@codesourcery.com> <1389712208-416-3-git-send-email-thomas@codesourcery.com> MIME-Version: 1.0 From: Thomas Schwinge gcc/c/ * c-parser.c (c_parser_oacc_all_clauses): New function. (c_parser_oacc_parallel): Use it. * c-typeck.c (c_finish_omp_clauses): Update comment. Remove duplicated variable initialization. --- gcc/c/c-parser.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++----- gcc/c/c-typeck.c | 4 ++-- 2 files changed, 56 insertions(+), 7 deletions(-) diff --git gcc/c/c-parser.c gcc/c/c-parser.c index ce46f31..c8b80db 100644 --- gcc/c/c-parser.c +++ gcc/c/c-parser.c @@ -9465,7 +9465,7 @@ c_parser_pragma_pch_preprocess (c_parser *parser) c_common_pch_pragma (parse_in, TREE_STRING_POINTER (name)); } -/* OpenMP 2.5 / 3.0 / 3.1 / 4.0 parsing routines. */ +/* OpenACC and OpenMP parsing routines. */ /* Returns name of the next clause. If the clause is not recognized PRAGMA_OMP_CLAUSE_NONE is returned and @@ -10767,9 +10767,58 @@ c_parser_omp_clause_uniform (c_parser *parser, tree list) return list; } +/* Parse all OpenACC clauses. The set clauses allowed by the directive + is a bitmask in MASK. Return the list of clauses found. */ + +static tree +c_parser_oacc_all_clauses (c_parser *parser, omp_clause_mask mask, + const char *where, bool finish_p = true) +{ + tree clauses = NULL; + bool first = true; + + while (c_parser_next_token_is_not (parser, CPP_PRAGMA_EOL)) + { + location_t here; + pragma_omp_clause c_kind; + const char *c_name; + tree prev = clauses; + + if (!first && c_parser_next_token_is (parser, CPP_COMMA)) + c_parser_consume_token (parser); + + here = c_parser_peek_token (parser)->location; + c_kind = c_parser_omp_clause_name (parser); + + switch (c_kind) + { + default: + c_parser_error (parser, "expected clause"); + goto saw_error; + } + + first = false; + + if (((mask >> c_kind) & 1) == 0 && !parser->error) + { + /* Remove the invalid clause(s) from the list to avoid + confusing the rest of the compiler. */ + clauses = prev; + error_at (here, "%qs is not valid for %qs", c_name, where); + } + } + + saw_error: + c_parser_skip_to_pragma_eol (parser); + + if (finish_p) + return c_finish_omp_clauses (clauses); + + return clauses; +} + /* Parse all OpenMP clauses. The set clauses allowed by the directive - is a bitmask in MASK. Return the list of clauses found; the result - of clause default goes in *pdefault. */ + is a bitmask in MASK. Return the list of clauses found. */ static tree c_parser_omp_all_clauses (c_parser *parser, omp_clause_mask mask, @@ -11019,8 +11068,8 @@ c_parser_oacc_parallel (location_t loc, c_parser *parser) { tree stmt, clauses, block; - clauses = c_parser_omp_all_clauses (parser, OACC_PARALLEL_CLAUSE_MASK, - "#pragma acc parallel"); + clauses = c_parser_oacc_all_clauses (parser, OACC_PARALLEL_CLAUSE_MASK, + "#pragma acc parallel"); gcc_assert (clauses == NULL); block = c_begin_omp_parallel (); diff --git gcc/c/c-typeck.c gcc/c/c-typeck.c index 854e149..81f0c5c 100644 --- gcc/c/c-typeck.c +++ gcc/c/c-typeck.c @@ -11661,7 +11661,7 @@ c_find_omp_placeholder_r (tree *tp, int *, void *data) return NULL_TREE; } -/* For all elements of CLAUSES, validate them vs OpenMP constraints. +/* For all elements of CLAUSES, validate them against their constraints. Remove any elements from the list that are invalid. */ tree @@ -11669,7 +11669,7 @@ c_finish_omp_clauses (tree clauses) { bitmap_head generic_head, firstprivate_head, lastprivate_head; bitmap_head aligned_head; - tree c, t, *pc = &clauses; + tree c, t, *pc; bool branch_seen = false; bool copyprivate_seen = false; tree *nowait_clause = NULL;