aarch64: Add vector floating point extend pattern [PR113880, PR113869]
[official-gcc.git] / gcc / testsuite / gfortran.dg / realloc_on_assign_1.f03
blob0eb08b91cd201b91386d26c78903d6550e83a44c
1 ! { dg-do run }
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(:,:)
8   integer(4) :: j
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"]
14   allocate(a(1))
15   mat = reshape (src, [2,2])
17   a = [4,3,2,1]
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
25   b = a
26   if (size(b, 1) .ne. 10) STOP 5
27   if (any (b .ne. a)) STOP 6
29   a = [4,3,2,1]
30   if (size(a, 1) .ne. 4) STOP 7
31   if (any (a .ne. [4,3,2,1])) STOP 8
33   a = b
34   if (size(a, 1) .ne. 10) STOP 9
35   if (any (a .ne. [((42 - i), i = 1, 10)])) STOP 10
37   j = 20
38   a = [(i, i = 1, j)]
39   if (size(a, 1) .ne. j) STOP 11
40   if (any (a .ne. [(i, i = 1, j)])) STOP 12
42   a = foo (15)
43   if (size(a, 1) .ne. 15) STOP 13
44   if (any (a .ne. [((i + 15), i = 1, 15)])) STOP 14
46   a = src
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
51   k = 7
52   a = b(k:8)
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
57   c = mat
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
62   deallocate (c)
63   c = mat(2:,:)
64   if (any (lbound (c) .ne. lbound (mat(2:,:)))) STOP 24
66   chr1 = chr2(2:1:-1)
67   if (lbound(chr1, 1) .ne. 1) STOP 25
68   if (any (chr1 .ne. chr2(2:1:-1))) STOP 26
70   b = c(1, :) + c(2, :)
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
73 contains
74   function foo (n) result(res)
75     integer(4), allocatable, dimension(:) :: res
76     integer(4) :: n
77     allocate (res(n))
78     res = [((i + 15), i = 1, n)]
79   end function foo
80 end