https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126940
Tobias Burnus <burnus at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jvdelisle at gcc dot gnu.org
--- Comment #2 from Tobias Burnus <burnus at gcc dot gnu.org> ---
Bisecting points at r17-3342-gf3943597388db4
NOTE: IMHO the solution is to update the expected output pattern - at least I
don't think that the testcase would be able to detect issues in the code gen
itself.
However, I want to point out that the commit already modified this testcase -
albeit only for line 77 (and following):
> --- a/libgomp/testsuite/libgomp.oacc-fortran/host_data-5.F90
> +++ b/libgomp/testsuite/libgomp.oacc-fortran/host_data-5.F90
> @@ -77,4 +77,11 @@ subroutine foo (p2, parr, host_p, host_parr, cond)
> - ! { dg-note {variable 'parm\.[0-9]+' declared in block isn't candidate
> for adjusting OpenACC privatization level: artificial} "" { target *-*-* }
> .-8 }
> - ! { dg-note {variable 'D\.[0-9]+' declared in block isn't candidate for
> adjusting OpenACC privatization level: artificial} "" { target *-*-* } .-9 }
> - ! { dg-note {variable 'transfer\.[0-9]+' declared in block isn't
> candidate for adjusting OpenACC privatization level: artificial} "" { target
> *-*-* } .-10 }
> - ! { dg-note {variable 'parm\.[0-9]+' declared in block isn't candidate
> for adjusting OpenACC privatization level: not addressable} "" { target *-*-*
> } .-11 }
> + ! { dg-note {variable 'D\.[0-9]+' declared in block isn't candidate for
> adjusting OpenACC privatization level: artificial} "" { target *-*-* } .-8 }
> + ! { dg-note {variable 'transfer\.[0-9]+' declared in block isn't
> candidate for adjusting OpenACC privatization level: artificial} "" { target
> *-*-* } .-9 }
> + ! { dg-note {variable 'parm\.[0-9]+' declared in block isn't candidate
> for adjusting OpenACC privatization level: not addressable} "" { target *-*-*
> } .-10 }
> + ! The TARGET dummy 'parr' is addressed by the span of its descriptor, so
> + ! passing it to a dummy without a descriptor packs it when it is not
> + ! contiguous.
> + ! { dg-note {variable 'iftmp\.[0-9]+' declared in block isn't candidate
> for adjusting OpenACC privatization level: not addressable} "" { target *-*-*
> } .-14 }
> + ! { dg-note {variable 'atmp\.[0-9]+' declared in block isn't candidate
> for adjusting OpenACC privatization level: not addressable} "" { target *-*-*
> } .-15 }
> + ! { dg-note {variable 'arg_ptr\.[0-9]+' declared in block isn't
> candidate for adjusting OpenACC privatization level: not addressable} "" {
> target *-*-* } .-16 }
> + ! { dg-note {variable 'contiguous\.[0-9]+' declared in block isn't
> candidate for adjusting OpenACC privatization level: not addressable} "" {
> target *-*-* } .-17 }
> + ! { dg-note {variable 'S\.[0-9]+' declared in block isn't candidate for
> adjusting OpenACC privatization level: not addressable} "" { target *-*-* }
> .-18 }
commit f3943597388db4846386b6d5a18d33ebf80ea96c
Author: Jerry DeLisle
AuthorDate: Mon Aug 10 09:37:01 2026 -0700
Commit: Jerry DeLisle
CommitDate: Mon Aug 17 13:06:41 2026 -0700
fortran: [PR53800] Wrong copy-in/out with array actual to TARGET dummy
An actual argument whose elements are spaced by more than the element
size - a CLASS array, or a component of a derived-type array - was
copied in and out when passed to a TARGET or POINTER dummy, so pointers
associated with the dummy went stale on return.
Such an actual argument is now passed with a descriptor of its own,
whose element type is that of the subobject and whose span is the
element size of the array, as is already done for a pointer assignment
to a subobject of an array. The dummy addresses its elements through
that span. Passing it on to a dummy that requires contiguous storage
copies it, but only if it turns out not to be contiguous.
PR fortran/53800
gcc/fortran/ChangeLog:
* gfortran.h (gfc_is_span_addressed_dummy): New prototype.
* symbol.cc (gfc_is_span_addressed_dummy): New function.
* expr.cc (is_subref_array): Return true for a span addressed
dummy.
* trans.h (gfc_get_span_descriptor): New prototype.
* trans.cc (gfc_get_span_descriptor): New function returning the
descriptor that carries a pointer array decl's span.
(get_array_span): Use it, including for character types.
* trans-array.cc (is_pointer_array): Note in the comment that the
tree must be a descriptor.
(span_addressed_array): New function returning the decl that
provides the span of an array.
(gfc_get_array_span): Use it.
(gfc_conv_scalarized_array_ref, gfc_conv_array_ref): Likewise, so
that a descriptorless dummy is addressed by its span.
(gfc_get_dataptr_offset): Likewise and dereference a spanned
character element.
(gfc_conv_expr_descriptor): Describe a subobject of the array
elements by a new descriptor when no temporary is made.
* trans-decl.cc (gfc_build_dummy_array_decl): Use
gfc_is_span_addressed_dummy to mark the dummy as a pointer array.
(gfc_get_symbol_decl): Likewise.
* trans-expr.cc (is_subobject_ref): New function.
(copy_in_out_allowed): Take the actual argument. Use
gfc_is_span_addressed_dummy and keep the copy for an actual
argument with a vector subscript.
(gfc_conv_gfc_desc_to_cfi_desc): Remove the now duplicate
offsetting
of the data pointer for a subobject reference.
(gfc_class_array_data_assign): Also copy the span field.
(gfc_conv_procedure_call): Use copy_in_out_allowed to skip
copy-in/copy-out for a class array reference, a class array
function
result and a subref array. Pass a spanned descriptor instead and
make the copy of a span addressed dummy conditional on it not being
contiguous.
* trans-intrinsic.cc (gfc_conv_is_contiguous_expr): Check the span
of a span addressed dummy against the element length.
gcc/testsuite/ChangeLog:
* gfortran.dg/c_loc_test_22.f90: Update dump patterns for span
addressing.
* gfortran.dg/class_to_type_5.f90: New test.
* gfortran.dg/class_to_type_6.f90: New test.
* gfortran.dg/class_to_type_7.f90: New test.
* gfortran.dg/class_to_type_8.f90: New test.
* gfortran.dg/class_to_type_9.f90: New test.
libgomp/ChangeLog:
* testsuite/libgomp.oacc-fortran/host_data-5.F90: Update the
privatization notes for the packing of a TARGET dummy.