[flang] Accept polymorphic component element in storage_size
[llvm-project.git] / flang / test / Lower / derived-type-descriptor.f90
blob22f7bf188440b89b30732b93a712df4f577c4c4f
1 ! Test lowering of derived type descriptors builtin data
2 ! RUN: bbc -emit-fir %s -o - | FileCheck %s
3 ! RUN: %flang_fc1 -emit-fir %s -o - | FileCheck %s
5 subroutine foo()
6 real, save, target :: init_values(10, 10)
7 type sometype
8 integer :: num = 42
9 real, pointer :: values(:, :) => init_values
10 end type
11 type(sometype), allocatable, save :: x(:)
12 end subroutine
14 ! CHECK-LABEL: fir.global linkonce_odr @_QFfooE.n.num constant target : !fir.char<1,3> {
15 ! CHECK: %[[res:.*]] = fir.string_lit "num"(3) : !fir.char<1,3>
16 ! CHECK: fir.has_value %[[res]] : !fir.char<1,3>
17 ! CHECK-LABEL: fir.global linkonce_odr @_QFfooE.di.sometype.num constant target : i32
18 ! CHECK-LABEL: fir.global linkonce_odr @_QFfooE.n.values constant target : !fir.char<1,6> {
19 ! CHECK: %[[res:.*]] = fir.string_lit "values"(6) : !fir.char<1,6>
20 ! CHECK: fir.has_value %[[res]] : !fir.char<1,6>
21 ! CHECK-LABEL: fir.global linkonce_odr @_QFfooE.n.sometype constant target : !fir.char<1,8> {
22 ! CHECK: %[[res:.*]] = fir.string_lit "sometype"(8) : !fir.char<1,8>
23 ! CHECK: fir.has_value %[[res]] : !fir.char<1,8>
25 ! CHECK-LABEL: fir.global linkonce_odr @_QFfooE.di.sometype.values constant target : !fir.type<_QFfooT.dp.sometype.values{values:!fir.box<!fir.ptr<!fir.array<?x?xf32>>>}> {
26 ! CHECK: fir.address_of(@_QFfooEinit_values)
27 ! CHECK: }
29 ! CHECK-LABEL: fir.global linkonce_odr @_QFfooE.dt.sometype constant target {{.*}} {
30 !CHECK: fir.address_of(@_QFfooE.n.sometype)
31 !CHECK: fir.address_of(@_QFfooE.c.sometype)
32 ! CHECK:}
34 ! CHECK-LABEL: fir.global linkonce_odr @_QFfooE.c.sometype constant {{.*}} {
35 ! CHECK: fir.address_of(@_QFfooE.n.num)
36 ! CHECK: fir.address_of(@_QFfooE.di.sometype.num) : !fir.ref<i32>
37 ! CHECK: fir.address_of(@_QFfooE.n.values)
38 ! CHECK: fir.address_of(@_QFfooE.di.sometype.values)
39 ! CHECK: }
41 subroutine char_comp_init()
42 implicit none
43 type t
44 character(8) :: name='Empty'
45 end type t
46 type(t) :: a
47 end subroutine
49 ! CHECK-LABEL: fir.global linkonce_odr @_QFchar_comp_initE.di.t.name constant target : !fir.char<1,8> {
50 ! CHECK: %[[res:.*]] = fir.string_lit "Empty "(8) : !fir.char<1,8>
51 ! CHECK: fir.has_value %[[res]] : !fir.char<1,8>
53 ! CHECK-LABEL: fir.global linkonce_odr @_QFchar_comp_initE.c.t constant target : {{.*}} {
54 ! CHECK: fir.address_of(@_QFchar_comp_initE.di.t.name) : !fir.ref<!fir.char<1,8>>
55 ! CHECK: }