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