Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[clang] Binary literals are flagged as a GNU extension even when compiling in C23 mode #72017

Closed
LocalSpook opened this issue Nov 11, 2023 · 1 comment · Fixed by #81658
Closed
Labels
c23 clang:diagnostics New/improved warning or error message in Clang, but not in clang-tidy or static analyzer confirmed Verified by a second party

Comments

@LocalSpook
Copy link

C23 added binary literals into the standard, but currently, when compiling with -std=c23 -Wpedantic, the compiler emits a warning (-Wgnu-binary-literal) that they're a GNU extension.

Reproducing the error

Compile the following program with clang -std=c23 -Wpedantic:

int main() {
    return 0b0;
}

Here's that program in Compiler Explorer, compiled with Clang trunk: https://godbolt.org/z/Ezz6ox37x.

Expected behaviour

The program should compile with no warnings.

Possible solution

Don't enable -Wgnu-binary-literal as part of -Wpedantic when compiling as C23.

@github-actions github-actions bot added the clang Clang issues not falling into any other category label Nov 11, 2023
@EugeneZelenko EugeneZelenko added c23 clang:diagnostics New/improved warning or error message in Clang, but not in clang-tidy or static analyzer and removed clang Clang issues not falling into any other category labels Nov 11, 2023
@AaronBallman AaronBallman added the confirmed Verified by a second party label Feb 13, 2024
AaronBallman added a commit to AaronBallman/llvm-project that referenced this issue Feb 13, 2024
We previously would diagnose them as a GNU extension in C mode, but
they are now a feature of C23. This removes the old warning group,
-Wgnu-binary-literal, as it no longer makes sense and searching through
public repositories shows it is a rarely used option (same for the -Wno
form). It also adds the companion compatibility warning which existed
for C++ but not for C.

Fixes llvm#72017
AaronBallman added a commit that referenced this issue Feb 14, 2024
We previously would diagnose them as a GNU extension in C mode, but they
are now a feature of C23. The -Wgnu-binary-literal warning group no
longer controls any diagnostics as this is no longer a GNU extension.
The warning group is retained as a noop to help avoid "unknown warning"
diagnostics.

This also adds the companion compatibility warning which existed for C++
but not for C.

Fixes #72017
@LocalSpook
Copy link
Author

@AaronBallman Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c23 clang:diagnostics New/improved warning or error message in Clang, but not in clang-tidy or static analyzer confirmed Verified by a second party
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants