1 ! Test expression rewrites, in case where the expression cannot be
2 ! folded to constant values.
3 ! RUN: %flang_fc1 -fdebug-unparse %s 2>&1 | FileCheck %s
5 ! Test rewrites of inquiry intrinsics with arguments whose shape depends
6 ! on a function reference with non constant shape. The function reference
10 function returns_array(n
, m
)
11 integer :: returns_array(10:n
+10,10:m
+10)
15 function returns_array_2(n
)
16 integer, intent(in
) :: n
17 integer :: returns_array_2(n
)
21 function returns_array_3()
22 integer :: returns_array_3(7:46+2)
26 subroutine ubound_test(x
, n
, m
)
28 !CHECK: PRINT *, [INTEGER(4)::int(size(x,dim=1),kind=4),int(size(x,dim=2),kind=4)]
30 !CHECK: PRINT *, ubound(returns_array(n,m))
31 print *, ubound(returns_array(n
, m
))
32 !CHECK: PRINT *, ubound(returns_array(n,m),dim=1_4)
33 print *, ubound(returns_array(n
, m
), dim
=1)
34 !CHECK: PRINT *, ubound(returns_array_2(m))
35 print *, ubound(returns_array_2(m
))
37 print *, ubound(returns_array_3(), dim
=1, kind
=8)
40 subroutine size_test(x
, n
, m
)
42 !CHECK: PRINT *, int(size(x,dim=1)*size(x,dim=2),kind=4)
44 !CHECK: PRINT *, size(returns_array(n,m))
45 print *, size(returns_array(n
, m
))
46 !CHECK: PRINT *, size(returns_array(n,m),dim=1_4)
47 print *, size(returns_array(n
, m
), dim
=1)
48 !CHECK: PRINT *, size(returns_array_2(m))
49 print *, size(returns_array_2(m
))
51 print *, size(returns_array_3(), kind
=8)
54 subroutine shape_test(x
, n
, m
)
56 !CHECK: PRINT *, [INTEGER(4)::int(size(x,dim=1),kind=4),int(size(x,dim=2),kind=4)]
58 !CHECK: PRINT *, shape(returns_array(n,m))
59 print *, shape(returns_array(n
, m
))
60 !CHECK: PRINT *, shape(returns_array_2(m))
61 print *, shape(returns_array_2(m
))
62 !CHECK: PRINT *, [INTEGER(8)::42_8]
63 print *, shape(returns_array_3(), kind
=8)
66 subroutine lbound_test(x
, n
, m
)
68 !CHECK: PRINT *, [INTEGER(4)::1_4,1_4]
70 !CHECK: PRINT *, [INTEGER(4)::1_4,1_4]
71 print *, lbound(returns_array(n
, m
))
73 print *, lbound(returns_array(n
, m
), dim
=1)
75 print *, lbound(returns_array_2(m
), dim
=1)
77 print *, lbound(returns_array_3(), dim
=1)
81 subroutine len_test(a
,b
, c
, d
, e
, n
, m
)
82 character(*), intent(in
) :: a
85 character(10), intent(in
) :: c
88 integer, intent(in
) :: n
, m
89 character(n
), intent(in
) :: e
91 !CHECK: PRINT *, int(a%len,kind=4)
95 !CHECK: PRINT *, len(b(a))
97 !CHECK: PRINT *, len(b(a)//a)
98 print *, len(b(a
) // a
)
101 !CHECK: PRINT *, len(c(int(i,kind=8):int(j,kind=8)))
105 !CHECK: PRINT *, 10_4
107 !CHECK: PRINT *, 20_4
108 print *, len(d(c
) // c
)
110 print *, len(a(10:4))
111 !CHECK: PRINT *, int(max(0_8,int(m,kind=8)-int(n,kind=8)+1_8),kind=4)
113 !CHECK: PRINT *, len(b(a(int(n,kind=8):int(m,kind=8))))
114 print *, len(b(a(n
:m
)))
115 !CHECK: PRINT *, int(max(0_8,max(0_8,int(n,kind=8))-4_8+1_8),kind=4)
117 end subroutine len_test