This is the mail archive of the
mailing list for the GCC project.
Re: [PATCH 2/5, OpenACC] Support Fortran optional arguments in the firstprivate clause
- From: Tobias Burnus <tobias dot burnus at physik dot fu-berlin dot de>
- To: Kwok Cheung Yeung <kcy at codesourcery dot com>, Jakub Jelinek <jakub at redhat dot com>
- Cc: gcc-patches at gcc dot gnu dot org, fortran at gcc dot gnu dot org, thomas at codesourcery dot com
- Date: Thu, 18 Jul 2019 11:28:00 +0200
- Subject: Re: [PATCH 2/5, OpenACC] Support Fortran optional arguments in the firstprivate clause
I played around and came up with another second way one gets a single "*" without
I haven't checked whether which of those match the proposed omp_is_optional_argument's
+ && DECL_BY_REFERENCE (decl)
+ && TREE_CODE (TREE_TYPE (decl)) == POINTER_TYPE;
nor whether some checks reject any of those with OpenACC (or OpenMP).
In any case, the dump of "type(c_ptr),value", "integer, dimension(1)" and "integer,optional"
static void foo (void *, integer(kind=4) *, integer(kind=4) *);
Actually, if one combines VALUE with OPTIONAL, it gets even more interesting.
To implement it, one has two choices:
* pass a copy by reference (or NULL)
* pass by value (including a dummy value if absent) and denote the state as
The latter is done in gfortran, cf. PR fortran/35203, following the IBM compiler.
I am not sure whether it does need special care fore OpenACC (or OpenMP 5) offloading,
but that's at least a case which is not handled by the patch.
Actually, there is a bug: the declaration of the function and the definition of
the function is not the same - one misses the hidden argument :-(
That's now PR fortran/91196.
Fortran code - which now also contains VALUE, OPTIONAL:
logical(kind=c_bool) :: is_present
integer :: y(1)
y(1) = 5
is_present = foo(c_null_ptr, y)
logical(kind=c_bool) function foo(x, y, z, z2)
type(c_ptr), value :: x ! Matches a C 'void *' pointer
integer, target :: y(1)
integer, optional :: z
integer, value, optional :: z2
foo = present(z2)
end function foo