Skip to content

Commit e6321d9

Browse files
[Flang][Semantics] Add a semantic check for simd construct (#109089)
Add missing semantic check for the SAFELEN clause in the SIMD Order construct
1 parent b340310 commit e6321d9

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

flang/lib/Semantics/check-omp-structure.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2285,6 +2285,21 @@ void OmpStructureChecker::Leave(const parser::OmpClauseList &) {
22852285
}
22862286
}
22872287
}
2288+
2289+
// 2.11.5 Simd construct restriction (OpenMP 5.1)
2290+
if (auto *sl_clause{FindClause(llvm::omp::Clause::OMPC_safelen)}) {
2291+
if (auto *o_clause{FindClause(llvm::omp::Clause::OMPC_order)}) {
2292+
const auto &orderClause{
2293+
std::get<parser::OmpClause::Order>(o_clause->u)};
2294+
if (std::get<parser::OmpOrderClause::Type>(orderClause.v.t) ==
2295+
parser::OmpOrderClause::Type::Concurrent) {
2296+
context_.Say(sl_clause->source,
2297+
"The `SAFELEN` clause cannot appear in the `SIMD` directive "
2298+
"with `ORDER(CONCURRENT)` clause"_err_en_US);
2299+
}
2300+
}
2301+
}
2302+
22882303
// Sema checks related to presence of multiple list items within the same
22892304
// clause
22902305
CheckMultListItems();

flang/test/Semantics/OpenMP/clause-validity01.f90

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,12 @@
390390
enddo
391391
!$omp end parallel
392392

393+
!ERROR: The `SAFELEN` clause cannot appear in the `SIMD` directive with `ORDER(CONCURRENT)` clause
394+
!$omp simd order(concurrent) safelen(1+2)
395+
do i = 1, N
396+
a = 3.14
397+
enddo
398+
393399
! 2.11.1 parallel-do-clause -> parallel-clause |
394400
! do-clause
395401

0 commit comments

Comments
 (0)