Hi Thomas,

Am 24.03.25 um 21:40 schrieb Thomas Koenig:
Hello world,

the attached patch handles dumping prototypes for C functions returning
function pointers.  For the test case

MODULE test
    USE, INTRINSIC :: ISO_C_BINDING
CONTAINS
    FUNCTION lookup(idx) BIND(C)
      type(C_FUNPTR) :: lookup
      integer(C_INT), VALUE :: idx
      lookup = C_FUNLOC(x1)
    END FUNCTION lookup

    subroutine x1()
    end subroutine x1
  END MODULE test

the prototype is

void (*lookup (int idx)) ();

Regression-tested.  Again no test case because I don't know
how.  During testing, I also found that vtabs were dumped,
this is also corrected.

OK for trunk?

the attached patch contains a chunk changing resolve.cc
that is neither described in the suggested commit message,
and it fails to compile here:

../../gcc-trunk/gcc/fortran/resolve.cc: In function 'void check_c_funptr_assign_interface(gfc_expr*, gfc_expr*)': ../../gcc-trunk/gcc/fortran/resolve.cc:12248:48: error: 'gfc_expr' {aka 'struct gfc_expr'} has no member named 'is_c_interop'
12248 |   if (rhs->expr_type != EXPR_FUNCTION || !rhs->is_c_interop)
      |                                                ^~~~~~~~~~~~

Can you please check whether you inadvertently added something
that was not planned or tested?

Cheers,
Harald


Best regards

     Thomas

gcc/fortran/ChangeLog:

     PR fortran/119419
     * dump-parse-tree.cc (write_funptr_fcn): New function.
     (write_type): Invoke it for C_FUNPTR.
     (write_interop_decl): Do not dump vtabs.



Reply via email to