Fortran: Fix parameterized derived type errors
Corrects calculation of offsets for elements within parameterized derived types in Fortran.
This commit fixes errors related to parameterized derived types (PDTs) in Fortran. Specifically, it corrects the calculation of the offset for elements within these types by ensuring the lower bound contribution is multiplied by the accumulated size. A minor format correction is also included.
In Details
The change in trans-array.cc modifies structure_alloc_comps to correctly compute offsets for PDTs. Previously, the contribution of lbound was not properly scaled by the accumulated size, leading to incorrect memory layouts. This affects how components within parameterized derived types are accessed. A minor correction is also made in gfc_trans_deferred_vars in trans-decl.cc.
- parameterized derived type (PDT)
- A derived type in Fortran whose definition includes type parameters (like kind or length) that can be specified at the time of variable declaration. This allows for more flexible and generic data structures.
- derived type
- A user-defined data type in Fortran that can aggregate components of different types, similar to a 'struct' in C.
- offset
- The distance in bytes from the beginning of a memory block to a specific element or member within that block.