[flang-commits] [flang] [flang][OpenMP] Diagnose invalid reduction modifiers (PR #92406)
Krzysztof Parzyszek via flang-commits
flang-commits at lists.llvm.org
Mon May 20 06:25:32 PDT 2024
================
@@ -2393,6 +2394,57 @@ void OmpStructureChecker::CheckReductionTypeList(
}
}
+void OmpStructureChecker::CheckReductionModifier(
+ const parser::OmpClause::Reduction &x) {
+ using ReductionModifier = parser::OmpReductionClause::ReductionModifier;
+ const auto &maybeModifier{std::get<std::optional<ReductionModifier>>(x.v.t)};
+ if (!maybeModifier || *maybeModifier == ReductionModifier::Default) {
+ // No modifier, or the default one is always ok.
+ return;
+ }
+ ReductionModifier modifier{*maybeModifier};
+ const DirectiveContext &dirCtx{GetContext()};
+ if (modifier == ReductionModifier::Task) {
+ // "Task" is only allowed on worksharing or "parallel" directive.
+ static llvm::omp::Directive worksharing[]{
+ llvm::omp::Directive::OMPD_do,
+ // llvm::omp::Directive::OMPD_for, C++ only
+ llvm::omp::Directive::OMPD_loop,
----------------
kparzysz wrote:
Added a separate check for "loop".
https://github.com/llvm/llvm-project/pull/92406
More information about the flang-commits
mailing list