llvm-project/flang/test/Lower/zero-size.f90
Valentin Clement 99d239341c
[flang][NFC] Add lowering tests
Add couple of tests for the lowering.

This patch is part of the upstreaming effort from fir-dev branch.

Reviewed By: PeteSteinfeld

Differential Revision: https://reviews.llvm.org/D121991

Co-authored-by: Jean Perier <jperier@nvidia.com>
Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
Co-authored-by: V Donaldson <vdonaldson@nvidia.com>
2022-03-18 14:48:56 +01:00

47 lines
1.5 KiB
Fortran

! RUN: bbc -o - %s | FileCheck %s
! CHECK-LABEL: _QPzero1
subroutine zero1(z)
real, dimension(:) :: z
print*, size(z), z, ':'
end
! CHECK-LABEL: _QPzero2
subroutine zero2
type dt
integer :: j = 17
end type
! CHECK: %[[z:[0-9]*]] = fir.alloca !fir.array<0x!fir.type<_QFzero2Tdt{j:i32}>> {bindc_name = "z", uniq_name = "_QFzero2Ez"}
! CHECK: %[[shape:[0-9]*]] = fir.shape %c0 : (index) -> !fir.shape<1>
! 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}>>>
type(dt) :: z(0)
print*, size(z), z, ':'
end
! CHECK-LABEL: _QPzero3
subroutine zero3
type dt
integer :: j
end type
! CHECK: %[[z:[0-9]*]] = fir.address_of(@_QFzero3Ez) : !fir.ref<!fir.array<0x!fir.type<_QFzero3Tdt{j:i32}>>>
! CHECK: %[[shape:[0-9]*]] = fir.shape %c0 : (index) -> !fir.shape<1>
! 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}>>>
type(dt) :: z(0) = dt(99)
print*, size(z), z, ':'
end
! CHECK-LABEL: _QQmain
program prog
real nada(2:-1)
interface
subroutine zero1(aa)
real, dimension(:) :: aa
end
end interface
! CHECK: %[[shape:[0-9]*]] = fir.shape_shift %c2, %c0 : (index, index) -> !fir.shapeshift<1>
! CHECK: %2 = fir.embox %0(%[[shape]]) : (!fir.ref<!fir.array<0xf32>>, !fir.shapeshift<1>) -> !fir.box<!fir.array<0xf32>>
call zero1(nada)
call zero2
call zero3
end