[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.
This commit is contained in:
Peter Klausler 2025-03-10 13:17:12 -07:00 committed by GitHub
parent 6b5b0821e3
commit 33b061f8ea
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 11 additions and 0 deletions

View File

@ -89,6 +89,9 @@ void DeallocateChecker::Leave(const parser::DeallocateStmt &deallocateStmt) {
"Object in DEALLOCATE statement is not deallocatable"_err_en_US)
.Attach(std::move(
whyNot->set_severity(parser::Severity::Because)));
} else if (evaluate::ExtractCoarrayRef(*expr)) { // F'2023 C955
context_.Say(source,
"Component in DEALLOCATE statement may not be coindexed"_err_en_US);
}
}
},

View File

@ -27,6 +27,11 @@ Integer :: pi
Character(256) :: ee
Procedure(Real) :: prp
type at
real, allocatable :: a
end type
type(at) :: c[*]
Allocate(rp)
Deallocate(rp)
@ -67,4 +72,7 @@ Deallocate(x, stat=s, errmsg=ee, stat=s)
!ERROR: ERRMSG may not be duplicated in a DEALLOCATE statement
Deallocate(x, stat=s, errmsg=ee, errmsg=ee)
!ERROR: Component in DEALLOCATE statement may not be coindexed
deallocate(c[1]%a)
End Program deallocatetest