2016-03-12 Paul Thomas <pault@gcc.gnu.org>
[official-gcc.git] / gcc / testsuite / gfortran.dg / submodule_15.f08
blob499bc66d5ac4cc84e90255cdf7ee1a2a297904c2
1 ! { dg-do run }
3 ! Check the fix for PR69524, where module procedures were not permitted
4 ! in a module CONTAINS section.
6 ! Reorted by Kirill Yukhin  <kyukhin@gcc.gnu.org>
8 module A
9   implicit none
10   interface
11      module subroutine A1(i)
12        integer, intent(inout) :: i
13      end subroutine A1
14      module subroutine A2(i)
15        integer, intent(inout) :: i
16      end subroutine A2
17      integer module function A3(i)
18        integer, intent(inout) :: i
19      end function A3
20      module subroutine B1(i)
21        integer, intent(inout) :: i
22      end subroutine B1
23   end interface
24   integer :: incr         ! Make sure that everybody can access a module variable
25 contains
26   module subroutine A1(i) ! Full declaration
27     integer, intent(inout) :: i
28     call b1 (i)           ! Call the submodule procedure
29     incr = incr + 1
30   end subroutine A1
32   module PROCEDURE A2     ! Abreviated declaration
33     call b1 (i)           ! Call the submodule procedure
34     incr = incr + 1
35   end procedure A2
37   module PROCEDURE A3     ! Abreviated declaration
38     call a1 (i)           ! Call the module procedure in the module
39     call a2 (i)           !            ditto
40     call b1 (i)           ! Call the submodule procedure
41     incr = incr + 1
42     a3 = i + incr
43   end procedure A3
44 end module A
46 submodule (A) a_son
47   implicit none
48 contains
49   module procedure b1
50     i = i + incr
51   end procedure
52 end submodule
54   use A
55   integer :: i = 1
56   incr = 1
57   if (a3(i) .ne. 11) call abort
58 end