]> git.tdb.fi Git - libs/gl.git/commitdiff
Check for function declaration conflicting with something else
authorMikko Rasa <tdb@tdb.fi>
Thu, 4 Mar 2021 15:57:00 +0000 (17:57 +0200)
committerMikko Rasa <tdb@tdb.fi>
Thu, 4 Mar 2021 15:59:38 +0000 (17:59 +0200)
Functions are allowed to have multiple declarations but only one
definition.

source/glsl/validate.cpp

index 5fd4ebcae76a8d050285fcb17c48336dbfce315b..f3390048298e2708db5e307e37b0832144c7c2dd 100644 (file)
@@ -95,6 +95,10 @@ void DeclarationValidator::visit(InterfaceBlock &iface)
 
 void DeclarationValidator::visit(FunctionDeclaration &func)
 {
+       if(Statement *previous = find_definition(func.name))
+               if(!dynamic_cast<FunctionDeclaration *>(previous))
+                       multiple_definition(format("'%s'", func.name), func, *previous);
+
        if(func.definition==&func)
                check_definition(func.name, func);
        TraversingVisitor::visit(func);