[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:21:17 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:
Nit: Our code style is against inconsistent bracing
```suggestion
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;
}
```
https://github.com/llvm/llvm-project/pull/130228
More information about the cfe-commits
mailing list