1! { dg-do run }
2! PR52012 - tests of automatic reallocation on assignment for variable = array_intrinsic
3!
4! Contributed by Tobias Burnus and Dominique Dhumieres
5!
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]
10
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])) STOP 1
15
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])) STOP 2
20
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])) STOP 3
26
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])) STOP 4
30  deallocate (e)
31
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])) STOP 5
36end
37