aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gfortran.dg/c-interop/explicit-interface.f90
blob: a7eda825758f36077c739c181357be85fab3cdfe (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
! { dg-do compile }
!
! TS 29113
! 6.2 Explicit interface
! 
! Additionally to the rules of subclause 12.4.2.2 of ISO/IEC 1539-1:2010,
! a procedure shall have an explicit interface if it has a dummy argument
! that is assumed-rank.
!
! NOTE 6.1
! An explicit interface is also required for a procedure if it has a
! dummy argument that is assumed-type because an assumed-type dummy 
! argument is polymorphic.
!
! This file contains code that is expected to produce errors.

module m1

  interface

    subroutine s1 (a)
      integer :: a(..)
    end subroutine

    subroutine s2 (b)
      type(*) :: b
    end subroutine

  end interface

end module

module m2

  contains

  ! This subroutine has an explicit interface, and so do the things
  ! it calls.
  subroutine good (a, b)
    use m1
    integer :: a(..)
    type (*) :: b

    call s1 (a)
    call s2 (b)
  end subroutine

  ! This subroutine has an explicit interface, but the things it calls don't.
  subroutine bad (a, b)
    use m1
    integer :: a(..)
    type (*) :: b
    external :: s3, s4

    call s3 (a)  ! { dg-error "Assumed-rank argument" }
    call s4 (b)  ! { dg-error "Assumed-type argument" }
  end subroutine

end module