1 ! Test lowering of component reference to HLFIR
2 ! RUN: bbc -emit-fir -hlfir -o - %s | FileCheck %s
16 character(5) :: scalar_char
21 real :: array_comp(10,20)
26 real :: array_comp_lbs(2:11,3:22)
31 character(5) :: array_char_comp(10,20)
35 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
37 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
39 subroutine test_scalar(a
)
42 call use_real_scalar(a
%scalar_x
)
43 ! CHECK-LABEL: func.func @_QPtest_scalar(
44 ! CHECK: %[[VAL_1:.*]]:2 = hlfir.declare %[[VAL_0:[a-z0-9]*]] {{.*}}Ea
45 ! CHECK: %[[VAL_2:.*]] = hlfir.designate %[[VAL_1]]#0{"scalar_x"} : (!fir.ref<!fir.type<_QMcomp_refTt1{scalar_i:i32,scalar_x:f32}>>) -> !fir.ref<f32>
48 subroutine test_scalar_char(a
)
51 call use_char_scalar(a
%scalar_char
)
52 ! CHECK-LABEL: func.func @_QPtest_scalar_char(
53 ! CHECK: %[[VAL_1:.*]]:2 = hlfir.declare %[[VAL_0:[a-z0-9]*]] {{.*}}Ea
54 ! CHECK: %[[VAL_2:.*]] = arith.constant 5 : index
55 ! CHECK: %[[VAL_3:.*]] = hlfir.designate %[[VAL_1]]#0{"scalar_char"} typeparams %[[VAL_2]] : (!fir.ref<!fir.type<_QMcomp_refTt_char{scalar_i:i32,scalar_char:!fir.char<1,5>}>>, index) -> !fir.ref<!fir.char<1,5>>
58 subroutine test_scalar_char_substring(a
)
61 call use_char_scalar(a
%scalar_char(3:))
62 ! CHECK-LABEL: func.func @_QPtest_scalar_char_substring(
63 ! CHECK: %[[VAL_1:.*]]:2 = hlfir.declare %[[VAL_0:[a-z0-9]*]] {{.*}}Ea
64 ! CHECK: %[[VAL_2:.*]] = arith.constant 3 : index
65 ! CHECK: %[[VAL_3:.*]] = arith.constant 5 : index
66 ! CHECK: %[[VAL_4:.*]] = arith.constant 3 : index
67 ! CHECK: %[[VAL_5:.*]] = hlfir.designate %[[VAL_1]]#0{"scalar_char"} substr %[[VAL_2]], %[[VAL_3]] typeparams %[[VAL_4]] : (!fir.ref<!fir.type<_QMcomp_refTt_char{scalar_i:i32,scalar_char:!fir.char<1,5>}>>, index, index, index) -> !fir.ref<!fir.char<1,3>>
70 subroutine test_array_comp_1(a
)
73 call use_real_array(a
%array_comp
)
74 ! CHECK-LABEL: func.func @_QPtest_array_comp_1(
75 ! CHECK: %[[VAL_1:.*]]:2 = hlfir.declare %[[VAL_0:[a-z0-9]*]] {{.*}}Ea
76 ! CHECK: %[[VAL_2:.*]] = arith.constant 10 : index
77 ! CHECK: %[[VAL_3:.*]] = arith.constant 20 : index
78 ! CHECK: %[[VAL_4:.*]] = fir.shape %[[VAL_2]], %[[VAL_3]] : (index, index) -> !fir.shape<2>
79 ! CHECK: %[[VAL_5:.*]] = hlfir.designate %[[VAL_1]]#0{"array_comp"} shape %[[VAL_4]] : (!fir.ref<!fir.type<_QMcomp_refTt_array{scalar_i:i32,array_comp:!fir.array<10x20xf32>}>>, !fir.shape<2>) -> !fir.ref<!fir.array<10x20xf32>>
82 subroutine test_array_comp_slice(a
)
86 call use_real_array(a
%array_comp(:, 4:20:1))
87 ! CHECK-LABEL: func.func @_QPtest_array_comp_slice(
88 ! CHECK: %[[VAL_1:.*]]:2 = hlfir.declare %[[VAL_0:[a-z0-9]*]] {{.*}}Ea
89 ! CHECK: %[[VAL_2:.*]] = arith.constant 10 : index
90 ! CHECK: %[[VAL_3:.*]] = arith.constant 20 : index
91 ! CHECK: %[[VAL_4:.*]] = fir.shape %[[VAL_2]], %[[VAL_3]] : (index, index) -> !fir.shape<2>
92 ! CHECK: %[[VAL_5:.*]] = arith.constant 1 : index
93 ! CHECK: %[[VAL_6:.*]] = arith.constant 1 : index
94 ! CHECK: %[[VAL_7:.*]] = arith.constant 10 : index
95 ! CHECK: %[[VAL_8:.*]] = arith.constant 4 : index
96 ! CHECK: %[[VAL_9:.*]] = arith.constant 20 : index
97 ! CHECK: %[[VAL_10:.*]] = arith.constant 1 : index
98 ! CHECK: %[[VAL_11:.*]] = arith.constant 17 : index
99 ! CHECK: %[[VAL_12:.*]] = fir.shape %[[VAL_7]], %[[VAL_11]] : (index, index) -> !fir.shape<2>
100 ! CHECK: %[[VAL_13:.*]] = hlfir.designate %[[VAL_1]]#0{"array_comp"} <%[[VAL_4]]> (%[[VAL_5]]:%[[VAL_2]]:%[[VAL_6]], %[[VAL_8]]:%[[VAL_9]]:%[[VAL_10]]) shape %[[VAL_12]] : (!fir.ref<!fir.type<_QMcomp_refTt_array{scalar_i:i32,array_comp:!fir.array<10x20xf32>}>>, !fir.shape<2>, index, index, index, index, index, index, !fir.shape<2>) -> !fir.ref<!fir.array<10x17xf32>>
103 subroutine test_array_comp_non_contiguous_slice(a
)
107 print *, a
%array_comp(1:6:1, 4:20:1)
108 ! CHECK-LABEL: func.func @_QPtest_array_comp_non_contiguous_slice(
109 ! CHECK: %[[VAL_1:.*]]:2 = hlfir.declare %[[VAL_0:[a-z0-9]*]] {{.*}}Ea
110 ! CHECK: %[[VAL_7:.*]] = arith.constant 10 : index
111 ! CHECK: %[[VAL_8:.*]] = arith.constant 20 : index
112 ! CHECK: %[[VAL_9:.*]] = fir.shape %[[VAL_7]], %[[VAL_8]] : (index, index) -> !fir.shape<2>
113 ! CHECK: %[[VAL_10:.*]] = arith.constant 1 : index
114 ! CHECK: %[[VAL_11:.*]] = arith.constant 6 : index
115 ! CHECK: %[[VAL_12:.*]] = arith.constant 1 : index
116 ! CHECK: %[[VAL_13:.*]] = arith.constant 6 : index
117 ! CHECK: %[[VAL_14:.*]] = arith.constant 4 : index
118 ! CHECK: %[[VAL_15:.*]] = arith.constant 20 : index
119 ! CHECK: %[[VAL_16:.*]] = arith.constant 1 : index
120 ! CHECK: %[[VAL_17:.*]] = arith.constant 17 : index
121 ! CHECK: %[[VAL_18:.*]] = fir.shape %[[VAL_13]], %[[VAL_17]] : (index, index) -> !fir.shape<2>
122 ! CHECK: %[[VAL_19:.*]] = hlfir.designate %[[VAL_1]]#0{"array_comp"} <%[[VAL_9]]> (%[[VAL_10]]:%[[VAL_11]]:%[[VAL_12]], %[[VAL_14]]:%[[VAL_15]]:%[[VAL_16]]) shape %[[VAL_18]] : (!fir.ref<!fir.type<_QMcomp_refTt_array{scalar_i:i32,array_comp:!fir.array<10x20xf32>}>>, !fir.shape<2>, index, index, index, index, index, index, !fir.shape<2>) -> !fir.box<!fir.array<6x17xf32>>
125 subroutine test_array_lbs_comp_lbs_1(a
)
127 type(t_array_lbs
) :: a
128 call use_real_array(a
%array_comp_lbs
)
129 ! CHECK-LABEL: func.func @_QPtest_array_lbs_comp_lbs_1(
130 ! CHECK: %[[VAL_1:.*]]:2 = hlfir.declare %[[VAL_0:[a-z0-9]*]] {{.*}}Ea
131 ! CHECK: %[[VAL_2:.*]] = arith.constant 10 : index
132 ! CHECK: %[[VAL_3:.*]] = arith.constant 20 : index
133 ! CHECK: %[[VAL_4:.*]] = arith.constant 2 : index
134 ! CHECK: %[[VAL_5:.*]] = arith.constant 3 : index
135 ! CHECK: %[[VAL_6:.*]] = fir.shape_shift %[[VAL_4]], %[[VAL_2]], %[[VAL_5]], %[[VAL_3]] : (index, index, index, index) -> !fir.shapeshift<2>
136 ! CHECK: %[[VAL_7:.*]] = hlfir.designate %[[VAL_1]]#0{"array_comp_lbs"} shape %[[VAL_6]] : (!fir.ref<!fir.type<_QMcomp_refTt_array_lbs{scalar_i:i32,array_comp_lbs:!fir.array<10x20xf32>}>>, !fir.shapeshift<2>) -> !fir.box<!fir.array<10x20xf32>>
139 subroutine test_array_lbs_comp_lbs_slice(a
)
141 type(t_array_lbs
) :: a
143 call use_real_array(a
%array_comp_lbs(:, 4:20:1))
144 ! CHECK-LABEL: func.func @_QPtest_array_lbs_comp_lbs_slice(
145 ! CHECK: %[[VAL_1:.*]]:2 = hlfir.declare %[[VAL_0:[a-z0-9]*]] {{.*}}Ea
146 ! CHECK: %[[VAL_2:.*]] = arith.constant 10 : index
147 ! CHECK: %[[VAL_3:.*]] = arith.constant 20 : index
148 ! CHECK: %[[VAL_4:.*]] = arith.constant 2 : index
149 ! CHECK: %[[VAL_5:.*]] = arith.constant 3 : index
150 ! CHECK: %[[VAL_6:.*]] = fir.shape_shift %[[VAL_4]], %[[VAL_2]], %[[VAL_5]], %[[VAL_3]] : (index, index, index, index) -> !fir.shapeshift<2>
151 ! CHECK: %[[VAL_7:.*]] = arith.constant 1 : index
152 ! CHECK: %[[VAL_8:.*]] = arith.addi %[[VAL_4]], %[[VAL_2]] : index
153 ! CHECK: %[[VAL_9:.*]] = arith.subi %[[VAL_8]], %[[VAL_7]] : index
154 ! CHECK: %[[VAL_10:.*]] = arith.constant 1 : index
155 ! CHECK: %[[VAL_11:.*]] = arith.constant 10 : index
156 ! CHECK: %[[VAL_12:.*]] = arith.constant 4 : index
157 ! CHECK: %[[VAL_13:.*]] = arith.constant 20 : index
158 ! CHECK: %[[VAL_14:.*]] = arith.constant 1 : index
159 ! CHECK: %[[VAL_15:.*]] = arith.constant 17 : index
160 ! CHECK: %[[VAL_16:.*]] = fir.shape %[[VAL_11]], %[[VAL_15]] : (index, index) -> !fir.shape<2>
161 ! CHECK: %[[VAL_17:.*]] = hlfir.designate %[[VAL_1]]#0{"array_comp_lbs"} <%[[VAL_6]]> (%[[VAL_4]]:%[[VAL_9]]:%[[VAL_10]], %[[VAL_12]]:%[[VAL_13]]:%[[VAL_14]]) shape %[[VAL_16]] : (!fir.ref<!fir.type<_QMcomp_refTt_array_lbs{scalar_i:i32,array_comp_lbs:!fir.array<10x20xf32>}>>, !fir.shapeshift<2>, index, index, index, index, index, index, !fir.shape<2>) -> !fir.ref<!fir.array<10x17xf32>>
164 subroutine test_array_char_comp_1(a
)
166 type(t_array_char
) :: a
167 call use_array_char(a
%array_char_comp
)
168 ! CHECK-LABEL: func.func @_QPtest_array_char_comp_1(
169 ! CHECK: %[[VAL_1:.*]]:2 = hlfir.declare %[[VAL_0:[a-z0-9]*]] {{.*}}Ea
170 ! CHECK: %[[VAL_2:.*]] = arith.constant 10 : index
171 ! CHECK: %[[VAL_3:.*]] = arith.constant 20 : index
172 ! CHECK: %[[VAL_4:.*]] = fir.shape %[[VAL_2]], %[[VAL_3]] : (index, index) -> !fir.shape<2>
173 ! CHECK: %[[VAL_5:.*]] = arith.constant 5 : index
174 ! CHECK: %[[VAL_6:.*]] = hlfir.designate %[[VAL_1]]#0{"array_char_comp"} shape %[[VAL_4]] typeparams %[[VAL_5]] : (!fir.ref<!fir.type<_QMcomp_refTt_array_char{scalar_i:i32,array_char_comp:!fir.array<10x20x!fir.char<1,5>>}>>, !fir.shape<2>, index) -> !fir.ref<!fir.array<10x20x!fir.char<1,5>>>
177 subroutine test_array_char_comp_slice(a
)
179 type(t_array_char
) :: a
181 call use_array_char(a
%array_char_comp(:, 4:20:1))
182 ! CHECK-LABEL: func.func @_QPtest_array_char_comp_slice(
183 ! CHECK: %[[VAL_1:.*]]:2 = hlfir.declare %[[VAL_0:[a-z0-9]*]] {{.*}}Ea
184 ! CHECK: %[[VAL_2:.*]] = arith.constant 10 : index
185 ! CHECK: %[[VAL_3:.*]] = arith.constant 20 : index
186 ! CHECK: %[[VAL_4:.*]] = fir.shape %[[VAL_2]], %[[VAL_3]] : (index, index) -> !fir.shape<2>
187 ! CHECK: %[[VAL_5:.*]] = arith.constant 5 : index
188 ! CHECK: %[[VAL_6:.*]] = arith.constant 1 : index
189 ! CHECK: %[[VAL_7:.*]] = arith.constant 1 : index
190 ! CHECK: %[[VAL_8:.*]] = arith.constant 10 : index
191 ! CHECK: %[[VAL_9:.*]] = arith.constant 4 : index
192 ! CHECK: %[[VAL_10:.*]] = arith.constant 20 : index
193 ! CHECK: %[[VAL_11:.*]] = arith.constant 1 : index
194 ! CHECK: %[[VAL_12:.*]] = arith.constant 17 : index
195 ! CHECK: %[[VAL_13:.*]] = fir.shape %[[VAL_8]], %[[VAL_12]] : (index, index) -> !fir.shape<2>
196 ! CHECK: %[[VAL_14:.*]] = hlfir.designate %[[VAL_1]]#0{"array_char_comp"} <%[[VAL_4]]> (%[[VAL_6]]:%[[VAL_2]]:%[[VAL_7]], %[[VAL_9]]:%[[VAL_10]]:%[[VAL_11]]) shape %[[VAL_13]] typeparams %[[VAL_5]] : (!fir.ref<!fir.type<_QMcomp_refTt_array_char{scalar_i:i32,array_char_comp:!fir.array<10x20x!fir.char<1,5>>}>>, !fir.shape<2>, index, index, index, index, index, index, !fir.shape<2>, index) -> !fir.ref<!fir.array<10x17x!fir.char<1,5>>>
199 subroutine test_array_char_comp_non_contiguous_slice(a
)
201 type(t_array_char
) :: a
203 print *, a
%array_char_comp(1:10:1,1:20:1)(2:4)
204 ! CHECK-LABEL: func.func @_QPtest_array_char_comp_non_contiguous_slice(
205 ! CHECK: %[[VAL_1:.*]]:2 = hlfir.declare %[[VAL_0:[a-z0-9]*]] {{.*}}Ea
206 ! CHECK: %[[VAL_7:.*]] = arith.constant 10 : index
207 ! CHECK: %[[VAL_8:.*]] = arith.constant 20 : index
208 ! CHECK: %[[VAL_9:.*]] = fir.shape %[[VAL_7]], %[[VAL_8]] : (index, index) -> !fir.shape<2>
209 ! CHECK: %[[VAL_10:.*]] = arith.constant 1 : index
210 ! CHECK: %[[VAL_11:.*]] = arith.constant 10 : index
211 ! CHECK: %[[VAL_12:.*]] = arith.constant 1 : index
212 ! CHECK: %[[VAL_13:.*]] = arith.constant 10 : index
213 ! CHECK: %[[VAL_14:.*]] = arith.constant 1 : index
214 ! CHECK: %[[VAL_15:.*]] = arith.constant 20 : index
215 ! CHECK: %[[VAL_16:.*]] = arith.constant 1 : index
216 ! CHECK: %[[VAL_17:.*]] = arith.constant 20 : index
217 ! CHECK: %[[VAL_18:.*]] = fir.shape %[[VAL_13]], %[[VAL_17]] : (index, index) -> !fir.shape<2>
218 ! CHECK: %[[VAL_19:.*]] = arith.constant 2 : index
219 ! CHECK: %[[VAL_20:.*]] = arith.constant 4 : index
220 ! CHECK: %[[VAL_21:.*]] = arith.constant 3 : index
221 ! CHECK: %[[VAL_22:.*]] = hlfir.designate %[[VAL_1]]#0{"array_char_comp"} <%[[VAL_9]]> (%[[VAL_10]]:%[[VAL_11]]:%[[VAL_12]], %[[VAL_14]]:%[[VAL_15]]:%[[VAL_16]]) substr %[[VAL_19]], %[[VAL_20]] shape %[[VAL_18]] typeparams %[[VAL_21]] : (!fir.ref<!fir.type<_QMcomp_refTt_array_char{scalar_i:i32,array_char_comp:!fir.array<10x20x!fir.char<1,5>>}>>, !fir.shape<2>, index, index, index, index, index, index, index, index, !fir.shape<2>, index) -> !fir.box<!fir.array<10x20x!fir.char<1,3>>>
224 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
226 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
228 subroutine test_array(a
)
232 ! CHECK-LABEL: func.func @_QPtest_array(
233 ! CHECK: %[[VAL_1:.*]]:2 = hlfir.declare %[[VAL_0:[a-z0-9]*]] {{.*}}Ea
234 ! CHECK: %[[VAL_7:.*]] = arith.constant 0 : index
235 ! CHECK: %[[VAL_8:.*]]:3 = fir.box_dims %[[VAL_1]]#0, %[[VAL_7]] : (!fir.box<!fir.array<?x!fir.type<_QMcomp_refTt1{scalar_i:i32,scalar_x:f32}>>>, index) -> (index, index, index)
236 ! CHECK: %[[VAL_9:.*]] = fir.shape %[[VAL_8]]#1 : (index) -> !fir.shape<1>
237 ! CHECK: %[[VAL_10:.*]] = hlfir.designate %[[VAL_1]]#0{"scalar_x"} shape %[[VAL_9]] : (!fir.box<!fir.array<?x!fir.type<_QMcomp_refTt1{scalar_i:i32,scalar_x:f32}>>>, !fir.shape<1>) -> !fir.box<!fir.array<?xf32>>
240 subroutine test_array_char(a
, n
)
244 print *, a
%scalar_char
245 ! CHECK-LABEL: func.func @_QPtest_array_char(
246 ! CHECK: %[[VAL_9:.*]]:2 = hlfir.declare %[[VAL_0:[a-z0-9]*]](%[[VAL_8:[a-z0-9]*]]) {{.*}}Ea
247 ! CHECK: %[[VAL_15:.*]] = arith.constant 5 : index
248 ! CHECK: %[[VAL_16:.*]] = hlfir.designate %[[VAL_9]]#0{"scalar_char"} shape %[[VAL_8]] typeparams %[[VAL_15]] : (!fir.box<!fir.array<?x!fir.type<_QMcomp_refTt_char{scalar_i:i32,scalar_char:!fir.char<1,5>}>>>, !fir.shape<1>, index) -> !fir.box<!fir.array<?x!fir.char<1,5>>>
251 subroutine test_array_char_substring(a
)
253 type(t_char
) :: a(100)
254 print *, a
%scalar_char(3:)
255 ! CHECK-LABEL: func.func @_QPtest_array_char_substring(
256 ! CHECK: %[[VAL_3:.*]]:2 = hlfir.declare %[[VAL_0:[a-z0-9]*]](%[[VAL_2:[a-z0-9]*]]) {{.*}}Ea
257 ! CHECK: %[[VAL_9:.*]] = arith.constant 3 : index
258 ! CHECK: %[[VAL_10:.*]] = arith.constant 5 : index
259 ! CHECK: %[[VAL_11:.*]] = arith.constant 3 : index
260 ! CHECK: %[[VAL_12:.*]] = hlfir.designate %[[VAL_3]]#0{"scalar_char"} substr %[[VAL_9]], %[[VAL_10]] shape %[[VAL_2]] typeparams %[[VAL_11]] : (!fir.ref<!fir.array<100x!fir.type<_QMcomp_refTt_char{scalar_i:i32,scalar_char:!fir.char<1,5>}>>>, index, index, !fir.shape<1>, index) -> !fir.box<!fir.array<100x!fir.char<1,3>>>
263 subroutine test_array_array_comp_1(a
)
265 type(t_array
) :: a(100)
266 print *, a
%array_comp(4,5)
267 ! CHECK-LABEL: func.func @_QPtest_array_array_comp_1(
268 ! CHECK: %[[VAL_3:.*]]:2 = hlfir.declare %[[VAL_0:[a-z0-9]*]](%[[VAL_2:[a-z0-9]*]]) {{.*}}Ea
269 ! CHECK: %[[VAL_9:.*]] = arith.constant 10 : index
270 ! CHECK: %[[VAL_10:.*]] = arith.constant 20 : index
271 ! CHECK: %[[VAL_11:.*]] = fir.shape %[[VAL_9]], %[[VAL_10]] : (index, index) -> !fir.shape<2>
272 ! CHECK: %[[VAL_12:.*]] = arith.constant 4 : index
273 ! CHECK: %[[VAL_13:.*]] = arith.constant 5 : index
274 ! CHECK: %[[VAL_14:.*]] = hlfir.designate %[[VAL_3]]#0{"array_comp"} <%[[VAL_11]]> (%[[VAL_12]], %[[VAL_13]]) shape %[[VAL_2]] : (!fir.ref<!fir.array<100x!fir.type<_QMcomp_refTt_array{scalar_i:i32,array_comp:!fir.array<10x20xf32>}>>>, !fir.shape<2>, index, index, !fir.shape<1>) -> !fir.box<!fir.array<100xf32>>
277 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
278 ! Test several part ref (produces chain of hlfir.designate) !
279 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
281 subroutine test_scalar_chain(a
)
284 call use_real_scalar(a
%scalar_t1
%scalar_x
)
285 ! CHECK-LABEL: func.func @_QPtest_scalar_chain(
286 ! CHECK: %[[VAL_1:.*]]:2 = hlfir.declare %[[VAL_0:[a-z0-9]*]] {{.*}}Ea
287 ! CHECK: %[[VAL_2:.*]] = hlfir.designate %[[VAL_1]]#0{"scalar_t1"} : (!fir.ref<!fir.type<_QMcomp_refTt2{scalar_i2:i32,scalar_t1:!fir.type<_QMcomp_refTt1{scalar_i:i32,scalar_x:f32}>}>>) -> !fir.ref<!fir.type<_QMcomp_refTt1{scalar_i:i32,scalar_x:f32}>>
288 ! CHECK: %[[VAL_3:.*]] = hlfir.designate %[[VAL_2]]{"scalar_x"} : (!fir.ref<!fir.type<_QMcomp_refTt1{scalar_i:i32,scalar_x:f32}>>) -> !fir.ref<f32>
291 subroutine test_array_scalar_chain(a
)
294 print *, a
%scalar_t1
%scalar_x
295 ! CHECK-LABEL: func.func @_QPtest_array_scalar_chain(
296 ! CHECK: %[[VAL_1:.*]] = arith.constant 100 : index
297 ! CHECK: %[[VAL_2:.*]] = fir.shape %[[VAL_1]] : (index) -> !fir.shape<1>
298 ! CHECK: %[[VAL_3:.*]]:2 = hlfir.declare %[[VAL_0:[a-z0-9]*]](%[[VAL_2:[a-z0-9]*]]) {{.*}}Ea
299 ! CHECK: %[[VAL_9:.*]] = hlfir.designate %[[VAL_3]]#0{"scalar_t1"} shape %[[VAL_2]] : (!fir.ref<!fir.array<100x!fir.type<_QMcomp_refTt2{scalar_i2:i32,scalar_t1:!fir.type<_QMcomp_refTt1{scalar_i:i32,scalar_x:f32}>}>>>, !fir.shape<1>) -> !fir.box<!fir.array<100x!fir.type<_QMcomp_refTt1{scalar_i:i32,scalar_x:f32}>>>
300 ! CHECK: %[[VAL_10:.*]] = hlfir.designate %[[VAL_9]]{"scalar_x"} shape %[[VAL_2]] : (!fir.box<!fir.array<100x!fir.type<_QMcomp_refTt1{scalar_i:i32,scalar_x:f32}>>>, !fir.shape<1>) -> !fir.box<!fir.array<100xf32>>
303 subroutine test_scalar_chain_2(a
)
306 print *, a(10)%scalar_x
307 ! CHECK-LABEL: func.func @_QPtest_scalar_chain_2(
308 ! CHECK: %[[VAL_3:.*]]:2 = hlfir.declare %[[VAL_0:[a-z0-9]*]](%[[VAL_2:[a-z0-9]*]]) {{.*}}Ea
309 ! CHECK: %[[VAL_9:.*]] = arith.constant 10 : index
310 ! CHECK: %[[VAL_10:.*]] = hlfir.designate %[[VAL_3]]#0 (%[[VAL_9]]) : (!fir.ref<!fir.array<50x!fir.type<_QMcomp_refTt1{scalar_i:i32,scalar_x:f32}>>>, index) -> !fir.ref<!fir.type<_QMcomp_refTt1{scalar_i:i32,scalar_x:f32}>>
311 ! CHECK: %[[VAL_11:.*]] = hlfir.designate %[[VAL_10]]{"scalar_x"} : (!fir.ref<!fir.type<_QMcomp_refTt1{scalar_i:i32,scalar_x:f32}>>) -> !fir.ref<f32>
314 subroutine test_array_ref_chain(a
)
316 type(t_array
) :: a(100)
317 print *, a(1:50:5)%array_comp(4,5)
318 ! CHECK-LABEL: func.func @_QPtest_array_ref_chain(
319 ! CHECK: %[[VAL_3:.*]]:2 = hlfir.declare %[[VAL_0:[a-z0-9]*]](%[[VAL_2:[a-z0-9]*]]) {{.*}}Ea
320 ! CHECK: %[[VAL_9:.*]] = arith.constant 1 : index
321 ! CHECK: %[[VAL_10:.*]] = arith.constant 50 : index
322 ! CHECK: %[[VAL_11:.*]] = arith.constant 5 : index
323 ! CHECK: %[[VAL_12:.*]] = arith.constant 10 : index
324 ! CHECK: %[[VAL_13:.*]] = fir.shape %[[VAL_12]] : (index) -> !fir.shape<1>
325 ! CHECK: %[[VAL_14:.*]] = hlfir.designate %[[VAL_3]]#0 (%[[VAL_9]]:%[[VAL_10]]:%[[VAL_11]]) shape %[[VAL_13]] : (!fir.ref<!fir.array<100x!fir.type<_QMcomp_refTt_array{scalar_i:i32,array_comp:!fir.array<10x20xf32>}>>>, index, index, index, !fir.shape<1>) -> !fir.box<!fir.array<10x!fir.type<_QMcomp_refTt_array{scalar_i:i32,array_comp:!fir.array<10x20xf32>}>>>
326 ! CHECK: %[[VAL_15:.*]] = arith.constant 10 : index
327 ! CHECK: %[[VAL_16:.*]] = arith.constant 20 : index
328 ! CHECK: %[[VAL_17:.*]] = fir.shape %[[VAL_15]], %[[VAL_16]] : (index, index) -> !fir.shape<2>
329 ! CHECK: %[[VAL_18:.*]] = arith.constant 4 : index
330 ! CHECK: %[[VAL_19:.*]] = arith.constant 5 : index
331 ! CHECK: %[[VAL_20:.*]] = hlfir.designate %[[VAL_14]]{"array_comp"} <%[[VAL_17]]> (%[[VAL_18]], %[[VAL_19]]) shape %[[VAL_13]] : (!fir.box<!fir.array<10x!fir.type<_QMcomp_refTt_array{scalar_i:i32,array_comp:!fir.array<10x20xf32>}>>>, !fir.shape<2>, index, index, !fir.shape<1>) -> !fir.box<!fir.array<10xf32>>