import gdb-1999-08-02 snapshot
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.c++ / overload.exp
CommitLineData
c906108c
SS
1# Copyright (C) 1998 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 2 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, write to the Free Software
15# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
16
17# Please email any bugs, comments, and/or additions to this file to:
18# bug-gdb@prep.ai.mit.edu
19
20# written by Elena Zannoni (ezannoni@cygnus.com)
21
22# This file is part of the gdb testsuite
23#
24# tests for overloaded member functions. Command Line calls
25#
26
27
28if $tracelevel then {
29 strace $tracelevel
30 }
31
32#
33# test running programs
34#
35set prms_id 0
36set bug_id 0
37
38set testfile "overload"
39set srcfile ${testfile}.cc
40set binfile ${objdir}/${subdir}/${testfile}
41
42if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } {
43 gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
44}
45
9e0b60a8
JM
46if [get_compiler_info ${binfile} "c++"] {
47 return -1
48}
c906108c
SS
49
50gdb_exit
51gdb_start
52gdb_reinitialize_dir $srcdir/$subdir
53gdb_load ${binfile}
54
55# set it up at a breakpoint so we can play with the variable values
56#
57if ![runto_main] then {
58 perror "couldn't run to breakpoint"
59 continue
60}
61
62send_gdb "break marker1\n" ; gdb_expect -re ".*$gdb_prompt $"
63
64 send_gdb "cont\n"
65 gdb_expect {
66 -re "Break.* marker1 \\(\\) at .*:$decimal.*$gdb_prompt $" {
67 send_gdb "up\n"
68 gdb_expect {
69 -re ".*$gdb_prompt $" {}
70 timeout { fail "up from marker1" }
71 }
72 }
73 -re "$gdb_prompt $" { fail "continue to marker1" }
74 timeout { fail "(timeout) continue to marker1" }
75 }
76
77
78send_gdb "print foo_instance1\n"
79gdb_expect {
80 -re ".\[0-9\]* = \{ifoo = 111, ccpfoo = 0x0\}\r\n$gdb_prompt $" {
81 pass "print foo_instance1"
82 }
83 -re ".*$gdb_prompt $" { fail "print foo_instance1" }
84 timeout { fail "(timeout) print foo_instance1" }
85 }
86
87
a0b3c4fd 88setup_xfail "hppa*-*-*" CLLbs16901
c906108c
SS
89send_gdb "ptype foo_instance1\n"
90gdb_expect {
91 -re "type = class foo \{.*public:.*int ifoo;.*const char \\*ccpfoo;.*foo\\(int\\);.*foo\\(int, (const char|char const) \\*\\);.*foo\\(foo &\\);.*~foo\\(void\\);.*void foofunc\\(int\\);.*void foofunc\\(int, signed char \\*\\);.*int overload1arg\\(void\\);.*int overload1arg\\(char\\);.*int overload1arg\\(signed char\\);.*int overload1arg\\(unsigned char\\);.*int overload1arg\\(short\\);.*int overload1arg\\(unsigned short\\);.*int overload1arg\\(int\\);.*int overload1arg\\(unsigned int\\);.*int overload1arg\\(long\\);.*int overload1arg\\(unsigned long\\);.*int overload1arg\\(float\\);.*int overload1arg\\(double\\);.*int overloadargs\\(int\\);.*int overloadargs\\(int, int\\);.*int overloadargs\\(int, int, int\\);.*int overloadargs\\(int, int, int, int\\);.*int overloadargs\\(int, int, int, int, int\\);.*int overloadargs\\(int, int, int, int, int, int\\);.*int overloadargs\\(int, int, int, int, int, int, int\\);.*int overloadargs\\(int, int, int, int, int, int, int, int\\);.*int overloadargs\\(int, int, int, int, int, int, int, int, int\\);.*int overloadargs\\(int, int, int, int, int, int, int, int, int, int\\);.*int overloadargs\\(int, int, int, int, int, int, int, int, int, int, int\\);\r\n\}\r\n$gdb_prompt $" {
92 pass "ptype foo_instance1 (HP aCC -- known quirk with ~foo parameter list)"
93 }
9e0b60a8
JM
94 -re "type = class foo .*int overloadargs\\(int, int, int, int, int, int, int, int, int, int, int\\);\r\n\}\r\n$gdb_prompt $" {
95 pass "ptype foo_instance1 (shorter match)"
96 }
c906108c
SS
97 -re ".*$gdb_prompt $" { fail "ptype foo_instance1" }
98 timeout { fail "(timeout) ptype foo_instance1" }
99 }
100
101send_gdb "print foo_instance2\n"
102gdb_expect {
103 -re ".\[0-9\]* = \{ifoo = 222, ccpfoo = $hex \"A\"\}\r\n$gdb_prompt $" {
104 pass "print foo_instance2"
105 }
106 -re ".*$gdb_prompt $" { fail "print foo_instance2" }
107 timeout { fail "(timeout) print foo_instance2" }
108 }
109
110send_gdb "print foo_instance3\n"
111gdb_expect {
112 -re ".\[0-9\]* = \{ifoo = 222, ccpfoo = $hex \"A\"\}\r\n$gdb_prompt $" {
113 pass "print foo_instance3"
114 }
115 -re ".*$gdb_prompt $" { fail "print foo_instance3" }
116 timeout { fail "(timeout) print foo_instance3" }
117 }
118
119
9e0b60a8
JM
120# The overload resolver added by HP (valops.c:find_overload_match) doesn't
121# work right for G++ output, since the list of parameters seems not to
122# be filled in correctly. Until this gets fixed, don't expect to pass
123# these tests.
c906108c 124
a0b3c4fd 125setup_xfail "*-*-*" CLLbs16901
c906108c
SS
126send_gdb "print foo_instance1.overloadargs(1)\n"
127gdb_expect {
128 -re ".\[0-9\]* = 1\r\n$gdb_prompt $" {
129 pass "print call overloaded func 1 arg"
130 }
131 -re ".*$gdb_prompt $" { fail "print call overloaded func 1 arg" }
132 timeout { fail "(timeout) print call overloaded func 1 arg" }
133 }
134
9e0b60a8 135
a0b3c4fd 136setup_xfail "*-*-*" CLLbs16901
9e0b60a8 137
c906108c
SS
138send_gdb "print foo_instance1.overloadargs(1, 2)\n"
139gdb_expect {
140 -re ".\[0-9\]* = 2\r\n$gdb_prompt $" {
141 pass "print call overloaded func 2 args"
142 }
143 -re ".*$gdb_prompt $" { fail "print call overloaded func 2 args" }
144 timeout { fail "(timeout) print call overloaded func 2 args" }
145 }
146
147
a0b3c4fd 148setup_xfail "*-*-*" CLLbs16901
9e0b60a8 149
c906108c
SS
150send_gdb "print foo_instance1.overloadargs(1, 2, 3)\n"
151gdb_expect {
152 -re ".\[0-9\]* = 3\r\n$gdb_prompt $" {
153 pass "print call overloaded func 3 args"
154 }
155 -re ".*$gdb_prompt $" { fail "print call overloaded func 3 args" }
156 timeout { fail "(timeout) print call overloaded func 3 args" }
157 }
158
159
a0b3c4fd 160setup_xfail "*-*-*" CLLbs16901
9e0b60a8 161
c906108c
SS
162send_gdb "print foo_instance1.overloadargs(1, 2, 3, 4)\n"
163gdb_expect {
164 -re ".\[0-9\]* = 4\r\n$gdb_prompt $" {
165 pass "print call overloaded func 4 args"
166 }
167 -re ".*$gdb_prompt $" { fail "print call overloaded func 4 args" }
168 timeout { fail "(timeout) print call overloaded func 4 args" }
169 }
170
171
a0b3c4fd 172setup_xfail "*-*-*" CLLbs16901
9e0b60a8 173
c906108c
SS
174send_gdb "print foo_instance1.overloadargs(1, 2, 3, 4, 5)\n"
175gdb_expect {
176 -re ".\[0-9\]* = 5\r\n$gdb_prompt $" {
177 pass "print call overloaded func 5 args"
178 }
179 -re ".*$gdb_prompt $" { fail "print call overloaded func 5 args" }
180 timeout { fail "(timeout) print call overloaded func 5 args" }
181 }
182
183
a0b3c4fd 184setup_xfail "*-*-*" CLLbs16901
9e0b60a8 185
c906108c
SS
186send_gdb "print foo_instance1.overloadargs(1, 2, 3, 4, 5, 6)\n"
187gdb_expect {
188 -re ".\[0-9\]* = 6\r\n$gdb_prompt $" {
189 pass "print call overloaded func 6 args"
190 }
191 -re ".*$gdb_prompt $" { fail "print call overloaded func 6 args" }
192 timeout { fail "(timeout) print call overloaded func 6 args" }
193 }
194
195
a0b3c4fd 196setup_xfail "*-*-*" CLLbs16901
9e0b60a8 197
c906108c
SS
198send_gdb "print foo_instance1.overloadargs(1, 2, 3, 4, 5, 6, 7)\n"
199gdb_expect {
200 -re ".\[0-9\]* = 7\r\n$gdb_prompt $" {
201 pass "print call overloaded func 7 args"
202 }
203 -re ".*$gdb_prompt $" { fail "print call overloaded func 7 args" }
204 timeout { fail "(timeout) print call overloaded func 7 args" }
205 }
206
207
a0b3c4fd 208setup_xfail "*-*-*" CLLbs16901
9e0b60a8 209
c906108c
SS
210send_gdb "print foo_instance1.overloadargs(1, 2, 3, 4, 5, 6, 7, 8)\n"
211gdb_expect {
212 -re ".\[0-9\]* = 8\r\n$gdb_prompt $" {
213 pass "print call overloaded func 8 args"
214 }
215 -re ".*$gdb_prompt $" { fail "print call overloaded func 8 args" }
216 timeout { fail "(timeout) print call overloaded func 8 args" }
217 }
218
219
a0b3c4fd 220setup_xfail "*-*-*" CLLbs16901
9e0b60a8 221
c906108c
SS
222send_gdb "print foo_instance1.overloadargs(1, 2, 3, 4, 5, 6, 7, 8, 9)\n"
223gdb_expect {
224 -re ".\[0-9\]* = 9\r\n$gdb_prompt $" {
225 pass "print call overloaded func 9 args"
226 }
227 -re ".*$gdb_prompt $" { fail "print call overloaded func 9 args" }
228 timeout { fail "(timeout) print call overloaded func 9 args" }
229 }
230
231
a0b3c4fd 232setup_xfail "*-*-*" CLLbs16901
9e0b60a8 233
c906108c
SS
234send_gdb "print foo_instance1.overloadargs(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)\n"
235gdb_expect {
236 -re ".\[0-9\]* = 10\r\n$gdb_prompt $" {
237 pass "print call overloaded func 10 args"
238 }
239 -re ".*$gdb_prompt $" { fail "print call overloaded func 10 args" }
240 timeout { fail "(timeout) print call overloaded func 10 args" }
241 }
242
243
a0b3c4fd 244setup_xfail "*-*-*" CLLbs16901
9e0b60a8 245
c906108c
SS
246send_gdb "print foo_instance1.overloadargs(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)\n"
247gdb_expect {
248 -re ".\[0-9\]* = 11\r\n$gdb_prompt $" {
249 pass "print call overloaded func 11 args"
250 }
251 -re ".*$gdb_prompt $" { fail "print call overloaded func 11 args" }
252 timeout { fail "(timeout) print call overloaded func 11 args" }
253 }
254
255
a0b3c4fd 256setup_xfail "*-*-*" CLLbs16901
9e0b60a8 257
c906108c
SS
258send_gdb "print foo_instance1.overload1arg()\n"
259gdb_expect {
260 -re ".\[0-9\]* = 1\r\n$gdb_prompt $" {
261 pass "print call overloaded func void arg"
262 }
263 -re ".*$gdb_prompt $" { fail "print call overloaded func void arg" }
264 timeout { fail "(timeout) print call overloaded func void arg" }
265 }
266
9e0b60a8 267
a0b3c4fd 268setup_xfail "*-*-*" CLLbs16901
9e0b60a8 269
c906108c
SS
270send_gdb "print foo_instance1.overload1arg((char)arg2)\n"
271gdb_expect {
272 -re ".\[0-9\]* = 2\r\n$gdb_prompt $" {
273 pass "print call overloaded func char arg"
274 }
275 -re ".*$gdb_prompt $" { fail "print call overloaded func char arg" }
276 timeout { fail "(timeout) print call overloaded func char arg" }
277 }
278
9e0b60a8 279
a0b3c4fd 280setup_xfail "*-*-*" CLLbs16901
9e0b60a8 281
c906108c
SS
282send_gdb "print foo_instance1.overload1arg((signed char)arg3)\n"
283gdb_expect {
284 -re ".\[0-9\]* = 3\r\n$gdb_prompt $" {
285 pass "print call overloaded func signed char arg"
286 }
287 -re ".*$gdb_prompt $" { fail "print call overloaded func signed char arg" }
288 timeout { fail "(timeout) print call overloaded func signed char arg" }
289 }
290
291
a0b3c4fd 292setup_xfail "*-*-*" CLLbs16901
9e0b60a8 293
c906108c
SS
294send_gdb "print foo_instance1.overload1arg((unsigned char)arg4)\n"
295gdb_expect {
296 -re ".\[0-9\]* = 4\r\n$gdb_prompt $" {
297 pass "print call overloaded func unsigned char arg"
298 }
299 -re ".*$gdb_prompt $" { fail "print call overloaded func unsigned char arg" }
300 timeout { fail "(timeout) print call overloaded func unsigned char arg" }
301 }
302
303
a0b3c4fd 304setup_xfail "*-*-*" CLLbs16901
9e0b60a8 305
c906108c
SS
306send_gdb "print foo_instance1.overload1arg((short)arg5)\n"
307gdb_expect {
308 -re ".\[0-9\]* = 5\r\n$gdb_prompt $" {
309 pass "print call overloaded func short arg"
310 }
311 -re ".*$gdb_prompt $" { fail "print call overloaded func short arg" }
312 timeout { fail "(timeout) print call overloaded func short arg" }
313 }
314
315
a0b3c4fd 316setup_xfail "*-*-*" CLLbs16901
9e0b60a8 317
c906108c
SS
318send_gdb "print foo_instance1.overload1arg((unsigned short)arg6)\n"
319gdb_expect {
320 -re ".\[0-9\]* = 6\r\n$gdb_prompt $" {
321 pass "print call overloaded func unsigned short arg"
322 }
323 -re ".*$gdb_prompt $" { fail "print call overloaded func unsigned short arg" }
324 timeout { fail "(timeout) print call overloaded func unsigned short arg" }
325 }
326
327
a0b3c4fd 328setup_xfail "*-*-*" CLLbs16901
9e0b60a8 329
c906108c
SS
330send_gdb "print foo_instance1.overload1arg((int)arg7)\n"
331gdb_expect {
332 -re ".\[0-9\]* = 7\r\n$gdb_prompt $" {
333 pass "print call overloaded func int arg"
334 }
335 -re ".*$gdb_prompt $" { fail "print call overloaded func int arg" }
336 timeout { fail "(timeout) print call overloaded func int arg" }
337 }
338
339
a0b3c4fd 340setup_xfail "*-*-*" CLLbs16901
9e0b60a8 341
c906108c
SS
342send_gdb "print foo_instance1.overload1arg((unsigned int)arg8)\n"
343gdb_expect {
344 -re ".\[0-9\]* = 8\r\n$gdb_prompt $" {
345 pass "print call overloaded func unsigned int arg"
346 }
347 -re ".*$gdb_prompt $" { fail "print call overloaded func unsigned int arg" }
348 timeout { fail "(timeout) print call overloaded func unsigned int arg" }
349 }
350
351
a0b3c4fd 352setup_xfail "*-*-*" CLLbs16901
9e0b60a8 353
c906108c
SS
354send_gdb "print foo_instance1.overload1arg((long)arg9)\n"
355gdb_expect {
356 -re ".\[0-9\]* = 9\r\n$gdb_prompt $" {
357 pass "print call overloaded func long arg"
358 }
359 -re ".*$gdb_prompt $" { fail "print call overloaded func long arg" }
360 timeout { fail "(timeout) print call overloaded func long arg" }
361 }
362
363
a0b3c4fd 364setup_xfail "*-*-*" CLLbs16901
9e0b60a8 365
c906108c
SS
366send_gdb "print foo_instance1.overload1arg((unsigned long)arg10)\n"
367gdb_expect {
368 -re ".\[0-9\]* = 10\r\n$gdb_prompt $" {
369 pass "print call overloaded func unsigned long arg"
370 }
371 -re ".*$gdb_prompt $" { fail "print call overloaded func unsigned long arg" }
372 timeout { fail "(timeout) print call overloaded func unsigned long arg" }
373 }
374
375
a0b3c4fd 376setup_xfail "*-*-*" CLLbs16901
9e0b60a8 377
c906108c
SS
378send_gdb "print foo_instance1.overload1arg((float)arg11)\n"
379gdb_expect {
380 -re ".\[0-9\]* = 11\r\n$gdb_prompt $" {
381 pass "print call overloaded func float arg"
382 }
383 -re ".*$gdb_prompt $" { fail "print call overloaded func float arg" }
384 timeout { fail "(timeout) print call overloaded func float arg" }
385 }
386
387
a0b3c4fd 388setup_xfail "*-*-*" CLLbs16901
9e0b60a8 389
c906108c
SS
390send_gdb "print foo_instance1.overload1arg((double)arg12)\n"
391gdb_expect {
392 -re ".\[0-9\]* = 12\r\n$gdb_prompt $" {
393 pass "print call overloaded func double arg"
394 }
395 -re ".*$gdb_prompt $" { fail "print call overloaded func double arg" }
396 timeout { fail "(timeout) print call overloaded func double arg" }
397 }
This page took 0.048513 seconds and 4 git commands to generate.