diff --git a/clang/lib/AST/Interp/ByteCodeExprGen.cpp b/clang/lib/AST/Interp/ByteCodeExprGen.cpp index 975d3b68e9b24..72789d9d34814 100644 --- a/clang/lib/AST/Interp/ByteCodeExprGen.cpp +++ b/clang/lib/AST/Interp/ByteCodeExprGen.cpp @@ -3163,6 +3163,10 @@ bool ByteCodeExprGen::VisitDeclRefExpr(const DeclRefExpr *E) { } else if (const auto *FuncDecl = dyn_cast(D)) { const Function *F = getFunction(FuncDecl); return F && this->emitGetFnPtr(F, E); + } else if (isa(D)) { + if (std::optional Index = P.getOrCreateGlobal(D)) + return this->emitGetPtrGlobal(*Index, E); + return false; } // References are implemented via pointers, so when we see a DeclRefExpr diff --git a/clang/test/AST/Interp/lambda.cpp b/clang/test/AST/Interp/lambda.cpp index a433e5666e4f4..75a4a628f1183 100644 --- a/clang/test/AST/Interp/lambda.cpp +++ b/clang/test/AST/Interp/lambda.cpp @@ -213,3 +213,15 @@ namespace ThisCapture { static_assert(F.a == 33, ""); static_assert(F.Aplus2() == (33 + 2), ""); } + +namespace GH62611 { + template + struct C { + static constexpr auto B = A; + }; + + int test() { + C<>::B(42); + return 0; + } +}