diff options
author | Ben Cheng <bccheng@google.com> | 2014-03-25 22:37:19 -0700 |
---|---|---|
committer | Ben Cheng <bccheng@google.com> | 2014-03-25 22:37:19 -0700 |
commit | 1bc5aee63eb72b341f506ad058502cd0361f0d10 (patch) | |
tree | c607e8252f3405424ff15bc2d00aa38dadbb2518 /gcc-4.9/gcc/testsuite/gfortran.dg/assumed_rank_bounds_2.f90 | |
parent | 283a0bf58fcf333c58a2a92c3ebbc41fb9eb1fdb (diff) | |
download | toolchain_gcc-1bc5aee63eb72b341f506ad058502cd0361f0d10.tar.gz toolchain_gcc-1bc5aee63eb72b341f506ad058502cd0361f0d10.tar.bz2 toolchain_gcc-1bc5aee63eb72b341f506ad058502cd0361f0d10.zip |
Initial checkin of GCC 4.9.0 from trunk (r208799).
Change-Id: I48a3c08bb98542aa215912a75f03c0890e497dba
Diffstat (limited to 'gcc-4.9/gcc/testsuite/gfortran.dg/assumed_rank_bounds_2.f90')
-rw-r--r-- | gcc-4.9/gcc/testsuite/gfortran.dg/assumed_rank_bounds_2.f90 | 112 |
1 files changed, 112 insertions, 0 deletions
diff --git a/gcc-4.9/gcc/testsuite/gfortran.dg/assumed_rank_bounds_2.f90 b/gcc-4.9/gcc/testsuite/gfortran.dg/assumed_rank_bounds_2.f90 new file mode 100644 index 000000000..b9c8e56f4 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gfortran.dg/assumed_rank_bounds_2.f90 @@ -0,0 +1,112 @@ +! { dg-do run } +! +! Test the behaviour of lbound, ubound of shape with assumed rank arguments +! in an array context (without DIM argument). +! + +program test + + integer :: a(2:4,-2:5) + integer, allocatable :: b(:,:) + integer, allocatable :: c(:,:) + integer, pointer :: d(:,:) + character(52) :: buffer + + b = foo(a) + !print *,b(:,1) + if (any(b(:,1) /= [11, 101])) call abort + buffer = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz' + write(buffer,*) b(:,1) + if (buffer /= ' 11 101') call abort + + !print *,b(:,2) + if (any(b(:,2) /= [3, 8])) call abort + buffer = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz' + write(buffer,*) b(:,2) + if (buffer /= ' 3 8') call abort + + !print *,b(:,3) + if (any(b(:,3) /= [13, 108])) call abort + buffer = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz' + write(buffer,*) b(:,3) + if (buffer /= ' 13 108') call abort + + + allocate(c(1:2,-3:6)) + b = bar(c) + !print *,b(:,1) + if (any(b(:,1) /= [11, 97])) call abort + buffer = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz' + write(buffer,*) b(:,1) + if (buffer /= ' 11 97') call abort + + !print *,b(:,2) + if (any(b(:,2) /= [12, 106])) call abort + buffer = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz' + write(buffer,*) b(:,2) + if (buffer /= ' 12 106') call abort + + !print *,b(:,3) + if (any(b(:,3) /= [2, 10])) call abort + buffer = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz' + write(buffer,*) b(:,3) + if (buffer /= ' 2 10') call abort + + + allocate(d(3:5,-1:10)) + b = baz(d) + !print *,b(:,1) + if (any(b(:,1) /= [3, -1])) call abort + buffer = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz' + write(buffer,*) b(:,1) + if (buffer /= ' 3 -1') call abort + + !print *,b(:,2) + if (any(b(:,2) /= [15, 110])) call abort + buffer = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz' + write(buffer,*) b(:,2) + if (buffer /= ' 15 110') call abort + + !print *,b(:,3) + if (any(b(:,3) /= [13, 112])) call abort + buffer = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz' + write(buffer,*) b(:,3) + if (buffer /= ' 13 112') call abort + + +contains + function foo(arg) result(res) + integer :: arg(..) + integer, allocatable :: res(:,:) + + allocate(res(rank(arg), 3)) + + res(:,1) = lbound(arg) + (/ 10, 100 /) + res(:,2) = ubound(arg) + res(:,3) = (/ 10, 100 /) + shape(arg) + + end function foo + function bar(arg) result(res) + integer, allocatable :: arg(..) + integer, allocatable :: res(:,:) + + allocate(res(-1:rank(arg)-2, 3)) + + res(:,1) = lbound(arg) + (/ 10, 100 /) + res(:,2) = (/ 10, 100 /) + ubound(arg) + res(:,3) = shape(arg) + + end function bar + function baz(arg) result(res) + integer, pointer :: arg(..) + integer, allocatable :: res(:,:) + + allocate(res(2:rank(arg)+1, 3)) + + res(:,1) = lbound(arg) + res(:,2) = (/ 10, 100 /) + ubound(arg) + res(:,3) = shape(arg) + (/ 10, 100 /) + + end function baz +end program test + |