On 12/07/2019 12:41 pm, Jakub Jelinek wrote:
This should be done through a langhook.
Are really all PARM_DECLs wtih DECL_BY_REFERENCE and pointer type optional
arguments? I mean, POINTER_TYPE is used for a lot of cases.
Hmmm... I thought it was the case that if you pass an argument in by reference
(the default) in Fortran, the PARM_DECL will always be a reference to the
argument type if non-optional, or a pointer if optional. However, fixed-shape
arrays are passed in via a pointer whether optional or not...
I also experimented with passing in a pointer by value, but it seems like that
is not allowed. e.g.
subroutine foo(x)
integer, pointer, value :: x
end subroutine foo
results in:
11 | integer, pointer, value :: x
| 1
Error: VALUE attribute conflicts with POINTER attribute at (1)
Are there any more examples in Fortran where a PARM_DECL is a pointer type
without being optional?
In the Fortran FE, optional arguments are indicated by setting attr.optional on
the gfc_symbol for the parameter, but the OMP lowering works on a tree - is it
somehow possible to get from the tree back to the gfc_symbol? If so, that would
be a more reliable method of detecting optional arguments.
Thanks
Kwok