[clang] [Clang] Use Compat diagnostics for most extension/compatibility warnings (PR #216693)

2026-09-02 Thread Aaron Ballman via cfe-commits


@@ -11,6 +11,17 @@
 
//===--===//
 
 let Component = "Lex", CategoryName = "Lexical or Preprocessor Issue" in {
+// C23 compatibility with C17 and earlier.
+defm c23_pp_directive : C23Compat<
+  "use of a '#%select{|elifdef|elifndef}0' directive is", 
/*ext_warn*/true>;
+
+// C++23 compatibility with C++20 and earlier.
+defm cxx23_pp_directive : CXX23Compat<
+  "use of a '#%select{|elifdef|elifndef}0' directive is">;
+
+// C++26 compatibility with C++23 and earlier.
+defm raw_string_literal_character_set : CXX26Compat<
+  " '%0' in a raw string literal delimiter is", /*ext_warn*/false>;

AaronBallman wrote:

```suggestion
  "'%0' in a raw string literal delimiter is", /*ext_warn*/false>;
```
I think that was a typo with the original?

https://github.com/llvm/llvm-project/pull/216693
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Use Compat diagnostics for most extension/compatibility warnings (PR #216693)

2026-09-02 Thread Nikolas Klauser via cfe-commits


@@ -11,6 +11,17 @@
 
//===--===//
 
 let Component = "Lex", CategoryName = "Lexical or Preprocessor Issue" in {
+// C23 compatibility with C17 and earlier.
+defm c23_pp_directive : C23Compat<
+  "use of a '#%select{|elifdef|elifndef}0' directive is", 
/*ext_warn*/true>;
+
+// C++23 compatibility with C++20 and earlier.
+defm cxx23_pp_directive : CXX23Compat<
+  "use of a '#%select{|elifdef|elifndef}0' directive is">;
+
+// C++26 compatibility with C++23 and earlier.
+defm raw_string_literal_character_set : CXX26Compat<
+  " '%0' in a raw string literal delimiter is", /*ext_warn*/false>;

philnik777 wrote:

Yeah, I wasn't sure whether this should be changed, so I just left it as-is. 
Happy to remove the leading space though.

https://github.com/llvm/llvm-project/pull/216693
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Use Compat diagnostics for most extension/compatibility warnings (PR #216693)

2026-09-02 Thread Nikolas Klauser via cfe-commits

https://github.com/philnik777 closed 
https://github.com/llvm/llvm-project/pull/216693
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Use Compat diagnostics for most extension/compatibility warnings (PR #216693)

2026-09-02 Thread Nikolas Klauser via cfe-commits

https://github.com/philnik777 auto_merge_enabled 
https://github.com/llvm/llvm-project/pull/216693
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Use Compat diagnostics for most extension/compatibility warnings (PR #216693)

2026-09-02 Thread Aaron Ballman via cfe-commits

https://github.com/AaronBallman approved this pull request.

Thank you for this! LGTM but there may be one nit to clean up (feel free to 
ignore if I'm wrong about it being an existing typo though).

https://github.com/llvm/llvm-project/pull/216693
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Use Compat diagnostics for most extension/compatibility warnings (PR #216693)

2026-09-02 Thread Aaron Ballman via cfe-commits

https://github.com/AaronBallman edited 
https://github.com/llvm/llvm-project/pull/216693
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Use Compat diagnostics for most extension/compatibility warnings (PR #216693)

2026-08-17 Thread Vlad Serebrennikov via cfe-commits

https://github.com/Endilll commented:

Changes to C++ DR tests LGTM
Thank you for uncovering more conformance tests that expect extension warnings 
(they are never welcome there).

https://github.com/llvm/llvm-project/pull/216693
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Use Compat diagnostics for most extension/compatibility warnings (PR #216693)

2026-08-17 Thread Erich Keane via cfe-commits

https://github.com/erichkeane approved this pull request.

I really like this, this is a cool cleanup!  I think @Endilll and @AaronBallman 
(Away at WG14 this week!) should both at least be aware before merging though.

That said, we DO now have a pretty obvious pattern of differentiating which 
compat-warning based on C++ standar version TOO!  Can't help but wonder if 
THOSE need some sort of merging :) 

https://github.com/llvm/llvm-project/pull/216693
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Use Compat diagnostics for most extension/compatibility warnings (PR #216693)

2026-08-17 Thread via cfe-commits

llvmorg-github-actions[bot] wrote:




@llvm/pr-subscribers-clang

Author: Nikolas Klauser (philnik777)


Changes

This changes the wording of a few diagnostic messages to be more canonical. 
Otherwise this should be NFC.

---

Patch is 105.64 KiB, truncated to 20.00 KiB below, full version: 
https://github.com/llvm/llvm-project/pull/216693.diff


38 Files Affected:

- (modified) clang/include/clang/Basic/DiagnosticCommonKinds.td (+5-11) 
- (modified) clang/include/clang/Basic/DiagnosticLexKinds.td (+11-25) 
- (modified) clang/include/clang/Basic/DiagnosticParseKinds.td (+80-252) 
- (modified) clang/include/clang/Basic/DiagnosticSemaKinds.td (+22-82) 
- (modified) clang/include/clang/Lex/Lexer.h (+2) 
- (modified) clang/include/clang/Lex/Preprocessor.h (+9) 
- (modified) clang/lib/Lex/Lexer.cpp (+6-3) 
- (modified) clang/lib/Lex/PPDirectives.cpp (+6-16) 
- (modified) clang/lib/Lex/PPExpressions.cpp (+7-6) 
- (modified) clang/lib/Parse/ParseCXXInlineMethods.cpp (+6-12) 
- (modified) clang/lib/Parse/ParseDecl.cpp (+12-27) 
- (modified) clang/lib/Parse/ParseDeclCXX.cpp (+22-66) 
- (modified) clang/lib/Parse/ParseExpr.cpp (+7-10) 
- (modified) clang/lib/Parse/ParseExprCXX.cpp (+7-20) 
- (modified) clang/lib/Parse/ParseObjc.cpp (+1-1) 
- (modified) clang/lib/Parse/ParseOpenMP.cpp (+1-1) 
- (modified) clang/lib/Parse/ParseStmt.cpp (+12-30) 
- (modified) clang/lib/Parse/ParseTemplate.cpp (+4-12) 
- (modified) clang/lib/Parse/Parser.cpp (+2-6) 
- (modified) clang/lib/Sema/SemaDeclCXX.cpp (+6-18) 
- (modified) clang/lib/Sema/SemaExpr.cpp (+7-10) 
- (modified) clang/lib/Sema/SemaLambda.cpp (+4-12) 
- (modified) clang/lib/Sema/SemaStmt.cpp (+1-3) 
- (modified) clang/lib/Sema/SemaTemplate.cpp (+4-10) 
- (modified) clang/lib/Sema/SemaTemplateVariadic.cpp (+1-3) 
- (modified) clang/lib/Sema/SemaType.cpp (+2-6) 
- (modified) 
clang/test/CXX/basic/basic.lookup/basic.lookup.qual/namespace.qual/p2.cpp 
(+3-3) 
- (modified) clang/test/CXX/drs/cwg0xx.cpp (+5-5) 
- (modified) clang/test/CXX/drs/cwg4xx.cpp (+3-3) 
- (modified) clang/test/CXX/stmt.stmt/stmt.select/p3.cpp (+6-6) 
- (modified) clang/test/Lexer/cxx2c-raw-strings.cpp (+4-4) 
- (modified) clang/test/Parser/cxx0x-in-cxx98.cpp (+1-1) 
- (modified) clang/test/Parser/cxx0x-lambda-expressions.cpp (+1-1) 
- (modified) clang/test/Parser/cxx11-user-defined-literals.cpp (+1-1) 
- (modified) clang/test/Parser/cxx1z-nested-namespace-definition.cpp (+1-1) 
- (modified) clang/test/Sema/static-assert.c (+1-1) 
- (modified) clang/test/SemaCXX/cxx98-compat.cpp (+2-2) 
- (modified) clang/test/SemaCXX/static-assert-ext.cpp (+2-2) 


``diff
diff --git a/clang/include/clang/Basic/DiagnosticCommonKinds.td 
b/clang/include/clang/Basic/DiagnosticCommonKinds.td
index 192fdf9299eb4..2c9ad1d324f28 100644
--- a/clang/include/clang/Basic/DiagnosticCommonKinds.td
+++ b/clang/include/clang/Basic/DiagnosticCommonKinds.td
@@ -11,6 +11,11 @@
 
//===--===//
 
 let Component = "Common" in {
+// C++11 compatibility with C++98.
+defm variadic_templates : CXX11Compat<"variadic templates are">;
+
+// C++23 compatibility with C++20 and earlier.
+defm size_t_suffix : CXX23Compat<"'size_t' suffix for literals is">;
 
 // Substitutions.
 
@@ -91,11 +96,6 @@ def warn_method_param_declaration : Warning<"redeclaration 
of method parameter %
 def err_invalid_storage_class_in_func_decl : Error<
   "invalid storage class specifier in function declarator">;
 def err_expected_namespace_name : Error<"expected namespace name">;
-def ext_variadic_templates : ExtWarn<
-  "variadic templates are a C++11 extension">, InGroup;
-def warn_cxx98_compat_variadic_templates :
-  Warning<"variadic templates are incompatible with C++98">,
-  InGroup, DefaultIgnore;
 def err_default_special_members : Error<
   "only special member functions %select{|and comparison operators }0"
   "may be defaulted">;
@@ -223,12 +223,6 @@ def ext_cxx11_longlong : Extension<
 def warn_cxx98_compat_longlong : Warning<
   "'long long' is incompatible with C++98">,
   InGroup, DefaultIgnore;
-def ext_cxx23_size_t_suffix : ExtWarn<
-  "'size_t' suffix for literals is a C++23 extension">,
-  InGroup;
-def warn_cxx20_compat_size_t_suffix : Warning<
-  "'size_t' suffix for literals is incompatible with C++ standards before "
-  "C++23">, InGroup, DefaultIgnore;
 def err_cxx23_size_t_suffix: Error<
   "'size_t' suffix for literals is a C++23 feature">;
 def err_size_t_literal_too_large: Error<
diff --git a/clang/include/clang/Basic/DiagnosticLexKinds.td 
b/clang/include/clang/Basic/DiagnosticLexKinds.td
index f0791ed486a74..bb2800e0cdbc1 100644
--- a/clang/include/clang/Basic/DiagnosticLexKinds.td
+++ b/clang/include/clang/Basic/DiagnosticLexKinds.td
@@ -11,6 +11,17 @@
 
//===--===//
 
 let Component = "Lex", CategoryName = "Lexical or Preprocessor Issue" in {
+// C23 compatibility with C17 and earlier.
+defm 

[clang] [Clang] Use Compat diagnostics for most extension/compatibility warnings (PR #216693)

2026-08-17 Thread Nikolas Klauser via cfe-commits

https://github.com/philnik777 ready_for_review 
https://github.com/llvm/llvm-project/pull/216693
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Use Compat diagnostics for most extension/compatibility warnings (PR #216693)

2026-08-17 Thread Nikolas Klauser via cfe-commits

https://github.com/philnik777 edited 
https://github.com/llvm/llvm-project/pull/216693
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Use Compat diagnostics for most extension/compatibility warnings (PR #216693)

2026-08-17 Thread via cfe-commits

github-actions[bot] wrote:




:warning: C/C++ code formatter, clang-format found issues in your code. 
:warning:



You can test this locally with the following command:


``bash
git-clang-format --diff origin/main HEAD --extensions h,c,cpp -- 
clang/include/clang/Lex/Lexer.h clang/include/clang/Lex/Preprocessor.h 
clang/lib/Lex/Lexer.cpp clang/lib/Lex/PPDirectives.cpp 
clang/lib/Lex/PPExpressions.cpp clang/lib/Parse/ParseCXXInlineMethods.cpp 
clang/lib/Parse/ParseDecl.cpp clang/lib/Parse/ParseDeclCXX.cpp 
clang/lib/Parse/ParseExpr.cpp clang/lib/Parse/ParseExprCXX.cpp 
clang/lib/Parse/ParseObjc.cpp clang/lib/Parse/ParseOpenMP.cpp 
clang/lib/Parse/ParseStmt.cpp clang/lib/Parse/ParseTemplate.cpp 
clang/lib/Parse/Parser.cpp clang/lib/Sema/SemaDeclCXX.cpp 
clang/lib/Sema/SemaExpr.cpp clang/lib/Sema/SemaLambda.cpp 
clang/lib/Sema/SemaStmt.cpp clang/lib/Sema/SemaTemplate.cpp 
clang/lib/Sema/SemaTemplateVariadic.cpp clang/lib/Sema/SemaType.cpp 
clang/test/CXX/basic/basic.lookup/basic.lookup.qual/namespace.qual/p2.cpp 
clang/test/CXX/drs/cwg0xx.cpp clang/test/CXX/drs/cwg4xx.cpp 
clang/test/CXX/stmt.stmt/stmt.select/p3.cpp 
clang/test/Lexer/cxx2c-raw-strings.cpp clang/test/Parser/cxx0x-in-cxx98.cpp 
clang/test/Parser/cxx0x-lambda-expressions.cpp 
clang/test/Parser/cxx11-user-defined-literals.cpp 
clang/test/Parser/cxx1z-nested-namespace-definition.cpp 
clang/test/Sema/static-assert.c clang/test/SemaCXX/cxx98-compat.cpp 
clang/test/SemaCXX/static-assert-ext.cpp --diff_from_common_commit
``

:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:





View the diff from clang-format here.


``diff
diff --git a/clang/lib/Parse/ParseStmt.cpp b/clang/lib/Parse/ParseStmt.cpp
index 78d0648c7..5e67cd551 100644
--- a/clang/lib/Parse/ParseStmt.cpp
+++ b/clang/lib/Parse/ParseStmt.cpp
@@ -2483,7 +2483,8 @@ StmtResult Parser::ParseReturnStatement() {
 if (Tok.is(tok::l_brace) && getLangOpts().CPlusPlus) {
   R = ParseInitializer();
   if (R.isUsable())
-DiagCompat(R.get()->getBeginLoc(), 
diag_compat::generalized_initializer_lists);
+DiagCompat(R.get()->getBeginLoc(),
+   diag_compat::generalized_initializer_lists);
 } else
   R = ParseExpression();
 if (R.isInvalid()) {

``




https://github.com/llvm/llvm-project/pull/216693
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits