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