1 ! RUN: bbc -emit-fir %s -o - | FileCheck %s
2 ! RUN: %flang_fc1 -emit-fir %s -o - | FileCheck %s
4 ! CHECK-LABEL: ichar_test
5 subroutine ichar_test(c
)
8 ! CHECK-DAG: %[[unbox:.*]]:2 = fir.unboxchar
9 ! CHECK-DAG: %[[J:.*]] = fir.alloca i32 {{{.*}}uniq_name = "{{.*}}Ej"}
10 ! CHECK-DAG: %[[STR:.*]] = fir.alloca !fir.array{{.*}} {{{.*}}uniq_name = "{{.*}}Estr"}
11 ! CHECK: %[[BOX:.*]] = fir.convert %[[unbox]]#0 : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.char<1>>
12 ! CHECK: %[[PTR:.*]] = fir.load %[[BOX]] : !fir.ref<!fir.char<1>>
13 ! CHECK: %[[CHAR:.*]] = fir.extract_value %[[PTR]], [0 : index] :
14 ! CHECK: %[[ARG:.*]] = arith.extui %[[CHAR]] : i8 to i32
15 ! CHECK: fir.call @{{.*}}OutputInteger32{{.*}}%[[ARG]]
16 ! CHECK: fir.call @{{.*}}EndIoStatement
19 ! CHECK-DAG: %{{.*}} = fir.load %[[J]] : !fir.ref<i32>
20 ! CHECK: %[[PTR1:.*]] = fir.coordinate_of %[[STR]], %
21 ! CHECK: %[[PTR2:.*]] = fir.load %[[PTR1]] : !fir.ref<!fir.char<1>>
22 ! CHECK: %[[CHAR:.*]] = fir.extract_value %[[PTR2]], [0 : index] :
23 ! CHECK: %[[ARG:.*]] = arith.extui %[[CHAR]] : i8 to i32
24 ! CHECK: fir.call @{{.*}}OutputInteger32{{.*}}%[[ARG]]
25 ! CHECK: fir.call @{{.*}}EndIoStatement
26 print *, ichar(str(J
))
28 ! "Magic" 88 below is the ASCII code for `X` and the value returned by IACHAR (’X’)
29 ! CHECK: %[[c88:.*]] = arith.constant 88 : i32
30 ! CHECK-NEXT: fir.call @{{.*}}OutputInteger32({{.*}}, %[[c88]])
31 ! CHECK-NEXT: fir.call @{{.*}}EndIoStatement
35 ! Check that 'arith.extui' op is not generated if type are matching.
36 ! CHECK-LABEL: no_extui
37 subroutine no_extui(ch
)
38 integer, parameter :: kind
= selected_char_kind('ISO_10646')
39 character(*, kind
), intent(in
) :: ch(:)
41 ! CHECK-NOT: arith.extui