Fortran: Address parameterized derived type errors with hidden arguments.
GCC's Fortran compiler improves handling of parameterized derived types by introducing hidden arguments for correctness.
This commit significantly enhances GCC’s Fortran compiler’s handling of parameterized derived types (PDTs), addressing errors related to their usage, particularly in function arguments and allocations. It introduces a mechanism to use ‘hidden arguments’ for PDTs that require them, ensuring correct parameter passing and type checking. New functions and data structures are added to manage this, along with checks for parameter consistency and runtime error reporting for mismatches. This resolves issues with PDTs in various calling and allocation contexts.
In Details
This patch for GCC's Fortran frontend introduces substantial changes to how parameterized derived types (PDTs) are handled, particularly concerning hidden arguments and parameter validation. A new function, gfc_pdt_requires_hidden_arg, determines when a PDT dummy argument needs an accompanying hidden argument to pass its parameter values. This is integrated into the code generation for function arguments (create_function_arglist) and deferred variable handling (gfc_trans_deferred_vars). New functions fixup_assumed_PDT_parameters and check_PDT_parameters validate actual vs. ALLOCATE…
- parameterized derived type (PDT)
- A Fortran derived type whose components or its own kind, length, or rank can be specified by parameters, allowing for more flexible and generic data structures.
- hidden argument
- An argument passed to a procedure that is not explicitly declared by the caller but is managed by the compiler to support certain language features, such as passing parameters for parameterized derived types.
- Fortran
- A high-level programming language primarily used for scientific and numerical computation.
- ALLOCATE statement
- A Fortran statement used to dynamically allocate storage for variables, typically arrays or derived types.
- runtime error
- An error that occurs during the execution of a program, as opposed to a compile-time error.
- ICE
- Internal Compiler Error, a severe error within the compiler itself that halts compilation.