[flang-commits] [flang] [Flang]: Lowering reference to functions that return a procedure pointer (PR #78194)

Daniel Chen via flang-commits flang-commits at lists.llvm.org
Wed Jan 24 08:59:39 PST 2024


DanielCChen wrote:

> It seems to be legal to use procedure pointer result in ASSOCIATED, this currently crashes:
> 
> ```
>  interface
>    function foo()
>      procedure(), pointer :: foo
>    end function
>  end interface
>  print *, associated(foo())
>  end
> ```
> 
> So either the fir.boxproc results needs to be placed in a storage after the call so that code that expects to get pointers works, or the ASSOCIATED lowering should accept fir.boxproc as first argument too.
> 
> https://github.com/llvm/llvm-project/blob/a90347ecc7e32c25a3b3820723f8405369f3abdc/flang/lib/Optimizer/Builder/IntrinsicCall.cpp#L2180

Good point. With the current implementation, I think I can make `genAssociated` to take `fir.boxproc` as the type of `arg[0]` and skip the `fir::load`. 

https://github.com/llvm/llvm-project/pull/78194


More information about the flang-commits mailing list