Skip to content

Commit 38ea68b

Browse files
tbaederryuxuanchen1997
authored andcommitted
[clang][Interp] Fix calling variadic call operators
Summary: Test Plan: Reviewers: Subscribers: Tasks: Tags: Differential Revision: https://phabricator.intern.facebook.com/D60250544
1 parent c417008 commit 38ea68b

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

clang/lib/AST/Interp/Interp.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,8 @@ void cleanupAfterFunctionCall(InterpState &S, CodePtr OpPC) {
233233
assert(false && "Can't get arguments from that expression type");
234234

235235
assert(NumArgs >= CurFunc->getNumWrittenParams());
236-
NumVarArgs = NumArgs - CurFunc->getNumWrittenParams();
236+
NumVarArgs = NumArgs - (CurFunc->getNumWrittenParams() +
237+
isa<CXXOperatorCallExpr>(CallSite));
237238
for (unsigned I = 0; I != NumVarArgs; ++I) {
238239
const Expr *A = Args[NumArgs - 1 - I];
239240
popArg(S, A);

clang/test/AST/Interp/cxx20.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -827,3 +827,17 @@ namespace CheckingNullPtrForInitialization {
827827
return x;
828828
}
829829
}
830+
831+
namespace VariadicCallOperator {
832+
class F {
833+
public:
834+
constexpr void operator()(int a, int b, ...) {}
835+
};
836+
constexpr int foo() {
837+
F f;
838+
839+
f(1,2, 3);
840+
return 1;
841+
}
842+
constexpr int A = foo();
843+
}

0 commit comments

Comments
 (0)