2017-11-05 Paul Thomas <pault@gcc.gnu.org>
[official-gcc.git] / gcc / testsuite / gfortran.dg / realloc_on_assign_11.f90
blobab96bb9deaf837e1ce318ee11c4a96b8b1edfeeb
1 ! { dg-do run }
2 ! PR52012 - tests of automatic reallocation on assignment for variable = array_intrinsic
4 ! Contributed by Tobias Burnus and Dominique Dhumieres
6 integer, allocatable :: a(:), b(:), e(:,:)
7 integer :: c(1:5,1:5), d(1:5,1:5)
8 allocate(b(3))
9 b = [1,2,3]
11 ! Shape conforms so bounds follow allocation.
12 allocate (a(7:9))
13 a = reshape( b, shape=[size(b)])
14 if (any ([lbound(a), ubound(a), size(a), shape (a)] .ne. [7,9,3,3])) call abort
16 deallocate (a)
17 ! 'a' not allocated so lbound defaults to 1.
18 a = reshape( b, shape=[size(b)])
19 if (any ([lbound(a), ubound(a), size(a), shape (a)] .ne. [1,3,3,3])) call abort
21 deallocate (a)
22 ! Shape conforms so bounds follow allocation.
23 allocate (a(0:0))
24 a(0) = 1
25 if (any ([lbound(a), ubound(a), size(a), shape (a)] .ne. [0,0,1,1])) call abort
27 ! 'a' not allocated so lbound defaults to 1.
28 e = matmul (c(2:5,:), d(:, 3:4))
29 if (any ([lbound(e), ubound(e), size(e), shape (e)] .ne. [1,1,4,2,8,4,2])) call abort
30 deallocate (e)
32 ! Shape conforms so bounds follow allocation.
33 allocate (e(4:7, 11:12))
34 e = matmul (c(2:5,:), d(:, 3:4))
35 if (any ([lbound(e), ubound(e), size(e), shape (e)] .ne. [4,11,7,12,8,4,2])) call abort
36 end