[WebAssembly] Fix asan issue from https://reviews.llvm.org/D121349
[llvm-project.git] / flang / test / Evaluate / rewrite01.f90
blob1627dc62c1b9d77462bab9a61fe219807c4ea5d8
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
7 ! must be retained.
8 module some_mod
9 contains
10 function returns_array(n, m)
11 integer :: returns_array(10:n+10,10:m+10)
12 returns_array = 0
13 end function
15 function returns_array_2(n)
16 integer, intent(in) :: n
17 integer :: returns_array_2(n)
18 returns_array_2 = 0
19 end function
21 function returns_array_3()
22 integer :: returns_array_3(7:46+2)
23 returns_array_3 = 0
24 end function
26 subroutine ubound_test(x, n, m)
27 integer :: x(n, m)
28 !CHECK: PRINT *, [INTEGER(4)::int(size(x,dim=1),kind=4),int(size(x,dim=2),kind=4)]
29 print *, ubound(x)
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))
36 !CHECK: PRINT *, 42_8
37 print *, ubound(returns_array_3(), dim=1, kind=8)
38 end subroutine
40 subroutine size_test(x, n, m)
41 integer :: x(n, m)
42 !CHECK: PRINT *, int(size(x,dim=1)*size(x,dim=2),kind=4)
43 print *, size(x)
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))
50 !CHECK: PRINT *, 42_8
51 print *, size(returns_array_3(), kind=8)
52 end subroutine
54 subroutine shape_test(x, n, m)
55 integer :: x(n, m)
56 !CHECK: PRINT *, [INTEGER(4)::int(size(x,dim=1),kind=4),int(size(x,dim=2),kind=4)]
57 print *, shape(x)
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)
64 end subroutine
66 subroutine lbound_test(x, n, m)
67 integer :: x(n, m)
68 !CHECK: PRINT *, [INTEGER(4)::1_4,1_4]
69 print *, lbound(x)
70 !CHECK: PRINT *, [INTEGER(4)::1_4,1_4]
71 print *, lbound(returns_array(n, m))
72 !CHECK: PRINT *, 1_4
73 print *, lbound(returns_array(n, m), dim=1)
74 !CHECK: PRINT *, 1_4
75 print *, lbound(returns_array_2(m), dim=1)
76 !CHECK: PRINT *, 1_4
77 print *, lbound(returns_array_3(), dim=1)
78 end subroutine
80 !CHECK: len_test
81 subroutine len_test(a,b, c, d, e, n, m)
82 character(*), intent(in) :: a
83 character(*) :: b
84 external b
85 character(10), intent(in) :: c
86 character(10) :: d
87 external d
88 integer, intent(in) :: n, m
89 character(n), intent(in) :: e
91 !CHECK: PRINT *, int(a%len,kind=4)
92 print *, len(a)
93 !CHECK: PRINT *, 5_4
94 print *, len(a(1:5))
95 !CHECK: PRINT *, len(b(a))
96 print *, len(b(a))
97 !CHECK: PRINT *, len(b(a)//a)
98 print *, len(b(a) // a)
99 !CHECK: PRINT *, 10_4
100 print *, len(c)
101 !CHECK: PRINT *, len(c(int(i,kind=8):int(j,kind=8)))
102 print *, len(c(i:j))
103 !CHECK: PRINT *, 5_4
104 print *, len(c(1:5))
105 !CHECK: PRINT *, 10_4
106 print *, len(d(c))
107 !CHECK: PRINT *, 20_4
108 print *, len(d(c) // c)
109 !CHECK: PRINT *, 0_4
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)
112 print *, len(a(n:m))
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)
116 print *, len(e(4:))
117 end subroutine len_test
119 end module