-
Notifications
You must be signed in to change notification settings - Fork 10.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[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.
- Loading branch information
Showing
2 changed files
with
58 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
! 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 |