From patchwork Fri Oct 28 09:09:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 12167 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp712648wru; Fri, 28 Oct 2022 02:10:30 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4r/NjWP9RikHHY7D30Cx+HBXQdX/XOEfGSpFvswIP41Fb4hGDp5/JfSjSKccy+zFXd+LiZ X-Received: by 2002:aa7:c6c8:0:b0:460:e19b:ec12 with SMTP id b8-20020aa7c6c8000000b00460e19bec12mr39269565eds.209.1666948230038; Fri, 28 Oct 2022 02:10:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666948230; cv=none; d=google.com; s=arc-20160816; b=IPMMVh++tqTI/68/eptWAOrsbXbgMLkgbdHPopg083W4yNc9P6kwUwwFbWovO7oS/N xqKKzGtrnoDPYdtoi+hBmRJNoCz43hZK590h7Q0rXdJj+GAemY4iPx/3w5OrgEwMDaGY cGMYscq4nmOJylSScUpQFnIGxPgWDXYURcqubV+QQgPDmwXxn15zDyqWQNEX51GAmx7T uSmZWitXHh0Ehk6EBrpjc8ZAlMl4Lv70kdaRyHRMQOUbyuKLOvlk3qhi3Vt9hEI2k4yy tC58sakrpYOh7qGnkjaziV7j6BobMAUjyt9EImO+d+ta7OkbQBWnRoBRvZiDPM6QVMDL V9nQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:reply-to:from:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence :content-disposition:mime-version:message-id:subject:to:date :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=UFfEnEXNDhuRCzW8EKbgbDwg+qz4+k0BPqebAKSFSpU=; b=hmTbW6ms93xtKqw+YAXOBbnrWN/ssr5Im3ekqJoTAN0+63EIyzoqTWoPCwML5xB9Bp VrpnT586xpWA3w4gUvHieBbp0zpxUBvmd8kP92zTO+714TEvXyP4WnDE7tR5fccHSAdk tPtHRMnR8xGtlnCvg3Cn8eS4BsNVgaA5kBtt2Hh/oNwSDFJ6MW7FCqla1a2KSpH7/b9l fi7tLMT+UXNbM92KRD/zhuOopvwSjqY1J4tfWQ0SIVWv7tnXIV+6EoSMm5ZmNUhCHXhM WtD4jrj6CuzrD7PHI7GWcVBv7i7Vk//fwTPl4D+9I8n0fz5zIizixeA6gm+aeDK5phoB 9hmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=tHcdmLLM; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id gn37-20020a1709070d2500b007a858ead52dsi4820286ejc.732.2022.10.28.02.10.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Oct 2022 02:10:30 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=tHcdmLLM; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 8D68A3857B88 for ; Fri, 28 Oct 2022 09:10:28 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8D68A3857B88 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1666948228; bh=UFfEnEXNDhuRCzW8EKbgbDwg+qz4+k0BPqebAKSFSpU=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=tHcdmLLMvUEyTM5gkEZZXmhe+qqeSGRJbFgVZPPwud2Z15zpi/fGoawIrGrP5kTRb TGDsNv0YqZaX+pBGIqL7ctXAjLGp5/8macxEjOiKTE4leo+WpefR0FwJ7tO63e9Nk9 zebhxitSPGYTb5r4l/qDJbBCKtokdMFH+nHlO3gg= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id E13BF385842A for ; Fri, 28 Oct 2022 09:09:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org E13BF385842A Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-657-yaWj-94QMWKpiflGaKchMA-1; Fri, 28 Oct 2022 05:09:31 -0400 X-MC-Unique: yaWj-94QMWKpiflGaKchMA-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E23BC85A5B6; Fri, 28 Oct 2022 09:09:30 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.193.252]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 529631121315; Fri, 28 Oct 2022 09:09:30 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.17.1/8.17.1) with ESMTPS id 29S99RX62262248 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 28 Oct 2022 11:09:28 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 29S99Qcq2262247; Fri, 28 Oct 2022 11:09:26 +0200 Date: Fri, 28 Oct 2022 11:09:26 +0200 To: gcc-patches@gcc.gnu.org Subject: [committed] openmp: Allow optional comma after directive-specifier in C/C++ Message-ID: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-3.7 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Jakub Jelinek via Gcc-patches From: Jakub Jelinek Reply-To: Jakub Jelinek Cc: Tobias Burnus Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747921906993816461?= X-GMAIL-MSGID: =?utf-8?q?1747921906993816461?= Hi! Previously we've been allowing that comma only in C++ when in attribute form (which was the reason why it has been allowed), but 5.1 allows that even in pragma form in C/C++ (with clarifications in 5.2) and 5.2 also in Fortran (which this patch doesn't implement). Note, for directives which take an argument (== unnamed clause), comma is not allowed in between the directive name and the argument, like the directive-1.c testcase shows. Bootstrapped/regtested on x86_64-linux and i686-linux, committed to trunk. 2022-10-28 Jakub Jelinek gcc/c/ * c-parser.cc (c_parser_omp_all_clauses): Allow optional comma before the first clause. (c_parser_omp_allocate, c_parser_omp_atomic, c_parser_omp_depobj, c_parser_omp_flush, c_parser_omp_scan_loop_body, c_parser_omp_ordered, c_finish_omp_declare_variant, c_parser_omp_declare_target, c_parser_omp_declare_reduction, c_parser_omp_requires, c_parser_omp_error, c_parser_omp_assumption_clauses): Likewise. gcc/cp/ * parser.cc (cp_parser_omp_all_clauses): Allow optional comma before the first clause even in pragma syntax. (cp_parser_omp_allocate, cp_parser_omp_atomic, cp_parser_omp_depobj, cp_parser_omp_flush, cp_parser_omp_scan_loop_body, cp_parser_omp_ordered, cp_parser_omp_assumption_clauses, cp_finish_omp_declare_variant, cp_parser_omp_declare_target, cp_parser_omp_declare_reduction_exprs, cp_parser_omp_requires, cp_parser_omp_error): Likewise. gcc/testsuite/ * c-c++-common/gomp/directive-1.c: New test. * c-c++-common/gomp/clauses-6.c: New test. * c-c++-common/gomp/declare-variant-2.c (f75a): Declare. (f75): Use f75a as variant instead of f1 and don't expect error. * g++.dg/gomp/clause-4.C (foo): Don't expect error on comma before first clause. * gcc.dg/gomp/clause-2.c (foo): Likewise. Jakub --- gcc/c/c-parser.cc.jj 2022-10-14 09:26:50.345509324 +0200 +++ gcc/c/c-parser.cc 2022-10-27 15:11:14.902665656 +0200 @@ -17366,7 +17366,7 @@ c_parser_omp_all_clauses (c_parser *pars if (nested && c_parser_next_token_is (parser, CPP_CLOSE_PAREN)) break; - if (!first) + if (!first || nested != 2) { if (c_parser_next_token_is (parser, CPP_COMMA)) c_parser_consume_token (parser); @@ -18453,6 +18453,9 @@ c_parser_omp_allocate (location_t loc, c { tree allocator = NULL_TREE; tree nl = c_parser_omp_var_list_parens (parser, OMP_CLAUSE_ALLOCATE, NULL_TREE); + if (c_parser_next_token_is (parser, CPP_COMMA) + && c_parser_peek_2nd_token (parser)->type == CPP_NAME) + c_parser_consume_token (parser); if (c_parser_next_token_is (parser, CPP_NAME)) { matching_parens parens; @@ -18591,7 +18594,6 @@ c_parser_omp_atomic (location_t loc, c_p bool structured_block = false; bool swapped = false; bool non_lvalue_p; - bool first = true; tree clauses = NULL_TREE; bool capture = false; bool compare = false; @@ -18602,13 +18604,10 @@ c_parser_omp_atomic (location_t loc, c_p while (c_parser_next_token_is_not (parser, CPP_PRAGMA_EOL)) { - if (!first - && c_parser_next_token_is (parser, CPP_COMMA) + if (c_parser_next_token_is (parser, CPP_COMMA) && c_parser_peek_2nd_token (parser)->type == CPP_NAME) c_parser_consume_token (parser); - first = false; - if (c_parser_next_token_is (parser, CPP_NAME)) { const char *p @@ -19553,6 +19552,8 @@ c_parser_omp_depobj (c_parser *parser) parens.skip_until_found_close (parser); tree clause = NULL_TREE; enum omp_clause_depend_kind kind = OMP_CLAUSE_DEPEND_INVALID; + if (c_parser_next_token_is (parser, CPP_COMMA)) + c_parser_consume_token (parser); location_t c_loc = c_parser_peek_token (parser)->location; if (c_parser_next_token_is (parser, CPP_NAME)) { @@ -19629,6 +19630,9 @@ c_parser_omp_flush (c_parser *parser) location_t loc = c_parser_peek_token (parser)->location; c_parser_consume_pragma (parser); enum memmodel mo = MEMMODEL_LAST; + if (c_parser_next_token_is (parser, CPP_COMMA) + && c_parser_peek_2nd_token (parser)->type == CPP_NAME) + c_parser_consume_token (parser); if (c_parser_next_token_is (parser, CPP_NAME)) { const char *p @@ -19721,6 +19725,9 @@ c_parser_omp_scan_loop_body (c_parser *p c_parser_consume_pragma (parser); + if (c_parser_next_token_is (parser, CPP_COMMA)) + c_parser_consume_token (parser); + if (c_parser_next_token_is (parser, CPP_NAME)) { const char *p @@ -20504,9 +20511,14 @@ c_parser_omp_ordered (c_parser *parser, return false; } - if (c_parser_next_token_is (parser, CPP_NAME)) + int n = 1; + if (c_parser_next_token_is (parser, CPP_COMMA)) + n = 2; + + if (c_parser_peek_nth_token (parser, n)->type == CPP_NAME) { - const char *p = IDENTIFIER_POINTER (c_parser_peek_token (parser)->value); + const char *p + = IDENTIFIER_POINTER (c_parser_peek_nth_token (parser, n)->value); if (!strcmp ("depend", p) || !strcmp ("doacross", p)) { @@ -22379,6 +22391,10 @@ c_finish_omp_declare_variant (c_parser * parens.require_close (parser); + if (c_parser_next_token_is (parser, CPP_COMMA) + && c_parser_peek_2nd_token (parser)->type == CPP_NAME) + c_parser_consume_token (parser); + const char *clause = ""; location_t match_loc = c_parser_peek_token (parser)->location; if (c_parser_next_token_is (parser, CPP_NAME)) @@ -22548,7 +22564,9 @@ c_parser_omp_declare_target (c_parser *p tree clauses = NULL_TREE; int device_type = 0; bool only_device_type = true; - if (c_parser_next_token_is (parser, CPP_NAME)) + if (c_parser_next_token_is (parser, CPP_NAME) + || (c_parser_next_token_is (parser, CPP_COMMA) + && c_parser_peek_2nd_token (parser)->type == CPP_NAME)) clauses = c_parser_omp_all_clauses (parser, OMP_DECLARE_TARGET_CLAUSE_MASK, "#pragma omp declare target"); else if (c_parser_next_token_is (parser, CPP_OPEN_PAREN)) @@ -22969,10 +22987,14 @@ c_parser_omp_declare_reduction (c_parser initializer.set_error (); if (!c_parser_require (parser, CPP_CLOSE_PAREN, "expected %<)%>")) bad = true; - else if (c_parser_next_token_is (parser, CPP_NAME) - && strcmp (IDENTIFIER_POINTER + else if (c_parser_next_token_is (parser, CPP_COMMA) + && c_parser_peek_2nd_token (parser)->type == CPP_NAME) + c_parser_consume_token (parser); + if (!bad + && (c_parser_next_token_is (parser, CPP_NAME) + && strcmp (IDENTIFIER_POINTER (c_parser_peek_token (parser)->value), - "initializer") == 0) + "initializer") == 0)) { c_parser_consume_token (parser); pop_scope (); @@ -23165,7 +23187,6 @@ c_parser_omp_declare (c_parser *parser, static void c_parser_omp_requires (c_parser *parser) { - bool first = true; enum omp_requires new_req = (enum omp_requires) 0; c_parser_consume_pragma (parser); @@ -23173,13 +23194,10 @@ c_parser_omp_requires (c_parser *parser) location_t loc = c_parser_peek_token (parser)->location; while (c_parser_next_token_is_not (parser, CPP_PRAGMA_EOL)) { - if (!first - && c_parser_next_token_is (parser, CPP_COMMA) + if (c_parser_next_token_is (parser, CPP_COMMA) && c_parser_peek_2nd_token (parser)->type == CPP_NAME) c_parser_consume_token (parser); - first = false; - if (c_parser_next_token_is (parser, CPP_NAME)) { const char *p @@ -23450,7 +23468,6 @@ c_parser_omp_error (c_parser *parser, en int at_compilation = -1; int severity_fatal = -1; tree message = NULL_TREE; - bool first = true; bool bad = false; location_t loc = c_parser_peek_token (parser)->location; @@ -23458,13 +23475,10 @@ c_parser_omp_error (c_parser *parser, en while (c_parser_next_token_is_not (parser, CPP_PRAGMA_EOL)) { - if (!first - && c_parser_next_token_is (parser, CPP_COMMA) + if (c_parser_next_token_is (parser, CPP_COMMA) && c_parser_peek_2nd_token (parser)->type == CPP_NAME) c_parser_consume_token (parser); - first = false; - if (!c_parser_next_token_is (parser, CPP_NAME)) break; @@ -23620,7 +23634,6 @@ c_parser_omp_error (c_parser *parser, en static void c_parser_omp_assumption_clauses (c_parser *parser, bool is_assume) { - bool first = true; bool no_openmp = false; bool no_openmp_routines = false; bool no_parallelism = false; @@ -23636,13 +23649,10 @@ c_parser_omp_assumption_clauses (c_parse while (c_parser_next_token_is_not (parser, CPP_PRAGMA_EOL)) { - if (!first - && c_parser_next_token_is (parser, CPP_COMMA) + if (c_parser_next_token_is (parser, CPP_COMMA) && c_parser_peek_2nd_token (parser)->type == CPP_NAME) c_parser_consume_token (parser); - first = false; - if (!c_parser_next_token_is (parser, CPP_NAME)) break; --- gcc/cp/parser.cc.jj 2022-10-26 09:50:26.089811555 +0200 +++ gcc/cp/parser.cc 2022-10-27 14:52:26.955303487 +0200 @@ -40443,12 +40443,7 @@ cp_parser_omp_all_clauses (cp_parser *pa if (nested && cp_lexer_next_token_is (parser->lexer, CPP_CLOSE_PAREN)) break; - if (!first - /* OpenMP 5.1 allows optional comma in between directive-name and - clauses everywhere, but as we aren't done with OpenMP 5.0 - implementation yet, let's allow it for now only in C++11 - attributes. */ - || (parser->lexer->in_omp_attribute_pragma && nested != 2)) + if (!first || nested != 2) { if (cp_lexer_next_token_is (parser->lexer, CPP_COMMA)) cp_lexer_consume_token (parser->lexer); @@ -40881,9 +40876,7 @@ cp_parser_omp_allocate (cp_parser *parse location_t loc = pragma_tok->location; tree nl = cp_parser_omp_var_list (parser, OMP_CLAUSE_ALLOCATE, NULL_TREE); - /* For now only in C++ attributes, do it always for OpenMP 5.1. */ - if (parser->lexer->in_omp_attribute_pragma - && cp_lexer_next_token_is (parser->lexer, CPP_COMMA) + if (cp_lexer_next_token_is (parser->lexer, CPP_COMMA) && cp_lexer_nth_token_is (parser->lexer, 2, CPP_NAME)) cp_lexer_consume_token (parser->lexer); @@ -41004,7 +40997,6 @@ cp_parser_omp_atomic (cp_parser *parser, enum tree_code code = ERROR_MARK, opcode = NOP_EXPR; enum omp_memory_order memory_order = OMP_MEMORY_ORDER_UNSPECIFIED; bool structured_block = false; - bool first = true; tree clauses = NULL_TREE; bool capture = false; bool compare = false; @@ -41015,14 +41007,10 @@ cp_parser_omp_atomic (cp_parser *parser, while (cp_lexer_next_token_is_not (parser->lexer, CPP_PRAGMA_EOL)) { - /* For now only in C++ attributes, do it always for OpenMP 5.1. */ - if ((!first || parser->lexer->in_omp_attribute_pragma) - && cp_lexer_next_token_is (parser->lexer, CPP_COMMA) + if (cp_lexer_next_token_is (parser->lexer, CPP_COMMA) && cp_lexer_nth_token_is (parser->lexer, 2, CPP_NAME)) cp_lexer_consume_token (parser->lexer); - first = false; - if (cp_lexer_next_token_is (parser->lexer, CPP_NAME)) { tree id = cp_lexer_peek_token (parser->lexer)->u.value; @@ -41976,11 +41964,9 @@ cp_parser_omp_depobj (cp_parser *parser, tree clause = NULL_TREE; enum omp_clause_depend_kind kind = OMP_CLAUSE_DEPEND_INVALID; - location_t c_loc = cp_lexer_peek_token (parser->lexer)->location; - /* For now only in C++ attributes, do it always for OpenMP 5.1. */ - if (parser->lexer->in_omp_attribute_pragma - && cp_lexer_next_token_is (parser->lexer, CPP_COMMA)) + if (cp_lexer_next_token_is (parser->lexer, CPP_COMMA)) cp_lexer_consume_token (parser->lexer); + location_t c_loc = cp_lexer_peek_token (parser->lexer)->location; if (cp_lexer_next_token_is (parser->lexer, CPP_NAME)) { tree id = cp_lexer_peek_token (parser->lexer)->u.value; @@ -42063,9 +42049,7 @@ static void cp_parser_omp_flush (cp_parser *parser, cp_token *pragma_tok) { enum memmodel mo = MEMMODEL_LAST; - /* For now only in C++ attributes, do it always for OpenMP 5.1. */ - if (parser->lexer->in_omp_attribute_pragma - && cp_lexer_next_token_is (parser->lexer, CPP_COMMA) + if (cp_lexer_next_token_is (parser->lexer, CPP_COMMA) && cp_lexer_nth_token_is (parser->lexer, 2, CPP_NAME)) cp_lexer_consume_token (parser->lexer); if (cp_lexer_next_token_is (parser->lexer, CPP_NAME)) @@ -42790,8 +42774,7 @@ cp_parser_omp_scan_loop_body (cp_parser cp_lexer_consume_token (parser->lexer); - if (parser->lexer->in_omp_attribute_pragma - && cp_lexer_next_token_is (parser->lexer, CPP_COMMA)) + if (cp_lexer_next_token_is (parser->lexer, CPP_COMMA)) cp_lexer_consume_token (parser->lexer); if (cp_lexer_next_token_is (parser->lexer, CPP_NAME)) @@ -43593,9 +43576,7 @@ cp_parser_omp_ordered (cp_parser *parser location_t loc = pragma_tok->location; int n = 1; - /* For now only in C++ attributes, do it always for OpenMP 5.1. */ - if (parser->lexer->in_omp_attribute_pragma - && cp_lexer_next_token_is (parser->lexer, CPP_COMMA)) + if (cp_lexer_next_token_is (parser->lexer, CPP_COMMA)) n = 2; if (cp_lexer_nth_token_is (parser->lexer, n, CPP_NAME)) @@ -45949,7 +45930,6 @@ static void cp_parser_omp_assumption_clauses (cp_parser *parser, cp_token *pragma_tok, bool is_assume) { - bool first = true; bool no_openmp = false; bool no_openmp_routines = false; bool no_parallelism = false; @@ -45965,14 +45945,10 @@ cp_parser_omp_assumption_clauses (cp_par while (cp_lexer_next_token_is_not (parser->lexer, CPP_PRAGMA_EOL)) { - /* For now only in C++ attributes, do it always for OpenMP 5.1. */ - if ((!first || parser->lexer->in_omp_attribute_pragma) - && cp_lexer_next_token_is (parser->lexer, CPP_COMMA) + if (cp_lexer_next_token_is (parser->lexer, CPP_COMMA) && cp_lexer_nth_token_is (parser->lexer, 2, CPP_NAME)) cp_lexer_consume_token (parser->lexer); - first = false; - if (!cp_lexer_next_token_is (parser->lexer, CPP_NAME)) break; @@ -46209,9 +46185,7 @@ cp_finish_omp_declare_variant (cp_parser location_t finish_loc = get_finish (varid.get_location ()); location_t varid_loc = make_location (caret_loc, start_loc, finish_loc); - /* For now only in C++ attributes, do it always for OpenMP 5.1. */ - if (parser->lexer->in_omp_attribute_pragma - && cp_lexer_next_token_is (parser->lexer, CPP_COMMA) + if (cp_lexer_next_token_is (parser->lexer, CPP_COMMA) && cp_lexer_nth_token_is (parser->lexer, 2, CPP_NAME)) cp_lexer_consume_token (parser->lexer); @@ -46287,11 +46261,6 @@ cp_parser_late_parsing_omp_declare_simd cp_lexer_consume_token (parser->lexer); if (strcmp (kind, "simd") == 0) { - /* For now only in C++ attributes, do it always for OpenMP 5.1. - if (cp_lexer_next_token_is (parser->lexer, CPP_COMMA) - && cp_lexer_nth_token_is (parser->lexer, 2, CPP_NAME)) - cp_lexer_consume_token (parser->lexer); */ - cl = cp_parser_omp_all_clauses (parser, OMP_DECLARE_SIMD_CLAUSE_MASK, "#pragma omp declare simd", pragma_tok); @@ -46549,9 +46518,7 @@ cp_parser_omp_declare_target (cp_parser int device_type = 0; bool only_device_type = true; if (cp_lexer_next_token_is (parser->lexer, CPP_NAME) - /* For now only in C++ attributes, do it always for OpenMP 5.1. */ - || (parser->lexer->in_omp_attribute_pragma - && cp_lexer_next_token_is (parser->lexer, CPP_COMMA) + || (cp_lexer_next_token_is (parser->lexer, CPP_COMMA) && cp_lexer_nth_token_is (parser->lexer, 2, CPP_NAME))) clauses = cp_parser_omp_all_clauses (parser, OMP_DECLARE_TARGET_CLAUSE_MASK, @@ -46801,9 +46768,7 @@ cp_parser_omp_declare_reduction_exprs (t if (!cp_parser_require (parser, CPP_CLOSE_PAREN, RT_CLOSE_PAREN)) return false; - /* For now only in C++ attributes, do it always for OpenMP 5.1. */ - if (parser->lexer->in_omp_attribute_pragma - && cp_lexer_next_token_is (parser->lexer, CPP_COMMA) + if (cp_lexer_next_token_is (parser->lexer, CPP_COMMA) && cp_lexer_nth_token_is (parser->lexer, 2, CPP_NAME)) cp_lexer_consume_token (parser->lexer); @@ -47235,20 +47200,15 @@ cp_parser_omp_declare (cp_parser *parser static bool cp_parser_omp_requires (cp_parser *parser, cp_token *pragma_tok) { - bool first = true; enum omp_requires new_req = (enum omp_requires) 0; location_t loc = pragma_tok->location; while (cp_lexer_next_token_is_not (parser->lexer, CPP_PRAGMA_EOL)) { - /* For now only in C++ attributes, do it always for OpenMP 5.1. */ - if ((!first || parser->lexer->in_omp_attribute_pragma) - && cp_lexer_next_token_is (parser->lexer, CPP_COMMA) + if (cp_lexer_next_token_is (parser->lexer, CPP_COMMA) && cp_lexer_nth_token_is (parser->lexer, 2, CPP_NAME)) cp_lexer_consume_token (parser->lexer); - first = false; - if (cp_lexer_next_token_is (parser->lexer, CPP_NAME)) { tree id = cp_lexer_peek_token (parser->lexer)->u.value; @@ -47402,20 +47362,15 @@ cp_parser_omp_error (cp_parser *parser, int at_compilation = -1; int severity_fatal = -1; tree message = NULL_TREE; - bool first = true; bool bad = false; location_t loc = pragma_tok->location; while (cp_lexer_next_token_is_not (parser->lexer, CPP_PRAGMA_EOL)) { - /* For now only in C++ attributes, do it always for OpenMP 5.1. */ - if ((!first || parser->lexer->in_omp_attribute_pragma) - && cp_lexer_next_token_is (parser->lexer, CPP_COMMA) + if (cp_lexer_next_token_is (parser->lexer, CPP_COMMA) && cp_lexer_nth_token_is (parser->lexer, 2, CPP_NAME)) cp_lexer_consume_token (parser->lexer); - first = false; - if (cp_lexer_next_token_is_not (parser->lexer, CPP_NAME)) break; --- gcc/testsuite/c-c++-common/gomp/directive-1.c.jj 2022-10-27 16:52:07.408685768 +0200 +++ gcc/testsuite/c-c++-common/gomp/directive-1.c 2022-10-27 17:29:48.609671613 +0200 @@ -0,0 +1,28 @@ +int thr; +#pragma omp threadprivate, (thr) /* { dg-error "expected '\\\(' before ',' token" } */ + /* { dg-error "expected end of line before ',' token" "" { target c++ } .-1 } */ +#pragma omp declare reduction, (foo: int : omp_out += omp_in), initializer (omp_priv = 0) /* { dg-error "expected '\\\(' before ',' token" } */ +void f1 (void); +#pragma omp declare variant, (f1), match (user={condition(true)}) /* { dg-error "expected '\\\(' before ',' token" } */ +void f2 (void); +int j; +#pragma omp declare target, (j) /* { dg-error "expected end of line before ',' token" } */ + +typedef struct __attribute__((__aligned__ (sizeof (void *)))) omp_depend_t { + char __omp_depend_t__[2 * sizeof (void *)]; +} omp_depend_t; +extern omp_depend_t d; + +void +foo (void) +{ + int i, k = 0, l = 0; + #pragma omp allocate, (i) /* { dg-error "expected '\\\(' before ',' token" } */ + /* { dg-error "expected end of line before ',' token" "" { target c++ } .-1 } */ + /* { dg-message "not yet supported" "" { target *-*-* } .-2 } */ + #pragma omp critical, (bar) /* { dg-error "expected '#pragma omp' clause before '\\\(' token" } */ + ; + #pragma omp flush, (k, l) /* { dg-error "expected '\\\(' or end of line before ',' token" "" { target c } } */ + /* { dg-error "expected end of line before ',' token" "" { target c++ } .-1 } */ + #pragma omp depobj, (d) depend(in : l) /* { dg-error "expected '\\\(' before ',' token" } */ +} --- gcc/testsuite/c-c++-common/gomp/clauses-6.c.jj 2022-10-27 15:19:08.198121764 +0200 +++ gcc/testsuite/c-c++-common/gomp/clauses-6.c 2022-10-27 17:23:04.276220308 +0200 @@ -0,0 +1,604 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-std=c99" { target c } } */ + +typedef enum omp_allocator_handle_t +#if __cplusplus >= 201103L +: __UINTPTR_TYPE__ +#endif +{ + omp_null_allocator = 0, + omp_default_mem_alloc = 1, + omp_large_cap_mem_alloc = 2, + omp_const_mem_alloc = 3, + omp_high_bw_mem_alloc = 4, + omp_low_lat_mem_alloc = 5, + omp_cgroup_mem_alloc = 6, + omp_pteam_mem_alloc = 7, + omp_thread_mem_alloc = 8, + __omp_allocator_handle_t_max__ = __UINTPTR_MAX__ +} omp_allocator_handle_t; + +typedef enum omp_sync_hint_t { +omp_sync_hint_none = 0x0, +omp_lock_hint_none = omp_sync_hint_none, +omp_sync_hint_uncontended = 0x1, +omp_lock_hint_uncontended = omp_sync_hint_uncontended, +omp_sync_hint_contended = 0x2, +omp_lock_hint_contended = omp_sync_hint_contended, +omp_sync_hint_nonspeculative = 0x4, +omp_lock_hint_nonspeculative = omp_sync_hint_nonspeculative, +omp_sync_hint_speculative = 0x8, +omp_lock_hint_speculative = omp_sync_hint_speculative +} omp_sync_hint_t; + +typedef struct __attribute__((__aligned__ (sizeof (void *)))) omp_depend_t { + char __omp_depend_t__[2 * sizeof (void *)]; +} omp_depend_t; + +int t; +#pragma omp threadprivate (t) + +#pragma omp declare target +int f, l, ll, r, r2; + +void +foo (int d, int m, int i1, int i2, int p, int *idp, int s, + int nte, int tl, int nth, int g, int nta, int fi, int pp, int *q, int ntm) +{ + #pragma omp distribute parallel for, \ + private (p), firstprivate (f), collapse(1), dist_schedule(static, 16), \ + if (parallel: i2), default(shared), shared(s), reduction(+:r), num_threads (nth), proc_bind(spread), \ + lastprivate (l), schedule(static, 4), order(concurrent), allocate (omp_default_mem_alloc:f) + for (int i = 0; i < 64; i++) + ll++; + #pragma omp distribute parallel for simd, \ + private (p), firstprivate (f), collapse(1), dist_schedule(static, 16), \ + if (parallel: i2), if(simd: i1), default(shared), shared(s), reduction(+:r), num_threads (nth), proc_bind(spread), \ + lastprivate (l), schedule(static, 4), nontemporal(ntm), \ + safelen(8), simdlen(4), aligned(q: 32), order(concurrent), allocate (omp_default_mem_alloc:f) + for (int i = 0; i < 64; i++) + ll++; + #pragma omp distribute simd, \ + private (p), firstprivate (f), collapse(1), dist_schedule(static, 16), \ + safelen(8), simdlen(4), aligned(q: 32), reduction(+:r), if(i1), nontemporal(ntm), \ + order(concurrent), allocate (omp_default_mem_alloc:f) + for (int i = 0; i < 64; i++) + ll++; +} + +void +qux (int p) +{ + #pragma omp loop, bind(teams), order(concurrent), \ + private (p), lastprivate (l), collapse(1), reduction(+:r) + for (l = 0; l < 64; ++l) + ll++; +} +#pragma omp end declare target + +void +baz (int d, int m, int i1, int i2, int p, int *idp, int s, + int nte, int tl, int nth, int g, int nta, int fi, int pp, int *q, int ntm) +{ + #pragma omp distribute parallel for, \ + private (p), firstprivate (f), collapse(1), dist_schedule(static, 16), \ + if (parallel: i2), default(shared), shared(s), reduction(+:r), num_threads (nth), proc_bind(spread), \ + lastprivate (l), schedule(static, 4), copyin(t), allocate (p) + for (int i = 0; i < 64; i++) + ll++; + #pragma omp distribute parallel for, \ + private (p), firstprivate (f), collapse(1), dist_schedule(static, 16), \ + if (parallel: i2), default(shared), shared(s), reduction(+:r), num_threads (nth), proc_bind(spread), \ + lastprivate (l), schedule(static, 4), order(concurrent), allocate (p) + for (int i = 0; i < 64; i++) + ll++; + #pragma omp distribute parallel for simd, \ + private (p), firstprivate (f), collapse(1), dist_schedule(static, 16), \ + if (parallel: i2), if(simd: i1), default(shared), shared(s), reduction(+:r), num_threads (nth), proc_bind(spread), \ + lastprivate (l), schedule(static, 4), nontemporal(ntm), \ + safelen(8), simdlen(4), aligned(q: 32), copyin(t), allocate (f) + for (int i = 0; i < 64; i++) + ll++; + #pragma omp distribute parallel for simd, \ + private (p), firstprivate (f), collapse(1), dist_schedule(static, 16), \ + if (parallel: i2), if(simd: i1), default(shared), shared(s), reduction(+:r), num_threads (nth), proc_bind(spread), \ + lastprivate (l), schedule(static, 4), nontemporal(ntm), \ + safelen(8), simdlen(4), aligned(q: 32), order(concurrent), allocate (f) + for (int i = 0; i < 64; i++) + ll++; + #pragma omp distribute simd, \ + private (p), firstprivate (f), collapse(1), dist_schedule(static, 16), \ + safelen(8), simdlen(4), aligned(q: 32), reduction(+:r), if(i1), nontemporal(ntm), \ + order(concurrent), allocate (f) + for (int i = 0; i < 64; i++) + ll++; + #pragma omp loop, bind(parallel), order(concurrent), \ + private (p), lastprivate (l), collapse(1), reduction(+:r) + for (l = 0; l < 64; ++l) + ll++; +} + +void +bar (int d, int m, int i1, int i2, int i3, int p, int *idp, int hda, int s, + int nte, int tl, int nth, int g, int nta, int fi, int pp, int *q, int *dd, int ntm, + int n1, int n2) +{ + #pragma omp for simd, \ + private (p), firstprivate (f), lastprivate (l), linear (ll:1), reduction(+:r), schedule(static, 4), collapse(1), nowait, \ + safelen(8), simdlen(4), aligned(q: 32), nontemporal(ntm), if(i1), order(concurrent), allocate (f) + for (int i = 0; i < 64; i++) + ll++; + #pragma omp parallel for, \ + private (p), firstprivate (f), if (parallel: i2), default(shared), shared(s), copyin(t), reduction(+:r), num_threads (nth), proc_bind(spread), \ + lastprivate (l), linear (ll:1), ordered, schedule(static, 4), collapse(1), allocate (f) + for (int i = 0; i < 64; i++) + ll++; + #pragma omp parallel for, \ + private (p), firstprivate (f), if (parallel: i2), default(shared), shared(s), copyin(t), reduction(+:r), num_threads (nth), proc_bind(spread), \ + lastprivate (l), linear (ll:1), schedule(static, 4), collapse(1), order(concurrent), allocate (f) + for (int i = 0; i < 64; i++) + ll++; + #pragma omp parallel for simd, \ + private (p), firstprivate (f), if (i2), default(shared), shared(s), copyin(t), reduction(+:r), num_threads (nth), proc_bind(spread), \ + lastprivate (l), linear (ll:1), schedule(static, 4), collapse(1), \ + safelen(8), simdlen(4), aligned(q: 32), nontemporal(ntm), order(concurrent), allocate (f) + for (int i = 0; i < 64; i++) + ll++; + #pragma omp parallel sections, \ + private (p), firstprivate (f), if (parallel: i2), default(shared), shared(s), copyin(t), reduction(+:r), num_threads (nth), proc_bind(spread), \ + lastprivate (l), allocate (f) + { + #pragma omp section + {} + #pragma omp section + {} + } + #pragma omp target parallel, \ + device(d), map (tofrom: m), if (target: i1), private (p), firstprivate (f), defaultmap(tofrom: scalar), is_device_ptr (idp), \ + if (parallel: i2), default(shared), shared(s), reduction(+:r), num_threads (nth), proc_bind(spread), \ + nowait, depend(inout: dd[0]), allocate (omp_default_mem_alloc:f), in_reduction(+:r2), has_device_addr(hda) + ; + #pragma omp target parallel for, \ + device(d), map (tofrom: m), if (target: i1), private (p), firstprivate (f), defaultmap(tofrom: scalar), is_device_ptr (idp), \ + if (parallel: i2), default(shared), shared(s), reduction(+:r), num_threads (nth), proc_bind(spread), \ + lastprivate (l), linear (ll:1), ordered, schedule(static, 4), collapse(1), nowait, depend(inout: dd[0]), \ + allocate (omp_default_mem_alloc:f), in_reduction(+:r2), has_device_addr(hda) + for (int i = 0; i < 64; i++) + ll++; + #pragma omp target parallel for, \ + device(d), map (tofrom: m), if (target: i1), private (p), firstprivate (f), defaultmap(tofrom: scalar), is_device_ptr (idp), \ + if (parallel: i2), default(shared), shared(s), reduction(+:r), num_threads (nth), proc_bind(spread), \ + lastprivate (l), linear (ll:1), schedule(static, 4), collapse(1), nowait, depend(inout: dd[0]), order(concurrent), \ + allocate (omp_default_mem_alloc:f), in_reduction(+:r2), has_device_addr(hda) + for (int i = 0; i < 64; i++) + ll++; + #pragma omp target parallel for simd, \ + device(d), map (tofrom: m), if (target: i1), private (p), firstprivate (f), defaultmap(tofrom: scalar), is_device_ptr (idp), \ + if (parallel: i2), default(shared), shared(s), reduction(+:r), num_threads (nth), proc_bind(spread), \ + lastprivate (l), linear (ll:1), schedule(static, 4), collapse(1), \ + safelen(8), simdlen(4), aligned(q: 32), nowait, depend(inout: dd[0]), nontemporal(ntm), if (simd: i3), order(concurrent), \ + allocate (omp_default_mem_alloc:f), in_reduction(+:r2), has_device_addr(hda) + for (int i = 0; i < 64; i++) + ll++; + #pragma omp target teams, \ + device(d), map (tofrom: m), if (target: i1), private (p), firstprivate (f), defaultmap(tofrom: scalar), is_device_ptr (idp), \ + shared(s), default(shared), reduction(+:r), num_teams(nte - 1:nte), thread_limit(tl), nowait depend(inout: dd[0]), \ + allocate (omp_default_mem_alloc:f), in_reduction(+:r2), has_device_addr(hda) + ; + #pragma omp target teams distribute, \ + device(d), map (tofrom: m), if (target: i1), private (p), firstprivate (f), defaultmap(tofrom: scalar), is_device_ptr (idp), \ + shared(s), default(shared), reduction(+:r), num_teams(nte), thread_limit(tl), order(concurrent), \ + collapse(1), dist_schedule(static, 16), nowait, depend(inout: dd[0]), allocate (omp_default_mem_alloc:f), in_reduction(+:r2), \ + has_device_addr(hda) + for (int i = 0; i < 64; i++) + ; + #pragma omp target teams distribute parallel for, \ + device(d), map (tofrom: m), if (target: i1), private (p), firstprivate (f), defaultmap(tofrom: scalar), is_device_ptr (idp), \ + shared(s), default(shared), reduction(+:r), num_teams(nte-1:nte), thread_limit(tl), \ + collapse(1), dist_schedule(static, 16), \ + if (parallel: i2), num_threads (nth), proc_bind(spread), \ + lastprivate (l), schedule(static, 4), nowait, depend(inout: dd[0]), order(concurrent), \ + allocate (omp_default_mem_alloc:f), in_reduction(+:r2), has_device_addr(hda) + for (int i = 0; i < 64; i++) + ll++; + #pragma omp target teams distribute parallel for simd, \ + device(d), map (tofrom: m), if (target: i1), private (p), firstprivate (f), defaultmap(tofrom: scalar), is_device_ptr (idp), \ + shared(s), default(shared), reduction(+:r), num_teams(nte), thread_limit(tl), \ + collapse(1), dist_schedule(static, 16), \ + if (parallel: i2), num_threads (nth), proc_bind(spread), \ + lastprivate (l), schedule(static, 4), order(concurrent), \ + safelen(8), simdlen(4), aligned(q: 32), nowait, depend(inout: dd[0]), nontemporal(ntm), if (simd: i3), \ + allocate (omp_default_mem_alloc:f), in_reduction(+:r2), has_device_addr(hda) + for (int i = 0; i < 64; i++) + ll++; + #pragma omp target teams distribute simd, \ + device(d), map (tofrom: m), if (i1), private (p), firstprivate (f), defaultmap(tofrom: scalar), is_device_ptr (idp), \ + shared(s), default(shared), reduction(+:r), num_teams(nte-1:nte), thread_limit(tl), \ + collapse(1), dist_schedule(static, 16), order(concurrent), \ + safelen(8), simdlen(4), aligned(q: 32), nowait depend(inout: dd[0]), nontemporal(ntm), \ + allocate (omp_default_mem_alloc:f), in_reduction(+:r2), has_device_addr(hda) + for (int i = 0; i < 64; i++) + ll++; + #pragma omp target simd, \ + device(d), map (tofrom: m), if (target: i1), private (p), firstprivate (f), defaultmap(tofrom: scalar), is_device_ptr (idp), \ + safelen(8), simdlen(4), lastprivate (l), linear(ll: 1), aligned(q: 32), reduction(+:r), \ + nowait depend(inout: dd[0]), nontemporal(ntm), if(simd:i3), order(concurrent), \ + allocate (omp_default_mem_alloc:f), in_reduction(+:r2), has_device_addr(hda) + for (int i = 0; i < 64; i++) + ll++; + #pragma omp taskgroup, task_reduction(+:r2), allocate (r2) + #pragma omp taskloop simd, \ + private (p), firstprivate (f), lastprivate (l), shared (s), default(shared), grainsize (g), collapse(1), untied, if(taskloop: i1), if(simd: i2), final(fi), mergeable, priority (pp), \ + safelen(8), simdlen(4), linear(ll: 1), aligned(q: 32), reduction(default, +:r), in_reduction(+:r2), nontemporal(ntm), \ + order(concurrent), allocate (f) + for (int i = 0; i < 64; i++) + ll++; + #pragma omp taskgroup, task_reduction(+:r), allocate (r) + #pragma omp taskloop simd, \ + private (p), firstprivate (f), lastprivate (l), shared (s), default(shared), grainsize (g), collapse(1), untied, if(i1), final(fi), mergeable, nogroup, priority (pp), \ + safelen(8), simdlen(4), linear(ll: 1), aligned(q: 32), in_reduction(+:r), nontemporal(ntm), \ + order(concurrent), allocate (f) + for (int i = 0; i < 64; i++) + ll++; + #pragma omp taskwait + #pragma omp taskloop simd, \ + private (p), firstprivate (f), lastprivate (l), shared (s), default(shared), num_tasks (nta), collapse(1), if(taskloop: i1), final(fi), priority (pp), \ + safelen(8), simdlen(4), linear(ll: 1), aligned(q: 32), reduction(+:r), if (simd: i3), nontemporal(ntm), \ + order(concurrent), allocate (f) + for (int i = 0; i < 64; i++) + ll++; + #pragma omp target, nowait, depend(inout: dd[0]), in_reduction(+:r2) + #pragma omp teams distribute, \ + private(p), firstprivate (f), shared(s), default(shared), reduction(+:r), num_teams(nte), thread_limit(tl), \ + collapse(1), dist_schedule(static, 16), allocate (omp_default_mem_alloc: f), order(concurrent) + for (int i = 0; i < 64; i++) + ; + #pragma omp target + #pragma omp teams distribute parallel for, \ + private(p), firstprivate (f), shared(s), default(shared), reduction(+:r), num_teams(nte-1:nte), thread_limit(tl), \ + collapse(1), dist_schedule(static, 16), \ + if (parallel: i2), num_threads (nth), proc_bind(spread), \ + lastprivate (l), schedule(static, 4), order(concurrent), allocate (omp_default_mem_alloc: f) + for (int i = 0; i < 64; i++) + ll++; + #pragma omp target + #pragma omp teams distribute parallel for simd, \ + private(p), firstprivate (f), shared(s), default(shared), reduction(+:r), num_teams(nte), thread_limit(tl), \ + collapse(1), dist_schedule(static, 16), \ + if (parallel: i2), num_threads (nth), proc_bind(spread), \ + lastprivate (l), schedule(static, 4), order(concurrent), \ + safelen(8), simdlen(4), aligned(q: 32), if (simd: i3), nontemporal(ntm), \ + allocate (omp_default_mem_alloc: f) + for (int i = 0; i < 64; i++) + ll++; + #pragma omp target + #pragma omp teams distribute simd, \ + private(p), firstprivate (f), shared(s), default(shared), reduction(+:r), num_teams(nte-1:nte), thread_limit(tl), \ + collapse(1), dist_schedule(static, 16), order(concurrent), \ + safelen(8), simdlen(4), aligned(q: 32), if(i3), nontemporal(ntm), \ + allocate (omp_default_mem_alloc: f) + for (int i = 0; i < 64; i++) + ll++; + #pragma omp teams distribute parallel for, \ + private(p), firstprivate (f), shared(s), default(shared), reduction(+:r), num_teams(nte), thread_limit(tl), \ + collapse(1), dist_schedule(static, 16), \ + if (parallel: i2), num_threads (nth), proc_bind(spread), \ + lastprivate (l), schedule(static, 4), copyin(t), allocate (f) + for (int i = 0; i < 64; i++) + ll++; + #pragma omp teams distribute parallel for, \ + private(p), firstprivate (f), shared(s), default(shared), reduction(+:r), num_teams(nte-1:nte), thread_limit(tl), \ + collapse(1), dist_schedule(static, 16), order(concurrent), \ + if (parallel: i2), num_threads (nth), proc_bind(spread), \ + lastprivate (l), schedule(static, 4), allocate (f) + for (int i = 0; i < 64; i++) + ll++; + #pragma omp teams distribute parallel for simd, \ + private(p), firstprivate (f), shared(s), default(shared), reduction(+:r), num_teams(nte), thread_limit(tl), \ + collapse(1), dist_schedule(static, 16), \ + if (parallel: i2), num_threads (nth), proc_bind(spread), \ + lastprivate (l), schedule(static, 4), \ + safelen(8), simdlen(4), aligned(q: 32), if (simd: i3), nontemporal(ntm), copyin(t), \ + allocate (f) + for (int i = 0; i < 64; i++) + ll++; + #pragma omp teams distribute parallel for simd, \ + private(p), firstprivate (f), shared(s), default(shared), reduction(+:r), num_teams(nte-1:nte), thread_limit(tl), \ + collapse(1), dist_schedule(static, 16), \ + if (parallel: i2), num_threads (nth), proc_bind(spread), \ + lastprivate (l), schedule(static, 4), order(concurrent), \ + safelen(8), simdlen(4), aligned(q: 32), if (simd: i3), nontemporal(ntm), \ + allocate (f) + for (int i = 0; i < 64; i++) + ll++; + #pragma omp teams distribute simd, \ + private(p), firstprivate (f), shared(s), default(shared), reduction(+:r), num_teams(nte), thread_limit(tl), \ + collapse(1), dist_schedule(static, 16), order(concurrent), \ + safelen(8), simdlen(4), aligned(q: 32), if(i3), nontemporal(ntm), allocate(f) + for (int i = 0; i < 64; i++) + ll++; + #pragma omp parallel master, \ + private (p), firstprivate (f), if (parallel: i2), default(shared), shared(s), reduction(+:r), \ + num_threads (nth), proc_bind(spread), copyin(t), allocate (f) + ; + #pragma omp parallel masked, \ + private (p), firstprivate (f), if (parallel: i2), default(shared), shared(s), reduction(+:r), \ + num_threads (nth), proc_bind(spread), copyin(t), allocate (f), filter (d) + ; + #pragma omp taskgroup, task_reduction (+:r2), allocate (r2) + #pragma omp master taskloop, \ + private (p), firstprivate (f), lastprivate (l), shared (s), default(shared), grainsize (g), collapse(1), untied, if(taskloop: i1), final(fi), mergeable, priority (pp), \ + reduction(default, +:r), in_reduction(+:r2), allocate (f) + for (int i = 0; i < 64; i++) + ll++; + #pragma omp taskgroup, task_reduction (+:r2), allocate (r2) + #pragma omp masked taskloop, \ + private (p), firstprivate (f), lastprivate (l), shared (s), default(shared), grainsize (g), collapse(1), untied, if(taskloop: i1), final(fi), mergeable, priority (pp), \ + reduction(default, +:r), in_reduction(+:r2), allocate (f), filter (d) + for (int i = 0; i < 64; i++) + ll++; + #pragma omp taskgroup, task_reduction (+:r2), allocate (r2) + #pragma omp master taskloop simd, \ + private (p), firstprivate (f), lastprivate (l), shared (s), default(shared), grainsize (g), collapse(1), untied, if(taskloop: i1), if(simd: i2), final(fi), mergeable, priority (pp), \ + safelen(8), simdlen(4), linear(ll: 1), aligned(q: 32), reduction(default, +:r), in_reduction(+:r2), nontemporal(ntm), \ + order(concurrent), allocate (f) + for (int i = 0; i < 64; i++) + ll++; + #pragma omp taskgroup, task_reduction (+:r2), allocate (r2) + #pragma omp masked taskloop simd, \ + private (p), firstprivate (f), lastprivate (l), shared (s), default(shared), grainsize (g), collapse(1), untied, if(taskloop: i1), if(simd: i2), final(fi), mergeable, priority (pp), \ + safelen(8), simdlen(4), linear(ll: 1), aligned(q: 32), reduction(default, +:r), in_reduction(+:r2), nontemporal(ntm), \ + order(concurrent), allocate (f), filter (d) + for (int i = 0; i < 64; i++) + ll++; + #pragma omp parallel master taskloop, \ + private (p), firstprivate (f), lastprivate (l), shared (s), default(shared), grainsize (g), collapse(1), untied, if(taskloop: i1), final(fi), mergeable, priority (pp), \ + reduction(default, +:r), if (parallel: i2), num_threads (nth), proc_bind(spread), copyin(t), allocate (f) + for (int i = 0; i < 64; i++) + ll++; + #pragma omp parallel masked taskloop, \ + private (p), firstprivate (f), lastprivate (l), shared (s), default(shared), grainsize (g), collapse(1), untied, if(taskloop: i1), final(fi), mergeable, priority (pp), \ + reduction(default, +:r), if (parallel: i2), num_threads (nth), proc_bind(spread), copyin(t), allocate (f), filter (d) + for (int i = 0; i < 64; i++) + ll++; + #pragma omp parallel master taskloop simd, \ + private (p), firstprivate (f), lastprivate (l), shared (s), default(shared), grainsize (g), collapse(1), untied, if(taskloop: i1), if(simd: i2), final(fi), mergeable, priority (pp), \ + safelen(8), simdlen(4), linear(ll: 1), aligned(q: 32), reduction(default, +:r), nontemporal(ntm), if (parallel: i2), num_threads (nth), proc_bind(spread), copyin(t), \ + order(concurrent), allocate (f) + for (int i = 0; i < 64; i++) + ll++; + #pragma omp parallel masked taskloop simd, \ + private (p), firstprivate (f), lastprivate (l), shared (s), default(shared), grainsize (g), collapse(1), untied, if(taskloop: i1), if(simd: i2), final(fi), mergeable, priority (pp), \ + safelen(8), simdlen(4), linear(ll: 1), aligned(q: 32), reduction(default, +:r), nontemporal(ntm), if (parallel: i2), num_threads (nth), proc_bind(spread), copyin(t), \ + order(concurrent), allocate (f), filter (d) + for (int i = 0; i < 64; i++) + ll++; + #pragma omp taskgroup, task_reduction (+:r2), allocate (r2) + #pragma omp master taskloop, \ + private (p), firstprivate (f), lastprivate (l), shared (s), default(shared), num_tasks (nta), collapse(1), untied, if(i1), final(fi), mergeable, priority (pp), \ + reduction(default, +:r), in_reduction(+:r2) + for (int i = 0; i < 64; i++) + ll++; + #pragma omp taskgroup, task_reduction (+:r2), allocate (r2) + #pragma omp mastked taskloop, \ + private (p), firstprivate (f), lastprivate (l), shared (s), default(shared), num_tasks (nta), collapse(1), untied, if(i1), final(fi), mergeable, priority (pp), \ + reduction(default, +:r), in_reduction(+:r2), filter (d) + for (int i = 0; i < 64; i++) + ll++; + #pragma omp taskgroup, task_reduction (+:r2), allocate (r2) + #pragma omp master taskloop simd, \ + private (p), firstprivate (f), lastprivate (l), shared (s), default(shared), num_tasks (nta), collapse(1), untied, if(i1), final(fi), mergeable, priority (pp), \ + safelen(8), simdlen(4), linear(ll: 1), aligned(q: 32), reduction(default, +:r), in_reduction(+:r2), nontemporal(ntm), \ + order(concurrent), allocate (f) + for (int i = 0; i < 64; i++) + ll++; + #pragma omp taskgroup, task_reduction (+:r2), allocate (r2) + #pragma omp masked taskloop simd, \ + private (p), firstprivate (f), lastprivate (l), shared (s), default(shared), num_tasks (nta), collapse(1), untied, if(i1), final(fi), mergeable, priority (pp), \ + safelen(8), simdlen(4), linear(ll: 1), aligned(q: 32), reduction(default, +:r), in_reduction(+:r2), nontemporal(ntm), \ + order(concurrent), allocate (f), filter (d) + for (int i = 0; i < 64; i++) + ll++; + #pragma omp parallel master taskloop, \ + private (p), firstprivate (f), lastprivate (l), shared (s), default(shared), num_tasks (nta), collapse(1), untied, if(i1), final(fi), mergeable, priority (pp), \ + reduction(default, +:r), num_threads (nth), proc_bind(spread), copyin(t), allocate (f) + for (int i = 0; i < 64; i++) + ll++; + #pragma omp parallel masked taskloop, \ + private (p), firstprivate (f), lastprivate (l), shared (s), default(shared), num_tasks (nta), collapse(1), untied, if(i1), final(fi), mergeable, priority (pp), \ + reduction(default, +:r), num_threads (nth), proc_bind(spread), copyin(t), allocate (f), filter (d) + for (int i = 0; i < 64; i++) + ll++; + #pragma omp parallel master taskloop simd, \ + private (p), firstprivate (f), lastprivate (l), shared (s), default(shared), num_tasks (nta), collapse(1), untied, if(i1), final(fi), mergeable, priority (pp), \ + safelen(8), simdlen(4), linear(ll: 1), aligned(q: 32), reduction(default, +:r), nontemporal(ntm), num_threads (nth), proc_bind(spread), copyin(t), \ + order(concurrent), allocate (f) + for (int i = 0; i < 64; i++) + ll++; + #pragma omp parallel masked taskloop simd, \ + private (p), firstprivate (f), lastprivate (l), shared (s), default(shared), num_tasks (nta), collapse(1), untied, if(i1), final(fi), mergeable, priority (pp), \ + safelen(8), simdlen(4), linear(ll: 1), aligned(q: 32), reduction(default, +:r), nontemporal(ntm), num_threads (nth), proc_bind(spread), copyin(t), \ + order(concurrent), allocate (f), filter (d) + for (int i = 0; i < 64; i++) + ll++; + #pragma omp loop, bind(thread), order(concurrent), \ + private (p), lastprivate (l), collapse(1), reduction(+:r) + for (l = 0; l < 64; ++l) + ll++; + #pragma omp parallel loop, \ + private (p), firstprivate (f), if (parallel: i2), default(shared), shared(s), copyin(t), reduction(+:r), num_threads (nth), proc_bind(spread), \ + lastprivate (l), collapse(1), bind(parallel), order(concurrent), allocate (f) + for (l = 0; l < 64; l++) + ll++; + #pragma omp parallel loop, \ + private (p), firstprivate (f), if (parallel: i2), default(shared), shared(s), copyin(t), reduction(+:r), num_threads (nth), proc_bind(spread), \ + lastprivate (l), collapse(1), allocate (f) + for (l = 0; l < 64; l++) + ll++; + #pragma omp teams loop, \ + private(p), firstprivate (f), shared(s), default(shared), reduction(+:r), num_teams(nte-1:nte), thread_limit(tl), \ + collapse(1), lastprivate (l), bind(teams), allocate (f) + for (l = 0; l < 64; ++l) + ; + #pragma omp teams loop, \ + private(p), firstprivate (f), shared(s), default(shared), reduction(+:r), num_teams(nte), thread_limit(tl), \ + collapse(1), lastprivate (l), order(concurrent), allocate (f) + for (l = 0; l < 64; ++l) + ; + #pragma omp target parallel loop, \ + device(d), map (tofrom: m), if (target: i1), private (p), firstprivate (f), defaultmap(tofrom: scalar), is_device_ptr (idp), \ + if (parallel: i2), default(shared), shared(s), reduction(+:r), num_threads (nth), proc_bind(spread), \ + nowait depend(inout: dd[0]), lastprivate (l), bind(parallel), order(concurrent), collapse(1), \ + allocate (omp_default_mem_alloc: f), in_reduction(+:r2), has_device_addr(hda) + for (l = 0; l < 64; ++l) + ; + #pragma omp target parallel loop, \ + device(d), map (tofrom: m), if (target: i1), private (p), firstprivate (f), defaultmap(tofrom: scalar), is_device_ptr (idp), \ + if (parallel: i2), default(shared), shared(s), reduction(+:r), num_threads (nth), proc_bind(spread), \ + nowait depend(inout: dd[0]), lastprivate (l), order(concurrent), collapse(1), \ + allocate (omp_default_mem_alloc: f), in_reduction(+:r2), has_device_addr(hda) + for (l = 0; l < 64; ++l) + ; + #pragma omp target teams loop, \ + device(d), map (tofrom: m), if (target: i1), private (p), firstprivate (f), defaultmap(tofrom: scalar), is_device_ptr (idp), \ + shared(s), default(shared), reduction(+:r), num_teams(nte-1:nte), thread_limit(tl), nowait depend(inout: dd[0]), \ + lastprivate (l), bind(teams), collapse(1), \ + allocate (omp_default_mem_alloc: f), in_reduction(+:r2), has_device_addr(hda) + for (l = 0; l < 64; ++l) + ; + #pragma omp target teams loop, \ + device(d), map (tofrom: m), if (target: i1), private (p), firstprivate (f), defaultmap(tofrom: scalar), is_device_ptr (idp), \ + shared(s), default(shared), reduction(+:r), num_teams(nte), thread_limit(tl), nowait depend(inout: dd[0]), \ + lastprivate (l), order(concurrent), collapse(1), \ + allocate (omp_default_mem_alloc: f), in_reduction(+:r2), has_device_addr(hda) + for (l = 0; l < 64; ++l) + ; + #pragma omp critical + ; + #pragma omp critical (foobar),hint(omp_sync_hint_none) + ; + #pragma omp taskwait, depend (inout: dd[0]) + ; + #pragma omp taskgroup, task_reduction(+:r2),allocate (r2) + ; + #pragma omp atomic, update,seq_cst,hint(omp_sync_hint_none) + p++; + #pragma omp atomic, read, hint(omp_sync_hint_none),relaxed + f = p; + #pragma omp atomic,write, release hint(omp_sync_hint_none) + p = f; + #pragma omp flush + ; + #pragma omp flush, acq_rel + ; + #pragma omp flush, acquire + ; + #pragma omp flush, release + ; + #pragma omp flush, seq_cst + ; + #pragma omp flush (p, f) + ; + #pragma omp simd, \ + private (p),lastprivate (l),linear (ll:1),reduction(+:r),collapse(1),safelen(8),simdlen(4),aligned(q: 32), \ + nontemporal(ntm),if(i1) + for (int i = 0; i < 64; i++) + #pragma omp ordered, simd + ll++; + #pragma omp for, \ + private (p),firstprivate (f),lastprivate (l),linear (ll:1),reduction(+:r),schedule(static, 4),collapse(1),nowait, \ + ordered, allocate (f) + for (int i = 0; i < 64; i++) + #pragma omp ordered, threads + ll++; + #pragma omp for, ordered (1) + for (l = 0; l < 64; l++) + { + #pragma omp ordered, depend (sink: l - 1) + ; + #pragma omp ordered, depend (source) + ; + } + extern omp_depend_t depobj; + #pragma omp depobj(depobj),depend(in : dd[0]) + ; + #pragma omp parallel + { + if (p) { + #pragma omp cancel, parallel + ; + } else { + #pragma omp cancellation point, parallel + ; + } + } + #pragma omp scope, private (p), firstprivate (f), reduction(+:r), nowait, \ + allocate(omp_default_mem_alloc: r) + ; + #pragma omp scope, private (p), firstprivate (f), reduction(task, +:r), \ + allocate (omp_default_mem_alloc: f) + ; + extern int t2; + #pragma omp threadprivate (t2) + extern int t2; + #pragma omp declare reduction (dr: int: omp_out += omp_in),initializer (omp_priv = 0) + #pragma omp assume, no_openmp, no_openmp_routines, no_parallelism, \ + absent (atomic, barrier, cancel, cancellation point), \ + absent (critical, depobj), \ + absent (distribute, flush, loop, masked, master, nothing, ordered), \ + absent (parallel, scan, scope, section, sections, simd, single, task), \ + absent (taskgroup, taskloop, taskwait, taskyield), \ + absent (target, teams, for, error), holds (n1 < n2) + if (0) + ; + #pragma omp assume, contains (simd) + #pragma omp for simd + for (int i = 0; i < 64; i++) + ; +} + +void corge1 (); + +void +corge () +{ + #pragma omp declare variant (corge1),match (construct={parallel,for}) + extern void corge2 (); + #pragma omp parallel + #pragma omp for + for (int i = 0; i < 5; i++) + corge2 (); + #pragma omp declare simd, simdlen(4),linear(l),aligned(p:4),uniform(p),inbranch + #pragma omp declare simd,simdlen(8),notinbranch + extern int corge3 (int l, int *p); + #pragma omp declare simd, simdlen(4),linear(l),aligned(p:4),uniform(p),inbranch + #pragma omp declare simd, simdlen(8),notinbranch + extern int corge4 (int l, int *p); + #pragma omp declare simd, simdlen(4),linear(l),aligned(p:4),uniform(p),inbranch + #pragma omp declare simd, simdlen(8),notinbranch + extern int corge5 (int l, int *p); + #pragma omp declare target + extern void corge6 (); + #pragma omp end declare target +} + +int +garply (int a, int *c, int *d, int *e, int *f) +{ + int i; + #pragma omp simd, reduction (inscan, +: a) + for (i = 0; i < 64; i++) + { + d[i] = a; + #pragma omp scan, exclusive (a) + a += c[i]; + } + #pragma omp simd, reduction (inscan, +: a) + for (i = 0; i < 64; i++) + { + a += c[i]; + #pragma omp scan inclusive (a) + d[i] = a; + } + return a; +} --- gcc/testsuite/c-c++-common/gomp/declare-variant-2.c.jj 2020-01-12 11:54:37.000000000 +0100 +++ gcc/testsuite/c-c++-common/gomp/declare-variant-2.c 2022-10-27 15:52:58.946183471 +0200 @@ -149,7 +149,8 @@ void f72 (void); void f73 (void); #pragma omp declare variant (f1) match(construct={requires}) /* { dg-error "selector 'requires' not allowed for context selector set 'construct'" } */ void f74 (void); -#pragma omp declare variant (f1),match(construct={parallel}) /* { dg-error "expected 'match' before ','" } */ +void f75a (void); +#pragma omp declare variant (f75a),match(construct={parallel}) void f75 (void); #pragma omp declare variant (f1) match(implementation={atomic_default_mem_order("relaxed")}) /* { dg-error "expected identifier before string constant" } */ void f76 (void); --- gcc/testsuite/g++.dg/gomp/clause-4.C.jj 2020-01-11 16:31:54.707298413 +0100 +++ gcc/testsuite/g++.dg/gomp/clause-4.C 2022-10-27 15:53:50.878474339 +0200 @@ -14,7 +14,7 @@ foo (int x) ; #pragma omp p num_threads(4),if(1),private(x) ; -#pragma omp p, num_threads (4), if (1), private (x) // { dg-error "clause before" } +#pragma omp p, num_threads (4), if (1), private (x) ; #pragma omp p num_threads (4), if (1), private (x), // { dg-error "clause before" } ; --- gcc/testsuite/gcc.dg/gomp/clause-2.c.jj 2020-01-11 16:31:55.144291862 +0100 +++ gcc/testsuite/gcc.dg/gomp/clause-2.c 2022-10-27 15:51:11.451651283 +0200 @@ -14,7 +14,7 @@ foo (int x) ; #pragma omp p num_threads(4),if(1),private(x) ; -#pragma omp p, num_threads (4), if (1), private (x) /* { dg-error "clause before" } */ +#pragma omp p, num_threads (4), if (1), private (x) ; #pragma omp p num_threads (4), if (1), private (x), /* { dg-error "clause before" } */ ;