* doc/extend.texi (Loop-Specific Pragmas): Document pragma GCC unroll.
[official-gcc.git] / gcc / testsuite / g++.dg / ext / has_trivial_constructor.C
blobf4addd82446fcc6325477f6ab081b678cee3feb8
1 // { dg-do run }
2 #include <cassert>
4 struct A
6   double a;
7   double b;
8 };
10 union U
12   double a;
13   double b;  
16 struct B
18   B() { }
21 struct C 
22 : public B { };
24 struct D
25 : public A { };
27 struct E
29   A a;
32 struct F
34   B b;
37 template<typename T>
38   bool
39   f()
40   { return __has_trivial_constructor(T); } 
42 template<typename T>
43   class My
44   {
45   public:
46     bool
47     f()
48     { return !!__has_trivial_constructor(T); }
49   };
51 template<typename T>
52   class My2
53   {
54   public:
55     static const bool trait = __has_trivial_constructor(T);
56   };
58 template<typename T>
59   const bool My2<T>::trait;
61 template<typename T, bool b = __has_trivial_constructor(T)>
62   struct My3_help
63   { static const bool trait = b; };
65 template<typename T, bool b>
66   const bool My3_help<T, b>::trait;
68 template<typename T>
69   class My3
70   {
71   public:
72     bool
73     f()
74     { return My3_help<T>::trait; }
75   };
77 #define PTEST(T) (__has_trivial_constructor(T) && f<T>() \
78                   && My<T>().f() && My2<T>::trait && My3<T>().f())
80 #define NTEST(T) (!__has_trivial_constructor(T) && !f<T>() \
81                   && !My<T>().f() && !My2<T>::trait && !My3<T>().f())
83 int main()
85   assert (PTEST (int));
86   assert (NTEST (int (int)));
87   assert (NTEST (void));
88   assert (PTEST (A));
89   assert (PTEST (U));
90   assert (NTEST (B));
91   assert (NTEST (C));
92   assert (PTEST (D));
93   assert (PTEST (D[]));
94   assert (PTEST (E));
95   assert (NTEST (F));
97   return 0;