consistency.pass.cpp 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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. // Due to C++17 inline variables ASAN flags this test as containing an ODR
  10. // violation because Clock::is_steady is defined in both the dylib and this TU.
  11. // UNSUPPORTED: asan
  12. // Starting with C++17, Clock::is_steady is inlined (but not before LLVM-3.9!),
  13. // but before C++17 it requires the symbol to be present in the dylib, which
  14. // is only shipped starting with macosx10.9.
  15. // XFAIL: with_system_cxx_lib=macosx10.7 && (c++98 || c++03 || c++11 || c++14 || apple-clang-7 || apple-clang-8.0)
  16. // XFAIL: with_system_cxx_lib=macosx10.8 && (c++98 || c++03 || c++11 || c++14 || apple-clang-7 || apple-clang-8.0)
  17. // <chrono>
  18. // high_resolution_clock
  19. // check clock invariants
  20. #include <chrono>
  21. #include "test_macros.h"
  22. template <class T>
  23. void test(const T &) {}
  24. int main(int, char**)
  25. {
  26. typedef std::chrono::high_resolution_clock C;
  27. static_assert((std::is_same<C::rep, C::duration::rep>::value), "");
  28. static_assert((std::is_same<C::period, C::duration::period>::value), "");
  29. static_assert((std::is_same<C::duration, C::time_point::duration>::value), "");
  30. static_assert(C::is_steady || !C::is_steady, "");
  31. test(std::chrono::high_resolution_clock::is_steady);
  32. return 0;
  33. }