xref: /llvm-project/flang/test/Lower/logical-as-fortran.f90 (revision 4cc9437a7e649e2d1a1a47578f6ffb4d420b8d60)
1! Test that logicals are lowered to Fortran logical types where it matters
2! RUN: bbc %s -emit-fir -o - | FileCheck %s
3
4! Logicals should be lowered to Fortran logical types in memory/function
5! interfaces.
6
7
8! CHECK-LABEL: _QPtest_value_arguments
9subroutine test_value_arguments()
10interface
11subroutine foo2(l)
12  logical(2) :: l
13end subroutine
14subroutine foo4(l)
15  logical(4) :: l
16end subroutine
17end interface
18
19  ! CHECK: %[[true2:.*]] = fir.convert %true{{.*}} : (i1) -> !fir.logical<2>
20  ! CHECK: fir.store %[[true2]] to %[[mem2:.*]] : !fir.ref<!fir.logical<2>>
21  ! CHECK: fir.call @_QPfoo2(%[[mem2]]) {{.*}}: (!fir.ref<!fir.logical<2>>) -> ()
22call foo2(.true._2)
23
24  ! CHECK: %[[true4:.*]] = fir.convert %true{{.*}} : (i1) -> !fir.logical<4>
25  ! CHECK: fir.store %[[true4]] to %[[mem4:.*]] : !fir.ref<!fir.logical<4>>
26  ! CHECK: fir.call @_QPfoo4(%[[mem4]]) {{.*}}: (!fir.ref<!fir.logical<4>>) -> ()
27call foo4(.true.)
28
29end subroutine
30