has_feature_cxx0x.cpp revision 7f0ffb3a9f4ce7428fd4f6eb3c3274c867c134f8
1// RUN: %clang_cc1 -E -triple x86_64-linux-gnu -std=c++11 %s -o - | FileCheck --check-prefix=CHECK-11 %s
2// RUN: %clang_cc1 -E -triple armv7-apple-darwin -std=c++11 %s -o - | FileCheck --check-prefix=CHECK-NO-TLS %s
3// RUN: %clang_cc1 -E -triple x86_64-linux-gnu %s -o - | FileCheck --check-prefix=CHECK-NO-11 %s
4// RUN: %clang_cc1 -E -triple x86_64-linux-gnu -std=c++1y %s -o - | FileCheck --check-prefix=CHECK-1Y %s
5
6#if __has_feature(cxx_atomic)
7int has_atomic();
8#else
9int no_atomic();
10#endif
11
12// CHECK-1Y: has_atomic
13// CHECK-11: has_atomic
14// CHECK-NO-11: no_atomic
15
16#if __has_feature(cxx_lambdas)
17int has_lambdas();
18#else
19int no_lambdas();
20#endif
21
22// CHECK-1Y: has_lambdas
23// CHECK-11: has_lambdas
24// CHECK-NO-11: no_lambdas
25
26
27#if __has_feature(cxx_nullptr)
28int has_nullptr();
29#else
30int no_nullptr();
31#endif
32
33// CHECK-1Y: has_nullptr
34// CHECK-11: has_nullptr
35// CHECK-NO-11: no_nullptr
36
37
38#if __has_feature(cxx_decltype)
39int has_decltype();
40#else
41int no_decltype();
42#endif
43
44// CHECK-1Y: has_decltype
45// CHECK-11: has_decltype
46// CHECK-NO-11: no_decltype
47
48
49#if __has_feature(cxx_decltype_incomplete_return_types)
50int has_decltype_incomplete_return_types();
51#else
52int no_decltype_incomplete_return_types();
53#endif
54
55// CHECK-1Y: has_decltype_incomplete_return_types
56// CHECK-11: has_decltype_incomplete_return_types
57// CHECK-NO-11: no_decltype_incomplete_return_types
58
59
60#if __has_feature(cxx_auto_type)
61int has_auto_type();
62#else
63int no_auto_type();
64#endif
65
66// CHECK-1Y: has_auto_type
67// CHECK-11: has_auto_type
68// CHECK-NO-11: no_auto_type
69
70
71#if __has_feature(cxx_trailing_return)
72int has_trailing_return();
73#else
74int no_trailing_return();
75#endif
76
77// CHECK-1Y: has_trailing_return
78// CHECK-11: has_trailing_return
79// CHECK-NO-11: no_trailing_return
80
81
82#if __has_feature(cxx_attributes)
83int has_attributes();
84#else
85int no_attributes();
86#endif
87
88// CHECK-1Y: has_attributes
89// CHECK-11: has_attributes
90// CHECK-NO-11: no_attributes
91
92
93#if __has_feature(cxx_static_assert)
94int has_static_assert();
95#else
96int no_static_assert();
97#endif
98
99// CHECK-1Y: has_static_assert
100// CHECK-11: has_static_assert
101// CHECK-NO-11: no_static_assert
102
103#if __has_feature(cxx_deleted_functions)
104int has_deleted_functions();
105#else
106int no_deleted_functions();
107#endif
108
109// CHECK-1Y: has_deleted_functions
110// CHECK-11: has_deleted_functions
111// CHECK-NO-11: no_deleted_functions
112
113#if __has_feature(cxx_defaulted_functions)
114int has_defaulted_functions();
115#else
116int no_defaulted_functions();
117#endif
118
119// CHECK-1Y: has_defaulted_functions
120// CHECK-11: has_defaulted_functions
121// CHECK-NO-11: no_defaulted_functions
122
123#if __has_feature(cxx_rvalue_references)
124int has_rvalue_references();
125#else
126int no_rvalue_references();
127#endif
128
129// CHECK-1Y: has_rvalue_references
130// CHECK-11: has_rvalue_references
131// CHECK-NO-11: no_rvalue_references
132
133
134#if __has_feature(cxx_variadic_templates)
135int has_variadic_templates();
136#else
137int no_variadic_templates();
138#endif
139
140// CHECK-1Y: has_variadic_templates
141// CHECK-11: has_variadic_templates
142// CHECK-NO-11: no_variadic_templates
143
144
145#if __has_feature(cxx_inline_namespaces)
146int has_inline_namespaces();
147#else
148int no_inline_namespaces();
149#endif
150
151// CHECK-1Y: has_inline_namespaces
152// CHECK-11: has_inline_namespaces
153// CHECK-NO-11: no_inline_namespaces
154
155
156#if __has_feature(cxx_range_for)
157int has_range_for();
158#else
159int no_range_for();
160#endif
161
162// CHECK-1Y: has_range_for
163// CHECK-11: has_range_for
164// CHECK-NO-11: no_range_for
165
166
167#if __has_feature(cxx_reference_qualified_functions)
168int has_reference_qualified_functions();
169#else
170int no_reference_qualified_functions();
171#endif
172
173// CHECK-1Y: has_reference_qualified_functions
174// CHECK-11: has_reference_qualified_functions
175// CHECK-NO-11: no_reference_qualified_functions
176
177#if __has_feature(cxx_default_function_template_args)
178int has_default_function_template_args();
179#else
180int no_default_function_template_args();
181#endif
182
183// CHECK-1Y: has_default_function_template_args
184// CHECK-11: has_default_function_template_args
185// CHECK-NO-11: no_default_function_template_args
186
187#if __has_feature(cxx_noexcept)
188int has_noexcept();
189#else
190int no_noexcept();
191#endif
192
193// CHECK-1Y: has_noexcept
194// CHECK-11: has_noexcept
195// CHECK-NO-11: no_noexcept
196
197#if __has_feature(cxx_override_control)
198int has_override_control();
199#else
200int no_override_control();
201#endif
202
203// CHECK-1Y: has_override_control
204// CHECK-11: has_override_control
205// CHECK-NO-11: no_override_control
206
207#if __has_feature(cxx_alias_templates)
208int has_alias_templates();
209#else
210int no_alias_templates();
211#endif
212
213// CHECK-1Y: has_alias_templates
214// CHECK-11: has_alias_templates
215// CHECK-NO-11: no_alias_templates
216
217#if __has_feature(cxx_implicit_moves)
218int has_implicit_moves();
219#else
220int no_implicit_moves();
221#endif
222
223// CHECK-1Y: has_implicit_moves
224// CHECK-11: has_implicit_moves
225// CHECK-NO-11: no_implicit_moves
226
227#if __has_feature(cxx_alignas)
228int has_alignas();
229#else
230int no_alignas();
231#endif
232
233// CHECK-1Y: has_alignas
234// CHECK-11: has_alignas
235// CHECK-NO-11: no_alignas
236
237#if __has_feature(cxx_raw_string_literals)
238int has_raw_string_literals();
239#else
240int no_raw_string_literals();
241#endif
242
243// CHECK-1Y: has_raw_string_literals
244// CHECK-11: has_raw_string_literals
245// CHECK-NO-11: no_raw_string_literals
246
247#if __has_feature(cxx_unicode_literals)
248int has_unicode_literals();
249#else
250int no_unicode_literals();
251#endif
252
253// CHECK-1Y: has_unicode_literals
254// CHECK-11: has_unicode_literals
255// CHECK-NO-11: no_unicode_literals
256
257#if __has_feature(cxx_constexpr)
258int has_constexpr();
259#else
260int no_constexpr();
261#endif
262
263// CHECK-1Y: has_constexpr
264// CHECK-11: has_constexpr
265// CHECK-NO-11: no_constexpr
266
267#if __has_feature(cxx_generalized_initializers)
268int has_generalized_initializers();
269#else
270int no_generalized_initializers();
271#endif
272
273// CHECK-1Y: has_generalized_initializers
274// CHECK-11: has_generalized_initializers
275// CHECK-NO-11: no_generalized_initializers
276
277#if __has_feature(cxx_unrestricted_unions)
278int has_unrestricted_unions();
279#else
280int no_unrestricted_unions();
281#endif
282
283// CHECK-1Y: has_unrestricted_unions
284// CHECK-11: has_unrestricted_unions
285// CHECK-NO-11: no_unrestricted_unions
286
287#if __has_feature(cxx_user_literals)
288int has_user_literals();
289#else
290int no_user_literals();
291#endif
292
293// CHECK-1Y: has_user_literals
294// CHECK-11: has_user_literals
295// CHECK-NO-11: no_user_literals
296
297#if __has_feature(cxx_local_type_template_args)
298int has_local_type_template_args();
299#else
300int no_local_type_template_args();
301#endif
302
303// CHECK-1Y: has_local_type_template_args
304// CHECK-11: has_local_type_template_args
305// CHECK-NO-11: no_local_type_template_args
306
307#if __has_feature(cxx_inheriting_constructors)
308int has_inheriting_constructors();
309#else
310int no_inheriting_constructors();
311#endif
312
313// CHECK-1Y: has_inheriting_constructors
314// CHECK-11: has_inheriting_constructors
315// CHECK-NO-11: no_inheriting_constructors
316
317#if __has_feature(cxx_thread_local)
318int has_thread_local();
319#else
320int no_thread_local();
321#endif
322
323// CHECK-1Y: has_thread_local
324// CHECK-11: has_thread_local
325// CHECK-NO-11: no_thread_local
326// CHECK-NO-TLS: no_thread_local
327
328// === C++1y features ===
329
330#if __has_feature(cxx_binary_literals)
331int has_binary_literals();
332#else
333int no_binary_literals();
334#endif
335
336// CHECK-1Y: has_binary_literals
337// CHECK-11: no_binary_literals
338// CHECK-NO-11: no_binary_literals
339
340#if __has_feature(cxx_aggregate_nsdmi)
341int has_aggregate_nsdmi();
342#else
343int no_aggregate_nsdmi();
344#endif
345
346// CHECK-1Y: has_aggregate_nsdmi
347// CHECK-11: no_aggregate_nsdmi
348// CHECK-NO-11: no_aggregate_nsdmi
349