https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102459

--- Comment #9 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jerry DeLisle <[email protected]>:

https://gcc.gnu.org/g:d2ab04fbba7b97d17e4f9e0885d71a4e1faafc96

commit r16-8070-gd2ab04fbba7b97d17e4f9e0885d71a4e1faafc96
Author: Christopher Albert <[email protected]>
Date:   Tue Mar 10 18:46:54 2026 +0100

    fortran: Fix OpenMP iterator depend lowering for component arrays
[PR102459]

    When lowering an OpenMP depend clause with an iterator expression such as
    x(j)%a, the front end currently looks only at the first REF_ARRAY to
    decide between scalar-reference lowering and array-descriptor lowering.
    For x(j)%a that first ref is the scalar base element x(j), but the full
    expression is still the rank-1 component array a.

    As a result, the code calls gfc_conv_expr_reference on an array-valued
    expression, which later reaches gfc_conv_scalarized_array_ref without a
    scalarizer state and ICEs.

    Fix this by choosing the lowering path from the rank of the full
    expression.  Rank-zero expressions still use gfc_conv_expr_reference,
    while array-valued expressions are lowered through
gfc_conv_expr_descriptor.
    Apply the same adjustment to the analogous depobj helper and add a
    regression test for task depend clauses covering both x(j)%a and the
    scalar control case x(j)%a(1).

    gcc/fortran/ChangeLog:

            PR fortran/102459
            * trans-openmp.cc (gfc_trans_omp_clauses): Choose the scalar
            reference path from the full expression rank rather than the first
            array reference.
            (gfc_trans_omp_depobj): Likewise.

    gcc/testsuite/ChangeLog:

            PR fortran/102459
            * gfortran.dg/pr102459.f90: New test.

    Signed-off-by: Christopher Albert <[email protected]>

Reply via email to