diff --git a/module.cpp b/module.cpp index c7725b2f..58782d0f 100644 --- a/module.cpp +++ b/module.cpp @@ -506,10 +506,13 @@ Module::AddFunctionDeclaration(Symbol *funSym, bool isInline) { break; } if (i == functionType->GetNumParameters()) { + std::string thisRetType = functionType->GetReturnTypeString(); + std::string otherRetType = ofType->GetReturnTypeString(); Error(funSym->pos, "Illegal to overload function by return " - "type only (previous declaration was at line %d of " - "file %s).", overloadFunc->pos.first_line, - overloadFunc->pos.name); + "type only. This function returns \"%s\" while " + "previous declaration at %s:%d returns \"%s\".", + thisRetType.c_str(), overloadFunc->pos.name, + overloadFunc->pos.first_line, otherRetType.c_str()); return; } } diff --git a/type.cpp b/type.cpp index 3a276be4..1aaeb2a6 100644 --- a/type.cpp +++ b/type.cpp @@ -2552,6 +2552,19 @@ FunctionType::GetDIType(llvm::DIDescriptor scope) const { } +const std::string +FunctionType::GetReturnTypeString() const { + std::string ret; + if (isTask) + ret += "task "; + if (isExported) + ret += "export "; + if (isExternC) + ret += "extern \"C\" "; + return ret + returnType->GetString(); +} + + LLVM_TYPE_CONST llvm::FunctionType * FunctionType::LLVMFunctionType(llvm::LLVMContext *ctx, bool includeMask) const { if (isTask == true) diff --git a/type.h b/type.h index 54cea005..5c690e60 100644 --- a/type.h +++ b/type.h @@ -776,6 +776,8 @@ public: const Type *GetReturnType() const { return returnType; } + const std::string GetReturnTypeString() const; + /** This method returns the LLVM FunctionType that corresponds to this function type. The \c includeMask parameter indicates whether the llvm::FunctionType should have a mask as the last argument in its