From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1534) id 27151385701F; Fri, 28 Oct 2022 11:18:19 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 27151385701F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1666955899; bh=Up1Yho0sWCuX3nrAHkO8tMhwyN1obUqZDjammTfQHkg=; h=From:To:Subject:Date:From; b=ESdojDigFPrJD5z9DvMQev9na9im5mIrd6IFvqIpVGsCVcfjmGAOHMHVcqEt+KYv7 5LpE9l7pWGLfxqsVPuCOZLPBo6thrF34FEiugjxTFurSb0WixVszkEniiFZBJW6dYL bQ+guWBdDyV6rdT+TcKGI/jcPv3AHGxhL1RpCo8Y= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Tobias Burnus To: gcc-cvs@gcc.gnu.org Subject: [gcc/devel/omp/gcc-12] openmp: Allow optional comma after directive-specifier in C/C++ X-Act-Checkin: gcc X-Git-Author: Jakub Jelinek X-Git-Refname: refs/heads/devel/omp/gcc-12 X-Git-Oldrev: 33eae55cd9effd9e0bb0c3659cc5dfc100b6fd4e X-Git-Newrev: 6f8e1b6eb1e4c2f5d76086a66f86c9f6b54ae913 Message-Id: <20221028111819.27151385701F@sourceware.org> Date: Fri, 28 Oct 2022 11:18:19 +0000 (GMT) List-Id: https://gcc.gnu.org/g:6f8e1b6eb1e4c2f5d76086a66f86c9f6b54ae913 commit 6f8e1b6eb1e4c2f5d76086a66f86c9f6b54ae913 Author: Jakub Jelinek Date: Fri Oct 28 11:03:56 2022 +0200 openmp: Allow optional comma after directive-specifier in C/C++ 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. 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. (cherry picked from commit 89999f2358724fa4e71c7c3b4de340582c0e43da) Diff: --- gcc/c/ChangeLog.omp | 14 + gcc/c/c-parser.cc | 64 ++- gcc/cp/ChangeLog.omp | 14 + gcc/cp/parser.cc | 73 +-- gcc/testsuite/ChangeLog.omp | 13 + gcc/testsuite/c-c++-common/gomp/clauses-6.c | 604 +++++++++++++++++++++ .../c-c++-common/gomp/declare-variant-2.c | 3 +- gcc/testsuite/c-c++-common/gomp/directive-1.c | 28 + gcc/testsuite/g++.dg/gomp/clause-4.C | 2 +- gcc/testsuite/gcc.dg/gomp/clause-2.c | 2 +- 10 files changed, 728 insertions(+), 89 deletions(-) diff --git a/gcc/c/ChangeLog.omp b/gcc/c/ChangeLog.omp index 1deeb6bb5b3..501314b86df 100644 --- a/gcc/c/ChangeLog.omp +++ b/gcc/c/ChangeLog.omp @@ -1,3 +1,17 @@ +2022-10-28 Tobias Burnus + + Backport from mainline: + 2022-10-28 Jakub Jelinek + + * 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. + 2022-10-27 Marcel Vollweiler * c-typeck.cc (c_finish_omp_clauses): Remove "gang reduction on an diff --git a/gcc/c/c-parser.cc b/gcc/c/c-parser.cc index 9258ce57401..f810f0ef5b3 100644 --- a/gcc/c/c-parser.cc +++ b/gcc/c/c-parser.cc @@ -17314,7 +17314,7 @@ c_parser_omp_all_clauses (c_parser *parser, omp_clause_mask mask, 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); @@ -18409,6 +18409,9 @@ c_parser_omp_allocate (location_t loc, c_parser *parser) { 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; @@ -18547,7 +18550,6 @@ c_parser_omp_atomic (location_t loc, c_parser *parser, bool openacc) bool structured_block = false; bool swapped = false; bool non_lvalue_p; - bool first = true; tree clauses = NULL_TREE; bool capture = false; bool compare = false; @@ -18558,13 +18560,10 @@ c_parser_omp_atomic (location_t loc, c_parser *parser, bool openacc) 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 @@ -19509,6 +19508,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)) { @@ -19585,6 +19586,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 @@ -19677,6 +19681,9 @@ c_parser_omp_scan_loop_body (c_parser *parser, bool open_brace_parsed) 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 @@ -20461,9 +20468,14 @@ c_parser_omp_ordered (c_parser *parser, enum pragma_context context, 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)) { @@ -22370,6 +22382,10 @@ c_finish_omp_declare_variant (c_parser *parser, tree fndecl, tree parms) 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)) @@ -22539,7 +22555,9 @@ c_parser_omp_declare_target (c_parser *parser) 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)) @@ -22960,10 +22978,14 @@ c_parser_omp_declare_reduction (c_parser *parser, enum pragma_context context) 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 (); @@ -23156,7 +23178,6 @@ c_parser_omp_declare (c_parser *parser, enum pragma_context context) 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); @@ -23164,13 +23185,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 @@ -23459,7 +23477,6 @@ c_parser_omp_error (c_parser *parser, enum pragma_context context) 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; @@ -23467,13 +23484,10 @@ c_parser_omp_error (c_parser *parser, enum pragma_context context) 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; @@ -23992,7 +24006,6 @@ error: 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; @@ -24008,13 +24021,10 @@ c_parser_omp_assumption_clauses (c_parser *parser, bool is_assume) 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; diff --git a/gcc/cp/ChangeLog.omp b/gcc/cp/ChangeLog.omp index 7c1fde00075..1899bde8c88 100644 --- a/gcc/cp/ChangeLog.omp +++ b/gcc/cp/ChangeLog.omp @@ -1,3 +1,17 @@ +2022-10-28 Tobias Burnus + + Backport from mainline: + 2022-10-28 Jakub Jelinek + + * 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. + 2022-10-27 Marcel Vollweiler * semantics.cc (finish_omp_clauses): Remove "gang reduction on an orphan diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc index 06f089a2167..974bd43536c 100644 --- a/gcc/cp/parser.cc +++ b/gcc/cp/parser.cc @@ -40513,12 +40513,7 @@ cp_parser_omp_all_clauses (cp_parser *parser, omp_clause_mask mask, 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); @@ -40955,9 +40950,7 @@ cp_parser_omp_allocate (cp_parser *parser, cp_token *pragma_tok) 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); @@ -41078,7 +41071,6 @@ cp_parser_omp_atomic (cp_parser *parser, cp_token *pragma_tok, bool openacc) 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; @@ -41089,14 +41081,10 @@ cp_parser_omp_atomic (cp_parser *parser, cp_token *pragma_tok, bool openacc) 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; @@ -42050,11 +42038,9 @@ cp_parser_omp_depobj (cp_parser *parser, cp_token *pragma_tok) 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; @@ -42137,9 +42123,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)) @@ -42864,8 +42848,7 @@ cp_parser_omp_scan_loop_body (cp_parser *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)) @@ -43667,9 +43650,7 @@ cp_parser_omp_ordered (cp_parser *parser, cp_token *pragma_tok, 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)) @@ -46060,7 +46041,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; @@ -46076,14 +46056,10 @@ cp_parser_omp_assumption_clauses (cp_parser *parser, cp_token *pragma_tok, 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; @@ -46322,9 +46298,7 @@ cp_finish_omp_declare_variant (cp_parser *parser, cp_token *pragma_tok, 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); @@ -46400,11 +46374,6 @@ cp_parser_late_parsing_omp_declare_simd (cp_parser *parser, tree attrs) 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); @@ -46662,9 +46631,7 @@ cp_parser_omp_declare_target (cp_parser *parser, cp_token *pragma_tok) 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, @@ -47285,9 +47252,7 @@ cp_parser_omp_declare_reduction_exprs (tree fndecl, cp_parser *parser) 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); @@ -47719,20 +47684,15 @@ cp_parser_omp_declare (cp_parser *parser, cp_token *pragma_tok, 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; @@ -47904,20 +47864,15 @@ cp_parser_omp_error (cp_parser *parser, cp_token *pragma_tok, 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; diff --git a/gcc/testsuite/ChangeLog.omp b/gcc/testsuite/ChangeLog.omp index 0c60381e24c..ef76bf2bbb3 100644 --- a/gcc/testsuite/ChangeLog.omp +++ b/gcc/testsuite/ChangeLog.omp @@ -1,3 +1,16 @@ +2022-10-28 Tobias Burnus + + Backport from mainline: + 2022-10-28 Jakub Jelinek + + * 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. + 2022-10-28 Thomas Schwinge Backported from master: diff --git a/gcc/testsuite/c-c++-common/gomp/clauses-6.c b/gcc/testsuite/c-c++-common/gomp/clauses-6.c new file mode 100644 index 00000000000..3502647ffb4 --- /dev/null +++ b/gcc/testsuite/c-c++-common/gomp/clauses-6.c @@ -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; +} diff --git a/gcc/testsuite/c-c++-common/gomp/declare-variant-2.c b/gcc/testsuite/c-c++-common/gomp/declare-variant-2.c index 5554059bd60..3c2c12c9e03 100644 --- a/gcc/testsuite/c-c++-common/gomp/declare-variant-2.c +++ b/gcc/testsuite/c-c++-common/gomp/declare-variant-2.c @@ -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); diff --git a/gcc/testsuite/c-c++-common/gomp/directive-1.c b/gcc/testsuite/c-c++-common/gomp/directive-1.c new file mode 100644 index 00000000000..e1218bd6869 --- /dev/null +++ b/gcc/testsuite/c-c++-common/gomp/directive-1.c @@ -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" } */ +} diff --git a/gcc/testsuite/g++.dg/gomp/clause-4.C b/gcc/testsuite/g++.dg/gomp/clause-4.C index 06b91e8a28d..db191e2b689 100644 --- a/gcc/testsuite/g++.dg/gomp/clause-4.C +++ b/gcc/testsuite/g++.dg/gomp/clause-4.C @@ -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" } ; diff --git a/gcc/testsuite/gcc.dg/gomp/clause-2.c b/gcc/testsuite/gcc.dg/gomp/clause-2.c index 4b12fc8f0c0..4d37c41cc9f 100644 --- a/gcc/testsuite/gcc.dg/gomp/clause-2.c +++ b/gcc/testsuite/gcc.dg/gomp/clause-2.c @@ -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" } */ ;