Debian Codegraph @

gcc/testsuite/gfortran.dg/submodule_29.f08

raw
1 ! { dg-do run }
2 !
3 ! Test the fix for PR80554 in which it was not recognised that the symbol 'i'
4 ! is host associated in the submodule 's' so that the new declaration in the
5 ! submodule was rejected.
6 !
7 ! Contributed by Tamas Bela Feher <[email protected]>
8 !
9 module M
10 implicit none
11 integer :: i = 0
12 character (100) :: buffer
13 interface
14 module subroutine write_i()
15 end subroutine
16 end interface
17 interface
18 module subroutine write_i_2()
19 end subroutine
20 end interface
21 contains
22 subroutine foo
23 integer :: i
24 end
25 end module
26
27 submodule (M) S
28 integer :: i = 137
29 contains
30 module subroutine write_i()
31 write (buffer,*) i
32 end subroutine
33 end submodule
34
35 submodule (M:S) S2
36 integer :: i = 1037
37 contains
38 module subroutine write_i_2()
39 write (buffer,*) i
40 end subroutine
41 end submodule
42
43 program test_submod_variable
44 use M
45 implicit none
46 integer :: j
47 i = 42
48 call write_i
49 read (buffer, *) j
50 if (i .ne. 42) STOP 1
51 if (j .ne. 137) STOP 2
52 call write_i_2
53 read (buffer, *) j
54 if (i .ne. 42) STOP 3
55 if (j .ne. 1037) STOP 4
56 end program