Peter Klausler 96aa48100c [flang] Make uninitialized allocatable components explicitly NULL() in structure constructors
When a structure constructor does not initialize an allocatable component,
ensure that the typed expression representation contains an explicit
NULL() for the component.  Expression semantics already copies default
initialized expressions for nonallocatable components into structure
constructors.  This change is expected to simplify lowering.

Differential Revision: https://reviews.llvm.org/D121162
2022-03-07 16:41:38 -08:00

25 lines
534 B
Fortran

! RUN: %python %S/test_modfile.py %s %flang_fc1
! Ensures that uninitialized allocatable components in a structure constructor
! appear with explicit NULL() in the expression representation.
module m
type t
real, allocatable :: x1, x2, x3
end type
type t2
type(t) :: a = t(NULL(),x2=NULL())
end type
end module
!Expect: m.mod
!module m
!type::t
!real(4),allocatable::x1
!real(4),allocatable::x2
!real(4),allocatable::x3
!end type
!type::t2
!type(t)::a=t(x1=NULL(),x2=NULL(),x3=NULL())
!end type
!intrinsic::null
!end