1 // Test rtti hint flags
2 // Copyright (C) 2000 Free Software Foundation, Inc.
3 // Contributed by Nathan Sidwell 3 Apr 2000 <nathan@nathan@codesourcery.com>
4
5 #include <typeinfo>
6
7 #if defined (__GXX_ABI_VERSION) && __GXX_ABI_VERSION >= 100
8 #include <cxxabi.h>
9
10 struct A {int m;};
11 struct A1vA : virtual A {int m;};
12 struct A2vA : virtual A {int m;};
13 struct A1A : A {int m;};
14 struct A2A : A {int m;};
15 struct B {int m;};
16
17 struct C1 : B, virtual A {int m;};
18
19 struct D1 : A1vA, A2vA {int m;};
20
21 struct E1 : A1A, A2A {int m;};
22
23 struct E2 : A1A, A2vA {int m;};
24
25 struct F1 : A1A, A1vA, A2vA {int m;};
26
27 struct P1 : protected A {int m;};
28
29 struct P2 : B, P1 {int m;};
30
31 using namespace abi;
32
expect(int flags,std::type_info const & info)33 int expect (int flags, std::type_info const &info)
34 {
35 abi::__vmi_class_type_info const *ptr =
36 dynamic_cast <abi::__vmi_class_type_info const *> (&info);
37 if (!ptr)
38 return 0;
39 if (ptr->__flags != flags)
40 return 0;
41 return 1;
42 }
43
main()44 int main ()
45 {
46 if (! expect (0 | 8, typeid (C1)))
47 return 1;
48 if (! expect (2 | 8, typeid (D1)))
49 return 2;
50 if (! expect (1 | 8, typeid (E1)))
51 return 3;
52 if (! expect (1 | 8, typeid (E2)))
53 return 4;
54 if (! expect (3 | 8, typeid (F1)))
55 return 5;
56
57 if (!expect (4, typeid (P1)))
58 return 6;
59 if (!expect (12, typeid (P2)))
60 return 7;
61
62 return 0;
63 }
64
65 #else
main()66 int main ()
67 {
68 return 0;
69 }
70 #endif
71