Files
clang-p2996/flang/test/Semantics/declarations07.f90
Peter Klausler 94d47e6325 [flang] Catch nasty order-of-declarations case (#71881)
It is possible to declare the rank of an object after that object has
been used in the same specification part in a specification function
reference whose result or generic resolution may well have depended on
the object being apparently a scalar.

Catch this case, and emit a warning -- not an error, yet, due to fear of
false positives.

See the new test for examples.
2023-11-13 16:24:43 -08:00

19 lines
637 B
Fortran

! RUN: %python %S/test_errors.py %s %flang_fc1 -Werror
! A nasty case of a weird order of declarations - a symbol may appear
! as an actual argument to a specification function before its rank
! has been declared.
program main
interface kind
pure integer function mykind(x)
real, intent(in) :: x(:)
end
end interface
real a, b
integer, parameter :: ak = kind(a)
integer, parameter :: br = rank(b)
!WARNING: 'a' appeared earlier as a scalar actual argument to a specification function
dimension a(1)
!WARNING: 'b' appeared earlier as a scalar actual argument to a specification function
dimension b(1)
end