[flang][openacc] Use OpenACC terminator instead of fir.unreachable after Stop stmt...
[llvm-project.git] / flang / test / Lower / allocate-source-allocatables.f90
blob1d67eea49626a9ea4398a7330d4600f36fb92b28
1 ! RUN: bbc --use-desc-for-alloc=false -emit-fir %s -o - | FileCheck %s
3 ! Test lowering of allocatables for allocate statements with source.
5 ! CHECK-LABEL: func.func @_QPtest_allocatable_scalar(
6 ! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<f32> {fir.bindc_name = "a"}) {
7 ! CHECK: %[[VAL_1:.*]] = fir.address_of(@_QFtest_allocatable_scalarEx1) : !fir.ref<!fir.box<!fir.heap<f32>>>
8 ! CHECK: %[[VAL_2:.*]] = fir.address_of(@_QFtest_allocatable_scalarEx2) : !fir.ref<!fir.box<!fir.heap<f32>>>
9 ! CHECK: %[[VAL_3:.*]] = arith.constant false
10 ! CHECK: %[[VAL_4:.*]] = fir.absent !fir.box<none>
11 ! CHECK: %[[VAL_7:.*]] = fir.embox %[[VAL_0]] : (!fir.ref<f32>) -> !fir.box<f32>
12 ! CHECK: %[[VAL_8:.*]] = fir.convert %[[VAL_1]] : (!fir.ref<!fir.box<!fir.heap<f32>>>) -> !fir.ref<!fir.box<none>>
13 ! CHECK: %[[VAL_9:.*]] = fir.convert %[[VAL_7]] : (!fir.box<f32>) -> !fir.box<none>
14 ! CHECK: %[[VAL_11:.*]] = fir.call @_FortranAAllocatableAllocateSource(%[[VAL_8]], %[[VAL_9]], %[[VAL_3]], %[[VAL_4]], %{{.*}}, %{{.*}}) {{.*}}: (!fir.ref<!fir.box<none>>, !fir.box<none>, i1, !fir.box<none>, !fir.ref<i8>, i32) -> i32
15 ! CHECK: %[[VAL_12:.*]] = fir.convert %[[VAL_2]] : (!fir.ref<!fir.box<!fir.heap<f32>>>) -> !fir.ref<!fir.box<none>>
16 ! CHECK: %[[VAL_13:.*]] = fir.convert %[[VAL_7]] : (!fir.box<f32>) -> !fir.box<none>
17 ! CHECK: %[[VAL_15:.*]] = fir.call @_FortranAAllocatableAllocateSource(%[[VAL_12]], %[[VAL_13]], %[[VAL_3]], %[[VAL_4]], %{{.*}}, %{{.*}}) {{.*}}: (!fir.ref<!fir.box<none>>, !fir.box<none>, i1, !fir.box<none>, !fir.ref<i8>, i32) -> i32
18 ! CHECK: return
19 ! CHECK: }
21 subroutine test_allocatable_scalar(a)
22 real, save, allocatable :: x1, x2
23 real :: a
25 allocate(x1, x2, source = a)
26 end
28 ! CHECK-LABEL: func.func @_QPtest_allocatable_2d_array(
29 ! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<i32> {fir.bindc_name = "n"},
30 ! CHECK-SAME: %[[VAL_1:.*]]: !fir.ref<!fir.array<?x?xi32>> {fir.bindc_name = "a"}) {
31 ! CHECK: %[[VAL_2:.*]] = fir.alloca i32 {bindc_name = "sss", uniq_name = "_QFtest_allocatable_2d_arrayEsss"}
32 ! CHECK: %[[VAL_3:.*]] = fir.alloca !fir.box<!fir.heap<!fir.array<?x?xi32>>> {bindc_name = "x1", uniq_name = "_QFtest_allocatable_2d_arrayEx1"}
33 ! CHECK: %[[VAL_4:.*]] = fir.alloca !fir.heap<!fir.array<?x?xi32>> {uniq_name = "_QFtest_allocatable_2d_arrayEx1.addr"}
34 ! CHECK: %[[VAL_5:.*]] = fir.alloca index {uniq_name = "_QFtest_allocatable_2d_arrayEx1.lb0"}
35 ! CHECK: %[[VAL_6:.*]] = fir.alloca index {uniq_name = "_QFtest_allocatable_2d_arrayEx1.ext0"}
36 ! CHECK: %[[VAL_7:.*]] = fir.alloca index {uniq_name = "_QFtest_allocatable_2d_arrayEx1.lb1"}
37 ! CHECK: %[[VAL_8:.*]] = fir.alloca index {uniq_name = "_QFtest_allocatable_2d_arrayEx1.ext1"}
38 ! CHECK: %[[VAL_9:.*]] = fir.zero_bits !fir.heap<!fir.array<?x?xi32>>
39 ! CHECK: fir.store %[[VAL_9]] to %[[VAL_4]] : !fir.ref<!fir.heap<!fir.array<?x?xi32>>>
40 ! CHECK: %[[VAL_10:.*]] = fir.alloca !fir.box<!fir.heap<!fir.array<?x?xi32>>> {bindc_name = "x2", uniq_name = "_QFtest_allocatable_2d_arrayEx2"}
41 ! CHECK: %[[VAL_17:.*]] = fir.alloca !fir.box<!fir.heap<!fir.array<?x?xi32>>> {bindc_name = "x3", uniq_name = "_QFtest_allocatable_2d_arrayEx3"}
42 ! CHECK: %[[VAL_24:.*]] = fir.load %[[VAL_0]] : !fir.ref<i32>
43 ! CHECK: %[[VAL_25:.*]] = fir.convert %[[VAL_24]] : (i32) -> i64
44 ! CHECK: %[[VAL_26:.*]] = fir.convert %[[VAL_25]] : (i64) -> index
45 ! CHECK: %[[VAL_27:.*]] = arith.constant 0 : index
46 ! CHECK: %[[VAL_28:.*]] = arith.cmpi sgt, %[[VAL_26]], %[[VAL_27]] : index
47 ! CHECK: %[[VAL_29:.*]] = arith.select %[[VAL_28]], %[[VAL_26]], %[[VAL_27]] : index
48 ! CHECK: %[[VAL_30:.*]] = fir.load %[[VAL_0]] : !fir.ref<i32>
49 ! CHECK: %[[VAL_31:.*]] = fir.convert %[[VAL_30]] : (i32) -> i64
50 ! CHECK: %[[VAL_32:.*]] = fir.convert %[[VAL_31]] : (i64) -> index
51 ! CHECK: %[[VAL_33:.*]] = arith.constant 0 : index
52 ! CHECK: %[[VAL_34:.*]] = arith.cmpi sgt, %[[VAL_32]], %[[VAL_33]] : index
53 ! CHECK: %[[VAL_35:.*]] = arith.select %[[VAL_34]], %[[VAL_32]], %[[VAL_33]] : index
54 ! CHECK: %[[VAL_36:.*]] = arith.constant false
55 ! CHECK: %[[VAL_37:.*]] = fir.absent !fir.box<none>
56 ! CHECK: %[[VAL_40:.*]] = fir.shape %[[VAL_29]], %[[VAL_35]] : (index, index) -> !fir.shape<2>
57 ! CHECK: %[[VAL_41:.*]] = fir.embox %[[VAL_1]](%[[VAL_40]]) : (!fir.ref<!fir.array<?x?xi32>>, !fir.shape<2>) -> !fir.box<!fir.array<?x?xi32>>
58 ! CHECK: %[[VAL_42:.*]] = fir.load %[[VAL_5]] : !fir.ref<index>
59 ! CHECK: %[[VAL_43:.*]] = fir.load %[[VAL_6]] : !fir.ref<index>
60 ! CHECK: %[[VAL_44:.*]] = fir.load %[[VAL_7]] : !fir.ref<index>
61 ! CHECK: %[[VAL_45:.*]] = fir.load %[[VAL_8]] : !fir.ref<index>
62 ! CHECK: %[[VAL_46:.*]] = fir.load %[[VAL_4]] : !fir.ref<!fir.heap<!fir.array<?x?xi32>>>
63 ! CHECK: %[[VAL_47:.*]] = fir.shape_shift %[[VAL_42]], %[[VAL_43]], %[[VAL_44]], %[[VAL_45]] : (index, index, index, index) -> !fir.shapeshift<2>
64 ! CHECK: %[[VAL_48:.*]] = fir.embox %[[VAL_46]](%[[VAL_47]]) : (!fir.heap<!fir.array<?x?xi32>>, !fir.shapeshift<2>) -> !fir.box<!fir.heap<!fir.array<?x?xi32>>>
65 ! CHECK: fir.store %[[VAL_48]] to %[[VAL_3]] : !fir.ref<!fir.box<!fir.heap<!fir.array<?x?xi32>>>>
66 ! CHECK: %[[VAL_49:.*]] = arith.constant 1 : index
67 ! CHECK: %[[VAL_50:.*]] = arith.constant 0 : index
68 ! CHECK: %[[VAL_51:.*]]:3 = fir.box_dims %[[VAL_41]], %[[VAL_50]] : (!fir.box<!fir.array<?x?xi32>>, index) -> (index, index, index)
69 ! CHECK: %[[VAL_52:.*]] = arith.addi %[[VAL_51]]#1, %[[VAL_49]] : index
70 ! CHECK: %[[VAL_53:.*]] = arith.subi %[[VAL_52]], %[[VAL_49]] : index
71 ! CHECK: %[[VAL_54:.*]] = arith.constant 0 : i32
72 ! CHECK: %[[VAL_55:.*]] = fir.convert %[[VAL_3]] : (!fir.ref<!fir.box<!fir.heap<!fir.array<?x?xi32>>>>) -> !fir.ref<!fir.box<none>>
73 ! CHECK: %[[VAL_56:.*]] = fir.convert %[[VAL_49]] : (index) -> i64
74 ! CHECK: %[[VAL_57:.*]] = fir.convert %[[VAL_53]] : (index) -> i64
75 ! CHECK: %[[VAL_58:.*]] = fir.call @_FortranAAllocatableSetBounds(%[[VAL_55]], %[[VAL_54]], %[[VAL_56]], %[[VAL_57]]) {{.*}}: (!fir.ref<!fir.box<none>>, i32, i64, i64) -> none
76 ! CHECK: %[[VAL_59:.*]] = arith.constant 1 : index
77 ! CHECK: %[[VAL_60:.*]]:3 = fir.box_dims %[[VAL_41]], %[[VAL_59]] : (!fir.box<!fir.array<?x?xi32>>, index) -> (index, index, index)
78 ! CHECK: %[[VAL_61:.*]] = arith.addi %[[VAL_60]]#1, %[[VAL_49]] : index
79 ! CHECK: %[[VAL_62:.*]] = arith.subi %[[VAL_61]], %[[VAL_49]] : index
80 ! CHECK: %[[VAL_63:.*]] = arith.constant 1 : i32
81 ! CHECK: %[[VAL_64:.*]] = fir.convert %[[VAL_3]] : (!fir.ref<!fir.box<!fir.heap<!fir.array<?x?xi32>>>>) -> !fir.ref<!fir.box<none>>
82 ! CHECK: %[[VAL_65:.*]] = fir.convert %[[VAL_49]] : (index) -> i64
83 ! CHECK: %[[VAL_66:.*]] = fir.convert %[[VAL_62]] : (index) -> i64
84 ! CHECK: %[[VAL_67:.*]] = fir.call @_FortranAAllocatableSetBounds(%[[VAL_64]], %[[VAL_63]], %[[VAL_65]], %[[VAL_66]]) {{.*}}: (!fir.ref<!fir.box<none>>, i32, i64, i64) -> none
85 ! CHECK: %[[VAL_68:.*]] = fir.convert %[[VAL_3]] : (!fir.ref<!fir.box<!fir.heap<!fir.array<?x?xi32>>>>) -> !fir.ref<!fir.box<none>>
86 ! CHECK: %[[VAL_69:.*]] = fir.convert %[[VAL_41]] : (!fir.box<!fir.array<?x?xi32>>) -> !fir.box<none>
87 ! CHECK: %[[VAL_71:.*]] = fir.call @_FortranAAllocatableAllocateSource(%[[VAL_68]], %[[VAL_69]], %[[VAL_36]], %[[VAL_37]], %{{.*}}, %{{.*}}) {{.*}}: (!fir.ref<!fir.box<none>>, !fir.box<none>, i1, !fir.box<none>, !fir.ref<i8>, i32) -> i32
88 ! CHECK: %[[VAL_94:.*]] = fir.call @_FortranAAllocatableSetBounds(
89 ! CHECK: %[[VAL_103:.*]] = fir.call @_FortranAAllocatableSetBounds(
90 ! CHECK: %[[VAL_107:.*]] = fir.call @_FortranAAllocatableAllocateSource(
91 ! CHECK: %[[VAL_114:.*]] = arith.constant true
92 ! CHECK: %[[VAL_149:.*]] = fir.call @_FortranAAllocatableSetBounds(
93 ! CHECK: %[[VAL_158:.*]] = fir.call @_FortranAAllocatableSetBounds(
94 ! CHECK: %[[VAL_162:.*]] = fir.call @_FortranAAllocatableAllocateSource(%{{.*}}, %{{.*}}, %[[VAL_114]]
96 subroutine test_allocatable_2d_array(n, a)
97 integer, allocatable :: x1(:,:), x2(:,:), x3(:,:)
98 integer :: n, sss, a(n, n)
100 allocate(x1, x2, source = a)
101 allocate(x3, source = a(1:3:2, 2:3), stat=sss)
104 ! CHECK-LABEL: func.func @_QPtest_allocatable_with_shapespec(
105 ! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<i32> {fir.bindc_name = "n"},
106 ! CHECK-SAME: %[[VAL_1:.*]]: !fir.ref<!fir.array<?xi32>> {fir.bindc_name = "a"},
107 ! CHECK-SAME: %[[VAL_2:.*]]: !fir.ref<i32> {fir.bindc_name = "m"}) {
108 ! CHECK: %[[VAL_3:.*]] = fir.alloca !fir.box<!fir.heap<!fir.array<?xi32>>> {bindc_name = "x1", uniq_name = "_QFtest_allocatable_with_shapespecEx1"}
109 ! CHECK: %[[VAL_4:.*]] = fir.alloca !fir.heap<!fir.array<?xi32>> {uniq_name = "_QFtest_allocatable_with_shapespecEx1.addr"}
110 ! CHECK: %[[VAL_5:.*]] = fir.alloca index {uniq_name = "_QFtest_allocatable_with_shapespecEx1.lb0"}
111 ! CHECK: %[[VAL_6:.*]] = fir.alloca index {uniq_name = "_QFtest_allocatable_with_shapespecEx1.ext0"}
112 ! CHECK: %[[VAL_7:.*]] = fir.zero_bits !fir.heap<!fir.array<?xi32>>
113 ! CHECK: fir.store %[[VAL_7]] to %[[VAL_4]] : !fir.ref<!fir.heap<!fir.array<?xi32>>>
114 ! CHECK: %[[VAL_8:.*]] = fir.alloca !fir.box<!fir.heap<!fir.array<?xi32>>> {bindc_name = "x2", uniq_name = "_QFtest_allocatable_with_shapespecEx2"}
115 ! CHECK: %[[VAL_9:.*]] = fir.alloca !fir.heap<!fir.array<?xi32>> {uniq_name = "_QFtest_allocatable_with_shapespecEx2.addr"}
116 ! CHECK: %[[VAL_10:.*]] = fir.alloca index {uniq_name = "_QFtest_allocatable_with_shapespecEx2.lb0"}
117 ! CHECK: %[[VAL_11:.*]] = fir.alloca index {uniq_name = "_QFtest_allocatable_with_shapespecEx2.ext0"}
118 ! CHECK: %[[VAL_12:.*]] = fir.zero_bits !fir.heap<!fir.array<?xi32>>
119 ! CHECK: fir.store %[[VAL_12]] to %[[VAL_9]] : !fir.ref<!fir.heap<!fir.array<?xi32>>>
120 ! CHECK: %[[VAL_13:.*]] = fir.load %[[VAL_0]] : !fir.ref<i32>
121 ! CHECK: %[[VAL_14:.*]] = fir.convert %[[VAL_13]] : (i32) -> i64
122 ! CHECK: %[[VAL_15:.*]] = fir.convert %[[VAL_14]] : (i64) -> index
123 ! CHECK: %[[VAL_16:.*]] = arith.constant 0 : index
124 ! CHECK: %[[VAL_17:.*]] = arith.cmpi sgt, %[[VAL_15]], %[[VAL_16]] : index
125 ! CHECK: %[[VAL_18:.*]] = arith.select %[[VAL_17]], %[[VAL_15]], %[[VAL_16]] : index
126 ! CHECK: %[[VAL_19:.*]] = arith.constant false
127 ! CHECK: %[[VAL_20:.*]] = fir.absent !fir.box<none>
128 ! CHECK: %[[VAL_23:.*]] = fir.shape %[[VAL_18]] : (index) -> !fir.shape<1>
129 ! CHECK: %[[VAL_24:.*]] = fir.embox %[[VAL_1]](%[[VAL_23]]) : (!fir.ref<!fir.array<?xi32>>, !fir.shape<1>) -> !fir.box<!fir.array<?xi32>>
130 ! CHECK: %[[VAL_25:.*]] = fir.load %[[VAL_5]] : !fir.ref<index>
131 ! CHECK: %[[VAL_26:.*]] = fir.load %[[VAL_6]] : !fir.ref<index>
132 ! CHECK: %[[VAL_27:.*]] = fir.load %[[VAL_4]] : !fir.ref<!fir.heap<!fir.array<?xi32>>>
133 ! CHECK: %[[VAL_28:.*]] = fir.shape_shift %[[VAL_25]], %[[VAL_26]] : (index, index) -> !fir.shapeshift<1>
134 ! CHECK: %[[VAL_29:.*]] = fir.embox %[[VAL_27]](%[[VAL_28]]) : (!fir.heap<!fir.array<?xi32>>, !fir.shapeshift<1>) -> !fir.box<!fir.heap<!fir.array<?xi32>>>
135 ! CHECK: fir.store %[[VAL_29]] to %[[VAL_3]] : !fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>>
136 ! CHECK: %[[VAL_30:.*]] = arith.constant 2 : i32
137 ! CHECK: %[[VAL_31:.*]] = fir.load %[[VAL_2]] : !fir.ref<i32>
138 ! CHECK: %[[VAL_32:.*]] = arith.constant 0 : i32
139 ! CHECK: %[[VAL_33:.*]] = fir.convert %[[VAL_3]] : (!fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>>) -> !fir.ref<!fir.box<none>>
140 ! CHECK: %[[VAL_34:.*]] = fir.convert %[[VAL_30]] : (i32) -> i64
141 ! CHECK: %[[VAL_35:.*]] = fir.convert %[[VAL_31]] : (i32) -> i64
142 ! CHECK: %[[VAL_36:.*]] = fir.call @_FortranAAllocatableSetBounds(%[[VAL_33]], %[[VAL_32]], %[[VAL_34]], %[[VAL_35]]) {{.*}}: (!fir.ref<!fir.box<none>>, i32, i64, i64) -> none
143 ! CHECK: %[[VAL_37:.*]] = fir.convert %[[VAL_3]] : (!fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>>) -> !fir.ref<!fir.box<none>>
144 ! CHECK: %[[VAL_38:.*]] = fir.convert %[[VAL_24]] : (!fir.box<!fir.array<?xi32>>) -> !fir.box<none>
145 ! CHECK: %[[VAL_40:.*]] = fir.call @_FortranAAllocatableAllocateSource(%[[VAL_37]], %[[VAL_38]], %[[VAL_19]], %[[VAL_20]], %{{.*}}, %{{.*}}) {{.*}}: (!fir.ref<!fir.box<none>>, !fir.box<none>, i1, !fir.box<none>, !fir.ref<i8>, i32) -> i32
146 ! CHECK: %[[VAL_41:.*]] = fir.load %[[VAL_3]] : !fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>>
147 ! CHECK: %[[VAL_42:.*]] = arith.constant 0 : index
148 ! CHECK: %[[VAL_43:.*]]:3 = fir.box_dims %[[VAL_41]], %[[VAL_42]] : (!fir.box<!fir.heap<!fir.array<?xi32>>>, index) -> (index, index, index)
149 ! CHECK: %[[VAL_44:.*]] = fir.box_addr %[[VAL_41]] : (!fir.box<!fir.heap<!fir.array<?xi32>>>) -> !fir.heap<!fir.array<?xi32>>
150 ! CHECK: fir.store %[[VAL_44]] to %[[VAL_4]] : !fir.ref<!fir.heap<!fir.array<?xi32>>>
151 ! CHECK: fir.store %[[VAL_43]]#1 to %[[VAL_6]] : !fir.ref<index>
152 ! CHECK: fir.store %[[VAL_43]]#0 to %[[VAL_5]] : !fir.ref<index>
153 ! CHECK: %[[VAL_45:.*]] = fir.load %[[VAL_10]] : !fir.ref<index>
154 ! CHECK: %[[VAL_46:.*]] = fir.load %[[VAL_11]] : !fir.ref<index>
155 ! CHECK: %[[VAL_47:.*]] = fir.load %[[VAL_9]] : !fir.ref<!fir.heap<!fir.array<?xi32>>>
156 ! CHECK: %[[VAL_48:.*]] = fir.shape_shift %[[VAL_45]], %[[VAL_46]] : (index, index) -> !fir.shapeshift<1>
157 ! CHECK: %[[VAL_49:.*]] = fir.embox %[[VAL_47]](%[[VAL_48]]) : (!fir.heap<!fir.array<?xi32>>, !fir.shapeshift<1>) -> !fir.box<!fir.heap<!fir.array<?xi32>>>
158 ! CHECK: fir.store %[[VAL_49]] to %[[VAL_8]] : !fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>>
159 ! CHECK: %[[VAL_50:.*]] = arith.constant 1 : index
160 ! CHECK: %[[VAL_51:.*]] = fir.load %[[VAL_0]] : !fir.ref<i32>
161 ! CHECK: %[[VAL_52:.*]] = arith.constant 0 : i32
162 ! CHECK: %[[VAL_53:.*]] = fir.convert %[[VAL_8]] : (!fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>>) -> !fir.ref<!fir.box<none>>
163 ! CHECK: %[[VAL_54:.*]] = fir.convert %[[VAL_50]] : (index) -> i64
164 ! CHECK: %[[VAL_55:.*]] = fir.convert %[[VAL_51]] : (i32) -> i64
165 ! CHECK: %[[VAL_56:.*]] = fir.call @_FortranAAllocatableSetBounds(%[[VAL_53]], %[[VAL_52]], %[[VAL_54]], %[[VAL_55]]) {{.*}}: (!fir.ref<!fir.box<none>>, i32, i64, i64) -> none
166 ! CHECK: %[[VAL_57:.*]] = fir.convert %[[VAL_8]] : (!fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>>) -> !fir.ref<!fir.box<none>>
167 ! CHECK: %[[VAL_58:.*]] = fir.convert %[[VAL_24]] : (!fir.box<!fir.array<?xi32>>) -> !fir.box<none>
168 ! CHECK: %[[VAL_60:.*]] = fir.call @_FortranAAllocatableAllocateSource(%[[VAL_57]], %[[VAL_58]], %[[VAL_19]], %[[VAL_20]], %{{.*}}, %{{.*}}) {{.*}}: (!fir.ref<!fir.box<none>>, !fir.box<none>, i1, !fir.box<none>, !fir.ref<i8>, i32) -> i32
170 subroutine test_allocatable_with_shapespec(n, a, m)
171 integer, allocatable :: x1(:), x2(:)
172 integer :: n, m, a(n)
174 allocate(x1(2:m), x2(n), source = a)
177 ! CHECK-LABEL: func.func @_QPtest_allocatable_from_const(
178 ! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<i32> {fir.bindc_name = "n"},
179 ! CHECK-SAME: %[[VAL_1:.*]]: !fir.ref<!fir.array<?xi32>> {fir.bindc_name = "a"}) {
180 ! CHECK: %[[VAL_2:.*]] = fir.alloca !fir.box<!fir.heap<!fir.array<?xi32>>> {bindc_name = "x1", uniq_name = "_QFtest_allocatable_from_constEx1"}
181 ! CHECK: %[[VAL_3:.*]] = fir.alloca !fir.heap<!fir.array<?xi32>> {uniq_name = "_QFtest_allocatable_from_constEx1.addr"}
182 ! CHECK: %[[VAL_4:.*]] = fir.alloca index {uniq_name = "_QFtest_allocatable_from_constEx1.lb0"}
183 ! CHECK: %[[VAL_5:.*]] = fir.alloca index {uniq_name = "_QFtest_allocatable_from_constEx1.ext0"}
184 ! CHECK: %[[VAL_6:.*]] = fir.zero_bits !fir.heap<!fir.array<?xi32>>
185 ! CHECK: fir.store %[[VAL_6]] to %[[VAL_3]] : !fir.ref<!fir.heap<!fir.array<?xi32>>>
186 ! CHECK: %[[VAL_7:.*]] = arith.constant false
187 ! CHECK: %[[VAL_8:.*]] = fir.absent !fir.box<none>
188 ! CHECK: %[[VAL_11:.*]] = arith.constant 5 : index
189 ! CHECK: %[[VAL_13:.*]] = arith.constant 5 : index
190 ! CHECK: %[[VAL_14:.*]] = fir.shape %[[VAL_13]] : (index) -> !fir.shape<1>
191 ! CHECK: %[[VAL_15:.*]] = fir.array_load %[[VAL_12:.*]](%[[VAL_14]]) : (!fir.ref<!fir.array<5xi32>>, !fir.shape<1>) -> !fir.array<5xi32>
192 ! CHECK: %[[VAL_16:.*]] = fir.allocmem !fir.array<5xi32>
193 ! CHECK: %[[VAL_17:.*]] = fir.shape %[[VAL_11]] : (index) -> !fir.shape<1>
194 ! CHECK: %[[VAL_18:.*]] = fir.array_load %[[VAL_16]](%[[VAL_17]]) : (!fir.heap<!fir.array<5xi32>>, !fir.shape<1>) -> !fir.array<5xi32>
195 ! CHECK: %[[VAL_19:.*]] = arith.constant 1 : index
196 ! CHECK: %[[VAL_20:.*]] = arith.constant 0 : index
197 ! CHECK: %[[VAL_21:.*]] = arith.subi %[[VAL_11]], %[[VAL_19]] : index
198 ! CHECK: %[[VAL_27:.*]] = fir.do_loop %[[VAL_23:.*]] = %[[VAL_20]] to %[[VAL_21]] step %[[VAL_19]] unordered iter_args(%[[VAL_24:.*]] = %[[VAL_18]]) -> (!fir.array<5xi32>) {
199 ! CHECK: %[[VAL_25:.*]] = fir.array_fetch %[[VAL_15]], %[[VAL_23]] : (!fir.array<5xi32>, index) -> i32
200 ! CHECK: %[[VAL_26:.*]] = fir.array_update %[[VAL_24]], %[[VAL_25]], %[[VAL_23]] : (!fir.array<5xi32>, i32, index) -> !fir.array<5xi32>
201 ! CHECK: fir.result %[[VAL_26]] : !fir.array<5xi32>
202 ! CHECK: }
203 ! CHECK: fir.array_merge_store %[[VAL_18]], %[[VAL_27]] to %[[VAL_16]] : !fir.array<5xi32>, !fir.array<5xi32>, !fir.heap<!fir.array<5xi32>>
204 ! CHECK: %[[VAL_28:.*]] = fir.shape %[[VAL_11]] : (index) -> !fir.shape<1>
205 ! CHECK: %[[VAL_29:.*]] = fir.embox %[[VAL_16]](%[[VAL_28]]) : (!fir.heap<!fir.array<5xi32>>, !fir.shape<1>) -> !fir.box<!fir.array<5xi32>>
206 ! CHECK: %[[VAL_30:.*]] = fir.load %[[VAL_4]] : !fir.ref<index>
207 ! CHECK: %[[VAL_31:.*]] = fir.load %[[VAL_5]] : !fir.ref<index>
208 ! CHECK: %[[VAL_32:.*]] = fir.load %[[VAL_3]] : !fir.ref<!fir.heap<!fir.array<?xi32>>>
209 ! CHECK: %[[VAL_33:.*]] = fir.shape_shift %[[VAL_30]], %[[VAL_31]] : (index, index) -> !fir.shapeshift<1>
210 ! CHECK: %[[VAL_34:.*]] = fir.embox %[[VAL_32]](%[[VAL_33]]) : (!fir.heap<!fir.array<?xi32>>, !fir.shapeshift<1>) -> !fir.box<!fir.heap<!fir.array<?xi32>>>
211 ! CHECK: fir.store %[[VAL_34]] to %[[VAL_2]] : !fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>>
212 ! CHECK: %[[VAL_35:.*]] = arith.constant 1 : index
213 ! CHECK: %[[VAL_36:.*]] = arith.constant 0 : index
214 ! CHECK: %[[VAL_37:.*]]:3 = fir.box_dims %[[VAL_29]], %[[VAL_36]] : (!fir.box<!fir.array<5xi32>>, index) -> (index, index, index)
215 ! CHECK: %[[VAL_38:.*]] = arith.addi %[[VAL_37]]#1, %[[VAL_35]] : index
216 ! CHECK: %[[VAL_39:.*]] = arith.subi %[[VAL_38]], %[[VAL_35]] : index
217 ! CHECK: %[[VAL_40:.*]] = arith.constant 0 : i32
218 ! CHECK: %[[VAL_41:.*]] = fir.convert %[[VAL_2]] : (!fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>>) -> !fir.ref<!fir.box<none>>
219 ! CHECK: %[[VAL_42:.*]] = fir.convert %[[VAL_35]] : (index) -> i64
220 ! CHECK: %[[VAL_43:.*]] = fir.convert %[[VAL_39]] : (index) -> i64
221 ! CHECK: %[[VAL_44:.*]] = fir.call @_FortranAAllocatableSetBounds(%[[VAL_41]], %[[VAL_40]], %[[VAL_42]], %[[VAL_43]]) {{.*}}: (!fir.ref<!fir.box<none>>, i32, i64, i64) -> none
222 ! CHECK: %[[VAL_45:.*]] = fir.convert %[[VAL_2]] : (!fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>>) -> !fir.ref<!fir.box<none>>
223 ! CHECK: %[[VAL_46:.*]] = fir.convert %[[VAL_29]] : (!fir.box<!fir.array<5xi32>>) -> !fir.box<none>
224 ! CHECK: %[[VAL_48:.*]] = fir.call @_FortranAAllocatableAllocateSource(%[[VAL_45]], %[[VAL_46]], %[[VAL_7]], %[[VAL_8]], %{{.*}}, %{{.*}}) {{.*}}: (!fir.ref<!fir.box<none>>, !fir.box<none>, i1, !fir.box<none>, !fir.ref<i8>, i32) -> i32
225 ! CHECK: %[[VAL_49:.*]] = fir.load %[[VAL_2]] : !fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>>
226 ! CHECK: %[[VAL_50:.*]] = arith.constant 0 : index
227 ! CHECK: %[[VAL_51:.*]]:3 = fir.box_dims %[[VAL_49]], %[[VAL_50]] : (!fir.box<!fir.heap<!fir.array<?xi32>>>, index) -> (index, index, index)
228 ! CHECK: %[[VAL_52:.*]] = fir.box_addr %[[VAL_49]] : (!fir.box<!fir.heap<!fir.array<?xi32>>>) -> !fir.heap<!fir.array<?xi32>>
229 ! CHECK: fir.store %[[VAL_52]] to %[[VAL_3]] : !fir.ref<!fir.heap<!fir.array<?xi32>>>
230 ! CHECK: fir.store %[[VAL_51]]#1 to %[[VAL_5]] : !fir.ref<index>
231 ! CHECK: fir.store %[[VAL_51]]#0 to %[[VAL_4]] : !fir.ref<index>
232 ! CHECK: fir.freemem %[[VAL_16]] : !fir.heap<!fir.array<5xi32>>
233 ! CHECK: return
234 ! CHECK: }
236 subroutine test_allocatable_from_const(n, a)
237 integer, allocatable :: x1(:)
238 integer :: n, a(n)
240 allocate(x1, source = [1, 2, 3, 4, 5])
243 ! CHECK-LABEL: func.func @_QPtest_allocatable_chararray(
244 ! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<i32> {fir.bindc_name = "n"},
245 ! CHECK-SAME: %[[VAL_1:.*]]: !fir.boxchar<1> {fir.bindc_name = "a"}) {
246 ! CHECK: %[[VAL_2:.*]] = fir.alloca !fir.box<!fir.heap<!fir.array<?x!fir.char<1,4>>>> {bindc_name = "x1", uniq_name = "_QFtest_allocatable_chararrayEx1"}
247 ! CHECK: %[[VAL_3:.*]] = fir.alloca !fir.heap<!fir.array<?x!fir.char<1,4>>> {uniq_name = "_QFtest_allocatable_chararrayEx1.addr"}
248 ! CHECK: %[[VAL_4:.*]] = fir.alloca index {uniq_name = "_QFtest_allocatable_chararrayEx1.lb0"}
249 ! CHECK: %[[VAL_5:.*]] = fir.alloca index {uniq_name = "_QFtest_allocatable_chararrayEx1.ext0"}
250 ! CHECK: %[[VAL_6:.*]] = fir.zero_bits !fir.heap<!fir.array<?x!fir.char<1,4>>>
251 ! CHECK: fir.store %[[VAL_6]] to %[[VAL_3]] : !fir.ref<!fir.heap<!fir.array<?x!fir.char<1,4>>>>
252 ! CHECK: %[[VAL_7:.*]]:2 = fir.unboxchar %[[VAL_1]] : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
253 ! CHECK: %[[VAL_8:.*]] = fir.convert %[[VAL_7]]#0 : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<?x!fir.char<1,?>>>
254 ! CHECK: %[[VAL_9:.*]] = fir.load %[[VAL_0]] : !fir.ref<i32>
255 ! CHECK: %[[VAL_10:.*]] = fir.convert %[[VAL_9]] : (i32) -> i64
256 ! CHECK: %[[VAL_11:.*]] = fir.convert %[[VAL_10]] : (i64) -> index
257 ! CHECK: %[[VAL_12:.*]] = arith.constant 0 : index
258 ! CHECK: %[[VAL_13:.*]] = arith.cmpi sgt, %[[VAL_11]], %[[VAL_12]] : index
259 ! CHECK: %[[VAL_14:.*]] = arith.select %[[VAL_13]], %[[VAL_11]], %[[VAL_12]] : index
260 ! CHECK: %[[VAL_15:.*]] = arith.constant false
261 ! CHECK: %[[VAL_16:.*]] = fir.absent !fir.box<none>
262 ! CHECK: %[[VAL_19:.*]] = fir.shape %[[VAL_14]] : (index) -> !fir.shape<1>
263 ! CHECK: %[[VAL_20:.*]] = fir.embox %[[VAL_8]](%[[VAL_19]]) typeparams %[[VAL_7]]#1 : (!fir.ref<!fir.array<?x!fir.char<1,?>>>, !fir.shape<1>, index) -> !fir.box<!fir.array<?x!fir.char<1,?>>>
264 ! CHECK: %[[VAL_21:.*]] = fir.load %[[VAL_4]] : !fir.ref<index>
265 ! CHECK: %[[VAL_22:.*]] = fir.load %[[VAL_5]] : !fir.ref<index>
266 ! CHECK: %[[VAL_23:.*]] = fir.load %[[VAL_3]] : !fir.ref<!fir.heap<!fir.array<?x!fir.char<1,4>>>>
267 ! CHECK: %[[VAL_24:.*]] = fir.shape_shift %[[VAL_21]], %[[VAL_22]] : (index, index) -> !fir.shapeshift<1>
268 ! CHECK: %[[VAL_25:.*]] = fir.embox %[[VAL_23]](%[[VAL_24]]) : (!fir.heap<!fir.array<?x!fir.char<1,4>>>, !fir.shapeshift<1>) -> !fir.box<!fir.heap<!fir.array<?x!fir.char<1,4>>>>
269 ! CHECK: fir.store %[[VAL_25]] to %[[VAL_2]] : !fir.ref<!fir.box<!fir.heap<!fir.array<?x!fir.char<1,4>>>>>
270 ! CHECK: %[[VAL_26:.*]] = arith.constant 1 : index
271 ! CHECK: %[[VAL_27:.*]] = arith.constant 0 : index
272 ! CHECK: %[[VAL_28:.*]]:3 = fir.box_dims %[[VAL_20]], %[[VAL_27]] : (!fir.box<!fir.array<?x!fir.char<1,?>>>, index) -> (index, index, index)
273 ! CHECK: %[[VAL_29:.*]] = arith.addi %[[VAL_28]]#1, %[[VAL_26]] : index
274 ! CHECK: %[[VAL_30:.*]] = arith.subi %[[VAL_29]], %[[VAL_26]] : index
275 ! CHECK: %[[VAL_31:.*]] = arith.constant 0 : i32
276 ! CHECK: %[[VAL_32:.*]] = fir.convert %[[VAL_2]] : (!fir.ref<!fir.box<!fir.heap<!fir.array<?x!fir.char<1,4>>>>>) -> !fir.ref<!fir.box<none>>
277 ! CHECK: %[[VAL_33:.*]] = fir.convert %[[VAL_26]] : (index) -> i64
278 ! CHECK: %[[VAL_34:.*]] = fir.convert %[[VAL_30]] : (index) -> i64
279 ! CHECK: %[[VAL_35:.*]] = fir.call @_FortranAAllocatableSetBounds(%[[VAL_32]], %[[VAL_31]], %[[VAL_33]], %[[VAL_34]]) {{.*}}: (!fir.ref<!fir.box<none>>, i32, i64, i64) -> none
280 ! CHECK: %[[VAL_36:.*]] = fir.convert %[[VAL_2]] : (!fir.ref<!fir.box<!fir.heap<!fir.array<?x!fir.char<1,4>>>>>) -> !fir.ref<!fir.box<none>>
281 ! CHECK: %[[VAL_37:.*]] = fir.convert %[[VAL_20]] : (!fir.box<!fir.array<?x!fir.char<1,?>>>) -> !fir.box<none>
282 ! CHECK: %[[VAL_39:.*]] = fir.call @_FortranAAllocatableAllocateSource(%[[VAL_36]], %[[VAL_37]], %[[VAL_15]], %[[VAL_16]], %{{.*}}, %{{.*}}) {{.*}}: (!fir.ref<!fir.box<none>>, !fir.box<none>, i1, !fir.box<none>, !fir.ref<i8>, i32) -> i32
284 subroutine test_allocatable_chararray(n, a)
285 character(4), allocatable :: x1(:)
286 integer :: n
287 character(*) :: a(n)
289 allocate(x1, source = a)
292 ! CHECK-LABEL: func.func @_QPtest_allocatable_char(
293 ! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<i32> {fir.bindc_name = "n"},
294 ! CHECK-SAME: %[[VAL_1:.*]]: !fir.boxchar<1> {fir.bindc_name = "a"}) {
295 ! CHECK: %[[VAL_2:.*]]:2 = fir.unboxchar %[[VAL_1]] : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
296 ! CHECK: %[[VAL_3:.*]] = fir.alloca !fir.box<!fir.heap<!fir.char<1,?>>> {bindc_name = "x1", uniq_name = "_QFtest_allocatable_charEx1"}
297 ! CHECK: %[[VAL_4:.*]] = fir.alloca !fir.heap<!fir.char<1,?>> {uniq_name = "_QFtest_allocatable_charEx1.addr"}
298 ! CHECK: %[[VAL_5:.*]] = fir.alloca index {uniq_name = "_QFtest_allocatable_charEx1.len"}
299 ! CHECK: %[[VAL_6:.*]] = fir.zero_bits !fir.heap<!fir.char<1,?>>
300 ! CHECK: fir.store %[[VAL_6]] to %[[VAL_4]] : !fir.ref<!fir.heap<!fir.char<1,?>>>
301 ! CHECK: %[[VAL_7:.*]] = arith.constant false
302 ! CHECK: %[[VAL_8:.*]] = fir.absent !fir.box<none>
303 ! CHECK: %[[VAL_11:.*]] = fir.embox %[[VAL_2]]#0 typeparams %[[VAL_2]]#1 : (!fir.ref<!fir.char<1,?>>, index) -> !fir.box<!fir.char<1,?>>
304 ! CHECK: %[[VAL_12:.*]] = fir.load %[[VAL_5]] : !fir.ref<index>
305 ! CHECK: %[[VAL_13:.*]] = fir.load %[[VAL_4]] : !fir.ref<!fir.heap<!fir.char<1,?>>>
306 ! CHECK: %[[VAL_14:.*]] = fir.embox %[[VAL_13]] typeparams %[[VAL_12]] : (!fir.heap<!fir.char<1,?>>, index) -> !fir.box<!fir.heap<!fir.char<1,?>>>
307 ! CHECK: fir.store %[[VAL_14]] to %[[VAL_3]] : !fir.ref<!fir.box<!fir.heap<!fir.char<1,?>>>>
308 ! CHECK: %[[VAL_15:.*]] = fir.box_elesize %[[VAL_11]] : (!fir.box<!fir.char<1,?>>) -> index
309 ! CHECK: %[[VAL_16:.*]] = fir.convert %[[VAL_3]] : (!fir.ref<!fir.box<!fir.heap<!fir.char<1,?>>>>) -> !fir.ref<!fir.box<none>>
310 ! CHECK: %[[VAL_17:.*]] = fir.convert %[[VAL_15]] : (index) -> i64
311 ! CHECK: %[[VAL_18:.*]] = arith.constant 1 : i32
312 ! CHECK: %[[VAL_19:.*]] = arith.constant 0 : i32
313 ! CHECK: %[[VAL_20:.*]] = arith.constant 0 : i32
314 ! CHECK: %[[VAL_21:.*]] = fir.call @_FortranAAllocatableInitCharacterForAllocate(%[[VAL_16]], %[[VAL_17]], %[[VAL_18]], %[[VAL_19]], %[[VAL_20]]) {{.*}}: (!fir.ref<!fir.box<none>>, i64, i32, i32, i32) -> none
315 ! CHECK: %[[VAL_22:.*]] = fir.convert %[[VAL_3]] : (!fir.ref<!fir.box<!fir.heap<!fir.char<1,?>>>>) -> !fir.ref<!fir.box<none>>
316 ! CHECK: %[[VAL_23:.*]] = fir.convert %[[VAL_11]] : (!fir.box<!fir.char<1,?>>) -> !fir.box<none>
317 ! CHECK: %[[VAL_25:.*]] = fir.call @_FortranAAllocatableAllocateSource(%[[VAL_22]], %[[VAL_23]], %[[VAL_7]], %[[VAL_8]], %{{.*}}, %{{.*}}) {{.*}}: (!fir.ref<!fir.box<none>>, !fir.box<none>, i1, !fir.box<none>, !fir.ref<i8>, i32) -> i32
319 subroutine test_allocatable_char(n, a)
320 character(:), allocatable :: x1
321 integer :: n
322 character(*) :: a
324 allocate(x1, source = a)
327 ! CHECK-LABEL: func.func @_QPtest_allocatable_derived_type(
328 ! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.box<!fir.heap<!fir.array<?x!fir.type<_QFtest_allocatable_derived_typeTt{x:!fir.box<!fir.heap<!fir.array<?xi32>>>}>>>>> {fir.bindc_name = "y"}) {
329 ! CHECK: %[[VAL_1:.*]] = fir.alloca !fir.box<!fir.heap<!fir.array<?x!fir.type<_QFtest_allocatable_derived_typeTt{x:!fir.box<!fir.heap<!fir.array<?xi32>>>}>>>> {bindc_name = "z", uniq_name = "_QFtest_allocatable_derived_typeEz"}
330 ! CHECK: %[[VAL_2:.*]] = fir.alloca !fir.heap<!fir.array<?x!fir.type<_QFtest_allocatable_derived_typeTt{x:!fir.box<!fir.heap<!fir.array<?xi32>>>}>>> {uniq_name = "_QFtest_allocatable_derived_typeEz.addr"}
331 ! CHECK: %[[VAL_3:.*]] = fir.alloca index {uniq_name = "_QFtest_allocatable_derived_typeEz.lb0"}
332 ! CHECK: %[[VAL_4:.*]] = fir.alloca index {uniq_name = "_QFtest_allocatable_derived_typeEz.ext0"}
333 ! CHECK: %[[VAL_5:.*]] = fir.zero_bits !fir.heap<!fir.array<?x!fir.type<_QFtest_allocatable_derived_typeTt{x:!fir.box<!fir.heap<!fir.array<?xi32>>>}>>>
334 ! CHECK: fir.store %[[VAL_5]] to %[[VAL_2]] : !fir.ref<!fir.heap<!fir.array<?x!fir.type<_QFtest_allocatable_derived_typeTt{x:!fir.box<!fir.heap<!fir.array<?xi32>>>}>>>>
335 ! CHECK: %[[VAL_6:.*]] = arith.constant false
336 ! CHECK: %[[VAL_7:.*]] = fir.absent !fir.box<none>
337 ! CHECK: %[[VAL_10:.*]] = fir.load %[[VAL_0]] : !fir.ref<!fir.box<!fir.heap<!fir.array<?x!fir.type<_QFtest_allocatable_derived_typeTt{x:!fir.box<!fir.heap<!fir.array<?xi32>>>}>>>>>
338 ! CHECK: %[[VAL_11:.*]] = arith.constant 0 : index
339 ! CHECK: %[[VAL_12:.*]]:3 = fir.box_dims %[[VAL_10]], %[[VAL_11]] : (!fir.box<!fir.heap<!fir.array<?x!fir.type<_QFtest_allocatable_derived_typeTt{x:!fir.box<!fir.heap<!fir.array<?xi32>>>}>>>>, index) -> (index, index, index)
340 ! CHECK: %[[VAL_13:.*]] = fir.shift %[[VAL_12]]#0 : (index) -> !fir.shift<1>
341 ! CHECK: %[[VAL_14:.*]] = fir.rebox %[[VAL_10]](%[[VAL_13]]) : (!fir.box<!fir.heap<!fir.array<?x!fir.type<_QFtest_allocatable_derived_typeTt{x:!fir.box<!fir.heap<!fir.array<?xi32>>>}>>>>, !fir.shift<1>) -> !fir.box<!fir.array<?x!fir.type<_QFtest_allocatable_derived_typeTt{x:!fir.box<!fir.heap<!fir.array<?xi32>>>}>>>
342 ! CHECK: %[[VAL_15:.*]] = fir.load %[[VAL_3]] : !fir.ref<index>
343 ! CHECK: %[[VAL_16:.*]] = fir.load %[[VAL_4]] : !fir.ref<index>
344 ! CHECK: %[[VAL_17:.*]] = fir.load %[[VAL_2]] : !fir.ref<!fir.heap<!fir.array<?x!fir.type<_QFtest_allocatable_derived_typeTt{x:!fir.box<!fir.heap<!fir.array<?xi32>>>}>>>>
345 ! CHECK: %[[VAL_18:.*]] = fir.shape_shift %[[VAL_15]], %[[VAL_16]] : (index, index) -> !fir.shapeshift<1>
346 ! CHECK: %[[VAL_19:.*]] = fir.embox %[[VAL_17]](%[[VAL_18]]) : (!fir.heap<!fir.array<?x!fir.type<_QFtest_allocatable_derived_typeTt{x:!fir.box<!fir.heap<!fir.array<?xi32>>>}>>>, !fir.shapeshift<1>) -> !fir.box<!fir.heap<!fir.array<?x!fir.type<_QFtest_allocatable_derived_typeTt{x:!fir.box<!fir.heap<!fir.array<?xi32>>>}>>>>
347 ! CHECK: fir.store %[[VAL_19]] to %[[VAL_1]] : !fir.ref<!fir.box<!fir.heap<!fir.array<?x!fir.type<_QFtest_allocatable_derived_typeTt{x:!fir.box<!fir.heap<!fir.array<?xi32>>>}>>>>>
348 ! CHECK: %[[VAL_20:.*]] = arith.constant 1 : index
349 ! CHECK: %[[VAL_21:.*]] = arith.constant 0 : index
350 ! CHECK: %[[VAL_22:.*]]:3 = fir.box_dims %[[VAL_14]], %[[VAL_21]] : (!fir.box<!fir.array<?x!fir.type<_QFtest_allocatable_derived_typeTt{x:!fir.box<!fir.heap<!fir.array<?xi32>>>}>>>, index) -> (index, index, index)
351 ! CHECK: %[[VAL_23:.*]] = arith.addi %[[VAL_22]]#1, %[[VAL_12]]#0 : index
352 ! CHECK: %[[VAL_24:.*]] = arith.subi %[[VAL_23]], %[[VAL_20]] : index
353 ! CHECK: %[[VAL_25:.*]] = arith.constant 0 : i32
354 ! CHECK: %[[VAL_26:.*]] = fir.convert %[[VAL_1]] : (!fir.ref<!fir.box<!fir.heap<!fir.array<?x!fir.type<_QFtest_allocatable_derived_typeTt{x:!fir.box<!fir.heap<!fir.array<?xi32>>>}>>>>>) -> !fir.ref<!fir.box<none>>
355 ! CHECK: %[[VAL_27:.*]] = fir.convert %[[VAL_12]]#0 : (index) -> i64
356 ! CHECK: %[[VAL_28:.*]] = fir.convert %[[VAL_24]] : (index) -> i64
357 ! CHECK: %[[VAL_29:.*]] = fir.call @_FortranAAllocatableSetBounds(%[[VAL_26]], %[[VAL_25]], %[[VAL_27]], %[[VAL_28]]) {{.*}}: (!fir.ref<!fir.box<none>>, i32, i64, i64) -> none
358 ! CHECK: %[[VAL_30:.*]] = fir.convert %[[VAL_1]] : (!fir.ref<!fir.box<!fir.heap<!fir.array<?x!fir.type<_QFtest_allocatable_derived_typeTt{x:!fir.box<!fir.heap<!fir.array<?xi32>>>}>>>>>) -> !fir.ref<!fir.box<none>>
359 ! CHECK: %[[VAL_31:.*]] = fir.convert %[[VAL_14]] : (!fir.box<!fir.array<?x!fir.type<_QFtest_allocatable_derived_typeTt{x:!fir.box<!fir.heap<!fir.array<?xi32>>>}>>>) -> !fir.box<none>
360 ! CHECK: %[[VAL_33:.*]] = fir.call @_FortranAAllocatableAllocateSource(%[[VAL_30]], %[[VAL_31]], %[[VAL_6]], %[[VAL_7]], %{{.*}}, %{{.*}}) {{.*}}: (!fir.ref<!fir.box<none>>, !fir.box<none>, i1, !fir.box<none>, !fir.ref<i8>, i32) -> i32
362 subroutine test_allocatable_derived_type(y)
363 type t
364 integer, allocatable :: x(:)
365 end type
366 type(t), allocatable :: z(:), y(:)
368 allocate(z, source=y)