llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang Author: Timm Baeder (tbaederr) <details> <summary>Changes</summary> --- Full diff: https://github.com/llvm/llvm-project/pull/106552.diff 2 Files Affected: - (modified) clang/lib/AST/ByteCode/Compiler.cpp (+1-3) - (modified) clang/test/AST/ByteCode/records.cpp (+6) ``````````diff diff --git a/clang/lib/AST/ByteCode/Compiler.cpp b/clang/lib/AST/ByteCode/Compiler.cpp index 0fc942a4f1bc4f..46545a5b3267e6 100644 --- a/clang/lib/AST/ByteCode/Compiler.cpp +++ b/clang/lib/AST/ByteCode/Compiler.cpp @@ -3287,6 +3287,7 @@ template <class Emitter> bool Compiler<Emitter>::visit(const Expr *E) { if (!this->emitGetPtrLocal(*LocalIndex, E)) return false; + InitLinkScope<Emitter> ILS(this, InitLink::Temp(*LocalIndex)); return this->visitInitializer(E); } @@ -4254,9 +4255,6 @@ bool Compiler<Emitter>::VisitCXXThisExpr(const CXXThisExpr *E) { // instance pointer of the current function frame, but e.g. to the declaration // currently being initialized. Here we emit the necessary instruction(s) for // this scenario. - if (!InitStackActive || !E->isImplicit()) - return this->emitThis(E); - if (InitStackActive && !InitStack.empty()) { unsigned StartIndex = 0; for (StartIndex = InitStack.size() - 1; StartIndex > 0; --StartIndex) { diff --git a/clang/test/AST/ByteCode/records.cpp b/clang/test/AST/ByteCode/records.cpp index 7e3cf5b94518f7..2799afa9577b78 100644 --- a/clang/test/AST/ByteCode/records.cpp +++ b/clang/test/AST/ByteCode/records.cpp @@ -1653,3 +1653,9 @@ namespace ExprWithCleanups { constexpr auto F = true ? 1i : 2i; static_assert(F == 1i, ""); } + +namespace ExplicitThisInTemporary { + struct B { B *p = this; }; + constexpr bool g(B b) { return &b == b.p; } + static_assert(g({}), ""); +} `````````` </details> https://github.com/llvm/llvm-project/pull/106552 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits