Fortran: Fix regression in parameterized derived type errors
Fortran compiler fixes regression in parameterized derived type handling by deferring initializations and improving type checking.
This change resolves a regression in the Fortran compiler’s handling of parameterized derived types (PDTs) by adjusting how component initializers are processed. It defers the update and simplification of component initializers until the end of a loop and refines the type checking for initializers. This prevents incorrect assignments and ensures that real PDT template components are handled appropriately, fixing issues with type resolution.
In Details
This patch addresses PR128877 for Fortran PDTs. It modifies gfc_trans_deferred_vars in decl.cc to defer updating types and simplifying component initializers to the end of the loop. It also refines the logic in resolve_component in resolve.cc to prevent passing real PDT template components with kind=0 through gfc_check_assign_symbol, improving the robustness of PDT handling.
- PDT
- Parameterized Derived Type in Fortran. A derived type whose definition includes parameters that can be specified when the type is declared, allowing for more flexible and generic type definitions.
- initializer
- A value or expression used to set the initial state of a variable or object when it is declared or created.