[flang-commits] [flang] [Flang] Add partial support for lowering procedure pointer assignment. (PR #70461)

via flang-commits flang-commits at lists.llvm.org
Mon Nov 13 02:17:45 PST 2023


================
@@ -1158,6 +1181,7 @@ genUserCall(Fortran::lower::PreparedActualArguments &loweredActuals,
     case PassBy::CharBoxValueAttribute:
     case PassBy::Box:
     case PassBy::BaseAddress:
+    case PassBy::BoxProcRef:
----------------
jeanPerier wrote:

I think passing NULL() directly to a procedure pointer requires special handling here since the interpretation of NULL is context dependent.

```
interface
 subroutine iface()
 end subroutine
 subroutine test(p)
   procedure(iface), pointer, intent(in) :: p
 end subroutine
end interface
call test(null())
end
````

Seems to lower to:
```
  func.func @_QQmain() {
    %0 = fir.absent !fir.ref<!fir.boxproc<() -> ()>>
    fir.call @_QPtest(%0) fastmath<contract> : (!fir.ref<!fir.boxproc<() -> ()>>) -> ()
    return
  }
```

Which seems incorrect to me (passing a nullptr instead of a pointer to a nullptr).

I am OK with adding a TODO in this patch for the `Fortran::evaluate::UnwrapExpr<Fortran::evaluate::NullPointer>(*expr)` case.


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


More information about the flang-commits mailing list