1 ! RUN: bbc -hlfir=false %s -o - | FileCheck %s
3 ! CHECK-LABEL: substring_main
4 subroutine substring_main
5 character*7 :: string(2) = ['12 ', '12 ']
9 elemental
function inner(arg
)
10 character(len
=*), intent(in
) :: arg
16 ! CHECK: %[[a0:.*]] = fir.alloca i32 {bindc_name = "ival", uniq_name = "_QFsubstring_mainEival"}
17 ! CHECK: %[[a2:.*]] = fir.address_of(@_QFsubstring_mainEstring) : !fir.ref<!fir.array<2x!fir.char<1,7>>>
18 ! CHECK: fir.store {{.*}} to %[[a0]] : !fir.ref<i32>
19 ! CHECK: %[[a3:.*]] = fir.shape {{.*}} : (index) -> !fir.shape<1>
20 ! CHECK: %[[a4:.*]] = fir.slice {{.*}}, {{.*}}, {{.*}} : (index, index, index) -> !fir.slice<1>
21 ! CHECK: br ^bb1({{.*}}, {{.*}} : index, index)
22 ! CHECK: ^bb1(%[[a5:.*]]: index, %[[a6:.*]]: index): // 2 preds: ^bb0, ^bb2
23 ! CHECK: %[[a7:.*]] = arith.cmpi sgt, %[[a6]], {{.*}} : index
24 ! CHECK: cond_br %[[a7]], ^bb2, ^bb3
25 ! CHECK: ^bb2: // pred: ^bb1
26 ! CHECK: %[[a8:.*]] = arith.addi %[[a5]], {{.*}} : index
27 ! CHECK: %[[a9:.*]] = fir.array_coor %[[a2]](%[[a3]]) [%[[a4]]] %[[a8]] : (!fir.ref<!fir.array<2x!fir.char<1,7>>>, !fir.shape<1>, !fir.slice<1>, index) -> !fir.ref<!fir.char<1,7>>
28 ! CHECK: %[[a10:.*]] = fir.load %[[a0]] : !fir.ref<i32>
29 ! CHECK: %[[a11:.*]] = fir.convert %[[a10]] : (i32) -> index
30 ! CHECK: %[[a12:.*]] = arith.subi %[[a11]], {{.*}} : index
31 ! CHECK: %[[a13:.*]] = fir.convert %[[a9]] : (!fir.ref<!fir.char<1,7>>) -> !fir.ref<!fir.array<7x!fir.char<1>>>
32 ! CHECK: %[[a14:.*]] = fir.coordinate_of %[[a13]], %[[a12]] : (!fir.ref<!fir.array<7x!fir.char<1>>>, index) -> !fir.ref<!fir.char<1>>
33 ! CHECK: %[[a15:.*]] = fir.convert %[[a14]] : (!fir.ref<!fir.char<1>>) -> !fir.ref<!fir.char<1,?>>
34 ! CHECK: %[[a16:.*]] = fir.emboxchar %[[a15]], {{.*}} : (!fir.ref<!fir.char<1,?>>, index) -> !fir.boxchar<1>
35 ! CHECK: %[[a17:.*]] = fir.call @_QPinner(%[[a16]]) {{.*}}: (!fir.boxchar<1>) -> i32
36 result
= inner(string(1:2)(ival
:ival
))
38 end subroutine substring_main