For parameterized derived type component initializers whose
expressions' types depend on parameter values, f18's current
scheme of analyzing the initialization expression once during
name resolution fails. For example,
type :: pdt(k)
integer, kind :: k
real :: component = real(0.0, kind=k)
end type
To handle such cases, it is necessary to re-analyze the parse
trees of these initialization expressions once for each distinct
initialization of the type.
This patch adds code to wipe an expression parse tree of its
typed expressions, and update those of its symbol table pointers
that reference type parameters, and then re-analyze that parse
tree to generate the properly typed component initializers.
Differential Revision: https://reviews.llvm.org/D123728
19 lines
413 B
Fortran
19 lines
413 B
Fortran
! RUN: %python %S/test_modfile.py %s %flang_fc1
|
|
! Ensure proper formatting of component initializers in PDTs;
|
|
! they should be unparsed from their parse trees.
|
|
module m
|
|
type :: t(k)
|
|
integer, kind :: k
|
|
real(kind=k) :: x = real(0., kind=k)
|
|
end type
|
|
end module
|
|
|
|
!Expect: m.mod
|
|
!module m
|
|
!type::t(k)
|
|
!integer(4),kind::k
|
|
!real(int(int(k,kind=4),kind=8))::x=real(0., kind=k)
|
|
!end type
|
|
!intrinsic::real
|
|
!end
|