[PATCH] openmp, fortran: Check that event handles passed to detach clauses are not arrays [PR104131]
Tobias Burnus
tobias@codesourcery.com
Tue Mar 1 07:58:54 GMT 2022
On 28.02.22 22:37, Jakub Jelinek via Fortran wrote:
> On Mon, Feb 28, 2022 at 09:45:10PM +0100, Mikael Morin wrote:
>> Lesson learned today: expressions don’t have a corank.
>> Does pr104131-2.f90 really need to be rejected?
In my reading of the spec, pr104131-2.f90 is _valid_ (in newer OMP). At
least that's implied by the spec as quoted by Jakub:
> OpenMP 5.2 says that detach clause should be treated as if it appears on a
> firstprivate clause and for the privatization clauses says:
> "A private variable must not be coindexed or appear as an actual argument to a procedure where
> the corresponding dummy argument is a coarray."
> 5.1 had the same restriction.
+++ b/gcc/testsuite/gfortran.dg/gomp/pr104131-2.f90
...
+ integer (kind=omp_event_handle_kind) :: x[*]
+ !$omp task detach (x)
Here, 'x' is a coarray – but refers to the local variable on this image.
But the following is invalid as it is coindexed:
!$omp task detach (x[3])
where x[3] means that the value from 'x' on image 3 should be used.
The wording actually also permits array sections. But contrary to coarrays,
(which are odd but otherwise fine), I think it does not really make sense
to have arrays and array sections here.
(Do we need/want to get this clarified/changed in spec?)
But from the wording of the spec, also the first testcase seems to be valid.
* * *
>> A variable that is part of another variable (as an array element or a
>> structure element) cannot appear in a detach clause.
> which tells that the check should be on expr->ref instead of
> expr->sym->as or expr->rank.
I think looking at the "sym" is fine when matching the expression
via gfc_match_omp_variable_list with allow_derived=false (default).
As then there cannot be derived-type components.
Additionally, expr->rank > 0 rules out arrays/array sections
but permits array elements while sym->addr.dimension also rules
out array elements.
BTW: after resolving a variable, expr->ref always exists
for arrays – either to select an element or array section
or otherwise, there is an AR_FULL for a whole array.
Tobias
-----------------
Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955
More information about the Fortran
mailing list