[flang-commits] [flang] e6321d9 - [Flang][Semantics] Add a semantic check for simd construct (#109089)
via flang-commits
flang-commits at lists.llvm.org
Thu Oct 17 21:43:51 PDT 2024
Author: Thirumalai Shaktivel
Date: 2024-10-18T10:13:49+05:30
New Revision: e6321d94dee1c7f611bc08dacd3a851e3299fc16
URL: https://github.com/llvm/llvm-project/commit/e6321d94dee1c7f611bc08dacd3a851e3299fc16
DIFF: https://github.com/llvm/llvm-project/commit/e6321d94dee1c7f611bc08dacd3a851e3299fc16.diff
LOG: [Flang][Semantics] Add a semantic check for simd construct (#109089)
Add missing semantic check for the SAFELEN clause in the SIMD Order
construct
Added:
Modified:
flang/lib/Semantics/check-omp-structure.cpp
flang/test/Semantics/OpenMP/clause-validity01.f90
Removed:
################################################################################
diff --git a/flang/lib/Semantics/check-omp-structure.cpp b/flang/lib/Semantics/check-omp-structure.cpp
index 3db252e5fc8ef3..473ed2be3dbca7 100644
--- a/flang/lib/Semantics/check-omp-structure.cpp
+++ b/flang/lib/Semantics/check-omp-structure.cpp
@@ -2285,6 +2285,21 @@ void OmpStructureChecker::Leave(const parser::OmpClauseList &) {
}
}
}
+
+ // 2.11.5 Simd construct restriction (OpenMP 5.1)
+ if (auto *sl_clause{FindClause(llvm::omp::Clause::OMPC_safelen)}) {
+ if (auto *o_clause{FindClause(llvm::omp::Clause::OMPC_order)}) {
+ const auto &orderClause{
+ std::get<parser::OmpClause::Order>(o_clause->u)};
+ if (std::get<parser::OmpOrderClause::Type>(orderClause.v.t) ==
+ parser::OmpOrderClause::Type::Concurrent) {
+ context_.Say(sl_clause->source,
+ "The `SAFELEN` clause cannot appear in the `SIMD` directive "
+ "with `ORDER(CONCURRENT)` clause"_err_en_US);
+ }
+ }
+ }
+
// Sema checks related to presence of multiple list items within the same
// clause
CheckMultListItems();
diff --git a/flang/test/Semantics/OpenMP/clause-validity01.f90 b/flang/test/Semantics/OpenMP/clause-validity01.f90
index 24540492e73271..1a7a57b124e9bd 100644
--- a/flang/test/Semantics/OpenMP/clause-validity01.f90
+++ b/flang/test/Semantics/OpenMP/clause-validity01.f90
@@ -390,6 +390,12 @@
enddo
!$omp end parallel
+ !ERROR: The `SAFELEN` clause cannot appear in the `SIMD` directive with `ORDER(CONCURRENT)` clause
+ !$omp simd order(concurrent) safelen(1+2)
+ do i = 1, N
+ a = 3.14
+ enddo
+
! 2.11.1 parallel-do-clause -> parallel-clause |
! do-clause
More information about the flang-commits
mailing list