]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.c++/overload.exp
import gdb-1999-06-21 snapshot
[thirdparty/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
46# Create and source the file that provides information about the compiler
47# used to compile the test case.
48
49if [get_compiler_info ${binfile} "c++"] {
50 return -1
51}
c906108c
SS
52
53gdb_exit
54gdb_start
55gdb_reinitialize_dir $srcdir/$subdir
56gdb_load ${binfile}
57
58# set it up at a breakpoint so we can play with the variable values
59#
60if ![runto_main] then {
61 perror "couldn't run to breakpoint"
62 continue
63}
64
65send_gdb "break marker1\n" ; gdb_expect -re ".*$gdb_prompt $"
66
67 send_gdb "cont\n"
68 gdb_expect {
69 -re "Break.* marker1 \\(\\) at .*:$decimal.*$gdb_prompt $" {
70 send_gdb "up\n"
71 gdb_expect {
72 -re ".*$gdb_prompt $" {}
73 timeout { fail "up from marker1" }
74 }
75 }
76 -re "$gdb_prompt $" { fail "continue to marker1" }
77 timeout { fail "(timeout) continue to marker1" }
78 }
79
80
81send_gdb "print foo_instance1\n"
82gdb_expect {
83 -re ".\[0-9\]* = \{ifoo = 111, ccpfoo = 0x0\}\r\n$gdb_prompt $" {
84 pass "print foo_instance1"
85 }
86 -re ".*$gdb_prompt $" { fail "print foo_instance1" }
87 timeout { fail "(timeout) print foo_instance1" }
88 }
89
90
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.
126if {$gcc_compiled} then { setup_xfail "*-*-*" }
c906108c
SS
127
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
JM
137
138if {$gcc_compiled} then { setup_xfail "*-*-*" }
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
9e0b60a8
JM
150if {$gcc_compiled} then { setup_xfail "*-*-*" }
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
9e0b60a8
JM
162if {$gcc_compiled} then { setup_xfail "*-*-*" }
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
9e0b60a8
JM
174if {$gcc_compiled} then { setup_xfail "*-*-*" }
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
9e0b60a8
JM
186if {$gcc_compiled} then { setup_xfail "*-*-*" }
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
9e0b60a8
JM
198if {$gcc_compiled} then { setup_xfail "*-*-*" }
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
9e0b60a8
JM
210if {$gcc_compiled} then { setup_xfail "*-*-*" }
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
9e0b60a8
JM
222if {$gcc_compiled} then { setup_xfail "*-*-*" }
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
9e0b60a8
JM
234if {$gcc_compiled} then { setup_xfail "*-*-*" }
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
9e0b60a8
JM
246if {$gcc_compiled} then { setup_xfail "*-*-*" }
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
9e0b60a8
JM
258if {$gcc_compiled} then { setup_xfail "*-*-*" }
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
JM
269
270if {$gcc_compiled} then { setup_xfail "*-*-*" }
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
JM
281
282if {$gcc_compiled} then { setup_xfail "*-*-*" }
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
9e0b60a8
JM
294if {$gcc_compiled} then { setup_xfail "*-*-*" }
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
9e0b60a8
JM
306if {$gcc_compiled} then { setup_xfail "*-*-*" }
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
9e0b60a8
JM
318if {$gcc_compiled} then { setup_xfail "*-*-*" }
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
9e0b60a8
JM
330if {$gcc_compiled} then { setup_xfail "*-*-*" }
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
9e0b60a8
JM
342if {$gcc_compiled} then { setup_xfail "*-*-*" }
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
9e0b60a8
JM
354if {$gcc_compiled} then { setup_xfail "*-*-*" }
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
9e0b60a8
JM
366if {$gcc_compiled} then { setup_xfail "*-*-*" }
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
9e0b60a8
JM
378if {$gcc_compiled} then { setup_xfail "*-*-*" }
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
9e0b60a8
JM
390if {$gcc_compiled} then { setup_xfail "*-*-*" }
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 }