Commit | Line | Data |
---|---|---|
116f09e7 | 1 | # Copyright 1992, 1994, 1995, 1996, 1997, 1998, 1999, 2001, 2002, 2003, 2004 |
b6ba6518 | 2 | # 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) |
51615d72 | 19 | # And rewritten by Michael Chastain <mec.gnu@mindspring.com>. |
c906108c | 20 | |
184ad485 MC |
21 | set wsopt "\[\r\n\t \]*" |
22 | set ws "\[\r\n\t \]+" | |
23 | set nl "\[\r\n\]+" | |
c906108c SS |
24 | |
25 | if $tracelevel then { | |
51615d72 | 26 | strace $tracelevel |
c906108c SS |
27 | } |
28 | ||
d4f3574e SS |
29 | if { [skip_cplus_tests] } { continue } |
30 | ||
c906108c SS |
31 | set testfile "virtfunc" |
32 | set srcfile ${testfile}.cc | |
33 | set binfile ${objdir}/${subdir}/${testfile} | |
34 | ||
f2dd3617 | 35 | if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {c++ debug}] != "" } { |
c906108c SS |
36 | gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." |
37 | } | |
38 | ||
184ad485 | 39 | # Test ptype of a class. |
51615d72 MC |
40 | # |
41 | # Different C++ compilers produce different output. I build up regular | |
42 | # expressions piece by piece to accommodate all the compilers that I | |
43 | # have seen: gcc 2.95.3, gcc 3.3.2 (ABI 1), gcc 3.4 prerelease (ABI 2); | |
44 | # and all the debug formats I have seen: dwarf-2 and stabs+. | |
45 | # | |
46 | # A complicated class declaration looks like this: | |
47 | # | |
48 | # class A : public virtual V { // re_class | |
49 | # private: | |
50 | # V * _vb$V; // re_vbptr | |
51 | # int a; // re_fields | |
52 | # | |
184ad485 | 53 | # public: // re_access_methods |
51615d72 MC |
54 | # A & operator=(A const &); // re_synth_gcc_2 |
55 | # A(int, A const &); // ... | |
56 | # A(int); // ... | |
57 | # virtual int f(void); // re_methods | |
58 | # } | |
59 | # | |
60 | # RE_CLASS matches the class declaration. C++ allows multiple ways of | |
61 | # expressing this. | |
62 | # | |
63 | # struct ... { private: ... }; | |
64 | # class ... { private: ... }; | |
65 | # class ... { ... }; | |
66 | # | |
184ad485 MC |
67 | # RE_VBPTR matches the virtual base declarations. gcc 2.95.3 sometimes |
68 | # emits these, but gcc 3.X.Y never emits these. The name depends on the | |
69 | # debug format. | |
c906108c | 70 | # |
51615d72 MC |
71 | # RE_FIELDS matches the data fields of the class. |
72 | # RE_METHODS matches the methods explicitly declared for the class. | |
c906108c | 73 | # |
51615d72 MC |
74 | # RE_SYNTH_GCC_2 and RE_SYNTH_GCC_3 match the optional synthetic methods |
75 | # of the class. gcc -gstabs+ emits these methods, and gcc -gdwarf-2 | |
76 | # does not. | |
77 | # | |
184ad485 MC |
78 | # RE_ACCESS_METHODS is an access specifier after RE_FIELDS and before |
79 | # the methods (explicit methods and/or synthetic methods). | |
80 | # There is also an RE_ACCESS_FIELDS. | |
51615d72 | 81 | # |
184ad485 | 82 | # When I get HP-UX aCC, I hope that I can just add RE_SYNTH_ACC_NNN. |
51615d72 MC |
83 | # |
84 | # Yet another twist: with gcc v2, ctor and dtor methods have a hidden | |
85 | # argument in front, the "in-charge" flag. With gcc v3, there is no | |
86 | # hidden argument; instead, there are multiple object functions for | |
87 | # each ctor and dtor. | |
88 | # | |
184ad485 MC |
89 | # -- chastain 2004-01-01 |
90 | ||
184ad485 | 91 | proc test_one_ptype { command testname re_class re_vbptr re_access_fields re_fields re_access_methods re_methods re_synth_gcc_2 re_synth_gcc_3 re_star } { |
c906108c | 92 | global gdb_prompt |
184ad485 | 93 | global wsopt |
c906108c SS |
94 | global ws |
95 | global nl | |
96 | ||
184ad485 MC |
97 | gdb_test_multiple "$command" "$testname" { |
98 | -re "type = $re_class${wsopt}$re_access_fields${wsopt}$re_fields${wsopt}$re_access_methods${wsopt}$re_methods$nl\}$re_star$nl$gdb_prompt $" { | |
99 | # gcc 2.95.3, dwarf-2, no vbptr | |
100 | # gcc 3.X, abi 1, dwarf-2 | |
101 | # gcc 3.X, abi 2, dwarf-2 | |
1ff8cadf | 102 | pass "$testname" |
184ad485 MC |
103 | } |
104 | -re "type = $re_class${wsopt}$re_vbptr${wsopt}$re_access_fields${wsopt}$re_fields${wsopt}$re_access_methods${wsopt}$re_methods$nl\}$re_star$nl$gdb_prompt $" { | |
105 | # gcc 2.95.3, dwarf-2, vbptr | |
106 | # TODO: drow says the vbptr is a bug | |
1ff8cadf | 107 | pass "$testname" |
184ad485 MC |
108 | } |
109 | -re "type = $re_class${wsopt}$re_access_fields${wsopt}$re_fields${wsopt}$re_access_methods${wsopt}$re_synth_gcc_2${wsopt}$re_methods$nl\}$re_star$nl$gdb_prompt $" { | |
110 | # gcc 2.95.3, stabs+, no vbptr | |
1ff8cadf | 111 | pass "$testname" |
184ad485 MC |
112 | } |
113 | -re "type = $re_class${wsopt}$re_vbptr${wsopt}$re_access_fields${wsopt}$re_fields${wsopt}$re_access_methods${wsopt}$re_synth_gcc_2${wsopt}$re_methods$nl\}$re_star$nl$gdb_prompt $" { | |
114 | # gcc 2.95.3, stabs+, vbptr | |
115 | # TODO: drow says the vbptr is a bug | |
1ff8cadf | 116 | pass "$testname" |
184ad485 MC |
117 | } |
118 | -re "type = $re_class${wsopt}$re_access_fields${wsopt}$re_fields${wsopt}$re_access_methods${wsopt}$re_synth_gcc_3${wsopt}$re_methods$nl\}$re_star$nl$gdb_prompt $" { | |
119 | # gcc 3.X, abi 1, stabs+ | |
1ff8cadf | 120 | pass "$testname" |
184ad485 MC |
121 | } |
122 | -re "type = $re_class${wsopt}$re_access_fields${wsopt}$re_fields${wsopt}$re_access_methods${wsopt}$re_methods${wsopt}$re_synth_gcc_3$nl\}$re_star$nl$gdb_prompt $" { | |
123 | # gcc 3.X, abi 2, stabs+ | |
1ff8cadf | 124 | pass "$testname" |
c906108c | 125 | } |
c906108c SS |
126 | } |
127 | ||
184ad485 | 128 | } |
51615d72 | 129 | |
184ad485 MC |
130 | proc test_ptype_of_classes {} { |
131 | global gdb_prompt | |
132 | global ws | |
133 | global nl | |
51615d72 | 134 | |
184ad485 | 135 | # class VA |
51615d72 | 136 | |
184ad485 MC |
137 | test_one_ptype "ptype VA" "ptype VA" \ |
138 | "((struct|class) VA \{${ws}public:|struct VA \{)" \ | |
139 | "" \ | |
140 | "" "int va;" \ | |
141 | "" "" \ | |
142 | "VA & operator=\\(VA const ?&\\);${ws}VA\\(VA const ?&\\);${ws}VA\\((void|)\\);" \ | |
a7995a30 | 143 | "(VA & operator=\\(VA const ?&\\);${ws}|)VA\\(VA const ?&\\);${ws}VA\\((void|)\\);" \ |
184ad485 | 144 | "" |
c906108c | 145 | |
184ad485 | 146 | # class VB |
c2d11a7d | 147 | |
184ad485 MC |
148 | test_one_ptype "ptype VB" "ptype VB" \ |
149 | "((struct|class) VB \{${ws}public:|struct VB \{)" \ | |
150 | "" \ | |
151 | "" "int vb;" \ | |
152 | "" "int fvb\\((void|)\\);${ws}virtual int vvb\\((void|)\\);" \ | |
153 | "VB & operator=\\(VB const ?&\\);${ws}VB\\(VB const ?&\\);${ws}VB\\((void|)\\);" \ | |
a7995a30 | 154 | "(VB & operator=\\(VB const ?&\\);${ws}|)VB\\(VB const ?&\\);${ws}VB\\((void|)\\);" \ |
184ad485 | 155 | "" |
c906108c | 156 | |
51615d72 | 157 | # class V |
c906108c | 158 | |
184ad485 MC |
159 | test_one_ptype "ptype V" "ptype V" \ |
160 | "class V : public VA, public VB \{${ws}public:" \ | |
161 | "" \ | |
162 | "" "int w;" \ | |
163 | "" "int f\\((void|)\\);${ws}virtual int vv\\((void|)\\);" \ | |
164 | "V & operator=\\(V const ?&\\);${ws}V\\(V const ?&\\);${ws}V\\((void|)\\);" \ | |
a7995a30 | 165 | "(V & operator=\\(V const ?&\\);${ws}|)V\\(V const ?&\\);${ws}V\\((void|)\\);" \ |
184ad485 | 166 | "" |
c906108c | 167 | |
184ad485 | 168 | # class A |
c906108c | 169 | |
184ad485 MC |
170 | test_one_ptype "ptype A" "ptype A" \ |
171 | "class A : public virtual V \{(${ws}private:|)" \ | |
172 | "V \\*(_vb.1V|_vb.V);" \ | |
173 | "" "int a;" \ | |
174 | "public:" "virtual int f\\((void|)\\);" \ | |
175 | "A & operator=\\(A const ?&\\);${ws}A\\(int, A const ?&\\);${ws}A\\(int\\);" \ | |
a7995a30 | 176 | "(A & operator=\\(A const ?&\\);${ws}|)A\\(A const ?&\\);${ws}A\\((void|)\\);" \ |
184ad485 | 177 | "" |
c906108c | 178 | |
184ad485 | 179 | # class B |
c906108c | 180 | |
184ad485 MC |
181 | test_one_ptype "ptype B" "ptype B" \ |
182 | "class B : public A \{(${ws}private:|)" \ | |
183 | "V \\*(_vb.1V|_vb.V);" \ | |
184 | "" "int b;" \ | |
185 | "public:" "virtual int f\\((void|)\\);" \ | |
186 | "B & operator=\\(B const ?&\\);${ws}B\\(int, B const ?&\\);${ws}B\\(int\\);" \ | |
a7995a30 | 187 | "(B & operator=\\(B const ?&\\);${ws}|)B\\(B const ?&\\);${ws}B\\((void|)\\);" \ |
184ad485 | 188 | "" |
c906108c | 189 | |
184ad485 | 190 | # class C |
c906108c | 191 | |
184ad485 MC |
192 | test_one_ptype "ptype C" "ptype C" \ |
193 | "class C : public virtual V \{(${ws}private:|)" \ | |
194 | "V \\*(_vb.1V|_vb.V);" \ | |
195 | "public:" "int c;" \ | |
196 | "" "" \ | |
197 | "C & operator=\\(C const ?&\\);${ws}C\\(int, C const ?&\\);${ws}C\\(int\\);" \ | |
a7995a30 | 198 | "(C & operator=\\(C const ?&\\);${ws}|)C\\(C const ?&\\);${ws}C\\((void|)\\);" \ |
184ad485 | 199 | "" |
c906108c | 200 | |
184ad485 | 201 | # class AD |
c906108c | 202 | |
184ad485 MC |
203 | test_one_ptype "ptype AD" "ptype AD" \ |
204 | "((struct|class) AD \{${ws}public:|struct AD \{)" \ | |
205 | "" \ | |
206 | "" "" \ | |
207 | "" "virtual int vg\\((void|)\\);" \ | |
208 | "AD & operator=\\(AD const ?&\\);${ws}AD\\(AD const ?&\\);${ws}AD\\((void|)\\);" \ | |
a7995a30 | 209 | "(AD & operator=\\(AD const ?&\\);${ws}|)AD\\(AD const ?&\\);${ws}AD\\((void|)\\);" \ |
184ad485 | 210 | "" |
c906108c | 211 | |
184ad485 | 212 | # class D |
c906108c | 213 | |
184ad485 MC |
214 | test_one_ptype "ptype D" "ptype D" \ |
215 | "class D : public AD, public virtual V \{(${ws}private:|)" \ | |
216 | "V \\*(_vb.1V|_vb.V);" \ | |
217 | "public:" "int d;" \ | |
218 | "" "static void s\\((void|)\\);${ws}virtual int vg\\((void|)\\);${ws}virtual int vd\\((void|)\\);${ws}int fd\\((void|)\\);" \ | |
219 | "D & operator=\\(D const ?&\\);${ws}D\\(int, D const ?&\\);${ws}D\\(int\\);" \ | |
a7995a30 | 220 | "(D & operator=\\(D const ?&\\);${ws}|)D\\(D const ?&\\);${ws}D\\((void|)\\);" \ |
184ad485 | 221 | "" |
c906108c | 222 | |
184ad485 MC |
223 | # class E |
224 | # TODO: E does not show a vbptr for V. That seems strange. | |
51615d72 | 225 | |
184ad485 MC |
226 | test_one_ptype "ptype E" "ptype E" \ |
227 | "class E : public B, public virtual V, public D, public C \{(${ws}private:|)" \ | |
228 | "" \ | |
229 | "public:" "int e;" \ | |
230 | "" "virtual int f\\((void|)\\);${ws}virtual int vg\\((void|)\\);${ws}virtual int vv\\((void|)\\);" \ | |
231 | "E & operator=\\(E const ?&\\);${ws}E\\(int, E const ?&\\);${ws}E\\(int\\);" \ | |
a7995a30 | 232 | "(E & operator=\\(E const ?&\\);${ws}|)E\\(E const ?&\\);${ws}E\\((void|)\\);" \ |
184ad485 | 233 | "" |
c906108c | 234 | |
184ad485 | 235 | # An instance of D |
51615d72 | 236 | |
184ad485 MC |
237 | test_one_ptype "ptype dd" "ptype dd" \ |
238 | "class D : public AD, public virtual V \{(${ws}private:|)" \ | |
239 | "V \\*(_vb.1V|_vb.V);" \ | |
240 | "public:" "int d;" \ | |
241 | "" "static void s\\((void|)\\);${ws}virtual int vg\\((void|)\\);${ws}virtual int vd\\((void|)\\);${ws}int fd\\((void|)\\);" \ | |
242 | "D & operator=\\(D const ?&\\);${ws}D\\(int, D const ?&\\);${ws}D\\(int\\);" \ | |
a7995a30 | 243 | "(D & operator=\\(D const ?&\\);${ws}|)D\\(D const ?&\\);${ws}D\\((void|)\\);" \ |
184ad485 | 244 | "" |
c906108c | 245 | |
184ad485 | 246 | # An instance of D * |
51615d72 | 247 | |
184ad485 MC |
248 | test_one_ptype "ptype ppd" "ptype ppd" \ |
249 | "class D : public AD, public virtual V \{(${ws}private:|)" \ | |
250 | "V \\*(_vb.1V|_vb.V);" \ | |
251 | "public:" "int d;" \ | |
252 | "" "static void s\\((void|)\\);${ws}virtual int vg\\((void|)\\);${ws}virtual int vd\\((void|)\\);${ws}int fd\\((void|)\\);" \ | |
253 | "D & operator=\\(D const ?&\\);${ws}D\\(int, D const ?&\\);${ws}D\\(int\\);" \ | |
a7995a30 | 254 | "(D & operator=\\(D const ?&\\);${ws}|)D\\(D const ?&\\);${ws}D\\((void|)\\);" \ |
184ad485 | 255 | " ?\\*" |
c906108c | 256 | |
184ad485 MC |
257 | # An instance of AD * |
258 | # TODO: this should be named pADd, not pAd. | |
51615d72 | 259 | |
184ad485 MC |
260 | test_one_ptype "ptype pAd" "ptype pAd" \ |
261 | "((struct|class) AD \{${ws}public:|struct AD \{)" \ | |
262 | "" \ | |
263 | "" "" \ | |
264 | "" "virtual int vg\\((void|)\\);" \ | |
265 | "AD & operator=\\(AD const ?&\\);${ws}AD\\(AD const ?&\\);${ws}AD\\((void|)\\);" \ | |
a7995a30 | 266 | "(AD & operator=\\(AD const ?&\\);${ws}|)AD\\(AD const ?&\\);${ws}AD\\((void|)\\);" \ |
184ad485 | 267 | " ?\\*" |
c906108c | 268 | |
184ad485 | 269 | # An instance of A |
c906108c | 270 | |
184ad485 MC |
271 | test_one_ptype "ptype a" "ptype a" \ |
272 | "class A : public virtual V \{(${ws}private:|)" \ | |
273 | "V \\*(_vb.1V|_vb.V);" \ | |
274 | "" "int a;" \ | |
275 | "public:" "virtual int f\\((void|)\\);" \ | |
276 | "A & operator=\\(A const ?&\\);${ws}A\\(int, A const ?&\\);${ws}A\\(int\\);" \ | |
a7995a30 | 277 | "(A & operator=\\(A const ?&\\);${ws}|)A\\(A const ?&\\);${ws}A\\((void|)\\);" \ |
184ad485 | 278 | "" |
c906108c | 279 | |
51615d72 MC |
280 | # An instance of B |
281 | ||
184ad485 MC |
282 | test_one_ptype "ptype b" "ptype b" \ |
283 | "class B : public A \{(${ws}private:|)" \ | |
284 | "V \\*(_vb.1V|_vb.V);" \ | |
285 | "" "int b;" \ | |
286 | "public:" "virtual int f\\((void|)\\);" \ | |
287 | "B & operator=\\(B const ?&\\);${ws}B\\(int, B const ?&\\);${ws}B\\(int\\);" \ | |
a7995a30 | 288 | "(B & operator=\\(B const ?&\\);${ws}|)B\\(B const ?&\\);${ws}B\\((void|)\\);" \ |
184ad485 | 289 | "" |
c906108c | 290 | |
184ad485 | 291 | # An instance of C |
51615d72 | 292 | |
184ad485 MC |
293 | test_one_ptype "ptype c" "ptype c" \ |
294 | "class C : public virtual V \{(${ws}private:|)" \ | |
295 | "V \\*(_vb.1V|_vb.V);" \ | |
296 | "public:" "int c;" \ | |
297 | "" "" \ | |
298 | "C & operator=\\(C const ?&\\);${ws}C\\(int, C const ?&\\);${ws}C\\(int\\);" \ | |
a7995a30 | 299 | "(C & operator=\\(C const ?&\\);${ws}|)C\\(C const ?&\\);${ws}C\\((void|)\\);" \ |
184ad485 | 300 | "" |
c906108c | 301 | |
184ad485 | 302 | # An instance of D |
51615d72 | 303 | |
184ad485 MC |
304 | test_one_ptype "ptype d" "ptype d" \ |
305 | "class D : public AD, public virtual V \{(${ws}private:|)" \ | |
306 | "V \\*(_vb.1V|_vb.V);" \ | |
307 | "public:" "int d;" \ | |
308 | "" "static void s\\((void|)\\);${ws}virtual int vg\\((void|)\\);${ws}virtual int vd\\((void|)\\);${ws}int fd\\((void|)\\);" \ | |
309 | "D & operator=\\(D const ?&\\);${ws}D\\(int, D const ?&\\);${ws}D\\(int\\);" \ | |
a7995a30 | 310 | "(D & operator=\\(D const ?&\\);${ws}|)D\\(D const ?&\\);${ws}D\\((void|)\\);" \ |
184ad485 | 311 | "" |
51615d72 | 312 | |
184ad485 | 313 | # An instance of E |
c906108c | 314 | |
184ad485 MC |
315 | test_one_ptype "ptype e" "ptype e" \ |
316 | "class E : public B, public virtual V, public D, public C \{(${ws}private:|)" \ | |
317 | "" \ | |
318 | "public:" "int e;" \ | |
319 | "" "virtual int f\\((void|)\\);${ws}virtual int vg\\((void|)\\);${ws}virtual int vv\\((void|)\\);" \ | |
320 | "E & operator=\\(E const ?&\\);${ws}E\\(int, E const ?&\\);${ws}E\\(int\\);" \ | |
a7995a30 | 321 | "(E & operator=\\(E const ?&\\);${ws}|)E\\(E const ?&\\);${ws}E\\((void|)\\);" \ |
184ad485 | 322 | "" |
51615d72 | 323 | |
184ad485 | 324 | # An instance of V |
51615d72 | 325 | |
184ad485 MC |
326 | test_one_ptype "ptype v" "ptype v" \ |
327 | "class V : public VA, public VB \{${ws}public:" \ | |
328 | "" \ | |
329 | "" "int w;" \ | |
330 | "" "int f\\((void|)\\);${ws}virtual int vv\\((void|)\\);" \ | |
331 | "V & operator=\\(V const ?&\\);${ws}V\\(V const ?&\\);${ws}V\\((void|)\\);" \ | |
a7995a30 | 332 | "(V & operator=\\(V const ?&\\);${ws}|)V\\(V const ?&\\);${ws}V\\((void|)\\);" \ |
184ad485 | 333 | "" |
51615d72 | 334 | |
184ad485 | 335 | # An instance of VB |
c906108c | 336 | |
184ad485 MC |
337 | test_one_ptype "ptype vb" "ptype vb" \ |
338 | "((struct|class) VB \{${ws}public:|struct VB \{)" \ | |
339 | "" \ | |
340 | "" "int vb;" \ | |
341 | "" "int fvb\\((void|)\\);${ws}virtual int vvb\\((void|)\\);" \ | |
342 | "VB & operator=\\(VB const ?&\\);${ws}VB\\(VB const ?&\\);${ws}VB\\((void|)\\);" \ | |
a7995a30 | 343 | "(VB & operator=\\(VB const ?&\\);${ws}|)VB\\(VB const ?&\\);${ws}VB\\((void|)\\);" \ |
184ad485 | 344 | "" |
51615d72 | 345 | |
184ad485 | 346 | # An instance of A * |
c906108c | 347 | |
184ad485 MC |
348 | test_one_ptype "ptype pAa" "ptype pAa" \ |
349 | "class A : public virtual V \{(${ws}private:|)" \ | |
350 | "V \\*(_vb.1V|_vb.V);" \ | |
351 | "" "int a;" \ | |
352 | "public:" "virtual int f\\((void|)\\);" \ | |
353 | "A & operator=\\(A const ?&\\);${ws}A\\(int, A const ?&\\);${ws}A\\(int\\);" \ | |
a7995a30 | 354 | "(A & operator=\\(A const ?&\\);${ws}|)A\\(A const ?&\\);${ws}A\\((void|)\\);" \ |
184ad485 | 355 | " ?\\*" |
51615d72 | 356 | |
184ad485 | 357 | # An instance of A * |
c906108c | 358 | |
184ad485 MC |
359 | test_one_ptype "ptype pAe" "ptype pAe" \ |
360 | "class A : public virtual V \{(${ws}private:|)" \ | |
361 | "V \\*(_vb.1V|_vb.V);" \ | |
362 | "" "int a;" \ | |
363 | "public:" "virtual int f\\((void|)\\);" \ | |
364 | "A & operator=\\(A const ?&\\);${ws}A\\(int, A const ?&\\);${ws}A\\(int\\);" \ | |
a7995a30 | 365 | "(A & operator=\\(A const ?&\\);${ws}|)A\\(A const ?&\\);${ws}A\\((void|)\\);" \ |
184ad485 | 366 | " ?\\*" |
c906108c | 367 | |
184ad485 | 368 | # An instance of B * |
c906108c | 369 | |
184ad485 MC |
370 | test_one_ptype "ptype pBe" "ptype pBe" \ |
371 | "class B : public A \{(${ws}private:|)" \ | |
372 | "V \\*(_vb.1V|_vb.V);" \ | |
373 | "" "int b;" \ | |
374 | "public:" "virtual int f\\((void|)\\);" \ | |
375 | "B & operator=\\(B const ?&\\);${ws}B\\(int, B const ?&\\);${ws}B\\(int\\);" \ | |
a7995a30 | 376 | "(B & operator=\\(B const ?&\\);${ws}|)B\\(B const ?&\\);${ws}B\\((void|)\\);" \ |
184ad485 | 377 | " ?\\*" |
c906108c | 378 | |
184ad485 | 379 | # An instance of D * |
51615d72 | 380 | |
184ad485 MC |
381 | test_one_ptype "ptype pDd" "ptype pDd" \ |
382 | "class D : public AD, public virtual V \{(${ws}private:|)" \ | |
383 | "V \\*(_vb.1V|_vb.V);" \ | |
384 | "public:" "int d;" \ | |
385 | "" "static void s\\((void|)\\);${ws}virtual int vg\\((void|)\\);${ws}virtual int vd\\((void|)\\);${ws}int fd\\((void|)\\);" \ | |
386 | "D & operator=\\(D const ?&\\);${ws}D\\(int, D const ?&\\);${ws}D\\(int\\);" \ | |
a7995a30 | 387 | "(D & operator=\\(D const ?&\\);${ws}|)D\\(D const ?&\\);${ws}D\\((void|)\\);" \ |
184ad485 | 388 | " ?\\*" |
c906108c | 389 | |
51615d72 MC |
390 | # An instance of D * |
391 | ||
184ad485 MC |
392 | test_one_ptype "ptype pDe" "ptype pDe" \ |
393 | "class D : public AD, public virtual V \{(${ws}private:|)" \ | |
394 | "V \\*(_vb.1V|_vb.V);" \ | |
395 | "public:" "int d;" \ | |
396 | "" "static void s\\((void|)\\);${ws}virtual int vg\\((void|)\\);${ws}virtual int vd\\((void|)\\);${ws}int fd\\((void|)\\);" \ | |
397 | "D & operator=\\(D const ?&\\);${ws}D\\(int, D const ?&\\);${ws}D\\(int\\);" \ | |
a7995a30 | 398 | "(D & operator=\\(D const ?&\\);${ws}|)D\\(D const ?&\\);${ws}D\\((void|)\\);" \ |
184ad485 | 399 | " ?\\*" |
c906108c | 400 | |
184ad485 | 401 | # An instance of V * |
51615d72 | 402 | |
184ad485 MC |
403 | test_one_ptype "ptype pVa" "ptype pVa" \ |
404 | "class V : public VA, public VB \{${ws}public:" \ | |
405 | "" \ | |
406 | "" "int w;" \ | |
407 | "" "int f\\((void|)\\);${ws}virtual int vv\\((void|)\\);" \ | |
408 | "V & operator=\\(V const ?&\\);${ws}V\\(V const ?&\\);${ws}V\\((void|)\\);" \ | |
a7995a30 | 409 | "(V & operator=\\(V const ?&\\);${ws}|)V\\(V const ?&\\);${ws}V\\((void|)\\);" \ |
184ad485 | 410 | " ?\\*" |
c906108c | 411 | |
184ad485 | 412 | # An instance of V * |
51615d72 | 413 | |
184ad485 MC |
414 | test_one_ptype "ptype pVv" "ptype pVv" \ |
415 | "class V : public VA, public VB \{${ws}public:" \ | |
416 | "" \ | |
417 | "" "int w;" \ | |
418 | "" "int f\\((void|)\\);${ws}virtual int vv\\((void|)\\);" \ | |
419 | "V & operator=\\(V const ?&\\);${ws}V\\(V const ?&\\);${ws}V\\((void|)\\);" \ | |
a7995a30 | 420 | "(V & operator=\\(V const ?&\\);${ws}|)V\\(V const ?&\\);${ws}V\\((void|)\\);" \ |
184ad485 | 421 | " ?\\*" |
c906108c | 422 | |
184ad485 | 423 | # An instance of V * |
51615d72 | 424 | |
184ad485 MC |
425 | test_one_ptype "ptype pVe" "ptype pVe" \ |
426 | "class V : public VA, public VB \{${ws}public:" \ | |
427 | "" \ | |
428 | "" "int w;" \ | |
429 | "" "int f\\((void|)\\);${ws}virtual int vv\\((void|)\\);" \ | |
430 | "V & operator=\\(V const ?&\\);${ws}V\\(V const ?&\\);${ws}V\\((void|)\\);" \ | |
a7995a30 | 431 | "(V & operator=\\(V const ?&\\);${ws}|)V\\(V const ?&\\);${ws}V\\((void|)\\);" \ |
184ad485 | 432 | " ?\\*" |
51615d72 | 433 | |
184ad485 | 434 | # An instance of V * |
c906108c | 435 | |
184ad485 MC |
436 | test_one_ptype "ptype pVd" "ptype pVd" \ |
437 | "class V : public VA, public VB \{${ws}public:" \ | |
438 | "" \ | |
439 | "" "int w;" \ | |
440 | "" "int f\\((void|)\\);${ws}virtual int vv\\((void|)\\);" \ | |
441 | "V & operator=\\(V const ?&\\);${ws}V\\(V const ?&\\);${ws}V\\((void|)\\);" \ | |
a7995a30 | 442 | "(V & operator=\\(V const ?&\\);${ws}|)V\\(V const ?&\\);${ws}V\\((void|)\\);" \ |
184ad485 | 443 | " ?\\*" |
51615d72 | 444 | |
184ad485 MC |
445 | # An instance of AD * |
446 | ||
184ad485 MC |
447 | test_one_ptype "ptype pADe" "ptype pADe" \ |
448 | "((struct|class) AD \{${ws}public:|struct AD \{)" \ | |
449 | "" \ | |
450 | "" "" \ | |
451 | "" "virtual int vg\\((void|)\\);" \ | |
452 | "AD & operator=\\(AD const ?&\\);${ws}AD\\(AD const ?&\\);${ws}AD\\((void|)\\);" \ | |
a7995a30 | 453 | "(AD & operator=\\(AD const ?&\\);${ws}|)AD\\(AD const ?&\\);${ws}AD\\((void|)\\);" \ |
184ad485 | 454 | " ?\\*" |
c906108c | 455 | |
51615d72 MC |
456 | # An instance of E * |
457 | ||
184ad485 MC |
458 | test_one_ptype "ptype pEe" "ptype pEe" \ |
459 | "class E : public B, public virtual V, public D, public C \{(${ws}private:|)" \ | |
460 | "" \ | |
461 | "public:" "int e;" \ | |
462 | "" "virtual int f\\((void|)\\);${ws}virtual int vg\\((void|)\\);${ws}virtual int vv\\((void|)\\);" \ | |
463 | "E & operator=\\(E const ?&\\);${ws}E\\(int, E const ?&\\);${ws}E\\(int\\);" \ | |
a7995a30 | 464 | "(E & operator=\\(E const ?&\\);${ws}|)E\\(E const ?&\\);${ws}E\\((void|)\\);" \ |
184ad485 MC |
465 | " ?\\*" |
466 | ||
467 | # An instance of VB * | |
468 | ||
184ad485 MC |
469 | test_one_ptype "ptype pVB" "ptype pVB" \ |
470 | "((struct|class) VB \{${ws}public:|struct VB \{)" \ | |
471 | "" \ | |
472 | "" "int vb;" \ | |
473 | "" "int fvb\\((void|)\\);${ws}virtual int vvb\\((void|)\\);" \ | |
474 | "VB & operator=\\(VB const ?&\\);${ws}VB\\(VB const ?&\\);${ws}VB\\((void|)\\);" \ | |
a7995a30 | 475 | "(VB & operator=\\(VB const ?&\\);${ws}|)VB\\(VB const ?&\\);${ws}VB\\((void|)\\);" \ |
184ad485 | 476 | " ?\\*" |
51615d72 | 477 | } |
c906108c | 478 | |
51615d72 MC |
479 | # Call virtual functions. |
480 | ||
481 | proc test_virtual_calls {} { | |
482 | global gdb_prompt | |
483 | global nl | |
484 | ||
485 | if [target_info exists gdb,cannot_call_functions] { | |
486 | setup_xfail "*-*-*" 2416 | |
487 | fail "This target can not call functions" | |
488 | return 0 | |
c906108c SS |
489 | } |
490 | ||
51615d72 MC |
491 | gdb_test "print pAe->f()" "\\$\[0-9\]+ = 20" |
492 | gdb_test "print pAa->f()" "\\$\[0-9\]+ = 1" | |
493 | gdb_test "print pDe->vg()" "\\$\[0-9\]+ = 202" | |
494 | gdb_test "print pADe->vg()" "\\$\[0-9\]+ = 202" | |
495 | gdb_test "print pDd->vg()" "\\$\[0-9\]+ = 101" | |
496 | gdb_test "print pEe->vvb()" "\\$\[0-9\]+ = 411" | |
497 | gdb_test "print pVB->vvb()" "\\$\[0-9\]+ = 407" | |
498 | gdb_test "print pBe->vvb()" "\\$\[0-9\]+ = 411" | |
499 | gdb_test "print pDe->vvb()" "\\$\[0-9\]+ = 411" | |
500 | gdb_test "print pEe->vd()" "\\$\[0-9\]+ = 282" | |
501 | gdb_test "print pEe->fvb()" "\\$\[0-9\]+ = 311" | |
502 | ||
51615d72 MC |
503 | # more recent results: |
504 | # wrong value "202" | |
505 | # gcc 2.95.3 -gdwarf-2 | |
506 | # gcc 2.95.3 -gstabs+ | |
507 | # attempt to take addres of value not located in memory | |
508 | # gcc 3.3.2 -gdwarf-2 | |
509 | # gcc 3.3.2 -gstabs+ | |
510 | # | |
511 | # -- chastain 2003-12-31 | |
512 | ||
513 | gdb_test_multiple "print pEe->D::vg()" "print pEe->D::vg()" { | |
514 | -re "\\$\[0-9]+ = 102$nl$gdb_prompt $" { | |
515 | pass "print pEe->D::vg()" | |
516 | } | |
517 | -re "Attempt to take address of value not located in memory.$nl$gdb_prompt $" { | |
518 | kfail "gdb/1064" "print pEe->D::vg()" | |
519 | } | |
c906108c SS |
520 | } |
521 | } | |
522 | ||
523 | proc do_tests {} { | |
524 | global prms_id | |
525 | global bug_id | |
51615d72 MC |
526 | global srcdir subdir binfile |
527 | global gdb_prompt | |
c906108c SS |
528 | |
529 | set prms_id 0 | |
530 | set bug_id 0 | |
531 | ||
51615d72 MC |
532 | gdb_exit |
533 | gdb_start | |
534 | gdb_reinitialize_dir $srcdir/$subdir | |
535 | gdb_load $binfile | |
c906108c | 536 | |
51615d72 MC |
537 | gdb_test "set language c++" "" "" |
538 | gdb_test "set width 0" "" "" | |
c906108c | 539 | |
51615d72 | 540 | runto_main |
c906108c SS |
541 | test_ptype_of_classes |
542 | ||
51615d72 MC |
543 | gdb_breakpoint test_calls |
544 | gdb_test "continue" ".*Breakpoint .* test_calls.*" "" | |
545 | test_virtual_calls | |
c906108c SS |
546 | } |
547 | ||
548 | do_tests |