[WebAssembly] Fix asan issue from https://reviews.llvm.org/D121349
[llvm-project.git] / flang / test / Evaluate / folding08.f90
blobf00ec873a0324c46717bf5070a72c934cce282dc
1 ! RUN: %python %S/test_folding.py %s %flang_fc1
2 ! Test folding of LBOUND and UBOUND
4 module m
5 real :: a3(42:52)
6 integer, parameter :: lba3(*) = lbound(a3)
7 logical, parameter :: test_lba3 = all(lba3 == [42])
8 type :: t
9 real :: a
10 end type
11 type(t) :: ta(0:2)
12 character(len=2) :: ca(-1:1)
13 integer, parameter :: lbtadim = lbound(ta,1)
14 logical, parameter :: test_lbtadim = lbtadim == 0
15 integer, parameter :: ubtadim = ubound(ta,1)
16 logical, parameter :: test_ubtadim = ubtadim == 2
17 integer, parameter :: lbta1(*) = lbound(ta)
18 logical, parameter :: test_lbta1 = all(lbta1 == [0])
19 integer, parameter :: ubta1(*) = ubound(ta)
20 logical, parameter :: test_ubta1 = all(ubta1 == [2])
21 integer, parameter :: lbta2(*) = lbound(ta(:))
22 logical, parameter :: test_lbta2 = all(lbta2 == [1])
23 integer, parameter :: ubta2(*) = ubound(ta(:))
24 logical, parameter :: test_ubta2 = all(ubta2 == [3])
25 integer, parameter :: lbta3(*) = lbound(ta%a)
26 logical, parameter :: test_lbta3 = all(lbta3 == [1])
27 integer, parameter :: ubta3(*) = ubound(ta%a)
28 logical, parameter :: test_ubta3 = all(ubta3 == [3])
29 integer, parameter :: lbca1(*) = lbound(ca)
30 logical, parameter :: test_lbca1 = all(lbca1 == [-1])
31 integer, parameter :: ubca1(*) = ubound(ca)
32 logical, parameter :: test_ubca1 = all(ubca1 == [1])
33 integer, parameter :: lbca2(*) = lbound(ca(:)(1:1))
34 logical, parameter :: test_lbca2 = all(lbca2 == [1])
35 integer, parameter :: ubca2(*) = ubound(ca(:)(1:1))
36 logical, parameter :: test_ubca2 = all(ubca2 == [3])
37 integer, parameter :: lbfoo(*) = lbound(foo())
38 logical, parameter :: test_lbfoo = all(lbfoo == [1,1])
39 integer, parameter :: ubfoo(*) = ubound(foo())
40 logical, parameter :: test_ubfoo = all(ubfoo == [2,3])
41 contains
42 function foo()
43 real :: foo(2:3,4:6)
44 end function
45 subroutine test(n1,a1,a2)
46 integer, intent(in) :: n1
47 real, intent(in) :: a1(1:n1), a2(0:*)
48 integer, parameter :: lba1(*) = lbound(a1)
49 logical, parameter :: test_lba1 = all(lba1 == [1])
50 integer, parameter :: lba2(*) = lbound(a2)
51 logical, parameter :: test_lba2 = all(lba2 == [0])
52 end subroutine
53 subroutine test2
54 real :: a(2:3,4:6)
55 associate (b => a)
56 block
57 integer, parameter :: lbb(*) = lbound(b)
58 logical, parameter :: test_lbb = all(lbb == [2,4])
59 integer, parameter :: ubb(*) = ubound(b)
60 logical, parameter :: test_ubb = all(ubb == [3,6])
61 end block
62 end associate
63 associate (b => a + 0)
64 block
65 integer, parameter :: lbb(*) = lbound(b)
66 logical, parameter :: test_lbb = all(lbb == [1,1])
67 integer, parameter :: ubb(*) = ubound(b)
68 logical, parameter :: test_ubb = all(ubb == [2,3])
69 end block
70 end associate
71 end subroutine
72 end