[Flang] Incorrect diagnose when declare a procedure with explicit typing in multiple statements
Consider the following code.
integer :: proc
procedure() :: proc
end
Flang currently issues an error as
2:16: error: The interface for procedure 'proc' has already been declared
procedure() :: proc
^^^^
./t.f:2:16: Declaration of 'proc'
procedure() :: proc
^^^^
It seems incorrect. This code should be equivalent to procedure(integer) :: proc.
@llvm/issue-subscribers-flang-frontend
Author: Daniel Chen (DanielCChen)
Flang currently issues an error as
2:16: error: The interface for procedure 'proc' has already been declared
procedure() :: proc
^^^^
./t.f:2:16: Declaration of 'proc'
procedure() :: proc
^^^^
It seems incorrect. This code should be equivalent to procedure(integer) :: proc.
@llvm/issue-subscribers-bug
Author: Daniel Chen (DanielCChen)
Flang currently issues an error as
2:16: error: The interface for procedure 'proc' has already been declared
procedure() :: proc
^^^^
./t.f:2:16: Declaration of 'proc'
procedure() :: proc
^^^^
It seems incorrect. This code should be equivalent to procedure(integer) :: proc.
https://github.com/llvm/llvm-project/pull/82835
Thanks for the quick fix! @klausler PR #82935 fixed the reproducer and some of the original test cases.
However, one variation still fails.
The reproducer is as follows.
integer :: proc
procedure(integer) :: proc
end
That case has multiple type declarations for the same symbol; gfortran and NAG also emit errors.
Yeah, I saw gfortran issuing an error, but both XLF and ifort accept it. It seems a harmless thing to do as the procedure declaration statement declares proc to be a function that has integer return type, which is consistent with the previous type declaration statement. Of course, if the type are different, it would definitely be an error. I can't think of a bad thing about this. Would this be an extension candidate if the standard doesn't allow it (admitted I didn't check it closely to say "yes" or "no").
Go right ahead and implement it if that's what you want.
Thanks for confirming that. I will open a new issue to track that and let the merging of PR #82835 to close this one.