1! { dg-do run }
2! Test the fix for PR40551 in which the assignment
3! was not dealing correctly with non-contiguous lhs
4! references; eg. a(1,:)
5!
6! Reported by by Maciej Zwierzycki
7! at http://gcc.gnu.org/ml/fortran/2009-06/msg00254.html
8! and by Tobias Burnus <burnus@gcc.gnu.org> on Bugzilla
9!
10integer :: a(2,2)
11a = -42
12a(1,:) = func()
13if (any (reshape (a, [4]) /= [1, -42, 2, -42])) call abort
14a = -42
15a(2,:) = func()
16if (any (reshape (a, [4]) /= [-42, 1, -42, 2])) call abort
17a = -42
18a(:,1) = func()
19if (any (reshape (a, [4]) /= [1, 2, -42, -42])) call abort
20a = -42
21a(:,2) = func()
22if (any (reshape (a, [4]) /= [-42, -42, 1, 2])) call abort
23contains
24 function func()
25   integer :: func(2)
26   call sub(func)
27 end function func
28 subroutine sub(a)
29   integer :: a(2)
30   a = [1,2]
31 end subroutine
32end
33
34