Skip to content

[flang][OpenMP] Deprecation message for DESTROY with no argument #114988

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 5, 2024

Conversation

kparzysz
Copy link
Contributor

@kparzysz kparzysz commented Nov 5, 2024

[5.2:625:17] The syntax of the DESTROY clause on the DEPOBJ construct with no argument was deprecated.

@llvmbot llvmbot added flang Flang issues not falling into any other category flang:openmp flang:semantics labels Nov 5, 2024
@llvmbot
Copy link
Member

llvmbot commented Nov 5, 2024

@llvm/pr-subscribers-flang-semantics

Author: Krzysztof Parzyszek (kparzysz)

Changes

[5.2:625:17] The syntax of the DESTROY clause on the DEPOBJ construct with no argument was deprecated.


Full diff: https://github.com/llvm/llvm-project/pull/114988.diff

3 Files Affected:

  • (modified) flang/lib/Semantics/check-omp-structure.cpp (+15-5)
  • (modified) flang/test/Semantics/OpenMP/depobj-construct-v50.f90 (+1-1)
  • (modified) flang/test/Semantics/OpenMP/depobj-construct-v52.f90 (+6)
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

@llvmbot
Copy link
Member

llvmbot commented Nov 5, 2024

@llvm/pr-subscribers-flang-openmp

Author: Krzysztof Parzyszek (kparzysz)

Changes

[5.2:625:17] The syntax of the DESTROY clause on the DEPOBJ construct with no argument was deprecated.


Full diff: https://github.com/llvm/llvm-project/pull/114988.diff

3 Files Affected:

  • (modified) flang/lib/Semantics/check-omp-structure.cpp (+15-5)
  • (modified) flang/test/Semantics/OpenMP/depobj-construct-v50.f90 (+1-1)
  • (modified) flang/test/Semantics/OpenMP/depobj-construct-v52.f90 (+6)
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

[5.2:625:17] The syntax of the DESTROY clause on the DEPOBJ construct
with no argument was deprecated.
@kparzysz kparzysz force-pushed the users/kparzysz/depobp-destroy branch from 0eabb24 to 4aba4bf Compare November 5, 2024 13:57
Copy link
Contributor

@kiranchandramohan kiranchandramohan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LG. Nit comment inline.

Comment on lines 2655 to 2664
"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));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Consider putting on the same line if clang-format is OK to easily search error messages.

@kparzysz kparzysz merged commit 5f8b83e into llvm:main Nov 5, 2024
8 checks passed
@kparzysz kparzysz deleted the users/kparzysz/depobp-destroy branch November 5, 2024 18:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
flang:openmp flang:semantics flang Flang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants