[flang] Catch ASSOCIATE(x=>assumed_rank) (#100626)

An assumed-rank dummy argument cannot be the variable or expression in
the selector of an ASSOCIATE construct. (SELECT TYPE/RANK are fine.)
This commit is contained in:
Peter Klausler 2024-07-30 09:44:09 -07:00 committed by GitHub
parent fffbabfd47
commit ed5a78a13f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 12 additions and 1 deletions

View File

@ -7121,9 +7121,13 @@ void ConstructVisitor::Post(const parser::AssociateStmt &x) {
for (auto nthLastAssoc{assocCount}; nthLastAssoc > 0; --nthLastAssoc) {
SetCurrentAssociation(nthLastAssoc);
if (auto *symbol{MakeAssocEntity()}) {
if (ExtractCoarrayRef(GetCurrentAssociation().selector.expr)) { // C1103
const MaybeExpr &expr{GetCurrentAssociation().selector.expr};
if (ExtractCoarrayRef(expr)) { // C1103
Say("Selector must not be a coindexed object"_err_en_US);
}
if (evaluate::IsAssumedRank(expr)) {
Say("Selector must not be assumed-rank"_err_en_US);
}
SetTypeFromAssociation(*symbol);
SetAttrsFromAssociation(*symbol);
}

View File

@ -0,0 +1,7 @@
! RUN: %python %S/test_errors.py %s %flang_fc1
subroutine bad(a)
real :: a(..)
!ERROR: Selector must not be assumed-rank
associate(x => a)
end associate
end subroutine