[flang-commits] [flang] [flang][OpenMP][Semantics] Modify a semantic check which was tightly checking list items in IS_DEVICE_PTR to be only dummy arguments. (PR #74370)

via flang-commits flang-commits at lists.llvm.org
Mon Dec 4 13:11:34 PST 2023


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-flang-semantics

@llvm/pr-subscribers-flang-openmp

Author: Raghu Maddhipatla (raghavendhra)

<details>
<summary>Changes</summary>

Modifying https://github.com/llvm/llvm-project/pull/71255

Changed semantic check to only check for, "Variable in IS_DEVICE_PTR clause must be a dummy argument that does not have the ALLOCATABLE, POINTER or VALUE attribute." Earlier there was an additional semantic check "Variable in IS_DEVICE_PTR clause must be a dummy argument" which might be incorrect.

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


2 Files Affected:

- (modified) flang/lib/Semantics/check-omp-structure.cpp (+2-5) 
- (modified) flang/test/Semantics/OpenMP/target01.f90 (-1) 


``````````diff
diff --git a/flang/lib/Semantics/check-omp-structure.cpp b/flang/lib/Semantics/check-omp-structure.cpp
index 2f4eb9a854270..c2362d225130d 100644
--- a/flang/lib/Semantics/check-omp-structure.cpp
+++ b/flang/lib/Semantics/check-omp-structure.cpp
@@ -2994,11 +2994,8 @@ void OmpStructureChecker::Enter(const parser::OmpClause::IsDevicePtr &x) {
         context_.Say(itr->second->source,
             "Variable '%s' in IS_DEVICE_PTR clause must be of type C_PTR"_err_en_US,
             source.ToString());
-      } else if (!(IsDummy(*symbol))) {
-        context_.Say(itr->second->source,
-            "Variable '%s' in IS_DEVICE_PTR clause must be a dummy argument"_err_en_US,
-            source.ToString());
-      } else if (IsAllocatableOrPointer(*symbol) || IsValue(*symbol)) {
+      } else if (IsDummy(*symbol) &&
+          (IsAllocatableOrPointer(*symbol) || IsValue(*symbol))) {
         context_.Say(itr->second->source,
             "Variable '%s' in IS_DEVICE_PTR clause must be a dummy argument that does not have the ALLOCATABLE, POINTER or VALUE attribute."_err_en_US,
             source.ToString());
diff --git a/flang/test/Semantics/OpenMP/target01.f90 b/flang/test/Semantics/OpenMP/target01.f90
index 485fa1f2530c3..2ce9a1af7cc80 100644
--- a/flang/test/Semantics/OpenMP/target01.f90
+++ b/flang/test/Semantics/OpenMP/target01.f90
@@ -39,7 +39,6 @@ subroutine bar(b1, b2, b3)
   type(c_ptr), pointer :: b2
   type(c_ptr), value :: b3
 
-  !ERROR: Variable 'c' in IS_DEVICE_PTR clause must be a dummy argument
   !$omp target is_device_ptr(c)
     y = y + 1
   !$omp end target

``````````

</details>


https://github.com/llvm/llvm-project/pull/74370


More information about the flang-commits mailing list