Skip to content

Suppress __COUNTER__ pedantic warning on Clang#3079

Open
iamtgiri wants to merge 2 commits intocatchorg:develfrom
iamtgiri:fix/clang-counter-pedantic-warning
Open

Suppress __COUNTER__ pedantic warning on Clang#3079
iamtgiri wants to merge 2 commits intocatchorg:develfrom
iamtgiri:fix/clang-counter-pedantic-warning

Conversation

@iamtgiri
Copy link

Description

Clang 22 with -pedantic-errors treats __COUNTER__ as a C2y
extension and emits a hard error on every TEST_CASE() usage.

This fix wraps the __COUNTER__ usage in catch_unique_name.hpp
with Clang-specific diagnostic pragmas to suppress -Wc2y-extensions
locally, without affecting any other compiler or warning.

GitHub Issues

Closes #3076

Clang 22 with -pedantic-errors treats __COUNTER__ as a C2y
extension and emits an error. Wrap the __COUNTER__ usage with
diagnostic pragmas to suppress the warning on Clang.

Fixes catchorg#3076
@codecov
Copy link

codecov bot commented Mar 11, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.37%. Comparing base (50e9dbf) to head (6e073fd).
⚠️ Report is 2 commits behind head on devel.

Additional details and impacted files
@@            Coverage Diff             @@
##            devel    #3079      +/-   ##
==========================================
- Coverage   91.38%   91.37%   -0.01%     
==========================================
  Files         204      204              
  Lines        8899     8899              
==========================================
- Hits         8132     8131       -1     
- Misses        767      768       +1     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Older Clang versions (< 22) do not recognize -Wc2y-extensions
and emit an error for the unknown warning group. Suppress
-Wunknown-warning-option first so older Clang versions silently
ignore the unrecognized warning name.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Clang 22 error: '__COUNTER__' is a C2y extension [-Werror,-Wc2y-extensions]

1 participant