IR: de-duplicate two CmpInst routines (NFC) (#116866)
[llvm-project.git] / flang / test / Lower / assumed-type.f90
blob44ce41d757379074cf3b529c2d11944d9911f1bf
1 ! RUN: bbc -emit-fir -hlfir=false %s -o - | FileCheck %s
3 module assumed_type_test
5 interface
6 subroutine assumed(a)
7 type(*), intent(in), target :: a
8 end subroutine
9 end interface
11 interface
12 subroutine assumed_r(a)
13 type(*), intent(in), target :: a(*)
14 end subroutine
15 end interface
17 contains
19 subroutine call_assumed()
20 integer, target :: i
21 call assumed(i)
22 end subroutine
24 ! CHECK-LABEL: func.func @_QMassumed_type_testPcall_assumed() {
25 ! CHECK: %[[I:.*]] = fir.alloca i32 {bindc_name = "i", fir.target, uniq_name = "_QMassumed_type_testFcall_assumedEi"}
26 ! CHECK: %[[CONV:.*]] = fir.convert %[[I]] : (!fir.ref<i32>) -> !fir.ref<none>
27 ! CHECK: fir.call @_QPassumed(%[[CONV]]) {{.*}}: (!fir.ref<none>) -> ()
29 subroutine call_assumed_r()
30 integer, target :: i(10)
31 call assumed_r(i)
32 end subroutine
34 ! CHECK-LABEL: func.func @_QMassumed_type_testPcall_assumed_r() {
35 ! CHECK: %[[I:.*]] = fir.alloca !fir.array<10xi32> {bindc_name = "i", fir.target, uniq_name = "_QMassumed_type_testFcall_assumed_rEi"}
36 ! CHECK: %[[CONV:.*]] = fir.convert %[[I]] : (!fir.ref<!fir.array<10xi32>>) -> !fir.ref<!fir.array<?xnone>>
37 ! CHECK: fir.call @_QPassumed_r(%[[CONV]]) {{.*}} : (!fir.ref<!fir.array<?xnone>>) -> ()
39 subroutine assumed_type_optional_to_intrinsic(a)
40 type(*), optional :: a(:)
41 if (present(a)) print*, 'present'
42 end subroutine
44 ! CHECK-LABEL: func.func @_QMassumed_type_testPassumed_type_optional_to_intrinsic(
45 ! CHECK-SAME: %[[ARG0:.*]]: !fir.box<!fir.array<?xnone>> {fir.bindc_name = "a", fir.optional}) {
46 ! CHECK: %{{.*}} = fir.is_present %[[ARG0]] : (!fir.box<!fir.array<?xnone>>) -> i1
48 subroutine assumed_type_lbound(a)
49 type(*), optional :: a(:,:)
50 print*,lbound(a,dim=1)
51 end subroutine
53 ! CHECK-LABEL: func.func @_QMassumed_type_testPassumed_type_lbound(
54 ! CHECK-SAME: %[[ARG0:.*]]: !fir.box<!fir.array<?x?xnone>> {fir.bindc_name = "a", fir.optional}) {
55 ! CHECK: %[[C1:.*]] = arith.constant 1 : i32
56 ! CHECK: %{{.*}} = fir.call @_FortranAioOutputInteger32(%{{.*}}, %[[C1]]) {{.*}} : (!fir.ref<i8>, i32) -> i1
58 end module