xref: /netbsd-src/external/gpl3/gdb/dist/gdb/testsuite/gdb.fortran/module.f90 (revision 2a1c97808946e9207c01bcd7f0d669b8d9cc6ee9)
1! Copyright 2009-2024 Free Software Foundation, Inc.
2!
3! This program is free software; you can redistribute it and/or modify
4! it under the terms of the GNU General Public License as published by
5! the Free Software Foundation; either version 3 of the License, or
6! (at your option) any later version.
7!
8! This program is distributed in the hope that it will be useful,
9! but WITHOUT ANY WARRANTY; without even the implied warranty of
10! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11! GNU General Public License for more details.
12!
13! You should have received a copy of the GNU General Public License
14! along with this program.  If not, see <http://www.gnu.org/licenses/>.
15
16module mod1
17        integer :: var_i = 1
18        integer :: var_const
19        parameter (var_const = 20)
20end module mod1
21
22module mod2
23        integer :: var_i = 2
24end module mod2
25
26module mod3
27        integer :: mod2 = 3
28        integer :: mod1 = 3
29        integer :: var_i = 3
30end module mod3
31
32module modmany
33        integer :: var_a = 10, var_b = 11, var_c = 12, var_i = 14
34end module modmany
35
36module moduse
37        integer :: var_x = 30, var_y = 31
38end module moduse
39
40        subroutine sub1
41        use mod1
42        if (var_i .ne. 1) call abort
43        var_i = 1                         ! i-is-1
44        end
45
46        subroutine sub2
47        use mod2
48        if (var_i .ne. 2) call abort
49        var_i = 2                         ! i-is-2
50        end
51
52        subroutine sub3
53        use mod3
54        if (var_i .ne. 3) call abort
55        var_i = 3                         ! i-is-3
56        END
57
58        program module
59
60        use modmany, only: var_b, var_d => var_c, var_i
61	use moduse, var_z => var_y
62
63        call sub1
64        call sub2
65        call sub3
66
67        if (var_b .ne. 11) call abort
68        if (var_d .ne. 12) call abort
69        if (var_i .ne. 14) call abort
70        if (var_x .ne. 30) call abort
71        if (var_z .ne. 31) call abort
72        var_b = 11                         ! a-b-c-d
73end
74