aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/gfortran.dg/interface_derived_type_1.f90
blob: efd81fd674c2a9d3a1f0ce00b7e4c8c3e99f170f (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
! { dg-do compile }
! Test the fix for PR20903, in which derived types could be host associated within
! interface bodies.
!
! Contributed by Joost VandeVondele <jv244@cam.ac.uk>
! 
module test
  implicit none
  type fcnparms
    integer :: i
  end type fcnparms
contains
  subroutine sim_1(func1,params)
    interface
      function func1(fparams)
        type(fcnparms) :: fparams ! { dg-error "is being used before it is defined" }
        real :: func1
      end function func1
    end interface
    type(fcnparms)     :: params
   end subroutine sim_1

  subroutine sim_2(func2,params)
    interface
      function func2(fparams)     ! This is OK because of the derived type decl.
        type fcnparms
          integer :: i
        end type fcnparms
        type(fcnparms)  :: fparams
        real :: func2
      end function func2
    end interface
    type(fcnparms)      :: params ! This is OK, of course
   end subroutine sim_2
end module  test

module type_decl
  implicit none
  type fcnparms
    integer :: i
  end type fcnparms
end module type_decl

subroutine sim_3(func3,params)
  use type_decl
  interface
    function func3(fparams)
      use type_decl
      type(fcnparms)   :: fparams ! This is OK - use associated
      real :: func3
    end function func3
  end interface
  type(fcnparms)       :: params  !         -ditto-
end subroutine sim_3