[clang] [Clang] Implement P0963R3 "Structured binding declaration as a condition" (PR #130228)

Matheus Izvekov via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 10 06:23:03 PDT 2025


================
@@ -740,13 +740,16 @@ Sema::ActOnDecompositionDeclarator(Scope *S, Declarator &D,
     return nullptr;
   }
 
-  Diag(Decomp.getLSquareLoc(),
-       !getLangOpts().CPlusPlus17
-           ? diag::ext_decomp_decl
-           : D.getContext() == DeclaratorContext::Condition
-                 ? diag::ext_decomp_decl_cond
-                 : diag::warn_cxx14_compat_decomp_decl)
-      << Decomp.getSourceRange();
+  unsigned DiagID;
+  if (!getLangOpts().CPlusPlus17)
+    DiagID = diag::ext_decomp_decl;
+  else if (D.getContext() == DeclaratorContext::Condition) {
+    DiagID = getLangOpts().CPlusPlus26 ? diag::warn_cxx26_decomp_decl_cond
+                                       : diag::ext_decomp_decl_cond;
+  } else
+    DiagID = diag::warn_cxx14_compat_decomp_decl;
----------------
mizvekov wrote:

Or maybe don't brace any branch at all instead.

https://github.com/llvm/llvm-project/pull/130228


More information about the cfe-commits mailing list