Richard Smith | 7a614d8 | 2011-06-11 17:19:42 +0000 | [diff] [blame^] | 1 | // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -verify -std=gnu++0x %s |
Sebastian Redl | 64b45f7 | 2009-01-05 20:52:13 +0000 | [diff] [blame] | 2 | #define T(b) (b) ? 1 : -1 |
| 3 | #define F(b) (b) ? -1 : 1 |
| 4 | |
| 5 | struct NonPOD { NonPOD(int); }; |
| 6 | |
| 7 | // PODs |
| 8 | enum Enum { EV }; |
| 9 | struct POD { Enum e; int i; float f; NonPOD* p; }; |
Eli Friedman | 1d954f6 | 2009-08-15 21:55:26 +0000 | [diff] [blame] | 10 | struct Empty {}; |
| 11 | typedef Empty EmptyAr[10]; |
Sebastian Redl | 64b45f7 | 2009-01-05 20:52:13 +0000 | [diff] [blame] | 12 | typedef int Int; |
| 13 | typedef Int IntAr[10]; |
Sebastian Redl | 607a178 | 2010-09-08 00:48:43 +0000 | [diff] [blame] | 14 | typedef Int IntArNB[]; |
Sebastian Redl | 64b45f7 | 2009-01-05 20:52:13 +0000 | [diff] [blame] | 15 | class Statics { static int priv; static NonPOD np; }; |
Eli Friedman | 1d954f6 | 2009-08-15 21:55:26 +0000 | [diff] [blame] | 16 | union EmptyUnion {}; |
| 17 | union Union { int i; float f; }; |
| 18 | struct HasFunc { void f (); }; |
| 19 | struct HasOp { void operator *(); }; |
| 20 | struct HasConv { operator int(); }; |
| 21 | struct HasAssign { void operator =(int); }; |
Sebastian Redl | 64b45f7 | 2009-01-05 20:52:13 +0000 | [diff] [blame] | 22 | |
Douglas Gregor | 2cf9d65 | 2010-09-28 20:38:10 +0000 | [diff] [blame] | 23 | struct HasAnonymousUnion { |
| 24 | union { |
| 25 | int i; |
| 26 | float f; |
| 27 | }; |
| 28 | }; |
| 29 | |
Chandler Carruth | 25df423 | 2011-04-30 10:46:26 +0000 | [diff] [blame] | 30 | typedef int Vector __attribute__((vector_size(16))); |
| 31 | typedef int VectorExt __attribute__((ext_vector_type(4))); |
| 32 | |
Sebastian Redl | 64b45f7 | 2009-01-05 20:52:13 +0000 | [diff] [blame] | 33 | // Not PODs |
Sebastian Redl | 607a178 | 2010-09-08 00:48:43 +0000 | [diff] [blame] | 34 | typedef const void cvoid; |
Sebastian Redl | 64b45f7 | 2009-01-05 20:52:13 +0000 | [diff] [blame] | 35 | struct Derives : POD {}; |
Chandler Carruth | 34eaaa5 | 2011-04-23 20:51:39 +0000 | [diff] [blame] | 36 | typedef Derives DerivesAr[10]; |
| 37 | typedef Derives DerivesArNB[]; |
Eli Friedman | 1d954f6 | 2009-08-15 21:55:26 +0000 | [diff] [blame] | 38 | struct DerivesEmpty : Empty {}; |
Sebastian Redl | 64b45f7 | 2009-01-05 20:52:13 +0000 | [diff] [blame] | 39 | struct HasCons { HasCons(int); }; |
Eli Friedman | 1d954f6 | 2009-08-15 21:55:26 +0000 | [diff] [blame] | 40 | struct HasCopyAssign { HasCopyAssign operator =(const HasCopyAssign&); }; |
Richard Smith | 7a614d8 | 2011-06-11 17:19:42 +0000 | [diff] [blame^] | 41 | struct HasMoveAssign { HasMoveAssign operator =(const HasMoveAssign&&); }; |
Sebastian Redl | 64b45f7 | 2009-01-05 20:52:13 +0000 | [diff] [blame] | 42 | struct HasDest { ~HasDest(); }; |
| 43 | class HasPriv { int priv; }; |
| 44 | class HasProt { protected: int prot; }; |
| 45 | struct HasRef { int i; int& ref; HasRef() : i(0), ref(i) {} }; |
| 46 | struct HasNonPOD { NonPOD np; }; |
| 47 | struct HasVirt { virtual void Virt() {}; }; |
Chandler Carruth | 34eaaa5 | 2011-04-23 20:51:39 +0000 | [diff] [blame] | 48 | typedef NonPOD NonPODAr[10]; |
Douglas Gregor | 5e03f9e | 2009-07-23 23:49:00 +0000 | [diff] [blame] | 49 | typedef HasVirt VirtAr[10]; |
Chandler Carruth | 34eaaa5 | 2011-04-23 20:51:39 +0000 | [diff] [blame] | 50 | typedef NonPOD NonPODArNB[]; |
Eli Friedman | 1d954f6 | 2009-08-15 21:55:26 +0000 | [diff] [blame] | 51 | union NonPODUnion { int i; Derives n; }; |
Chandler Carruth | c69f636 | 2011-04-23 21:02:37 +0000 | [diff] [blame] | 52 | struct DerivesHasCons : HasCons {}; |
| 53 | struct DerivesHasCopyAssign : HasCopyAssign {}; |
Chandler Carruth | 4d6e5a2 | 2011-04-23 23:10:33 +0000 | [diff] [blame] | 54 | struct DerivesHasMoveAssign : HasMoveAssign {}; |
Chandler Carruth | c69f636 | 2011-04-23 21:02:37 +0000 | [diff] [blame] | 55 | struct DerivesHasDest : HasDest {}; |
| 56 | struct DerivesHasPriv : HasPriv {}; |
| 57 | struct DerivesHasProt : HasProt {}; |
| 58 | struct DerivesHasRef : HasRef {}; |
| 59 | struct DerivesHasVirt : HasVirt {}; |
Sebastian Redl | 64b45f7 | 2009-01-05 20:52:13 +0000 | [diff] [blame] | 60 | |
Sebastian Redl | c238f09 | 2010-08-31 04:59:00 +0000 | [diff] [blame] | 61 | struct HasNoThrowCopyAssign { |
| 62 | void operator =(const HasNoThrowCopyAssign&) throw(); |
| 63 | }; |
| 64 | struct HasMultipleCopyAssign { |
| 65 | void operator =(const HasMultipleCopyAssign&) throw(); |
| 66 | void operator =(volatile HasMultipleCopyAssign&); |
| 67 | }; |
| 68 | struct HasMultipleNoThrowCopyAssign { |
| 69 | void operator =(const HasMultipleNoThrowCopyAssign&) throw(); |
| 70 | void operator =(volatile HasMultipleNoThrowCopyAssign&) throw(); |
| 71 | }; |
| 72 | |
| 73 | struct HasNoThrowConstructor { HasNoThrowConstructor() throw(); }; |
| 74 | struct HasNoThrowConstructorWithArgs { |
| 75 | HasNoThrowConstructorWithArgs(HasCons i = HasCons(0)) throw(); |
| 76 | }; |
| 77 | |
| 78 | struct HasNoThrowCopy { HasNoThrowCopy(const HasNoThrowCopy&) throw(); }; |
| 79 | struct HasMultipleCopy { |
| 80 | HasMultipleCopy(const HasMultipleCopy&) throw(); |
| 81 | HasMultipleCopy(volatile HasMultipleCopy&); |
| 82 | }; |
| 83 | struct HasMultipleNoThrowCopy { |
| 84 | HasMultipleNoThrowCopy(const HasMultipleNoThrowCopy&) throw(); |
| 85 | HasMultipleNoThrowCopy(volatile HasMultipleNoThrowCopy&) throw(); |
| 86 | }; |
| 87 | |
Sebastian Redl | d4b25cb | 2010-09-02 23:19:42 +0000 | [diff] [blame] | 88 | struct HasVirtDest { virtual ~HasVirtDest(); }; |
| 89 | struct DerivedVirtDest : HasVirtDest {}; |
| 90 | typedef HasVirtDest VirtDestAr[1]; |
| 91 | |
Sebastian Redl | 64b45f7 | 2009-01-05 20:52:13 +0000 | [diff] [blame] | 92 | void is_pod() |
| 93 | { |
Chandler Carruth | e567e83 | 2011-04-23 20:51:37 +0000 | [diff] [blame] | 94 | { int arr[T(__is_pod(int))]; } |
| 95 | { int arr[T(__is_pod(Enum))]; } |
| 96 | { int arr[T(__is_pod(POD))]; } |
| 97 | { int arr[T(__is_pod(Int))]; } |
| 98 | { int arr[T(__is_pod(IntAr))]; } |
| 99 | { int arr[T(__is_pod(Statics))]; } |
| 100 | { int arr[T(__is_pod(Empty))]; } |
| 101 | { int arr[T(__is_pod(EmptyUnion))]; } |
| 102 | { int arr[T(__is_pod(Union))]; } |
| 103 | { int arr[T(__is_pod(HasFunc))]; } |
| 104 | { int arr[T(__is_pod(HasOp))]; } |
| 105 | { int arr[T(__is_pod(HasConv))]; } |
| 106 | { int arr[T(__is_pod(HasAssign))]; } |
| 107 | { int arr[T(__is_pod(IntArNB))]; } |
| 108 | { int arr[T(__is_pod(HasAnonymousUnion))]; } |
Chandler Carruth | 25df423 | 2011-04-30 10:46:26 +0000 | [diff] [blame] | 109 | { int arr[T(__is_pod(Vector))]; } |
| 110 | { int arr[T(__is_pod(VectorExt))]; } |
Sebastian Redl | 64b45f7 | 2009-01-05 20:52:13 +0000 | [diff] [blame] | 111 | |
Chandler Carruth | e567e83 | 2011-04-23 20:51:37 +0000 | [diff] [blame] | 112 | { int arr[F(__is_pod(Derives))]; } |
Chandler Carruth | 34eaaa5 | 2011-04-23 20:51:39 +0000 | [diff] [blame] | 113 | { int arr[F(__is_pod(DerivesAr))]; } |
| 114 | { int arr[F(__is_pod(DerivesArNB))]; } |
| 115 | { int arr[F(__is_pod(DerivesEmpty))]; } |
Chandler Carruth | e567e83 | 2011-04-23 20:51:37 +0000 | [diff] [blame] | 116 | { int arr[F(__is_pod(HasCons))]; } |
| 117 | { int arr[F(__is_pod(HasCopyAssign))]; } |
Chandler Carruth | 4d6e5a2 | 2011-04-23 23:10:33 +0000 | [diff] [blame] | 118 | { int arr[F(__is_pod(HasMoveAssign))]; } |
Chandler Carruth | e567e83 | 2011-04-23 20:51:37 +0000 | [diff] [blame] | 119 | { int arr[F(__is_pod(HasDest))]; } |
| 120 | { int arr[F(__is_pod(HasPriv))]; } |
| 121 | { int arr[F(__is_pod(HasProt))]; } |
| 122 | { int arr[F(__is_pod(HasRef))]; } |
Chandler Carruth | e567e83 | 2011-04-23 20:51:37 +0000 | [diff] [blame] | 123 | { int arr[F(__is_pod(HasVirt))]; } |
Chandler Carruth | c69f636 | 2011-04-23 21:02:37 +0000 | [diff] [blame] | 124 | { int arr[F(__is_pod(DerivesHasCons))]; } |
| 125 | { int arr[F(__is_pod(DerivesHasCopyAssign))]; } |
Chandler Carruth | 4d6e5a2 | 2011-04-23 23:10:33 +0000 | [diff] [blame] | 126 | { int arr[F(__is_pod(DerivesHasMoveAssign))]; } |
Chandler Carruth | c69f636 | 2011-04-23 21:02:37 +0000 | [diff] [blame] | 127 | { int arr[F(__is_pod(DerivesHasDest))]; } |
| 128 | { int arr[F(__is_pod(DerivesHasPriv))]; } |
| 129 | { int arr[F(__is_pod(DerivesHasProt))]; } |
| 130 | { int arr[F(__is_pod(DerivesHasRef))]; } |
| 131 | { int arr[F(__is_pod(DerivesHasVirt))]; } |
Chandler Carruth | 34eaaa5 | 2011-04-23 20:51:39 +0000 | [diff] [blame] | 132 | { int arr[F(__is_pod(NonPOD))]; } |
| 133 | { int arr[F(__is_pod(HasNonPOD))]; } |
Chandler Carruth | e567e83 | 2011-04-23 20:51:37 +0000 | [diff] [blame] | 134 | { int arr[F(__is_pod(NonPODAr))]; } |
Chandler Carruth | 34eaaa5 | 2011-04-23 20:51:39 +0000 | [diff] [blame] | 135 | { int arr[F(__is_pod(NonPODArNB))]; } |
Chandler Carruth | e567e83 | 2011-04-23 20:51:37 +0000 | [diff] [blame] | 136 | { int arr[F(__is_pod(void))]; } |
| 137 | { int arr[F(__is_pod(cvoid))]; } |
Chandler Carruth | e567e83 | 2011-04-23 20:51:37 +0000 | [diff] [blame] | 138 | // { int arr[F(__is_pod(NonPODUnion))]; } |
Sebastian Redl | 64b45f7 | 2009-01-05 20:52:13 +0000 | [diff] [blame] | 139 | } |
| 140 | |
Eli Friedman | 1d954f6 | 2009-08-15 21:55:26 +0000 | [diff] [blame] | 141 | typedef Empty EmptyAr[10]; |
| 142 | struct Bit0 { int : 0; }; |
| 143 | struct Bit0Cons { int : 0; Bit0Cons(); }; |
| 144 | struct BitOnly { int x : 3; }; |
| 145 | //struct DerivesVirt : virtual POD {}; |
| 146 | |
| 147 | void is_empty() |
| 148 | { |
Chandler Carruth | e567e83 | 2011-04-23 20:51:37 +0000 | [diff] [blame] | 149 | { int arr[T(__is_empty(Empty))]; } |
| 150 | { int arr[T(__is_empty(DerivesEmpty))]; } |
| 151 | { int arr[T(__is_empty(HasCons))]; } |
| 152 | { int arr[T(__is_empty(HasCopyAssign))]; } |
Chandler Carruth | 4d6e5a2 | 2011-04-23 23:10:33 +0000 | [diff] [blame] | 153 | { int arr[T(__is_empty(HasMoveAssign))]; } |
Chandler Carruth | e567e83 | 2011-04-23 20:51:37 +0000 | [diff] [blame] | 154 | { int arr[T(__is_empty(HasDest))]; } |
| 155 | { int arr[T(__is_empty(HasFunc))]; } |
| 156 | { int arr[T(__is_empty(HasOp))]; } |
| 157 | { int arr[T(__is_empty(HasConv))]; } |
| 158 | { int arr[T(__is_empty(HasAssign))]; } |
| 159 | { int arr[T(__is_empty(Bit0))]; } |
| 160 | { int arr[T(__is_empty(Bit0Cons))]; } |
Eli Friedman | 1d954f6 | 2009-08-15 21:55:26 +0000 | [diff] [blame] | 161 | |
Chandler Carruth | e567e83 | 2011-04-23 20:51:37 +0000 | [diff] [blame] | 162 | { int arr[F(__is_empty(Int))]; } |
| 163 | { int arr[F(__is_empty(POD))]; } |
| 164 | { int arr[F(__is_empty(EmptyUnion))]; } |
| 165 | { int arr[F(__is_empty(EmptyAr))]; } |
| 166 | { int arr[F(__is_empty(HasRef))]; } |
| 167 | { int arr[F(__is_empty(HasVirt))]; } |
| 168 | { int arr[F(__is_empty(BitOnly))]; } |
| 169 | { int arr[F(__is_empty(void))]; } |
| 170 | { int arr[F(__is_empty(IntArNB))]; } |
| 171 | { int arr[F(__is_empty(HasAnonymousUnion))]; } |
| 172 | // { int arr[F(__is_empty(DerivesVirt))]; } |
Eli Friedman | 1d954f6 | 2009-08-15 21:55:26 +0000 | [diff] [blame] | 173 | } |
| 174 | |
Sebastian Redl | 64b45f7 | 2009-01-05 20:52:13 +0000 | [diff] [blame] | 175 | typedef Derives ClassType; |
| 176 | |
| 177 | void is_class() |
| 178 | { |
Chandler Carruth | e567e83 | 2011-04-23 20:51:37 +0000 | [diff] [blame] | 179 | { int arr[T(__is_class(Derives))]; } |
| 180 | { int arr[T(__is_class(HasPriv))]; } |
| 181 | { int arr[T(__is_class(ClassType))]; } |
| 182 | { int arr[T(__is_class(HasAnonymousUnion))]; } |
Sebastian Redl | 64b45f7 | 2009-01-05 20:52:13 +0000 | [diff] [blame] | 183 | |
Chandler Carruth | e567e83 | 2011-04-23 20:51:37 +0000 | [diff] [blame] | 184 | { int arr[F(__is_class(int))]; } |
| 185 | { int arr[F(__is_class(Enum))]; } |
| 186 | { int arr[F(__is_class(Int))]; } |
| 187 | { int arr[F(__is_class(IntAr))]; } |
Chandler Carruth | 34eaaa5 | 2011-04-23 20:51:39 +0000 | [diff] [blame] | 188 | { int arr[F(__is_class(DerivesAr))]; } |
Chandler Carruth | e567e83 | 2011-04-23 20:51:37 +0000 | [diff] [blame] | 189 | { int arr[F(__is_class(Union))]; } |
| 190 | { int arr[F(__is_class(cvoid))]; } |
| 191 | { int arr[F(__is_class(IntArNB))]; } |
Sebastian Redl | 64b45f7 | 2009-01-05 20:52:13 +0000 | [diff] [blame] | 192 | } |
| 193 | |
| 194 | typedef Union UnionAr[10]; |
| 195 | typedef Union UnionType; |
| 196 | |
| 197 | void is_union() |
| 198 | { |
Chandler Carruth | e567e83 | 2011-04-23 20:51:37 +0000 | [diff] [blame] | 199 | { int arr[T(__is_union(Union))]; } |
| 200 | { int arr[T(__is_union(UnionType))]; } |
Sebastian Redl | 64b45f7 | 2009-01-05 20:52:13 +0000 | [diff] [blame] | 201 | |
Chandler Carruth | e567e83 | 2011-04-23 20:51:37 +0000 | [diff] [blame] | 202 | { int arr[F(__is_union(int))]; } |
| 203 | { int arr[F(__is_union(Enum))]; } |
| 204 | { int arr[F(__is_union(Int))]; } |
| 205 | { int arr[F(__is_union(IntAr))]; } |
| 206 | { int arr[F(__is_union(UnionAr))]; } |
| 207 | { int arr[F(__is_union(cvoid))]; } |
| 208 | { int arr[F(__is_union(IntArNB))]; } |
| 209 | { int arr[F(__is_union(HasAnonymousUnion))]; } |
Sebastian Redl | 64b45f7 | 2009-01-05 20:52:13 +0000 | [diff] [blame] | 210 | } |
| 211 | |
| 212 | typedef Enum EnumType; |
| 213 | |
| 214 | void is_enum() |
| 215 | { |
Chandler Carruth | e567e83 | 2011-04-23 20:51:37 +0000 | [diff] [blame] | 216 | { int arr[T(__is_enum(Enum))]; } |
| 217 | { int arr[T(__is_enum(EnumType))]; } |
Sebastian Redl | 64b45f7 | 2009-01-05 20:52:13 +0000 | [diff] [blame] | 218 | |
Chandler Carruth | e567e83 | 2011-04-23 20:51:37 +0000 | [diff] [blame] | 219 | { int arr[F(__is_enum(int))]; } |
| 220 | { int arr[F(__is_enum(Union))]; } |
| 221 | { int arr[F(__is_enum(Int))]; } |
| 222 | { int arr[F(__is_enum(IntAr))]; } |
| 223 | { int arr[F(__is_enum(UnionAr))]; } |
| 224 | { int arr[F(__is_enum(Derives))]; } |
| 225 | { int arr[F(__is_enum(ClassType))]; } |
| 226 | { int arr[F(__is_enum(cvoid))]; } |
| 227 | { int arr[F(__is_enum(IntArNB))]; } |
| 228 | { int arr[F(__is_enum(HasAnonymousUnion))]; } |
Sebastian Redl | 64b45f7 | 2009-01-05 20:52:13 +0000 | [diff] [blame] | 229 | } |
| 230 | |
Eli Friedman | 1d954f6 | 2009-08-15 21:55:26 +0000 | [diff] [blame] | 231 | typedef HasVirt Polymorph; |
Sebastian Redl | 64b45f7 | 2009-01-05 20:52:13 +0000 | [diff] [blame] | 232 | struct InheritPolymorph : Polymorph {}; |
| 233 | |
| 234 | void is_polymorphic() |
| 235 | { |
Chandler Carruth | e567e83 | 2011-04-23 20:51:37 +0000 | [diff] [blame] | 236 | { int arr[T(__is_polymorphic(Polymorph))]; } |
| 237 | { int arr[T(__is_polymorphic(InheritPolymorph))]; } |
Sebastian Redl | 64b45f7 | 2009-01-05 20:52:13 +0000 | [diff] [blame] | 238 | |
Chandler Carruth | e567e83 | 2011-04-23 20:51:37 +0000 | [diff] [blame] | 239 | { int arr[F(__is_polymorphic(int))]; } |
| 240 | { int arr[F(__is_polymorphic(Union))]; } |
| 241 | { int arr[F(__is_polymorphic(Int))]; } |
| 242 | { int arr[F(__is_polymorphic(IntAr))]; } |
| 243 | { int arr[F(__is_polymorphic(UnionAr))]; } |
| 244 | { int arr[F(__is_polymorphic(Derives))]; } |
| 245 | { int arr[F(__is_polymorphic(ClassType))]; } |
| 246 | { int arr[F(__is_polymorphic(Enum))]; } |
| 247 | { int arr[F(__is_polymorphic(cvoid))]; } |
| 248 | { int arr[F(__is_polymorphic(IntArNB))]; } |
Sebastian Redl | 64b45f7 | 2009-01-05 20:52:13 +0000 | [diff] [blame] | 249 | } |
Douglas Gregor | 5e03f9e | 2009-07-23 23:49:00 +0000 | [diff] [blame] | 250 | |
John Wiegley | 20c0da7 | 2011-04-27 23:09:49 +0000 | [diff] [blame] | 251 | void is_integral() |
| 252 | { |
| 253 | int t01[T(__is_integral(bool))]; |
| 254 | int t02[T(__is_integral(char))]; |
| 255 | int t03[T(__is_integral(signed char))]; |
| 256 | int t04[T(__is_integral(unsigned char))]; |
| 257 | //int t05[T(__is_integral(char16_t))]; |
| 258 | //int t06[T(__is_integral(char32_t))]; |
| 259 | int t07[T(__is_integral(wchar_t))]; |
| 260 | int t08[T(__is_integral(short))]; |
| 261 | int t09[T(__is_integral(unsigned short))]; |
| 262 | int t10[T(__is_integral(int))]; |
| 263 | int t11[T(__is_integral(unsigned int))]; |
| 264 | int t12[T(__is_integral(long))]; |
| 265 | int t13[T(__is_integral(unsigned long))]; |
| 266 | |
| 267 | int t21[F(__is_integral(float))]; |
| 268 | int t22[F(__is_integral(double))]; |
| 269 | int t23[F(__is_integral(long double))]; |
| 270 | int t24[F(__is_integral(Union))]; |
| 271 | int t25[F(__is_integral(UnionAr))]; |
| 272 | int t26[F(__is_integral(Derives))]; |
| 273 | int t27[F(__is_integral(ClassType))]; |
| 274 | int t28[F(__is_integral(Enum))]; |
| 275 | int t29[F(__is_integral(void))]; |
| 276 | int t30[F(__is_integral(cvoid))]; |
| 277 | int t31[F(__is_integral(IntArNB))]; |
| 278 | } |
| 279 | |
| 280 | void is_floating_point() |
| 281 | { |
| 282 | int t01[T(__is_floating_point(float))]; |
| 283 | int t02[T(__is_floating_point(double))]; |
| 284 | int t03[T(__is_floating_point(long double))]; |
| 285 | |
| 286 | int t11[F(__is_floating_point(bool))]; |
| 287 | int t12[F(__is_floating_point(char))]; |
| 288 | int t13[F(__is_floating_point(signed char))]; |
| 289 | int t14[F(__is_floating_point(unsigned char))]; |
| 290 | //int t15[F(__is_floating_point(char16_t))]; |
| 291 | //int t16[F(__is_floating_point(char32_t))]; |
| 292 | int t17[F(__is_floating_point(wchar_t))]; |
| 293 | int t18[F(__is_floating_point(short))]; |
| 294 | int t19[F(__is_floating_point(unsigned short))]; |
| 295 | int t20[F(__is_floating_point(int))]; |
| 296 | int t21[F(__is_floating_point(unsigned int))]; |
| 297 | int t22[F(__is_floating_point(long))]; |
| 298 | int t23[F(__is_floating_point(unsigned long))]; |
| 299 | int t24[F(__is_floating_point(Union))]; |
| 300 | int t25[F(__is_floating_point(UnionAr))]; |
| 301 | int t26[F(__is_floating_point(Derives))]; |
| 302 | int t27[F(__is_floating_point(ClassType))]; |
| 303 | int t28[F(__is_floating_point(Enum))]; |
| 304 | int t29[F(__is_floating_point(void))]; |
| 305 | int t30[F(__is_floating_point(cvoid))]; |
| 306 | int t31[F(__is_floating_point(IntArNB))]; |
| 307 | } |
| 308 | |
| 309 | void is_arithmetic() |
| 310 | { |
| 311 | int t01[T(__is_arithmetic(float))]; |
| 312 | int t02[T(__is_arithmetic(double))]; |
| 313 | int t03[T(__is_arithmetic(long double))]; |
| 314 | int t11[T(__is_arithmetic(bool))]; |
| 315 | int t12[T(__is_arithmetic(char))]; |
| 316 | int t13[T(__is_arithmetic(signed char))]; |
| 317 | int t14[T(__is_arithmetic(unsigned char))]; |
| 318 | //int t15[T(__is_arithmetic(char16_t))]; |
| 319 | //int t16[T(__is_arithmetic(char32_t))]; |
| 320 | int t17[T(__is_arithmetic(wchar_t))]; |
| 321 | int t18[T(__is_arithmetic(short))]; |
| 322 | int t19[T(__is_arithmetic(unsigned short))]; |
| 323 | int t20[T(__is_arithmetic(int))]; |
| 324 | int t21[T(__is_arithmetic(unsigned int))]; |
| 325 | int t22[T(__is_arithmetic(long))]; |
| 326 | int t23[T(__is_arithmetic(unsigned long))]; |
| 327 | |
| 328 | int t24[F(__is_arithmetic(Union))]; |
| 329 | int t25[F(__is_arithmetic(UnionAr))]; |
| 330 | int t26[F(__is_arithmetic(Derives))]; |
| 331 | int t27[F(__is_arithmetic(ClassType))]; |
| 332 | int t28[F(__is_arithmetic(Enum))]; |
| 333 | int t29[F(__is_arithmetic(void))]; |
| 334 | int t30[F(__is_arithmetic(cvoid))]; |
| 335 | int t31[F(__is_arithmetic(IntArNB))]; |
| 336 | } |
| 337 | |
| 338 | struct ACompleteType {}; |
| 339 | struct AnIncompleteType; |
| 340 | |
| 341 | void is_complete_type() |
| 342 | { |
| 343 | int t01[T(__is_complete_type(float))]; |
| 344 | int t02[T(__is_complete_type(double))]; |
| 345 | int t03[T(__is_complete_type(long double))]; |
| 346 | int t11[T(__is_complete_type(bool))]; |
| 347 | int t12[T(__is_complete_type(char))]; |
| 348 | int t13[T(__is_complete_type(signed char))]; |
| 349 | int t14[T(__is_complete_type(unsigned char))]; |
| 350 | //int t15[T(__is_complete_type(char16_t))]; |
| 351 | //int t16[T(__is_complete_type(char32_t))]; |
| 352 | int t17[T(__is_complete_type(wchar_t))]; |
| 353 | int t18[T(__is_complete_type(short))]; |
| 354 | int t19[T(__is_complete_type(unsigned short))]; |
| 355 | int t20[T(__is_complete_type(int))]; |
| 356 | int t21[T(__is_complete_type(unsigned int))]; |
| 357 | int t22[T(__is_complete_type(long))]; |
| 358 | int t23[T(__is_complete_type(unsigned long))]; |
| 359 | int t24[T(__is_complete_type(ACompleteType))]; |
| 360 | |
| 361 | int t30[F(__is_complete_type(AnIncompleteType))]; |
| 362 | } |
| 363 | |
| 364 | void is_void() |
| 365 | { |
| 366 | int t01[T(__is_void(void))]; |
| 367 | int t02[T(__is_void(cvoid))]; |
| 368 | |
| 369 | int t10[F(__is_void(float))]; |
| 370 | int t11[F(__is_void(double))]; |
| 371 | int t12[F(__is_void(long double))]; |
| 372 | int t13[F(__is_void(bool))]; |
| 373 | int t14[F(__is_void(char))]; |
| 374 | int t15[F(__is_void(signed char))]; |
| 375 | int t16[F(__is_void(unsigned char))]; |
| 376 | int t17[F(__is_void(wchar_t))]; |
| 377 | int t18[F(__is_void(short))]; |
| 378 | int t19[F(__is_void(unsigned short))]; |
| 379 | int t20[F(__is_void(int))]; |
| 380 | int t21[F(__is_void(unsigned int))]; |
| 381 | int t22[F(__is_void(long))]; |
| 382 | int t23[F(__is_void(unsigned long))]; |
| 383 | int t24[F(__is_void(Union))]; |
| 384 | int t25[F(__is_void(UnionAr))]; |
| 385 | int t26[F(__is_void(Derives))]; |
| 386 | int t27[F(__is_void(ClassType))]; |
| 387 | int t28[F(__is_void(Enum))]; |
| 388 | int t29[F(__is_void(IntArNB))]; |
| 389 | int t30[F(__is_void(void*))]; |
| 390 | int t31[F(__is_void(cvoid*))]; |
| 391 | } |
| 392 | |
| 393 | void is_array() |
| 394 | { |
| 395 | int t01[T(__is_array(IntAr))]; |
| 396 | int t02[T(__is_array(IntArNB))]; |
| 397 | int t03[T(__is_array(UnionAr))]; |
| 398 | |
| 399 | int t10[F(__is_array(void))]; |
| 400 | int t11[F(__is_array(cvoid))]; |
| 401 | int t12[F(__is_array(float))]; |
| 402 | int t13[F(__is_array(double))]; |
| 403 | int t14[F(__is_array(long double))]; |
| 404 | int t15[F(__is_array(bool))]; |
| 405 | int t16[F(__is_array(char))]; |
| 406 | int t17[F(__is_array(signed char))]; |
| 407 | int t18[F(__is_array(unsigned char))]; |
| 408 | int t19[F(__is_array(wchar_t))]; |
| 409 | int t20[F(__is_array(short))]; |
| 410 | int t21[F(__is_array(unsigned short))]; |
| 411 | int t22[F(__is_array(int))]; |
| 412 | int t23[F(__is_array(unsigned int))]; |
| 413 | int t24[F(__is_array(long))]; |
| 414 | int t25[F(__is_array(unsigned long))]; |
| 415 | int t26[F(__is_array(Union))]; |
| 416 | int t27[F(__is_array(Derives))]; |
| 417 | int t28[F(__is_array(ClassType))]; |
| 418 | int t29[F(__is_array(Enum))]; |
| 419 | int t30[F(__is_array(void*))]; |
| 420 | int t31[F(__is_array(cvoid*))]; |
| 421 | } |
| 422 | |
| 423 | template <typename T> void tmpl_func(T&) {} |
| 424 | |
| 425 | template <typename T> struct type_wrapper { |
| 426 | typedef T type; |
| 427 | typedef T* ptrtype; |
| 428 | typedef T& reftype; |
| 429 | }; |
| 430 | |
| 431 | void is_function() |
| 432 | { |
| 433 | int t01[T(__is_function(type_wrapper<void(void)>::type))]; |
| 434 | int t02[T(__is_function(typeof(tmpl_func<int>)))]; |
| 435 | |
| 436 | typedef void (*ptr_to_func_type)(void); |
| 437 | |
| 438 | int t10[F(__is_function(void))]; |
| 439 | int t11[F(__is_function(cvoid))]; |
| 440 | int t12[F(__is_function(float))]; |
| 441 | int t13[F(__is_function(double))]; |
| 442 | int t14[F(__is_function(long double))]; |
| 443 | int t15[F(__is_function(bool))]; |
| 444 | int t16[F(__is_function(char))]; |
| 445 | int t17[F(__is_function(signed char))]; |
| 446 | int t18[F(__is_function(unsigned char))]; |
| 447 | int t19[F(__is_function(wchar_t))]; |
| 448 | int t20[F(__is_function(short))]; |
| 449 | int t21[F(__is_function(unsigned short))]; |
| 450 | int t22[F(__is_function(int))]; |
| 451 | int t23[F(__is_function(unsigned int))]; |
| 452 | int t24[F(__is_function(long))]; |
| 453 | int t25[F(__is_function(unsigned long))]; |
| 454 | int t26[F(__is_function(Union))]; |
| 455 | int t27[F(__is_function(Derives))]; |
| 456 | int t28[F(__is_function(ClassType))]; |
| 457 | int t29[F(__is_function(Enum))]; |
| 458 | int t30[F(__is_function(void*))]; |
| 459 | int t31[F(__is_function(cvoid*))]; |
| 460 | int t32[F(__is_function(void(*)()))]; |
| 461 | int t33[F(__is_function(ptr_to_func_type))]; |
| 462 | int t34[F(__is_function(type_wrapper<void(void)>::ptrtype))]; |
| 463 | int t35[F(__is_function(type_wrapper<void(void)>::reftype))]; |
| 464 | } |
| 465 | |
| 466 | void is_reference() |
| 467 | { |
| 468 | int t01[T(__is_reference(int&))]; |
| 469 | int t02[T(__is_reference(const int&))]; |
| 470 | int t03[T(__is_reference(void *&))]; |
| 471 | |
| 472 | int t10[F(__is_reference(int))]; |
| 473 | int t11[F(__is_reference(const int))]; |
| 474 | int t12[F(__is_reference(void *))]; |
| 475 | } |
| 476 | |
| 477 | void is_lvalue_reference() |
| 478 | { |
| 479 | int t01[T(__is_lvalue_reference(int&))]; |
| 480 | int t02[T(__is_lvalue_reference(void *&))]; |
| 481 | int t03[T(__is_lvalue_reference(const int&))]; |
| 482 | int t04[T(__is_lvalue_reference(void * const &))]; |
| 483 | |
| 484 | int t10[F(__is_lvalue_reference(int))]; |
| 485 | int t11[F(__is_lvalue_reference(const int))]; |
| 486 | int t12[F(__is_lvalue_reference(void *))]; |
| 487 | } |
| 488 | |
| 489 | #if __has_feature(cxx_rvalue_references) |
| 490 | |
| 491 | void is_rvalue_reference() |
| 492 | { |
| 493 | int t01[T(__is_rvalue_reference(const int&&))]; |
| 494 | int t02[T(__is_rvalue_reference(void * const &&))]; |
| 495 | |
| 496 | int t10[F(__is_rvalue_reference(int&))]; |
| 497 | int t11[F(__is_rvalue_reference(void *&))]; |
| 498 | int t12[F(__is_rvalue_reference(const int&))]; |
| 499 | int t13[F(__is_rvalue_reference(void * const &))]; |
| 500 | int t14[F(__is_rvalue_reference(int))]; |
| 501 | int t15[F(__is_rvalue_reference(const int))]; |
| 502 | int t16[F(__is_rvalue_reference(void *))]; |
| 503 | } |
| 504 | |
| 505 | #endif |
| 506 | |
| 507 | void is_fundamental() |
| 508 | { |
| 509 | int t01[T(__is_fundamental(float))]; |
| 510 | int t02[T(__is_fundamental(double))]; |
| 511 | int t03[T(__is_fundamental(long double))]; |
| 512 | int t11[T(__is_fundamental(bool))]; |
| 513 | int t12[T(__is_fundamental(char))]; |
| 514 | int t13[T(__is_fundamental(signed char))]; |
| 515 | int t14[T(__is_fundamental(unsigned char))]; |
| 516 | //int t15[T(__is_fundamental(char16_t))]; |
| 517 | //int t16[T(__is_fundamental(char32_t))]; |
| 518 | int t17[T(__is_fundamental(wchar_t))]; |
| 519 | int t18[T(__is_fundamental(short))]; |
| 520 | int t19[T(__is_fundamental(unsigned short))]; |
| 521 | int t20[T(__is_fundamental(int))]; |
| 522 | int t21[T(__is_fundamental(unsigned int))]; |
| 523 | int t22[T(__is_fundamental(long))]; |
| 524 | int t23[T(__is_fundamental(unsigned long))]; |
| 525 | int t24[T(__is_fundamental(void))]; |
| 526 | int t25[T(__is_fundamental(cvoid))]; |
| 527 | |
| 528 | int t30[F(__is_fundamental(Union))]; |
| 529 | int t31[F(__is_fundamental(UnionAr))]; |
| 530 | int t32[F(__is_fundamental(Derives))]; |
| 531 | int t33[F(__is_fundamental(ClassType))]; |
| 532 | int t34[F(__is_fundamental(Enum))]; |
| 533 | int t35[F(__is_fundamental(IntArNB))]; |
| 534 | } |
| 535 | |
| 536 | void is_object() |
| 537 | { |
| 538 | int t01[T(__is_object(int))]; |
| 539 | int t02[T(__is_object(int *))]; |
| 540 | int t03[T(__is_object(void *))]; |
| 541 | int t04[T(__is_object(Union))]; |
| 542 | int t05[T(__is_object(UnionAr))]; |
| 543 | int t06[T(__is_object(ClassType))]; |
| 544 | int t07[T(__is_object(Enum))]; |
| 545 | |
| 546 | int t10[F(__is_object(type_wrapper<void(void)>::type))]; |
| 547 | int t11[F(__is_object(int&))]; |
| 548 | int t12[F(__is_object(void))]; |
| 549 | } |
| 550 | |
| 551 | void is_scalar() |
| 552 | { |
| 553 | int t01[T(__is_scalar(float))]; |
| 554 | int t02[T(__is_scalar(double))]; |
| 555 | int t03[T(__is_scalar(long double))]; |
| 556 | int t04[T(__is_scalar(bool))]; |
| 557 | int t05[T(__is_scalar(char))]; |
| 558 | int t06[T(__is_scalar(signed char))]; |
| 559 | int t07[T(__is_scalar(unsigned char))]; |
| 560 | int t08[T(__is_scalar(wchar_t))]; |
| 561 | int t09[T(__is_scalar(short))]; |
| 562 | int t10[T(__is_scalar(unsigned short))]; |
| 563 | int t11[T(__is_scalar(int))]; |
| 564 | int t12[T(__is_scalar(unsigned int))]; |
| 565 | int t13[T(__is_scalar(long))]; |
| 566 | int t14[T(__is_scalar(unsigned long))]; |
| 567 | int t15[T(__is_scalar(Enum))]; |
| 568 | int t16[T(__is_scalar(void*))]; |
| 569 | int t17[T(__is_scalar(cvoid*))]; |
| 570 | |
| 571 | int t20[F(__is_scalar(void))]; |
| 572 | int t21[F(__is_scalar(cvoid))]; |
| 573 | int t22[F(__is_scalar(Union))]; |
| 574 | int t23[F(__is_scalar(UnionAr))]; |
| 575 | int t24[F(__is_scalar(Derives))]; |
| 576 | int t25[F(__is_scalar(ClassType))]; |
| 577 | int t26[F(__is_scalar(IntArNB))]; |
| 578 | } |
| 579 | |
| 580 | struct StructWithMembers { |
| 581 | int member; |
| 582 | void method() {} |
| 583 | }; |
| 584 | |
| 585 | void is_compound() |
| 586 | { |
| 587 | int t01[T(__is_compound(void*))]; |
| 588 | int t02[T(__is_compound(cvoid*))]; |
| 589 | int t03[T(__is_compound(void (*)()))]; |
| 590 | int t04[T(__is_compound(int StructWithMembers::*))]; |
| 591 | int t05[T(__is_compound(void (StructWithMembers::*)()))]; |
| 592 | int t06[T(__is_compound(int&))]; |
| 593 | int t07[T(__is_compound(Union))]; |
| 594 | int t08[T(__is_compound(UnionAr))]; |
| 595 | int t09[T(__is_compound(Derives))]; |
| 596 | int t10[T(__is_compound(ClassType))]; |
| 597 | int t11[T(__is_compound(IntArNB))]; |
| 598 | int t12[T(__is_compound(Enum))]; |
| 599 | |
| 600 | int t20[F(__is_compound(float))]; |
| 601 | int t21[F(__is_compound(double))]; |
| 602 | int t22[F(__is_compound(long double))]; |
| 603 | int t23[F(__is_compound(bool))]; |
| 604 | int t24[F(__is_compound(char))]; |
| 605 | int t25[F(__is_compound(signed char))]; |
| 606 | int t26[F(__is_compound(unsigned char))]; |
| 607 | int t27[F(__is_compound(wchar_t))]; |
| 608 | int t28[F(__is_compound(short))]; |
| 609 | int t29[F(__is_compound(unsigned short))]; |
| 610 | int t30[F(__is_compound(int))]; |
| 611 | int t31[F(__is_compound(unsigned int))]; |
| 612 | int t32[F(__is_compound(long))]; |
| 613 | int t33[F(__is_compound(unsigned long))]; |
| 614 | int t34[F(__is_compound(void))]; |
| 615 | int t35[F(__is_compound(cvoid))]; |
| 616 | } |
| 617 | |
| 618 | void is_pointer() |
| 619 | { |
| 620 | StructWithMembers x; |
| 621 | |
| 622 | int t01[T(__is_pointer(void*))]; |
| 623 | int t02[T(__is_pointer(cvoid*))]; |
| 624 | int t03[T(__is_pointer(cvoid*))]; |
| 625 | int t04[T(__is_pointer(char*))]; |
| 626 | int t05[T(__is_pointer(int*))]; |
| 627 | int t06[T(__is_pointer(int**))]; |
| 628 | int t07[T(__is_pointer(ClassType*))]; |
| 629 | int t08[T(__is_pointer(Derives*))]; |
| 630 | int t09[T(__is_pointer(Enum*))]; |
| 631 | int t10[T(__is_pointer(IntArNB*))]; |
| 632 | int t11[T(__is_pointer(Union*))]; |
| 633 | int t12[T(__is_pointer(UnionAr*))]; |
| 634 | int t13[T(__is_pointer(StructWithMembers*))]; |
| 635 | int t14[T(__is_pointer(void (*)()))]; |
| 636 | |
| 637 | int t20[F(__is_pointer(void))]; |
| 638 | int t21[F(__is_pointer(cvoid))]; |
| 639 | int t22[F(__is_pointer(cvoid))]; |
| 640 | int t23[F(__is_pointer(char))]; |
| 641 | int t24[F(__is_pointer(int))]; |
| 642 | int t25[F(__is_pointer(int))]; |
| 643 | int t26[F(__is_pointer(ClassType))]; |
| 644 | int t27[F(__is_pointer(Derives))]; |
| 645 | int t28[F(__is_pointer(Enum))]; |
| 646 | int t29[F(__is_pointer(IntArNB))]; |
| 647 | int t30[F(__is_pointer(Union))]; |
| 648 | int t31[F(__is_pointer(UnionAr))]; |
| 649 | int t32[F(__is_pointer(StructWithMembers))]; |
| 650 | int t33[F(__is_pointer(int StructWithMembers::*))]; |
| 651 | int t34[F(__is_pointer(void (StructWithMembers::*) ()))]; |
| 652 | } |
| 653 | |
| 654 | void is_member_object_pointer() |
| 655 | { |
| 656 | StructWithMembers x; |
| 657 | |
| 658 | int t01[T(__is_member_object_pointer(int StructWithMembers::*))]; |
| 659 | |
| 660 | int t10[F(__is_member_object_pointer(void (StructWithMembers::*) ()))]; |
| 661 | int t11[F(__is_member_object_pointer(void*))]; |
| 662 | int t12[F(__is_member_object_pointer(cvoid*))]; |
| 663 | int t13[F(__is_member_object_pointer(cvoid*))]; |
| 664 | int t14[F(__is_member_object_pointer(char*))]; |
| 665 | int t15[F(__is_member_object_pointer(int*))]; |
| 666 | int t16[F(__is_member_object_pointer(int**))]; |
| 667 | int t17[F(__is_member_object_pointer(ClassType*))]; |
| 668 | int t18[F(__is_member_object_pointer(Derives*))]; |
| 669 | int t19[F(__is_member_object_pointer(Enum*))]; |
| 670 | int t20[F(__is_member_object_pointer(IntArNB*))]; |
| 671 | int t21[F(__is_member_object_pointer(Union*))]; |
| 672 | int t22[F(__is_member_object_pointer(UnionAr*))]; |
| 673 | int t23[F(__is_member_object_pointer(StructWithMembers*))]; |
| 674 | int t24[F(__is_member_object_pointer(void))]; |
| 675 | int t25[F(__is_member_object_pointer(cvoid))]; |
| 676 | int t26[F(__is_member_object_pointer(cvoid))]; |
| 677 | int t27[F(__is_member_object_pointer(char))]; |
| 678 | int t28[F(__is_member_object_pointer(int))]; |
| 679 | int t29[F(__is_member_object_pointer(int))]; |
| 680 | int t30[F(__is_member_object_pointer(ClassType))]; |
| 681 | int t31[F(__is_member_object_pointer(Derives))]; |
| 682 | int t32[F(__is_member_object_pointer(Enum))]; |
| 683 | int t33[F(__is_member_object_pointer(IntArNB))]; |
| 684 | int t34[F(__is_member_object_pointer(Union))]; |
| 685 | int t35[F(__is_member_object_pointer(UnionAr))]; |
| 686 | int t36[F(__is_member_object_pointer(StructWithMembers))]; |
| 687 | int t37[F(__is_member_object_pointer(void (*)()))]; |
| 688 | } |
| 689 | |
| 690 | void is_member_function_pointer() |
| 691 | { |
| 692 | StructWithMembers x; |
| 693 | |
| 694 | int t01[T(__is_member_function_pointer(void (StructWithMembers::*) ()))]; |
| 695 | |
| 696 | int t10[F(__is_member_function_pointer(int StructWithMembers::*))]; |
| 697 | int t11[F(__is_member_function_pointer(void*))]; |
| 698 | int t12[F(__is_member_function_pointer(cvoid*))]; |
| 699 | int t13[F(__is_member_function_pointer(cvoid*))]; |
| 700 | int t14[F(__is_member_function_pointer(char*))]; |
| 701 | int t15[F(__is_member_function_pointer(int*))]; |
| 702 | int t16[F(__is_member_function_pointer(int**))]; |
| 703 | int t17[F(__is_member_function_pointer(ClassType*))]; |
| 704 | int t18[F(__is_member_function_pointer(Derives*))]; |
| 705 | int t19[F(__is_member_function_pointer(Enum*))]; |
| 706 | int t20[F(__is_member_function_pointer(IntArNB*))]; |
| 707 | int t21[F(__is_member_function_pointer(Union*))]; |
| 708 | int t22[F(__is_member_function_pointer(UnionAr*))]; |
| 709 | int t23[F(__is_member_function_pointer(StructWithMembers*))]; |
| 710 | int t24[F(__is_member_function_pointer(void))]; |
| 711 | int t25[F(__is_member_function_pointer(cvoid))]; |
| 712 | int t26[F(__is_member_function_pointer(cvoid))]; |
| 713 | int t27[F(__is_member_function_pointer(char))]; |
| 714 | int t28[F(__is_member_function_pointer(int))]; |
| 715 | int t29[F(__is_member_function_pointer(int))]; |
| 716 | int t30[F(__is_member_function_pointer(ClassType))]; |
| 717 | int t31[F(__is_member_function_pointer(Derives))]; |
| 718 | int t32[F(__is_member_function_pointer(Enum))]; |
| 719 | int t33[F(__is_member_function_pointer(IntArNB))]; |
| 720 | int t34[F(__is_member_function_pointer(Union))]; |
| 721 | int t35[F(__is_member_function_pointer(UnionAr))]; |
| 722 | int t36[F(__is_member_function_pointer(StructWithMembers))]; |
| 723 | int t37[F(__is_member_function_pointer(void (*)()))]; |
| 724 | } |
| 725 | |
| 726 | void is_member_pointer() |
| 727 | { |
| 728 | StructWithMembers x; |
| 729 | |
| 730 | int t01[T(__is_member_pointer(int StructWithMembers::*))]; |
| 731 | int t02[T(__is_member_pointer(void (StructWithMembers::*) ()))]; |
| 732 | |
| 733 | int t10[F(__is_member_pointer(void*))]; |
| 734 | int t11[F(__is_member_pointer(cvoid*))]; |
| 735 | int t12[F(__is_member_pointer(cvoid*))]; |
| 736 | int t13[F(__is_member_pointer(char*))]; |
| 737 | int t14[F(__is_member_pointer(int*))]; |
| 738 | int t15[F(__is_member_pointer(int**))]; |
| 739 | int t16[F(__is_member_pointer(ClassType*))]; |
| 740 | int t17[F(__is_member_pointer(Derives*))]; |
| 741 | int t18[F(__is_member_pointer(Enum*))]; |
| 742 | int t19[F(__is_member_pointer(IntArNB*))]; |
| 743 | int t20[F(__is_member_pointer(Union*))]; |
| 744 | int t21[F(__is_member_pointer(UnionAr*))]; |
| 745 | int t22[F(__is_member_pointer(StructWithMembers*))]; |
| 746 | int t23[F(__is_member_pointer(void))]; |
| 747 | int t24[F(__is_member_pointer(cvoid))]; |
| 748 | int t25[F(__is_member_pointer(cvoid))]; |
| 749 | int t26[F(__is_member_pointer(char))]; |
| 750 | int t27[F(__is_member_pointer(int))]; |
| 751 | int t28[F(__is_member_pointer(int))]; |
| 752 | int t29[F(__is_member_pointer(ClassType))]; |
| 753 | int t30[F(__is_member_pointer(Derives))]; |
| 754 | int t31[F(__is_member_pointer(Enum))]; |
| 755 | int t32[F(__is_member_pointer(IntArNB))]; |
| 756 | int t33[F(__is_member_pointer(Union))]; |
| 757 | int t34[F(__is_member_pointer(UnionAr))]; |
| 758 | int t35[F(__is_member_pointer(StructWithMembers))]; |
| 759 | int t36[F(__is_member_pointer(void (*)()))]; |
| 760 | } |
| 761 | |
| 762 | void is_const() |
| 763 | { |
| 764 | int t01[T(__is_const(cvoid))]; |
| 765 | int t02[T(__is_const(const char))]; |
| 766 | int t03[T(__is_const(const int))]; |
| 767 | int t04[T(__is_const(const long))]; |
| 768 | int t05[T(__is_const(const short))]; |
| 769 | int t06[T(__is_const(const signed char))]; |
| 770 | int t07[T(__is_const(const wchar_t))]; |
| 771 | int t08[T(__is_const(const bool))]; |
| 772 | int t09[T(__is_const(const float))]; |
| 773 | int t10[T(__is_const(const double))]; |
| 774 | int t11[T(__is_const(const long double))]; |
| 775 | int t12[T(__is_const(const unsigned char))]; |
| 776 | int t13[T(__is_const(const unsigned int))]; |
| 777 | int t14[T(__is_const(const unsigned long long))]; |
| 778 | int t15[T(__is_const(const unsigned long))]; |
| 779 | int t16[T(__is_const(const unsigned short))]; |
| 780 | int t17[T(__is_const(const void))]; |
| 781 | int t18[T(__is_const(const ClassType))]; |
| 782 | int t19[T(__is_const(const Derives))]; |
| 783 | int t20[T(__is_const(const Enum))]; |
| 784 | int t21[T(__is_const(const IntArNB))]; |
| 785 | int t22[T(__is_const(const Union))]; |
| 786 | int t23[T(__is_const(const UnionAr))]; |
| 787 | |
| 788 | int t30[F(__is_const(char))]; |
| 789 | int t31[F(__is_const(int))]; |
| 790 | int t32[F(__is_const(long))]; |
| 791 | int t33[F(__is_const(short))]; |
| 792 | int t34[F(__is_const(signed char))]; |
| 793 | int t35[F(__is_const(wchar_t))]; |
| 794 | int t36[F(__is_const(bool))]; |
| 795 | int t37[F(__is_const(float))]; |
| 796 | int t38[F(__is_const(double))]; |
| 797 | int t39[F(__is_const(long double))]; |
| 798 | int t40[F(__is_const(unsigned char))]; |
| 799 | int t41[F(__is_const(unsigned int))]; |
| 800 | int t42[F(__is_const(unsigned long long))]; |
| 801 | int t43[F(__is_const(unsigned long))]; |
| 802 | int t44[F(__is_const(unsigned short))]; |
| 803 | int t45[F(__is_const(void))]; |
| 804 | int t46[F(__is_const(ClassType))]; |
| 805 | int t47[F(__is_const(Derives))]; |
| 806 | int t48[F(__is_const(Enum))]; |
| 807 | int t49[F(__is_const(IntArNB))]; |
| 808 | int t50[F(__is_const(Union))]; |
| 809 | int t51[F(__is_const(UnionAr))]; |
| 810 | } |
| 811 | |
| 812 | void is_volatile() |
| 813 | { |
| 814 | int t02[T(__is_volatile(volatile char))]; |
| 815 | int t03[T(__is_volatile(volatile int))]; |
| 816 | int t04[T(__is_volatile(volatile long))]; |
| 817 | int t05[T(__is_volatile(volatile short))]; |
| 818 | int t06[T(__is_volatile(volatile signed char))]; |
| 819 | int t07[T(__is_volatile(volatile wchar_t))]; |
| 820 | int t08[T(__is_volatile(volatile bool))]; |
| 821 | int t09[T(__is_volatile(volatile float))]; |
| 822 | int t10[T(__is_volatile(volatile double))]; |
| 823 | int t11[T(__is_volatile(volatile long double))]; |
| 824 | int t12[T(__is_volatile(volatile unsigned char))]; |
| 825 | int t13[T(__is_volatile(volatile unsigned int))]; |
| 826 | int t14[T(__is_volatile(volatile unsigned long long))]; |
| 827 | int t15[T(__is_volatile(volatile unsigned long))]; |
| 828 | int t16[T(__is_volatile(volatile unsigned short))]; |
| 829 | int t17[T(__is_volatile(volatile void))]; |
| 830 | int t18[T(__is_volatile(volatile ClassType))]; |
| 831 | int t19[T(__is_volatile(volatile Derives))]; |
| 832 | int t20[T(__is_volatile(volatile Enum))]; |
| 833 | int t21[T(__is_volatile(volatile IntArNB))]; |
| 834 | int t22[T(__is_volatile(volatile Union))]; |
| 835 | int t23[T(__is_volatile(volatile UnionAr))]; |
| 836 | |
| 837 | int t30[F(__is_volatile(char))]; |
| 838 | int t31[F(__is_volatile(int))]; |
| 839 | int t32[F(__is_volatile(long))]; |
| 840 | int t33[F(__is_volatile(short))]; |
| 841 | int t34[F(__is_volatile(signed char))]; |
| 842 | int t35[F(__is_volatile(wchar_t))]; |
| 843 | int t36[F(__is_volatile(bool))]; |
| 844 | int t37[F(__is_volatile(float))]; |
| 845 | int t38[F(__is_volatile(double))]; |
| 846 | int t39[F(__is_volatile(long double))]; |
| 847 | int t40[F(__is_volatile(unsigned char))]; |
| 848 | int t41[F(__is_volatile(unsigned int))]; |
| 849 | int t42[F(__is_volatile(unsigned long long))]; |
| 850 | int t43[F(__is_volatile(unsigned long))]; |
| 851 | int t44[F(__is_volatile(unsigned short))]; |
| 852 | int t45[F(__is_volatile(void))]; |
| 853 | int t46[F(__is_volatile(ClassType))]; |
| 854 | int t47[F(__is_volatile(Derives))]; |
| 855 | int t48[F(__is_volatile(Enum))]; |
| 856 | int t49[F(__is_volatile(IntArNB))]; |
| 857 | int t50[F(__is_volatile(Union))]; |
| 858 | int t51[F(__is_volatile(UnionAr))]; |
| 859 | } |
| 860 | |
| 861 | struct TrivialStruct { |
| 862 | int member; |
| 863 | }; |
| 864 | |
| 865 | struct NonTrivialStruct { |
| 866 | int member; |
| 867 | NonTrivialStruct() { |
| 868 | member = 0; |
| 869 | } |
| 870 | }; |
| 871 | |
Sean Hunt | feb375d | 2011-05-13 00:31:07 +0000 | [diff] [blame] | 872 | struct SuperNonTrivialStruct { |
| 873 | SuperNonTrivialStruct() { } |
| 874 | ~SuperNonTrivialStruct() { } |
| 875 | }; |
| 876 | |
| 877 | struct NonTCStruct { |
| 878 | NonTCStruct(const NonTCStruct&) {} |
| 879 | }; |
| 880 | |
John Wiegley | 20c0da7 | 2011-04-27 23:09:49 +0000 | [diff] [blame] | 881 | void is_trivial2() |
| 882 | { |
| 883 | int t01[T(__is_trivial(char))]; |
| 884 | int t02[T(__is_trivial(int))]; |
| 885 | int t03[T(__is_trivial(long))]; |
| 886 | int t04[T(__is_trivial(short))]; |
| 887 | int t05[T(__is_trivial(signed char))]; |
| 888 | int t06[T(__is_trivial(wchar_t))]; |
| 889 | int t07[T(__is_trivial(bool))]; |
| 890 | int t08[T(__is_trivial(float))]; |
| 891 | int t09[T(__is_trivial(double))]; |
| 892 | int t10[T(__is_trivial(long double))]; |
| 893 | int t11[T(__is_trivial(unsigned char))]; |
| 894 | int t12[T(__is_trivial(unsigned int))]; |
| 895 | int t13[T(__is_trivial(unsigned long long))]; |
| 896 | int t14[T(__is_trivial(unsigned long))]; |
| 897 | int t15[T(__is_trivial(unsigned short))]; |
| 898 | int t16[T(__is_trivial(ClassType))]; |
| 899 | int t17[T(__is_trivial(Derives))]; |
| 900 | int t18[T(__is_trivial(Enum))]; |
| 901 | int t19[T(__is_trivial(IntAr))]; |
| 902 | int t20[T(__is_trivial(Union))]; |
| 903 | int t21[T(__is_trivial(UnionAr))]; |
| 904 | int t22[T(__is_trivial(TrivialStruct))]; |
| 905 | |
| 906 | int t30[F(__is_trivial(void))]; |
| 907 | int t31[F(__is_trivial(NonTrivialStruct))]; |
Sean Hunt | feb375d | 2011-05-13 00:31:07 +0000 | [diff] [blame] | 908 | int t32[F(__is_trivial(SuperNonTrivialStruct))]; |
| 909 | int t33[F(__is_trivial(NonTCStruct))]; |
| 910 | } |
| 911 | |
| 912 | void is_trivially_copyable2() |
| 913 | { |
| 914 | int t01[T(__is_trivially_copyable(char))]; |
| 915 | int t02[T(__is_trivially_copyable(int))]; |
| 916 | int t03[T(__is_trivially_copyable(long))]; |
| 917 | int t04[T(__is_trivially_copyable(short))]; |
| 918 | int t05[T(__is_trivially_copyable(signed char))]; |
| 919 | int t06[T(__is_trivially_copyable(wchar_t))]; |
| 920 | int t07[T(__is_trivially_copyable(bool))]; |
| 921 | int t08[T(__is_trivially_copyable(float))]; |
| 922 | int t09[T(__is_trivially_copyable(double))]; |
| 923 | int t10[T(__is_trivially_copyable(long double))]; |
| 924 | int t11[T(__is_trivially_copyable(unsigned char))]; |
| 925 | int t12[T(__is_trivially_copyable(unsigned int))]; |
| 926 | int t13[T(__is_trivially_copyable(unsigned long long))]; |
| 927 | int t14[T(__is_trivially_copyable(unsigned long))]; |
| 928 | int t15[T(__is_trivially_copyable(unsigned short))]; |
| 929 | int t16[T(__is_trivially_copyable(ClassType))]; |
| 930 | int t17[T(__is_trivially_copyable(Derives))]; |
| 931 | int t18[T(__is_trivially_copyable(Enum))]; |
| 932 | int t19[T(__is_trivially_copyable(IntAr))]; |
| 933 | int t20[T(__is_trivially_copyable(Union))]; |
| 934 | int t21[T(__is_trivially_copyable(UnionAr))]; |
| 935 | int t22[T(__is_trivially_copyable(TrivialStruct))]; |
| 936 | int t23[T(__is_trivially_copyable(NonTrivialStruct))]; |
| 937 | |
| 938 | int t30[F(__is_trivially_copyable(void))]; |
| 939 | int t32[F(__is_trivially_copyable(SuperNonTrivialStruct))]; |
| 940 | int t31[F(__is_trivially_copyable(NonTCStruct))]; |
John Wiegley | 20c0da7 | 2011-04-27 23:09:49 +0000 | [diff] [blame] | 941 | } |
| 942 | |
| 943 | struct CStruct { |
| 944 | int one; |
| 945 | int two; |
| 946 | }; |
| 947 | |
| 948 | struct CEmptyStruct {}; |
| 949 | |
| 950 | struct CppEmptyStruct : CStruct {}; |
| 951 | struct CppStructStandard : CEmptyStruct { |
| 952 | int three; |
| 953 | int four; |
| 954 | }; |
| 955 | struct CppStructNonStandardByBase : CStruct { |
| 956 | int three; |
| 957 | int four; |
| 958 | }; |
| 959 | struct CppStructNonStandardByVirt : CStruct { |
| 960 | virtual void method() {} |
| 961 | }; |
| 962 | struct CppStructNonStandardByMemb : CStruct { |
| 963 | CppStructNonStandardByVirt member; |
| 964 | }; |
| 965 | struct CppStructNonStandardByProt : CStruct { |
| 966 | int five; |
| 967 | protected: |
| 968 | int six; |
| 969 | }; |
| 970 | struct CppStructNonStandardByVirtBase : virtual CStruct { |
| 971 | }; |
| 972 | struct CppStructNonStandardBySameBase : CEmptyStruct { |
| 973 | CEmptyStruct member; |
| 974 | }; |
| 975 | struct CppStructNonStandardBy2ndVirtBase : CEmptyStruct { |
| 976 | CEmptyStruct member; |
| 977 | }; |
| 978 | |
| 979 | void is_standard_layout() |
| 980 | { |
| 981 | typedef const int ConstInt; |
| 982 | typedef ConstInt ConstIntAr[4]; |
| 983 | typedef CppStructStandard CppStructStandardAr[4]; |
| 984 | |
| 985 | int t01[T(__is_standard_layout(int))]; |
| 986 | int t02[T(__is_standard_layout(ConstInt))]; |
| 987 | int t03[T(__is_standard_layout(ConstIntAr))]; |
| 988 | int t04[T(__is_standard_layout(CStruct))]; |
| 989 | int t05[T(__is_standard_layout(CppStructStandard))]; |
| 990 | int t06[T(__is_standard_layout(CppStructStandardAr))]; |
Chandler Carruth | 25df423 | 2011-04-30 10:46:26 +0000 | [diff] [blame] | 991 | int t07[T(__is_standard_layout(Vector))]; |
| 992 | int t08[T(__is_standard_layout(VectorExt))]; |
John Wiegley | 20c0da7 | 2011-04-27 23:09:49 +0000 | [diff] [blame] | 993 | |
| 994 | typedef CppStructNonStandardByBase CppStructNonStandardByBaseAr[4]; |
| 995 | |
| 996 | int t10[F(__is_standard_layout(CppStructNonStandardByVirt))]; |
| 997 | int t11[F(__is_standard_layout(CppStructNonStandardByMemb))]; |
| 998 | int t12[F(__is_standard_layout(CppStructNonStandardByProt))]; |
| 999 | int t13[F(__is_standard_layout(CppStructNonStandardByVirtBase))]; |
| 1000 | int t14[F(__is_standard_layout(CppStructNonStandardByBase))]; |
| 1001 | int t15[F(__is_standard_layout(CppStructNonStandardByBaseAr))]; |
| 1002 | int t16[F(__is_standard_layout(CppStructNonStandardBySameBase))]; |
| 1003 | int t17[F(__is_standard_layout(CppStructNonStandardBy2ndVirtBase))]; |
| 1004 | } |
| 1005 | |
| 1006 | void is_signed() |
| 1007 | { |
| 1008 | //int t01[T(__is_signed(char))]; |
| 1009 | int t02[T(__is_signed(int))]; |
| 1010 | int t03[T(__is_signed(long))]; |
| 1011 | int t04[T(__is_signed(short))]; |
| 1012 | int t05[T(__is_signed(signed char))]; |
| 1013 | int t06[T(__is_signed(wchar_t))]; |
| 1014 | |
| 1015 | int t10[F(__is_signed(bool))]; |
| 1016 | int t11[F(__is_signed(cvoid))]; |
| 1017 | int t12[F(__is_signed(float))]; |
| 1018 | int t13[F(__is_signed(double))]; |
| 1019 | int t14[F(__is_signed(long double))]; |
| 1020 | int t15[F(__is_signed(unsigned char))]; |
| 1021 | int t16[F(__is_signed(unsigned int))]; |
| 1022 | int t17[F(__is_signed(unsigned long long))]; |
| 1023 | int t18[F(__is_signed(unsigned long))]; |
| 1024 | int t19[F(__is_signed(unsigned short))]; |
| 1025 | int t20[F(__is_signed(void))]; |
| 1026 | int t21[F(__is_signed(ClassType))]; |
| 1027 | int t22[F(__is_signed(Derives))]; |
| 1028 | int t23[F(__is_signed(Enum))]; |
| 1029 | int t24[F(__is_signed(IntArNB))]; |
| 1030 | int t25[F(__is_signed(Union))]; |
| 1031 | int t26[F(__is_signed(UnionAr))]; |
| 1032 | } |
| 1033 | |
| 1034 | void is_unsigned() |
| 1035 | { |
| 1036 | int t01[T(__is_unsigned(bool))]; |
| 1037 | int t02[T(__is_unsigned(unsigned char))]; |
| 1038 | int t03[T(__is_unsigned(unsigned short))]; |
| 1039 | int t04[T(__is_unsigned(unsigned int))]; |
| 1040 | int t05[T(__is_unsigned(unsigned long))]; |
| 1041 | int t06[T(__is_unsigned(unsigned long long))]; |
| 1042 | int t07[T(__is_unsigned(Enum))]; |
| 1043 | |
| 1044 | int t10[F(__is_unsigned(void))]; |
| 1045 | int t11[F(__is_unsigned(cvoid))]; |
| 1046 | int t12[F(__is_unsigned(float))]; |
| 1047 | int t13[F(__is_unsigned(double))]; |
| 1048 | int t14[F(__is_unsigned(long double))]; |
| 1049 | int t16[F(__is_unsigned(char))]; |
| 1050 | int t17[F(__is_unsigned(signed char))]; |
| 1051 | int t18[F(__is_unsigned(wchar_t))]; |
| 1052 | int t19[F(__is_unsigned(short))]; |
| 1053 | int t20[F(__is_unsigned(int))]; |
| 1054 | int t21[F(__is_unsigned(long))]; |
| 1055 | int t22[F(__is_unsigned(Union))]; |
| 1056 | int t23[F(__is_unsigned(UnionAr))]; |
| 1057 | int t24[F(__is_unsigned(Derives))]; |
| 1058 | int t25[F(__is_unsigned(ClassType))]; |
| 1059 | int t26[F(__is_unsigned(IntArNB))]; |
| 1060 | } |
| 1061 | |
Douglas Gregor | 5e03f9e | 2009-07-23 23:49:00 +0000 | [diff] [blame] | 1062 | typedef Int& IntRef; |
| 1063 | typedef const IntAr ConstIntAr; |
| 1064 | typedef ConstIntAr ConstIntArAr[4]; |
| 1065 | |
| 1066 | struct HasCopy { |
| 1067 | HasCopy(HasCopy& cp); |
| 1068 | }; |
| 1069 | |
Chandler Carruth | 4d6e5a2 | 2011-04-23 23:10:33 +0000 | [diff] [blame] | 1070 | struct HasMove { |
Richard Smith | 7a614d8 | 2011-06-11 17:19:42 +0000 | [diff] [blame^] | 1071 | HasMove(HasMove&& cp); |
Chandler Carruth | 4d6e5a2 | 2011-04-23 23:10:33 +0000 | [diff] [blame] | 1072 | }; |
| 1073 | |
Sebastian Redl | 08295a5 | 2010-09-13 22:18:28 +0000 | [diff] [blame] | 1074 | struct HasTemplateCons { |
| 1075 | HasVirt Annoying; |
| 1076 | |
| 1077 | template <typename T> |
| 1078 | HasTemplateCons(const T&); |
| 1079 | }; |
| 1080 | |
Douglas Gregor | 5e03f9e | 2009-07-23 23:49:00 +0000 | [diff] [blame] | 1081 | void has_trivial_default_constructor() { |
Chandler Carruth | e567e83 | 2011-04-23 20:51:37 +0000 | [diff] [blame] | 1082 | { int arr[T(__has_trivial_constructor(Int))]; } |
| 1083 | { int arr[T(__has_trivial_constructor(IntAr))]; } |
| 1084 | { int arr[T(__has_trivial_constructor(Union))]; } |
| 1085 | { int arr[T(__has_trivial_constructor(UnionAr))]; } |
| 1086 | { int arr[T(__has_trivial_constructor(POD))]; } |
| 1087 | { int arr[T(__has_trivial_constructor(Derives))]; } |
Chandler Carruth | 34eaaa5 | 2011-04-23 20:51:39 +0000 | [diff] [blame] | 1088 | { int arr[T(__has_trivial_constructor(DerivesAr))]; } |
Chandler Carruth | e567e83 | 2011-04-23 20:51:37 +0000 | [diff] [blame] | 1089 | { int arr[T(__has_trivial_constructor(ConstIntAr))]; } |
| 1090 | { int arr[T(__has_trivial_constructor(ConstIntArAr))]; } |
| 1091 | { int arr[T(__has_trivial_constructor(HasDest))]; } |
| 1092 | { int arr[T(__has_trivial_constructor(HasPriv))]; } |
Chandler Carruth | 34eaaa5 | 2011-04-23 20:51:39 +0000 | [diff] [blame] | 1093 | { int arr[T(__has_trivial_constructor(HasCopyAssign))]; } |
Chandler Carruth | 4d6e5a2 | 2011-04-23 23:10:33 +0000 | [diff] [blame] | 1094 | { int arr[T(__has_trivial_constructor(HasMoveAssign))]; } |
Chandler Carruth | 34eaaa5 | 2011-04-23 20:51:39 +0000 | [diff] [blame] | 1095 | { int arr[T(__has_trivial_constructor(const Int))]; } |
| 1096 | |
Chandler Carruth | e567e83 | 2011-04-23 20:51:37 +0000 | [diff] [blame] | 1097 | { int arr[F(__has_trivial_constructor(HasCons))]; } |
| 1098 | { int arr[F(__has_trivial_constructor(HasRef))]; } |
| 1099 | { int arr[F(__has_trivial_constructor(HasCopy))]; } |
| 1100 | { int arr[F(__has_trivial_constructor(IntRef))]; } |
Chandler Carruth | e567e83 | 2011-04-23 20:51:37 +0000 | [diff] [blame] | 1101 | { int arr[F(__has_trivial_constructor(VirtAr))]; } |
| 1102 | { int arr[F(__has_trivial_constructor(void))]; } |
| 1103 | { int arr[F(__has_trivial_constructor(cvoid))]; } |
| 1104 | { int arr[F(__has_trivial_constructor(HasTemplateCons))]; } |
Douglas Gregor | 5e03f9e | 2009-07-23 23:49:00 +0000 | [diff] [blame] | 1105 | } |
| 1106 | |
| 1107 | void has_trivial_copy_constructor() { |
Chandler Carruth | e567e83 | 2011-04-23 20:51:37 +0000 | [diff] [blame] | 1108 | { int arr[T(__has_trivial_copy(Int))]; } |
| 1109 | { int arr[T(__has_trivial_copy(IntAr))]; } |
| 1110 | { int arr[T(__has_trivial_copy(Union))]; } |
| 1111 | { int arr[T(__has_trivial_copy(UnionAr))]; } |
| 1112 | { int arr[T(__has_trivial_copy(POD))]; } |
| 1113 | { int arr[T(__has_trivial_copy(Derives))]; } |
| 1114 | { int arr[T(__has_trivial_copy(ConstIntAr))]; } |
| 1115 | { int arr[T(__has_trivial_copy(ConstIntArAr))]; } |
| 1116 | { int arr[T(__has_trivial_copy(HasDest))]; } |
| 1117 | { int arr[T(__has_trivial_copy(HasPriv))]; } |
| 1118 | { int arr[T(__has_trivial_copy(HasCons))]; } |
| 1119 | { int arr[T(__has_trivial_copy(HasRef))]; } |
Chandler Carruth | 4d6e5a2 | 2011-04-23 23:10:33 +0000 | [diff] [blame] | 1120 | { int arr[T(__has_trivial_copy(HasMove))]; } |
Chandler Carruth | e567e83 | 2011-04-23 20:51:37 +0000 | [diff] [blame] | 1121 | { int arr[T(__has_trivial_copy(IntRef))]; } |
| 1122 | { int arr[T(__has_trivial_copy(HasCopyAssign))]; } |
Chandler Carruth | 4d6e5a2 | 2011-04-23 23:10:33 +0000 | [diff] [blame] | 1123 | { int arr[T(__has_trivial_copy(HasMoveAssign))]; } |
Chandler Carruth | e567e83 | 2011-04-23 20:51:37 +0000 | [diff] [blame] | 1124 | { int arr[T(__has_trivial_copy(const Int))]; } |
Chandler Carruth | 34eaaa5 | 2011-04-23 20:51:39 +0000 | [diff] [blame] | 1125 | |
| 1126 | { int arr[F(__has_trivial_copy(HasCopy))]; } |
| 1127 | { int arr[F(__has_trivial_copy(HasTemplateCons))]; } |
| 1128 | { int arr[F(__has_trivial_copy(DerivesAr))]; } |
Chandler Carruth | e567e83 | 2011-04-23 20:51:37 +0000 | [diff] [blame] | 1129 | { int arr[F(__has_trivial_copy(VirtAr))]; } |
| 1130 | { int arr[F(__has_trivial_copy(void))]; } |
| 1131 | { int arr[F(__has_trivial_copy(cvoid))]; } |
Douglas Gregor | 5e03f9e | 2009-07-23 23:49:00 +0000 | [diff] [blame] | 1132 | } |
| 1133 | |
| 1134 | void has_trivial_copy_assignment() { |
Chandler Carruth | e567e83 | 2011-04-23 20:51:37 +0000 | [diff] [blame] | 1135 | { int arr[T(__has_trivial_assign(Int))]; } |
| 1136 | { int arr[T(__has_trivial_assign(IntAr))]; } |
| 1137 | { int arr[T(__has_trivial_assign(Union))]; } |
| 1138 | { int arr[T(__has_trivial_assign(UnionAr))]; } |
| 1139 | { int arr[T(__has_trivial_assign(POD))]; } |
| 1140 | { int arr[T(__has_trivial_assign(Derives))]; } |
Chandler Carruth | e567e83 | 2011-04-23 20:51:37 +0000 | [diff] [blame] | 1141 | { int arr[T(__has_trivial_assign(HasDest))]; } |
| 1142 | { int arr[T(__has_trivial_assign(HasPriv))]; } |
| 1143 | { int arr[T(__has_trivial_assign(HasCons))]; } |
| 1144 | { int arr[T(__has_trivial_assign(HasRef))]; } |
| 1145 | { int arr[T(__has_trivial_assign(HasCopy))]; } |
Chandler Carruth | 4d6e5a2 | 2011-04-23 23:10:33 +0000 | [diff] [blame] | 1146 | { int arr[T(__has_trivial_assign(HasMove))]; } |
| 1147 | { int arr[T(__has_trivial_assign(HasMoveAssign))]; } |
Chandler Carruth | 34eaaa5 | 2011-04-23 20:51:39 +0000 | [diff] [blame] | 1148 | |
Chandler Carruth | e567e83 | 2011-04-23 20:51:37 +0000 | [diff] [blame] | 1149 | { int arr[F(__has_trivial_assign(IntRef))]; } |
| 1150 | { int arr[F(__has_trivial_assign(HasCopyAssign))]; } |
| 1151 | { int arr[F(__has_trivial_assign(const Int))]; } |
Chandler Carruth | 34eaaa5 | 2011-04-23 20:51:39 +0000 | [diff] [blame] | 1152 | { int arr[F(__has_trivial_assign(ConstIntAr))]; } |
| 1153 | { int arr[F(__has_trivial_assign(ConstIntArAr))]; } |
| 1154 | { int arr[F(__has_trivial_assign(DerivesAr))]; } |
Chandler Carruth | e567e83 | 2011-04-23 20:51:37 +0000 | [diff] [blame] | 1155 | { int arr[F(__has_trivial_assign(VirtAr))]; } |
| 1156 | { int arr[F(__has_trivial_assign(void))]; } |
| 1157 | { int arr[F(__has_trivial_assign(cvoid))]; } |
Douglas Gregor | 5e03f9e | 2009-07-23 23:49:00 +0000 | [diff] [blame] | 1158 | } |
| 1159 | |
| 1160 | void has_trivial_destructor() { |
Chandler Carruth | e567e83 | 2011-04-23 20:51:37 +0000 | [diff] [blame] | 1161 | { int arr[T(__has_trivial_destructor(Int))]; } |
| 1162 | { int arr[T(__has_trivial_destructor(IntAr))]; } |
| 1163 | { int arr[T(__has_trivial_destructor(Union))]; } |
| 1164 | { int arr[T(__has_trivial_destructor(UnionAr))]; } |
| 1165 | { int arr[T(__has_trivial_destructor(POD))]; } |
| 1166 | { int arr[T(__has_trivial_destructor(Derives))]; } |
| 1167 | { int arr[T(__has_trivial_destructor(ConstIntAr))]; } |
| 1168 | { int arr[T(__has_trivial_destructor(ConstIntArAr))]; } |
Chandler Carruth | e567e83 | 2011-04-23 20:51:37 +0000 | [diff] [blame] | 1169 | { int arr[T(__has_trivial_destructor(HasPriv))]; } |
| 1170 | { int arr[T(__has_trivial_destructor(HasCons))]; } |
| 1171 | { int arr[T(__has_trivial_destructor(HasRef))]; } |
| 1172 | { int arr[T(__has_trivial_destructor(HasCopy))]; } |
Chandler Carruth | 4d6e5a2 | 2011-04-23 23:10:33 +0000 | [diff] [blame] | 1173 | { int arr[T(__has_trivial_destructor(HasMove))]; } |
Chandler Carruth | e567e83 | 2011-04-23 20:51:37 +0000 | [diff] [blame] | 1174 | { int arr[T(__has_trivial_destructor(IntRef))]; } |
| 1175 | { int arr[T(__has_trivial_destructor(HasCopyAssign))]; } |
Chandler Carruth | 4d6e5a2 | 2011-04-23 23:10:33 +0000 | [diff] [blame] | 1176 | { int arr[T(__has_trivial_destructor(HasMoveAssign))]; } |
Chandler Carruth | e567e83 | 2011-04-23 20:51:37 +0000 | [diff] [blame] | 1177 | { int arr[T(__has_trivial_destructor(const Int))]; } |
Chandler Carruth | 34eaaa5 | 2011-04-23 20:51:39 +0000 | [diff] [blame] | 1178 | { int arr[T(__has_trivial_destructor(DerivesAr))]; } |
Chandler Carruth | e567e83 | 2011-04-23 20:51:37 +0000 | [diff] [blame] | 1179 | { int arr[T(__has_trivial_destructor(VirtAr))]; } |
Chandler Carruth | 34eaaa5 | 2011-04-23 20:51:39 +0000 | [diff] [blame] | 1180 | |
| 1181 | { int arr[F(__has_trivial_destructor(HasDest))]; } |
Chandler Carruth | e567e83 | 2011-04-23 20:51:37 +0000 | [diff] [blame] | 1182 | { int arr[F(__has_trivial_destructor(void))]; } |
| 1183 | { int arr[F(__has_trivial_destructor(cvoid))]; } |
Douglas Gregor | 5e03f9e | 2009-07-23 23:49:00 +0000 | [diff] [blame] | 1184 | } |
Anders Carlsson | 51f9404 | 2009-12-03 17:49:57 +0000 | [diff] [blame] | 1185 | |
| 1186 | struct A { ~A() {} }; |
| 1187 | template<typename> struct B : A { }; |
| 1188 | |
| 1189 | void f() { |
Chandler Carruth | e567e83 | 2011-04-23 20:51:37 +0000 | [diff] [blame] | 1190 | { int arr[F(__has_trivial_destructor(A))]; } |
| 1191 | { int arr[F(__has_trivial_destructor(B<int>))]; } |
Daniel Dunbar | a572887 | 2009-12-15 20:14:24 +0000 | [diff] [blame] | 1192 | } |
Sebastian Redl | c238f09 | 2010-08-31 04:59:00 +0000 | [diff] [blame] | 1193 | |
| 1194 | void has_nothrow_assign() { |
Chandler Carruth | e567e83 | 2011-04-23 20:51:37 +0000 | [diff] [blame] | 1195 | { int arr[T(__has_nothrow_assign(Int))]; } |
| 1196 | { int arr[T(__has_nothrow_assign(IntAr))]; } |
| 1197 | { int arr[T(__has_nothrow_assign(Union))]; } |
| 1198 | { int arr[T(__has_nothrow_assign(UnionAr))]; } |
| 1199 | { int arr[T(__has_nothrow_assign(POD))]; } |
| 1200 | { int arr[T(__has_nothrow_assign(Derives))]; } |
Chandler Carruth | e567e83 | 2011-04-23 20:51:37 +0000 | [diff] [blame] | 1201 | { int arr[T(__has_nothrow_assign(HasDest))]; } |
| 1202 | { int arr[T(__has_nothrow_assign(HasPriv))]; } |
| 1203 | { int arr[T(__has_nothrow_assign(HasCons))]; } |
| 1204 | { int arr[T(__has_nothrow_assign(HasRef))]; } |
| 1205 | { int arr[T(__has_nothrow_assign(HasCopy))]; } |
Chandler Carruth | 4d6e5a2 | 2011-04-23 23:10:33 +0000 | [diff] [blame] | 1206 | { int arr[T(__has_nothrow_assign(HasMove))]; } |
| 1207 | { int arr[T(__has_nothrow_assign(HasMoveAssign))]; } |
Chandler Carruth | 34eaaa5 | 2011-04-23 20:51:39 +0000 | [diff] [blame] | 1208 | { int arr[T(__has_nothrow_assign(HasNoThrowCopyAssign))]; } |
| 1209 | { int arr[T(__has_nothrow_assign(HasMultipleNoThrowCopyAssign))]; } |
| 1210 | { int arr[T(__has_nothrow_assign(HasVirtDest))]; } |
| 1211 | |
Chandler Carruth | e567e83 | 2011-04-23 20:51:37 +0000 | [diff] [blame] | 1212 | { int arr[F(__has_nothrow_assign(IntRef))]; } |
| 1213 | { int arr[F(__has_nothrow_assign(HasCopyAssign))]; } |
Chandler Carruth | e567e83 | 2011-04-23 20:51:37 +0000 | [diff] [blame] | 1214 | { int arr[F(__has_nothrow_assign(HasMultipleCopyAssign))]; } |
Chandler Carruth | 34eaaa5 | 2011-04-23 20:51:39 +0000 | [diff] [blame] | 1215 | { int arr[F(__has_nothrow_assign(const Int))]; } |
| 1216 | { int arr[F(__has_nothrow_assign(ConstIntAr))]; } |
| 1217 | { int arr[F(__has_nothrow_assign(ConstIntArAr))]; } |
| 1218 | { int arr[F(__has_nothrow_assign(DerivesAr))]; } |
| 1219 | { int arr[F(__has_nothrow_assign(VirtAr))]; } |
Chandler Carruth | e567e83 | 2011-04-23 20:51:37 +0000 | [diff] [blame] | 1220 | { int arr[F(__has_nothrow_assign(void))]; } |
| 1221 | { int arr[F(__has_nothrow_assign(cvoid))]; } |
Sebastian Redl | c238f09 | 2010-08-31 04:59:00 +0000 | [diff] [blame] | 1222 | } |
| 1223 | |
| 1224 | void has_nothrow_copy() { |
Chandler Carruth | e567e83 | 2011-04-23 20:51:37 +0000 | [diff] [blame] | 1225 | { int arr[T(__has_nothrow_copy(Int))]; } |
| 1226 | { int arr[T(__has_nothrow_copy(IntAr))]; } |
| 1227 | { int arr[T(__has_nothrow_copy(Union))]; } |
| 1228 | { int arr[T(__has_nothrow_copy(UnionAr))]; } |
| 1229 | { int arr[T(__has_nothrow_copy(POD))]; } |
Chandler Carruth | 34eaaa5 | 2011-04-23 20:51:39 +0000 | [diff] [blame] | 1230 | { int arr[T(__has_nothrow_copy(const Int))]; } |
Chandler Carruth | e567e83 | 2011-04-23 20:51:37 +0000 | [diff] [blame] | 1231 | { int arr[T(__has_nothrow_copy(ConstIntAr))]; } |
| 1232 | { int arr[T(__has_nothrow_copy(ConstIntArAr))]; } |
Chandler Carruth | 34eaaa5 | 2011-04-23 20:51:39 +0000 | [diff] [blame] | 1233 | { int arr[T(__has_nothrow_copy(Derives))]; } |
| 1234 | { int arr[T(__has_nothrow_copy(IntRef))]; } |
Chandler Carruth | e567e83 | 2011-04-23 20:51:37 +0000 | [diff] [blame] | 1235 | { int arr[T(__has_nothrow_copy(HasDest))]; } |
| 1236 | { int arr[T(__has_nothrow_copy(HasPriv))]; } |
| 1237 | { int arr[T(__has_nothrow_copy(HasCons))]; } |
| 1238 | { int arr[T(__has_nothrow_copy(HasRef))]; } |
Chandler Carruth | 4d6e5a2 | 2011-04-23 23:10:33 +0000 | [diff] [blame] | 1239 | { int arr[T(__has_nothrow_copy(HasMove))]; } |
Chandler Carruth | e567e83 | 2011-04-23 20:51:37 +0000 | [diff] [blame] | 1240 | { int arr[T(__has_nothrow_copy(HasCopyAssign))]; } |
Chandler Carruth | 4d6e5a2 | 2011-04-23 23:10:33 +0000 | [diff] [blame] | 1241 | { int arr[T(__has_nothrow_copy(HasMoveAssign))]; } |
Chandler Carruth | e567e83 | 2011-04-23 20:51:37 +0000 | [diff] [blame] | 1242 | { int arr[T(__has_nothrow_copy(HasNoThrowCopy))]; } |
Chandler Carruth | e567e83 | 2011-04-23 20:51:37 +0000 | [diff] [blame] | 1243 | { int arr[T(__has_nothrow_copy(HasMultipleNoThrowCopy))]; } |
Chandler Carruth | e567e83 | 2011-04-23 20:51:37 +0000 | [diff] [blame] | 1244 | { int arr[T(__has_nothrow_copy(HasVirtDest))]; } |
| 1245 | { int arr[T(__has_nothrow_copy(HasTemplateCons))]; } |
Chandler Carruth | 34eaaa5 | 2011-04-23 20:51:39 +0000 | [diff] [blame] | 1246 | |
| 1247 | { int arr[F(__has_nothrow_copy(HasCopy))]; } |
| 1248 | { int arr[F(__has_nothrow_copy(HasMultipleCopy))]; } |
| 1249 | { int arr[F(__has_nothrow_copy(DerivesAr))]; } |
| 1250 | { int arr[F(__has_nothrow_copy(VirtAr))]; } |
| 1251 | { int arr[F(__has_nothrow_copy(void))]; } |
| 1252 | { int arr[F(__has_nothrow_copy(cvoid))]; } |
Sebastian Redl | c238f09 | 2010-08-31 04:59:00 +0000 | [diff] [blame] | 1253 | } |
| 1254 | |
Richard Smith | 7a614d8 | 2011-06-11 17:19:42 +0000 | [diff] [blame^] | 1255 | template<bool b> struct assert_expr; |
| 1256 | template<> struct assert_expr<true> {}; |
| 1257 | |
Sebastian Redl | c238f09 | 2010-08-31 04:59:00 +0000 | [diff] [blame] | 1258 | void has_nothrow_constructor() { |
Chandler Carruth | e567e83 | 2011-04-23 20:51:37 +0000 | [diff] [blame] | 1259 | { int arr[T(__has_nothrow_constructor(Int))]; } |
| 1260 | { int arr[T(__has_nothrow_constructor(IntAr))]; } |
| 1261 | { int arr[T(__has_nothrow_constructor(Union))]; } |
| 1262 | { int arr[T(__has_nothrow_constructor(UnionAr))]; } |
| 1263 | { int arr[T(__has_nothrow_constructor(POD))]; } |
| 1264 | { int arr[T(__has_nothrow_constructor(Derives))]; } |
Chandler Carruth | 34eaaa5 | 2011-04-23 20:51:39 +0000 | [diff] [blame] | 1265 | { int arr[T(__has_nothrow_constructor(DerivesAr))]; } |
Chandler Carruth | e567e83 | 2011-04-23 20:51:37 +0000 | [diff] [blame] | 1266 | { int arr[T(__has_nothrow_constructor(ConstIntAr))]; } |
| 1267 | { int arr[T(__has_nothrow_constructor(ConstIntArAr))]; } |
| 1268 | { int arr[T(__has_nothrow_constructor(HasDest))]; } |
| 1269 | { int arr[T(__has_nothrow_constructor(HasPriv))]; } |
Chandler Carruth | 34eaaa5 | 2011-04-23 20:51:39 +0000 | [diff] [blame] | 1270 | { int arr[T(__has_nothrow_constructor(HasCopyAssign))]; } |
| 1271 | { int arr[T(__has_nothrow_constructor(const Int))]; } |
| 1272 | { int arr[T(__has_nothrow_constructor(HasNoThrowConstructor))]; } |
| 1273 | { int arr[T(__has_nothrow_constructor(HasVirtDest))]; } |
| 1274 | // { int arr[T(__has_nothrow_constructor(VirtAr))]; } // not implemented |
| 1275 | |
Chandler Carruth | e567e83 | 2011-04-23 20:51:37 +0000 | [diff] [blame] | 1276 | { int arr[F(__has_nothrow_constructor(HasCons))]; } |
| 1277 | { int arr[F(__has_nothrow_constructor(HasRef))]; } |
| 1278 | { int arr[F(__has_nothrow_constructor(HasCopy))]; } |
Chandler Carruth | 4d6e5a2 | 2011-04-23 23:10:33 +0000 | [diff] [blame] | 1279 | { int arr[F(__has_nothrow_constructor(HasMove))]; } |
Chandler Carruth | e567e83 | 2011-04-23 20:51:37 +0000 | [diff] [blame] | 1280 | { int arr[F(__has_nothrow_constructor(HasNoThrowConstructorWithArgs))]; } |
Chandler Carruth | 34eaaa5 | 2011-04-23 20:51:39 +0000 | [diff] [blame] | 1281 | { int arr[F(__has_nothrow_constructor(IntRef))]; } |
Chandler Carruth | e567e83 | 2011-04-23 20:51:37 +0000 | [diff] [blame] | 1282 | { int arr[F(__has_nothrow_constructor(void))]; } |
| 1283 | { int arr[F(__has_nothrow_constructor(cvoid))]; } |
Chandler Carruth | e567e83 | 2011-04-23 20:51:37 +0000 | [diff] [blame] | 1284 | { int arr[F(__has_nothrow_constructor(HasTemplateCons))]; } |
Richard Smith | 7a614d8 | 2011-06-11 17:19:42 +0000 | [diff] [blame^] | 1285 | |
| 1286 | // While parsing an in-class initializer, the constructor is not known to be |
| 1287 | // non-throwing yet. |
| 1288 | struct HasInClassInit { int n = (assert_expr<!__has_nothrow_constructor(HasInClassInit)>(), 0); }; |
| 1289 | { int arr[T(__has_nothrow_constructor(HasInClassInit))]; } |
Sebastian Redl | c238f09 | 2010-08-31 04:59:00 +0000 | [diff] [blame] | 1290 | } |
Sebastian Redl | d4b25cb | 2010-09-02 23:19:42 +0000 | [diff] [blame] | 1291 | |
| 1292 | void has_virtual_destructor() { |
Chandler Carruth | e567e83 | 2011-04-23 20:51:37 +0000 | [diff] [blame] | 1293 | { int arr[F(__has_virtual_destructor(Int))]; } |
| 1294 | { int arr[F(__has_virtual_destructor(IntAr))]; } |
| 1295 | { int arr[F(__has_virtual_destructor(Union))]; } |
| 1296 | { int arr[F(__has_virtual_destructor(UnionAr))]; } |
| 1297 | { int arr[F(__has_virtual_destructor(POD))]; } |
| 1298 | { int arr[F(__has_virtual_destructor(Derives))]; } |
Chandler Carruth | 34eaaa5 | 2011-04-23 20:51:39 +0000 | [diff] [blame] | 1299 | { int arr[F(__has_virtual_destructor(DerivesAr))]; } |
| 1300 | { int arr[F(__has_virtual_destructor(const Int))]; } |
Chandler Carruth | e567e83 | 2011-04-23 20:51:37 +0000 | [diff] [blame] | 1301 | { int arr[F(__has_virtual_destructor(ConstIntAr))]; } |
| 1302 | { int arr[F(__has_virtual_destructor(ConstIntArAr))]; } |
| 1303 | { int arr[F(__has_virtual_destructor(HasDest))]; } |
| 1304 | { int arr[F(__has_virtual_destructor(HasPriv))]; } |
| 1305 | { int arr[F(__has_virtual_destructor(HasCons))]; } |
| 1306 | { int arr[F(__has_virtual_destructor(HasRef))]; } |
| 1307 | { int arr[F(__has_virtual_destructor(HasCopy))]; } |
Chandler Carruth | 4d6e5a2 | 2011-04-23 23:10:33 +0000 | [diff] [blame] | 1308 | { int arr[F(__has_virtual_destructor(HasMove))]; } |
Chandler Carruth | e567e83 | 2011-04-23 20:51:37 +0000 | [diff] [blame] | 1309 | { int arr[F(__has_virtual_destructor(HasCopyAssign))]; } |
Chandler Carruth | 4d6e5a2 | 2011-04-23 23:10:33 +0000 | [diff] [blame] | 1310 | { int arr[F(__has_virtual_destructor(HasMoveAssign))]; } |
Chandler Carruth | 34eaaa5 | 2011-04-23 20:51:39 +0000 | [diff] [blame] | 1311 | { int arr[F(__has_virtual_destructor(IntRef))]; } |
Chandler Carruth | e567e83 | 2011-04-23 20:51:37 +0000 | [diff] [blame] | 1312 | { int arr[F(__has_virtual_destructor(VirtAr))]; } |
Sebastian Redl | d4b25cb | 2010-09-02 23:19:42 +0000 | [diff] [blame] | 1313 | |
Chandler Carruth | e567e83 | 2011-04-23 20:51:37 +0000 | [diff] [blame] | 1314 | { int arr[T(__has_virtual_destructor(HasVirtDest))]; } |
| 1315 | { int arr[T(__has_virtual_destructor(DerivedVirtDest))]; } |
| 1316 | { int arr[F(__has_virtual_destructor(VirtDestAr))]; } |
| 1317 | { int arr[F(__has_virtual_destructor(void))]; } |
| 1318 | { int arr[F(__has_virtual_destructor(cvoid))]; } |
Sebastian Redl | d4b25cb | 2010-09-02 23:19:42 +0000 | [diff] [blame] | 1319 | } |
Francois Pichet | 6ad6f28 | 2010-12-07 00:08:36 +0000 | [diff] [blame] | 1320 | |
| 1321 | |
| 1322 | class Base {}; |
| 1323 | class Derived : Base {}; |
| 1324 | class Derived2a : Derived {}; |
| 1325 | class Derived2b : Derived {}; |
| 1326 | class Derived3 : virtual Derived2a, virtual Derived2b {}; |
| 1327 | template<typename T> struct BaseA { T a; }; |
| 1328 | template<typename T> struct DerivedB : BaseA<T> { }; |
| 1329 | template<typename T> struct CrazyDerived : T { }; |
| 1330 | |
| 1331 | |
| 1332 | class class_forward; // expected-note {{forward declaration of 'class_forward'}} |
| 1333 | |
| 1334 | template <typename Base, typename Derived> |
| 1335 | void isBaseOfT() { |
| 1336 | int t[T(__is_base_of(Base, Derived))]; |
| 1337 | }; |
| 1338 | template <typename Base, typename Derived> |
| 1339 | void isBaseOfF() { |
| 1340 | int t[F(__is_base_of(Base, Derived))]; |
| 1341 | }; |
| 1342 | |
John McCall | d89d30f | 2011-01-28 22:02:36 +0000 | [diff] [blame] | 1343 | template <class T> class DerivedTemp : Base {}; |
| 1344 | template <class T> class NonderivedTemp {}; |
| 1345 | template <class T> class UndefinedTemp; // expected-note {{declared here}} |
Francois Pichet | 6ad6f28 | 2010-12-07 00:08:36 +0000 | [diff] [blame] | 1346 | |
| 1347 | void is_base_of() { |
Chandler Carruth | e567e83 | 2011-04-23 20:51:37 +0000 | [diff] [blame] | 1348 | { int arr[T(__is_base_of(Base, Derived))]; } |
| 1349 | { int arr[T(__is_base_of(const Base, Derived))]; } |
| 1350 | { int arr[F(__is_base_of(Derived, Base))]; } |
| 1351 | { int arr[F(__is_base_of(Derived, int))]; } |
| 1352 | { int arr[T(__is_base_of(Base, Base))]; } |
| 1353 | { int arr[T(__is_base_of(Base, Derived3))]; } |
| 1354 | { int arr[T(__is_base_of(Derived, Derived3))]; } |
| 1355 | { int arr[T(__is_base_of(Derived2b, Derived3))]; } |
| 1356 | { int arr[T(__is_base_of(Derived2a, Derived3))]; } |
| 1357 | { int arr[T(__is_base_of(BaseA<int>, DerivedB<int>))]; } |
| 1358 | { int arr[F(__is_base_of(DerivedB<int>, BaseA<int>))]; } |
| 1359 | { int arr[T(__is_base_of(Base, CrazyDerived<Base>))]; } |
| 1360 | { int arr[F(__is_base_of(Union, Union))]; } |
| 1361 | { int arr[T(__is_base_of(Empty, Empty))]; } |
| 1362 | { int arr[T(__is_base_of(class_forward, class_forward))]; } |
| 1363 | { int arr[F(__is_base_of(Empty, class_forward))]; } // expected-error {{incomplete type 'class_forward' used in type trait expression}} |
| 1364 | { int arr[F(__is_base_of(Base&, Derived&))]; } |
John McCall | d89d30f | 2011-01-28 22:02:36 +0000 | [diff] [blame] | 1365 | int t18[F(__is_base_of(Base[10], Derived[10]))]; |
Chandler Carruth | e567e83 | 2011-04-23 20:51:37 +0000 | [diff] [blame] | 1366 | { int arr[F(__is_base_of(int, int))]; } |
| 1367 | { int arr[F(__is_base_of(long, int))]; } |
| 1368 | { int arr[T(__is_base_of(Base, DerivedTemp<int>))]; } |
| 1369 | { int arr[F(__is_base_of(Base, NonderivedTemp<int>))]; } |
| 1370 | { int arr[F(__is_base_of(Base, UndefinedTemp<int>))]; } // expected-error {{implicit instantiation of undefined template 'UndefinedTemp<int>'}} |
Francois Pichet | 6ad6f28 | 2010-12-07 00:08:36 +0000 | [diff] [blame] | 1371 | |
| 1372 | isBaseOfT<Base, Derived>(); |
| 1373 | isBaseOfF<Derived, Base>(); |
| 1374 | |
| 1375 | isBaseOfT<Base, CrazyDerived<Base> >(); |
| 1376 | isBaseOfF<CrazyDerived<Base>, Base>(); |
| 1377 | |
| 1378 | isBaseOfT<BaseA<int>, DerivedB<int> >(); |
| 1379 | isBaseOfF<DerivedB<int>, BaseA<int> >(); |
| 1380 | } |
Douglas Gregor | 9f36113 | 2011-01-27 20:28:01 +0000 | [diff] [blame] | 1381 | |
John Wiegley | 20c0da7 | 2011-04-27 23:09:49 +0000 | [diff] [blame] | 1382 | #if 0 |
| 1383 | template<class T, class U> |
| 1384 | class TemplateClass {}; |
| 1385 | |
| 1386 | template<class T> |
| 1387 | using TemplateAlias = TemplateClass<T, int>; |
| 1388 | #endif |
| 1389 | |
| 1390 | typedef class Base BaseTypedef; |
| 1391 | |
| 1392 | void is_same() |
| 1393 | { |
| 1394 | int t01[T(__is_same(Base, Base))]; |
| 1395 | int t02[T(__is_same(Base, BaseTypedef))]; |
| 1396 | #if 0 |
| 1397 | int t03[T(__is_same(TemplateClass<int, int>, TemplateAlias<int>))]; |
| 1398 | #endif |
| 1399 | |
| 1400 | int t10[F(__is_same(Base, const Base))]; |
| 1401 | int t11[F(__is_same(Base, Base&))]; |
| 1402 | int t12[F(__is_same(Base, Derived))]; |
| 1403 | } |
| 1404 | |
| 1405 | struct IntWrapper |
| 1406 | { |
| 1407 | int value; |
| 1408 | IntWrapper(int _value) : value(_value) {} |
| 1409 | operator int() const { |
| 1410 | return value; |
| 1411 | } |
| 1412 | }; |
| 1413 | |
| 1414 | struct FloatWrapper |
| 1415 | { |
| 1416 | float value; |
| 1417 | FloatWrapper(float _value) : value(_value) {} |
| 1418 | FloatWrapper(const IntWrapper& obj) |
| 1419 | : value(static_cast<float>(obj.value)) {} |
| 1420 | operator float() const { |
| 1421 | return value; |
| 1422 | } |
| 1423 | operator IntWrapper() const { |
| 1424 | return IntWrapper(static_cast<int>(value)); |
| 1425 | } |
| 1426 | }; |
| 1427 | |
| 1428 | void is_convertible() |
| 1429 | { |
| 1430 | int t01[T(__is_convertible(IntWrapper, IntWrapper))]; |
| 1431 | int t02[T(__is_convertible(IntWrapper, const IntWrapper))]; |
| 1432 | int t03[T(__is_convertible(IntWrapper, int))]; |
| 1433 | int t04[T(__is_convertible(int, IntWrapper))]; |
| 1434 | int t05[T(__is_convertible(IntWrapper, FloatWrapper))]; |
| 1435 | int t06[T(__is_convertible(FloatWrapper, IntWrapper))]; |
| 1436 | int t07[T(__is_convertible(FloatWrapper, float))]; |
| 1437 | int t08[T(__is_convertible(float, FloatWrapper))]; |
| 1438 | } |
| 1439 | |
Douglas Gregor | 9f36113 | 2011-01-27 20:28:01 +0000 | [diff] [blame] | 1440 | struct FromInt { FromInt(int); }; |
| 1441 | struct ToInt { operator int(); }; |
| 1442 | typedef void Function(); |
| 1443 | |
Douglas Gregor | 1eee5dc | 2011-01-27 22:31:44 +0000 | [diff] [blame] | 1444 | void is_convertible_to(); |
| 1445 | class PrivateCopy { |
| 1446 | PrivateCopy(const PrivateCopy&); |
| 1447 | friend void is_convertible_to(); |
| 1448 | }; |
| 1449 | |
Douglas Gregor | b608b98 | 2011-01-28 02:26:04 +0000 | [diff] [blame] | 1450 | template<typename T> |
| 1451 | struct X0 { |
| 1452 | template<typename U> X0(const X0<U>&); |
| 1453 | }; |
| 1454 | |
Douglas Gregor | 9f36113 | 2011-01-27 20:28:01 +0000 | [diff] [blame] | 1455 | void is_convertible_to() { |
Chandler Carruth | e567e83 | 2011-04-23 20:51:37 +0000 | [diff] [blame] | 1456 | { int arr[T(__is_convertible_to(Int, Int))]; } |
| 1457 | { int arr[F(__is_convertible_to(Int, IntAr))]; } |
| 1458 | { int arr[F(__is_convertible_to(IntAr, IntAr))]; } |
| 1459 | { int arr[T(__is_convertible_to(void, void))]; } |
| 1460 | { int arr[T(__is_convertible_to(cvoid, void))]; } |
| 1461 | { int arr[T(__is_convertible_to(void, cvoid))]; } |
| 1462 | { int arr[T(__is_convertible_to(cvoid, cvoid))]; } |
| 1463 | { int arr[T(__is_convertible_to(int, FromInt))]; } |
| 1464 | { int arr[T(__is_convertible_to(long, FromInt))]; } |
| 1465 | { int arr[T(__is_convertible_to(double, FromInt))]; } |
| 1466 | { int arr[T(__is_convertible_to(const int, FromInt))]; } |
| 1467 | { int arr[T(__is_convertible_to(const int&, FromInt))]; } |
| 1468 | { int arr[T(__is_convertible_to(ToInt, int))]; } |
| 1469 | { int arr[T(__is_convertible_to(ToInt, const int&))]; } |
| 1470 | { int arr[T(__is_convertible_to(ToInt, long))]; } |
| 1471 | { int arr[F(__is_convertible_to(ToInt, int&))]; } |
| 1472 | { int arr[F(__is_convertible_to(ToInt, FromInt))]; } |
| 1473 | { int arr[T(__is_convertible_to(IntAr&, IntAr&))]; } |
| 1474 | { int arr[T(__is_convertible_to(IntAr&, const IntAr&))]; } |
| 1475 | { int arr[F(__is_convertible_to(const IntAr&, IntAr&))]; } |
| 1476 | { int arr[F(__is_convertible_to(Function, Function))]; } |
| 1477 | { int arr[F(__is_convertible_to(PrivateCopy, PrivateCopy))]; } |
| 1478 | { int arr[T(__is_convertible_to(X0<int>, X0<float>))]; } |
Douglas Gregor | 9f36113 | 2011-01-27 20:28:01 +0000 | [diff] [blame] | 1479 | } |
Chandler Carruth | b7e9589 | 2011-04-23 10:47:28 +0000 | [diff] [blame] | 1480 | |
| 1481 | void is_trivial() |
| 1482 | { |
Chandler Carruth | e567e83 | 2011-04-23 20:51:37 +0000 | [diff] [blame] | 1483 | { int arr[T(__is_trivial(int))]; } |
| 1484 | { int arr[T(__is_trivial(Enum))]; } |
| 1485 | { int arr[T(__is_trivial(POD))]; } |
| 1486 | { int arr[T(__is_trivial(Int))]; } |
| 1487 | { int arr[T(__is_trivial(IntAr))]; } |
Chandler Carruth | 018a088 | 2011-04-30 10:31:50 +0000 | [diff] [blame] | 1488 | { int arr[T(__is_trivial(IntArNB))]; } |
Chandler Carruth | e567e83 | 2011-04-23 20:51:37 +0000 | [diff] [blame] | 1489 | { int arr[T(__is_trivial(Statics))]; } |
| 1490 | { int arr[T(__is_trivial(Empty))]; } |
| 1491 | { int arr[T(__is_trivial(EmptyUnion))]; } |
| 1492 | { int arr[T(__is_trivial(Union))]; } |
Chandler Carruth | 34eaaa5 | 2011-04-23 20:51:39 +0000 | [diff] [blame] | 1493 | { int arr[T(__is_trivial(Derives))]; } |
| 1494 | { int arr[T(__is_trivial(DerivesAr))]; } |
Chandler Carruth | 018a088 | 2011-04-30 10:31:50 +0000 | [diff] [blame] | 1495 | { int arr[T(__is_trivial(DerivesArNB))]; } |
Chandler Carruth | 34eaaa5 | 2011-04-23 20:51:39 +0000 | [diff] [blame] | 1496 | { int arr[T(__is_trivial(DerivesEmpty))]; } |
Chandler Carruth | e567e83 | 2011-04-23 20:51:37 +0000 | [diff] [blame] | 1497 | { int arr[T(__is_trivial(HasFunc))]; } |
| 1498 | { int arr[T(__is_trivial(HasOp))]; } |
| 1499 | { int arr[T(__is_trivial(HasConv))]; } |
| 1500 | { int arr[T(__is_trivial(HasAssign))]; } |
| 1501 | { int arr[T(__is_trivial(HasAnonymousUnion))]; } |
Chandler Carruth | e567e83 | 2011-04-23 20:51:37 +0000 | [diff] [blame] | 1502 | { int arr[T(__is_trivial(HasPriv))]; } |
| 1503 | { int arr[T(__is_trivial(HasProt))]; } |
Chandler Carruth | c69f636 | 2011-04-23 21:02:37 +0000 | [diff] [blame] | 1504 | { int arr[T(__is_trivial(DerivesHasPriv))]; } |
| 1505 | { int arr[T(__is_trivial(DerivesHasProt))]; } |
Chandler Carruth | 25df423 | 2011-04-30 10:46:26 +0000 | [diff] [blame] | 1506 | { int arr[T(__is_trivial(Vector))]; } |
| 1507 | { int arr[T(__is_trivial(VectorExt))]; } |
Chandler Carruth | b7e9589 | 2011-04-23 10:47:28 +0000 | [diff] [blame] | 1508 | |
Chandler Carruth | e567e83 | 2011-04-23 20:51:37 +0000 | [diff] [blame] | 1509 | { int arr[F(__is_trivial(HasCons))]; } |
| 1510 | { int arr[F(__is_trivial(HasCopyAssign))]; } |
Chandler Carruth | 4d6e5a2 | 2011-04-23 23:10:33 +0000 | [diff] [blame] | 1511 | { int arr[F(__is_trivial(HasMoveAssign))]; } |
Chandler Carruth | e567e83 | 2011-04-23 20:51:37 +0000 | [diff] [blame] | 1512 | { int arr[F(__is_trivial(HasDest))]; } |
| 1513 | { int arr[F(__is_trivial(HasRef))]; } |
| 1514 | { int arr[F(__is_trivial(HasNonPOD))]; } |
| 1515 | { int arr[F(__is_trivial(HasVirt))]; } |
Chandler Carruth | c69f636 | 2011-04-23 21:02:37 +0000 | [diff] [blame] | 1516 | { int arr[F(__is_trivial(DerivesHasCons))]; } |
| 1517 | { int arr[F(__is_trivial(DerivesHasCopyAssign))]; } |
Chandler Carruth | 4d6e5a2 | 2011-04-23 23:10:33 +0000 | [diff] [blame] | 1518 | { int arr[F(__is_trivial(DerivesHasMoveAssign))]; } |
Chandler Carruth | c69f636 | 2011-04-23 21:02:37 +0000 | [diff] [blame] | 1519 | { int arr[F(__is_trivial(DerivesHasDest))]; } |
| 1520 | { int arr[F(__is_trivial(DerivesHasRef))]; } |
| 1521 | { int arr[F(__is_trivial(DerivesHasVirt))]; } |
Chandler Carruth | e567e83 | 2011-04-23 20:51:37 +0000 | [diff] [blame] | 1522 | { int arr[F(__is_trivial(void))]; } |
| 1523 | { int arr[F(__is_trivial(cvoid))]; } |
Chandler Carruth | b7e9589 | 2011-04-23 10:47:28 +0000 | [diff] [blame] | 1524 | } |
John Wiegley | 21ff2e5 | 2011-04-28 00:16:57 +0000 | [diff] [blame] | 1525 | |
Sean Hunt | feb375d | 2011-05-13 00:31:07 +0000 | [diff] [blame] | 1526 | void is_trivially_copyable() |
| 1527 | { |
| 1528 | { int arr[T(__is_trivially_copyable(int))]; } |
| 1529 | { int arr[T(__is_trivially_copyable(Enum))]; } |
| 1530 | { int arr[T(__is_trivially_copyable(POD))]; } |
| 1531 | { int arr[T(__is_trivially_copyable(Int))]; } |
| 1532 | { int arr[T(__is_trivially_copyable(IntAr))]; } |
| 1533 | { int arr[T(__is_trivially_copyable(IntArNB))]; } |
| 1534 | { int arr[T(__is_trivially_copyable(Statics))]; } |
| 1535 | { int arr[T(__is_trivially_copyable(Empty))]; } |
| 1536 | { int arr[T(__is_trivially_copyable(EmptyUnion))]; } |
| 1537 | { int arr[T(__is_trivially_copyable(Union))]; } |
| 1538 | { int arr[T(__is_trivially_copyable(Derives))]; } |
| 1539 | { int arr[T(__is_trivially_copyable(DerivesAr))]; } |
| 1540 | { int arr[T(__is_trivially_copyable(DerivesArNB))]; } |
| 1541 | { int arr[T(__is_trivially_copyable(DerivesEmpty))]; } |
| 1542 | { int arr[T(__is_trivially_copyable(HasFunc))]; } |
| 1543 | { int arr[T(__is_trivially_copyable(HasOp))]; } |
| 1544 | { int arr[T(__is_trivially_copyable(HasConv))]; } |
| 1545 | { int arr[T(__is_trivially_copyable(HasAssign))]; } |
| 1546 | { int arr[T(__is_trivially_copyable(HasAnonymousUnion))]; } |
| 1547 | { int arr[T(__is_trivially_copyable(HasPriv))]; } |
| 1548 | { int arr[T(__is_trivially_copyable(HasProt))]; } |
| 1549 | { int arr[T(__is_trivially_copyable(DerivesHasPriv))]; } |
| 1550 | { int arr[T(__is_trivially_copyable(DerivesHasProt))]; } |
| 1551 | { int arr[T(__is_trivially_copyable(Vector))]; } |
| 1552 | { int arr[T(__is_trivially_copyable(VectorExt))]; } |
| 1553 | { int arr[T(__is_trivially_copyable(HasCons))]; } |
| 1554 | { int arr[T(__is_trivially_copyable(HasRef))]; } |
| 1555 | { int arr[T(__is_trivially_copyable(HasNonPOD))]; } |
| 1556 | { int arr[T(__is_trivially_copyable(DerivesHasCons))]; } |
| 1557 | { int arr[T(__is_trivially_copyable(DerivesHasRef))]; } |
| 1558 | |
| 1559 | { int arr[F(__is_trivially_copyable(HasCopyAssign))]; } |
| 1560 | { int arr[F(__is_trivially_copyable(HasMoveAssign))]; } |
| 1561 | { int arr[F(__is_trivially_copyable(HasDest))]; } |
| 1562 | { int arr[F(__is_trivially_copyable(HasVirt))]; } |
| 1563 | { int arr[F(__is_trivially_copyable(DerivesHasCopyAssign))]; } |
| 1564 | { int arr[F(__is_trivially_copyable(DerivesHasMoveAssign))]; } |
| 1565 | { int arr[F(__is_trivially_copyable(DerivesHasDest))]; } |
| 1566 | { int arr[F(__is_trivially_copyable(DerivesHasVirt))]; } |
| 1567 | { int arr[F(__is_trivially_copyable(void))]; } |
| 1568 | { int arr[F(__is_trivially_copyable(cvoid))]; } |
| 1569 | } |
| 1570 | |
John Wiegley | 21ff2e5 | 2011-04-28 00:16:57 +0000 | [diff] [blame] | 1571 | void array_rank() { |
| 1572 | int t01[T(__array_rank(IntAr) == 1)]; |
| 1573 | int t02[T(__array_rank(ConstIntArAr) == 2)]; |
| 1574 | } |
| 1575 | |
| 1576 | void array_extent() { |
| 1577 | int t01[T(__array_extent(IntAr, 0) == 10)]; |
| 1578 | int t02[T(__array_extent(ConstIntArAr, 0) == 4)]; |
| 1579 | int t03[T(__array_extent(ConstIntArAr, 1) == 10)]; |
| 1580 | } |