From: Mikael Morin <[email protected]>

Hello,

This is the second version of part 7 of the array descriptor series.
The first version was posted in early september [1].

The plan was to fix a PR first [2] before coming back to this series, to
make a merge conflict resolution easier in the implementation of ASSOCIATED
and have first better testing coverage there.  Starting from that PR, and
following regressions, I have been producing wrong-code PRs faster than I
have been fixing them since then.

Now stage 1 has ended, and I would like to push the series before it's too
late.  It was first posted in september, and it fixes a couple of minor
bugs, so it qualifies as stage 3 material.  I have dropped the patch
changing ASSOCIATED, and amended the other patches considering Jerry's
comments.  For patch 4, the simple suggested changes have been included,
but the redundant reference walking is eliminated separately in a follow-up
patch.  Finally, the cobounds copy, which was propagated to the three scalar
descriptor initialization functions in the first version, is no longer
moved to the factored function and only remains in the function it was
already present in.  It was causing regressions with static coarrays
initialization.

I fortran-tested the series again on x86_64-pc-linux-gnu without new
failure.  OK for mainline?  I plan to push the series in the second half of
the coming week if I don't get any further comment.

[1] Version 1:
https://inbox.sourceware.org/fortran/[email protected]/t/#u
https://gcc.gnu.org/pipermail/gcc-patches/2026-September/729953.html

[2] PR127233: ASSOCIATED ignores element length:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=127233

--

this is the seventh part of the array descriptor series.  The previous part
isolated the initialization of scalar descriptors to three dedicated
functions.  These three functions do more or less the same thing, but with
subtle differences, either caused by bugs, useless code, or different
requirements or assumptions about their input.

This part fixes the bugs, removes useless differences and unifies the three
implementations.

Patches 1, 4 and 9 fix bugs in the descriptor initialization.  They are
affecting either the elem_len value (patches 1 and 9) or the type value
(patch 4).
Patch 3 fixes a possible ICE bug.
Patches 2 and 7 remove useless work in the descriptor initialization
generation.
Patches 6 and 8 factor common code to a shared function.
Patch 5 integrates more tightly class container extraction and value pointer
reference extraction.

--

v1 to v2 changes:

01->01: Keep assertion but loosen the condition to allow non-pointers in the
        untyped (i.e. unlimited polymorphic) case.  Move a comment so that
        it is obvious what it applies to.  Add a comment regarding the
        non-initialization of element length.

04->04: Always initialize class_ref variable.  Use a checking-only assert.

()->05: New patch: integrate extraction of the value pointer to the
        reference walk so that it's not done redundantly.

05->06: Keep cobounds copy out of the factored function.

06->(): Drop patch.

08->08: Adjust as a consequence of the removal of patch 06.

--

Previous parts in the array descriptor series:

part 6 (pushed):  fortran: Move scalar descriptor init
part 5 (pushed):  fortran: Move null- or default-initialization
part 4 (pushed):  fortran: Move dtype fields constants
part 3 (dropped): fortran: Ensure read-only getters
part 2 (pushed):  fortran: Add getters and setters
part 1 (pushed):  fortran: Move existing functions to a separate file

Mikael Morin (9):
  fortran: array descriptor: Guess size from declared type [PR122521]
  fortran: array descriptor: Simplify scalar dtype initialization
    [PR122521]
  fortran: array descriptor: Add a check for class container type
    [PR122521]
  fortran: array descriptor: Mark polymorphic descriptors as such
    [PR122521]
  fortran: array descriptor: Extract class container with its data
    pointer [PR122521]
  fortran: array descriptor: Factor scalar descriptor init 1/2
    [PR122521]
  fortran: array descriptor: Remove redundant array type unwrapping
    [PR122521]
  fortran: array descriptor: Factor scalar descriptor init 2/2
    [PR122521]
  fortran: array descriptor: Set polymorphic elem_len value [PR122521]

 gcc/fortran/trans-descriptor.cc               | 179 ++++++++++++++----
 gcc/fortran/trans-descriptor.h                |   6 +-
 gcc/fortran/trans-expr.cc                     |   4 +-
 gcc/fortran/trans-types.cc                    |  55 +++++-
 gcc/testsuite/gfortran.dg/assumed_rank_26.f90 |  26 +++
 gcc/testsuite/gfortran.dg/assumed_rank_27.f90 |  39 ++++
 gcc/testsuite/gfortran.dg/sizeof_7.f90        |  30 +++
 gcc/testsuite/gfortran.dg/sizeof_8.f90        |  33 ++++
 8 files changed, 328 insertions(+), 44 deletions(-)
 create mode 100644 gcc/testsuite/gfortran.dg/assumed_rank_26.f90
 create mode 100644 gcc/testsuite/gfortran.dg/assumed_rank_27.f90
 create mode 100644 gcc/testsuite/gfortran.dg/sizeof_7.f90
 create mode 100644 gcc/testsuite/gfortran.dg/sizeof_8.f90

-- 
2.53.0

Reply via email to