Skip to content

Commit 286f451

Browse files
authored
[flang] Catch attempts to use assumed-rank as elemental argument (#159852)
An assumed-rank array may not be used as an argument to an elemental procedure. Fixes #159555.
1 parent e6da918 commit 286f451

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

flang/lib/Semantics/check-call.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1538,6 +1538,10 @@ static bool CheckElementalConformance(parser::ContextualMessages &messages,
15381538
evaluate::SayWithDeclaration(messages, *wholeSymbol,
15391539
"Whole assumed-size array '%s' may not be used as an argument to an elemental procedure"_err_en_US,
15401540
wholeSymbol->name());
1541+
} else if (IsAssumedRank(*wholeSymbol)) {
1542+
evaluate::SayWithDeclaration(messages, *wholeSymbol,
1543+
"Assumed-rank array '%s' may not be used as an argument to an elemental procedure"_err_en_US,
1544+
wholeSymbol->name());
15411545
}
15421546
}
15431547
if (auto argShape{evaluate::GetShape(context, *expr)}) {
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
!RUN: %python %S/test_errors.py %s %flang_fc1
2+
module m
3+
contains
4+
elemental real function f(x)
5+
real, intent(in) :: x
6+
f = x
7+
end
8+
subroutine s(a)
9+
real a(..)
10+
!ERROR: Assumed-rank array 'a' may not be used as an argument to an elemental procedure
11+
print *, f(a)
12+
end
13+
end

0 commit comments

Comments
 (0)