PSyclone
PSyclone copied to clipboard
Parameter symbol accessed within derived type is not updated with initial value
As reported by @schreiberx, just running PSyclone on the following Fortran:
MODULE test_mod
IMPLICIT NONE
! parameters
INTEGER, PARAMETER :: rsh = 8
REAL(KIND=rsh), PARAMETER :: pi = 3.14159265358979323846
TYPE o1dv_param_type
INTEGER :: z0bstress_option
REAL(KIND=rsh) :: c_rho
REAL(KIND=rsh), ALLOCATABLE :: height_norm(:)
END TYPE
TYPE o1dv_out_type
REAL(KIND=rsh), ALLOCATABLE :: height(:)
REAL(KIND=rsh) :: dens_mean
END TYPE
CONTAINS
END MODULE test_mod
results in _gen_parameter_decls crashing because the Symbol rsh is a parameter but is missing its initial value.
I put a breakpoint in SymbolTable.add() and that showed that rsh is first added to the SymbolTable when parsing a derived type - at that point we know it is a kind parameter and therefore is a constant integer but we don't yet know more. Presumably, when we come to handle the actual declaration of rsh we fail to capture its initial value.