[Flang] Typed procedure pointer with implicit interface cannot pointer assign to a function reference that returns a procedure pointer with the explicit interface that has the same TKR.
Consider the following code:
interface
integer function bar()
end
function foo()
import
procedure(bar), pointer :: foo
end
end interface
procedure(integer), pointer :: p1
p1 => foo()
end
Flang currently issues an error as:
error: Semantic errors in t.f
./t.f:10:1: error: Procedure pointer 'p1' associated with result of reference to function 'foo' that is an incompatible procedure pointer: incompatible procedure attributes: ImplicitInterface
p1 => foo()
^^^^^^^^^^^
./t.f:9:32: Declaration of 'p1'
procedure(integer), pointer :: p1
^^
According to the standard (F2018) [10.2.2.4 Procedure pointer assignment]
" 5. If the pointer object has an implicit interface and is explicitly typed or referenced as a function, the pointer target shall be a function. ....
6 If the pointer object is a function with an implicit interface, the pointer target shall be a function with the same type; corresponding type parameters shall have the same value. "
It seems the above code is conforming.
@llvm/issue-subscribers-flang-frontend
Author: Daniel Chen (DanielCChen)
Flang currently issues an error as:
error: Semantic errors in t.f
./t.f:10:1: error: Procedure pointer 'p1' associated with result of reference to function 'foo' that is an incompatible procedure pointer: incompatible procedure attributes: ImplicitInterface
p1 => foo()
^^^^^^^^^^^
./t.f:9:32: Declaration of 'p1'
procedure(integer), pointer :: p1
^^
According to the standard (F2018) [10.2.2.4 Procedure pointer assignment]
" 5. If the pointer object has an implicit interface and is explicitly typed or referenced as a function, the pointer target shall be a function. ....
6 If the pointer object is a function with an implicit interface, the pointer target shall be a function with the same type; corresponding type parameters shall have the same value. "
It seems the above code is conforming.
@llvm/issue-subscribers-bug
Author: Daniel Chen (DanielCChen)
Flang currently issues an error as:
error: Semantic errors in t.f
./t.f:10:1: error: Procedure pointer 'p1' associated with result of reference to function 'foo' that is an incompatible procedure pointer: incompatible procedure attributes: ImplicitInterface
p1 => foo()
^^^^^^^^^^^
./t.f:9:32: Declaration of 'p1'
procedure(integer), pointer :: p1
^^
According to the standard (F2018) [10.2.2.4 Procedure pointer assignment]
" 5. If the pointer object has an implicit interface and is explicitly typed or referenced as a function, the pointer target shall be a function. ....
6 If the pointer object is a function with an implicit interface, the pointer target shall be a function with the same type; corresponding type parameters shall have the same value. "
It seems the above code is conforming.
https://github.com/llvm/llvm-project/pull/82796
I have verified PR #82796 has fixed the reproducer in the issue as well as the origin test case. Thanks for the quick fix! @klausler I will leave it and let the merging of the PR to close this issue.