diff --git a/flang/lib/Evaluate/tools.cpp b/flang/lib/Evaluate/tools.cpp --- a/flang/lib/Evaluate/tools.cpp +++ b/flang/lib/Evaluate/tools.cpp @@ -1166,7 +1166,7 @@ // 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 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 --- 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