llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang Author: Timm Baeder (tbaederr) <details> <summary>Changes</summary> Return Invalid() here instead of just false to match the diagnostic output of the current interpreter. --- Full diff: https://github.com/llvm/llvm-project/pull/136407.diff 2 Files Affected: - (modified) clang/lib/AST/ByteCode/Interp.h (+1-1) - (modified) clang/test/AST/ByteCode/memberpointers.cpp (+18) ``````````diff diff --git a/clang/lib/AST/ByteCode/Interp.h b/clang/lib/AST/ByteCode/Interp.h index 49e2326186bf8..866d8e4bf2251 100644 --- a/clang/lib/AST/ByteCode/Interp.h +++ b/clang/lib/AST/ByteCode/Interp.h @@ -1932,7 +1932,7 @@ inline bool CastMemberPtrPtr(InterpState &S, CodePtr OpPC) { S.Stk.push<Pointer>(*Ptr); return true; } - return false; + return Invalid(S, OpPC); } //===----------------------------------------------------------------------===// diff --git a/clang/test/AST/ByteCode/memberpointers.cpp b/clang/test/AST/ByteCode/memberpointers.cpp index db4a86ae03aff..5d622187e97f2 100644 --- a/clang/test/AST/ByteCode/memberpointers.cpp +++ b/clang/test/AST/ByteCode/memberpointers.cpp @@ -249,3 +249,21 @@ namespace CallExprTypeMismatch { } static_assert(test(), ""); } + +namespace CastMemberPtrPtrFailed{ + struct S { + constexpr S() {} + constexpr int f() const; + constexpr int g() const; + }; + struct T : S { + constexpr T(int n) : S(), n(n) {} + int n; + }; + + constexpr int S::g() const { + return this->*(int(S::*))&T::n; // both-note {{subexpression}} + } + static_assert(S().g(), ""); // both-error {{constant expression}} \ + // both-note {{in call to 'S().g()'}} +} `````````` </details> https://github.com/llvm/llvm-project/pull/136407 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits