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>
5
6#include <typeinfo>
7
8#if defined (__GXX_ABI_VERSION) && __GXX_ABI_VERSION >= 100
9#include <cxxabi.h>
10
11struct A {int m;};
12struct B;
13
14using namespace abi;
15
16int expect (int flags, std::type_info const &info)
17{
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;
25}
26
27int main ()
28{
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;
41
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;
60}
61
62#else
63int main ()
64{
65  return 0;
66}
67#endif
68