aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gfortran.dg/c-interop/c407c-1.f90
blob: 7abe33827407cfaf702825d9878c24947f6399df (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
! PR101333
! { dg-do compile }
!
! TS 29113
! C407c An assumed-type actual argument that corresponds to an
! assumed-rank dummy argument shall be assumed-shape or assumed-rank.
!
! This constraint is renumbered C711 in the 2018 Fortran standard.

module m
  interface
    subroutine g (a, b)
      implicit none
      type(*) :: a(..)
      integer :: b
    end subroutine
  end interface
end module

! Check that assumed-shape works.

subroutine s0 (x)
  use m
  implicit none
  type(*) :: x(:)

  call g (x, 1)
end subroutine

! Check that assumed-rank works.

subroutine s1 (x)
  use m
  implicit none
  type(*) :: x(..)

  call g (x, 1)
end subroutine

! Check that assumed-size gives an error.

subroutine s2 (x)
  use m
  implicit none
  type(*) :: x(*)

  call g (x, 1)  ! { dg-error "Assumed-type actual argument at .1. corresponding to assumed-rank dummy argument 'a' must be assumed-shape or assumed-rank" }
end subroutine

! Check that a scalar gives an error.
subroutine s3 (x)
  use m
  implicit none
  type(*) :: x

  call g (x, 1)  ! { dg-error "Assumed.type" }
end subroutine

! Explicit-shape assumed-type actual arguments are forbidden implicitly
! by c407a (C709 in the 2018 standard).  They're not allowed as dummy
! arguments, and assumed-type entities can only be declared as dummy
! arguments, so there is no other way to construct one to pass as an
! actual argument.