aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/gfortran.dg/nested_modules_6.f90
blob: b95742270bf267791be844e03a1d5779d476b1a8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
! { dg-do compile }
! Test the patch for PR30084 in which the reference to SIZE
! in function diag caused a segfault in module.c.
!
! Contributed by Troban Trumsko <trumsko@yahoo.com>
! and reduced by Steve Kargl <kargl@gcc.gnu.org>
!
module tao_random_numbers
  integer, dimension(10) :: s_buffer
  integer :: s_last = size (s_buffer)
end module tao_random_numbers

module linalg
  contains
  function diag (a) result (d)
    real, dimension(:,:), intent(in) :: a
    real, dimension(min(size(a,dim=1),size(a,dim=2))) :: d
    integer :: i
    do i = 1, min(size(a, dim = 1), size(a, dim = 2))
       d(i) = a(i,i)
    end do
  end function diag
end module linalg

module vamp_rest
  use tao_random_numbers
  use linalg
end module vamp_rest

  use vamp_rest
  real :: x(2, 2) = reshape ([1.,2.,3.,4.], [2,2])
  print *, s_last
  print *, diag (x)
end