llvm-project/flang/test/Lower/HLFIR/designators-parameter-array-slice.f90
Slava Zakharin 449823e202 [flang] Fixed IsContiguous check for slices of parameter arrays.
A section of a parameter array may be non-contiguous,
so the current !IsVariable(expr) check is too optimistic
to claim contiguity.

This patch fixes issues with incorrect hlfir.designate op generated
during lowering: the lowering queries IsContiguous to decide whether
to use fir.box<fir.array> or plain fir.ref<fir.array> to represent
the designator result.

Reviewed By: klausler

Differential Revision: https://reviews.llvm.org/D156494
2023-08-02 10:45:00 -07:00

12 lines
564 B
Fortran

! Test non-contiguous slice of parameter array.
! RUN: bbc -emit-hlfir --polymorphic-type -o - %s | FileCheck %s
subroutine test2(i)
integer, parameter :: a(*,*) = reshape( [ 1,2,3,4 ], [ 2,2 ])
integer :: x(2)
x = a(i,:)
end subroutine test2
! Check that the result type of the designate operation
! is a box (as opposed to !fir.ref<!fir.array<>>) that is able
! to represent non-contiguous array section:
! CHECK: hlfir.designate {{.*}} shape {{.*}} : (!fir.ref<!fir.array<2x2xi32>>, i64, index, index, index, !fir.shape<1>) -> !fir.box<!fir.array<2xi32>>