Break circular dependency between FIR dialect and utilities
[llvm-project.git] / flang / test / Lower / zero-size.f90
blob244062b37b92d85e64a15d6755bb2391788b852d
1 ! RUN: bbc -o - %s | FileCheck %s
3 ! CHECK-LABEL: _QPzero1
4 subroutine zero1(z)
5 real, dimension(:) :: z
6 print*, size(z), z, ':'
7 end
9 ! CHECK-LABEL: _QPzero2
10 subroutine zero2
11 type dt
12 integer :: j = 17
13 end type
14 ! CHECK: %[[z:[0-9]*]] = fir.alloca !fir.array<0x!fir.type<_QFzero2Tdt{j:i32}>> {bindc_name = "z", uniq_name = "_QFzero2Ez"}
15 ! CHECK: %[[shape:[0-9]*]] = fir.shape %c0 : (index) -> !fir.shape<1>
16 ! CHECK: fir.embox %[[z]](%[[shape]]) : (!fir.ref<!fir.array<0x!fir.type<_QFzero2Tdt{j:i32}>>>, !fir.shape<1>) -> !fir.box<!fir.array<0x!fir.type<_QFzero2Tdt{j:i32}>>>
17 type(dt) :: z(0)
18 print*, size(z), z, ':'
19 end
21 ! CHECK-LABEL: _QPzero3
22 subroutine zero3
23 type dt
24 integer :: j
25 end type
26 ! CHECK: %[[z:[0-9]*]] = fir.address_of(@_QFzero3Ez) : !fir.ref<!fir.array<0x!fir.type<_QFzero3Tdt{j:i32}>>>
27 ! CHECK: %[[shape:[0-9]*]] = fir.shape %c0 : (index) -> !fir.shape<1>
28 ! CHECK: fir.embox %[[z]](%[[shape]]) : (!fir.ref<!fir.array<0x!fir.type<_QFzero3Tdt{j:i32}>>>, !fir.shape<1>) -> !fir.box<!fir.array<0x!fir.type<_QFzero3Tdt{j:i32}>>>
29 type(dt) :: z(0) = dt(99)
30 print*, size(z), z, ':'
31 end
33 ! CHECK-LABEL: _QQmain
34 program prog
35 real nada(2:-1)
36 interface
37 subroutine zero1(aa)
38 real, dimension(:) :: aa
39 end
40 end interface
41 ! CHECK: %[[shape:[0-9]*]] = fir.shape_shift %c2, %c0 : (index, index) -> !fir.shapeshift<1>
42 ! CHECK: %2 = fir.embox %0(%[[shape]]) : (!fir.ref<!fir.array<0xf32>>, !fir.shapeshift<1>) -> !fir.box<!fir.array<0xf32>>
43 call zero1(nada)
44 call zero2
45 call zero3
46 end