[flang-commits] [flang] [flang][OpenMP] Deprecation message for DESTROY with no argument (PR #114988)

Krzysztof Parzyszek via flang-commits flang-commits at lists.llvm.org
Tue Nov 5 07:30:29 PST 2024


https://github.com/kparzysz updated https://github.com/llvm/llvm-project/pull/114988

>From 4aba4bfd24b254b2e4ab3a17b753e2963c54089a Mon Sep 17 00:00:00 2001
From: Krzysztof Parzyszek <Krzysztof.Parzyszek at amd.com>
Date: Tue, 5 Nov 2024 07:48:02 -0600
Subject: [PATCH 1/2] [flang][OpenMP] Deprecation message for DESTROY with no
 argument

[5.2:625:17] The syntax of the DESTROY clause on the DEPOBJ construct
with no argument was deprecated.
---
 flang/lib/Semantics/check-omp-structure.cpp   | 20 ++++++++++++++-----
 .../Semantics/OpenMP/depobj-construct-v50.f90 |  2 +-
 .../Semantics/OpenMP/depobj-construct-v52.f90 |  6 ++++++
 3 files changed, 22 insertions(+), 6 deletions(-)

diff --git a/flang/lib/Semantics/check-omp-structure.cpp b/flang/lib/Semantics/check-omp-structure.cpp
index 749d5887eaac07..e3fa3ea2b49a34 100644
--- a/flang/lib/Semantics/check-omp-structure.cpp
+++ b/flang/lib/Semantics/check-omp-structure.cpp
@@ -2648,11 +2648,21 @@ void OmpStructureChecker::Enter(const parser::OmpClause::Destroy &x) {
   llvm::omp::Directive dir{GetContext().directive};
   unsigned version{context_.langOptions().OpenMPVersion};
   if (dir == llvm::omp::Directive::OMPD_depobj) {
-    if (version < 52) {
-      context_.Say(GetContext().clauseSource,
-          "The object parameter in DESTROY clause in DEPOPJ construct "
-          "was introduced in %s"_port_en_US,
-          ThisVersion(52));
+    unsigned argSince{52}, noargDeprecatedIn{52};
+    if (x.v) {
+      if (version < argSince) {
+        context_.Say(GetContext().clauseSource,
+            "The object parameter in DESTROY clause on DEPOPJ construct "
+            "is not allowed in %s, %s"_warn_en_US,
+            ThisVersion(version), TryVersion(argSince));
+      }
+    } else {
+      if (version >= noargDeprecatedIn) {
+        context_.Say(GetContext().clauseSource,
+            "The DESTROY clause without argument on DEPOBJ construct "
+            "is deprecated in %s"_warn_en_US,
+            ThisVersion(noargDeprecatedIn));
+      }
     }
   }
 }
diff --git a/flang/test/Semantics/OpenMP/depobj-construct-v50.f90 b/flang/test/Semantics/OpenMP/depobj-construct-v50.f90
index e7fa24d521b63b..e87d86ca54bee7 100644
--- a/flang/test/Semantics/OpenMP/depobj-construct-v50.f90
+++ b/flang/test/Semantics/OpenMP/depobj-construct-v50.f90
@@ -23,6 +23,6 @@ subroutine f02
 subroutine f03
   integer :: obj, jbo
 !ERROR: The DESTROY clause must refer to the same object as the DEPOBJ construct
-!PORTABILITY: The object parameter in DESTROY clause in DEPOPJ construct was introduced in OpenMP v5.2
+!WARNING: The object parameter in DESTROY clause on DEPOPJ construct is not allowed in OpenMP v5.0, try -fopenmp-version=52
   !$omp depobj(obj) destroy(jbo)
 end
diff --git a/flang/test/Semantics/OpenMP/depobj-construct-v52.f90 b/flang/test/Semantics/OpenMP/depobj-construct-v52.f90
index f2e66485c6c801..6b695a30128ae9 100644
--- a/flang/test/Semantics/OpenMP/depobj-construct-v52.f90
+++ b/flang/test/Semantics/OpenMP/depobj-construct-v52.f90
@@ -13,3 +13,9 @@ subroutine f03
 !ERROR: The DESTROY clause must refer to the same object as the DEPOBJ construct
   !$omp depobj(obj) destroy(jbo)
 end
+
+subroutine f06
+  integer :: obj
+!WARNING: The DESTROY clause without argument on DEPOBJ construct is deprecated in OpenMP v5.2
+  !$omp depobj(obj) destroy
+end

>From 611e806230b7c99fd4eb7d6536231417a71ef7c0 Mon Sep 17 00:00:00 2001
From: Krzysztof Parzyszek <Krzysztof.Parzyszek at amd.com>
Date: Tue, 5 Nov 2024 09:29:49 -0600
Subject: [PATCH 2/2] keep message texts in a single line

---
 flang/lib/Semantics/check-omp-structure.cpp | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/flang/lib/Semantics/check-omp-structure.cpp b/flang/lib/Semantics/check-omp-structure.cpp
index e3fa3ea2b49a34..34fee2f7dc6b19 100644
--- a/flang/lib/Semantics/check-omp-structure.cpp
+++ b/flang/lib/Semantics/check-omp-structure.cpp
@@ -2652,15 +2652,13 @@ void OmpStructureChecker::Enter(const parser::OmpClause::Destroy &x) {
     if (x.v) {
       if (version < argSince) {
         context_.Say(GetContext().clauseSource,
-            "The object parameter in DESTROY clause on DEPOPJ construct "
-            "is not allowed in %s, %s"_warn_en_US,
+            "The object parameter in DESTROY clause on DEPOPJ construct is not allowed in %s, %s"_warn_en_US,
             ThisVersion(version), TryVersion(argSince));
       }
     } else {
       if (version >= noargDeprecatedIn) {
         context_.Say(GetContext().clauseSource,
-            "The DESTROY clause without argument on DEPOBJ construct "
-            "is deprecated in %s"_warn_en_US,
+            "The DESTROY clause without argument on DEPOBJ construct is deprecated in %s"_warn_en_US,
             ThisVersion(noargDeprecatedIn));
       }
     }



More information about the flang-commits mailing list