mirror of
https://github.com/google/benchmark.git
synced 2024-11-28 05:44:40 +00:00
Fix unit tests compilation with non-gnu / non-msvc compilers with c++11 support. (#1691)
donotoptimize_test.cc could not be compiled under non-gnu / non-msvc compilers, because only deprecated version of DoNotOptimize is available for these compilers. Tests are compiled with -Werror. Patch fixes test compilation by providing non-deprecated version of DoNotOptimize for compilers with c++11 standard support. Co-authored-by: dominic <510002+dmah42@users.noreply.github.com>
This commit is contained in:
parent
3623765dd3
commit
b40db86945
|
@ -584,6 +584,12 @@ inline BENCHMARK_ALWAYS_INLINE void DoNotOptimize(Tp const& value) {
|
|||
inline BENCHMARK_ALWAYS_INLINE void ClobberMemory() { _ReadWriteBarrier(); }
|
||||
#endif
|
||||
#else
|
||||
#ifdef BENCHMARK_HAS_CXX11
|
||||
template <class Tp>
|
||||
inline BENCHMARK_ALWAYS_INLINE void DoNotOptimize(Tp&& value) {
|
||||
internal::UseCharPointer(&reinterpret_cast<char const volatile&>(value));
|
||||
}
|
||||
#else
|
||||
template <class Tp>
|
||||
BENCHMARK_DEPRECATED_MSG(
|
||||
"The const-ref version of this method can permit "
|
||||
|
@ -591,6 +597,12 @@ BENCHMARK_DEPRECATED_MSG(
|
|||
inline BENCHMARK_ALWAYS_INLINE void DoNotOptimize(Tp const& value) {
|
||||
internal::UseCharPointer(&reinterpret_cast<char const volatile&>(value));
|
||||
}
|
||||
|
||||
template <class Tp>
|
||||
inline BENCHMARK_ALWAYS_INLINE void DoNotOptimize(Tp& value) {
|
||||
internal::UseCharPointer(&reinterpret_cast<char const volatile&>(value));
|
||||
}
|
||||
#endif
|
||||
// FIXME Add ClobberMemory() for non-gnu and non-msvc compilers, before C++11.
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Reference in a new issue