]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.fortran/oop_extend_type.f90
Update copyright year range in header of all files managed by GDB
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.fortran / oop_extend_type.f90
1 ! Copyright 2022-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
16 ! Test fortran extends feature (also for chained extends).
17 module testmod
18 implicit none
19 type :: point
20 real :: coo(3)
21 end type
22
23 type, extends(point) :: waypoint
24 real :: angle
25 end type
26
27 type, extends(waypoint) :: fancywaypoint
28 logical :: is_fancy
29 end type
30 end module
31
32 program testprog
33 use testmod
34 implicit none
35
36 logical l
37 type(waypoint) :: wp
38 type(fancywaypoint) :: fwp
39 type(waypoint), allocatable :: wp_vla(:)
40
41 l = .FALSE.
42 allocate(wp_vla(3)) ! Before vla allocation
43
44 l = allocated(wp_vla) ! After vla allocation
45
46 wp%angle = 100.00
47 wp%coo(:) = 1.00
48 wp%coo(2) = 2.00
49
50 fwp%is_fancy = .TRUE.
51 fwp%angle = 10.00
52 fwp%coo(:) = 2.00
53 fwp%coo(1) = 1.00
54
55 wp_vla(1)%angle = 101.00
56 wp_vla(1)%coo(:) = 10.00
57 wp_vla(1)%coo(2) = 12.00
58
59 wp_vla(2)%angle = 102.00
60 wp_vla(2)%coo(:) = 20.00
61 wp_vla(2)%coo(2) = 22.00
62
63 wp_vla(3)%angle = 103.00
64 wp_vla(3)%coo(:) = 30.00
65 wp_vla(3)%coo(2) = 32.00
66
67 print *, wp, wp_vla, fwp ! After value assignment
68
69 end program