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