https://github.com/bassiounix updated 
https://github.com/llvm/llvm-project/pull/209920

>From 5bf860d05bac35506a129dea2f2a0c141ca5fcc8 Mon Sep 17 00:00:00 2001
From: bassiounix <[email protected]>
Date: Thu, 16 Jul 2026 02:37:23 +0300
Subject: [PATCH 1/2] [clang][NFC] Update diagnostic handling for C2y
 compatibility in parser

---
 clang/include/clang/Basic/DiagnosticParseKinds.td | 7 +------
 clang/lib/Parse/ParseExprCXX.cpp                  | 4 +---
 clang/lib/Parse/ParseStmt.cpp                     | 4 +---
 3 files changed, 3 insertions(+), 12 deletions(-)

diff --git a/clang/include/clang/Basic/DiagnosticParseKinds.td 
b/clang/include/clang/Basic/DiagnosticParseKinds.td
index cfd35fba7ea07..e083a87cc62fb 100644
--- a/clang/include/clang/Basic/DiagnosticParseKinds.td
+++ b/clang/include/clang/Basic/DiagnosticParseKinds.td
@@ -169,12 +169,7 @@ def ext_c2y_generic_with_type_arg : Extension<
 def warn_c2y_compat_generic_with_type_arg : Warning<
   "passing a type argument as the first operand to '_Generic' is incompatible "
   "with C standards before C2y">, InGroup<CPre2yCompat>, DefaultIgnore;
-def warn_c2y_compat_decl_statement : Warning<
-  "'%select{if|switch}0' declaration statements are incompatible with "
-  "C standards before C2y">, DefaultIgnore, InGroup<CPre2yCompat>;
-def ext_c2y_decl_statement : Extension<
-  "'%select{if|switch}0' declaration statements are a C2y extension">,
-  InGroup<C2y>;
+defm decl_statement : C2yCompat<"'%select{if|switch}0' declaration statements 
are">;
 
 def ext_c99_feature : Extension<
   "'%0' is a C99 extension">, InGroup<C99>;
diff --git a/clang/lib/Parse/ParseExprCXX.cpp b/clang/lib/Parse/ParseExprCXX.cpp
index bb0cfaad4bc36..b2b1e74b07133 100644
--- a/clang/lib/Parse/ParseExprCXX.cpp
+++ b/clang/lib/Parse/ParseExprCXX.cpp
@@ -1908,9 +1908,7 @@ Sema::ConditionResult Parser::ParseCondition(StmtResult 
*InitStmt,
                                   : diag::ext_init_statement)
           << (CK == Sema::ConditionKind::Switch);
     else
-      Diag(Tok.getLocation(), getLangOpts().C2y
-                                  ? diag::warn_c2y_compat_decl_statement
-                                  : diag::ext_c2y_decl_statement)
+      DiagCompat(Tok.getLocation(), diag_compat::decl_statement)
           << (CK == Sema::ConditionKind::Switch);
   };
 
diff --git a/clang/lib/Parse/ParseStmt.cpp b/clang/lib/Parse/ParseStmt.cpp
index 75374f608c5ea..65f63bb5756e1 100644
--- a/clang/lib/Parse/ParseStmt.cpp
+++ b/clang/lib/Parse/ParseStmt.cpp
@@ -1340,9 +1340,7 @@ bool Parser::ParseParenExprOrCondition(StmtResult 
*InitStmt,
             << Cond.get().first->getSourceRange();
     } else if (Cond.get().first != nullptr)
       // Handle: if (int decl = 0) {}.
-      Diag(Cond.get().first->getBeginLoc(),
-           getLangOpts().C2y ? diag::warn_c2y_compat_decl_statement
-                             : diag::ext_c2y_decl_statement)
+      DiagCompat(Cond.get().first->getBeginLoc(), diag_compat::decl_statement)
           << (CK == Sema::ConditionKind::Switch);
   }
 

>From 5c6cc0f56b061ba885017db55545cf1de5f3ae35 Mon Sep 17 00:00:00 2001
From: bassiounix <[email protected]>
Date: Thu, 16 Jul 2026 19:38:53 +0300
Subject: [PATCH 2/2] move diagnostic to the top

---
 clang/include/clang/Basic/DiagnosticParseKinds.td | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/clang/include/clang/Basic/DiagnosticParseKinds.td 
b/clang/include/clang/Basic/DiagnosticParseKinds.td
index e083a87cc62fb..c411d89ef2fea 100644
--- a/clang/include/clang/Basic/DiagnosticParseKinds.td
+++ b/clang/include/clang/Basic/DiagnosticParseKinds.td
@@ -12,6 +12,9 @@
 
 let Component = "Parse" in {
 let CategoryName = "Parse Issue" in {
+// C2y compatibility with C89.
+defm decl_statement : C2yCompat<"'%select{if|switch}0' declaration statements 
are">;
+
 // C++11 compatibility with C++98.
 defm enum_fixed_underlying_type : CXX11Compat<
   "enumeration types with a fixed underlying type are",
@@ -169,7 +172,6 @@ def ext_c2y_generic_with_type_arg : Extension<
 def warn_c2y_compat_generic_with_type_arg : Warning<
   "passing a type argument as the first operand to '_Generic' is incompatible "
   "with C standards before C2y">, InGroup<CPre2yCompat>, DefaultIgnore;
-defm decl_statement : C2yCompat<"'%select{if|switch}0' declaration statements 
are">;
 
 def ext_c99_feature : Extension<
   "'%0' is a C99 extension">, InGroup<C99>;

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to