[flang-commits] [flang] [Flang][Semantics] Add a semantic check for simd construct (PR #109089)
Thirumalai Shaktivel via flang-commits
flang-commits at lists.llvm.org
Mon Sep 30 01:34:07 PDT 2024
https://github.com/Thirumalai-Shaktivel updated https://github.com/llvm/llvm-project/pull/109089
>From 3fac39b271af4635c4f5cab8520a332a237776b5 Mon Sep 17 00:00:00 2001
From: Thirumalai-Shaktivel <thirumalaishaktivel at gmail.com>
Date: Mon, 30 Sep 2024 08:32:20 +0000
Subject: [PATCH 1/2] [Flang][Semantics] Add a semantic check for simd
construct,
Fix: Add a missing semantic check for the SAFELEN clause in the SIMD Order construct
---
flang/lib/Semantics/check-omp-structure.cpp | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/flang/lib/Semantics/check-omp-structure.cpp b/flang/lib/Semantics/check-omp-structure.cpp
index 643b713b32e29d..650ef3bc432cfd 100644
--- a/flang/lib/Semantics/check-omp-structure.cpp
+++ b/flang/lib/Semantics/check-omp-structure.cpp
@@ -2156,6 +2156,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();
>From 8d269ed7166e60a695a6c88d1164894078f8f4e9 Mon Sep 17 00:00:00 2001
From: Thirumalai-Shaktivel <thirumalaishaktivel at gmail.com>
Date: Mon, 30 Sep 2024 08:32:59 +0000
Subject: [PATCH 2/2] [Test] Add a test
---
flang/test/Semantics/OpenMP/clause-validity01.f90 | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/flang/test/Semantics/OpenMP/clause-validity01.f90 b/flang/test/Semantics/OpenMP/clause-validity01.f90
index 020d63f735596d..9344258b9c1522 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