[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:
parent
6b5b0821e3
commit
33b061f8ea
@ -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);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user