[clang] [clang] propagate constexpr to binding VarDecl (PR #195860)
Matthias Wippich via cfe-commits
cfe-commits at lists.llvm.org
Thu May 21 08:38:31 PDT 2026
https://github.com/Tsche updated https://github.com/llvm/llvm-project/pull/195860
>From be798f3fa8a33149b5e9815d98717651f93d300b Mon Sep 17 00:00:00 2001
From: Matthias Wippich <mfwippich at gmail.com>
Date: Mon, 4 May 2026 05:30:53 +0200
Subject: [PATCH] [clang] propagate constexpr to binding VarDecl
---
clang/lib/Sema/SemaDeclCXX.cpp | 1 +
clang/test/SemaCXX/cxx2c-decomposition.cpp | 4 ----
2 files changed, 1 insertion(+), 4 deletions(-)
diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index de837ff0608d0..39c3aa2cdc2c0 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -1405,6 +1405,7 @@ static bool checkTupleLikeDecomposition(Sema &S,
/*TInfo=*/nullptr, Src->getStorageClass());
BindingVD->setLexicalDeclContext(Src->getLexicalDeclContext());
BindingVD->setTSCSpec(Src->getTSCSpec());
+ BindingVD->setConstexpr(Src->isConstexpr());
BindingVD->setImplicit();
if (Src->isInlineSpecified())
BindingVD->setInlineSpecified();
diff --git a/clang/test/SemaCXX/cxx2c-decomposition.cpp b/clang/test/SemaCXX/cxx2c-decomposition.cpp
index df2e3fa90263a..3e7fdfc904958 100644
--- a/clang/test/SemaCXX/cxx2c-decomposition.cpp
+++ b/clang/test/SemaCXX/cxx2c-decomposition.cpp
@@ -62,12 +62,8 @@ void test() {
test_tpl(0);
}
-// FIXME : support tuple
constexpr auto [a, b] = B{};
static_assert(a.n == 0);
-// expected-error at -1 {{static assertion expression is not an integral constant expression}} \
-// expected-note at -1 {{read of non-constexpr variable 'a' is not allowed in a constant expression}} \
-// expected-note at -2 {{declared here}}
constinit auto [init1] = Y {42};
constinit auto [init2] = X {}; // expected-error {{variable does not have a constant initializer}} \
More information about the cfe-commits
mailing list