[flang-commits] [flang] 09ef2da - [Flang][OpenMP] Use the ultimate symbol for allocatable check

Kiran Chandramohan via flang-commits flang-commits at lists.llvm.org
Tue Feb 21 07:26:33 PST 2023


Author: Kiran Chandramohan
Date: 2023-02-21T15:26:09Z
New Revision: 09ef2da6d0f460da70c37bec9107823faf480a84

URL: https://github.com/llvm/llvm-project/commit/09ef2da6d0f460da70c37bec9107823faf480a84
DIFF: https://github.com/llvm/llvm-project/commit/09ef2da6d0f460da70c37bec9107823faf480a84.diff

LOG: [Flang][OpenMP] Use the ultimate symbol for allocatable check

Reviewed By: peixin

Differential Revision: https://reviews.llvm.org/D144383

Added: 
    flang/test/Semantics/OpenMP/omp-private-is-pointer-allocatable-check.f90

Modified: 
    flang/lib/Evaluate/tools.cpp

Removed: 
    flang/test/Semantics/OpenMP/omp-private-is-pointer-check.f90


################################################################################
diff  --git a/flang/lib/Evaluate/tools.cpp b/flang/lib/Evaluate/tools.cpp
index a39493b60b678..e5bc9cd953fd0 100644
--- a/flang/lib/Evaluate/tools.cpp
+++ b/flang/lib/Evaluate/tools.cpp
@@ -1166,7 +1166,7 @@ bool IsAllocatableDesignator(const Expr<SomeType> &expr) {
   // Allocatable sub-objects are not themselves allocatable (9.5.3.1 NOTE 2).
   if (const semantics::Symbol *
       sym{UnwrapWholeSymbolOrComponentOrCoarrayRef(expr)}) {
-    return semantics::IsAllocatable(*sym);
+    return semantics::IsAllocatable(sym->GetUltimate());
   }
   return false;
 }

diff  --git a/flang/test/Semantics/OpenMP/omp-private-is-pointer-check.f90 b/flang/test/Semantics/OpenMP/omp-private-is-pointer-allocatable-check.f90
similarity index 51%
rename from flang/test/Semantics/OpenMP/omp-private-is-pointer-check.f90
rename to flang/test/Semantics/OpenMP/omp-private-is-pointer-allocatable-check.f90
index c2b7244e46485..7b3915d9a1104 100644
--- a/flang/test/Semantics/OpenMP/omp-private-is-pointer-check.f90
+++ b/flang/test/Semantics/OpenMP/omp-private-is-pointer-allocatable-check.f90
@@ -3,8 +3,16 @@
 subroutine s
   integer, pointer :: p
   integer, target :: t
+  real(4), allocatable :: arr
 
   !$omp parallel private(p)
     p=>t
   !$omp end parallel
+
+  allocate(arr)
+  !$omp parallel private(arr)
+  if (.not. allocated(arr)) then
+     print *, 'not allocated'
+  endif
+  !$omp end parallel
 end subroutine


        


More information about the flang-commits mailing list