Break circular dependency between FIR dialect and utilities
[llvm-project.git] / flang / test / Lower / global-initialization.f90
blobdd60a6fd8b9f8615b3593657e6bd79adb633eb4e
1 ! RUN: bbc %s -o - | FileCheck %s
3 program bar
4 ! CHECK: fir.address_of(@[[name1:.*]]my_data)
5 integer, save :: my_data = 1
6 print *, my_data
7 contains
9 ! CHECK-LABEL: func @_QFPfoo
10 subroutine foo()
11 ! CHECK: fir.address_of(@[[name2:.*foo.*my_data]])
12 integer, save :: my_data = 2
13 print *, my_data + 1
14 end subroutine
16 ! CHECK-LABEL: func @_QFPfoo2
17 subroutine foo2()
18 ! CHECK: fir.address_of(@[[name3:.*foo2.*my_data]])
19 integer, save :: my_data
20 my_data = 4
21 print *, my_data
22 end subroutine
24 ! CHECK-LABEL: func @_QFPfoo3
25 subroutine foo3()
26 ! CHECK-DAG: fir.address_of(@[[name4:.*foo3.*idata]]){{.*}}fir.array<5xi32>
27 ! CHECK-DAG: fir.address_of(@[[name5:.*foo3.*rdata]]){{.*}}fir.array<3xf16>
28 ! CHECK-DAG: fir.address_of(@[[name6:.*foo3.*my_data]]){{.*}}fir.array<2x4xi64>
29 integer*4, dimension(5), save :: idata = (/ (i*i, i=1,5) /)
30 integer*8, dimension(2, 10:13), save :: my_data = reshape((/1,2,3,4,5,6,7,8/), shape(my_data))
31 real*2, dimension(7:9), save :: rdata = (/100., 99., 98./)
32 print *, rdata(9)
33 print *, idata(3)
34 print *, my_data(1,11)
35 end subroutine
36 end program
38 ! CHECK: fir.global internal @[[name1]]
39 ! CHECK: fir.global internal @[[name2]]
40 ! CHECK: fir.global internal @[[name3]]
41 ! CHECK-DAG: fir.global internal @[[name4]]{{.*}}fir.array<5xi32>
42 ! CHECK-DAG: fir.global internal @[[name5]]{{.*}}fir.array<3xf16>
43 ! CHECK-DAG: fir.global internal @[[name6]]{{.*}}fir.array<2x4xi64>