Issue 184250
Summary Diagnostic for __COUNTER__ cannot be reduced to a warning with -Wno-error=c2y-extensions
Labels clang:diagnostics
Assignees
Reporter hvdijk
    ```c++
 int main() { return __COUNTER__; }
```

Up to Clang 21, this was accepted regardless of options. `__COUNTER__` is in the reserved namespace and no standard requires any diagnostic for the use of it, so that's fine.

As of Clang 22, this gets detected as a c2y extension and flagged by `-pedantic-errors`. This is questionable since previous standards did not mandate a diagnostic, but somewhat understandable. However, it cannot be selectively reduced to a warning: with `-pedantic-errors -Wno-error=c2y-extensions`, this remains an error, when the more specific option `-Wno-error=c2y-extensions` should override `-pedantic-errors`.

https://godbolt.org/z/ePszn7cb7

`-Wno-c2y-extensions` does work to suppress the diagnostic entirely.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to