* doc/extend.texi (Loop-Specific Pragmas): Document pragma GCC unroll.
[official-gcc.git] / gcc / testsuite / g++.dg / ext / is_base_of.C
blob8afa532e1cddb4befc4854e639081515cce5358d
1 // { dg-do run }
2 #include <cassert>
4 class A1
5
6   double a;
7   double b;  
8 };
10 class A2
11
12   double a;
13   double b;
16 class B
17 : private A1 { };
19 class C
20 : private A1, private A2 { };
22 union U
23
24   double a;
25   double b;
28 template<typename T, typename U>
29   bool
30   f()
31   { return __is_base_of(T, U); } 
33 template<typename T, typename U>
34   class My
35   {
36   public:
37     bool
38     f()
39     { return !!__is_base_of(T, U); }
40   };
42 template<typename T, typename U>
43   class My2
44   {
45   public:
46     static const bool trait = __is_base_of(T, U);
47   };
49 template<typename T, typename U>
50   const bool My2<T, U>::trait;
52 template<typename T, typename U, bool b = __is_base_of(T, U)>
53   struct My3_help
54   { static const bool trait = b; };
56 template<typename T, typename U, bool b>
57   const bool My3_help<T, U, b>::trait;
59 template<typename T, typename U>
60   class My3
61   {
62   public:
63     bool
64     f()
65     { return My3_help<T, U>::trait; }
66   };
68 #define PTEST(T, U) (__is_base_of(T, U) && f<T, U>() \
69                   && My<T, U>().f() && My2<T, U>::trait && My3<T, U>().f())
71 #define NTEST(T, U) (!__is_base_of(T, U) && !f<T, U>() \
72                   && !My<T, U>().f() && !My2<T, U>::trait && !My3<T, U>().f())
74 int main()
76   assert (NTEST (int, A1));
77   assert (NTEST (A1, void));
78   assert (PTEST (A1, A1));
79   assert (NTEST (A1*, A1*));
80   assert (NTEST (A1&, A1&));
81   assert (PTEST (A1, B));
82   assert (NTEST (B, A1));
83   assert (PTEST (A1, C));
84   assert (PTEST (A2, C));
85   assert (NTEST (C, A1));
86   assert (PTEST (A1, const B));
87   assert (NTEST (const B, A1));
88   assert (PTEST (A1, volatile C));
89   assert (PTEST (volatile A2, const C));
90   assert (NTEST (const volatile C, A1));
91   assert (NTEST (U, U));
93   return 0;