]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.fortran/ptype-on-functions.f90
Update copyright year range in all GDB files.
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.fortran / ptype-on-functions.f90
1 ! Copyright 2019-2020 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
16 module some_module
17 implicit none
18
19 type, public :: Number
20 integer :: a
21 contains
22 procedure :: get => get_number
23 procedure :: set => set_number
24 end type Number
25
26 contains
27
28 function get_number (this) result (val)
29 class (Number), intent (in) :: this
30 integer :: val
31 val = this%a
32 end function get_number
33
34 subroutine set_number (this, val)
35 class (Number), intent (inout) :: this
36 integer :: val
37 this%a = val
38 end subroutine set_number
39
40 end module some_module
41
42 logical function is_bigger (a,b)
43 integer, intent(in) :: a
44 integer, intent(in) :: b
45 is_bigger = a > b
46 end function is_bigger
47
48 subroutine say_numbers (v1,v2,v3)
49 integer,intent(in) :: v1
50 integer,intent(in) :: v2
51 integer,intent(in) :: v3
52 print *, v1,v2,v3
53 end subroutine say_numbers
54
55 program test
56 use some_module
57
58 interface
59 integer function fun1 (x)
60 integer :: x
61 end function fun1
62
63 integer function fun2 (x)
64 integer :: x
65 end function fun2
66 end interface
67
68 type (Number) :: n1
69 type (Number) :: n2
70
71 procedure(fun1), pointer:: fun_ptr => NULL()
72
73 call say_numbers (1,2,3) ! stop here
74 print *, fun_ptr (3)
75
76 end program test
77
78 integer function fun1 (x)
79 implicit none
80 integer :: x
81 fun1 = x + 1
82 end function fun1
83
84 integer function fun2 (x)
85 implicit none
86 integer :: x
87 fun2 = x + 2
88 end function fun2
89