summaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.fortran/dynamic-ptype-whatis.f90
blob: c20f95f631424e3e9f8669683d5bf216fe033886 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
! Copyright 2021-2023 Free Software Foundation, Inc.
!
! This program is free software; you can redistribute it and/or modify
! it under the terms of the GNU General Public License as published by
! the Free Software Foundation; either version 3 of the License, or
! (at your option) any later version.
!
! This program is distributed in the hope that it will be useful,
! but WITHOUT ANY WARRANTY; without even the implied warranty of
! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
! GNU General Public License for more details.
!
! You should have received a copy of the GNU General Public License
! along with this program.  If not, see <http://www.gnu.org/licenses/>.

program main

  ! A non-dynamic type.
  type type1
     integer(kind=4) :: spacer
     integer(kind=4) t1_i
  end type type1

  ! A first dynamic type.  The array is of a static type.
  type type2
     integer(kind=4) :: spacer
     type(type1), allocatable :: t2_array(:)
  end type type2

  ! Another dynamic type, the array is again a static type.
  type type3
     integer(kind=4) :: spacer
     type(type1), pointer :: t3_array(:)
  end type type3

  ! A dynamic type, this time the array contains a dynamic type.
  type type4
     integer(kind=4) :: spacer
     type(type2), allocatable :: t4_array(:)
  end type type4

  ! A static type, the array though contains dynamic types.
  type type5
     integer(kind=4) :: spacer
     type(type2) :: t5_array (4)
  end type type5

  ! A static type containing pointers to a type that contains a
  ! dynamic array.
  type type6
     type(type2), pointer :: ptr_1
     type(type2), pointer :: ptr_2
  end type type6

  real, dimension(:), pointer :: var1
  real, dimension(:), allocatable :: var2
  type(type1) :: var3
  type(type2), target :: var4
  type(type3) :: var5
  type(type4) :: var6
  type(type5) :: var7
  type(type6) :: var8

  allocate (var1 (3))

  allocate (var2 (4))

  allocate (var4%t2_array(3))

  allocate (var5%t3_array(3))

  allocate (var6%t4_array(3))
  allocate (var6%t4_array(1)%t2_array(2))
  allocate (var6%t4_array(2)%t2_array(5))
  allocate (var6%t4_array(3)%t2_array(4))

  allocate (var7%t5_array(1)%t2_array(2))
  allocate (var7%t5_array(2)%t2_array(5))
  allocate (var7%t5_array(3)%t2_array(4))
  allocate (var7%t5_array(4)%t2_array(1))

  var8%ptr_1 => var4
  var8%ptr_2 => var4

  print *, var1		! Break Here
  print *, var2
  print *, var3
  print *, var4%t2_array(1)
  print *, var5%t3_array(2)
  print *, var6%t4_array(1)%t2_array(1)
  print *, var7%t5_array(1)%t2_array(1)

end program main