1 ! RUN: bbc %s -o "-" -emit-fir | FileCheck %s
3 ! CHECK-LABEL: func @_QPsub() {
8 ! CHECK-LABEL: func @_QPasubroutine() {
9 subroutine AsUbRoUtInE()
13 ! CHECK-LABEL: func @_QPfoo() -> f32 {
21 ! CHECK-LABEL: func @_QPfunctn() -> f32 {
23 real, parameter :: pi
= 3.14
30 ! CHECK-LABEL: func @_QMtestmodPsub() {
35 ! CHECK-LABEL: func @_QMtestmodPfoo() -> f32 {
43 ! CHECK-LABEL: func @_QPfoo2()
47 ! CHECK-LABEL: func @_QFfoo2Psub() {
52 ! CHECK-LABEL: func @_QFfoo2Pfoo() {
58 ! CHECK-LABEL: func @_QPsub2()
61 ! CHECK-LABEL: func @_QFsub2Psub() {
66 ! CHECK-LABEL: func @_QFsub2Pfoo() {
74 ! CHECK-LABEL: func @_QMtestmod2Psub()
77 ! CHECK-LABEL: func @_QMtestmod2FsubPsubsub() {
87 module subroutine draw()
89 module function erase()
93 end module color_points
95 submodule (color_points
) color_points_a
97 ! CHECK-LABEL: func @_QMcolor_pointsScolor_points_aPsub() {
103 submodule (color_points
:color_points_a
) impl
105 ! CHECK-LABEL: func @_QMcolor_pointsScolor_points_aSimplPfoo()
108 ! CHECK-LABEL: func @_QMcolor_pointsScolor_points_aSimplFfooPbar() {
113 ! CHECK-LABEL: func @_QMcolor_pointsPdraw() {
114 module subroutine draw()
116 !FIXME func @_QMcolor_pointsPerase() -> i32 {
117 module procedure erase
122 ! CHECK-LABEL: func @_QPshould_not_collide() {
123 subroutine should_not_collide()
127 ! CHECK-LABEL: func @_QQmain() attributes {fir.bindc_name = "test"} {
131 ! CHECK-LABEL: func @_QFPshould_not_collide() {
132 subroutine should_not_collide()
137 ! CHECK-LABEL: func @omp_get_num_threads() -> f32 attributes {fir.bindc_name = "omp_get_num_threads"} {
138 function omp_get_num_threads() bind(c
)
142 ! CHECK-LABEL: func @get_threads() -> f32 attributes {fir.bindc_name = "get_threads"} {
143 function omp_get_num_threads_1() bind(c
, name
="get_threads")
147 ! CHECK-LABEL: func @bEtA() -> f32 attributes {fir.bindc_name = "bEtA"} {
148 function alpha() bind(c
, name
=" bEtA ")
152 ! CHECK-LABEL: func @bc1() attributes {fir.bindc_name = "bc1"} {
153 subroutine bind_c_s() Bind(C
,Name
='bc1')
155 end subroutine bind_c_s
157 ! CHECK-LABEL: func @_QPbind_c_s() {
158 subroutine bind_c_s()
159 ! CHECK: fir.call @_QPbind_c_q() {{.*}}: () -> ()
164 ! CHECK-LABEL: func @_QPbind_c_q() {
165 subroutine bind_c_q()
167 subroutine bind_c_s() Bind(C
, name
='bc1')
170 ! CHECK: fir.call @bc1() {{.*}}: () -> ()
175 ! Test that BIND(C) label is taken into account for ENTRY symbols.
176 ! CHECK-LABEL: func @_QPsub_with_entries() {
177 subroutine sub_with_entries
178 ! CHECK-LABEL: func @bar() attributes {fir.bindc_name = "bar"} {
179 entry some_entry() bind(c
, name
="bar")
180 ! CHECK-LABEL: func @_QPnormal_entry() {
182 ! CHECK-LABEL: func @some_other_entry() attributes {fir.bindc_name = "some_other_entry"} {
183 entry some_other_entry() bind(c
)
186 ! Test that semantics constructs binding labels with local name resolution
188 character*(*), parameter :: foo
= "bad!!"
189 character*(*), parameter :: ok
= "ok"
191 real function f1() bind(c
,name
=ok
//'1')
194 subroutine s1() bind(c
,name
=ok
//'2')
199 ! CHECK-LABEL: func @ok3() -> f32 attributes {fir.bindc_name = "ok3"} {
200 real function f2() bind(c
,name
=foo
//'3')
201 character*(*), parameter :: foo
= ok
202 ! CHECK: fir.call @ok1() {{.*}}: () -> f32
203 ! CHECK-LABEL: func @ok4() -> f32 attributes {fir.bindc_name = "ok4"} {
204 entry f3() bind(c
,name
=foo
//'4')
205 ! CHECK: fir.call @ok1() {{.*}}: () -> f32
208 ! CHECK-LABEL: func @ok5() attributes {fir.bindc_name = "ok5"} {
209 subroutine s2() bind(c
,name
=foo
//'5')
210 character*(*), parameter :: foo
= ok
211 ! CHECK: fir.call @ok2() {{.*}}: () -> ()
212 ! CHECK-LABEL: func @ok6() attributes {fir.bindc_name = "ok6"} {
213 entry s3() bind(c
,name
=foo
//'6')
214 ! CHECK: fir.call @ok2() {{.*}}: () -> ()
215 continue ! force end of specification part
216 ! CHECK-LABEL: func @ok7() attributes {fir.bindc_name = "ok7"} {
217 entry s4() bind(c
,name
=foo
//'7')
218 ! CHECK: fir.call @ok2() {{.*}}: () -> ()
224 ! CHECK-LABEL: func @_QPnest1
226 ! CHECK: fir.call @_QFnest1Pinner()
229 ! CHECK-LABEL: func @_QFnest1Pinner
231 ! CHECK: %[[V_0:[0-9]+]] = fir.address_of(@_QFnest1FinnerEkk) : !fir.ref<i32>
232 integer, save :: kk
= 1
233 print*, 'qq:inner', kk
237 ! CHECK-LABEL: func @_QPnest2
239 ! CHECK: fir.call @_QFnest2Pinner()
242 ! CHECK-LABEL: func @_QFnest2Pinner
244 ! CHECK: %[[V_0:[0-9]+]] = fir.address_of(@_QFnest2FinnerEkk) : !fir.ref<i32>
245 integer, save :: kk
= 77
246 print*, 'ss:inner', kk
250 ! CHECK-LABEL: fir.global internal @_QFfooEpi : f32 {