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