Home | History | Annotate | Download | only in time.clock.hires
      1 //===----------------------------------------------------------------------===//
      2 //
      3 //                     The LLVM Compiler Infrastructure
      4 //
      5 // This file is dual licensed under the MIT and the University of Illinois Open
      6 // Source Licenses. See LICENSE.TXT for details.
      7 //
      8 //===----------------------------------------------------------------------===//
      9 //
     10 // Due to C++17 inline variables ASAN flags this test as containing an ODR
     11 // violation because Clock::is_steady is defined in both the dylib and this TU.
     12 // UNSUPPORTED: asan
     13 
     14 // Starting with C++17, Clock::is_steady is inlined (but not before LLVM-3.9!),
     15 // but before C++17 it requires the symbol to be present in the dylib, which
     16 // is only shipped starting with macosx10.9.
     17 // XFAIL: with_system_cxx_lib=macosx10.7 && (c++98 || c++03 || c++11 || c++14 || apple-clang-7 || apple-clang-8.0)
     18 // XFAIL: with_system_cxx_lib=macosx10.8 && (c++98 || c++03 || c++11 || c++14 || apple-clang-7 || apple-clang-8.0)
     19 
     20 // <chrono>
     21 
     22 // high_resolution_clock
     23 
     24 // check clock invariants
     25 
     26 #include <chrono>
     27 
     28 template <class T>
     29 void test(const T &) {}
     30 
     31 int main()
     32 {
     33     typedef std::chrono::high_resolution_clock C;
     34     static_assert((std::is_same<C::rep, C::duration::rep>::value), "");
     35     static_assert((std::is_same<C::period, C::duration::period>::value), "");
     36     static_assert((std::is_same<C::duration, C::time_point::duration>::value), "");
     37     static_assert(C::is_steady || !C::is_steady, "");
     38     test(std::chrono::high_resolution_clock::is_steady);
     39 }
     40