summaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.fortran/oop_extend_type.exp
blob: 6f2924b47433c32f82a7a601f0b45e4700452de3 (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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
# Copyright 2022-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/>.

standard_testfile ".f90"
load_lib "fortran.exp"

if { [skip_fortran_tests] } {
    return -1
}

if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
     {debug f90 quiet}] } {
	 return -1
}

if ![fortran_runto_main] {
    perror "could not run to main"
    return -1
}

# Depending on the compiler being used, the type names can be printed differently.
set real [fortran_real4]
set logical [fortran_logical4]

set line1 [gdb_get_line_number "! Before vla allocation"]
gdb_breakpoint $line1
gdb_continue_to_breakpoint "line1" ".*$srcfile:$line1.*"

gdb_test "whatis wp_vla" "type = Type waypoint, allocatable \\(:\\)" \
    "whatis wp_vla before allocation"

set line2 [gdb_get_line_number "! After value assignment"]
gdb_breakpoint $line2
gdb_continue_to_breakpoint "line2" ".*$srcfile:$line2.*"

# test print of wp
set test "p wp%coo"
gdb_test_multiple "$test" "$test" {
    -re " = \\(1, 2, 1\\)\r\n$gdb_prompt $" {
      pass "$test"
    }
    -re "There is no member named coo.\r\n$gdb_prompt $" {
      kfail "gcc/49475" "$test"
    }
}
gdb_test "p wp%point%coo" " = \\(1, 2, 1\\)"
gdb_test "p wp%point" " = \\( coo = \\(1, 2, 1\\) \\)"
gdb_test "p wp" " = \\( point = \\( coo = \\(1, 2, 1\\) \\), angle = 100 \\)"

gdb_test "whatis wp" "type = Type waypoint"
set output_pass_wp [multi_line "type = Type, extends\\(point\\) :: waypoint" \
			       "    Type point :: point" \
			       "    $real :: angle" \
			       "End Type waypoint(, allocatable)?"]
set output_kfail_wp [multi_line "type = Type waypoint" \
			        "    Type point :: point" \
			        "    $real :: angle" \
			        "End Type waypoint(, allocatable)?"]

set test "ptype wp"
gdb_test_multiple "$test" "$test" {
    -re "$output_pass_wp\r\n$gdb_prompt $" {
      pass "$test"
    }
    -re "$output_kfail_wp\r\n$gdb_prompt $" {
      kfail "gcc/49475" "$test"
    }
}
set test "ptype wp%coo"
gdb_test_multiple "$test" "$test" {
    -re "$real \\(3\\)\r\n$gdb_prompt $" {
      pass "$test"
    }
    -re "There is no member named coo.\r\n$gdb_prompt $" {
      kfail "gcc/49475" "$test"
    }
}
gdb_test "ptype wp%point%coo" "$real \\(3\\)"

# test print of fwp
set test "p fwp%coo"
gdb_test_multiple "$test" "$test" {
    -re " = \\(1, 2, 2\\)\r\n$gdb_prompt $" {
      pass "$test"
    }
    -re "There is no member named coo.\r\n$gdb_prompt $" {
      kfail "gcc/49475" "$test"
    }
}
gdb_test "p fwp%waypoint%point%coo" " = \\(1, 2, 2\\)"
gdb_test "p fwp%waypoint%point" " = \\( coo = \\(1, 2, 2\\) \\)"
gdb_test "p fwp%waypoint" \
    " = \\( point = \\( coo = \\(1, 2, 2\\) \\), angle = 10 \\)"
gdb_test "p fwp" \
    " = \\( waypoint = \\( point = \\( coo = \\(1, 2, 2\\) \\), angle = 10 \\), is_fancy = \.TRUE\. \\)"

set test "p fwp%angle"
gdb_test_multiple "$test" "$test" {
    -re " = 10\r\n$gdb_prompt $" {
      pass "$test"
    }
    -re "There is no member named angle.\r\n$gdb_prompt $" {
      kfail "gcc/49475" "$test"
    }
}

gdb_test "whatis fwp" "type = Type fancywaypoint"
set test "ptype fwp"

set output_pass_fwp \
    [multi_line "type = Type, extends\\(waypoint\\) :: fancywaypoint" \
		"    Type waypoint :: waypoint" \
		"    $logical :: is_fancy" \
		"End Type fancywaypoint"]
set output_kfail_fwp \
    [multi_line "type = Type fancywaypoint" \
		"    Type waypoint :: waypoint" \
		"    $logical :: is_fancy" \
		"End Type fancywaypoint"]

gdb_test_multiple "$test" "$test" {
    -re "$output_pass_fwp\r\n$gdb_prompt $" {
	pass  "$test"
    }
    -re "$output_kfail_fwp\r\n$gdb_prompt $" {
	kfail "gcc/49475" "$test"
    }
}

set test "ptype fwp%coo"
gdb_test_multiple "$test" "$test" {
    -re "$real \\(3\\)\r\n$gdb_prompt $" {
      pass "$test"
    }
    -re "There is no member named coo.\r\n$gdb_prompt $" {
      kfail "gcc/49475" "$test"
    }
}
gdb_test "ptype fwp%waypoint%point%coo" "$real \\(3\\)"

# test print of wp_vla
set test "p wp_vla(1)%coo"
gdb_test_multiple "$test" "$test" {
    -re " = \\(10, 12, 10\\)\r\n$gdb_prompt $" {
      pass "$test"
    }
    -re "There is no member named coo.\r\n$gdb_prompt $" {
      kfail "gcc/49475" "$test"
    }
}

gdb_test "p wp_vla(1)%point%coo" " = \\(10, 12, 10\\)"
gdb_test "p wp_vla(1)%point" " = \\( coo = \\(10, 12, 10\\) \\)"
gdb_test "p wp_vla(1)" " = \\( point = \\( coo = \\(10, 12, 10\\) \\), angle = 101 \\)"

gdb_test "whatis wp_vla" "type = Type waypoint, allocatable \\(3\\)" \
    "whatis wp_vla after allocation"

set test "ptype wp_vla"
gdb_test_multiple "$test" "$test" {
    -re "$output_pass_wp \\(3\\)\r\n$gdb_prompt $" {
      pass "$test"
    }
    -re "$output_kfail_wp \\(3\\)\r\n$gdb_prompt $" {
      kfail "gcc/49475" "$test"
    }
}
set test "ptype wp_vla(1)%coo"
gdb_test_multiple "$test" "$test" {
    -re "$real \\(3\\)\r\n$gdb_prompt $" {
      pass "$test"
    }
    -re "There is no member named coo.\r\n$gdb_prompt $" {
      kfail "gcc/49475" "$test"
    }
}

gdb_test "ptype wp_vla(1)%point%coo" "$real \\(3\\)"