cxx-features.cpp 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. // RUN: %clang_cc1 -std=c++98 -verify %s
  2. // RUN: %clang_cc1 -std=c++11 -verify %s
  3. // RUN: %clang_cc1 -std=c++1y -fsized-deallocation -verify %s
  4. // RUN: %clang_cc1 -std=c++1y -fsized-deallocation -fconcepts-ts -DCONCEPTS_TS=1 -verify %s
  5. // expected-no-diagnostics
  6. #if __cplusplus < 201103L
  7. #define check(macro, cxx98, cxx11, cxx1y) cxx98 == 0 ? defined(__cpp_##macro) : __cpp_##macro != cxx98
  8. #elif __cplusplus < 201304L
  9. #define check(macro, cxx98, cxx11, cxx1y) cxx11 == 0 ? defined(__cpp_##macro) : __cpp_##macro != cxx11
  10. #else
  11. #define check(macro, cxx98, cxx11, cxx1y) cxx1y == 0 ? defined(__cpp_##macro) : __cpp_##macro != cxx1y
  12. #endif
  13. #if check(binary_literals, 0, 0, 201304)
  14. #error "wrong value for __cpp_binary_literals"
  15. #endif
  16. #if check(digit_separators, 0, 0, 201309)
  17. #error "wrong value for __cpp_digit_separators"
  18. #endif
  19. #if check(init_captures, 0, 0, 201304)
  20. #error "wrong value for __cpp_init_captures"
  21. #endif
  22. #if check(generic_lambdas, 0, 0, 201304)
  23. #error "wrong value for __cpp_generic_lambdas"
  24. #endif
  25. #if check(sized_deallocation, 0, 0, 201309)
  26. #error "wrong value for __cpp_sized_deallocation"
  27. #endif
  28. #if check(constexpr, 0, 200704, 201304)
  29. #error "wrong value for __cpp_constexpr"
  30. #endif
  31. #if check(decltype_auto, 0, 0, 201304)
  32. #error "wrong value for __cpp_decltype_auto"
  33. #endif
  34. #if check(return_type_deduction, 0, 0, 201304)
  35. #error "wrong value for __cpp_return_type_deduction"
  36. #endif
  37. #if check(runtime_arrays, 0, 0, 0)
  38. #error "wrong value for __cpp_runtime_arrays"
  39. #endif
  40. #if check(aggregate_nsdmi, 0, 0, 201304)
  41. #error "wrong value for __cpp_aggregate_nsdmi"
  42. #endif
  43. #if check(variable_templates, 0, 0, 201304)
  44. #error "wrong value for __cpp_variable_templates"
  45. #endif
  46. #if check(unicode_characters, 0, 200704, 200704)
  47. #error "wrong value for __cpp_unicode_characters"
  48. #endif
  49. #if check(raw_strings, 0, 200710, 200710)
  50. #error "wrong value for __cpp_raw_strings"
  51. #endif
  52. #if check(unicode_literals, 0, 200710, 200710)
  53. #error "wrong value for __cpp_unicode_literals"
  54. #endif
  55. #if check(user_defined_literals, 0, 200809, 200809)
  56. #error "wrong value for __cpp_user_defined_literals"
  57. #endif
  58. #if check(lambdas, 0, 200907, 200907)
  59. #error "wrong value for __cpp_lambdas"
  60. #endif
  61. #if check(range_based_for, 0, 200907, 200907)
  62. #error "wrong value for __cpp_range_based_for"
  63. #endif
  64. #if check(static_assert, 0, 200410, 200410)
  65. #error "wrong value for __cpp_static_assert"
  66. #endif
  67. #if check(decltype, 0, 200707, 200707)
  68. #error "wrong value for __cpp_decltype"
  69. #endif
  70. #if check(attributes, 0, 200809, 200809)
  71. #error "wrong value for __cpp_attributes"
  72. #endif
  73. #if check(rvalue_references, 0, 200610, 200610)
  74. #error "wrong value for __cpp_rvalue_references"
  75. #endif
  76. #if check(variadic_templates, 0, 200704, 200704)
  77. #error "wrong value for __cpp_variadic_templates"
  78. #endif
  79. #if check(initializer_lists, 0, 200806, 200806)
  80. #error "wrong value for __cpp_initializer_lists"
  81. #endif
  82. #if check(delegating_constructors, 0, 200604, 200604)
  83. #error "wrong value for __cpp_delegating_constructors"
  84. #endif
  85. #if check(nsdmi, 0, 200809, 200809)
  86. #error "wrong value for __cpp_nsdmi"
  87. #endif
  88. #if check(inheriting_constructors, 0, 200802, 200802)
  89. #error "wrong value for __cpp_inheriting_constructors"
  90. #endif
  91. #if check(ref_qualifiers, 0, 200710, 200710)
  92. #error "wrong value for __cpp_ref_qualifiers"
  93. #endif
  94. #if check(alias_templates, 0, 200704, 200704)
  95. #error "wrong value for __cpp_alias_templates"
  96. #endif
  97. #if check(experimental_concepts, 0, 0, CONCEPTS_TS)
  98. #error "wrong value for __cpp_experimental_concepts"
  99. #endif