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