[flang] procedure interface from declaration statement can be used before it is declared
Consider the contrived program below:
module m
implicit none
abstract interface
subroutine s_iface()
end subroutine
end interface
procedure(q), pointer :: r ! <-- illegal: q declared afterward
procedure(s_iface), pointer :: q
end module
use m
end
flang runs this without any warnings, although it appears to be a disallowed (J3/24-007, 15.4.3.6 p1):
C1515 (R1516) The name shall be the name of an abstract interface or of a procedure that has an explicit interface. If name is declared by a procedure-declaration-stmt it shall be previously declared. (emphasis added) If name denotes an intrinsic procedure it shall be one that is listed in Table 16.2.
gfortran rejects this case: Error: Interface 'q' at (1) is declared in a later PROCEDURE statement. When the statements declaring r and q are swapped, the program is accepted.
nvfortran also rejects it: NVFORTRAN-S-0155-Illegal procedure interface - q (/app/example.f90: 10).
Found using Claude when looking at the conformity of named constraint checks.
Opened #232928 with a fix for this.
@llvm/issue-subscribers-flang-frontend
Author: Ivan Pribec (ivan-pi)
module m
implicit none
abstract interface
subroutine s_iface()
end subroutine
end interface
procedure(q), pointer :: r ! <-- illegal: q declared afterward
procedure(s_iface), pointer :: q
end module
use m
end
flang runs this without any warnings, although it appears to be a disallowed (J3/24-007, 15.4.3.6 p1):
> C1515 (R1516) The name shall be the name of an abstract interface or of a procedure that has an explicit interface. If name is declared by a procedure-declaration-stmt it shall be previously declared. (emphasis added) If name denotes an intrinsic procedure it shall be one that is listed in Table 16.2.
gfortran rejects this case: Error: Interface 'q' at (1) is declared in a later PROCEDURE statement. When the statements declaring r and q are swapped, the program is accepted.
nvfortran also rejects it: NVFORTRAN-S-0155-Illegal procedure interface - q (/app/example.f90: 10).
Found using Claude when looking at the conformity of named constraint checks.