Skip to content

Commit ed5a78a

Browse files
authored
[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.)
1 parent fffbabf commit ed5a78a

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

flang/lib/Semantics/resolve-names.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7121,9 +7121,13 @@ void ConstructVisitor::Post(const parser::AssociateStmt &x) {
71217121
for (auto nthLastAssoc{assocCount}; nthLastAssoc > 0; --nthLastAssoc) {
71227122
SetCurrentAssociation(nthLastAssoc);
71237123
if (auto *symbol{MakeAssocEntity()}) {
7124-
if (ExtractCoarrayRef(GetCurrentAssociation().selector.expr)) { // C1103
7124+
const MaybeExpr &expr{GetCurrentAssociation().selector.expr};
7125+
if (ExtractCoarrayRef(expr)) { // C1103
71257126
Say("Selector must not be a coindexed object"_err_en_US);
71267127
}
7128+
if (evaluate::IsAssumedRank(expr)) {
7129+
Say("Selector must not be assumed-rank"_err_en_US);
7130+
}
71277131
SetTypeFromAssociation(*symbol);
71287132
SetAttrsFromAssociation(*symbol);
71297133
}

flang/test/Semantics/associate04.f90

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
! RUN: %python %S/test_errors.py %s %flang_fc1
2+
subroutine bad(a)
3+
real :: a(..)
4+
!ERROR: Selector must not be assumed-rank
5+
associate(x => a)
6+
end associate
7+
end subroutine

0 commit comments

Comments
 (0)