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

--- Comment #25 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:4827ebe466ddcb9c92e784526846806fa82a5a00

commit r17-3648-g4827ebe466ddcb9c92e784526846806fa82a5a00
Author: Jerry DeLisle <[email protected]>
Date:   Sun Aug 23 18:29:33 2026 -0700

    fortran: [PR49802]-3 Allow VALUE on assumed-shape and explicit-shape array
dummies

    Fortran 2003 C527 prohibited the VALUE attribute on any array dummy.
    Fortran 2008 relaxed this with C557, which prohibits only an
    assumed-size array, a coarray, and an entity with a coarray ultimate
    component.  gfortran was rejecting the whole combination in
    gfc_check_conflict, so the diagnostic for an assumed-rank dummy also
    came out as a VALUE/DIMENSION conflict rather than naming the real
    constraint.

    resolve.cc takes over the check, gated by gfc_notify_std so that
    -std=f2003 still rejects an array VALUE dummy.  An assumed-size array
    is rejected outright.  So is an array VALUE dummy of a BIND(C)
    procedure, since only a scalar VALUE dummy is interoperable with a
    formal parameter of the C prototype (F2023, 18.3.6 (4)), and a
    polymorphic array VALUE dummy, as not yet implemented.

    trans-types.cc keeps the dummy passed by reference, and
    gfc_conv_procedure_call gives it a private copy of the actual argument
    through gfc_conv_subref_array_arg with INTENT_IN, so nothing is written
    back.  The copy is deep, so that a callee cannot reach the actual
    argument's data through a shared allocatable component.

            PR fortran/49802

    gcc/fortran/ChangeLog:

            * resolve.cc (resolve_symbol): Allow VALUE on assumed-shape and
            explicit-shape array dummies under Fortran 2008 (C557); reject it
            on assumed-size arrays, on array dummies of a BIND(C) procedure,
            and, as not yet implemented, on polymorphic array dummies.
            * symbol.cc (gfc_check_conflict): Remove the conflict between
            VALUE and DIMENSION; only VALUE and CODIMENSION remain mutually
            exclusive.
            * trans-expr.cc (gfc_conv_procedure_call): For a VALUE array
            dummy, pass a private deep copy of the actual argument via
            gfc_conv_subref_array_arg with INTENT_IN.
            * trans-types.cc (gfc_sym_type): Use byref=1 for VALUE array
            dummies, so the ABI still passes by reference.

    gcc/testsuite/ChangeLog:

            * gfortran.dg/value_3.f90: Compile under -std=f2003 and replace the
            now-invalid expectation that an explicit-shape array dummy with
            VALUE conflicts with DIMENSION; this combination is permitted
            (F2008, C557).
            * gfortran.dg/assumed_rank_11.f90: Update expected diagnostic for
            VALUE on an assumed-rank dummy.
            * gfortran.dg/c-interop/c535a-2.f90: Likewise.
            * gfortran.dg/value_12.f90: New test.
            * gfortran.dg/value_13.f90: New test.
            * gfortran.dg/value_16.f90: New test.
            * gfortran.dg/value_17.f90: New test.

Reply via email to