[flang-commits] [flang] [flang][OpenMP] Diagnose invalid reduction modifiers (PR #92406)
Kiran Chandramohan via flang-commits
flang-commits at lists.llvm.org
Sat May 18 06:50:02 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,
----------------
kiranchandramohan wrote:
Is loop allowed?
https://github.com/llvm/llvm-project/pull/92406
More information about the flang-commits
mailing list