[flang-commits] [flang] e838c06 - [Flang] Use the ultimate symbol in a DeallocateStmt check
Kiran Chandramohan via flang-commits
flang-commits at lists.llvm.org
Fri Oct 7 07:48:24 PDT 2022
Author: Kiran Chandramohan
Date: 2022-10-07T14:47:59Z
New Revision: e838c0658835ed08b153dbd672e5ba90f3eb6b4d
URL: https://github.com/llvm/llvm-project/commit/e838c0658835ed08b153dbd672e5ba90f3eb6b4d
DIFF: https://github.com/llvm/llvm-project/commit/e838c0658835ed08b153dbd672e5ba90f3eb6b4d.diff
LOG: [Flang] Use the ultimate symbol in a DeallocateStmt check
Use the ultimate symbol while calling the `IsAllocatableOrPointer`
function to ensure that the check works as expected for
host-associated symbols.
Fixes #58178
Reviewed By: PeteSteinfeld
Differential Revision: https://reviews.llvm.org/D135443
Added:
flang/test/Semantics/OpenMP/dealloc.f90
Modified:
flang/lib/Semantics/check-deallocate.cpp
Removed:
################################################################################
diff --git a/flang/lib/Semantics/check-deallocate.cpp b/flang/lib/Semantics/check-deallocate.cpp
index d26935d283397..0b21244b22cb1 100644
--- a/flang/lib/Semantics/check-deallocate.cpp
+++ b/flang/lib/Semantics/check-deallocate.cpp
@@ -26,7 +26,8 @@ void DeallocateChecker::Leave(const parser::DeallocateStmt &deallocateStmt) {
} 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
index 0000000000000..b25fa62377f68
--- /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
More information about the flang-commits
mailing list