2 ! Tests the patch that implements F2003 automatic allocation and
3 ! reallocation of allocatable arrays on assignment.
5 ! Contributed by Paul Thomas <pault@gcc.gnu.org>
7 integer(4), allocatable :: a(:), b(:), c(:,:)
9 integer(4) :: src(2:5) = [11,12,13,14]
10 integer(4) :: mat(2:3,5:6)
11 character(4), allocatable :: chr1(:)
12 character(4) :: chr2(2) = ["abcd", "wxyz"]
15 mat = reshape (src, [2,2])
18 if (size(a, 1) .ne. 4) STOP 1
19 if (any (a .ne. [4,3,2,1])) STOP 2
21 a = [((42 - i), i = 1, 10)]
22 if (size(a, 1) .ne. 10) STOP 3
23 if (any (a .ne. [((42 - i), i = 1, 10)])) STOP 4
26 if (size(b, 1) .ne. 10) STOP 5
27 if (any (b .ne. a)) STOP 6
30 if (size(a, 1) .ne. 4) STOP 7
31 if (any (a .ne. [4,3,2,1])) STOP 8
34 if (size(a, 1) .ne. 10) STOP 9
35 if (any (a .ne. [((42 - i), i = 1, 10)])) STOP 10
39 if (size(a, 1) .ne. j) STOP 11
40 if (any (a .ne. [(i, i = 1, j)])) STOP 12
43 if (size(a, 1) .ne. 15) STOP 13
44 if (any (a .ne. [((i + 15), i = 1, 15)])) STOP 14
47 if (lbound(a, 1) .ne. lbound(src, 1)) STOP 15
48 if (ubound(a, 1) .ne. ubound(src, 1)) STOP 16
49 if (any (a .ne. [11,12,13,14])) STOP 17
53 if (lbound(a, 1) .ne. lbound (b(k:8), 1)) STOP 18
54 if (ubound(a, 1) .ne. ubound (b(k:8), 1)) STOP 19
55 if (any (a .ne. [35,34])) STOP 20
58 if (any (lbound (c) .ne. lbound (mat))) STOP 21
59 if (any (ubound (c) .ne. ubound (mat))) STOP 22
60 if (any (c .ne. mat)) STOP 23
64 if (any (lbound (c) .ne. lbound (mat(2:,:)))) STOP 24
67 if (lbound(chr1, 1) .ne. 1) STOP 25
68 if (any (chr1 .ne. chr2(2:1:-1))) STOP 26
71 if (lbound(b, 1) .ne. lbound (c(1, :) + c(2, :), 1)) STOP 27
72 if (any (b .ne. c(1, :) + c(2, :))) STOP 28
74 function foo (n) result(res)
75 integer(4), allocatable, dimension(:) :: res
78 res = [((i + 15), i = 1, n)]