aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gfortran.dg/submodule_15.f08
blob: ee9cc29e486827c09b60bdd95712dcb2e9825171 (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
! { dg-do run }
!
! Check the fix for PR69524, where module procedures were not permitted
! in a module CONTAINS section.
!
! Reorted by Kirill Yukhin  <kyukhin@gcc.gnu.org>
!
module A
  implicit none
  interface
     module subroutine A1(i)
       integer, intent(inout) :: i
     end subroutine A1
     module subroutine A2(i)
       integer, intent(inout) :: i
     end subroutine A2
     integer module function A3(i)
       integer, intent(inout) :: i
     end function A3
     module subroutine B1(i)
       integer, intent(inout) :: i
     end subroutine B1
  end interface
  integer :: incr         ! Make sure that everybody can access a module variable
contains
  module subroutine A1(i) ! Full declaration
    integer, intent(inout) :: i
    call b1 (i)           ! Call the submodule procedure
    incr = incr + 1
  end subroutine A1

  module PROCEDURE A2     ! Abreviated declaration
    call b1 (i)           ! Call the submodule procedure
    incr = incr + 1
  end procedure A2

  module PROCEDURE A3     ! Abreviated declaration
    call a1 (i)           ! Call the module procedure in the module
    call a2 (i)           !            ditto
    call b1 (i)           ! Call the submodule procedure
    incr = incr + 1
    a3 = i + incr
  end procedure A3
end module A

submodule (A) a_son
  implicit none
contains
  module procedure b1
    i = i + incr
  end procedure
end submodule

  use A
  integer :: i = 1
  incr = 1
  if (a3(i) .ne. 11) STOP 1
end