aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gfortran.dg/PR94110.f90
blob: 4e43332b64e5f1545910460cfaaab75c193cc095 (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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
! { dg-do compile }
!
! Test the fix for PR94110
! 
  
program asa_p

  implicit none

  integer, parameter :: n = 7

  type t
  end type t

  interface
    subroutine fc2 (x)
      import :: t
      class(t), pointer, intent(in) :: x(..)
    end subroutine
  end interface

  integer :: p(n)
  integer :: s

  p = 1
  s = sumf_as(p)
  if (s/=n) stop 1
  s = sumf_ar(p)
  if (s/=n) stop 2
  stop

contains

  function sumf_as(a) result(s)
    integer, target, intent(in) :: a(*)

    integer :: s

    s = sum_as(a)   ! { dg-error "Actual argument for .a. cannot be an assumed-size array" } 
    s = sum_p_ds(a) ! { dg-error "Actual argument for .a. cannot be an assumed-size array" } 
    s = sum_p_ar(a) ! { dg-error "Actual argument for .a. cannot be an assumed-size array" } 
    return
  end function sumf_as

  function sumf_ar(a) result(s)
    integer, target, intent(in) :: a(..)

    integer :: s

    select rank(a)
    rank(*)
      s = sum_as(a)   ! { dg-error "Actual argument for .a. cannot be an assumed-size array" } 
      s = sum_p_ds(a) ! { dg-error "Actual argument for .a. cannot be an assumed-size array" } 
      s = sum_p_ar(a) ! { dg-error "Actual argument for .a. cannot be an assumed-size array" } 
    rank default
      stop 3
    end select
    return
  end function sumf_ar

  function sum_as(a) result(s)
    integer, intent(in) :: a(:)
  
    integer :: s

    s = sum(a)
    return
  end function sum_as

  function sum_p_ds(a) result(s)
    integer, pointer, intent(in) :: a(:)
  
    integer :: s

    s = -1
    if(associated(a))&
      s = sum(a)
    return
  end function sum_p_ds

  function sum_p_ar(a) result(s)
    integer, pointer, intent(in) :: a(..)
  
    integer :: s

    s = -1
    select rank(a)
    rank(1)
      if(associated(a))&
        s = sum(a)
    rank default
      stop 4
    end select
    return
  end function sum_p_ar

  subroutine sub1(y)
    type(t), target :: y(*)
    call fc2 (y) ! { dg-error "Actual argument for .x. cannot be an assumed-size array" } 
  end subroutine sub1

end program asa_p