OSDN Git Service

2010-04-24 Kai Tietz <kai.tietz@onevision.com>
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gfortran.dg / func_assign_2.f90
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 !
10 integer :: a(2,2)
11 a = -42
12 a(1,:) = func()
13 if (any (reshape (a, [4]) /= [1, -42, 2, -42])) call abort 
14 a = -42
15 a(2,:) = func()
16 if (any (reshape (a, [4]) /= [-42, 1, -42, 2])) call abort 
17 a = -42
18 a(:,1) = func()
19 if (any (reshape (a, [4]) /= [1, 2, -42, -42])) call abort 
20 a = -42
21 a(:,2) = func()
22 if (any (reshape (a, [4]) /= [-42, -42, 1, 2])) call abort 
23 contains
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
32 end
33