Improve diagnostics for multiple function decls with IR type mismatch

This commit is contained in:
Martin Kinkelin 2018-08-18 20:41:41 +02:00
parent 6da0a6cd8a
commit 9fe95daeea
3 changed files with 9 additions and 1 deletions

View file

@ -551,10 +551,16 @@ void DtoDeclareFunction(FuncDeclaration *fdecl) {
func = LLFunction::Create(functype, llvm::GlobalValue::ExternalLinkage,
irMangle, &gIR->module);
} else if (func->getFunctionType() != functype) {
const auto existingTypeString = llvmTypeToString(func->getFunctionType());
const auto newTypeString = llvmTypeToString(functype);
error(fdecl->loc,
"Function type does not match previously declared "
"function with the same mangled name: `%s`",
mangleExact(fdecl));
errorSupplemental(fdecl->loc, "Previous IR type: %s",
existingTypeString.c_str());
errorSupplemental(fdecl->loc, "New IR type: %s",
newTypeString.c_str());
fatal();
}