Skip to content

Commit 5676478

Browse files
authored
[clang][bytecode] Avoid revisiting decomposition decl in visitDeclRef (#144226)
This simple patch removes the code to revisit `DecompositionDecl` in `visitDeclRef`. The revisit will try to emit the initializer of the `DecompositionDecl`, which could result in evaluation errors if the `DecompositionDecl` is not within a constexpr context.
1 parent b983431 commit 5676478

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

clang/lib/AST/ByteCode/Compiler.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6591,10 +6591,6 @@ bool Compiler<Emitter>::visitDeclRef(const ValueDecl *D, const Expr *E) {
65916591
return T->isReferenceType();
65926592
};
65936593

6594-
// DecompositionDecls are just proxies for us.
6595-
if (isa<DecompositionDecl>(VD))
6596-
return revisit(VD);
6597-
65986594
if ((VD->hasGlobalStorage() || VD->isStaticDataMember()) &&
65996595
typeShouldBeVisited(VD->getType())) {
66006596
if (const Expr *Init = VD->getAnyInitializer();

clang/test/AST/ByteCode/cxx17.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,3 +141,11 @@ template <int x> constexpr auto c() {
141141
}
142142

143143
auto y = c<1>(); // both-note {{in instantiation of function template specialization 'c<1>' requested here}}
144+
145+
namespace NonConstexprStructuredBinding {
146+
void f1() {
147+
int arr[2] = {};
148+
auto [a, b] = arr;
149+
static_assert(&a != &b);
150+
}
151+
}

0 commit comments

Comments
 (0)