diff --git a/include/benchmark/benchmark.h b/include/benchmark/benchmark.h index 3938f765..96b5b53c 100644 --- a/include/benchmark/benchmark.h +++ b/include/benchmark/benchmark.h @@ -242,12 +242,19 @@ BENCHMARK(BM_test)->Unit(benchmark::kMillisecond); #if defined(__GNUC__) || defined(__clang__) #define BENCHMARK_BUILTIN_EXPECT(x, y) __builtin_expect(x, y) #define BENCHMARK_DEPRECATED_MSG(msg) __attribute__((deprecated(msg))) +#define BENCHMARK_DISABLE_DEPRECATED_WARNING \ + _Pragma("GCC diagnostic push") \ + _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"") +#define BENCHMARK_RESTORE_DEPRECATED_WARNING \ + _Pragma("GCC diagnostic pop") #else #define BENCHMARK_BUILTIN_EXPECT(x, y) x #define BENCHMARK_DEPRECATED_MSG(msg) #define BENCHMARK_WARNING_MSG(msg) \ __pragma(message(__FILE__ "(" BENCHMARK_INTERNAL_TOSTRING( \ __LINE__) ") : warning note: " msg)) +#define BENCHMARK_DISABLE_DEPRECATED_WARNING +#define BENCHMARK_RESTORE_DEPRECATED_WARNING #endif #if defined(__GNUC__) && !defined(__clang__) @@ -339,7 +346,9 @@ class MemoryManager { virtual void Stop(Result* result) = 0; // FIXME(vyng): Make this pure virtual once we've migrated current users. + BENCHMARK_DISABLE_DEPRECATED_WARNING virtual void Stop(Result& result) { Stop(&result); } + BENCHMARK_RESTORE_DEPRECATED_WARNING }; // Register a MemoryManager instance that will be used to collect and report diff --git a/src/benchmark.cc b/src/benchmark.cc index 5cb28b73..28d9368e 100644 --- a/src/benchmark.cc +++ b/src/benchmark.cc @@ -378,10 +378,7 @@ void RunBenchmarks(const std::vector& benchmarks, // Disable deprecated warnings temporarily because we need to reference // CSVReporter but don't want to trigger -Werror=-Wdeprecated-declarations -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" -#endif +BENCHMARK_DISABLE_DEPRECATED_WARNING std::unique_ptr CreateReporter( std::string const& name, ConsoleReporter::OutputOptions output_opts) { @@ -398,9 +395,7 @@ std::unique_ptr CreateReporter( } } -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +BENCHMARK_RESTORE_DEPRECATED_WARNING } // end namespace diff --git a/src/benchmark_runner.cc b/src/benchmark_runner.cc index 84ed3bf8..fd23d468 100644 --- a/src/benchmark_runner.cc +++ b/src/benchmark_runner.cc @@ -321,7 +321,9 @@ void BenchmarkRunner::DoOneRepetition() { manager->WaitForAllThreads(); manager.reset(); + BENCHMARK_DISABLE_DEPRECATED_WARNING memory_manager->Stop(memory_result); + BENCHMARK_RESTORE_DEPRECATED_WARNING } // Ok, now actually report. diff --git a/test/output_test_helper.cc b/test/output_test_helper.cc index 95fe0d00..871e6de2 100644 --- a/test/output_test_helper.cc +++ b/test/output_test_helper.cc @@ -384,10 +384,8 @@ int SetSubstitutions( // Disable deprecated warnings temporarily because we need to reference // CSVReporter but don't want to trigger -Werror=-Wdeprecated-declarations -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" -#endif +BENCHMARK_DISABLE_DEPRECATED_WARNING + void RunOutputTests(int argc, char* argv[]) { using internal::GetTestCaseList; benchmark::Initialize(&argc, argv); @@ -446,9 +444,7 @@ void RunOutputTests(int argc, char* argv[]) { internal::GetResultsChecker().CheckResults(csv.out_stream); } -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +BENCHMARK_RESTORE_DEPRECATED_WARNING int SubstrCnt(const std::string& haystack, const std::string& pat) { if (pat.length() == 0) return 0;