void DeclarationValidator::visit(FunctionDeclaration &func)
{
+ string key = func.name+func.signature;
+ map<string, FunctionDeclaration *>::const_iterator i = overloaded_functions.find(key);
+ if(i==overloaded_functions.end())
+ overloaded_functions.insert(make_pair(key, &func));
+ else if(func.return_type_declaration && i->second->return_type_declaration!=func.return_type_declaration)
+ {
+ error(func, format("Conflicting return type '%s' for function '%s'", func.return_type_declaration->name, func.name));
+ if(i->second->return_type_declaration)
+ add_info(*i->second, format("Previously declared as returning '%s'", i->second->return_type_declaration->name));
+ }
+
if(Statement *previous = find_definition(func.name))
{
if(!dynamic_cast<FunctionDeclaration *>(previous))
std::map<Block *, BlockDeclarationMap> declarations;
std::map<std::string, InterfaceBlock *> interface_blocks;
+ std::map<std::string, FunctionDeclaration *> overloaded_functions;
bool anonymous_block;
public:
--- /dev/null
+#pragma MSP stage(vertex)
+layout(location=0) in vec4 position;
+void func();
+vec4 func();
+float func();
+float func(float v);
+void main()
+{
+ gl_Position = position;
+}
+
+/* Expected error:
+<test>:4: Conflicting return type 'vec4' for function 'func'
+<test>:3: Previously declared as returning 'void'
+<test>:5: Conflicting return type 'float' for function 'func'
+<test>:3: Previously declared as returning 'void'
+*/