OSDN Git Service

* g++.dg/ext/altivec-17.C: Adjust error message.
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / g++.dg / ext / has_nothrow_copy-1.C
1 // { dg-do "run" }
2 #include <cassert>
3
4 struct A
5 {
6   double a;
7   double b;
8 };
9
10 struct B
11 {
12   A a;
13 };
14
15 struct C
16 : public A { };
17
18 struct D
19 {
20   D(const D&) throw() { }
21 };
22
23 struct E
24 {
25   E(const E&) throw(int) { }
26 };
27
28 struct E1
29 {
30   E1(const E1&) throw(int) { throw int(); }
31 };
32
33 struct F
34 {
35   F() throw() { }
36 };
37
38 struct G
39 {
40   G() throw(int) { throw int(); }
41 };
42
43 struct H
44 {
45   H(H&) throw(int) { }
46 };
47
48 struct H1
49 {
50   H1(H1&) throw(int) { throw int(); }
51 };
52
53 struct I
54 {
55   I(I&) throw(int) { }
56   I(const I&) throw() { }
57 };
58
59 struct I1
60 {
61   I1(I1&) throw(int) { throw int(); }
62   I1(const I1&) throw() { }
63 };
64
65 struct J
66 {
67   J(J&) throw() { }
68   J(const J&) throw() { }
69   J(volatile J&) throw() { }
70   J(const volatile J&) throw() { }
71 };
72
73 template<typename T>
74   bool
75   f()
76   { return __has_nothrow_copy(T); } 
77
78 template<typename T>
79   class My
80   {
81   public:
82     bool
83     f()
84     { return !!__has_nothrow_copy(T); }
85   };
86
87 template<typename T>
88   class My2
89   {
90   public:
91     static const bool trait = __has_nothrow_copy(T);
92   };
93
94 template<typename T>
95   const bool My2<T>::trait;
96
97 template<typename T, bool b = __has_nothrow_copy(T)>
98   struct My3_help
99   { static const bool trait = b; };
100
101 template<typename T, bool b>
102   const bool My3_help<T, b>::trait;
103
104 template<typename T>
105   class My3
106   {
107   public:
108     bool
109     f()
110     { return My3_help<T>::trait; }
111   };
112
113 #define PTEST(T) (__has_nothrow_copy(T) && f<T>() \
114                   && My<T>().f() && My2<T>::trait && My3<T>().f())
115
116 #define NTEST(T) (!__has_nothrow_copy(T) && !f<T>() \
117                   && !My<T>().f() && !My2<T>::trait && !My3<T>().f())
118
119 int main()
120 {
121   assert (PTEST (int));
122   assert (NTEST (int (int)));
123   assert (NTEST (void));
124   assert (PTEST (A));
125   assert (PTEST (B));
126   assert (PTEST (C));
127   assert (PTEST (C[]));
128   assert (PTEST (D));
129   assert (NTEST (E));
130   assert (NTEST (E1));
131   assert (PTEST (F));
132   assert (PTEST (G));
133   assert (NTEST (H));
134   assert (NTEST (H1));
135   assert (NTEST (I));
136   assert (NTEST (I1));  
137   assert (PTEST (J));
138
139   return 0;
140 }