2020-05-12 02:38:53 +08:00
|
|
|
! RUN: %S/test_modfile.sh %s %t %f18
|
2018-09-01 07:20:00 +08:00
|
|
|
! Test writing procedure bindings in a derived type.
|
|
|
|
|
|
|
|
module m
|
|
|
|
interface
|
|
|
|
subroutine a(i, j)
|
|
|
|
integer :: i, j
|
|
|
|
end subroutine
|
|
|
|
end interface
|
|
|
|
type, abstract :: t
|
|
|
|
integer :: i
|
|
|
|
contains
|
|
|
|
procedure(a), deferred, nopass :: q
|
|
|
|
procedure(b), deferred, nopass :: p, r
|
|
|
|
end type
|
|
|
|
type t2
|
2018-09-06 23:01:49 +08:00
|
|
|
integer :: x
|
2018-09-01 07:20:00 +08:00
|
|
|
contains
|
2018-09-06 23:01:49 +08:00
|
|
|
private
|
2018-09-01 07:20:00 +08:00
|
|
|
final :: c
|
|
|
|
procedure, non_overridable :: d
|
2019-11-16 06:26:10 +08:00
|
|
|
end type
|
|
|
|
type, abstract :: t2a
|
|
|
|
contains
|
2018-09-06 23:01:49 +08:00
|
|
|
procedure(a), deferred, public, nopass :: e
|
|
|
|
end type
|
|
|
|
type t3
|
|
|
|
sequence
|
|
|
|
integer i
|
|
|
|
real x
|
2018-09-12 08:33:42 +08:00
|
|
|
double precision y
|
|
|
|
double complex z
|
2018-09-01 07:20:00 +08:00
|
|
|
end type
|
|
|
|
contains
|
|
|
|
subroutine b()
|
|
|
|
end subroutine
|
|
|
|
subroutine c(x)
|
|
|
|
type(t2) :: x
|
|
|
|
end subroutine
|
|
|
|
subroutine d(x)
|
|
|
|
class(t2) :: x
|
|
|
|
end subroutine
|
|
|
|
subroutine test
|
|
|
|
type(t2) :: x
|
|
|
|
call x%d()
|
|
|
|
end subroutine
|
|
|
|
end module
|
|
|
|
|
|
|
|
!Expect: m.mod
|
|
|
|
!module m
|
|
|
|
! interface
|
|
|
|
! subroutine a(i,j)
|
2018-09-12 08:33:42 +08:00
|
|
|
! integer(4)::i
|
|
|
|
! integer(4)::j
|
2018-09-01 07:20:00 +08:00
|
|
|
! end
|
|
|
|
! end interface
|
|
|
|
! type,abstract::t
|
2018-09-12 08:33:42 +08:00
|
|
|
! integer(4)::i
|
2018-09-01 07:20:00 +08:00
|
|
|
! contains
|
|
|
|
! procedure(a),deferred,nopass::q
|
|
|
|
! procedure(b),deferred,nopass::p
|
|
|
|
! procedure(b),deferred,nopass::r
|
|
|
|
! end type
|
|
|
|
! type::t2
|
2018-09-12 08:33:42 +08:00
|
|
|
! integer(4)::x
|
2018-09-01 07:20:00 +08:00
|
|
|
! contains
|
2019-12-06 02:24:18 +08:00
|
|
|
! procedure,non_overridable,private::d
|
2020-10-01 04:34:23 +08:00
|
|
|
! final::c
|
2019-11-16 06:26:10 +08:00
|
|
|
! end type
|
|
|
|
! type,abstract::t2a
|
|
|
|
! contains
|
2018-09-06 23:01:49 +08:00
|
|
|
! procedure(a),deferred,nopass::e
|
|
|
|
! end type
|
|
|
|
! type::t3
|
|
|
|
! sequence
|
2018-09-12 08:33:42 +08:00
|
|
|
! integer(4)::i
|
|
|
|
! real(4)::x
|
|
|
|
! real(8)::y
|
|
|
|
! complex(8)::z
|
2018-09-01 07:20:00 +08:00
|
|
|
! end type
|
|
|
|
!contains
|
|
|
|
! subroutine b()
|
|
|
|
! end
|
|
|
|
! subroutine c(x)
|
|
|
|
! type(t2)::x
|
|
|
|
! end
|
|
|
|
! subroutine d(x)
|
|
|
|
! class(t2)::x
|
|
|
|
! end
|
|
|
|
! subroutine test()
|
|
|
|
! end
|
|
|
|
!end
|
2020-12-29 00:50:30 +08:00
|
|
|
|
|
|
|
! Ensure the type is emitted before its use
|
|
|
|
module m2
|
|
|
|
private s
|
|
|
|
type :: t
|
|
|
|
contains
|
|
|
|
procedure :: foo
|
|
|
|
end type
|
|
|
|
abstract interface
|
|
|
|
subroutine s(x)
|
|
|
|
import
|
|
|
|
type(t) :: x
|
|
|
|
end subroutine
|
|
|
|
end interface
|
|
|
|
contains
|
|
|
|
subroutine foo(x)
|
|
|
|
class(t) :: x
|
|
|
|
end subroutine
|
|
|
|
end module
|
|
|
|
!Expect: m2.mod
|
|
|
|
!module m2
|
|
|
|
! type::t
|
|
|
|
! contains
|
|
|
|
! procedure::foo
|
|
|
|
! end type
|
|
|
|
! private::s
|
|
|
|
! abstract interface
|
|
|
|
! subroutine s(x)
|
|
|
|
! import::t
|
|
|
|
! type(t)::x
|
|
|
|
! end
|
|
|
|
! end interface
|
|
|
|
!contains
|
|
|
|
! subroutine foo(x)
|
|
|
|
! class(t)::x
|
|
|
|
! end
|
|
|
|
!end
|