mirror of
https://github.com/google/benchmark.git
synced 2024-12-27 13:00:36 +08: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(); }
|
inline BENCHMARK_ALWAYS_INLINE void ClobberMemory() { _ReadWriteBarrier(); }
|
||||||
#endif
|
#endif
|
||||||
#else
|
#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>
|
template <class Tp>
|
||||||
BENCHMARK_DEPRECATED_MSG(
|
BENCHMARK_DEPRECATED_MSG(
|
||||||
"The const-ref version of this method can permit "
|
"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) {
|
inline BENCHMARK_ALWAYS_INLINE void DoNotOptimize(Tp const& value) {
|
||||||
internal::UseCharPointer(&reinterpret_cast<char const volatile&>(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.
|
// FIXME Add ClobberMemory() for non-gnu and non-msvc compilers, before C++11.
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user