atomic.version.pass.cpp 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. //===----------------------------------------------------------------------===//
  2. //
  3. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  4. // See https://llvm.org/LICENSE.txt for license information.
  5. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  6. //
  7. //===----------------------------------------------------------------------===//
  8. //
  9. // WARNING: This test was generated by generate_feature_test_macro_components.py
  10. // and should not be edited manually.
  11. // UNSUPPORTED: libcpp-has-no-threads
  12. // <atomic>
  13. // Test the feature test macros defined by <atomic>
  14. /* Constant Value
  15. __cpp_lib_atomic_is_always_lock_free 201603L [C++17]
  16. __cpp_lib_atomic_ref 201806L [C++2a]
  17. __cpp_lib_char8_t 201811L [C++2a]
  18. */
  19. #include <atomic>
  20. #include "test_macros.h"
  21. #if TEST_STD_VER < 14
  22. # ifdef __cpp_lib_atomic_is_always_lock_free
  23. # error "__cpp_lib_atomic_is_always_lock_free should not be defined before c++17"
  24. # endif
  25. # ifdef __cpp_lib_atomic_ref
  26. # error "__cpp_lib_atomic_ref should not be defined before c++2a"
  27. # endif
  28. # ifdef __cpp_lib_char8_t
  29. # error "__cpp_lib_char8_t should not be defined before c++2a"
  30. # endif
  31. #elif TEST_STD_VER == 14
  32. # ifdef __cpp_lib_atomic_is_always_lock_free
  33. # error "__cpp_lib_atomic_is_always_lock_free should not be defined before c++17"
  34. # endif
  35. # ifdef __cpp_lib_atomic_ref
  36. # error "__cpp_lib_atomic_ref should not be defined before c++2a"
  37. # endif
  38. # ifdef __cpp_lib_char8_t
  39. # error "__cpp_lib_char8_t should not be defined before c++2a"
  40. # endif
  41. #elif TEST_STD_VER == 17
  42. # if !defined(_LIBCPP_HAS_NO_THREADS)
  43. # ifndef __cpp_lib_atomic_is_always_lock_free
  44. # error "__cpp_lib_atomic_is_always_lock_free should be defined in c++17"
  45. # endif
  46. # if __cpp_lib_atomic_is_always_lock_free != 201603L
  47. # error "__cpp_lib_atomic_is_always_lock_free should have the value 201603L in c++17"
  48. # endif
  49. # else
  50. # ifdef __cpp_lib_atomic_is_always_lock_free
  51. # error "__cpp_lib_atomic_is_always_lock_free should not be defined when !defined(_LIBCPP_HAS_NO_THREADS) is not defined!"
  52. # endif
  53. # endif
  54. # ifdef __cpp_lib_atomic_ref
  55. # error "__cpp_lib_atomic_ref should not be defined before c++2a"
  56. # endif
  57. # ifdef __cpp_lib_char8_t
  58. # error "__cpp_lib_char8_t should not be defined before c++2a"
  59. # endif
  60. #elif TEST_STD_VER > 17
  61. # if !defined(_LIBCPP_HAS_NO_THREADS)
  62. # ifndef __cpp_lib_atomic_is_always_lock_free
  63. # error "__cpp_lib_atomic_is_always_lock_free should be defined in c++2a"
  64. # endif
  65. # if __cpp_lib_atomic_is_always_lock_free != 201603L
  66. # error "__cpp_lib_atomic_is_always_lock_free should have the value 201603L in c++2a"
  67. # endif
  68. # else
  69. # ifdef __cpp_lib_atomic_is_always_lock_free
  70. # error "__cpp_lib_atomic_is_always_lock_free should not be defined when !defined(_LIBCPP_HAS_NO_THREADS) is not defined!"
  71. # endif
  72. # endif
  73. # if !defined(_LIBCPP_VERSION)
  74. # ifndef __cpp_lib_atomic_ref
  75. # error "__cpp_lib_atomic_ref should be defined in c++2a"
  76. # endif
  77. # if __cpp_lib_atomic_ref != 201806L
  78. # error "__cpp_lib_atomic_ref should have the value 201806L in c++2a"
  79. # endif
  80. # else // _LIBCPP_VERSION
  81. # ifdef __cpp_lib_atomic_ref
  82. # error "__cpp_lib_atomic_ref should not be defined because it is unimplemented in libc++!"
  83. # endif
  84. # endif
  85. # if defined(__cpp_char8_t)
  86. # ifndef __cpp_lib_char8_t
  87. # error "__cpp_lib_char8_t should be defined in c++2a"
  88. # endif
  89. # if __cpp_lib_char8_t != 201811L
  90. # error "__cpp_lib_char8_t should have the value 201811L in c++2a"
  91. # endif
  92. # else
  93. # ifdef __cpp_lib_char8_t
  94. # error "__cpp_lib_char8_t should not be defined when defined(__cpp_char8_t) is not defined!"
  95. # endif
  96. # endif
  97. #endif // TEST_STD_VER > 17
  98. int main(int, char**) { return 0; }