Author: Matt Turner Date: 2026-09-03T07:56:13-04:00 New Revision: 1d3ecdca6144f75ba30ee2a07fabead1ae486772
URL: https://github.com/llvm/llvm-project/commit/1d3ecdca6144f75ba30ee2a07fabead1ae486772 DIFF: https://github.com/llvm/llvm-project/commit/1d3ecdca6144f75ba30ee2a07fabead1ae486772.diff LOG: [clang] Make the _BitInt literal suffix a pedantic-only extension (#217815) Clang diagnoses the `wb`/`uwb` `_BitInt` literal suffixes before C23 by default. Nothing else about the feature is reported that eagerly. the `_BitInt` type the suffix names, is an `Extension` and only fires under `-pedantic` or `-Wbit-int-extension`. Change the suffix diagnostic to an `Extension` which is also how GCC behaes. Assisted-by: Claude Code Added: Modified: clang/docs/ReleaseNotes.md clang/include/clang/Basic/DiagnosticCommonKinds.td clang/test/AST/ByteCode/c.c clang/test/AST/ByteCode/complex.c clang/test/Lexer/bitint-constants-compat.c Removed: ################################################################################ diff --git a/clang/docs/ReleaseNotes.md b/clang/docs/ReleaseNotes.md index bf295981710ac..9fc46aabcffeb 100644 --- a/clang/docs/ReleaseNotes.md +++ b/clang/docs/ReleaseNotes.md @@ -278,6 +278,11 @@ features cannot lower the translation-unit ABI level; initialization, while not diagnosing parameters passed to the selected allocation function or promise constructor. (#GH217501) +- The `wb` and `uwb` `_BitInt` literal suffixes are no longer diagnosed by default + before C23. They stay in `-Wc23-extensions` and are still reported under + `-pedantic` or when that group is enabled explicitly, matching how the `_BitInt` + type itself is already handled. + - Fixed bug in `-Wdocumentation` so that it correctly handles explicit function template instantiations (#64087). diff --git a/clang/include/clang/Basic/DiagnosticCommonKinds.td b/clang/include/clang/Basic/DiagnosticCommonKinds.td index 2c9ad1d324f28..d8dfb3e306ed5 100644 --- a/clang/include/clang/Basic/DiagnosticCommonKinds.td +++ b/clang/include/clang/Basic/DiagnosticCommonKinds.td @@ -231,7 +231,7 @@ def err_size_t_literal_too_large: Error< def ext_cxx_bitint_suffix : Extension< "'_BitInt' suffix for literals is a Clang extension">, InGroup<BitIntExtension>; -def ext_c23_bitint_suffix : ExtWarn< +def ext_c23_bitint_suffix : Extension< "'_BitInt' suffix for literals is a C23 extension">, InGroup<C23>; def warn_c23_compat_bitint_suffix : Warning< diff --git a/clang/test/AST/ByteCode/c.c b/clang/test/AST/ByteCode/c.c index 4c39299db5ffa..5c1cebf2af998 100644 --- a/clang/test/AST/ByteCode/c.c +++ b/clang/test/AST/ByteCode/c.c @@ -417,11 +417,11 @@ void callReturnsComplex(void) { c = returnsComplex(0.); // all-warning {{passing arguments to 'returnsComplex' without a prototype is deprecated in all versions of C and is not supported in C23}} } -int complexMul[2 * (22222222222wb + 2i) == 2]; // all-warning {{'_BitInt' suffix for literals is a C23 extension}} \ +int complexMul[2 * (22222222222wb + 2i) == 2]; // pedantic-warning {{'_BitInt' suffix for literals is a C23 extension}} \ // pedantic-warning {{imaginary constants are a C2y extension}} \ // all-warning {{variable length array folded to constant array as an extension}} -int complexDiv[2 / (22222222222wb + 2i) == 2]; // all-warning {{'_BitInt' suffix for literals is a C23 extension}} \ +int complexDiv[2 / (22222222222wb + 2i) == 2]; // pedantic-warning {{'_BitInt' suffix for literals is a C23 extension}} \ // pedantic-warning {{imaginary constants are a C2y extension}} \ // all-warning {{variable length array folded to constant array as an extension}} diff --git a/clang/test/AST/ByteCode/complex.c b/clang/test/AST/ByteCode/complex.c index 12c51f95ff7c6..4baf3478886c2 100644 --- a/clang/test/AST/ByteCode/complex.c +++ b/clang/test/AST/ByteCode/complex.c @@ -29,4 +29,6 @@ void testComplexFloat(_Atomic(_Complex float) *fp) { *fp = f; } -void ZeroNeedsAlloc() { 9999999999999999999wb / 1wbi; } // both-warning 2{{'_BitInt' suffix for literals is a C23 extension}} +// The RUN lines above pass no -pedantic, so the C23 '_BitInt' suffix extension +// is not diagnosed here. +void ZeroNeedsAlloc() { 9999999999999999999wb / 1wbi; } diff --git a/clang/test/Lexer/bitint-constants-compat.c b/clang/test/Lexer/bitint-constants-compat.c index d8bff94ef88ca..9327ea043bd1e 100644 --- a/clang/test/Lexer/bitint-constants-compat.c +++ b/clang/test/Lexer/bitint-constants-compat.c @@ -1,4 +1,11 @@ -// RUN: %clang_cc1 -std=c17 -fsyntax-only -verify=ext -Wno-unused %s +// The suffix is a C23 extension, diagnosed like the other members of +// -Wc23-extensions: silent by default, reported under -pedantic or when the +// group is enabled explicitly. GNU C modes behave the same as ISO ones. +// RUN: %clang_cc1 -std=c17 -fsyntax-only -verify=ext -Wc23-extensions -Wno-unused %s +// RUN: %clang_cc1 -std=c17 -fsyntax-only -verify=ext -pedantic -Wno-unused -Wno-comment %s +// RUN: %clang_cc1 -std=c17 -fsyntax-only -verify=quiet -Wno-unused %s +// RUN: %clang_cc1 -std=gnu17 -fsyntax-only -verify=ext -pedantic -Wno-unused -Wno-comment %s +// RUN: %clang_cc1 -std=gnu17 -fsyntax-only -verify=quiet -Wno-unused %s // RUN: %clang_cc1 -std=c2x -fsyntax-only -verify=compat -Wpre-c2x-compat -Wno-unused %s // RUN: %clang_cc1 -fsyntax-only -verify=cpp -Wbit-int-extension -Wno-unused -x c++ %s @@ -8,6 +15,7 @@ #endif #if 18446744073709551615__uwb // ext-error {{invalid suffix '__uwb' on integer constant}} \ + quiet-error {{invalid suffix '__uwb' on integer constant}} \ compat-error {{invalid suffix '__uwb' on integer constant}} \ cpp-warning {{'_BitInt' suffix for literals is a Clang extension}} #endif @@ -18,6 +26,7 @@ void func(void) { cpp-error {{invalid suffix 'wb' on integer constant}} 18446744073709551615__wb; // ext-error {{invalid suffix '__wb' on integer constant}} \ + quiet-error {{invalid suffix '__wb' on integer constant}} \ compat-error {{invalid suffix '__wb' on integer constant}} \ cpp-warning {{'_BitInt' suffix for literals is a Clang extension}} } _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
