]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.cp/classes.exp
2010-06-08 Michael Snyder <msnyder@vmware.com>
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.cp / classes.exp
CommitLineData
6aba47ca 1# Copyright 1992, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
4c38e0a4 2# 2004, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
c906108c
SS
3
4# This program is free software; you can redistribute it and/or modify
5# it under the terms of the GNU General Public License as published by
e22f8b7c 6# the Free Software Foundation; either version 3 of the License, or
c906108c 7# (at your option) any later version.
e22f8b7c 8#
c906108c
SS
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU General Public License for more details.
e22f8b7c 13#
c906108c 14# You should have received a copy of the GNU General Public License
e22f8b7c 15# along with this program. If not, see <http://www.gnu.org/licenses/>.
c906108c 16
c906108c 17# This file was written by Fred Fish. (fnf@cygnus.com)
1cd3489f 18# And rewritten by Michael Chastain <mec.gnu@mindspring.com>.
c906108c 19
c906108c
SS
20set nl "\[\r\n\]+"
21
22if $tracelevel then {
1cd3489f 23 strace $tracelevel
c906108c
SS
24}
25
d4f3574e 26if { [skip_cplus_tests] } { continue }
c906108c 27
2d3a7986
MC
28load_lib "cp-support.exp"
29
ed69573c 30set testfile "classes"
c906108c
SS
31set srcfile ${testfile}.cc
32set binfile ${objdir}/${subdir}/${testfile}
33
c906108c 34if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } {
b60f0898
JB
35 untested classes.exp
36 return -1
c906108c
SS
37}
38
c906108c 39# Test ptype of class objects.
c906108c
SS
40
41proc test_ptype_class_objects {} {
c906108c 42
1cd3489f 43 # Simple type.
c906108c 44
2d3a7986
MC
45 cp_test_ptype_class \
46 "ptype struct default_public_struct" "" "struct" "default_public_struct" \
47 {
48 { field public "int a;" }
49 { field public "int b;" }
c906108c 50 }
c906108c 51
2d3a7986 52 # Another simple type.
c906108c 53
2d3a7986
MC
54 cp_test_ptype_class \
55 "ptype struct explicit_public_struct" "" "struct" "explicit_public_struct" \
56 {
57 { field public "int a;" }
58 { field public "int b;" }
c906108c 59 }
c906108c 60
2d3a7986 61 # Another simple type.
2fc1f950 62
2d3a7986
MC
63 cp_test_ptype_class \
64 "ptype struct protected_struct" "" "struct" "protected_struct" \
65 {
66 { field protected "int a;" }
67 { field protected "int b;" }
c906108c 68 }
c906108c 69
2d3a7986 70 # Another simple type.
2fc1f950 71
2d3a7986
MC
72 cp_test_ptype_class \
73 "ptype struct private_struct" "" "struct" "private_struct" \
74 {
75 { field private "int a;" }
76 { field private "int b;" }
c906108c 77 }
c906108c 78
2d3a7986 79 # A bigger type.
2fc1f950 80
2d3a7986
MC
81 cp_test_ptype_class \
82 "ptype struct mixed_protection_struct" "" "struct" "mixed_protection_struct" \
83 {
84 { field public "int a;" }
85 { field public "int b;" }
86 { field private "int c;" }
87 { field private "int d;" }
88 { field protected "int e;" }
89 { field protected "int f;" }
90 { field public "int g;" }
91 { field private "int h;" }
92 { field protected "int i;" }
c906108c 93 }
c906108c 94
1cd3489f
MC
95 # All that again with "class" instead of "struct".
96 # gdb does not care about the difference anyways.
c906108c 97
2d3a7986
MC
98 cp_test_ptype_class \
99 "ptype class public_class" "" "class" "public_class" \
100 {
101 { field public "int a;" }
102 { field public "int b;" }
c906108c 103 }
1cd3489f 104
2d3a7986 105 # Another simple type.
2fc1f950 106
2d3a7986
MC
107 cp_test_ptype_class \
108 "ptype class protected_class" "" "class" "protected_class" \
109 {
110 { field protected "int a;" }
111 { field protected "int b;" }
c906108c 112 }
c906108c 113
2d3a7986 114 # Another simple type.
2fc1f950 115
2d3a7986
MC
116 cp_test_ptype_class \
117 "ptype class default_private_class" "" "class" "default_private_class" \
118 {
119 { field private "int a;" }
120 { field private "int b;" }
c906108c 121 }
1cd3489f 122
2d3a7986 123 # Another simple type.
2fc1f950 124
2d3a7986
MC
125 cp_test_ptype_class \
126 "ptype class explicit_private_class" "" "class" "explicit_private_class" \
127 {
128 { field private "int a;" }
129 { field private "int b;" }
c906108c 130 }
c906108c 131
2d3a7986 132 # A bigger type.
1cd3489f 133
2d3a7986
MC
134 cp_test_ptype_class \
135 "ptype class mixed_protection_class" "" "class" "mixed_protection_class" \
136 {
2fc1f950 137
2d3a7986
MC
138 { field public "int a;" }
139 { field public "int b;" }
140 { field private "int c;" }
141 { field private "int d;" }
142 { field protected "int e;" }
143 { field protected "int f;" }
144 { field public "int g;" }
145 { field private "int h;" }
146 { field protected "int i;" }
c906108c 147 }
c906108c 148
1cd3489f
MC
149 # Here are some classes with inheritance.
150
151 # Base class.
152
2d3a7986
MC
153 cp_test_ptype_class \
154 "ptype class A" "" "class" "A" \
155 {
156 { field public "int a;" }
157 { field public "int x;" }
c906108c 158 }
c906108c 159
1cd3489f
MC
160 # Derived class.
161
2d3a7986
MC
162 cp_test_ptype_class \
163 "ptype class B" "" "class" "B" \
164 {
165 { base "public A" }
166 { field public "int b;" }
167 { field public "int x;" }
c906108c 168 }
c906108c 169
1cd3489f
MC
170 # Derived class.
171
2d3a7986
MC
172 cp_test_ptype_class \
173 "ptype class C" "" "class" "C" \
174 {
175 { base "public A" }
176 { field public "int c;" }
177 { field public "int x;" }
c906108c 178 }
c906108c 179
1cd3489f
MC
180 # Derived class, multiple inheritance.
181
2d3a7986
MC
182 cp_test_ptype_class \
183 "ptype class D" "" "class" "D" \
184 {
185 { base "public B" }
186 { base "public C" }
187 { field public "int d;" }
188 { field public "int x;" }
c906108c 189 }
c906108c 190
1cd3489f
MC
191 # Derived class.
192
2d3a7986
MC
193 cp_test_ptype_class \
194 "ptype class E" "" "class" "E" \
195 {
196 { base "public D" }
197 { field public "int e;" }
198 { field public "int x;" }
c906108c 199 }
c906108c 200
1cd3489f
MC
201 # This is a break from inheritance tests.
202 #
203 # gcc 2.X with stabs (stabs or stabs+?) used to have a problem with
204 # static methods whose name is the same as their argument mangling.
205
2d3a7986
MC
206 cp_test_ptype_class \
207 "ptype class Static" "" "class" "Static" \
208 {
209 { method public "static void ii(int, int);" }
3e36a0f4 210 }
af890c52 211
1cd3489f
MC
212 # Here are some virtual inheritance tests.
213
2d3a7986 214 # A virtual base class.
2fc1f950 215
2d3a7986
MC
216 cp_test_ptype_class \
217 "ptype class vA" "" "class" "vA" \
218 {
219 { field public "int va;" }
220 { field public "int vx;" }
c906108c 221 }
c906108c 222
2d3a7986 223 # A derived class with a virtual base.
2fc1f950 224
2d3a7986
MC
225 cp_test_ptype_class \
226 "ptype class vB" "" "class" "vB" \
227 {
228 { base "public virtual vA" }
229 { vbase "vA" }
230 { field public "int vb;" }
231 { field public "int vx;" }
2fc1f950 232 }
c906108c 233
2d3a7986 234 # Another derived class with a virtual base.
c906108c 235
2d3a7986
MC
236 cp_test_ptype_class \
237 "ptype class vC" "" "class" "vC" \
238 {
239 { base "public virtual vA" }
240 { vbase "vA" }
241 { field public "int vc;" }
242 { field public "int vx;" }
c906108c 243 }
c906108c 244
2d3a7986 245 # A classic diamond class.
2fc1f950 246
2d3a7986
MC
247 cp_test_ptype_class \
248 "ptype class vD" "" "class" "vD" \
249 {
250 { base "public virtual vB" }
251 { base "public virtual vC" }
252 { vbase "vC" }
253 { vbase "vB" }
254 { field public "int vd;" }
255 { field public "int vx;" }
c906108c 256 }
c906108c 257
2d3a7986 258 # A class derived from a diamond class.
c906108c 259
2d3a7986
MC
260 cp_test_ptype_class \
261 "ptype class vE" "" "class" "vE" \
262 {
263 { base "public virtual vD" }
264 { vbase "vD" }
265 { field public "int ve;" }
266 { field public "int vx;" }
5178b9d6 267 }
c906108c 268
1cd3489f
MC
269 # Another inheritance series.
270
2d3a7986
MC
271 # A base class.
272
273 cp_test_ptype_class \
274 "ptype class Base1" "" "class" "Base1" \
275 {
276 { field public "int x;" }
277 { method public "Base1(int);" }
278 }
279
280 # Another base class.
281
282 cp_test_ptype_class \
283 "ptype class Foo" "" "class" "Foo" \
284 {
285 { field public "int x;" }
286 { field public "int y;" }
287 { field public "static int st;" }
288 { method public "Foo(int, int);" }
289 { method public "int operator!();" }
290 { method public "operator int();" }
291 { method public "int times(int);" }
292 } \
293 "" \
294 {
295 {
296 "operator int();"
297 "int operator int();"
298 { setup_kfail "gdb/1497" "*-*-*" }
299 }
300 {
301 "operator int();"
302 "int operator int(void);"
303 { setup_kfail "gdb/1497" "*-*-*" }
304 }
3e36a0f4 305 }
c906108c 306
1cd3489f
MC
307 # A multiple inheritance derived class.
308
2d3a7986
MC
309 cp_test_ptype_class \
310 "ptype class Bar" "" "class" "Bar" \
311 {
312 { base "public Base1" }
313 { base "public Foo" }
314 { field public "int z;" }
315 { method public "Bar(int, int, int);" }
c906108c 316 }
2d3a7986 317
c906108c
SS
318}
319
c906108c 320# Test simple access to class members.
c906108c
SS
321
322proc test_non_inherited_member_access {} {
c906108c
SS
323
324 # Print non-inherited members of g_A.
226a8d71
MC
325 gdb_test "print g_A.a" ".* = 1"
326 gdb_test "print g_A.x" ".* = 2"
c906108c
SS
327
328 # Print non-inherited members of g_B.
226a8d71
MC
329 gdb_test "print g_B.b" ".* = 5"
330 gdb_test "print g_B.x" ".* = 6"
c906108c
SS
331
332 # Print non-inherited members of g_C.
226a8d71
MC
333 gdb_test "print g_C.c" ".* = 9"
334 gdb_test "print g_C.x" ".* = 10"
c906108c
SS
335
336 # Print non-inherited members of g_D.
226a8d71
MC
337 gdb_test "print g_D.d" ".* = 19"
338 gdb_test "print g_D.x" ".* = 20"
c906108c
SS
339
340 # Print non-inherited members of g_E.
226a8d71
MC
341 gdb_test "print g_E.e" ".* = 31"
342 gdb_test "print g_E.x" ".* = 32"
c906108c
SS
343}
344
1cd3489f
MC
345# Test access to members of other classes.
346# gdb should refuse to print them.
347# (I feel old -- I remember when this was legal in C -- chastain).
c906108c
SS
348
349proc test_wrong_class_members {} {
226a8d71
MC
350 gdb_test "print g_A.b" "There is no member( or method|) named b."
351 gdb_test "print g_B.c" "There is no member( or method|) named c."
352 gdb_test "print g_B.d" "There is no member( or method|) named d."
353 gdb_test "print g_C.b" "There is no member( or method|) named b."
354 gdb_test "print g_C.d" "There is no member( or method|) named d."
355 gdb_test "print g_D.e" "There is no member( or method|) named e."
c906108c
SS
356}
357
1cd3489f 358# Test access to names that are not members of any class.
c906108c 359
2bec0572 360proc test_nonexistent_members {} {
226a8d71
MC
361 gdb_test "print g_A.y" "There is no member( or method|) named y."
362 gdb_test "print g_B.z" "There is no member( or method|) named z."
363 gdb_test "print g_C.q" "There is no member( or method|) named q."
364 gdb_test "print g_D.p" "There is no member( or method|) named p."
c906108c
SS
365}
366
54602222
ND
367# Call a method that expects a base class parameter with base, inherited,
368# and unrelated class arguments.
54602222
ND
369
370proc test_method_param_class {} {
226a8d71
MC
371 gdb_test "call class_param.Aptr_a (&g_A)" ".* = 1"
372 gdb_test "call class_param.Aptr_x (&g_A)" ".* = 2"
373 gdb_test "call class_param.Aptr_a (&g_B)" ".* = 3"
374 gdb_test "call class_param.Aptr_x (&g_B)" ".* = 4"
375 gdb_test "call class_param.Aref_a (g_A)" ".* = 1"
376 gdb_test "call class_param.Aref_x (g_A)" ".* = 2"
377 gdb_test "call class_param.Aref_a (g_B)" ".* = 3"
378 gdb_test "call class_param.Aref_x (g_B)" ".* = 4"
379 gdb_test "call class_param.Aval_a (g_A)" ".* = 1"
380 gdb_test "call class_param.Aval_x (g_A)" ".* = 2"
381 gdb_test "call class_param.Aval_a (g_B)" ".* = 3"
382 gdb_test "call class_param.Aval_x (g_B)" ".* = 4"
54602222
ND
383
384 gdb_test "call class_param.Aptr_a (&foo)" "Cannot resolve .*" "unrelated class *param"
385 gdb_test "call class_param.Aref_a (foo)" "Cannot resolve .*" "unrelated class &param"
386 gdb_test "call class_param.Aval_a (foo)" "Cannot resolve .*" "unrelated class param"
387}
388
2bec0572 389# Examine a class with an enum field.
2bec0572
ND
390
391proc test_enums {} {
392 global gdb_prompt
1cd3489f 393 global nl
2bec0572
ND
394
395 # print the object
2bec0572 396
0114d602
DJ
397 # We match the enum values with and without qualifiers. As of
398 # 2008-08-21 we can output the qualifiers for DWARF-2.
399
1cd3489f 400 gdb_test "print obj_with_enum" \
0114d602 401 "\\$\[0-9\]+ = \{priv_enum = (ClassWithEnum::)?red, x = 0\}" \
1cd3489f
MC
402 "print obj_with_enum (1)"
403
404 # advance one line
405
406 gdb_test "next" ""
407
2bec0572 408 # print the object again
2bec0572 409
1cd3489f 410 gdb_test "print obj_with_enum" \
0114d602 411 "\\$\[0-9\]+ = \{priv_enum = (ClassWithEnum::)?green, x = 0\}" \
1cd3489f
MC
412 "print obj_with_enum (2)"
413
414 # print the enum member
415
0114d602 416 gdb_test "print obj_with_enum.priv_enum" "\\$\[0-9\]+ = (ClassWithEnum::)?green"
2bec0572
ND
417
418 # ptype on the enum member
1cd3489f
MC
419
420 gdb_test_multiple "ptype obj_with_enum.priv_enum" "ptype obj_with_enum.priv_enum" {
0114d602 421 -re "type = enum ClassWithEnum::PrivEnum \{ ?(ClassWithEnum::)?red, (ClassWithEnum::)?green, (ClassWithEnum::)?blue, (ClassWithEnum::)?yellow = 42 ?\}$nl$gdb_prompt $" {
1cd3489f
MC
422 pass "ptype obj_with_enum.priv_enum"
423 }
0114d602 424 -re "type = enum PrivEnum \{ ?(ClassWithEnum::)?red, (ClassWithEnum::)?green, (ClassWithEnum::)?blue, (ClassWithEnum::)?yellow = 42 ?\}$nl$gdb_prompt $" {
1cd3489f
MC
425 # gcc 2.95.3 -gdwarf-2
426 # gcc 3.3.2 -gdwarf-2
427 pass "ptype obj_with_enum.priv_enum"
428 }
429 -re "type = enum \{ ?red, green, blue, yellow = 42 ?\}$nl$gdb_prompt $" {
430 # This case case is a little dubious, but it's not clear what
431 # ought to be required of a ptype on a private enum...
432 # -sts 19990324
433 #
434 # It bugs me that this happens with gcc 3.
435 # -- chastain 2003-12-30
436 #
437 # gcc 2.95.3 -gstabs+
438 # gcc 3.3.2 -gstabs+
439 # gcc HEAD 2003-12-28 21:08:30 UTC -gstabs+
440 pass "ptype obj_with_enum.priv_enum"
441 }
2bec0572
ND
442 }
443
444 # ptype on the object
2fc1f950 445
2d3a7986
MC
446 # NOTE: carlton/2003-02-28: One could certainly argue that plain
447 # "PrivEnum"
448 # is acceptable: PrivEnum is a member of ClassWithEnum, so
449 # there's no need to explicitly qualify its name with
450 # "ClassWithEnum::". The truth, though, is that GDB is simply
451 # forgetting that PrivEnum is a member of ClassWithEnum, so we do
452 # that output for a bad reason instead of a good reason. Under
453 # stabs, we probably can't get this right; under DWARF-2, we can.
454
455 cp_test_ptype_class \
456 "ptype obj_with_enum" "" "class" "ClassWithEnum" \
457 {
458 { field public "ClassWithEnum::PrivEnum priv_enum;" }
459 { field public "int x;" }
460 } \
461 "" \
462 {
463 {
464 "ClassWithEnum::PrivEnum priv_enum;"
465 "PrivEnum priv_enum;"
466 { setup_kfail "gdb/57" "*-*-*" }
467 }
1cd3489f 468 }
2bec0572 469
1cd3489f 470 # I'll do this test two different ways, because of a parser bug.
23c73aa3 471 # See PR gdb/1588.
6ece72da 472
1cd3489f 473 gdb_test_multiple "print (ClassWithEnum::PrivEnum) 42" "print (ClassWithEnum::PrivEnum) 42" {
0114d602 474 -re "\\$\[0-9\]+ = (ClassWithEnum::)?yellow$nl$gdb_prompt $" {
1cd3489f 475 pass "print (ClassWithEnum::PrivEnum) 42"
d8a2d9e7 476 }
1cd3489f
MC
477 -re "A (parse|syntax) error in expression, near `42'.$nl$gdb_prompt $" {
478 # "parse error" is bison 1.35.
479 # "syntax error" is bison 1.875.
23c73aa3 480 kfail "gdb/1588" "print (ClassWithEnum::PrivEnum) 42"
d8a2d9e7 481 }
2bec0572 482 }
6ece72da 483
1cd3489f 484 gdb_test_multiple "print ('ClassWithEnum::PrivEnum') 42" "print ('ClassWithEnum::PrivEnum') 42" {
0114d602 485 -re "\\$\[0-9\]+ = (ClassWithEnum::)?yellow$nl$gdb_prompt $" {
1cd3489f
MC
486 # gcc 3.3.2 -gstabs+
487 # gcc HEAD 2003-12-28 21:08:30 UTC -gstabs+
488 pass "print ('ClassWithEnum::PrivEnum') 42"
489 }
490 -re "No symbol \"ClassWithEnum::PrivEnum\" in current context.$nl$gdb_prompt $" {
491 # gcc 2.95.3 -gdwarf-2
492 # gcc 3.3.2 -gdwarf-2
493 # gcc HEAD 2003-12-28 21:08:30 UTC -gdwarf-2
494 # gcc 2.95.3 -gstabs+
495 kfail "gdb/57" "print ('ClassWithEnum::PrivEnum') 42"
496 }
6ece72da 497 }
2bec0572
ND
498}
499
c906108c 500# Pointers to class members
c906108c
SS
501
502proc test_pointers_to_class_members {} {
0d5de010
DJ
503 gdb_test "print Bar::z" "Cannot reference non-static field \"z\""
504 gdb_test "print &Foo::x" "\\$\[0-9\]+ = &Foo::x"
1cd3489f
MC
505 gdb_test "print (int)&Foo::x" "\\$\[0-9\]+ = 0"
506 gdb_test "print (int)&Bar::y == 2*sizeof(int)" "\\$\[0-9\]+ = true"
184ad485 507
0d5de010
DJ
508 gdb_test "ptype Bar::z" "type = int"
509 gdb_test "ptype &Bar::z" "type = int Bar::\\*"
510
184ad485
MC
511 # TODO: this is a bogus test. It's looking at a variable that
512 # has not even been declared yet, so it's accessing random junk
513 # on the stack and comparing that it's NOT equal to a specific
514 # value. It's been like this since gdb 4.10 in 1993!
515 # -- chastain 2004-01-01
516 gdb_test "print (int)pmi == sizeof(int)" ".* = false"
c906108c
SS
517}
518
c906108c 519# Test static members.
c906108c
SS
520
521proc test_static_members {} {
c906108c 522 global hex
c906108c 523
1cd3489f 524 gdb_test "print Foo::st" "\\$\[0-9\]+ = 100"
35ec993f 525 gdb_test_no_output "set foo.st = 200" ""
1cd3489f
MC
526 gdb_test "print bar.st" "\\$\[0-9\]+ = 200"
527 gdb_test "print &foo.st" "\\$\[0-9\]+ = \\(int ?\\*\\) $hex"
528 gdb_test "print &Bar::st" "\\$\[0-9\]+ = \\(int ?\\*\\) $hex"
529 gdb_test "print *\$" "\\$\[0-9\]+ = 200"
c906108c 530
a8d52276 531 gdb_test_no_output "set print static-members off"
c906108c
SS
532 gdb_test "print csi" \
533 "{x = 10, y = 20}" \
534 "print csi without static members"
535 gdb_test "print cnsi" \
536 "{x = 30, y = 40}" \
537 "print cnsi without static members"
538
a8d52276 539 gdb_test_no_output "set print static-members on"
c906108c
SS
540 gdb_test "print csi" \
541 "{x = 10, y = 20, static null = {x = 0, y = 0, static null = <same as static member of an already seen type>}}" \
542 "print csi with static members"
c906108c
SS
543 gdb_test "print cnsi" \
544 "{x = 30, y = 40, static null = {x = 0, y = 0, static null = <same as static member of an already seen type>, static yy = {z = 5, static xx = {x = 1, y = 2, static null = <same as static member of an already seen type>, static yy = <same as static member of an already seen type>}}}, static yy = <same as static member of an already seen type>}" \
545 "print cnsi with static members"
546}
547
548proc do_tests {} {
c906108c
SS
549 global subdir
550 global objdir
551 global srcdir
552 global binfile
553 global gdb_prompt
1cd3489f 554 global nl
c906108c 555
c906108c
SS
556
557 # Start with a fresh gdb.
558
559 gdb_exit
560 gdb_start
561 gdb_reinitialize_dir $srcdir/$subdir
562 gdb_load $binfile
563
35ec993f
MS
564 gdb_test_no_output "set language c++" ""
565 gdb_test_no_output "set width 0" ""
c906108c 566
1cd3489f
MC
567 if ![runto_main ] then {
568 perror "couldn't run to breakpoint"
569 return
2bec0572
ND
570 }
571
1cd3489f
MC
572 gdb_breakpoint inheritance2
573 gdb_test "continue" ".*Breakpoint .* inheritance2.*" ""
c906108c 574
1cd3489f
MC
575 test_ptype_class_objects
576 test_non_inherited_member_access
577 test_wrong_class_members
578 test_nonexistent_members
579 test_method_param_class
c906108c 580
1cd3489f 581 gdb_breakpoint enums2
184ad485 582 gdb_test "continue" ".*Breakpoint .* enums2.*" "continue to enums2(\\(\\)|)"
471ba8c9
DJ
583 # Leave enums2. Make sure we reach the next line, in case there
584 # are any more instructions to finish the function call.
585 gdb_test_multiple "finish" "" {
586 -re "enums2 \\(\\);.*$gdb_prompt $" {
de7ff789 587 gdb_test "next" ".*" ""
471ba8c9
DJ
588 }
589 -re "$gdb_prompt $" { }
590 }
1cd3489f
MC
591 test_enums
592
de7ff789 593 gdb_test "finish" ".*" ""
184ad485
MC
594 test_pointers_to_class_members
595 test_static_members
596
1cd3489f
MC
597 # Now some random tests that were just thrown in here.
598
599 gdb_breakpoint marker_reg1
600 gdb_test "continue" ".*Breakpoint .* marker_reg1.*" ""
601 gdb_test "finish" "Run till exit from.*" "finish from marker_reg1"
602
603 # This class is so small that an instance of it can fit in a register.
604 # When gdb tries to call a method, it gets embarrassed about taking
605 # the address of a register.
606 #
607 # TODO: I think that message should be a PASS, not an XFAIL.
608 # gdb prints an informative message and declines to do something
609 # impossible.
610 #
611 # The method call actually succeeds if the compiler allocates very
612 # small classes in memory instead of registers. So this test does
613 # not tell us anything interesting if the call succeeds.
614 #
615 # -- chastain 2003-12-31
616 gdb_test_multiple "print v.method ()" "calling method for small class" {
617 -re "\\$\[0-9\]+ = 82$nl$gdb_prompt $" {
618 # gcc 3.3.2 -gdwarf-2
619 # gcc HEAD 2003-12-28 21:08:30 UTC -gdwarf-2
620 # gcc 3.3.2 -gstabs+
621 # gcc HEAD 2003-12-28 21:08:30 UTC -gstabs+
622 pass "calling method for small class"
623 }
624 -re "Address requested for identifier \"v\" which is in register .*$nl$gdb_prompt $" {
625 # gcc 2.95.3 -gdwarf-2
626 # gcc 2.95.3 -gstabs+
627 setup_xfail "*-*-*" 2972
628 fail "calling method for small class"
c906108c
SS
629 }
630 }
3fe8f3b3
KS
631
632 gdb_test "print base1::Base1" "<.*Base1.*>" "print ctor of typedef class"
633 gdb_test "print base1::~Base1" "<.*~Base1(\\(\\))?>" \
634 "print dtor of typedef class"
40f0318e
KS
635
636 gdb_test "list ByAnyOtherName::times" ".*int Foo::times.*"
c906108c
SS
637}
638
639do_tests