Skip to content

Commit

Permalink
Apply review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
kparzysz committed May 20, 2024
1 parent 903ffaf commit 7eb0ef2
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions flang/lib/Semantics/check-omp-structure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2404,16 +2404,24 @@ void OmpStructureChecker::CheckReductionModifier(
}
ReductionModifier modifier{*maybeModifier};
const DirectiveContext &dirCtx{GetContext()};
if (dirCtx.directive == llvm::omp::Directive::OMPD_loop) {
// [5.2:257:33-34]
// If a reduction-modifier is specified in a reduction clause that
// appears on the directive, then the reduction modifier must be
// default.
context_.Say(GetContext().clauseSource,
"REDUCTION modifier on LOOP directive must be DEFAULT"_err_en_US);
}
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,
llvm::omp::Directive::OMPD_scope,
llvm::omp::Directive::OMPD_sections,
llvm::omp::Directive::OMPD_single,
llvm::omp::Directive::OMPD_workshare,
// "single" and "workshare" are worksharing directives, but
// they don't allow reduction clause.
// "loop" is also worksharing, but has different restrictions.
};
if (dirCtx.directive != llvm::omp::Directive::OMPD_parallel &&
!llvm::is_contained(worksharing, dirCtx.directive)) {
Expand All @@ -2439,7 +2447,7 @@ void OmpStructureChecker::CheckReductionModifier(
}
} else {
// Catch-all for potential future modifiers to make sure that this
// function is up-tp-date.
// function is up-to-date.
context_.Say(GetContext().clauseSource,
"Unexpected modifier on REDUCTION clause"_err_en_US);
}
Expand Down

0 comments on commit 7eb0ef2

Please sign in to comment.