Skip to content

Commit 49b760f

Browse files
committed
[clang][Interp] Fix calling virtual CXXOperatorCallExprs
1 parent 5e140c8 commit 49b760f

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

clang/lib/AST/Interp/ByteCodeExprGen.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3341,7 +3341,8 @@ bool ByteCodeExprGen<Emitter>::VisitCallExpr(const CallExpr *E) {
33413341
// write the result into.
33423342
if (IsVirtual && !HasQualifier) {
33433343
uint32_t VarArgSize = 0;
3344-
unsigned NumParams = Func->getNumWrittenParams();
3344+
unsigned NumParams =
3345+
Func->getNumWrittenParams() + isa<CXXOperatorCallExpr>(E);
33453346
for (unsigned I = NumParams, N = E->getNumArgs(); I != N; ++I)
33463347
VarArgSize += align(primSize(classify(E->getArg(I)).value_or(PT_Ptr)));
33473348

clang/test/AST/Interp/records.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1467,3 +1467,16 @@ namespace IgnoredCtorWithZeroInit {
14671467
return (S(), true);
14681468
}
14691469
}
1470+
1471+
#if __cplusplus >= 202002L
1472+
namespace VirtOperator {
1473+
/// This used to crash because it's a virtual CXXOperatorCallExpr.
1474+
struct B {
1475+
virtual constexpr bool operator==(const B&) const { return true; }
1476+
};
1477+
struct D : B {
1478+
constexpr bool operator==(const B&) const override{ return false; } // both-note {{operator}}
1479+
};
1480+
constexpr bool cmp_base_derived = D() == D(); // both-warning {{ambiguous}}
1481+
}
1482+
#endif

0 commit comments

Comments
 (0)