diff --git a/flang/include/flang/Parser/dump-parse-tree.h b/flang/include/flang/Parser/dump-parse-tree.h --- a/flang/include/flang/Parser/dump-parse-tree.h +++ b/flang/include/flang/Parser/dump-parse-tree.h @@ -514,6 +514,7 @@ NODE(parser, OmpProcBindClause) NODE_ENUM(OmpProcBindClause, Type) NODE(parser, OmpReductionClause) + NODE(parser, OmpInReductionClause) NODE(parser, OmpReductionCombiner) NODE(OmpReductionCombiner, FunctionCombiner) NODE(parser, OmpReductionInitializerClause) 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 @@ -3433,6 +3433,13 @@ std::tuple t; }; +// OMP 5.0 2.19.5.6 in-reduction-clause -> IN_REDUCTION (reduction-identifier: +// variable-name-list) +struct OmpInReductionClause { + TUPLE_CLASS_BOILERPLATE(OmpInReductionClause); + std::tuple t; +}; + // OMP 5.0 2.11.4 allocate-clause -> ALLOCATE ([allocator:] variable-name-list) struct OmpAllocateClause { TUPLE_CLASS_BOILERPLATE(OmpAllocateClause); 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 @@ -104,6 +104,10 @@ TYPE_PARSER(construct( Parser{} / ":", Parser{})) +// OMP 5.0 2.19.5.6 IN_REDUCTION (reduction-identifier: variable-name-list) +TYPE_PARSER(construct( + Parser{} / ":", Parser{})) + // OMP 5.0 2.11.4 ALLOCATE ([allocator:] variable-name-list) TYPE_PARSER(construct( maybe(construct(scalarIntExpr) / ":"), @@ -224,6 +228,8 @@ parenthesized(Parser{}))) || "REDUCTION" >> construct(construct( parenthesized(Parser{}))) || + "IN_REDUCTION" >> construct(construct( + parenthesized(Parser{}))) || "TASK_REDUCTION" >> construct(construct( parenthesized(Parser{}))) || 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 @@ -2025,6 +2025,11 @@ Put(":"); Walk(std::get(x.t)); } + void Unparse(const OmpInReductionClause &x) { + Walk(std::get(x.t)); + Put(":"); + Walk(std::get(x.t)); + } void Unparse(const OmpAllocateClause &x) { Walk(std::get>(x.t)); Put(":"); diff --git a/flang/test/Parser/omp-block-construct-unparse.f90 b/flang/test/Parser/omp-block-construct-unparse.f90 new file mode 100644 --- /dev/null +++ b/flang/test/Parser/omp-block-construct-unparse.f90 @@ -0,0 +1,11 @@ +! RUN: %flang_fc1 -fdebug-unparse-no-sema -fopenmp %s | FileCheck %s +! Checks the unparsing of different OpenMP block constructs + +program block_construct_unparsing + integer:: x, y + !TASK + !CHECK: !$OMP TASK IN_REDUCTION(+:x) + !CHECK: !$OMP END TASK + !$omp task in_reduction(+: x) + !$omp end task +end program block_construct_unparsing 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 @@ -61,7 +61,7 @@ enddo !$omp end parallel - !$omp task private(b) allocate(b) + !$omp task private(b) allocate(b) in_reduction(+:b) do i = 1, N z = 2 end do 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 @@ -264,6 +264,7 @@ } def OMPC_InReduction : Clause<"in_reduction"> { let clangClass = "OMPInReductionClause"; + let flangClass = "OmpInReductionClause"; } def OMPC_UnifiedAddress : Clause<"unified_address"> { let clangClass = "OMPUnifiedAddressClause";