IR: de-duplicate two CmpInst routines (NFC) (#116866)
[llvm-project.git] / flang / test / Lower / basic-function.f90
blobf5f81545c899df1cb6a40b061473a095bf792f98
1 ! RUN: bbc %s -o "-" -emit-fir -hlfir=false | FileCheck %s
3 integer(1) function fct1()
4 end
5 ! CHECK-LABEL: func @_QPfct1() -> i8
6 ! CHECK: return %{{.*}} : i8
8 integer(2) function fct2()
9 end
10 ! CHECK-LABEL: func @_QPfct2() -> i16
11 ! CHECK: return %{{.*}} : i16
13 integer(4) function fct3()
14 end
15 ! CHECK-LABEL: func @_QPfct3() -> i32
16 ! CHECK: return %{{.*}} : i32
18 integer(8) function fct4()
19 end
20 ! CHECK-LABEL: func @_QPfct4() -> i64
21 ! CHECK: return %{{.*}} : i64
23 integer(16) function fct5()
24 end
25 ! CHECK-LABEL: func @_QPfct5() -> i128
26 ! CHECK: return %{{.*}} : i128
28 function fct()
29 integer :: fct
30 end
31 ! CHECK-LABEL: func @_QPfct() -> i32
32 ! CHECK: return %{{.*}} : i32
34 function fct_res() result(res)
35 integer :: res
36 end
37 ! CHECK-LABEL: func @_QPfct_res() -> i32
38 ! CHECK: return %{{.*}} : i32
40 integer function fct_body()
41 goto 1
42 1 stop
43 end
45 ! CHECK-LABEL: func @_QPfct_body() -> i32
46 ! CHECK: cf.br ^bb1
47 ! CHECK: ^bb1
48 ! CHECK: %{{.*}} = fir.call @_FortranAStopStatement
49 ! CHECK: fir.unreachable
51 function fct_iarr1()
52 integer, dimension(10) :: fct_iarr1
53 end
55 ! CHECK-LABEL: func @_QPfct_iarr1() -> !fir.array<10xi32>
56 ! CHECK: return %{{.*}} : !fir.array<10xi32>
58 function fct_iarr2()
59 integer, dimension(10, 20) :: fct_iarr2
60 end
62 ! CHECK-LABEL: func @_QPfct_iarr2() -> !fir.array<10x20xi32>
63 ! CHECK: return %{{.*}} : !fir.array<10x20xi32>
65 logical(1) function lfct1()
66 end
67 ! CHECK-LABEL: func @_QPlfct1() -> !fir.logical<1>
68 ! CHECK: return %{{.*}} : !fir.logical<1>
70 logical(2) function lfct2()
71 end
72 ! CHECK-LABEL: func @_QPlfct2() -> !fir.logical<2>
73 ! CHECK: return %{{.*}} : !fir.logical<2>
75 logical(4) function lfct3()
76 end
77 ! CHECK-LABEL: func @_QPlfct3() -> !fir.logical<4>
78 ! CHECK: return %{{.*}} : !fir.logical<4>
80 logical(8) function lfct4()
81 end
82 ! CHECK-LABEL: func @_QPlfct4() -> !fir.logical<8>
83 ! CHECK: return %{{.*}} : !fir.logical<8>
85 real(2) function rfct1()
86 end
87 ! CHECK-LABEL: func @_QPrfct1() -> f16
88 ! CHECK: return %{{.*}} : f16
90 real(3) function rfct2()
91 end
92 ! CHECK-LABEL: func @_QPrfct2() -> bf16
93 ! CHECK: return %{{.*}} : bf16
95 real function rfct3()
96 end
97 ! CHECK-LABEL: func @_QPrfct3() -> f32
98 ! CHECK: return %{{.*}} : f32
100 real(8) function rfct4()
102 ! CHECK-LABEL: func @_QPrfct4() -> f64
103 ! CHECK: return %{{.*}} : f64
105 real(10) function rfct5()
107 ! CHECK-LABEL: func @_QPrfct5() -> f80
108 ! CHECK: return %{{.*}} : f80
110 real(16) function rfct6()
112 ! CHECK-LABEL: func @_QPrfct6() -> f128
113 ! CHECK: return %{{.*}} : f128
115 complex(2) function cplxfct1()
117 ! CHECK-LABEL: func @_QPcplxfct1() -> complex<f16>
118 ! CHECK: return %{{.*}} : complex<f16>
120 complex(3) function cplxfct2()
122 ! CHECK-LABEL: func @_QPcplxfct2() -> complex<bf16>
123 ! CHECK: return %{{.*}} : complex<bf16>
125 complex(4) function cplxfct3()
127 ! CHECK-LABEL: func @_QPcplxfct3() -> complex<f32>
128 ! CHECK: return %{{.*}} : complex<f32>
130 complex(8) function cplxfct4()
132 ! CHECK-LABEL: func @_QPcplxfct4() -> complex<f64>
133 ! CHECK: return %{{.*}} : complex<f64>
135 complex(10) function cplxfct5()
137 ! CHECK-LABEL: func @_QPcplxfct5() -> complex<f80>
138 ! CHECK: return %{{.*}} : complex<f80>
140 complex(16) function cplxfct6()
142 ! CHECK-LABEL: func @_QPcplxfct6() -> complex<f128>
143 ! CHECK: return %{{.*}} : complex<f128>
145 function fct_with_character_return(i)
146 character(10) :: fct_with_character_return
147 integer :: i
149 ! CHECK-LABEL: func @_QPfct_with_character_return(
150 ! CHECK-SAME: %{{.*}}: !fir.ref<!fir.char<1,10>>{{.*}}, %{{.*}}: index{{.*}}, %{{.*}}: !fir.ref<i32>{{.*}}) -> !fir.boxchar<1> {