Skip to content

Commit d228191

Browse files
committed
[clang][Interp] Create global variables for TemplateParamObjectDecls
1 parent 35f3298 commit d228191

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

clang/lib/AST/Interp/ByteCodeExprGen.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3163,6 +3163,10 @@ bool ByteCodeExprGen<Emitter>::VisitDeclRefExpr(const DeclRefExpr *E) {
31633163
} else if (const auto *FuncDecl = dyn_cast<FunctionDecl>(D)) {
31643164
const Function *F = getFunction(FuncDecl);
31653165
return F && this->emitGetFnPtr(F, E);
3166+
} else if (isa<TemplateParamObjectDecl>(D)) {
3167+
if (std::optional<unsigned> Index = P.getOrCreateGlobal(D))
3168+
return this->emitGetPtrGlobal(*Index, E);
3169+
return false;
31663170
}
31673171

31683172
// References are implemented via pointers, so when we see a DeclRefExpr

clang/test/AST/Interp/lambda.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,3 +213,15 @@ namespace ThisCapture {
213213
static_assert(F.a == 33, "");
214214
static_assert(F.Aplus2() == (33 + 2), "");
215215
}
216+
217+
namespace GH62611 {
218+
template <auto A = [](auto x){}>
219+
struct C {
220+
static constexpr auto B = A;
221+
};
222+
223+
int test() {
224+
C<>::B(42);
225+
return 0;
226+
}
227+
}

0 commit comments

Comments
 (0)