#include <cstring>
#include <msp/core/raii.h>
#include <msp/strings/format.h>
+#include <msp/strings/utils.h>
#include "validate.h"
using namespace std;
void ReferenceValidator::visit(FunctionCall &call)
{
if(!call.declaration && !call.constructor)
- error(call, format("Call to undeclared function '%s'", call.name));
+ {
+ map<string, FunctionDeclaration *>::iterator i = stage->functions.lower_bound(call.name);
+ if(i!=stage->functions.end() && i->second->name==call.name)
+ {
+ bool valid_types = true;
+ string signature;
+ for(NodeArray<Expression>::const_iterator j=call.arguments.begin(); (valid_types && j!=call.arguments.end()); ++j)
+ {
+ if((*j)->type)
+ append(signature, ", ", (*j)->type->name);
+ else
+ valid_types = false;
+ }
+
+ if(valid_types)
+ error(call, format("No matching overload found for call to '%s(%s)'", call.name, signature));
+ }
+ else
+ error(call, format("Call to undeclared function '%s'", call.name));
+ }
TraversingVisitor::visit(call);
}