aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gfortran.dg/PR96726.f90
blob: b0b26b906693f743dc5e2bf8d7598c0f3d7d17e5 (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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
! { dg-do run }
!
! Test the fix for PR96726
!

module cref_m

  implicit none

  private

  public ::   &
    sizeish
  
contains

  pure function sizeish(a) result(s)
    integer, intent(in) :: a(..)

    integer :: s

    s = size(a)
    return
  end function sizeish
  
end module cref_m

program cref_p

  use cref_m, only: &
    sizeish

  implicit none
  
  integer            :: i

  integer, parameter :: n = 3
  integer, parameter :: p(*) = [(i, i=1,n*n)]
  
  integer :: a(n,n)
  integer :: b(n*n)

  a = reshape(p, shape=[n,n])
  call isub_a(a, b)
  if (any(b/=p)) stop 1
  call isub_b(a, b)
  if (any(b/=p)) stop 2
  stop

contains

  subroutine isub_a(a, b)
    integer, intent(in)  :: a(..)
    integer, intent(out) :: b(size(a))

    integer :: i
    
    b = [(i, i=1,size(b))]
    return
  end subroutine isub_a
  
  subroutine isub_b(a, b)
    integer, intent(in)  :: a(..)
    integer, intent(out) :: b(sizeish(a))

    integer :: i
    
    b = [(i, i=1,sizeish(b))]
    return
  end subroutine isub_b
  
end program cref_p