[flang-commits] [flang] 0c28080 - [flang][OpenMP] Perform checks on features from different versions (#229116)
via flang-commits
flang-commits at lists.llvm.org
Tue Oct 6 04:50:56 PDT 2026
Author: Krzysztof Parzyszek
Date: 2026-10-06T11:50:49Z
New Revision: 0c2808031a721945f3172e24daf09630558db28f
URL: https://github.com/llvm/llvm-project/commit/0c2808031a721945f3172e24daf09630558db28f
DIFF: https://github.com/llvm/llvm-project/commit/0c2808031a721945f3172e24daf09630558db28f.diff
LOG: [flang][OpenMP] Perform checks on features from different versions (#229116)
The check for DETACH and MERGEABLE used together was only done when the
OpenMP version was set to the versions that allow both clauses. The use
of these clauses is accepted with a warning in older versions as well,
so make sure to perform the checks for all versions.
Added:
flang/test/Semantics/OpenMP/task-45.f90
Modified:
flang/lib/Semantics/check-omp-structure.cpp
Removed:
################################################################################
diff --git a/flang/lib/Semantics/check-omp-structure.cpp b/flang/lib/Semantics/check-omp-structure.cpp
index c163005593df5..6193b297b62fb 100644
--- a/flang/lib/Semantics/check-omp-structure.cpp
+++ b/flang/lib/Semantics/check-omp-structure.cpp
@@ -3914,7 +3914,7 @@ void OmpStructureChecker::Leave(const parser::OmpClauseList &x) {
if (GetContext().directive == llvm::omp::Directive::OMPD_task) {
if (auto *detachClause{FindClause(llvm::omp::Clause::OMPC_detach)}) {
- if (version == 50 || version == 51) {
+ if (version < 52) {
// OpenMP 5.0: 2.10.1 Task construct restrictions
CheckNotAllowedIfClause(llvm::omp::Clause::OMPC_detach,
{llvm::omp::Clause::OMPC_mergeable});
diff --git a/flang/test/Semantics/OpenMP/task-45.f90 b/flang/test/Semantics/OpenMP/task-45.f90
new file mode 100644
index 0000000000000..64b7cf765f8d2
--- /dev/null
+++ b/flang/test/Semantics/OpenMP/task-45.f90
@@ -0,0 +1,14 @@
+! REQUIRES: openmp_runtime
+! RUN: %python %S/../test_errors.py %s %flang_fc1 %openmp_flags -fopenmp-version=45
+
+! Check that we still emit diagnostics for features from future versions
+! that are allowed under a warning.
+
+subroutine f
+ use omp_lib, only: omp_event_handle_kind
+ integer(kind=omp_event_handle_kind) :: e
+ !ERROR: Clause MERGEABLE is not allowed if clause DETACH appears on the TASK directive
+ !WARNING: DETACH clause is not allowed on TASK directive in OpenMP v4.5, try -fopenmp-version=50 [-Wopenmp-future]
+ !$omp task mergeable detach(e)
+ !$omp end task
+end
More information about the flang-commits
mailing list