From 73d52ab92ce8da522cd2eeb0d7f13c6af3f46e02 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Fri, 12 Mar 2021 00:23:10 +0200 Subject: [PATCH] Improve reporting of errors from function resolution If there are some overloads, report that none of them matched the argument types. --- source/glsl/validate.cpp | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/source/glsl/validate.cpp b/source/glsl/validate.cpp index 1458d01e..8805d41f 100644 --- a/source/glsl/validate.cpp +++ b/source/glsl/validate.cpp @@ -2,6 +2,7 @@ #include #include #include +#include #include "validate.h" using namespace std; @@ -239,7 +240,26 @@ void ReferenceValidator::visit(InterfaceBlockReference &iface) void ReferenceValidator::visit(FunctionCall &call) { if(!call.declaration && !call.constructor) - error(call, format("Call to undeclared function '%s'", call.name)); + { + map::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::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); } -- 2.45.2