@@ -1484,14 +1484,29 @@ class Fixture : public Benchmark {
14841484// ------------------------------------------------------
14851485// Macro to register benchmarks
14861486
1487+ // clang-format off
1488+ #if defined(__clang__)
1489+ #define BENCHMARK_DISABLE_COUNTER_WARNING \
1490+ _Pragma (" GCC diagnostic push" ) \
1491+ _Pragma(" GCC diagnostic ignored \" -Wunknown-warning-option\" " ) \
1492+ _Pragma(" GCC diagnostic ignored \" -Wc2y-extensions\" " )
1493+ #define BENCHMARK_RESTORE_COUNTER_WARNING _Pragma (" GCC diagnostic pop" )
1494+ #else
1495+ #define BENCHMARK_DISABLE_COUNTER_WARNING
1496+ #define BENCHMARK_RESTORE_COUNTER_WARNING
1497+ #endif
1498+ // clang-format on
1499+
14871500// Check that __COUNTER__ is defined and that __COUNTER__ increases by 1
14881501// every time it is expanded. X + 1 == X + 0 is used in case X is defined to be
14891502// empty. If X is empty the expression becomes (+1 == +0).
1503+ BENCHMARK_DISABLE_COUNTER_WARNING
14901504#if defined(__COUNTER__) && (__COUNTER__ + 1 == __COUNTER__ + 0)
14911505#define BENCHMARK_PRIVATE_UNIQUE_ID __COUNTER__
14921506#else
14931507#define BENCHMARK_PRIVATE_UNIQUE_ID __LINE__
14941508#endif
1509+ BENCHMARK_RESTORE_COUNTER_WARNING
14951510
14961511// Helpers for generating unique variable names
14971512#define BENCHMARK_PRIVATE_NAME (...) \
@@ -1505,9 +1520,10 @@ class Fixture : public Benchmark {
15051520 BaseClass##_##Method##_Benchmark
15061521
15071522#define BENCHMARK_PRIVATE_DECLARE (n ) \
1523+ BENCHMARK_DISABLE_COUNTER_WARNING \
15081524 /* NOLINTNEXTLINE(misc-use-anonymous-namespace) */ \
15091525 static ::benchmark::Benchmark const * const BENCHMARK_PRIVATE_NAME (n) \
1510- BENCHMARK_UNUSED
1526+ BENCHMARK_RESTORE_COUNTER_WARNING BENCHMARK_UNUSED
15111527
15121528#define BENCHMARK (...) \
15131529 BENCHMARK_PRIVATE_DECLARE (_benchmark_) = \
@@ -1695,9 +1711,11 @@ class Fixture : public Benchmark {
16951711 ::benchmark::internal::make_unique<UniqueName>()))
16961712
16971713#define BENCHMARK_TEMPLATE_INSTANTIATE_F (BaseClass, Method, ...) \
1714+ BENCHMARK_DISABLE_COUNTER_WARNING \
16981715 BENCHMARK_TEMPLATE_PRIVATE_INSTANTIATE_F ( \
16991716 BaseClass, Method, BENCHMARK_PRIVATE_NAME (BaseClass##Method), \
1700- __VA_ARGS__)
1717+ __VA_ARGS__) \
1718+ BENCHMARK_RESTORE_COUNTER_WARNING
17011719
17021720// This macro will define and register a benchmark within a fixture class.
17031721#define BENCHMARK_F (BaseClass, Method ) \
0 commit comments