This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Function pointers to a nested function / contained procedure
- From: Richard Biener <richard dot guenther at gmail dot com>
- To: Thomas König <tk at tkoenig dot net>
- Cc: GCC Development <gcc at gcc dot gnu dot org>, "fortran at gcc dot gnu dot org" <fortran at gcc dot gnu dot org>
- Date: Wed, 27 Mar 2019 10:02:21 +0100
- Subject: Re: Function pointers to a nested function / contained procedure
- References: <0D3ECD50-9BC6-449F-A88D-948164AD60CA@tkoenig.net>
On Wed, Mar 27, 2019 at 8:48 AM Thomas König <tk@tkoenig.net> wrote:
>
> Hi Eric,
> > There is an entire machinery in the middle-end and the back-ends to support this (look for trampolines/descriptors in the manual and the source code). This should essentially work out of the box for any language front-end.
> Thanks for the pointer. The documentation I have seen seems to point out what to do in a back end to implement this, less towards what to do in a front end. And the source is big :-)
> Could somebody maybe shed some additional light on what magic I would have to invoke in the Fortran front end?
I think the only thing required is that the function nesting is
appearant by means of DECL_CONTEXT of the inner function being
the outer function. Of course accesses of outer function variables
from the inner function have to use the same decl tree
(not just a copy of the decl with the same name).
Richard.
> Regards, Thomas