Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions core/metacling/src/TClingCallFunc.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,8 @@ void TClingCallFunc::make_narg_call(const std::string &return_type, const unsign
ROOT::TMetaUtils::GetNormalizedName(arg_type, QT, *fInterp, fNormCtxt);
callbuf << arg_type;
}
if (FD->isVariadic())
callbuf << ", ...";
callbuf << ")";
}

Expand Down
22 changes: 22 additions & 0 deletions core/metacling/test/TClingCallFuncTests.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,28 @@ TEST(TClingCallFunc, FunctionWrapperVoid)
gInterpreter->ClassInfo_Delete(GlobalNamespace);
}

TEST(TClingCallFunc, FunctionWrapperVariadic)
{
gInterpreter->Declare(R"cpp(
void FunctionWrapperFuncVariadic(int j, ...) {}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we actually add some work to the function body, run it and check the result? This would give us one extra degree of certainty.

)cpp");

ClassInfo_t *GlobalNamespace = gInterpreter->ClassInfo_Factory("");
CallFunc_t *mc = gInterpreter->CallFunc_Factory();
long offset = 0;

gInterpreter->CallFunc_SetFuncProto(mc, GlobalNamespace, "FunctionWrapperFuncVariadic", "int", &offset);
std::string wrapper = gInterpreter->CallFunc_GetWrapperCode(mc);

ASSERT_TRUE(gInterpreter->Declare(wrapper.c_str()));
// Make sure we didn't forget the ... in the variadic function signature.
ASSERT_TRUE(wrapper.find("((void (&)(int, ...))FunctionWrapperFuncVariadic)") != wrapper.npos);

// Cleanup
gInterpreter->CallFunc_Delete(mc);
gInterpreter->ClassInfo_Delete(GlobalNamespace);
}

TEST(TClingCallFunc, FunctionWrapperDefaultArg)
{
gInterpreter->Declare(R"cpp(
Expand Down