diff options
-rw-r--r-- | lib/Target/JSBackend/CallHandlers.h | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/lib/Target/JSBackend/CallHandlers.h b/lib/Target/JSBackend/CallHandlers.h index cfe4e25ec2..e1e8cbb46f 100644 --- a/lib/Target/JSBackend/CallHandlers.h +++ b/lib/Target/JSBackend/CallHandlers.h @@ -45,22 +45,24 @@ DEF_CALL_HANDLER(__default__, { NeedCasts = F->isDeclaration(); // if ffi call, need casts FT = F->getFunctionType(); if (EmscriptenAssertions) { - unsigned TypeNumArgs = FT->getNumParams(); - unsigned ActualNumArgs = getNumArgOperands(CI); - if (TypeNumArgs != ActualNumArgs) { - errs().changeColor(raw_ostream::YELLOW); - errs() << "warning:"; - errs().resetColor(); - errs() << " unexpected number of arguments " << utostr(ActualNumArgs) << " in call to '" << F->getName() << "', should be " << utostr(TypeNumArgs) << "\n"; - } - for (unsigned i = 0; i < std::min(TypeNumArgs, ActualNumArgs); i++) { - Type *TypeType = FT->getParamType(i); - Type *ActualType = CI->getOperand(i)->getType(); - if (getFunctionSignatureLetter(TypeType) != getFunctionSignatureLetter(ActualType)) { + if (!FT->isVarArg()) { + unsigned TypeNumArgs = FT->getNumParams(); + unsigned ActualNumArgs = getNumArgOperands(CI); + if (TypeNumArgs != ActualNumArgs) { errs().changeColor(raw_ostream::YELLOW); errs() << "warning:"; errs().resetColor(); - errs() << " unexpected argument type " << *ActualType << " at index " << utostr(i) << " in call to '" << F->getName() << "', should be " << *TypeType << "\n"; + errs() << " unexpected number of arguments " << utostr(ActualNumArgs) << " in call to '" << F->getName() << "', should be " << utostr(TypeNumArgs) << "\n"; + } + for (unsigned i = 0; i < std::min(TypeNumArgs, ActualNumArgs); i++) { + Type *TypeType = FT->getParamType(i); + Type *ActualType = CI->getOperand(i)->getType(); + if (getFunctionSignatureLetter(TypeType) != getFunctionSignatureLetter(ActualType)) { + errs().changeColor(raw_ostream::YELLOW); + errs() << "warning:"; + errs().resetColor(); + errs() << " unexpected argument type " << *ActualType << " at index " << utostr(i) << " in call to '" << F->getName() << "', should be " << *TypeType << "\n"; + } } } Type *TypeType = FT->getReturnType(); |