[clang][bytecode] Diagnose failed MemberPtrPtr casts differently (#136407)
Return Invalid() here instead of just false to match the diagnostic output of the current interpreter.
This commit is contained in:
@@ -1932,7 +1932,7 @@ inline bool CastMemberPtrPtr(InterpState &S, CodePtr OpPC) {
|
||||
S.Stk.push<Pointer>(*Ptr);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return Invalid(S, OpPC);
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
@@ -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()'}}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user