Silence -Wc2y-extensions warning around __COUNTER__#2108
Conversation
|
Tested this locally with cmake -S . -B ./build -G Ninja -DCMAKE_TOOLCHAIN_FILE=~/llvm/generated/llvm-toolchain-static-libcxx.cmake -DBENCHMARK_DOWNLOAD_DEPENDENCIES=ON -DBENCHMARK_ENABLE_TESTING=ON -DCMAKE_BUILD_TYPE=Release
(cmake --build ./build && cd build && ctest)one test failed, but fails on main as well |
include/benchmark/benchmark.h
Outdated
| // Macro to register benchmarks | ||
|
|
||
| #if defined(__clang__) | ||
| #define BENCHMARK_SILENCE_COUNTER_WARNING_PUSH \ |
There was a problem hiding this comment.
Let's follow the existing naming scheme for these,
BENCHMARK_DISABLE_COUNTER_WARNING an BENCHMARK_RESTORE_COUNTER_WARNING
include/benchmark/benchmark.h
Outdated
| #if defined(__clang__) | ||
| #define BENCHMARK_SILENCE_COUNTER_WARNING_PUSH \ | ||
| _Pragma("GCC diagnostic push") \ | ||
| _Pragma("GCC diagnostic ignored \"-Wc2y-extensions\"") |
There was a problem hiding this comment.
I'm guessing there is no more fine-grained flag for this specific warning?
|
And of course earlier clang's barf at that diag group, |
8a65006 to
fb33aa9
Compare
clang-23 in pedantic mode now warns that __COUNTER__ macro is c2y extension. This patch silences this warning around uses of this macro.
fb33aa9 to
12250c4
Compare
|
bazel issues are not related. i'll take a look at that. |
this is due to bazel silently bumping to 9.0.0 which changes how googletest needs to load library rules. i've pinned us to 8.2.1 until googletest upgrades. |
| /* NOLINTNEXTLINE(misc-use-anonymous-namespace) */ \ | ||
| static ::benchmark::Benchmark const* const BENCHMARK_PRIVATE_NAME(n) \ | ||
| BENCHMARK_UNUSED | ||
| BENCHMARK_RESTORE_COUNTER_WARNING BENCHMARK_UNUSED |
There was a problem hiding this comment.
There is no semantical difference, but these should have been on different lines.
There was a problem hiding this comment.
@LebedevRI, yes, sorry I was in a rush to get it done. Would you like another pr to fix that or thats fine?
This pulls in google/benchmark#2108 , which fixes a build error when using extremely new Clangs, which can occur during gfx1250 testing. Note that this does bump us past google/benchmark#1836, which gets rid of a division by number of threads on certain reported time values. I don't know if this impacts us, but I'm going to flag it anyway.
This pulls in google/benchmark#2108 , which fixes a build error when using extremely new Clangs, which can occur during gfx1250 testing. Note that this does bump us past google/benchmark#1836, which gets rid of a division by number of threads on certain reported time values. I don't know if this impacts us, but I'm going to flag it anyway.
__COUNTER__ is supported by all major compilers but newer Clangs flag it as use of upcoming C2y standard. Add diagnostic push/pop macros around call sites that expand __COUNTER__ for unique names. Follows the same pattern as google/benchmark#2108. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
__COUNTER__ is supported by all major compilers but newer Clangs flag it as use of upcoming C2y standard. Add diagnostic push/pop macros around call sites that expand __COUNTER__ for unique names. Follows the same pattern as google/benchmark#2108. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
__COUNTER__ is supported by all major compilers but newer Clangs flag it as use of upcoming C2y standard. Add diagnostic push/pop macros around call sites that expand __COUNTER__ for unique names. Follows the same pattern as google/benchmark#2108. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
__COUNTER__ is supported by all major compilers but newer Clangs flag it as use of upcoming C2y standard. Add diagnostic push/pop macros around call sites that expand __COUNTER__ for unique names. Follows the same pattern as google/benchmark#2108. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…COUNTER__` usage (#190) Fusilli builds using a very new Clang and `-Werror` (for example in [`TheRock`](https://github.com/ROCm/TheRock/tree/main/iree-libs)) will fail with `-Wc2y-extensions`. The error is warning about uses of `__COUNTER__`, which is supported by all major compilers, though technically unstandardized and part of the upcoming C2y standard. The `__COUNTER__` use isn't a practical problem, so we can add diagnostic push/pop macros around call sites that expand `__COUNTER__` to silence the error. The other options are for every consumer of fusilli to add `-Wno-c2y-extensions` to their builds, or to just use `__LINE__`. The former is pretty annoying, the latter option would probably be fine though could cause an issue if anyone used multiple `FUSILLI_ASSIGN_OR_RETURN`s on one line (unlikely). This PR follows the same pattern as google/benchmark#2108. Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
clang-23 in pedantic mode now warns that
__COUNTER__macro is c2y extension. This patch silences this warning around uses of this macro.Fixes #2057
Note: I had to fix this with ifdefs in a few places because
__COUNTER__is used for token generation. Also tried to do this with__extension__but it simply becomes a part of generated name.