[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 https://github.com/llvm/llvm-project/issues/159555.
This commit is contained in:
parent
e6da91810e
commit
286f45189b
@ -1538,6 +1538,10 @@ static bool CheckElementalConformance(parser::ContextualMessages &messages,
|
||||
evaluate::SayWithDeclaration(messages, *wholeSymbol,
|
||||
"Whole assumed-size array '%s' may not be used as an argument to an elemental procedure"_err_en_US,
|
||||
wholeSymbol->name());
|
||||
} else if (IsAssumedRank(*wholeSymbol)) {
|
||||
evaluate::SayWithDeclaration(messages, *wholeSymbol,
|
||||
"Assumed-rank array '%s' may not be used as an argument to an elemental procedure"_err_en_US,
|
||||
wholeSymbol->name());
|
||||
}
|
||||
}
|
||||
if (auto argShape{evaluate::GetShape(context, *expr)}) {
|
||||
|
||||
13
flang/test/Semantics/elemental03.f90
Normal file
13
flang/test/Semantics/elemental03.f90
Normal file
@ -0,0 +1,13 @@
|
||||
!RUN: %python %S/test_errors.py %s %flang_fc1
|
||||
module m
|
||||
contains
|
||||
elemental real function f(x)
|
||||
real, intent(in) :: x
|
||||
f = x
|
||||
end
|
||||
subroutine s(a)
|
||||
real a(..)
|
||||
!ERROR: Assumed-rank array 'a' may not be used as an argument to an elemental procedure
|
||||
print *, f(a)
|
||||
end
|
||||
end
|
||||
Loading…
x
Reference in New Issue
Block a user