1 /* Unit test suite for msvcrt C++ objects
3 * Copyright 2003 Jon Griffiths
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 #include "wine/test.h"
23 typedef void (*vtable_ptr)(void);
25 typedef struct __exception
32 typedef struct __type_info
41 #define __thiscall __stdcall
43 #define __thiscall __cdecl
46 /* Function pointers. We need to use these to call these funcs as __thiscall */
47 static HMODULE hMsvcrt;
49 static void* (__cdecl *poperator_new)(unsigned int);
50 static void (__cdecl *poperator_delete)(void*);
51 static void* (__cdecl *pmalloc)(unsigned int);
52 static void (__cdecl *pfree)(void*);
55 static void (__thiscall *pexception_ctor)(exception*,LPCSTR*);
56 static void (__thiscall *pexception_copy_ctor)(exception*,exception*);
57 static void (__thiscall *pexception_default_ctor)(exception*);
58 static void (__thiscall *pexception_dtor)(exception*);
59 static exception* (__thiscall *pexception_opequals)(exception*,exception*);
60 static char* (__thiscall *pexception_what)(exception*);
61 static vtable_ptr *pexception_vtable;
62 static void (__thiscall *pexception_vector_dtor)(exception*,unsigned int);
63 static void (__thiscall *pexception_scalar_dtor)(exception*,unsigned int);
66 static void (__thiscall *pbad_typeid_ctor)(exception*,LPCSTR);
67 static void (__thiscall *pbad_typeid_ctor_closure)(exception*);
68 static void (__thiscall *pbad_typeid_copy_ctor)(exception*,exception*);
69 static void (__thiscall *pbad_typeid_dtor)(exception*);
70 static exception* (__thiscall *pbad_typeid_opequals)(exception*,exception*);
71 static char* (__thiscall *pbad_typeid_what)(exception*);
72 static vtable_ptr *pbad_typeid_vtable;
73 static void (__thiscall *pbad_typeid_vector_dtor)(exception*,unsigned int);
74 static void (__thiscall *pbad_typeid_scalar_dtor)(exception*,unsigned int);
77 static void (__thiscall *pbad_cast_ctor)(exception*,LPCSTR*);
78 static void (__thiscall *pbad_cast_ctor2)(exception*,LPCSTR);
79 static void (__thiscall *pbad_cast_ctor_closure)(exception*);
80 static void (__thiscall *pbad_cast_copy_ctor)(exception*,exception*);
81 static void (__thiscall *pbad_cast_dtor)(exception*);
82 static exception* (__thiscall *pbad_cast_opequals)(exception*,exception*);
83 static char* (__thiscall *pbad_cast_what)(exception*);
84 static vtable_ptr *pbad_cast_vtable;
85 static void (__thiscall *pbad_cast_vector_dtor)(exception*,unsigned int);
86 static void (__thiscall *pbad_cast_scalar_dtor)(exception*,unsigned int);
88 /* __non_rtti_object */
89 static void (__thiscall *p__non_rtti_object_ctor)(exception*,LPCSTR);
90 static void (__thiscall *p__non_rtti_object_copy_ctor)(exception*,exception*);
91 static void (__thiscall *p__non_rtti_object_dtor)(exception*);
92 static exception* (__thiscall *p__non_rtti_object_opequals)(exception*,exception*);
93 static char* (__thiscall *p__non_rtti_object_what)(exception*);
94 static vtable_ptr *p__non_rtti_object_vtable;
95 static void (__thiscall *p__non_rtti_object_vector_dtor)(exception*,unsigned int);
96 static void (__thiscall *p__non_rtti_object_scalar_dtor)(exception*,unsigned int);
99 static void (__thiscall *ptype_info_dtor)(type_info*);
100 static char* (__thiscall *ptype_info_raw_name)(type_info*);
101 static char* (__thiscall *ptype_info_name)(type_info*);
102 static int (__thiscall *ptype_info_before)(type_info*,type_info*);
103 static int (__thiscall *ptype_info_opequals_equals)(type_info*,type_info*);
104 static int (__thiscall *ptype_info_opnot_equals)(type_info*,type_info*);
107 static type_info* (__cdecl *p__RTtypeid)(void*);
108 static void* (__cdecl *p__RTCastToVoid)(void*);
109 static void* (__cdecl *p__RTDynamicCast)(void*,int,void*,void*,int);
112 static char* (__cdecl *p__unDName)(char*,const char*,int,void*,void*,unsigned short int);
115 /* _very_ early native versions have serious RTTI bugs, so we check */
116 static void* bAncientVersion;
118 /* Emulate a __thiscall */
121 #include "pshpack1.h"
122 struct thiscall_thunk
124 BYTE pop_eax; /* popl %eax (ret addr) */
125 BYTE pop_edx; /* popl %edx (func) */
126 BYTE pop_ecx; /* popl %ecx (this) */
127 BYTE push_eax; /* pushl %eax */
128 WORD jmp_edx; /* jmp *%edx */
132 static void * (WINAPI *call_thiscall_func1)( void *func, void *this );
133 static void * (WINAPI *call_thiscall_func2)( void *func, void *this, const void *a );
135 static void init_thiscall_thunk(void)
137 struct thiscall_thunk *thunk = VirtualAlloc( NULL, sizeof(*thunk),
138 MEM_COMMIT, PAGE_EXECUTE_READWRITE );
139 thunk->pop_eax = 0x58; /* popl %eax */
140 thunk->pop_edx = 0x5a; /* popl %edx */
141 thunk->pop_ecx = 0x59; /* popl %ecx */
142 thunk->push_eax = 0x50; /* pushl %eax */
143 thunk->jmp_edx = 0xe2ff; /* jmp *%edx */
144 call_thiscall_func1 = (void *)thunk;
145 call_thiscall_func2 = (void *)thunk;
148 #define call_func1(func,_this) call_thiscall_func1(func,_this)
149 #define call_func2(func,_this,a) call_thiscall_func2(func,_this,(const void*)a)
153 #define init_thiscall_thunk() do { } while(0)
154 #define call_func1(func,_this) func(_this)
155 #define call_func2(func,_this,a) func(_this,a)
157 #endif /* __i386__ */
159 /* Some exports are only available in later versions */
160 #define SETNOFAIL(x,y) x = (void*)GetProcAddress(hMsvcrt,y)
161 #define SET(x,y) do { SETNOFAIL(x,y); ok(x != NULL, "Export '%s' not found\n", y); } while(0)
163 static BOOL InitFunctionPtrs(void)
165 hMsvcrt = GetModuleHandleA("msvcrt.dll");
167 hMsvcrt = GetModuleHandleA("msvcrtd.dll");
168 ok(hMsvcrt != 0, "GetModuleHandleA failed\n");
171 win_skip("Could not load msvcrt.dll\n");
175 SET(pmalloc, "malloc");
178 SET(pexception_vtable, "??_7exception@@6B@");
179 SET(pbad_typeid_vtable, "??_7bad_typeid@@6B@");
180 SET(pbad_cast_vtable, "??_7bad_cast@@6B@");
181 SET(p__non_rtti_object_vtable, "??_7__non_rtti_object@@6B@");
183 SET(p__RTtypeid, "__RTtypeid");
184 SET(p__RTCastToVoid, "__RTCastToVoid");
185 SET(p__RTDynamicCast, "__RTDynamicCast");
187 SET(p__unDName,"__unDName");
189 /* Extremely early versions export logic_error, and crash in RTTI */
190 SETNOFAIL(bAncientVersion, "??0logic_error@@QAE@ABQBD@Z");
191 if (sizeof(void *) > sizeof(int)) /* 64-bit initialization */
193 SETNOFAIL(poperator_new, "??_U@YAPEAX_K@Z");
194 SETNOFAIL(poperator_delete, "??_V@YAXPEAX@Z");
196 SET(pexception_ctor, "??0exception@@QEAA@AEBQEBD@Z");
197 SET(pexception_copy_ctor, "??0exception@@QEAA@AEBV0@@Z");
198 SET(pexception_default_ctor, "??0exception@@QEAA@XZ");
199 SET(pexception_dtor, "??1exception@@UEAA@XZ");
200 SET(pexception_opequals, "??4exception@@QEAAAEAV0@AEBV0@@Z");
201 SET(pexception_what, "?what@exception@@UEBAPEBDXZ");
202 pexception_vector_dtor = (void*)pexception_vtable[0];
203 pexception_scalar_dtor = (void*)pexception_vtable[0];
205 SET(pbad_typeid_ctor, "??0bad_typeid@@QEAA@PEBD@Z");
206 SETNOFAIL(pbad_typeid_ctor_closure, "??_Fbad_typeid@@QEAAXXZ");
207 SET(pbad_typeid_copy_ctor, "??0bad_typeid@@QEAA@AEBV0@@Z");
208 SET(pbad_typeid_dtor, "??1bad_typeid@@UEAA@XZ");
209 SET(pbad_typeid_opequals, "??4bad_typeid@@QEAAAEAV0@AEBV0@@Z");
210 SET(pbad_typeid_what, "?what@exception@@UEBAPEBDXZ");
211 pbad_typeid_vector_dtor = (void*)pbad_typeid_vtable[0];
212 pbad_typeid_scalar_dtor = (void*)pbad_typeid_vtable[0];
214 SET(pbad_cast_ctor, "??0bad_cast@@QEAA@AEBQEBD@Z");
215 SET(pbad_cast_ctor2, "??0bad_cast@@QEAA@PEBD@Z");
216 SET(pbad_cast_ctor_closure, "??_Fbad_cast@@QEAAXXZ");
217 SET(pbad_cast_copy_ctor, "??0bad_cast@@QEAA@AEBV0@@Z");
218 SET(pbad_cast_dtor, "??1bad_cast@@UEAA@XZ");
219 SET(pbad_cast_opequals, "??4bad_cast@@QEAAAEAV0@AEBV0@@Z");
220 SET(pbad_cast_what, "?what@exception@@UEBAPEBDXZ");
221 pbad_cast_vector_dtor = (void*)pbad_cast_vtable[0];
222 pbad_cast_scalar_dtor = (void*)pbad_cast_vtable[0];
224 SET(p__non_rtti_object_ctor, "??0__non_rtti_object@@QEAA@PEBD@Z");
225 SET(p__non_rtti_object_copy_ctor, "??0__non_rtti_object@@QEAA@AEBV0@@Z");
226 SET(p__non_rtti_object_dtor, "??1__non_rtti_object@@UEAA@XZ");
227 SET(p__non_rtti_object_opequals, "??4__non_rtti_object@@QEAAAEAV0@AEBV0@@Z");
228 SET(p__non_rtti_object_what, "?what@exception@@UEBAPEBDXZ");
229 p__non_rtti_object_vector_dtor = (void*)p__non_rtti_object_vtable[0];
230 p__non_rtti_object_scalar_dtor = (void*)p__non_rtti_object_vtable[0];
232 SET(ptype_info_dtor, "??1type_info@@UEAA@XZ");
233 SET(ptype_info_raw_name, "?raw_name@type_info@@QEBAPEBDXZ");
234 SET(ptype_info_name, "?name@type_info@@QEBAPEBDXZ");
235 SET(ptype_info_before, "?before@type_info@@QEBAHAEBV1@@Z");
236 SET(ptype_info_opequals_equals, "??8type_info@@QEBAHAEBV0@@Z");
237 SET(ptype_info_opnot_equals, "??9type_info@@QEBAHAEBV0@@Z");
241 SETNOFAIL(poperator_new, "??_U@YAPAXI@Z");
242 SETNOFAIL(poperator_delete, "??_V@YAXPAX@Z");
244 SET(pexception_ctor, "??0exception@@QAE@ABQBD@Z");
245 SET(pexception_copy_ctor, "??0exception@@QAE@ABV0@@Z");
246 SET(pexception_default_ctor, "??0exception@@QAE@XZ");
247 SET(pexception_dtor, "??1exception@@UAE@XZ");
248 SET(pexception_opequals, "??4exception@@QAEAAV0@ABV0@@Z");
249 SET(pexception_what, "?what@exception@@UBEPBDXZ");
250 SET(pexception_vector_dtor, "??_Eexception@@UAEPAXI@Z");
251 SET(pexception_scalar_dtor, "??_Gexception@@UAEPAXI@Z");
253 SET(pbad_typeid_ctor, "??0bad_typeid@@QAE@PBD@Z");
254 SETNOFAIL(pbad_typeid_ctor_closure, "??_Fbad_typeid@@QAEXXZ");
255 SET(pbad_typeid_copy_ctor, "??0bad_typeid@@QAE@ABV0@@Z");
256 SET(pbad_typeid_dtor, "??1bad_typeid@@UAE@XZ");
257 SET(pbad_typeid_opequals, "??4bad_typeid@@QAEAAV0@ABV0@@Z");
258 SET(pbad_typeid_what, "?what@exception@@UBEPBDXZ");
259 SET(pbad_typeid_vector_dtor, "??_Ebad_typeid@@UAEPAXI@Z");
260 SET(pbad_typeid_scalar_dtor, "??_Gbad_typeid@@UAEPAXI@Z");
262 SETNOFAIL(pbad_cast_ctor, "??0bad_cast@@QAE@ABQBD@Z");
264 SET(pbad_cast_ctor, "??0bad_cast@@AAE@PBQBD@Z");
265 SETNOFAIL(pbad_cast_ctor2, "??0bad_cast@@QAE@PBD@Z");
266 SETNOFAIL(pbad_cast_ctor_closure, "??_Fbad_cast@@QAEXXZ");
267 SET(pbad_cast_copy_ctor, "??0bad_cast@@QAE@ABV0@@Z");
268 SET(pbad_cast_dtor, "??1bad_cast@@UAE@XZ");
269 SET(pbad_cast_opequals, "??4bad_cast@@QAEAAV0@ABV0@@Z");
270 SET(pbad_cast_what, "?what@exception@@UBEPBDXZ");
271 SET(pbad_cast_vector_dtor, "??_Ebad_cast@@UAEPAXI@Z");
272 SET(pbad_cast_scalar_dtor, "??_Gbad_cast@@UAEPAXI@Z");
274 SET(p__non_rtti_object_ctor, "??0__non_rtti_object@@QAE@PBD@Z");
275 SET(p__non_rtti_object_copy_ctor, "??0__non_rtti_object@@QAE@ABV0@@Z");
276 SET(p__non_rtti_object_dtor, "??1__non_rtti_object@@UAE@XZ");
277 SET(p__non_rtti_object_opequals, "??4__non_rtti_object@@QAEAAV0@ABV0@@Z");
278 SET(p__non_rtti_object_what, "?what@exception@@UBEPBDXZ");
279 SET(p__non_rtti_object_vector_dtor, "??_E__non_rtti_object@@UAEPAXI@Z");
280 SET(p__non_rtti_object_scalar_dtor, "??_G__non_rtti_object@@UAEPAXI@Z");
282 SET(ptype_info_dtor, "??1type_info@@UAE@XZ");
283 SET(ptype_info_raw_name, "?raw_name@type_info@@QBEPBDXZ");
284 SET(ptype_info_name, "?name@type_info@@QBEPBDXZ");
285 SET(ptype_info_before, "?before@type_info@@QBEHABV1@@Z");
286 SET(ptype_info_opequals_equals, "??8type_info@@QBEHABV0@@Z");
287 SET(ptype_info_opnot_equals, "??9type_info@@QBEHABV0@@Z");
291 poperator_new = pmalloc;
292 if (!poperator_delete)
293 poperator_delete = pfree;
295 init_thiscall_thunk();
299 static void test_exception(void)
301 static const char* e_name = "An exception name";
303 exception e, e2, e3, *pe;
305 if (!poperator_new || !poperator_delete ||
306 !pexception_ctor || !pexception_copy_ctor || !pexception_default_ctor ||
307 !pexception_dtor || !pexception_opequals || !pexception_what ||
308 !pexception_vtable || !pexception_vector_dtor || !pexception_scalar_dtor)
311 /* 'const char*&' ctor */
312 memset(&e, 0, sizeof(e));
313 call_func2(pexception_ctor, &e, &e_name);
314 ok(e.vtable != NULL, "Null exception vtable for e\n");
315 ok(e.name && e.name != e_name && !strcmp(e.name, "An exception name"), "Bad name '%s' for e\n", e.name);
316 ok(e.do_free == 1, "do_free set to %d for e\n", e.do_free);
319 memset(&e2, 0, sizeof(e2));
320 call_func2(pexception_copy_ctor, &e2, &e);
321 ok(e2.vtable != NULL, "Null exception vtable for e2\n");
322 ok(e2.name && e2.name != e.name && !strcmp(e2.name, "An exception name"), "Bad exception name for e2\n");
323 ok(e2.do_free == 1, "do_free set to %d for e2\n", e2.do_free);
326 memset(&e3, 1, sizeof(e3));
327 call_func1(pexception_default_ctor, &e3);
328 ok(e3.vtable != NULL, "Null exception vtable for e3\n");
329 ok(e3.name == NULL, "Bad exception name for e3\n");
330 ok(e3.do_free == 0, "do_free set to %d for e3\n", e3.do_free);
332 ok(e.vtable == e2.vtable && e.vtable == e3.vtable, "exception vtables differ!\n");
334 /* Test calling the dtors */
335 call_func1(pexception_dtor, &e2);
336 call_func1(pexception_dtor, &e3);
338 /* Operator equals */
339 memset(&e2, 0, sizeof(e2));
340 call_func1(pexception_default_ctor, &e2);
341 pe = call_func2(pexception_opequals, &e2, &e);
342 ok(e2.vtable != NULL, "Null exception vtable for e2\n");
343 ok(e2.name && e2.name != e.name && !strcmp(e2.name, "An exception name"), "Bad exception name for e2\n");
344 ok(e2.do_free == 1, "do_free set to %d for e2\n", e2.do_free);
345 ok(pe == &e2, "opequals didn't return e2\n");
348 name = call_func1(pexception_what, &e2);
349 ok(e2.name == name, "Bad exception name from e2::what()\n");
352 ok(e2.vtable == pexception_vtable, "Bad vtable for e2\n");
353 call_func1(pexception_dtor, &e2);
356 pe = poperator_new(sizeof(exception));
357 ok(pe != NULL, "new() failed\n");
360 call_func2(pexception_ctor, pe, &e_name);
362 call_func2(pexception_scalar_dtor, pe, 0); /* Shouldn't delete pe */
365 call_func2(pexception_scalar_dtor, pe, 1); /* Should delete pe */
368 pe = poperator_new(sizeof(exception));
369 ok(pe != NULL, "new() failed\n");
372 /* vector dtor, single element */
373 call_func2(pexception_ctor, pe, &e_name);
374 call_func2(pexception_vector_dtor, pe, 1); /* Should delete pe as single element*/
377 pe = poperator_new(sizeof(exception) * 4 + sizeof(size_t));
378 ok(pe != NULL, "new() failed\n");
381 /* vector dtor, multiple elements */
382 char name[] = "a constant";
384 pe = (exception*)((size_t*)pe + 1);
385 call_func2(pexception_ctor, &pe[0], &e_name);
386 call_func2(pexception_ctor, &pe[1], &e_name);
387 call_func2(pexception_ctor, &pe[2], &e_name);
389 pe[3].do_free = 1; /* Crash if we try to free this */
390 call_func2(pexception_vector_dtor, pe, 3); /* Should delete all 3 and then pe block */
393 /* test our exported vtable is kosher */
394 pe = (void*)pexception_vtable; /* Use the exception struct to get vtable ptrs */
395 pexception_vector_dtor = (void*)pe->vtable;
396 pexception_what = (void*)pe->name;
398 name = call_func1(pexception_what, &e);
399 ok(e.name == name, "Bad exception name from vtable e::what()\n");
401 if (p__RTtypeid && !bAncientVersion)
404 type_info *ti = p__RTtypeid(&e);
405 ok (ti && ti->mangled &&
406 !strcmp(ti->mangled, ".?AVexception@@"), "bad rtti for e\n");
410 /* Check the returned type_info has rtti too */
411 type_info *ti2 = p__RTtypeid(ti);
412 ok (ti2 != NULL && !strcmp(ti2->mangled, ".?AVtype_info@@"), "bad rtti for e's type_info\n");
416 call_func2(pexception_vector_dtor, &e, 0); /* Should delete e.name, but not e */
419 /* This test is basically a cut 'n' paste of the exception test. but it verifies that
420 * bad_typeid works the exact same way... */
421 static void test_bad_typeid(void)
423 static const char* e_name = "A bad_typeid name";
425 exception e, e2, e3, *pe;
427 if (!poperator_new || !poperator_delete ||
428 !pbad_typeid_ctor || !pbad_typeid_copy_ctor ||
429 !pbad_typeid_dtor || !pbad_typeid_opequals || !pbad_typeid_what ||
430 !pbad_typeid_vtable || !pbad_typeid_vector_dtor || !pbad_typeid_scalar_dtor)
433 /* 'const char*' ctor */
434 memset(&e, 0, sizeof(e));
435 call_func2(pbad_typeid_ctor, &e, e_name);
436 ok(e.vtable != NULL, "Null bad_typeid vtable for e\n");
437 ok(e.name && e.name != e_name && !strcmp(e.name, "A bad_typeid name"), "Bad name '%s' for e\n", e.name);
438 ok(e.do_free == 1, "do_free set to %d for e\n", e.do_free);
441 memset(&e2, 0, sizeof(e2));
442 call_func2(pbad_typeid_copy_ctor, &e2, &e);
443 ok(e2.vtable != NULL, "Null bad_typeid vtable for e2\n");
444 ok(e2.name && e2.name != e.name && !strcmp(e2.name, "A bad_typeid name"), "Bad name '%s' for e2\n", e2.name);
445 ok(e2.do_free == 1, "do_free set to %d for e2\n", e2.do_free);
448 if (pbad_typeid_ctor_closure)
450 memset(&e3, 1, sizeof(e3));
451 call_func1(pbad_typeid_ctor_closure, &e3);
452 ok(e3.vtable != NULL, "Null bad_typeid vtable for e3\n");
453 ok(e3.name && !strcmp(e3.name, "bad typeid"), "Bad bad_typeid name for e3\n");
454 ok(e3.do_free == 1, "do_free set to %d for e3\n", e3.do_free);
455 ok(e.vtable == e3.vtable, "bad_typeid closure vtables differ!\n");
456 call_func1(pbad_typeid_dtor, &e3);
458 ok(e.vtable == e2.vtable, "bad_typeid vtables differ!\n");
460 /* Test calling the dtors */
461 call_func1(pbad_typeid_dtor, &e2);
463 /* Operator equals */
464 memset(&e2, 1, sizeof(e2));
465 call_func1(pexception_default_ctor, &e2);
466 pe = call_func2(pbad_typeid_opequals, &e2, &e);
467 ok(e2.vtable != NULL, "Null bad_typeid vtable for e2\n");
468 ok(e2.name && e2.name != e.name && !strcmp(e2.name, "A bad_typeid name"), "Bad bad_typeid name for e2\n");
469 ok(e2.do_free == 1, "do_free set to %d for e2\n", e2.do_free);
470 ok(pe == &e2, "opequals didn't return e2\n");
473 name = call_func1(pbad_typeid_what, &e2);
474 ok(e2.name == name, "Bad bad_typeid name from e2::what()\n");
477 ok(e2.vtable == pexception_vtable, "Bad vtable for e2\n");
478 call_func1(pbad_typeid_dtor, &e2);
481 pe = poperator_new(sizeof(exception));
482 ok(pe != NULL, "new() failed\n");
485 call_func2(pbad_typeid_ctor, pe, e_name);
487 call_func2(pbad_typeid_scalar_dtor, pe, 0); /* Shouldn't delete pe */
490 call_func2(pbad_typeid_scalar_dtor, pe, 1); /* Should delete pe */
493 pe = poperator_new(sizeof(exception));
494 ok(pe != NULL, "new() failed\n");
497 /* vector dtor, single element */
498 call_func2(pbad_typeid_ctor, pe, e_name);
499 call_func2(pbad_typeid_vector_dtor, pe, 1); /* Should delete pe as single element*/
502 pe = poperator_new(sizeof(exception) * 4 + sizeof(size_t));
503 ok(pe != NULL, "new() failed\n");
506 /* vector dtor, multiple elements */
508 pe = (exception*)((size_t*)pe + 1);
509 call_func2(pbad_typeid_ctor, &pe[0], e_name);
510 call_func2(pbad_typeid_ctor, &pe[1], e_name);
511 call_func2(pbad_typeid_ctor, &pe[2], e_name);
513 pe[3].do_free = 1; /* Crash if we try to free this element */
514 call_func2(pbad_typeid_vector_dtor, pe, 3); /* Should delete all 3 and then pe block */
517 /* test our exported vtable is kosher */
518 pe = (void*)pbad_typeid_vtable; /* Use the exception struct to get vtable ptrs */
519 pbad_typeid_vector_dtor = (void*)pe->vtable;
520 pbad_typeid_what = (void*)pe->name;
522 name = call_func1(pbad_typeid_what, &e);
523 ok(e.name == name, "Bad bad_typeid name from vtable e::what()\n");
525 if (p__RTtypeid && !bAncientVersion)
528 type_info *ti = p__RTtypeid(&e);
529 ok (ti != NULL && !strcmp(ti->mangled, ".?AVbad_typeid@@"), "bad rtti for e (%s)\n",
530 !ti ? "null" : ti->mangled);
533 call_func2(pbad_typeid_vector_dtor, &e, 0); /* Should delete e.name, but not e */
537 /* Ditto for this test... */
538 static void test_bad_cast(void)
540 static const char* e_name = "A bad_cast name";
542 exception e, e2, e3, *pe;
544 if (!poperator_new || !poperator_delete ||
545 !pbad_cast_ctor || !pbad_cast_copy_ctor ||
546 !pbad_cast_dtor || !pbad_cast_opequals || !pbad_cast_what ||
547 !pbad_cast_vtable || !pbad_cast_vector_dtor || !pbad_cast_scalar_dtor)
552 /* 'const char*' ctor */
553 memset(&e, 0, sizeof(e));
554 call_func2(pbad_cast_ctor2, &e, e_name);
555 ok(e.vtable != NULL, "Null bad_cast vtable for e\n");
556 ok(e.name && e.name != e_name && !strcmp(e.name, "A bad_cast name"), "Bad name '%s' for e\n", e.name);
557 ok(e.do_free == 1, "do_free set to %d for e\n", e.do_free);
558 call_func1(pbad_cast_dtor, &e);
561 /* 'const char*&' ctor */
562 memset(&e, 0, sizeof(e));
563 call_func2(pbad_cast_ctor, &e, &e_name);
564 ok(e.vtable != NULL, "Null bad_cast vtable for e\n");
565 ok(e.name && e.name != e_name && !strcmp(e.name, "A bad_cast name"), "Bad name '%s' for e\n", e.name);
566 ok(e.do_free == 1, "do_free set to %d for e\n", e.do_free);
569 memset(&e2, 0, sizeof(e2));
570 call_func2(pbad_cast_copy_ctor, &e2, &e);
571 ok(e2.vtable != NULL, "Null bad_cast vtable for e2\n");
572 ok(e2.name && e2.name != e.name && !strcmp(e2.name, "A bad_cast name"), "Bad name '%s' for e2\n", e2.name);
573 ok(e2.do_free == 1, "do_free set to %d for e2\n", e2.do_free);
576 if (pbad_cast_ctor_closure)
578 memset(&e3, 1, sizeof(e3));
579 call_func1(pbad_cast_ctor_closure, &e3);
580 ok(e3.vtable != NULL, "Null bad_cast vtable for e3\n");
581 ok(e3.name && !strcmp(e3.name, "bad cast"), "Bad bad_cast name for e3\n");
582 ok(e3.do_free == 1, "do_free set to %d for e3\n", e3.do_free);
583 ok(e.vtable == e3.vtable, "bad_cast closure vtables differ!\n");
584 call_func1(pbad_cast_dtor, &e3);
586 ok(e.vtable == e2.vtable, "bad_cast vtables differ!\n");
588 /* Test calling the dtors */
589 call_func1(pbad_cast_dtor, &e2);
591 /* Operator equals */
592 memset(&e2, 1, sizeof(e2));
593 call_func1(pexception_default_ctor, &e2);
594 pe = call_func2(pbad_cast_opequals, &e2, &e);
595 ok(e2.vtable != NULL, "Null bad_cast vtable for e2\n");
596 ok(e2.name && e2.name != e.name && !strcmp(e2.name, "A bad_cast name"), "Bad bad_cast name for e2\n");
597 ok(e2.do_free == 1, "do_free set to %d for e2\n", e2.do_free);
598 ok(pe == &e2, "opequals didn't return e2\n");
601 name = call_func1(pbad_cast_what, &e2);
602 ok(e2.name == name, "Bad bad_cast name from e2::what()\n");
605 ok(e2.vtable == pexception_vtable, "Bad vtable for e2\n");
606 call_func1(pbad_cast_dtor, &e2);
609 pe = poperator_new(sizeof(exception));
610 ok(pe != NULL, "new() failed\n");
613 call_func2(pbad_cast_ctor, pe, &e_name);
615 call_func2(pbad_cast_scalar_dtor, pe, 0); /* Shouldn't delete pe */
618 call_func2(pbad_cast_scalar_dtor, pe, 1); /* Should delete pe */
621 pe = poperator_new(sizeof(exception));
622 ok(pe != NULL, "new() failed\n");
625 /* vector dtor, single element */
626 call_func2(pbad_cast_ctor, pe, &e_name);
627 call_func2(pbad_cast_vector_dtor, pe, 1); /* Should delete pe as single element*/
630 pe = poperator_new(sizeof(exception) * 4 + sizeof(size_t));
631 ok(pe != NULL, "new() failed\n");
634 /* vector dtor, multiple elements */
636 pe = (exception*)((size_t*)pe + 1);
637 call_func2(pbad_cast_ctor, &pe[0], &e_name);
638 call_func2(pbad_cast_ctor, &pe[1], &e_name);
639 call_func2(pbad_cast_ctor, &pe[2], &e_name);
641 pe[3].do_free = 1; /* Crash if we try to free this element */
642 call_func2(pbad_cast_vector_dtor, pe, 3); /* Should delete all 3 and then pe block */
645 /* test our exported vtable is kosher */
646 pe = (void*)pbad_cast_vtable; /* Use the exception struct to get vtable ptrs */
647 pbad_cast_vector_dtor = (void*)pe->vtable;
648 pbad_cast_what = (void*)pe->name;
650 name = call_func1(pbad_cast_what, &e);
651 ok(e.name == name, "Bad bad_cast name from vtable e::what()\n");
653 if (p__RTtypeid && !bAncientVersion)
656 type_info *ti = p__RTtypeid(&e);
657 ok (ti != NULL && !strcmp(ti->mangled, ".?AVbad_cast@@"), "bad rtti for e\n");
659 call_func2(pbad_cast_vector_dtor, &e, 0); /* Should delete e.name, but not e */
662 /* ... and this one */
663 static void test___non_rtti_object(void)
665 static const char* e_name = "A __non_rtti_object name";
667 exception e, e2, *pe;
669 if (!poperator_new || !poperator_delete ||
670 !p__non_rtti_object_ctor || !p__non_rtti_object_copy_ctor ||
671 !p__non_rtti_object_dtor || !p__non_rtti_object_opequals || !p__non_rtti_object_what ||
672 !p__non_rtti_object_vtable || !p__non_rtti_object_vector_dtor || !p__non_rtti_object_scalar_dtor)
675 /* 'const char*' ctor */
676 memset(&e, 0, sizeof(e));
677 call_func2(p__non_rtti_object_ctor, &e, e_name);
678 ok(e.vtable != NULL, "Null __non_rtti_object vtable for e\n");
679 ok(e.name && e.name != e_name && !strcmp(e.name, "A __non_rtti_object name"), "Bad name '%s' for e\n", e.name);
680 ok(e.do_free == 1, "do_free set to %d for e\n", e.do_free);
683 memset(&e2, 0, sizeof(e2));
684 call_func2(p__non_rtti_object_copy_ctor, &e2, &e);
685 ok(e2.vtable != NULL, "Null __non_rtti_object vtable for e2\n");
686 ok(e2.name && e2.name != e.name && !strcmp(e2.name, "A __non_rtti_object name"), "Bad name '%s' for e2\n", e2.name);
687 ok(e2.do_free == 1, "do_free set to %d for e2\n", e2.do_free);
688 ok(e.vtable == e2.vtable, "__non_rtti_object vtables differ!\n");
690 /* Test calling the dtors */
691 call_func1(p__non_rtti_object_dtor, &e2);
693 /* Operator equals */
694 memset(&e2, 1, sizeof(e2));
695 call_func1(pexception_default_ctor, &e2);
696 pe = call_func2(p__non_rtti_object_opequals, &e2, &e);
697 ok(e2.vtable != NULL, "Null __non_rtti_object vtable for e2\n");
698 ok(e2.name && e2.name != e.name && !strcmp(e2.name, "A __non_rtti_object name"), "Bad __non_rtti_object name for e2\n");
699 ok(e2.do_free == 1, "do_free set to %d for e2\n", e2.do_free);
700 ok(pe == &e2, "opequals didn't return e2\n");
703 name = call_func1(p__non_rtti_object_what, &e2);
704 ok(e2.name == name, "Bad __non_rtti_object name from e2::what()\n");
707 ok(e2.vtable == pexception_vtable, "Bad vtable for e2\n");
708 call_func1(p__non_rtti_object_dtor, &e2);
711 pe = poperator_new(sizeof(exception));
712 ok(pe != NULL, "new() failed\n");
715 call_func2(p__non_rtti_object_ctor, pe, e_name);
717 call_func2(p__non_rtti_object_scalar_dtor, pe, 0); /* Shouldn't delete pe */
720 call_func2(p__non_rtti_object_scalar_dtor, pe, 1); /* Should delete pe */
723 pe = poperator_new(sizeof(exception));
724 ok(pe != NULL, "new() failed\n");
727 /* vector dtor, single element */
728 call_func2(p__non_rtti_object_ctor, pe, e_name);
729 call_func2(p__non_rtti_object_vector_dtor, pe, 1); /* Should delete pe as single element*/
732 pe = poperator_new(sizeof(exception) * 4 + sizeof(size_t));
733 ok(pe != NULL, "new() failed\n");
736 /* vector dtor, multiple elements */
738 pe = (exception*)((size_t*)pe + 1);
739 call_func2(p__non_rtti_object_ctor, &pe[0], e_name);
740 call_func2(p__non_rtti_object_ctor, &pe[1], e_name);
741 call_func2(p__non_rtti_object_ctor, &pe[2], e_name);
743 pe[3].do_free = 1; /* Crash if we try to free this element */
744 call_func2(p__non_rtti_object_vector_dtor, pe, 3); /* Should delete all 3 and then pe block */
747 /* test our exported vtable is kosher */
748 pe = (void*)p__non_rtti_object_vtable; /* Use the exception struct to get vtable ptrs */
749 p__non_rtti_object_vector_dtor = (void*)pe->vtable;
750 p__non_rtti_object_what = (void*)pe->name;
752 name = call_func1(p__non_rtti_object_what, &e);
753 ok(e.name == name, "Bad __non_rtti_object name from vtable e::what()\n");
755 if (p__RTtypeid && !bAncientVersion)
758 type_info *ti = p__RTtypeid(&e);
759 ok (ti != NULL && !strcmp(ti->mangled, ".?AV__non_rtti_object@@"), "bad rtti for e\n");
761 call_func2(p__non_rtti_object_vector_dtor, &e, 0); /* Should delete e.name, but not e */
764 static void test_type_info(void)
766 static type_info t1 = { NULL, NULL,{'.','?','A','V','t','e','s','t','1','@','@',0,0,0,0,0 } };
767 static type_info t1_1 = { NULL, NULL,{'?','?','A','V','t','e','s','t','1','@','@',0,0,0,0,0 } };
768 static type_info t2 = { NULL, NULL, {'.','?','A','V','t','e','s','t','2','@','@',0,0,0,0,0 } };
772 if (!pmalloc || !pfree || !ptype_info_dtor || !ptype_info_raw_name ||
773 !ptype_info_name || !ptype_info_before ||
774 !ptype_info_opequals_equals || !ptype_info_opnot_equals)
777 /* Test calling the dtors */
778 call_func1(ptype_info_dtor, &t1); /* No effect, since name is NULL */
779 t1.name = pmalloc(64);
780 strcpy(t1.name, "foo");
781 call_func1(ptype_info_dtor, &t1); /* Frees t1.name using 'free' */
785 name = call_func1(ptype_info_raw_name, &t1);
787 /* FIXME: This fails on native; it shouldn't though - native bug?
788 * ok(name && !strcmp(name, t1.mangled), "bad raw_name '%s' for t1 (expected '%s')\n", name, t1.mangled);
790 ok(t1.name == NULL, "raw_name() set name for t1\n");
794 name = call_func1(ptype_info_name, &t1);
795 ok(name && t1.name && !strcmp(name, t1.name), "bad name '%s' for t1\n", name);
797 ok(t1.name && !strcmp(t1.name, "class test1"), "demangled to '%s' for t1\n", t1.name);
798 call_func1(ptype_info_dtor, &t1);
802 res = (int)call_func2(ptype_info_before, &t1, &t1);
803 ok(res == 0, "expected 0, got %d\n", res);
804 res = (int)call_func2(ptype_info_before, &t2, &t1);
805 ok(res == 0, "expected 0, got %d\n", res);
806 res = (int)call_func2(ptype_info_before, &t1, &t2);
807 ok(res == 1, "expected 1, got %d\n", res);
808 /* Doesn't check first char */
809 res = (int)call_func2(ptype_info_before, &t1, &t1_1);
810 ok(res == 0, "expected 0, got %d\n", res);
812 /* opequals_equals */
814 res = (int)call_func2(ptype_info_opequals_equals, &t1, &t1);
815 ok(res == 1, "expected 1, got %d\n", res);
816 res = (int)call_func2(ptype_info_opequals_equals, &t1, &t2);
817 ok(res == 0, "expected 0, got %d\n", res);
818 res = (int)call_func2(ptype_info_opequals_equals, &t2, &t1);
819 ok(res == 0, "expected 0, got %d\n", res);
823 res = (int)call_func2(ptype_info_opnot_equals, &t1, &t1);
824 ok(res == 0, "expected 0, got %d\n", res);
825 res = (int)call_func2(ptype_info_opnot_equals, &t1, &t2);
826 ok(res == 1, "expected 1, got %d\n", res);
827 res = (int)call_func2(ptype_info_opnot_equals, &t2, &t1);
828 ok(res == 1, "expected 1, got %d\n", res);
831 static inline vtable_ptr *get_vtable( void *obj )
833 return *(vtable_ptr **)obj;
836 static inline void/*rtti_object_locator*/ *get_obj_locator( void *cppobj )
838 const vtable_ptr *vtable = get_vtable( cppobj );
839 return (void *)vtable[-1];
843 #define DEFINE_RTTI_REF(type, name) type *name
844 #define RTTI_REF(instance, name) &instance.name
845 #define RTTI_REF_SIG0(instance, name, base) RTTI_REF(instance, name)
847 #define DEFINE_RTTI_REF(type, name) unsigned name
848 #define RTTI_REF(instance, name) FIELD_OFFSET(struct rtti_data, name)
849 #define RTTI_REF_SIG0(instance, name, base) ((char*)&instance.name-base)
851 /* Test RTTI functions */
852 static void test_rtti(void)
854 struct _object_locator
856 unsigned int signature;
857 int base_class_offset;
859 DEFINE_RTTI_REF(type_info, type_descriptor);
860 DEFINE_RTTI_REF(struct _rtti_object_hierarchy, type_hierarchy);
861 DEFINE_RTTI_REF(void, object_locator);
866 type_info type_info[4];
868 struct _rtti_base_descriptor
870 DEFINE_RTTI_REF(type_info, type_descriptor);
871 int num_base_classes;
877 unsigned int attributes;
878 } base_descriptor[4];
880 struct _rtti_base_array {
881 DEFINE_RTTI_REF(struct _rtti_base_descriptor, bases[4]);
884 struct _rtti_object_hierarchy {
885 unsigned int signature;
886 unsigned int attributes;
888 DEFINE_RTTI_REF(struct _rtti_base_array, base_classes);
891 struct _object_locator object_locator;
892 } simple_class_rtti = {
893 { {NULL, NULL, "simple_class"} },
894 { {RTTI_REF(simple_class_rtti, type_info[0]), 0, {0, 0, 0}, 0} },
895 { {RTTI_REF(simple_class_rtti, base_descriptor[0])} },
896 {0, 0, 1, RTTI_REF(simple_class_rtti, base_array)},
897 {1, 0, 0, RTTI_REF(simple_class_rtti, type_info[0]), RTTI_REF(simple_class_rtti, object_hierarchy), RTTI_REF(simple_class_rtti, object_locator)}
898 }, child_class_rtti = {
899 { {NULL, NULL, "simple_class"}, {NULL, NULL, "child_class"} },
900 { {RTTI_REF(child_class_rtti, type_info[1]), 0, {4, -1, 0}, 0}, {RTTI_REF(child_class_rtti, type_info[0]), 0, {8, -1, 0}, 0} },
901 { {RTTI_REF(child_class_rtti, base_descriptor[0]), RTTI_REF(child_class_rtti, base_descriptor[1])} },
902 {0, 0, 2, RTTI_REF(child_class_rtti, base_array)},
903 {1, 0, 0, RTTI_REF(child_class_rtti, type_info[1]), RTTI_REF(child_class_rtti, object_hierarchy), RTTI_REF(child_class_rtti, object_locator)}
904 }, virtual_base_class_rtti = {
905 { {NULL, NULL, "simple_class"}, {NULL, NULL, "child_class"} },
906 { {RTTI_REF(virtual_base_class_rtti, type_info[1]), 0, {0x10, sizeof(void*), sizeof(int)}, 0}, {RTTI_REF(virtual_base_class_rtti, type_info[0]), 0, {8, -1, 0}, 0} },
907 { {RTTI_REF(virtual_base_class_rtti, base_descriptor[0]), RTTI_REF(virtual_base_class_rtti, base_descriptor[1])} },
908 {0, 0, 2, RTTI_REF(virtual_base_class_rtti, base_array)},
909 {1, 0, 0, RTTI_REF(virtual_base_class_rtti, type_info[1]), RTTI_REF(virtual_base_class_rtti, object_hierarchy), RTTI_REF(virtual_base_class_rtti, object_locator)}
911 static struct rtti_data simple_class_sig0_rtti, child_class_sig0_rtti;
913 void *simple_class_vtbl[2] = {&simple_class_rtti.object_locator};
914 void *simple_class = &simple_class_vtbl[1];
915 void *child_class_vtbl[2] = {&child_class_rtti.object_locator};
916 void *child_class = &child_class_vtbl[1];
917 void *simple_class_sig0_vtbl[2] = {&simple_class_sig0_rtti.object_locator};
918 void *simple_class_sig0 = &simple_class_sig0_vtbl[1];
919 void *child_class_sig0_vtbl[2] = {&child_class_sig0_rtti.object_locator};
920 void *child_class_sig0 = &child_class_sig0_vtbl[1];
921 void *virtual_base_class_vtbl[2] = {&virtual_base_class_rtti.object_locator};
922 int virtual_base_class_vbtbl[2] = {0, 0x100};
923 void *virtual_base_class[2] = {&virtual_base_class_vtbl[1], virtual_base_class_vbtbl};
925 static const char* e_name = "name";
931 char *base = (char*)GetModuleHandleW(NULL);
934 if (bAncientVersion ||
935 !p__RTCastToVoid || !p__RTtypeid || !pexception_ctor || !pbad_typeid_ctor
936 || !p__RTDynamicCast || !pexception_dtor || !pbad_typeid_dtor)
939 call_func2(pexception_ctor, &e, &e_name);
940 call_func2(pbad_typeid_ctor, &b, e_name);
942 obj_locator = get_obj_locator(&e);
943 if(obj_locator->signature!=1 && sizeof(void*)>sizeof(int))
944 old_signature = TRUE;
946 old_signature = FALSE;
948 /* dynamic_cast to void* */
949 casted = p__RTCastToVoid(&e);
950 ok (casted == (void*)&e, "failed cast to void\n");
952 /* dynamic_cast up */
953 ti = p__RTtypeid(&e);
954 bti = p__RTtypeid(&b);
956 casted = p__RTDynamicCast(&b, 0, NULL, ti, 0);
959 /* New versions do not allow this conversion due to compiler changes */
960 ok (casted == (void*)&b, "failed cast from bad_typeid to exception\n");
963 /* dynamic_cast down */
964 casted = p__RTDynamicCast(&e, 0, NULL, bti, 0);
965 ok (casted == NULL, "Cast succeeded\n");
967 call_func1(pexception_dtor, &e);
968 call_func1(pbad_typeid_dtor, &b);
970 simple_class_sig0_rtti = simple_class_rtti;
971 simple_class_sig0_rtti.object_locator.signature = 0;
972 simple_class_sig0_rtti.base_descriptor[0].type_descriptor = RTTI_REF_SIG0(simple_class_sig0_rtti, type_info[0], base);
973 simple_class_sig0_rtti.base_array.bases[0] = RTTI_REF_SIG0(simple_class_sig0_rtti, base_descriptor[0], base);
974 simple_class_sig0_rtti.object_hierarchy.base_classes = RTTI_REF_SIG0(simple_class_sig0_rtti, base_array, base);
975 simple_class_sig0_rtti.object_locator.type_descriptor = RTTI_REF_SIG0(simple_class_sig0_rtti, type_info[0], base);
976 simple_class_sig0_rtti.object_locator.type_hierarchy = RTTI_REF_SIG0(simple_class_sig0_rtti, object_hierarchy, base);
978 child_class_sig0_rtti = child_class_rtti;
979 child_class_sig0_rtti.object_locator.signature = 0;
980 child_class_sig0_rtti.base_descriptor[0].type_descriptor = RTTI_REF_SIG0(child_class_sig0_rtti, type_info[1], base);
981 child_class_sig0_rtti.base_descriptor[1].type_descriptor = RTTI_REF_SIG0(child_class_sig0_rtti, type_info[0], base);
982 child_class_sig0_rtti.base_array.bases[0] = RTTI_REF_SIG0(child_class_sig0_rtti, base_descriptor[0], base);
983 child_class_sig0_rtti.base_array.bases[1] = RTTI_REF_SIG0(child_class_sig0_rtti, base_descriptor[1], base);
984 child_class_sig0_rtti.object_hierarchy.base_classes = RTTI_REF_SIG0(child_class_sig0_rtti, base_array, base);
985 child_class_sig0_rtti.object_locator.type_descriptor = RTTI_REF_SIG0(child_class_sig0_rtti, type_info[1], base);
986 child_class_sig0_rtti.object_locator.type_hierarchy = RTTI_REF_SIG0(child_class_sig0_rtti, object_hierarchy, base);
988 ti = p__RTtypeid(&simple_class_sig0);
989 ok (ti && ti->mangled && !strcmp(ti->mangled, "simple_class"),
990 "incorrect rtti data\n");
992 casted = p__RTCastToVoid(&simple_class_sig0);
993 ok (casted == (void*)&simple_class_sig0, "failed cast to void\n");
995 ti = p__RTtypeid(&child_class_sig0);
996 ok (ti && ti->mangled && !strcmp(ti->mangled, "child_class"),
997 "incorrect rtti data\n");
999 casted = p__RTCastToVoid(&child_class_sig0);
1000 ok (casted == (void*)&child_class_sig0, "failed cast to void\n");
1002 casted = p__RTDynamicCast(&child_class_sig0, 0, NULL, simple_class_sig0_rtti.type_info, 0);
1005 ok (casted == (char*)&child_class_sig0+8, "failed cast to simple_class (%p %p)\n", casted, &child_class_sig0);
1008 casted = p__RTDynamicCast(&child_class_sig0, 0, &child_class_sig0_rtti.type_info[0], &child_class_sig0_rtti.type_info[1], 0);
1009 ok(casted == (char*)&child_class_sig0+4, "failed cast to child class (%p %p)\n", casted, &child_class_sig0);
1012 skip("signature==1 is not supported\n");
1016 ti = p__RTtypeid(&simple_class);
1017 ok (ti && ti->mangled && !strcmp(ti->mangled, "simple_class"),
1018 "incorrect rtti data\n");
1020 casted = p__RTCastToVoid(&simple_class);
1021 ok (casted == (void*)&simple_class, "failed cast to void\n");
1023 ti = p__RTtypeid(&child_class);
1024 ok (ti && ti->mangled && !strcmp(ti->mangled, "child_class"),
1025 "incorrect rtti data\n");
1027 casted = p__RTCastToVoid(&child_class);
1028 ok (casted == (void*)&child_class, "failed cast to void\n");
1030 casted = p__RTDynamicCast(&child_class, 0, NULL, simple_class_rtti.type_info, 0);
1033 ok (casted == (char*)&child_class+8, "failed cast to simple_class (%p %p)\n", casted, &child_class);
1036 casted = p__RTDynamicCast(&child_class, 0, &child_class_rtti.type_info[0], &child_class_rtti.type_info[1], 0);
1037 ok(casted == (char*)&child_class+4, "failed cast to child class (%p %p)\n", casted, &child_class);
1039 casted = p__RTDynamicCast(&virtual_base_class, 0, &virtual_base_class_rtti.type_info[0], &virtual_base_class_rtti.type_info[1], 0);
1040 ok(casted == (char*)&virtual_base_class+0x110+sizeof(void*), "failed cast to child class (%p %p)\n", casted, &virtual_base_class);
1049 static void test_demangle_datatype(void)
1052 struct _demangle demangle[]={
1053 /* { "BlaBla"," ?? ::Bla", FALSE}, */
1054 { "ABVVec4@ref2@dice@@","class dice::ref2::Vec4 const &",TRUE},
1055 { "?AV?$CDB_GEN_BIG_ENUM_FLAG@W4CDB_WYSIWYG_BITS_ENUM@@$0H@@@", "class CDB_GEN_BIG_ENUM_FLAG<enum CDB_WYSIWYG_BITS_ENUM,7>", TRUE},
1056 { "?AV?$CDB_GEN_BIG_ENUM_FLAG@W4CDB_WYSIWYG_BITS_ENUM@@$0HO@@@", "class CDB_GEN_BIG_ENUM_FLAG<enum CDB_WYSIWYG_BITS_ENUM,126>",TRUE},
1057 { "?AV?$CDB_GEN_BIG_ENUM_FLAG@W4CDB_WYSIWYG_BITS_ENUM@@$0HOA@@@", "class CDB_GEN_BIG_ENUM_FLAG<enum CDB_WYSIWYG_BITS_ENUM,2016>",TRUE},
1058 { "?AV?$CDB_GEN_BIG_ENUM_FLAG@W4CDB_WYSIWYG_BITS_ENUM@@$0HOAA@@@", "class CDB_GEN_BIG_ENUM_FLAG<enum CDB_WYSIWYG_BITS_ENUM,32256>",TRUE},
1059 { "?AV?$CDB_GEN_BIG_ENUM_FLAG@W4CDB_WYSIWYG_BITS_ENUM@@$01@@@", "?AV?$CDB_GEN_BIG_ENUM_FLAG@W4CDB_WYSIWYG_BITS_ENUM@@$01@@@", FALSE},
1060 /* { "?AV?$CDB_GEN_BIG_ENUM_FLAG@W4CDB_WYSIWYG_BITS_ENUM@@$011@@@", "?AV?$CDB_GEN_BIG_ENUM_FLAG@W4CDB_WYSIWYG_BITS_ENUM@@$011@@@",FALSE}, */
1062 int i, num_test = (sizeof(demangle)/sizeof(struct _demangle));
1064 for (i = 0; i < num_test; i++)
1066 name = p__unDName(0, demangle[i].mangled, 0, pmalloc, pfree, 0x2800);
1067 if (demangle[i].test_in_wine)
1068 ok(name != NULL && !strcmp(name,demangle[i].result), "Got name \"%s\" for %d\n", name, i);
1070 todo_wine ok(name != NULL && !strcmp(name,demangle[i].result), "Got name %s for %d\n", name, i);
1076 /* Compare two strings treating multiple spaces (' ', ascii 0x20) in s2
1077 as single space. Needed for test_demangle as __unDName() returns sometimes
1078 two spaces instead of one in some older native msvcrt dlls. */
1079 static int strcmp_space(const char *s1, const char *s2)
1081 const char* s2start = s2;
1083 while (*s1 == *s2 && *s1) {
1087 if (*s2 == ' ' && s2 > s2start && *(s2 - 1) == ' ')
1091 } while (*s1 && *s2);
1095 static void test_demangle(void)
1097 static struct {const char* in; const char* out; const char *broken; unsigned int flags;} test[] = {
1098 /* 0 */ {"??0bad_alloc@std@@QAE@ABV01@@Z",
1099 "public: __thiscall std::bad_alloc::bad_alloc(class std::bad_alloc const &)",
1100 "public: __thiscall std::bad_alloc::bad_alloc(class bad_alloc::bad_alloc const &)"},
1101 /* 1 */ {"??0bad_alloc@std@@QAE@PBD@Z",
1102 "public: __thiscall std::bad_alloc::bad_alloc(char const *)"},
1103 /* 2 */ {"??0bad_cast@@AAE@PBQBD@Z",
1104 "private: __thiscall bad_cast::bad_cast(char const * const *)"},
1105 /* 3 */ {"??0bad_cast@@QAE@ABQBD@Z",
1106 "public: __thiscall bad_cast::bad_cast(char const * const &)"},
1107 /* 4 */ {"??0bad_cast@@QAE@ABV0@@Z",
1108 "public: __thiscall bad_cast::bad_cast(class bad_cast const &)"},
1109 /* 5 */ {"??0bad_exception@std@@QAE@ABV01@@Z",
1110 "public: __thiscall std::bad_exception::bad_exception(class std::bad_exception const &)",
1111 "public: __thiscall std::bad_exception::bad_exception(class bad_exception::bad_exception const &)"},
1112 /* 6 */ {"??0bad_exception@std@@QAE@PBD@Z",
1113 "public: __thiscall std::bad_exception::bad_exception(char const *)"},
1114 /* 7 */ {"??0?$basic_filebuf@DU?$char_traits@D@std@@@std@@QAE@ABV01@@Z",
1115 "public: __thiscall std::basic_filebuf<char,struct std::char_traits<char> >::basic_filebuf<char,struct std::char_traits<char> >(class std::basic_filebuf<char,struct std::char_traits<char> > const &)",
1116 "public: __thiscall std::basic_filebuf<char,struct std::char_traits<char> >::basic_filebuf<char,struct std::char_traits<char> >(class basic_filebuf<char,struct std::char_traits<char> >::basic_filebuf<char,struct std::char_traits<char> > const &)"},
1117 /* 8 */ {"??0?$basic_filebuf@DU?$char_traits@D@std@@@std@@QAE@PAU_iobuf@@@Z",
1118 "public: __thiscall std::basic_filebuf<char,struct std::char_traits<char> >::basic_filebuf<char,struct std::char_traits<char> >(struct _iobuf *)"},
1119 /* 9 */ {"??0?$basic_filebuf@DU?$char_traits@D@std@@@std@@QAE@W4_Uninitialized@1@@Z",
1120 "public: __thiscall std::basic_filebuf<char,struct std::char_traits<char> >::basic_filebuf<char,struct std::char_traits<char> >(enum std::_Uninitialized)",
1121 "public: __thiscall std::basic_filebuf<char,struct std::char_traits<char> >::basic_filebuf<char,struct std::char_traits<char> >(enum basic_filebuf<char,struct std::char_traits<char> >::_Uninitialized)"},
1122 /* 10 */ {"??0?$basic_filebuf@GU?$char_traits@G@std@@@std@@QAE@ABV01@@Z",
1123 "public: __thiscall std::basic_filebuf<unsigned short,struct std::char_traits<unsigned short> >::basic_filebuf<unsigned short,struct std::char_traits<unsigned short> >(class std::basic_filebuf<unsigned short,struct std::char_traits<unsigned short> > const &)",
1124 "public: __thiscall std::basic_filebuf<unsigned short,struct std::char_traits<unsigned short> >::basic_filebuf<unsigned short,struct std::char_traits<unsigned short> >(class basic_filebuf<unsigned short,struct std::char_traits<unsigned short> >::basic_filebuf<unsigned short,struct std::char_traits<unsigned short> > const &)"},
1125 /* 11 */ {"??0?$basic_filebuf@GU?$char_traits@G@std@@@std@@QAE@PAU_iobuf@@@Z",
1126 "public: __thiscall std::basic_filebuf<unsigned short,struct std::char_traits<unsigned short> >::basic_filebuf<unsigned short,struct std::char_traits<unsigned short> >(struct _iobuf *)"},
1127 /* 12 */ {"??0?$basic_filebuf@GU?$char_traits@G@std@@@std@@QAE@W4_Uninitialized@1@@Z",
1128 "public: __thiscall std::basic_filebuf<unsigned short,struct std::char_traits<unsigned short> >::basic_filebuf<unsigned short,struct std::char_traits<unsigned short> >(enum std::_Uninitialized)",
1129 "public: __thiscall std::basic_filebuf<unsigned short,struct std::char_traits<unsigned short> >::basic_filebuf<unsigned short,struct std::char_traits<unsigned short> >(enum basic_filebuf<unsigned short,struct std::char_traits<unsigned short> >::_Uninitialized)"},
1130 /* 13 */ {"??0?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@ABV01@@Z",
1131 "public: __thiscall std::basic_stringstream<char,struct std::char_traits<char>,class std::allocator<char> >::basic_stringstream<char,struct std::char_traits<char>,class std::allocator<char> >(class std::basic_stringstream<char,struct std::char_traits<char>,class std::allocator<char> > const &)",
1132 "public: __thiscall std::basic_stringstream<char,struct std::char_traits<char>,class std::allocator<char> >::basic_stringstream<char,struct std::char_traits<char>,class std::allocator<char> >(class basic_stringstream<char,struct std::char_traits<char>,class std::allocator<char> >::basic_stringstream<char,struct std::char_traits<char>,class std::allocator<char> > const &)"},
1133 /* 14 */ {"??0?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@1@H@Z",
1134 "public: __thiscall std::basic_stringstream<char,struct std::char_traits<char>,class std::allocator<char> >::basic_stringstream<char,struct std::char_traits<char>,class std::allocator<char> >(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,int)",
1135 "public: __thiscall std::basic_stringstream<char,struct std::char_traits<char>,class std::allocator<char> >::basic_stringstream<char,struct std::char_traits<char>,class std::allocator<char> >(class basic_stringstream<char,struct std::char_traits<char>,class std::allocator<char> >::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,int)"},
1136 /* 15 */ {"??0?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@H@Z",
1137 "public: __thiscall std::basic_stringstream<char,struct std::char_traits<char>,class std::allocator<char> >::basic_stringstream<char,struct std::char_traits<char>,class std::allocator<char> >(int)"},
1138 /* 16 */ {"??0?$basic_stringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QAE@ABV01@@Z",
1139 "public: __thiscall std::basic_stringstream<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> >::basic_stringstream<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> >(class std::basic_stringstream<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> > const &)",
1140 "public: __thiscall std::basic_stringstream<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> >::basic_stringstream<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> >(class basic_stringstream<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> >::basic_stringstream<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> > const &)"},
1141 /* 17 */ {"??0?$basic_stringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QAE@ABV?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@1@H@Z",
1142 "public: __thiscall std::basic_stringstream<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> >::basic_stringstream<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> >(class std::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> > const &,int)",
1143 "public: __thiscall std::basic_stringstream<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> >::basic_stringstream<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> >(class basic_stringstream<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> >::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> > const &,int)"},
1144 /* 18 */ {"??0?$basic_stringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QAE@H@Z",
1145 "public: __thiscall std::basic_stringstream<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> >::basic_stringstream<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> >(int)"},
1146 /* 19 */ {"??0?$num_get@DV?$istreambuf_iterator@DU?$char_traits@D@std@@@std@@@std@@QAE@ABV_Locinfo@1@I@Z",
1147 "public: __thiscall std::num_get<char,class std::istreambuf_iterator<char,struct std::char_traits<char> > >::num_get<char,class std::istreambuf_iterator<char,struct std::char_traits<char> > >(class std::_Locinfo const &,unsigned int)",
1148 "public: __thiscall std::num_get<char,class std::istreambuf_iterator<char,struct std::char_traits<char> > >::num_get<char,class std::istreambuf_iterator<char,struct std::char_traits<char> > >(class num_get<char,class std::istreambuf_iterator<char,struct std::char_traits<char> > >::_Locinfo const &,unsigned int)"},
1149 /* 20 */ {"??0?$num_get@DV?$istreambuf_iterator@DU?$char_traits@D@std@@@std@@@std@@QAE@I@Z",
1150 "public: __thiscall std::num_get<char,class std::istreambuf_iterator<char,struct std::char_traits<char> > >::num_get<char,class std::istreambuf_iterator<char,struct std::char_traits<char> > >(unsigned int)"},
1151 /* 21 */ {"??0?$num_get@GV?$istreambuf_iterator@GU?$char_traits@G@std@@@std@@@std@@QAE@ABV_Locinfo@1@I@Z",
1152 "public: __thiscall std::num_get<unsigned short,class std::istreambuf_iterator<unsigned short,struct std::char_traits<unsigned short> > >::num_get<unsigned short,class std::istreambuf_iterator<unsigned short,struct std::char_traits<unsigned short> > >(class std::_Locinfo const &,unsigned int)",
1153 "public: __thiscall std::num_get<unsigned short,class std::istreambuf_iterator<unsigned short,struct std::char_traits<unsigned short> > >::num_get<unsigned short,class std::istreambuf_iterator<unsigned short,struct std::char_traits<unsigned short> > >(class num_get<unsigned short,class std::istreambuf_iterator<unsigned short,struct std::char_traits<unsigned short> > >::_Locinfo const &,unsigned int)"},
1154 /* 22 */ {"??0?$num_get@GV?$istreambuf_iterator@GU?$char_traits@G@std@@@std@@@std@@QAE@I@Z", "public: __thiscall std::num_get<unsigned short,class std::istreambuf_iterator<unsigned short,struct std::char_traits<unsigned short> > >::num_get<unsigned short,class std::istreambuf_iterator<unsigned short,struct std::char_traits<unsigned short> > >(unsigned int)"},
1155 /* 23 */ {"??0streambuf@@QAE@ABV0@@Z", "public: __thiscall streambuf::streambuf(class streambuf const &)"},
1156 /* 24 */ {"??0strstreambuf@@QAE@ABV0@@Z", "public: __thiscall strstreambuf::strstreambuf(class strstreambuf const &)"},
1157 /* 25 */ {"??0strstreambuf@@QAE@H@Z", "public: __thiscall strstreambuf::strstreambuf(int)"},
1158 /* 26 */ {"??0strstreambuf@@QAE@P6APAXJ@ZP6AXPAX@Z@Z", "public: __thiscall strstreambuf::strstreambuf(void * (__cdecl*)(long),void (__cdecl*)(void *))"},
1159 /* 27 */ {"??0strstreambuf@@QAE@PADH0@Z", "public: __thiscall strstreambuf::strstreambuf(char *,int,char *)"},
1160 /* 28 */ {"??0strstreambuf@@QAE@PAEH0@Z", "public: __thiscall strstreambuf::strstreambuf(unsigned char *,int,unsigned char *)"},
1161 /* 29 */ {"??0strstreambuf@@QAE@XZ", "public: __thiscall strstreambuf::strstreambuf(void)"},
1162 /* 30 */ {"??1__non_rtti_object@std@@UAE@XZ", "public: virtual __thiscall std::__non_rtti_object::~__non_rtti_object(void)"},
1163 /* 31 */ {"??1__non_rtti_object@@UAE@XZ", "public: virtual __thiscall __non_rtti_object::~__non_rtti_object(void)"},
1164 /* 32 */ {"??1?$num_get@DV?$istreambuf_iterator@DU?$char_traits@D@std@@@std@@@std@@UAE@XZ", "public: virtual __thiscall std::num_get<char,class std::istreambuf_iterator<char,struct std::char_traits<char> > >::~num_get<char,class std::istreambuf_iterator<char,struct std::char_traits<char> > >(void)"},
1165 /* 33 */ {"??1?$num_get@GV?$istreambuf_iterator@GU?$char_traits@G@std@@@std@@@std@@UAE@XZ", "public: virtual __thiscall std::num_get<unsigned short,class std::istreambuf_iterator<unsigned short,struct std::char_traits<unsigned short> > >::~num_get<unsigned short,class std::istreambuf_iterator<unsigned short,struct std::char_traits<unsigned short> > >(void)"},
1166 /* 34 */ {"??4istream_withassign@@QAEAAV0@ABV0@@Z", "public: class istream_withassign & __thiscall istream_withassign::operator=(class istream_withassign const &)"},
1167 /* 35 */ {"??4istream_withassign@@QAEAAVistream@@ABV1@@Z", "public: class istream & __thiscall istream_withassign::operator=(class istream const &)"},
1168 /* 36 */ {"??4istream_withassign@@QAEAAVistream@@PAVstreambuf@@@Z", "public: class istream & __thiscall istream_withassign::operator=(class streambuf *)"},
1169 /* 37 */ {"??5std@@YAAAV?$basic_istream@DU?$char_traits@D@std@@@0@AAV10@AAC@Z", "class std::basic_istream<char,struct std::char_traits<char> > & __cdecl std::operator>>(class std::basic_istream<char,struct std::char_traits<char> > &,signed char &)"},
1170 /* 38 */ {"??5std@@YAAAV?$basic_istream@DU?$char_traits@D@std@@@0@AAV10@AAD@Z", "class std::basic_istream<char,struct std::char_traits<char> > & __cdecl std::operator>>(class std::basic_istream<char,struct std::char_traits<char> > &,char &)"},
1171 /* 39 */ {"??5std@@YAAAV?$basic_istream@DU?$char_traits@D@std@@@0@AAV10@AAE@Z", "class std::basic_istream<char,struct std::char_traits<char> > & __cdecl std::operator>>(class std::basic_istream<char,struct std::char_traits<char> > &,unsigned char &)"},
1172 /* 40 */ {"??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@P6AAAVios_base@1@AAV21@@Z@Z", "public: class std::basic_ostream<unsigned short,struct std::char_traits<unsigned short> > & __thiscall std::basic_ostream<unsigned short,struct std::char_traits<unsigned short> >::operator<<(class std::ios_base & (__cdecl*)(class std::ios_base &))"},
1173 /* 41 */ {"??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@PAV?$basic_streambuf@GU?$char_traits@G@std@@@1@@Z", "public: class std::basic_ostream<unsigned short,struct std::char_traits<unsigned short> > & __thiscall std::basic_ostream<unsigned short,struct std::char_traits<unsigned short> >::operator<<(class std::basic_streambuf<unsigned short,struct std::char_traits<unsigned short> > *)"},
1174 /* 42 */ {"??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@PBX@Z", "public: class std::basic_ostream<unsigned short,struct std::char_traits<unsigned short> > & __thiscall std::basic_ostream<unsigned short,struct std::char_traits<unsigned short> >::operator<<(void const *)"},
1175 /* 43 */ {"??_8?$basic_fstream@DU?$char_traits@D@std@@@std@@7B?$basic_ostream@DU?$char_traits@D@std@@@1@@", "const std::basic_fstream<char,struct std::char_traits<char> >::`vbtable'{for `std::basic_ostream<char,struct std::char_traits<char> >'}"},
1176 /* 44 */ {"??_8?$basic_fstream@GU?$char_traits@G@std@@@std@@7B?$basic_istream@GU?$char_traits@G@std@@@1@@", "const std::basic_fstream<unsigned short,struct std::char_traits<unsigned short> >::`vbtable'{for `std::basic_istream<unsigned short,struct std::char_traits<unsigned short> >'}"},
1177 /* 45 */ {"??_8?$basic_fstream@GU?$char_traits@G@std@@@std@@7B?$basic_ostream@GU?$char_traits@G@std@@@1@@", "const std::basic_fstream<unsigned short,struct std::char_traits<unsigned short> >::`vbtable'{for `std::basic_ostream<unsigned short,struct std::char_traits<unsigned short> >'}"},
1178 /* 46 */ {"??9std@@YA_NPBDABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@0@@Z", "bool __cdecl std::operator!=(char const *,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)"},
1179 /* 47 */ {"??9std@@YA_NPBGABV?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@0@@Z", "bool __cdecl std::operator!=(unsigned short const *,class std::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> > const &)"},
1180 /* 48 */ {"??A?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEAADI@Z", "public: char & __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::operator[](unsigned int)"},
1181 /* 49 */ {"??A?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QBEABDI@Z", "public: char const & __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::operator[](unsigned int)const "},
1182 /* 50 */ {"??A?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QAEAAGI@Z", "public: unsigned short & __thiscall std::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> >::operator[](unsigned int)"},
1183 /* 51 */ {"??A?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QBEABGI@Z", "public: unsigned short const & __thiscall std::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> >::operator[](unsigned int)const "},
1184 /* 52 */ {"?abs@std@@YAMABV?$complex@M@1@@Z", "float __cdecl std::abs(class std::complex<float> const &)"},
1185 /* 53 */ {"?abs@std@@YANABV?$complex@N@1@@Z", "double __cdecl std::abs(class std::complex<double> const &)"},
1186 /* 54 */ {"?abs@std@@YAOABV?$complex@O@1@@Z", "long double __cdecl std::abs(class std::complex<long double> const &)"},
1187 /* 55 */ {"?cin@std@@3V?$basic_istream@DU?$char_traits@D@std@@@1@A", "class std::basic_istream<char,struct std::char_traits<char> > std::cin"},
1188 /* 56 */ {"?do_get@?$num_get@DV?$istreambuf_iterator@DU?$char_traits@D@std@@@std@@@std@@MBE?AV?$istreambuf_iterator@DU?$char_traits@D@std@@@2@V32@0AAVios_base@2@AAHAAG@Z", "protected: virtual class std::istreambuf_iterator<char,struct std::char_traits<char> > __thiscall std::num_get<char,class std::istreambuf_iterator<char,struct std::char_traits<char> > >::do_get(class std::istreambuf_iterator<char,struct std::char_traits<char> >,class std::istreambuf_iterator<char,struct std::char_traits<char> >,class std::ios_base &,int &,unsigned short &)const "},
1189 /* 57 */ {"?do_get@?$num_get@DV?$istreambuf_iterator@DU?$char_traits@D@std@@@std@@@std@@MBE?AV?$istreambuf_iterator@DU?$char_traits@D@std@@@2@V32@0AAVios_base@2@AAHAAI@Z", "protected: virtual class std::istreambuf_iterator<char,struct std::char_traits<char> > __thiscall std::num_get<char,class std::istreambuf_iterator<char,struct std::char_traits<char> > >::do_get(class std::istreambuf_iterator<char,struct std::char_traits<char> >,class std::istreambuf_iterator<char,struct std::char_traits<char> >,class std::ios_base &,int &,unsigned int &)const "},
1190 /* 58 */ {"?do_get@?$num_get@DV?$istreambuf_iterator@DU?$char_traits@D@std@@@std@@@std@@MBE?AV?$istreambuf_iterator@DU?$char_traits@D@std@@@2@V32@0AAVios_base@2@AAHAAJ@Z", "protected: virtual class std::istreambuf_iterator<char,struct std::char_traits<char> > __thiscall std::num_get<char,class std::istreambuf_iterator<char,struct std::char_traits<char> > >::do_get(class std::istreambuf_iterator<char,struct std::char_traits<char> >,class std::istreambuf_iterator<char,struct std::char_traits<char> >,class std::ios_base &,int &,long &)const "},
1191 /* 59 */ {"?do_get@?$num_get@DV?$istreambuf_iterator@DU?$char_traits@D@std@@@std@@@std@@MBE?AV?$istreambuf_iterator@DU?$char_traits@D@std@@@2@V32@0AAVios_base@2@AAHAAK@Z", "protected: virtual class std::istreambuf_iterator<char,struct std::char_traits<char> > __thiscall std::num_get<char,class std::istreambuf_iterator<char,struct std::char_traits<char> > >::do_get(class std::istreambuf_iterator<char,struct std::char_traits<char> >,class std::istreambuf_iterator<char,struct std::char_traits<char> >,class std::ios_base &,int &,unsigned long &)const "},
1192 /* 60 */ {"?do_get@?$num_get@DV?$istreambuf_iterator@DU?$char_traits@D@std@@@std@@@std@@MBE?AV?$istreambuf_iterator@DU?$char_traits@D@std@@@2@V32@0AAVios_base@2@AAHAAM@Z", "protected: virtual class std::istreambuf_iterator<char,struct std::char_traits<char> > __thiscall std::num_get<char,class std::istreambuf_iterator<char,struct std::char_traits<char> > >::do_get(class std::istreambuf_iterator<char,struct std::char_traits<char> >,class std::istreambuf_iterator<char,struct std::char_traits<char> >,class std::ios_base &,int &,float &)const "},
1193 /* 61 */ {"?_query_new_handler@@YAP6AHI@ZXZ", "int (__cdecl*__cdecl _query_new_handler(void))(unsigned int)"},
1194 /* 62 */ {"?register_callback@ios_base@std@@QAEXP6AXW4event@12@AAV12@H@ZH@Z", "public: void __thiscall std::ios_base::register_callback(void (__cdecl*)(enum std::ios_base::event,class std::ios_base &,int),int)"},
1195 /* 63 */ {"?seekg@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@JW4seekdir@ios_base@2@@Z", "public: class std::basic_istream<char,struct std::char_traits<char> > & __thiscall std::basic_istream<char,struct std::char_traits<char> >::seekg(long,enum std::ios_base::seekdir)"},
1196 /* 64 */ {"?seekg@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@V?$fpos@H@2@@Z", "public: class std::basic_istream<char,struct std::char_traits<char> > & __thiscall std::basic_istream<char,struct std::char_traits<char> >::seekg(class std::fpos<int>)"},
1197 /* 65 */ {"?seekg@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@JW4seekdir@ios_base@2@@Z", "public: class std::basic_istream<unsigned short,struct std::char_traits<unsigned short> > & __thiscall std::basic_istream<unsigned short,struct std::char_traits<unsigned short> >::seekg(long,enum std::ios_base::seekdir)"},
1198 /* 66 */ {"?seekg@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@V?$fpos@H@2@@Z", "public: class std::basic_istream<unsigned short,struct std::char_traits<unsigned short> > & __thiscall std::basic_istream<unsigned short,struct std::char_traits<unsigned short> >::seekg(class std::fpos<int>)"},
1199 /* 67 */ {"?seekoff@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MAE?AV?$fpos@H@2@JW4seekdir@ios_base@2@H@Z", "protected: virtual class std::fpos<int> __thiscall std::basic_filebuf<char,struct std::char_traits<char> >::seekoff(long,enum std::ios_base::seekdir,int)"},
1200 /* 68 */ {"?seekoff@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MAE?AV?$fpos@H@2@JW4seekdir@ios_base@2@H@Z", "protected: virtual class std::fpos<int> __thiscall std::basic_filebuf<unsigned short,struct std::char_traits<unsigned short> >::seekoff(long,enum std::ios_base::seekdir,int)"},
1201 /* 69 */ {"?set_new_handler@@YAP6AXXZP6AXXZ@Z", "void (__cdecl*__cdecl set_new_handler(void (__cdecl*)(void)))(void)"},
1202 /* 70 */ {"?str@?$basic_istringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEXABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@2@@Z", "public: void __thiscall std::basic_istringstream<char,struct std::char_traits<char>,class std::allocator<char> >::str(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)"},
1203 /* 71 */ {"?str@?$basic_istringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QBE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@2@XZ", "public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __thiscall std::basic_istringstream<char,struct std::char_traits<char>,class std::allocator<char> >::str(void)const "},
1204 /* 72 */ {"?str@?$basic_istringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QAEXABV?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@2@@Z", "public: void __thiscall std::basic_istringstream<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> >::str(class std::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> > const &)"},
1205 /* 73 */ {"?str@?$basic_istringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QBE?AV?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@2@XZ", "public: class std::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> > __thiscall std::basic_istringstream<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> >::str(void)const "},
1206 /* 74 */ {"?str@?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEXABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@2@@Z", "public: void __thiscall std::basic_ostringstream<char,struct std::char_traits<char>,class std::allocator<char> >::str(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)"},
1207 /* 75 */ {"?str@?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QBE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@2@XZ", "public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __thiscall std::basic_ostringstream<char,struct std::char_traits<char>,class std::allocator<char> >::str(void)const "},
1208 /* 76 */ {"?str@?$basic_ostringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QAEXABV?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@2@@Z", "public: void __thiscall std::basic_ostringstream<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> >::str(class std::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> > const &)"},
1209 /* 77 */ {"?str@?$basic_ostringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QBE?AV?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@2@XZ", "public: class std::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> > __thiscall std::basic_ostringstream<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> >::str(void)const "},
1210 /* 78 */ {"?str@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEXABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@2@@Z", "public: void __thiscall std::basic_stringbuf<char,struct std::char_traits<char>,class std::allocator<char> >::str(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)"},
1211 /* 79 */ {"?str@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QBE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@2@XZ", "public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __thiscall std::basic_stringbuf<char,struct std::char_traits<char>,class std::allocator<char> >::str(void)const "},
1212 /* 80 */ {"?str@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QAEXABV?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@2@@Z", "public: void __thiscall std::basic_stringbuf<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> >::str(class std::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> > const &)"},
1213 /* 81 */ {"?str@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QBE?AV?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@2@XZ", "public: class std::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> > __thiscall std::basic_stringbuf<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> >::str(void)const "},
1214 /* 82 */ {"?str@?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEXABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@2@@Z", "public: void __thiscall std::basic_stringstream<char,struct std::char_traits<char>,class std::allocator<char> >::str(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)"},
1215 /* 83 */ {"?str@?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QBE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@2@XZ", "public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __thiscall std::basic_stringstream<char,struct std::char_traits<char>,class std::allocator<char> >::str(void)const "},
1216 /* 84 */ {"?str@?$basic_stringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QAEXABV?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@2@@Z", "public: void __thiscall std::basic_stringstream<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> >::str(class std::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> > const &)"},
1217 /* 85 */ {"?str@?$basic_stringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QBE?AV?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@2@XZ", "public: class std::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> > __thiscall std::basic_stringstream<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> >::str(void)const "},
1218 /* 86 */ {"?_Sync@ios_base@std@@0_NA", "private: static bool std::ios_base::_Sync"},
1219 /* 87 */ {"??_U@YAPAXI@Z", "void * __cdecl operator new[](unsigned int)"},
1220 /* 88 */ {"??_V@YAXPAX@Z", "void __cdecl operator delete[](void *)"},
1221 /* 89 */ {"??X?$_Complex_base@M@std@@QAEAAV01@ABM@Z", "public: class std::_Complex_base<float> & __thiscall std::_Complex_base<float>::operator*=(float const &)"},
1222 /* 90 */ {"??Xstd@@YAAAV?$complex@M@0@AAV10@ABV10@@Z", "class std::complex<float> & __cdecl std::operator*=(class std::complex<float> &,class std::complex<float> const &)"},
1223 /* 91 */ {"?aaa@@YAHAAUbbb@@@Z", "int __cdecl aaa(struct bbb &)"},
1224 /* 92 */ {"?aaa@@YAHBAUbbb@@@Z", "int __cdecl aaa(struct bbb & volatile)"},
1225 /* 93 */ {"?aaa@@YAHPAUbbb@@@Z", "int __cdecl aaa(struct bbb *)"},
1226 /* 94 */ {"?aaa@@YAHQAUbbb@@@Z", "int __cdecl aaa(struct bbb * const)"},
1227 /* 95 */ {"?aaa@@YAHRAUbbb@@@Z", "int __cdecl aaa(struct bbb * volatile)"},
1228 /* 96 */ {"?aaa@@YAHSAUbbb@@@Z", "int __cdecl aaa(struct bbb * const volatile)"},
1229 /* 97 */ {"??0aa.a@@QAE@XZ", "??0aa.a@@QAE@XZ"},
1230 /* 98 */ {"??0aa$_3a@@QAE@XZ", "public: __thiscall aa$_3a::aa$_3a(void)"},
1231 /* 99 */ {"??2?$aaa@AAUbbb@@AAUccc@@AAU2@@ddd@1eee@2@QAEHXZ", "public: int __thiscall eee::eee::ddd::ddd::aaa<struct bbb &,struct ccc &,struct ccc &>::operator new(void)"},
1232 /* 100 */ {"?pSW@@3P6GHKPAX0PAU_tagSTACKFRAME@@0P6GH0K0KPAK@ZP6GPAX0K@ZP6GK0K@ZP6GK00PAU_tagADDRESS@@@Z@ZA", "int (__stdcall* pSW)(unsigned long,void *,void *,struct _tagSTACKFRAME *,void *,int (__stdcall*)(void *,unsigned long,void *,unsigned long,unsigned long *),void * (__stdcall*)(void *,unsigned long),unsigned long (__stdcall*)(void *,unsigned long),unsigned long (__stdcall*)(void *,void *,struct _tagADDRESS *))"},
1233 /* 101 */ {"?$_aaa@Vbbb@@", "_aaa<class bbb>"},
1234 /* 102 */ {"?$aaa@Vbbb@ccc@@Vddd@2@", "aaa<class ccc::bbb,class ccc::ddd>"},
1235 /* 103 */ { "??0?$Foo@P6GHPAX0@Z@@QAE@PAD@Z", "public: __thiscall Foo<int (__stdcall*)(void *,void *)>::Foo<int (__stdcall*)(void *,void *)>(char *)"},
1236 /* 104 */ { "??0?$Foo@P6GHPAX0@Z@@QAE@PAD@Z", "__thiscall Foo<int (__stdcall*)(void *,void *)>::Foo<int (__stdcall*)(void *,void *)>(char *)", NULL, 0x880},
1237 /* 105 */ { "?Qux@Bar@@0PAP6AHPAV1@AAH1PAH@ZA", "private: static int (__cdecl** Bar::Qux)(class Bar *,int &,int &,int *)" },
1238 /* 106 */ { "?Qux@Bar@@0PAP6AHPAV1@AAH1PAH@ZA", "Bar::Qux", NULL, 0x1800},
1239 /* 107 */ {"?$AAA@$DBAB@", "AAA<`template-parameter257'>"},
1240 /* 108 */ {"?$AAA@?C@", "AAA<`template-parameter-2'>"},
1241 /* 109 */ {"?$AAA@PAUBBB@@", "AAA<struct BBB *>"},
1242 /* 110 */ {"??$ccccc@PAVaaa@@@bar@bb@foo@@DGPAV0@PAV0@PAVee@@IPAPAVaaa@@1@Z",
1243 "private: static class bar * __stdcall foo::bb::bar::ccccc<class aaa *>(class bar *,class ee *,unsigned int,class aaa * *,class ee *)",
1244 "??$ccccc@PAVaaa@@@bar@bb@foo@@DGPAV0@PAV0@PAVee@@IPAPAVaaa@@1@Z"},
1245 /* 111 */ {"?f@T@@QAEHQCY1BE@BO@D@Z", "public: int __thiscall T::f(char (volatile * const)[20][30])"},
1246 /* 112 */ {"?f@T@@QAEHQAY2BE@BO@CI@D@Z", "public: int __thiscall T::f(char (* const)[20][30][40])"},
1247 /* 113 */ {"?f@T@@QAEHQAY1BE@BO@$$CBD@Z", "public: int __thiscall T::f(char const (* const)[20][30])"},
1248 /* 114 */ {"??0?$Foo@U?$vector_c@H$00$01$0?1$0A@$0A@$0HPPPPPPP@$0HPPPPPPP@$0HPPPPPPP@$0HPPPPPPP@$0HPPPPPPP@$0HPPPPPPP@$0HPPPPPPP@$0HPPPPPPP@$0HPPPPPPP@$0HPPPPPPP@$0HPPPPPPP@$0HPPPPPPP@$0HPPPPPPP@$0HPPPPPPP@$0HPPPPPPP@@mpl@boost@@@@QAE@XZ",
1249 "public: __thiscall Foo<struct boost::mpl::vector_c<int,1,2,-2,0,0,2147483647,2147483647,2147483647,2147483647,2147483647,2147483647,2147483647,2147483647,2147483647,2147483647,2147483647,2147483647,2147483647,2147483647,2147483647> >::Foo<struct boost::mpl::vector_c<int,1,2,-2,0,0,2147483647,2147483647,2147483647,2147483647,2147483647,2147483647,2147483647,2147483647,2147483647,2147483647,2147483647,2147483647,2147483647,2147483647,2147483647> >(void)"},
1250 /* 115 */ {"?swprintf@@YAHPAGIPBGZZ", "int __cdecl swprintf(unsigned short *,unsigned int,unsigned short const *,...)"},
1251 /* 116 */ {"?vswprintf@@YAHPAGIPBGPAD@Z", "int __cdecl vswprintf(unsigned short *,unsigned int,unsigned short const *,char *)"},
1252 /* 117 */ {"?vswprintf@@YAHPA_WIPB_WPAD@Z", "int __cdecl vswprintf(wchar_t *,unsigned int,wchar_t const *,char *)"},
1253 /* 118 */ {"?swprintf@@YAHPA_WIPB_WZZ", "int __cdecl swprintf(wchar_t *,unsigned int,wchar_t const *,...)"},
1254 /* 119 */ {"??Xstd@@YAAEAV?$complex@M@0@AEAV10@AEBV10@@Z", "class std::complex<float> & __ptr64 __cdecl std::operator*=(class std::complex<float> & __ptr64,class std::complex<float> const & __ptr64)"},
1255 /* 120 */ {"?_Doraise@bad_cast@std@@MEBAXXZ", "protected: virtual void __cdecl std::bad_cast::_Doraise(void)const __ptr64"},
1256 /* 121 */ {"??$?DM@std@@YA?AV?$complex@M@0@ABMABV10@@Z",
1257 "class std::complex<float> __cdecl std::operator*<float>(float const &,class std::complex<float> const &)",
1258 "??$?DM@std@@YA?AV?$complex@M@0@ABMABV10@@Z"},
1259 /* 122 */ {"?_R2@?BN@???$_Fabs@N@std@@YANAEBV?$complex@N@1@PEAH@Z@4NB",
1260 "double const `double __cdecl std::_Fabs<double>(class std::complex<double> const & __ptr64,int * __ptr64)'::`29'::_R2",
1261 "?_R2@?BN@???$_Fabs@N@std@@YANAEBV?$complex@N@1@PEAH@Z@4NB"},
1264 int i, num_test = (sizeof(test)/sizeof(test[0]));
1267 for (i = 0; i < num_test; i++)
1269 name = p__unDName(0, test[i].in, 0, pmalloc, pfree, test[i].flags);
1270 ok(name != NULL, "%u: unDName failed\n", i);
1271 if (!name) continue;
1272 ok( !strcmp_space(test[i].out, name) ||
1273 broken(test[i].broken && !strcmp_space(test[i].broken, name)),
1274 "%u: Got name \"%s\"\n", i, name );
1275 ok( !strcmp_space(test[i].out, name) ||
1276 broken(test[i].broken && !strcmp_space(test[i].broken, name)),
1277 "%u: Expected \"%s\"\n", i, test[i].out );
1284 if (!InitFunctionPtrs())
1290 test___non_rtti_object();
1293 test_demangle_datatype();