OSDN Git Service

2004-03-09 Michael Chastain <mec.gnu@mindspring.com>
[pf3gnuchains/pf3gnuchains3x.git] / gdb / testsuite / gdb.cp / classes.exp
1 # Copyright 1992, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
2 # 2003, 2004 Free Software Foundation, Inc.
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
6 # the Free Software Foundation; either version 2 of the License, or
7 # (at your option) any later version.
8
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.
13
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  
17
18 # This file was written by Fred Fish. (fnf@cygnus.com)
19 # And rewritten by Michael Chastain <mec.gnu@mindspring.com>.
20
21 set ws "\[\r\n\t \]+"
22 set nl "\[\r\n\]+"
23
24 if $tracelevel then {
25     strace $tracelevel
26 }
27
28 if { [skip_cplus_tests] } { continue }
29
30 set testfile "classes"
31 set srcfile ${testfile}.cc
32 set binfile ${objdir}/${subdir}/${testfile}
33
34 if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } {
35      gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
36 }
37
38 # Test ptype of class objects.
39 #
40 # This code accepts the output of gcc v2 and v3, dwarf-2 and stabs+.
41 # It could use some expansion with other compilers such as hp-ux ac++.
42 #
43 # There are lots of variations in the output:
44 #
45 # . gcc -stabs+ emits debug info for implicit member functions:
46 #   operator=, copy ctor, ctor.  gcc -gdwarf-2 does not.
47 #
48 # . gcc with abi version 1 puts the implicit member functions
49 #   at the beginning of the member function list; with abi version 2,
50 #   the implicit member functions are at the end of the member function
51 #   list.  This appears as an output difference with -gstabs+.
52 #   gcc 3.3.X defaults to abi version 1, and gcc 3.4 will default
53 #   to abi version 2.
54 #
55 # . gcc v2 shows data members for virtual base pointers.
56 #   gcc v3 does not.
57 #
58 # . gdb always prints "class" for both "class" and "struct".
59 #   In the future, I should accept "struct" in case gdb improves.
60
61 proc test_ptype_class_objects {} {
62     global gdb_prompt
63     global ws
64     global nl
65
66     # Simple type.
67
68     gdb_test_multiple "ptype struct default_public_struct" "ptype struct default_public_struct" {
69         -re "type = class default_public_struct \{${ws}public:${ws}int a;${ws}int b;$nl\}$nl$gdb_prompt $" {
70             # gcc 2.95.3 -gdwarf-2
71             # gcc 3.3.2 -gdwarf-2
72             # gcc HEAD 2003-12-28 21:08:30 UTC -gdwarf-2
73             pass "ptype struct default_public_struct"
74         }
75         -re "type = class default_public_struct \{${ws}public:${ws}int a;${ws}int b;${ws}default_public_struct ?& ?operator ?=\\(default_public_struct const ?&\\);${ws}default_public_struct\\(default_public_struct const ?&\\);${ws}default_public_struct\\((void|)\\);$nl\}$nl$gdb_prompt $" {
76             # gcc 2.95.3 -gstabs+
77             # gcc 3.3.2 -gstabs+
78             # gcc HEAD 2003-12-28 21:08:30 UTC -gstabs+
79             pass "ptype struct default_public_struct"
80         }
81     }
82
83     # Same test, slightly different type.
84
85     gdb_test_multiple "ptype struct explicit_public_struct" "ptype struct explicit_public_struct" {
86         -re "type = class explicit_public_struct \{${ws}public:${ws}int a;${ws}int b;$nl\}$nl$gdb_prompt $" {
87             # gcc 2.95.3 -gdwarf-2
88             # gcc 3.3.2 -gdwarf-2
89             # gcc HEAD 2003-12-28 21:08:30 UTC -gdwarf-2
90             pass "ptype struct explicit_public_struct"
91         }
92         -re "type = class explicit_public_struct \{${ws}public:${ws}int a;${ws}int b;${ws}explicit_public_struct ?& ?operator ?=\\(explicit_public_struct const ?&\\);${ws}explicit_public_struct\\(explicit_public_struct const ?&\\);${ws}explicit_public_struct\\((void|)\\);$nl\}$nl$gdb_prompt $" {
93             # gcc 2.95.3 -gstabs+
94             # gcc 3.3.2 -gstabs+
95             # gcc HEAD 2003-12-28 21:08:30 UTC -gstabs+
96             pass "ptype struct explicit_public_struct"
97         }
98     }
99
100     # Same test, slightly different type.
101
102     gdb_test_multiple "ptype struct protected_struct" "ptype struct protected_struct" {
103         -re "type = class protected_struct \{${ws}protected:${ws}int a;${ws}int b;$nl\}$nl$gdb_prompt $" {
104             # gcc 2.95.3 -gdwarf-2
105             # gcc 3.3.2 -gdwarf-2
106             # gcc HEAD 2003-12-28 21:08:30 UTC -gdwarf-2
107             pass "ptype struct protected_struct"
108         }
109         -re "type = class protected_struct \{${ws}protected:${ws}int a;${ws}int b;${ws}public:${ws}protected_struct ?& ?operator ?=\\(protected_struct const ?&\\);${ws}protected_struct\\(protected_struct const ?&\\);${ws}protected_struct\\((void|)\\);$nl\}$nl$gdb_prompt $" {
110             # gcc 2.95.3 -gstabs+
111             # gcc 3.3.2 -gstabs+
112             # gcc HEAD 2003-12-28 21:08:30 UTC -gstabs+
113             pass "ptype struct protected_struct"
114         }
115     }
116
117     # Same test, slightly different type.
118
119     gdb_test_multiple "ptype struct private_struct" "ptype struct private_struct" {
120         -re "type = class private_struct \{${ws}private:${ws}int a;${ws}int b;$nl\}$nl$gdb_prompt $" {
121             # gcc 2.95.3 -gdwarf-2
122             # gcc 3.3.2 -gdwarf-2
123             # gcc HEAD 2003-12-28 21:08:30 UTC -gdwarf-2
124             pass "ptype struct private_struct"
125         }
126         -re "type = class private_struct \{${ws}private:${ws}int a;${ws}int b;${ws}public:${ws}private_struct ?& ?operator ?=\\(private_struct const ?&\\);${ws}private_struct\\(private_struct const ?&\\);${ws}private_struct\\((void|)\\);$nl\}$nl$gdb_prompt $" {
127             # gcc 2.95.3 -gstabs+
128             # gcc 3.3.2 -gstabs+
129             # gcc HEAD 2003-12-28 21:08:30 UTC -gstabs+
130             pass "ptype struct private_struct"
131         }
132     }
133
134     # Similar test, bigger type.
135
136     gdb_test_multiple "ptype struct mixed_protection_struct" "ptype struct mixed_protection_struct" {
137         -re "type = class mixed_protection_struct \{${ws}public:${ws}int a;${ws}int b;${ws}private:${ws}int c;${ws}int d;${ws}protected:${ws}int e;${ws}int f;${ws}public:${ws}int g;${ws}private:${ws}int h;${ws}protected:${ws}int i;$nl\}$nl$gdb_prompt $" {
138             # gcc 2.95.3 -gdwarf-2
139             # gcc 3.3.2 -gdwarf-2
140             # gcc HEAD 2003-12-28 21:08:30 UTC -gdwarf-2
141             pass "ptype struct mixed_protection_struct"
142         }
143         -re "type = class mixed_protection_struct \{${ws}public:${ws}int a;${ws}int b;${ws}private:${ws}int c;${ws}int d;${ws}protected:${ws}int e;${ws}int f;${ws}public:${ws}int g;${ws}private:${ws}int h;${ws}protected:${ws}int i;${ws}public:${ws}mixed_protection_struct ?& ?operator ?=\\(mixed_protection_struct const ?&\\);${ws}mixed_protection_struct\\(mixed_protection_struct const ?&\\);${ws}mixed_protection_struct\\((void|)\\);$nl\}$nl$gdb_prompt $" {
144             # gcc 2.95.3 -gstabs+
145             # gcc 3.3.2 -gstabs+
146             # gcc HEAD 2003-12-28 21:08:30 UTC -gstabs+
147             pass "ptype struct mixed_protection_struct"
148         }
149     }
150
151     # All that again with "class" instead of "struct".
152     # gdb does not care about the difference anyways.
153
154     gdb_test_multiple "ptype class public_class" "ptype class public_class" {
155         -re "type = class public_class \{${ws}public:${ws}int a;${ws}int b;$nl\}$nl$gdb_prompt $" {
156             # gcc 2.95.3 -gdwarf-2
157             # gcc 3.3.2 -gdwarf-2
158             # gcc HEAD 2003-12-28 21:08:30 UTC -gdwarf-2
159             pass "ptype class public_class"
160         }
161         -re "type = class public_class \{${ws}public:${ws}int a;${ws}int b;${ws}public_class ?& ?operator ?=\\(public_class const ?&\\);${ws}public_class\\(public_class const ?&\\);${ws}public_class\\((void|)\\);$nl\}$nl$gdb_prompt $" {
162             # gcc 2.95.3 -gstabs+
163             # gcc 3.3.2 -gstabs+
164             # gcc HEAD 2003-12-28 21:08:30 UTC -gstabs+
165             pass "ptype class public_class"
166         }
167     }
168
169     # Same test, slightly different type.
170
171     gdb_test_multiple "ptype class protected_class" "ptype class protected_class" {
172         -re "type = class protected_class \{${ws}protected:${ws}int a;${ws}int b;$nl\}$nl$gdb_prompt $" {
173             # gcc 2.95.3 -gdwarf-2
174             # gcc 3.3.2 -gdwarf-2
175             # gcc HEAD 2003-12-28 21:08:30 UTC -gdwarf-2
176             pass "ptype class protected_class"
177         }
178         -re "type = class protected_class \{${ws}protected:${ws}int a;${ws}int b;${ws}public:${ws}protected_class ?& ?operator ?=\\(protected_class const ?&\\);${ws}protected_class\\(protected_class const ?&\\);${ws}protected_class\\((void|)\\);$nl\}$nl$gdb_prompt $" {
179             # gcc 2.95.3 -gstabs+
180             # gcc 3.3.2 -gstabs+
181             # gcc HEAD 2003-12-28 21:08:30 UTC -gstabs+
182             pass "ptype class protected_class"
183         }
184     }
185
186     # Same test, slightly different type.
187     # The 'private' is optional but gdb always prints it.
188
189     gdb_test_multiple "ptype class default_private_class" "ptype class default_private_class" {
190         -re "type = class default_private_class \{${ws}(private:${ws}|)int a;${ws}int b;$nl\}$nl$gdb_prompt $" {
191             # gcc 2.95.3 -gdwarf-2
192             # gcc 3.3.2 -gdwarf-2
193             # gcc HEAD 2003-12-28 21:08:30 UTC -gdwarf-2
194             pass "ptype class default_private_class"
195         }
196         -re "type = class default_private_class \{${ws}(private:${ws}|)int a;${ws}int b;${ws}public:${ws}default_private_class ?& ?operator ?=\\(default_private_class const ?&\\);${ws}default_private_class\\(default_private_class const ?&\\);${ws}default_private_class\\((void|)\\);$nl\}$nl$gdb_prompt $" {
197             # gcc 2.95.3 -gstabs+
198             # gcc 3.3.2 -gstabs+
199             # gcc HEAD 2003-12-28 21:08:30 UTC -gstabs+
200             pass "ptype class default_private_class"
201         }
202     }
203
204     # Same test, slightly different type.
205
206     gdb_test_multiple "ptype class explicit_private_class" "ptype class explicit_private_class" {
207         -re "type = class explicit_private_class \{${ws}(private:${ws}|)int a;${ws}int b;$nl\}$nl$gdb_prompt $" {
208             # gcc 2.95.3 -gdwarf-2
209             # gcc 3.3.2 -gdwarf-2
210             # gcc HEAD 2003-12-28 21:08:30 UTC -gdwarf-2
211             pass "ptype class explicit_private_class"
212         }
213         -re "type = class explicit_private_class \{${ws}(private:${ws}|)int a;${ws}int b;${ws}public:${ws}explicit_private_class ?& ?operator ?=\\(explicit_private_class const ?&\\);${ws}explicit_private_class\\(explicit_private_class const ?&\\);${ws}explicit_private_class\\((void|)\\);$nl\}$nl$gdb_prompt $" {
214             # gcc 2.95.3 -gstabs+
215             # gcc 3.3.2 -gstabs+
216             # gcc HEAD 2003-12-28 21:08:30 UTC -gstabs+
217             pass "ptype class explicit_private_class"
218         }
219     }
220
221     # Similar test, bigger type.
222
223     gdb_test_multiple "ptype class mixed_protection_class" "ptype struct mixed_protection_class" {
224         -re "type = class mixed_protection_class \{${ws}public:${ws}int a;${ws}int b;${ws}private:${ws}int c;${ws}int d;${ws}protected:${ws}int e;${ws}int f;${ws}public:${ws}int g;${ws}private:${ws}int h;${ws}protected:${ws}int i;$nl\}$nl$gdb_prompt $" {
225             # gcc 2.95.3 -gdwarf-2
226             # gcc 3.3.2 -gdwarf-2
227             # gcc HEAD 2003-12-28 21:08:30 UTC -gdwarf-2
228             pass "ptype class mixed_protection_class"
229         }
230         -re "type = class mixed_protection_class \{${ws}public:${ws}int a;${ws}int b;${ws}private:${ws}int c;${ws}int d;${ws}protected:${ws}int e;${ws}int f;${ws}public:${ws}int g;${ws}private:${ws}int h;${ws}protected:${ws}int i;${ws}public:${ws}mixed_protection_class ?& ?operator ?=\\(mixed_protection_class const ?&\\);${ws}mixed_protection_class\\(mixed_protection_class const ?&\\);${ws}mixed_protection_class\\((void|)\\);$nl\}$nl$gdb_prompt $" {
231             # gcc 2.95.3 -gstabs+
232             # gcc 3.3.2 -gstabs+
233             # gcc HEAD 2003-12-28 21:08:30 UTC -gstabs+
234             pass "ptype class mixed_protection_class"
235         }
236     }
237
238     # Here are some classes with inheritance.
239
240     # Base class.
241
242     gdb_test_multiple "ptype class A" "ptype class A" {
243         -re "type = class A \{${ws}public:${ws}int a;${ws}int x;$nl\}$nl$gdb_prompt $" {
244             # gcc 2.95.3 -gdwarf-2
245             # gcc 3.3.2 -gdwarf-2
246             # gcc HEAD 2003-12-28 21:08:30 UTC -gdwarf-2
247             pass "ptype class A"
248         }
249         -re "type = class A \{${ws}public:${ws}int a;${ws}int x;${ws}A ?& ?operator ?=\\(A const ?&\\);${ws}A\\(A const ?&\\);${ws}A\\((void|)\\);$nl\}$nl$gdb_prompt $" {
250             # gcc 2.95.3 -gstabs+
251             # gcc 3.3.2 -gstabs+
252             # gcc HEAD 2003-12-28 21:08:30 UTC -gstabs+
253             pass "ptype class A"
254         }
255     }
256
257     # Derived class.
258
259     gdb_test_multiple "ptype class B" "ptype class B" {
260         -re "type = class B : public A \{${ws}public:${ws}int b;${ws}int x;$nl\}$nl$gdb_prompt $" {
261             # gcc 2.95.3 -gdwarf-2
262             # gcc 3.3.2 -gdwarf-2
263             # gcc HEAD 2003-12-28 21:08:30 UTC -gdwarf-2
264             pass "ptype class B"
265         }
266         -re "type = class B : public A \{${ws}public:${ws}int b;${ws}int x;${ws}B ?& ?operator ?=\\(B const ?&\\);${ws}B\\(B const ?&\\);${ws}B\\((void|)\\);$nl\}$nl$gdb_prompt $" {
267             # gcc 2.95.3 -gstabs+
268             # gcc 3.3.2 -gstabs+
269             # gcc HEAD 2003-12-28 21:08:30 UTC -gstabs+
270             pass "ptype class B"
271         }
272     }
273
274     # Derived class.
275
276     gdb_test_multiple "ptype class C" "ptype class C" {
277         -re "type = class C : public A \{${ws}public:${ws}int c;${ws}int x;$nl\}$nl$gdb_prompt $" {
278             # gcc 2.95.3 -gdwarf-2
279             # gcc 3.3.2 -gdwarf-2
280             # gcc HEAD 2003-12-28 21:08:30 UTC -gdwarf-2
281             pass "ptype class C"
282         }
283         -re "type = class C : public A \{${ws}public:${ws}int c;${ws}int x;${ws}C ?& ?operator ?=\\(C const ?&\\);${ws}C\\(C const ?&\\);${ws}C\\((void|)\\);$nl\}$nl$gdb_prompt $" {
284             # gcc 2.95.3 -gstabs+
285             # gcc 3.3.2 -gstabs+
286             # gcc HEAD 2003-12-28 21:08:30 UTC -gstabs+
287             pass "ptype class C"
288         }
289     }
290
291     # Derived class, multiple inheritance.
292
293     gdb_test_multiple "ptype class D" "ptype class D" {
294         -re "type = class D : public B, public C \{${ws}public:${ws}int d;${ws}int x;$nl\}$nl$gdb_prompt $" {
295             # gcc 2.95.3 -gdwarf-2
296             # gcc 3.3.2 -gdwarf-2
297             # gcc HEAD 2003-12-28 21:08:30 UTC -gdwarf-2
298             pass "ptype class D"
299         }
300         -re "type = class D : public B, public C \{${ws}public:${ws}int d;${ws}int x;${ws}D ?& ?operator ?=\\(D const ?&\\);${ws}D\\(D const ?&\\);${ws}D\\((void|)\\);$nl\}$nl$gdb_prompt $" {
301             # gcc 2.95.3 -gstabs+
302             # gcc 3.3.2 -gstabs+
303             # gcc HEAD 2003-12-28 21:08:30 UTC -gstabs+
304             pass "ptype class D"
305         }
306     }
307
308     # Derived class.
309
310     gdb_test_multiple "ptype class E" "ptype class E" {
311         -re "type = class E : public D \{${ws}public:${ws}int e;${ws}int x;$nl\}$nl$gdb_prompt $" {
312             # gcc 2.95.3 -gdwarf-2
313             # gcc 3.3.2 -gdwarf-2
314             # gcc HEAD 2003-12-28 21:08:30 UTC -gdwarf-2
315             pass "ptype class E"
316         }
317         -re "type = class E : public D \{${ws}public:${ws}int e;${ws}int x;${ws}E ?& ?operator ?=\\(E const ?&\\);${ws}E\\(E const ?&\\);${ws}E\\((void|)\\);$nl\}$nl$gdb_prompt $" {
318             # gcc 2.95.3 -gstabs+
319             # gcc 3.3.2 -gstabs+
320             # gcc HEAD 2003-12-28 21:08:30 UTC -gstabs+
321             pass "ptype class E"
322         }
323     }
324
325     # This is a break from inheritance tests.
326     #
327     # gcc 2.X with stabs (stabs or stabs+?) used to have a problem with
328     # static methods whose name is the same as their argument mangling.
329  
330     gdb_test_multiple "ptype class Static" "ptype class Static" {
331         -re "type = class Static \{${ws}public:${ws}static void ii\\(int, int\\);$nl\}$nl$gdb_prompt $" {
332             # gcc 2.95.3 -gdwarf-2
333             # gcc 3.3.2 -gdwarf-2
334             # gcc HEAD 2003-12-28 21:08:30 UTC -gdwarf-2
335             pass "ptype class Static"
336         }
337         -re "type = class Static \{${ws}public:${ws}Static ?& ?operator ?=\\(Static const ?&\\);${ws}Static\\(Static const ?&\\);${ws}Static\\((void|)\\);${ws}static void ii\\(int, int\\);$nl\}$nl$gdb_prompt $" {
338             # gcc 2.95.3 -gstabs+
339             # gcc 3.3.2 -gstabs+
340             pass "ptype class Static"
341         }
342         -re "type = class Static \{${ws}public:${ws}static void ii\\(int, int\\);${ws}Static ?& ?operator ?=\\(Static const ?&\\);${ws}Static\\(Static const ?&\\);${ws}Static\\((void|)\\);$nl\}$nl$gdb_prompt $" {
343             # gcc HEAD 2003-12-28 21:08:30 UTC -gstabs+
344             pass "ptype class Static"
345         }
346     }
347
348     # Here are some virtual inheritance tests.
349
350     gdb_test_multiple "ptype class vA" "ptype class vA" {
351         -re "type = class vA \{${ws}public:${ws}int va;${ws}int vx;$nl\}$nl$gdb_prompt $" {
352             # gcc 2.95.3 -gdwarf-2
353             # gcc 3.3.2 -gdwarf-2
354             # gcc HEAD 2003-12-28 21:08:30 UTC -gdwarf-2
355             pass "ptype class vA"
356         }
357         -re "type = class vA \{${ws}public:${ws}int va;${ws}int vx;${ws}vA ?& ?operator ?=\\(vA const ?&\\);${ws}vA\\(vA const ?&\\);${ws}vA\\((void|)\\);$nl\}$nl$gdb_prompt $" {
358             # gcc 2.95.3 -gstabs+
359             # gcc 3.3.2 -gstabs+
360             # gcc HEAD 2003-12-28 21:08:30 UTC -gstabs+
361             pass "ptype class vA"
362         }
363     }
364
365     # With gcc 2, gdb prints the virtual base pointer.
366     # With gcc 3, gdb does not print the virtual base pointer.
367     # drow considers it a gdb bug if gdb prints the vbptr.
368
369     gdb_test_multiple "ptype class vB" "ptype class vB" {
370         -re "type = class vB : public virtual vA \{${ws}private:${ws}vA ?\\* ?_vb.2vA;${ws}public:${ws}int vb;${ws}int vx;$nl\}$nl$gdb_prompt $" {
371             # gcc 2.95.3 -gdwarf-2
372             # TODO: kfail this
373             fail "ptype class vB"
374         }
375         -re "type = class vB : public virtual vA \{${ws}public:${ws}int vb;${ws}int vx;$nl\}$nl$gdb_prompt $" {
376             # gcc 3.3.2 -gdwarf-2
377             # gcc HEAD 2003-12-28 21:08:30 UTC -gdwarf-2
378             pass "ptype class vB"
379         }
380         -re "type = class vB : public virtual vA \{${ws}private:${ws}vA ?\\* ?_vb.vA;${ws}public:${ws}int vb;${ws}int vx;${ws}vB ?& ?operator ?=\\(vB const ?&\\);${ws}vB\\(int, ?vB const ?&\\);${ws}vB\\(int\\);$nl\}$nl$gdb_prompt $" {
381             # gcc 2.95.3 -gstabs+
382             # See the hidden "in-charge" ctor parameter!
383             # TODO: kfail this
384             setup_xfail "*-*-*"
385             fail "ptype class vB (FIXME: non-portable virtual table constructs)"
386         }
387         -re "type = class vB : public virtual vA \{${ws}public:${ws}int vb;${ws}int vx;${ws}vB ?& ?operator ?=\\(vB const ?&\\);${ws}vB\\(vB const ?&\\);${ws}vB\\((void|)\\);$nl\}$nl$gdb_prompt $" {
388             # gcc 3.3.2 -gstabs+
389             # gcc HEAD 2003-12-28 21:08:30 UTC -gstabs+
390             pass "ptype class vB"
391         }
392     }
393
394     # Another class with a virtual base.
395
396     gdb_test_multiple "ptype class vC" "ptype class vC" {
397         -re "type = class vC : public virtual vA \{${ws}private:${ws}vA ?\\* ?_vb.2vA;${ws}public:${ws}int vc;${ws}int vx;$nl\}$nl$gdb_prompt $" {
398             # gcc 2.95.3 -gdwarf-2
399             # TODO: kfail
400             fail "ptype class vC"
401         }
402         -re "type = class vC : public virtual vA \{${ws}public:${ws}int vc;${ws}int vx;$nl\}$nl$gdb_prompt $" {
403             # gcc 3.3.2 -gdwarf-2
404             # gcc HEAD 2003-12-28 21:08:30 UTC -gdwarf-2
405             pass "ptype class vC"
406         }
407         -re "type = class vC : public virtual vA \{${ws}private:${ws}vA ?\\* ?_vb.vA;${ws}public:${ws}int vc;${ws}int vx;${ws}vC ?& ?operator ?=\\(vC const ?&\\);${ws}vC\\(int, ?vC const ?&\\);${ws}vC\\(int\\);$nl\}$nl$gdb_prompt $" {
408             # gcc 2.95.3 -gstabs+
409             # See the hidden "in-charge" ctor parameter!
410             # TODO: kfail
411             setup_xfail "*-*-*"
412             fail "ptype class vC (FIXME: non-portable virtual table constructs)"
413         }
414         -re "type = class vC : public virtual vA \{${ws}public:${ws}int vc;${ws}int vx;${ws}vC ?& ?operator ?=\\(vC const ?&\\);${ws}vC\\(vC const ?&\\);${ws}vC\\((void|)\\);$nl\}$nl$gdb_prompt $" {
415             # gcc 3.3.2 -gstabs+
416             # gcc HEAD 2003-12-28 21:08:30 UTC -gstabs+
417             pass "ptype class vC"
418         }
419     }
420
421     # The classic diamond inheritance.
422
423     gdb_test_multiple "ptype class vD" "ptype class vD" {
424         -re "type = class vD : public virtual vB, public virtual vC \{${ws}private:${ws}vC ?\\* ?_vb.2vC;${ws}vB ?\\* ?_vb.2vB;${ws}public:${ws}int vd;${ws}int vx;$nl\}$nl$gdb_prompt $" {
425             # gcc 2.95.3 -gdwarf-2
426             # TODO: kfail
427             fail "ptype class vD"
428         }
429         -re "type = class vD : public virtual vB, public virtual vC \{${ws}public:${ws}int vd;${ws}int vx;$nl\}$nl$gdb_prompt $" {
430             # gcc 3.3.2 -gdwarf-2
431             # gcc HEAD 2003-12-28 21:08:30 UTC -gdwarf-2
432             pass "ptype class vD"
433         }
434         -re "type = class vD : public virtual vB, public virtual vC \{${ws}private:${ws}vC ?\\* ?_vb.vC;${ws}vB ?\\* ?_vb.vB;${ws}public:${ws}int vd;${ws}int vx;${ws}vD ?& ?operator ?=\\(vD const ?&\\);${ws}vD\\(int, ?vD const ?&\\);${ws}vD\\(int\\);$nl\}$nl$gdb_prompt $" {
435             # gcc 2.95.3 -gstabs+
436             # See the hidden "in-charge" ctor parameter!
437             # TODO: kfail
438             setup_xfail "*-*-*"
439             fail "ptype class vD (FIXME: non-portable virtual table constructs)"
440         }
441         -re "type = class vD : public virtual vB, public virtual vC \{${ws}public:${ws}int vd;${ws}int vx;${ws}vD ?& ?operator ?=\\(vD const ?&\\);${ws}vD\\(vD const ?&\\);${ws}vD\\((void|)\\);$nl\}$nl$gdb_prompt $" {
442             # gcc 3.3.2 -gstabs+
443             # gcc HEAD 2003-12-28 21:08:30 UTC -gstabs+
444             pass "ptype class vD"
445         }
446     }
447
448     # One more case of virtual derivation.
449
450     gdb_test_multiple "ptype class vE" "ptype class vE" {
451         -re "type = class vE : public virtual vD \{${ws}private:${ws}vD ?\\* ?_vb.2vD;${ws}public:${ws}int ve;${ws}int vx;$nl\}$nl$gdb_prompt $" {
452             # gcc 2.95.3 -gdwarf-2
453             # TODO: kfail
454             fail "ptype class vE"
455         }
456         -re "type = class vE : public virtual vD \{${ws}public:${ws}int ve;${ws}int vx;$nl\}$nl$gdb_prompt $" {
457             # gcc 3.3.2 -gdwarf-2
458             # gcc HEAD 2003-12-28 21:08:30 UTC -gdwarf-2
459             pass "ptype class vE"
460         }
461         -re "type = class vE : public virtual vD \{${ws}private:${ws}vD ?\\* ?_vb.vD;${ws}public:${ws}int ve;${ws}int vx;${ws}vE ?& ?operator ?=\\(vE const ?&\\);${ws}vE\\(int, ?vE const ?&\\);${ws}vE\\(int\\);$nl\}$nl$gdb_prompt $" {
462             # gcc 2.95.3 -gstabs+
463             # See the hidden "in-charge" ctor parameter!
464             # TODO: kfail
465             setup_xfail "*-*-*"
466             fail "ptype class vE (FIXME: non-portable virtual table constructs)"
467         }
468         -re "type = class vE : public virtual vD \{${ws}public:${ws}int ve;${ws}int vx;${ws}vE ?& ?operator ?=\\(vE const ?&\\);${ws}vE\\(vE const ?&\\);${ws}vE\\((void|)\\);$nl\}$nl$gdb_prompt $" {
469             # gcc 3.3.2 -gstabs+
470             # gcc HEAD 2003-12-28 21:08:30 UTC -gstabs+
471             pass "ptype class vE"
472         }
473     }
474
475     # Another inheritance series.
476
477     gdb_test_multiple "ptype class Base1" "ptype class Base1" {
478         -re "type = class Base1 \{${ws}public:${ws}int x;${ws}Base1\\(int\\);$nl\}$nl$gdb_prompt $" {
479             # gcc 2.95.3 -gdwarf-2
480             # gcc 3.3.2 -gdwarf-2
481             # gcc HEAD 2003-12-28 21:08:30 UTC -gdwarf-2
482             pass "ptype class Base1"
483         }
484         -re "type = class Base1 \{${ws}public:${ws}int x;${ws}Base1 ?& ?operator ?=\\(Base1 const ?&\\);${ws}Base1\\(Base1 const ?&\\);${ws}Base1\\(int\\);$nl\}$nl$gdb_prompt $" {
485             # gcc 2.95.3 -gstabs+
486             # gcc 3.3.2 -gstabs+
487             pass "ptype class Base1"
488         }
489         -re "type = class Base1 \{${ws}public:${ws}int x;${ws}Base1\\(int\\);${ws}Base1 ?& ?operator ?=\\(Base1 const ?&\\);${ws}Base1\\(Base1 const ?&\\);$nl\}$nl$gdb_prompt $" {
490             # gcc HEAD 2003-12-28 21:08:30 UTC -gstabs+
491             pass "ptype class Base1"
492         }
493     }
494
495     # The second base class.
496
497     gdb_test_multiple "ptype class Foo" "ptype class Foo" {
498         -re "type = class Foo \{${ws}public:${ws}int x;${ws}int y;${ws}static int st;${ws}Foo\\(int, int\\);${ws}int operator ?!\\((void|)\\);${ws}operator int\\((void|)\\);${ws}int times\\(int\\);$nl\}$nl$gdb_prompt $" {
499             # gcc 2.95.3 -gdwarf-2
500             # gcc 3.3.2 -gdwarf-2
501             # gcc HEAD 2003-12-28 21:08:30 UTC -gdwarf-2
502             pass "ptype class Foo"
503         }
504         -re "type = class Foo \{${ws}public:${ws}int x;${ws}int y;${ws}static int st;${ws}Foo ?& ?operator ?=\\(Foo const ?&\\);${ws}Foo\\(Foo const ?&\\);${ws}Foo\\(int, int\\);${ws}int operator ?!\\((void|)\\);${ws}int operator int\\((void|)\\);${ws}int times\\(int\\);$nl\}$nl$gdb_prompt $" {
505             # gcc 2.95.3 -gstabs+
506             # TODO: "int operator int()" is a bug
507             # kfail "gdb/1497" "ptype class Foo"
508             pass "ptype class Foo"
509         }
510         -re "type = class Foo \{${ws}public:${ws}int x;${ws}int y;${ws}static int st;${ws}Foo ?& ?operator ?=\\(Foo const ?&\\);${ws}Foo\\(Foo const ?&\\);${ws}Foo\\(int, int\\);${ws}int operator ?!\\((void|)\\);${ws}operator int\\((void|)\\);${ws}int times\\(int\\);$nl\}$nl$gdb_prompt $" {
511             # gcc 3.3.2 -gstabs+
512             pass "ptype class Foo"
513         }
514         -re "type = class Foo \{${ws}public:${ws}int x;${ws}int y;${ws}static int st;${ws}Foo\\(int, int\\);${ws}int operator ?!\\((void|)\\);${ws}operator int\\((void|)\\);${ws}int times\\(int\\);${ws}Foo ?& ?operator ?=\\(Foo const ?&\\);${ws}Foo\\(Foo const ?&\\);$nl\}$nl$gdb_prompt $" {
515             # gcc HEAD 2003-12-28 21:08:30 UTC -gstabs+
516             pass "ptype class Foo"
517         }
518     }
519
520     # A multiple inheritance derived class.
521
522     gdb_test_multiple "ptype class Bar" "ptype class Bar" {
523         -re "type = class Bar : public Base1, public Foo \{${ws}public:${ws}int z;${ws}Bar\\(int, int, int\\);$nl\}$nl$gdb_prompt $" {
524             # gcc 2.95.3 -gdwarf-2
525             # gcc 3.3.2 -gdwarf-2
526             # gcc HEAD 2003-12-28 21:08:30 UTC -gdwarf-2
527             pass "ptype class Bar"
528         }
529         -re "type = class Bar : public Base1, public Foo \{${ws}public:${ws}int z;${ws}Bar ?& ?operator ?=\\(Bar const ?&\\);${ws}Bar\\(Bar const ?&\\);${ws}Bar\\(int, int, int\\);$nl\}$nl$gdb_prompt $" {
530             # gcc 2.95.3 -gstabs+
531             # gcc 3.3.2 -gstabs+
532             pass "ptype class Bar"
533         }
534         -re "type = class Bar : public Base1, public Foo \{${ws}public:${ws}int z;${ws}Bar\\(int, int, int\\);${ws}Bar ?& ?operator ?=\\(Bar const ?&\\);${ws}Bar\\(Bar const ?&\\);$nl\}$nl$gdb_prompt $" {
535             # gcc HEAD 2003-12-28 21:08:30 UTC -gstabs+
536             pass "ptype class Bar"
537         }
538     }
539 }
540
541 # Test simple access to class members.
542 # TODO: these test names are gross!
543 # Just let the test name default.
544
545 proc test_non_inherited_member_access {} {
546     global gdb_prompt
547     
548     # Print non-inherited members of g_A.
549     gdb_test "print g_A.a" ".* = 1" "g_A.a incorrect"
550     gdb_test "print g_A.x" ".* = 2" "g_A.x incorrect"
551
552     # Print non-inherited members of g_B.
553     gdb_test "print g_B.b" ".* = 5" "g_B.b incorrect"
554     gdb_test "print g_B.x" ".* = 6" "g_B.x incorrect"
555
556     # Print non-inherited members of g_C.
557     gdb_test "print g_C.c" ".* = 9" "g_C.c incorrect"
558     gdb_test "print g_C.x" ".* = 10" "g_C.x incorrect"
559
560     # Print non-inherited members of g_D.
561     gdb_test "print g_D.d" ".* = 19" "g_D.d incorrect"
562     gdb_test "print g_D.x" ".* = 20" "g_D.x incorrect"
563
564     # Print non-inherited members of g_E.
565     gdb_test "print g_E.e" ".* = 31" "g_E.e incorrect"
566     gdb_test "print g_E.x" ".* = 32" "g_E.x incorrect"
567 }
568
569 # Test access to members of other classes.
570 # gdb should refuse to print them.
571 # (I feel old -- I remember when this was legal in C -- chastain).
572 # TODO: Again, change the silly test names.
573
574 proc test_wrong_class_members {} {
575     global gdb_prompt
576
577     gdb_test "print g_A.b" "There is no member( or method|) named b." "print g_A.b should be error"
578     gdb_test "print g_B.c" "There is no member( or method|) named c." "print g_B.c should be error"
579     gdb_test "print g_B.d" "There is no member( or method|) named d." "print g_B.d should be error"
580     gdb_test "print g_C.b" "There is no member( or method|) named b." "print g_C.b should be error"
581     gdb_test "print g_C.d" "There is no member( or method|) named d." "print g_C.d should be error"
582     gdb_test "print g_D.e" "There is no member( or method|) named e." "print g_D.e should be error"
583 }
584
585 # Test access to names that are not members of any class.
586 # TODO: test names again.
587
588 proc test_nonexistent_members {} {
589     global gdb_prompt
590
591     gdb_test "print g_A.y" "There is no member( or method|) named y." "print g_A.y should be error"
592     gdb_test "print g_B.z" "There is no member( or method|) named z." "print g_B.z should be error"
593     gdb_test "print g_C.q" "There is no member( or method|) named q." "print g_C.q should be error"
594     gdb_test "print g_D.p" "There is no member( or method|) named p." "print g_D.p should be error"
595 }
596
597 # Call a method that expects a base class parameter with base, inherited,
598 # and unrelated class arguments.
599
600 proc test_method_param_class {} {
601     gdb_test "call class_param.Aptr_a (&g_A)" ".* = 1" "base class param->a"
602     gdb_test "call class_param.Aptr_x (&g_A)" ".* = 2" "base class param->x"
603     gdb_test "call class_param.Aptr_a (&g_B)" ".* = 3" "inherited class param->a"
604     gdb_test "call class_param.Aptr_x (&g_B)" ".* = 4" "inherited class param->x"
605     gdb_test "call class_param.Aref_a (g_A)" ".* = 1" "base class (&param)->a"
606     gdb_test "call class_param.Aref_x (g_A)" ".* = 2" "base class (&param)->x"
607     gdb_test "call class_param.Aref_a (g_B)" ".* = 3" "inherited class (&param)->a"
608     gdb_test "call class_param.Aref_x (g_B)" ".* = 4" "inherited class (&param)->x"
609     gdb_test "call class_param.Aval_a (g_A)" ".* = 1" "base class param.a"
610     gdb_test "call class_param.Aval_x (g_A)" ".* = 2" "base class param.x"
611     gdb_test "call class_param.Aval_a (g_B)" ".* = 3" "inherited class param.a"
612     gdb_test "call class_param.Aval_x (g_B)" ".* = 4" "inherited class param.x"
613
614     gdb_test "call class_param.Aptr_a (&foo)" "Cannot resolve .*" "unrelated class *param"
615     gdb_test "call class_param.Aref_a (foo)" "Cannot resolve .*" "unrelated class &param"
616     gdb_test "call class_param.Aval_a (foo)" "Cannot resolve .*" "unrelated class param"
617 }
618
619 # Examine a class with an enum field.
620
621 proc test_enums {} {
622     global gdb_prompt
623     global nl
624     global ws
625
626     # print the object
627
628     gdb_test "print obj_with_enum" \
629         "\\$\[0-9\]+ = \{priv_enum = red, x = 0\}" \
630         "print obj_with_enum (1)"
631
632     # advance one line
633
634     gdb_test "next" ""
635
636     # TODO: with gcc HEAD 2003-12-28 21:08:30 UTC -gdwarf-2,
637     # gdb says that obj_with_enum is out of scope here and the
638     # tests after this FAIL.  This needs investigation.
639     # -- chastain 2003-12-30
640
641     # print the object again
642
643     gdb_test "print obj_with_enum" \
644         "\\$\[0-9\]+ = \{priv_enum = green, x = 0\}" \
645         "print obj_with_enum (2)"
646
647     # print the enum member
648
649     gdb_test "print obj_with_enum.priv_enum" "\\$\[0-9\]+ = green"
650
651     # ptype on the enum member
652
653     gdb_test_multiple "ptype obj_with_enum.priv_enum" "ptype obj_with_enum.priv_enum" {
654         -re "type = enum ClassWithEnum::PrivEnum \{ ?red, green, blue, yellow = 42 ?\}$nl$gdb_prompt $" {
655             pass "ptype obj_with_enum.priv_enum"
656         }
657         -re "type = enum PrivEnum \{ ?red, green, blue, yellow = 42 ?\}$nl$gdb_prompt $" {
658             # gcc 2.95.3 -gdwarf-2
659             # gcc 3.3.2 -gdwarf-2
660             pass "ptype obj_with_enum.priv_enum"
661         }
662         -re "type = enum \{ ?red, green, blue, yellow = 42 ?\}$nl$gdb_prompt $" {
663             # This case case is a little dubious, but it's not clear what
664             # ought to be required of a ptype on a private enum...
665             # -sts 19990324
666             #
667             # It bugs me that this happens with gcc 3.
668             # -- chastain 2003-12-30
669             #
670             # gcc 2.95.3 -gstabs+
671             # gcc 3.3.2 -gstabs+
672             # gcc HEAD 2003-12-28 21:08:30 UTC -gstabs+
673             pass "ptype obj_with_enum.priv_enum"
674         }
675     }
676
677     # ptype on the object
678     gdb_test_multiple "ptype obj_with_enum" "ptype obj_with_enum" {
679         -re "type = class ClassWithEnum \{${ws}public:${ws}(enum |)ClassWithEnum::PrivEnum priv_enum;${ws}int x;$nl\}$nl$gdb_prompt $" {
680             pass "ptype obj_with_enum"
681         }
682         -re "type = class ClassWithEnum \{${ws}public:${ws}(enum |)PrivEnum priv_enum;${ws}int x;$nl\}$nl$gdb_prompt $" {
683             # NOTE: carlton/2003-02-28: One could certainly argue that
684             # this output is acceptable: PrivEnum is a member of
685             # ClassWithEnum, so there's no need to explicitly qualify
686             # its name with "ClassWithEnum::".  The truth, though, is
687             # that GDB is simply forgetting that PrivEnum is a member
688             # of ClassWithEnum, so we do that output for a bad reason
689             # instead of a good reason.  Under stabs, we probably
690             # can't get this right; under DWARF-2, we can.
691             #
692             # gcc 2.95.3 -gdwarf-2
693             # gcc 3.3.2 -gdwarf-2
694             kfail "gdb/57" "ptype obj_with_enum"
695         }
696         -re "type = class ClassWithEnum \{${ws}public:${ws}(enum |)PrivEnum priv_enum;${ws}int x;${ws}ClassWithEnum ?& ?operator ?=\\(ClassWithEnum const ?&\\);${ws}ClassWithEnum\\(ClassWithEnum const ?&\\);${ws}ClassWithEnum\\((void|)\\);$nl\}$nl$gdb_prompt $" {
697             # gcc 2.95.3 -gstabs+
698             kfail "gdb/57" "ptype obj_with_enum"
699         }
700         -re "type = class ClassWithEnum \{${ws}public:${ws}(enum |)ClassWithEnum::PrivEnum priv_enum;${ws}int x;${ws}ClassWithEnum ?& ?operator ?=\\(ClassWithEnum const ?&\\);${ws}ClassWithEnum\\(ClassWithEnum const ?&\\);${ws}ClassWithEnum\\((void|)\\);$nl\}$nl$gdb_prompt $" {
701             # I think this is a PASS, but only carlton knows for sure.
702             # -- chastain 2003-12-30
703             #
704             # gcc 3.3.2 -gstabs+
705             # gcc HEAD 2003-12-28 21:08:30 UTC -gstabs+
706             fail "ptype obj_with_enum"
707         }
708     }
709
710     # I'll do this test two different ways, because of a parser bug.
711     # See PR gdb/826.
712
713     gdb_test_multiple "print (ClassWithEnum::PrivEnum) 42" "print (ClassWithEnum::PrivEnum) 42" {
714         -re "\\$\[0-9\]+ = yellow$nl$gdb_prompt $" {
715             pass "print (ClassWithEnum::PrivEnum) 42"
716         }
717         -re "A (parse|syntax) error in expression, near `42'.$nl$gdb_prompt $" {
718             # "parse error" is bison 1.35.
719             # "syntax error" is bison 1.875.
720             kfail "gdb/826" "print (ClassWithEnum::PrivEnum) 42"
721         }
722     }
723
724     gdb_test_multiple "print ('ClassWithEnum::PrivEnum') 42" "print ('ClassWithEnum::PrivEnum') 42" {
725         -re "\\$\[0-9\]+ = yellow$nl$gdb_prompt $" {
726             # gcc 3.3.2 -gstabs+
727             # gcc HEAD 2003-12-28 21:08:30 UTC -gstabs+
728             pass "print ('ClassWithEnum::PrivEnum') 42"
729         }
730         -re "No symbol \"ClassWithEnum::PrivEnum\" in current context.$nl$gdb_prompt $" {
731             # gcc 2.95.3 -gdwarf-2
732             # gcc 3.3.2 -gdwarf-2
733             # gcc HEAD 2003-12-28 21:08:30 UTC -gdwarf-2
734             # gcc 2.95.3 -gstabs+
735             kfail "gdb/57" "print ('ClassWithEnum::PrivEnum') 42"
736         }
737     }
738 }
739
740 # Pointers to class members
741
742 proc test_pointers_to_class_members {} {
743     global gdb_prompt
744
745     gdb_test "print Bar::z" "\\$\[0-9\]+ = \\(int ?\\( ?Bar::& ?\\) ?\\) ?Bar::z"
746     gdb_test "print &Foo::x" "\\$\[0-9\]+ = \\(int ?\\( ?Foo::\\* ?\\) ?\\) ?&Foo::x"
747     gdb_test "print (int)&Foo::x" "\\$\[0-9\]+ = 0"
748     gdb_test "print (int)&Bar::y == 2*sizeof(int)" "\\$\[0-9\]+ = true"
749
750     # TODO: this is a bogus test.  It's looking at a variable that
751     # has not even been declared yet, so it's accessing random junk
752     # on the stack and comparing that it's NOT equal to a specific
753     # value.  It's been like this since gdb 4.10 in 1993!
754     # -- chastain 2004-01-01
755     gdb_test "print (int)pmi == sizeof(int)" ".* = false"
756 }
757
758 # Test static members.
759
760 proc test_static_members {} {
761     global gdb_prompt
762     global hex
763
764     gdb_test "print Foo::st" "\\$\[0-9\]+ = 100"
765     gdb_test "set foo.st = 200" "" ""
766     gdb_test "print bar.st" "\\$\[0-9\]+ = 200"
767     gdb_test "print &foo.st" "\\$\[0-9\]+ = \\(int ?\\*\\) $hex"
768     gdb_test "print &Bar::st" "\\$\[0-9\]+ = \\(int ?\\*\\) $hex"
769     gdb_test "print *\$" "\\$\[0-9\]+ = 200"
770
771     gdb_test "set print static-members off" ""
772     gdb_test "print csi" \
773         "{x = 10, y = 20}" \
774         "print csi without static members"
775     gdb_test "print cnsi" \
776         "{x = 30, y = 40}" \
777         "print cnsi without static members"
778
779     gdb_test "set print static-members on" ""
780     gdb_test "print csi" \
781         "{x = 10, y = 20, static null = {x = 0, y = 0, static null = <same as static member of an already seen type>}}" \
782         "print csi with static members"
783     gdb_test "print cnsi" \
784         "{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>}" \
785         "print cnsi with static members"
786 }
787
788 proc do_tests {} {
789     global prms_id
790     global bug_id
791     global subdir
792     global objdir
793     global srcdir
794     global binfile
795     global gdb_prompt
796     global nl
797
798     set prms_id 0
799     set bug_id 0
800
801     # Start with a fresh gdb.
802
803     gdb_exit
804     gdb_start
805     gdb_reinitialize_dir $srcdir/$subdir
806     gdb_load $binfile
807
808     gdb_test "set language c++" "" ""
809     gdb_test "set width 0" "" ""
810
811     if ![runto_main ] then {
812         perror "couldn't run to breakpoint"
813         return
814     }
815
816     gdb_breakpoint inheritance2
817     gdb_test "continue" ".*Breakpoint .* inheritance2.*" ""
818
819     test_ptype_class_objects
820     test_non_inherited_member_access
821     test_wrong_class_members
822     test_nonexistent_members
823     test_method_param_class
824
825     gdb_breakpoint enums2
826     gdb_test "continue" ".*Breakpoint .* enums2.*" "continue to enums2(\\(\\)|)"
827     gdb_test "finish" "" ""
828     test_enums
829
830     gdb_test "finish" "" ""
831     test_pointers_to_class_members
832     test_static_members
833
834     # Now some random tests that were just thrown in here.
835
836     gdb_breakpoint marker_reg1
837     gdb_test "continue" ".*Breakpoint .* marker_reg1.*" ""
838     gdb_test "finish" "Run till exit from.*" "finish from marker_reg1"
839
840     # This class is so small that an instance of it can fit in a register.
841     # When gdb tries to call a method, it gets embarrassed about taking
842     # the address of a register.
843     #
844     # TODO: I think that message should be a PASS, not an XFAIL.
845     # gdb prints an informative message and declines to do something
846     # impossible.
847     #
848     # The method call actually succeeds if the compiler allocates very
849     # small classes in memory instead of registers.  So this test does
850     # not tell us anything interesting if the call succeeds.
851     #
852     # -- chastain 2003-12-31
853     gdb_test_multiple "print v.method ()" "calling method for small class" {
854         -re "\\$\[0-9\]+ = 82$nl$gdb_prompt $" {
855             # gcc 3.3.2 -gdwarf-2
856             # gcc HEAD 2003-12-28 21:08:30 UTC -gdwarf-2
857             # gcc 3.3.2 -gstabs+
858             # gcc HEAD 2003-12-28 21:08:30 UTC -gstabs+
859             pass "calling method for small class"
860         }
861         -re "Address requested for identifier \"v\" which is in register .*$nl$gdb_prompt $" {
862             # gcc 2.95.3 -gdwarf-2
863             # gcc 2.95.3 -gstabs+
864             setup_xfail "*-*-*" 2972
865             fail "calling method for small class"
866         }
867     }
868
869     # This is a random v2 demangling test.
870     # This is redundant with existing tests in demangle.exp.
871     # TODO: Just remove this.
872     gdb_test "maint demangle inheritance1__Fv" "inheritance1\\(void\\)" "demangle"
873 }
874
875 do_tests