diff --git a/flang/include/flang/Parser/parse-tree.h b/flang/include/flang/Parser/parse-tree.h --- a/flang/include/flang/Parser/parse-tree.h +++ b/flang/include/flang/Parser/parse-tree.h @@ -3415,7 +3415,7 @@ // variable-name-list) struct OmpReductionClause { TUPLE_CLASS_BOILERPLATE(OmpReductionClause); - std::tuple> t; + std::tuple t; }; // OMP 5.0 2.11.4 allocate-clause -> ALLOCATE ([allocator:] variable-name-list) diff --git a/flang/lib/Parser/openmp-parsers.cpp b/flang/lib/Parser/openmp-parsers.cpp --- a/flang/lib/Parser/openmp-parsers.cpp +++ b/flang/lib/Parser/openmp-parsers.cpp @@ -102,7 +102,7 @@ construct(Parser{})) TYPE_PARSER(construct( - Parser{} / ":", nonemptyList(designator))) + Parser{} / ":", Parser{})) // OMP 5.0 2.11.4 ALLOCATE ([allocator:] variable-name-list) TYPE_PARSER(construct( @@ -220,6 +220,9 @@ parenthesized(Parser{}))) || "REDUCTION" >> construct(parenthesized(Parser{})) || + "TASK_REDUCTION" >> + construct(construct( + parenthesized(Parser{}))) || "RELAXED" >> construct(construct()) || "RELEASE" >> construct(construct()) || "SAFELEN" >> construct(construct( diff --git a/flang/lib/Parser/unparse.cpp b/flang/lib/Parser/unparse.cpp --- a/flang/lib/Parser/unparse.cpp +++ b/flang/lib/Parser/unparse.cpp @@ -2016,7 +2016,7 @@ Word("REDUCTION("); Walk(std::get(x.t)); Put(":"); - Walk(std::get>(x.t), ","); + Walk(std::get(x.t)); Put(")"); } void Unparse(const OmpAllocateClause &x) { diff --git a/flang/lib/Semantics/check-omp-structure.h b/flang/lib/Semantics/check-omp-structure.h --- a/flang/lib/Semantics/check-omp-structure.h +++ b/flang/lib/Semantics/check-omp-structure.h @@ -155,6 +155,7 @@ void Enter(const parser::OmpClause::Safelen &); void Enter(const parser::OmpClause::Shared &); void Enter(const parser::OmpClause::Simdlen &); + void Enter(const parser::OmpClause::TaskReduction &); void Enter(const parser::OmpClause::ThreadLimit &); void Enter(const parser::OmpClause::To &); void Enter(const parser::OmpClause::Link &); diff --git a/flang/lib/Semantics/check-omp-structure.cpp b/flang/lib/Semantics/check-omp-structure.cpp --- a/flang/lib/Semantics/check-omp-structure.cpp +++ b/flang/lib/Semantics/check-omp-structure.cpp @@ -419,6 +419,7 @@ CHECK_SIMPLE_CLAUSE(Nogroup, OMPC_nogroup) CHECK_SIMPLE_CLAUSE(Notinbranch, OMPC_notinbranch) CHECK_SIMPLE_CLAUSE(Nowait, OMPC_nowait) +CHECK_SIMPLE_CLAUSE(TaskReduction, OMPC_task_reduction) CHECK_SIMPLE_CLAUSE(To, OMPC_to) CHECK_SIMPLE_CLAUSE(Uniform, OMPC_uniform) CHECK_SIMPLE_CLAUSE(Untied, OMPC_untied) diff --git a/flang/test/Semantics/omp-clause-validity01.f90 b/flang/test/Semantics/omp-clause-validity01.f90 --- a/flang/test/Semantics/omp-clause-validity01.f90 +++ b/flang/test/Semantics/omp-clause-validity01.f90 @@ -349,7 +349,8 @@ ! collapse-clause a = 0.0 - !$omp simd private(b) reduction(+:a) + !ERROR: TASK_REDUCTION clause is not allowed on the SIMD directive + !$omp simd private(b) reduction(+:a) task_reduction(+:a) do i = 1, N a = a + b + 3.14 enddo @@ -449,7 +450,8 @@ enddo !ERROR: At most one NUM_TASKS clause can appear on the TASKLOOP directive - !$omp taskloop num_tasks(3) num_tasks(2) + !ERROR: TASK_REDUCTION clause is not allowed on the TASKLOOP directive + !$omp taskloop num_tasks(3) num_tasks(2) task_reduction(*:a) do i = 1,N a = 3.14 enddo diff --git a/llvm/include/llvm/Frontend/OpenMP/OMP.td b/llvm/include/llvm/Frontend/OpenMP/OMP.td --- a/llvm/include/llvm/Frontend/OpenMP/OMP.td +++ b/llvm/include/llvm/Frontend/OpenMP/OMP.td @@ -231,6 +231,7 @@ } def OMPC_TaskReduction : Clause<"task_reduction"> { let clangClass = "OMPTaskReductionClause"; + let flangClassValue = "OmpReductionClause"; } def OMPC_InReduction : Clause<"in_reduction"> { let clangClass = "OMPInReductionClause";