[flang] Accept polymorphic component element in storage_size
[llvm-project.git] / flang / test / Lower / dummy-argument-derived.f90
blob55093e1670995d635a8022b2859d8df60b03177e
1 ! Test lowering of derived type dummy arguments
2 ! RUN: bbc -emit-fir %s -o - | FileCheck %s
3 module type_defs
4 type simple_type
5 integer :: i
6 end type
7 type with_kind(k)
8 integer, kind :: k
9 real(k) :: x
10 end type
11 end module
13 ! -----------------------------------------------------------------------------
14 ! Test passing of derived type arguments that do not require a
15 ! fir.box (runtime descriptor).
16 ! -----------------------------------------------------------------------------
18 ! Test simple type scalar with no attribute.
19 ! CHECK-LABEL: func @_QPtest1(
20 ! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.type<_QMtype_defsTsimple_type{i:i32}>> {fir.bindc_name = "a"}) {
21 subroutine test1(a)
22 use type_defs
23 type(simple_type) :: a
24 end subroutine
26 ! Test simple type explicit array with no attribute.
27 ! CHECK-LABEL: func @_QPtest2(
28 ! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.array<100x!fir.type<_QMtype_defsTsimple_type{i:i32}>>> {fir.bindc_name = "a"}) {
29 subroutine test2(a)
30 use type_defs
31 type(simple_type) :: a(100)
32 end subroutine
34 ! Test simple type scalar with TARGET attribute.
35 ! CHECK-LABEL: func @_QPtest3(
36 ! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.type<_QMtype_defsTsimple_type{i:i32}>> {fir.bindc_name = "a", fir.target}) {
37 subroutine test3(a)
38 use type_defs
39 type(simple_type), target :: a
40 end subroutine
42 ! Test simple type explicit array with TARGET attribute.
43 ! CHECK-LABEL: func @_QPtest4(
44 ! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.array<100x!fir.type<_QMtype_defsTsimple_type{i:i32}>>> {fir.bindc_name = "a", fir.target}) {
45 subroutine test4(a)
46 use type_defs
47 type(simple_type), target :: a(100)
48 end subroutine
50 ! Test kind parametrized derived type scalar with no attribute.
51 ! CHECK-LABEL: func @_QPtest1k(
52 ! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.type<_QMtype_defsTwith_kindK4{x:f32}>> {fir.bindc_name = "a"}) {
53 subroutine test1k(a)
54 use type_defs
55 type(with_kind(4)) :: a
56 end subroutine
58 ! Test kind parametrized derived type explicit array with no attribute.
59 ! CHECK-LABEL: func @_QPtest2k(
60 ! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.array<100x!fir.type<_QMtype_defsTwith_kindK4{x:f32}>>> {fir.bindc_name = "a"}) {
61 subroutine test2k(a)
62 use type_defs
63 type(with_kind(4)) :: a(100)
64 end subroutine
66 ! Test kind parametrized derived type scalar with TARGET attribute.
67 ! CHECK-LABEL: func @_QPtest3k(
68 ! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.type<_QMtype_defsTwith_kindK4{x:f32}>> {fir.bindc_name = "a", fir.target}) {
69 subroutine test3k(a)
70 use type_defs
71 type(with_kind(4)), target :: a
72 end subroutine
74 ! Test kind parametrized derived type explicit array with TARGET attribute.
75 ! CHECK-LABEL: func @_QPtest4k(
76 ! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.array<100x!fir.type<_QMtype_defsTwith_kindK4{x:f32}>>> {fir.bindc_name = "a", fir.target}) {
77 subroutine test4k(a)
78 use type_defs
79 type(with_kind(4)), target :: a(100)
80 end subroutine
82 ! -----------------------------------------------------------------------------
83 ! Test passing of derived type arguments that require a fir.box (runtime descriptor).
84 ! -----------------------------------------------------------------------------
86 ! Test simple type assumed shape array with no attribute.
87 ! CHECK-LABEL: func @_QPtest5(
88 ! CHECK-SAME: %[[VAL_0:.*]]: !fir.box<!fir.array<?x!fir.type<_QMtype_defsTsimple_type{i:i32}>>> {fir.bindc_name = "a"}) {
89 subroutine test5(a)
90 use type_defs
91 type(simple_type) :: a(:)
92 end subroutine
94 ! Test simple type assumed shape array with TARGET attribute.
95 ! CHECK-LABEL: func @_QPtest6(
96 ! CHECK-SAME: %[[VAL_0:.*]]: !fir.box<!fir.array<?x!fir.type<_QMtype_defsTsimple_type{i:i32}>>> {fir.bindc_name = "a", fir.target}) {
97 subroutine test6(a)
98 use type_defs
99 type(simple_type), target :: a(:)
100 end subroutine
102 ! Test kind parametrized derived type assumed shape array with no attribute.
103 ! CHECK-LABEL: func @_QPtest5k(
104 ! CHECK-SAME: %[[VAL_0:.*]]: !fir.box<!fir.array<?x!fir.type<_QMtype_defsTwith_kindK4{x:f32}>>> {fir.bindc_name = "a"}) {
105 subroutine test5k(a)
106 use type_defs
107 type(with_kind(4)) :: a(:)
108 end subroutine
110 ! Test kind parametrized derived type assumed shape array with TARGET attribute.
111 ! CHECK-LABEL: func @_QPtest6k(
112 ! CHECK-SAME: %[[VAL_0:.*]]: !fir.box<!fir.array<?x!fir.type<_QMtype_defsTwith_kindK4{x:f32}>>> {fir.bindc_name = "a", fir.target}) {
113 subroutine test6k(a)
114 use type_defs
115 type(with_kind(4)), target :: a(:)
116 end subroutine