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