Skip to content

Commit 1c0e09b

Browse files
committed
[flang] Catch attempts to use assumed-rank as elemental argument
An assumed-rank array may not be used as an argument to an elemental procedure. Fixes #159555.
1 parent d90a313 commit 1c0e09b

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
@@ -1483,6 +1483,10 @@ static bool CheckElementalConformance(parser::ContextualMessages &messages,
14831483
evaluate::SayWithDeclaration(messages, *wholeSymbol,
14841484
"Whole assumed-size array '%s' may not be used as an argument to an elemental procedure"_err_en_US,
14851485
wholeSymbol->name());
1486+
} else if (IsAssumedRank(*wholeSymbol)) {
1487+
evaluate::SayWithDeclaration(messages, *wholeSymbol,
1488+
"Assumed-rank array '%s' may not be used as an argument to an elemental procedure"_err_en_US,
1489+
wholeSymbol->name());
14861490
}
14871491
}
14881492
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)