Skip to content

Commit 33b061f

Browse files
authored
[flang] Enforce C955 on DEALLOCATE (#129788)
Constraint C955 in F'2023 prohibits an allocate-object from being coindexed. We catch this on ALLOCATE statements but missed it on DEALLOCATE.
1 parent 6b5b082 commit 33b061f

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

flang/lib/Semantics/check-deallocate.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,9 @@ void DeallocateChecker::Leave(const parser::DeallocateStmt &deallocateStmt) {
8989
"Object in DEALLOCATE statement is not deallocatable"_err_en_US)
9090
.Attach(std::move(
9191
whyNot->set_severity(parser::Severity::Because)));
92+
} else if (evaluate::ExtractCoarrayRef(*expr)) { // F'2023 C955
93+
context_.Say(source,
94+
"Component in DEALLOCATE statement may not be coindexed"_err_en_US);
9295
}
9396
}
9497
},

flang/test/Semantics/deallocate05.f90

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ Program deallocatetest
2727
Character(256) :: ee
2828
Procedure(Real) :: prp
2929

30+
type at
31+
real, allocatable :: a
32+
end type
33+
type(at) :: c[*]
34+
3035
Allocate(rp)
3136
Deallocate(rp)
3237

@@ -67,4 +72,7 @@ Program deallocatetest
6772
!ERROR: ERRMSG may not be duplicated in a DEALLOCATE statement
6873
Deallocate(x, stat=s, errmsg=ee, errmsg=ee)
6974

75+
!ERROR: Component in DEALLOCATE statement may not be coindexed
76+
deallocate(c[1]%a)
77+
7078
End Program deallocatetest

0 commit comments

Comments
 (0)