mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-04-30 23:20:40 +03:00
Improve diagnostics for multiple function decls with IR type mismatch
This commit is contained in:
parent
6da0a6cd8a
commit
9fe95daeea
3 changed files with 9 additions and 1 deletions
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -1740,7 +1740,7 @@ llvm::Constant *buildStringLiteralConstant(StringExp *se, bool zeroTerm) {
|
|||
return LLConstantArray::get(at, vals);
|
||||
}
|
||||
|
||||
static std::string llvmTypeToString(llvm::Type *type) {
|
||||
std::string llvmTypeToString(llvm::Type *type) {
|
||||
std::string result;
|
||||
llvm::raw_string_ostream stream(result);
|
||||
stream << *type;
|
||||
|
|
|
@ -297,4 +297,6 @@ DValue *makeVarDValue(Type *type, VarDeclaration *vd,
|
|||
/// true; otherwise it just returns false.
|
||||
bool toInPlaceConstruction(DLValue *lhs, Expression *rhs);
|
||||
|
||||
std::string llvmTypeToString(LLType *type);
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue