Author: Timm Bäder Date: 2024-02-16T16:07:42+01:00 New Revision: d228191c8bb80ebf337d282374941c465dabc78d
URL: https://github.com/llvm/llvm-project/commit/d228191c8bb80ebf337d282374941c465dabc78d DIFF: https://github.com/llvm/llvm-project/commit/d228191c8bb80ebf337d282374941c465dabc78d.diff LOG: [clang][Interp] Create global variables for TemplateParamObjectDecls Added: Modified: clang/lib/AST/Interp/ByteCodeExprGen.cpp clang/test/AST/Interp/lambda.cpp Removed: ################################################################################ diff --git a/clang/lib/AST/Interp/ByteCodeExprGen.cpp b/clang/lib/AST/Interp/ByteCodeExprGen.cpp index 975d3b68e9b242..72789d9d348144 100644 --- a/clang/lib/AST/Interp/ByteCodeExprGen.cpp +++ b/clang/lib/AST/Interp/ByteCodeExprGen.cpp @@ -3163,6 +3163,10 @@ bool ByteCodeExprGen<Emitter>::VisitDeclRefExpr(const DeclRefExpr *E) { } else if (const auto *FuncDecl = dyn_cast<FunctionDecl>(D)) { const Function *F = getFunction(FuncDecl); return F && this->emitGetFnPtr(F, E); + } else if (isa<TemplateParamObjectDecl>(D)) { + if (std::optional<unsigned> 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 a433e5666e4f4c..75a4a628f11833 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 <auto A = [](auto x){}> + struct C { + static constexpr auto B = A; + }; + + int test() { + C<>::B(42); + return 0; + } +} _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits