has_feature_cxx0x.cpp 10 KB

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