[flang] Accept polymorphic component element in storage_size
[llvm-project.git] / flang / test / Lower / basic-function.f90
blob2ff3ef2a0bd2cf18fd01e157056714f76a44b227
1 ! RUN: bbc %s -o "-" -emit-fir | 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() -> !fir.complex<2>
118 ! CHECK: return %{{.*}} : !fir.complex<2>
120 complex(3) function cplxfct2()
122 ! CHECK-LABEL: func @_QPcplxfct2() -> !fir.complex<3>
123 ! CHECK: return %{{.*}} : !fir.complex<3>
125 complex(4) function cplxfct3()
127 ! CHECK-LABEL: func @_QPcplxfct3() -> !fir.complex<4>
128 ! CHECK: return %{{.*}} : !fir.complex<4>
130 complex(8) function cplxfct4()
132 ! CHECK-LABEL: func @_QPcplxfct4() -> !fir.complex<8>
133 ! CHECK: return %{{.*}} : !fir.complex<8>
135 complex(10) function cplxfct5()
137 ! CHECK-LABEL: func @_QPcplxfct5() -> !fir.complex<10>
138 ! CHECK: return %{{.*}} : !fir.complex<10>
140 complex(16) function cplxfct6()
142 ! CHECK-LABEL: func @_QPcplxfct6() -> !fir.complex<16>
143 ! CHECK: return %{{.*}} : !fir.complex<16>
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> {