e77d2dc9704def0d56a1ab5d16ba73e07d95be5e
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.c++ / overload.exp
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
28 if $tracelevel then {
29 strace $tracelevel
30 }
31
32 #
33 # test running programs
34 #
35 set prms_id 0
36 set bug_id 0
37
38 set testfile "overload"
39 set srcfile ${testfile}.cc
40 set binfile ${objdir}/${subdir}/${testfile}
41
42 if { [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
46 # Create and source the file that provides information about the compiler
47 # used to compile the test case.
48
49 if [get_compiler_info ${binfile} "c++"] {
50 return -1
51 }
52
53 gdb_exit
54 gdb_start
55 gdb_reinitialize_dir $srcdir/$subdir
56 gdb_load ${binfile}
57
58 # set it up at a breakpoint so we can play with the variable values
59 #
60 if ![runto_main] then {
61 perror "couldn't run to breakpoint"
62 continue
63 }
64
65 send_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
81 send_gdb "print foo_instance1\n"
82 gdb_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
91 send_gdb "ptype foo_instance1\n"
92 gdb_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 }
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 }
99 -re ".*$gdb_prompt $" { fail "ptype foo_instance1" }
100 timeout { fail "(timeout) ptype foo_instance1" }
101 }
102
103 send_gdb "print foo_instance2\n"
104 gdb_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
112 send_gdb "print foo_instance3\n"
113 gdb_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
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.
126 if {$gcc_compiled} then { setup_xfail "*-*-*" }
127
128 send_gdb "print foo_instance1.overloadargs(1)\n"
129 gdb_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
137
138 if {$gcc_compiled} then { setup_xfail "*-*-*" }
139
140 send_gdb "print foo_instance1.overloadargs(1, 2)\n"
141 gdb_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
150 if {$gcc_compiled} then { setup_xfail "*-*-*" }
151
152 send_gdb "print foo_instance1.overloadargs(1, 2, 3)\n"
153 gdb_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
162 if {$gcc_compiled} then { setup_xfail "*-*-*" }
163
164 send_gdb "print foo_instance1.overloadargs(1, 2, 3, 4)\n"
165 gdb_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
174 if {$gcc_compiled} then { setup_xfail "*-*-*" }
175
176 send_gdb "print foo_instance1.overloadargs(1, 2, 3, 4, 5)\n"
177 gdb_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
186 if {$gcc_compiled} then { setup_xfail "*-*-*" }
187
188 send_gdb "print foo_instance1.overloadargs(1, 2, 3, 4, 5, 6)\n"
189 gdb_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
198 if {$gcc_compiled} then { setup_xfail "*-*-*" }
199
200 send_gdb "print foo_instance1.overloadargs(1, 2, 3, 4, 5, 6, 7)\n"
201 gdb_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
210 if {$gcc_compiled} then { setup_xfail "*-*-*" }
211
212 send_gdb "print foo_instance1.overloadargs(1, 2, 3, 4, 5, 6, 7, 8)\n"
213 gdb_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
222 if {$gcc_compiled} then { setup_xfail "*-*-*" }
223
224 send_gdb "print foo_instance1.overloadargs(1, 2, 3, 4, 5, 6, 7, 8, 9)\n"
225 gdb_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
234 if {$gcc_compiled} then { setup_xfail "*-*-*" }
235
236 send_gdb "print foo_instance1.overloadargs(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)\n"
237 gdb_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
246 if {$gcc_compiled} then { setup_xfail "*-*-*" }
247
248 send_gdb "print foo_instance1.overloadargs(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)\n"
249 gdb_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
258 if {$gcc_compiled} then { setup_xfail "*-*-*" }
259
260 send_gdb "print foo_instance1.overload1arg()\n"
261 gdb_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
269
270 if {$gcc_compiled} then { setup_xfail "*-*-*" }
271
272 send_gdb "print foo_instance1.overload1arg((char)arg2)\n"
273 gdb_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
281
282 if {$gcc_compiled} then { setup_xfail "*-*-*" }
283
284 send_gdb "print foo_instance1.overload1arg((signed char)arg3)\n"
285 gdb_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
294 if {$gcc_compiled} then { setup_xfail "*-*-*" }
295
296 send_gdb "print foo_instance1.overload1arg((unsigned char)arg4)\n"
297 gdb_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
306 if {$gcc_compiled} then { setup_xfail "*-*-*" }
307
308 send_gdb "print foo_instance1.overload1arg((short)arg5)\n"
309 gdb_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
318 if {$gcc_compiled} then { setup_xfail "*-*-*" }
319
320 send_gdb "print foo_instance1.overload1arg((unsigned short)arg6)\n"
321 gdb_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
330 if {$gcc_compiled} then { setup_xfail "*-*-*" }
331
332 send_gdb "print foo_instance1.overload1arg((int)arg7)\n"
333 gdb_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
342 if {$gcc_compiled} then { setup_xfail "*-*-*" }
343
344 send_gdb "print foo_instance1.overload1arg((unsigned int)arg8)\n"
345 gdb_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
354 if {$gcc_compiled} then { setup_xfail "*-*-*" }
355
356 send_gdb "print foo_instance1.overload1arg((long)arg9)\n"
357 gdb_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
366 if {$gcc_compiled} then { setup_xfail "*-*-*" }
367
368 send_gdb "print foo_instance1.overload1arg((unsigned long)arg10)\n"
369 gdb_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
378 if {$gcc_compiled} then { setup_xfail "*-*-*" }
379
380 send_gdb "print foo_instance1.overload1arg((float)arg11)\n"
381 gdb_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
390 if {$gcc_compiled} then { setup_xfail "*-*-*" }
391
392 send_gdb "print foo_instance1.overload1arg((double)arg12)\n"
393 gdb_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 }
This page took 0.038588 seconds and 3 git commands to generate.