Improve error message about incompatible function types.

When reporting that a function has illegally been overloaded only
by return type, include "task", "export", and "extern "C"", as appropriate
in the error message to make clear what the issue is.

Finishes issue #216.
This commit is contained in:
Matt Pharr
2012-04-03 05:43:23 -07:00
parent dc09d46bf4
commit 920cf63201
3 changed files with 21 additions and 3 deletions

View File

@@ -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;
}
}