xref: /llvm-project/flang/test/Lower/array-expression-slice-2.f90 (revision f35f863a88f83332bef9605ef4cfe4f05c066efb)
1! RUN: bbc -hlfir=false %s -o - | FileCheck %s
2
3! CHECK-LABEL: func @_QPi
4subroutine i
5  implicit none
6  integer :: ctemp(10) = (/1,2,3,4,5,6,7,8,9,22/)
7  print *, ctemp(1:10)
8end subroutine i
9
10! CHECK-LABEL: func @_QPs
11subroutine s
12  integer, parameter :: LONGreal = 8
13  real (kind = LONGreal), dimension(-1:11) :: x = (/0,0,0,0,0,0,0,0,0,0,0,0,0/)
14  real (kind = LONGreal), dimension(0:12) :: g = (/0,0,0,0,0,0,0,0,0,0,0,0,0/)
15  real (kind = LONGreal) :: gs(13)
16  x(1) = 4.0
17  g(1) = 5.0
18  gs = g(0:12:1) + x(11:(-1):(-1))
19  print *, gs
20  !print *, dot_product(g(0:12:1), x(11:(-1):(-1)))
21end subroutine s
22
23! CHECK-LABEL: func @_QPs2
24subroutine s2
25  real :: x(10)
26  x = 0.0
27  ! CHECK: fir.call @_FortranAioBeginExternalListOutput
28  print *, x
29  ! CHECK: %[[s:.*]] = fir.slice {{.*}} !fir.slice<1>
30  ! CHECK: %[[p:.*]] = fir.array_coor %{{.*}} [%[[s]]] %
31  ! CHECK: fir.store %{{.*}} to %[[p]] : !fir.ref<f32>
32  x(1:10:3) = 2.0
33  ! CHECK: fir.call @_FortranAioBeginExternalListOutput
34  print *, x
35end subroutine s2
36
37! CHECK-LABEL: func @_QQmain
38program main
39  integer :: A(10)
40  A(1) = 1
41  A(2) = 2
42  A(3) = 3
43  print *, A
44  ! CHECK: %[[A:.*]] = fir.address_of(@_QFEa)
45  ! CHECK: %[[shape:.*]] = fir.shape %c10
46  ! CHECK: %[[slice:.*]] = fir.slice %
47  ! CHECK: fir.embox %[[A]](%[[shape]]) [%[[slice]]] :
48  print*, A(1:3:1)
49  call s
50  call i
51end program main
52