diff --git a/flang/lib/Semantics/check-deallocate.cpp b/flang/lib/Semantics/check-deallocate.cpp --- a/flang/lib/Semantics/check-deallocate.cpp +++ b/flang/lib/Semantics/check-deallocate.cpp @@ -26,7 +26,8 @@ } else if (!IsVariableName(*symbol)) { context_.Say(name.source, "name in DEALLOCATE statement must be a variable name"_err_en_US); - } else if (!IsAllocatableOrPointer(*symbol)) { // C932 + } else if (!IsAllocatableOrPointer( + symbol->GetUltimate())) { // C932 context_.Say(name.source, "name in DEALLOCATE statement must have the ALLOCATABLE or POINTER attribute"_err_en_US); } else { diff --git a/flang/test/Semantics/OpenMP/dealloc.f90 b/flang/test/Semantics/OpenMP/dealloc.f90 new file mode 100644 --- /dev/null +++ b/flang/test/Semantics/OpenMP/dealloc.f90 @@ -0,0 +1,13 @@ +! RUN: %python %S/../test_errors.py %s %flang_fc1 -fopenmp + +! Test to check that no errors are present when allocate statements +! are applied on privatised variables. + +subroutine s + implicit none + double precision,allocatable,dimension(:) :: r + !$omp parallel private(r) + allocate(r(1)) + deallocate(r) + !$omp end parallel +end subroutine