]> git.ipfire.org Git - thirdparty/gcc.git/commit
C prototypes for functions returning C function pointers.
authorThomas Koenig <tkoenig@gcc.gnu.org>
Tue, 25 Mar 2025 17:42:30 +0000 (18:42 +0100)
committerThomas Koenig <tkoenig@gcc.gnu.org>
Tue, 25 Mar 2025 17:47:44 +0000 (18:47 +0100)
commit737a5760bb24a0a945cc2c916ba452e3f0060c58
tree9cd59c3ea3223f5277072f1172d6512ea5708113
parent479a0a8644e5efa0470f032be21ca7749968af42
C prototypes for functions returning C function pointers.

This 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.

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.
gcc/fortran/dump-parse-tree.cc