fortran: Copy array span from target descriptor in pointer assignments
Fixes array pointer assignments in Fortran to correctly copy the span from the target descriptor.
This change addresses a bug in Fortran pointer assignments where the span of an array pointer was not correctly copied from its target descriptor. By marking the _data field of array pointer class containers with GFC_DECL_PTR_ARRAY_P, the compiler now ensures that the span is copied from the target descriptor, even for polymorphic arrays. This corrects issues related to derived types and ensures accurate array behavior.
In Details
In Fortran, array pointer assignments were incorrectly assuming the class container size as the span for polymorphic arrays, failing when the target was a parent of an extended derived type. This change sets the GFC_DECL_PTR_ARRAY_P flag on the _data field of array pointer class containers in gfc_get_derived_type to ensure the span is copied from the target descriptor. It also removes a redundant condition in is_pointer_array in trans-array.cc.
- span
- In Fortran array handling, the span refers to the size or extent of an array, particularly relevant for dynamic or polymorphic arrays.
- GFC_DECL_PTR_ARRAY_P
- A flag used in the Fortran front-end to indicate that a data field is part of a polymorphic array pointer.
- polymorphic arrays
- Arrays in Fortran whose type can change at runtime, often associated with inheritance and dynamic dispatch.