As Fortran 2018 18.2.3.6, the intrinsic c_loc(x) gets the C address
of argument x. It returns the scalar of type C_PTR. As defined in
iso_c_binding in flang/module/__fortran_builtins.f90, C_PTR is the
derived type with only one component of integer 64.
This supports the lowering of intrinsic module procedure c_loc by
converting the address of argument into integer 64, where the argument
is lowered as Box and the address is generated using fir.box_addr.
The lowering of intrinsic c_funloc has the similar characteristic and
will be supported later.
The execution tests for various data types are in issue
https://github.com/llvm/llvm-project/issues/56552.
I do not fully understand why the POINTER case is left TODO, shouldn't it be handled in the same way ?
If the issue id to get the right memory type, I suggest you use BoxValue::getMemTy():
This will ensure the fir.heap/fir.ptr aspect are kept in the BoxAddrOp result.