]> git.tdb.fi Git - libs/gl.git/commitdiff
Require GLSL functions to be declared before use
authorMikko Rasa <tdb@tdb.fi>
Tue, 9 Mar 2021 17:17:36 +0000 (19:17 +0200)
committerMikko Rasa <tdb@tdb.fi>
Tue, 9 Mar 2021 20:26:19 +0000 (22:26 +0200)
source/glsl/validate.cpp
source/glsl/validate.h

index 91d1de991515dc74dbb359d0385a0429ef855803..1458d01eaaba8743d40e90bb9b030790dca3cad9 100644 (file)
@@ -236,6 +236,13 @@ void ReferenceValidator::visit(InterfaceBlockReference &iface)
                error(iface, format("Use of unlinked input block '%s'", iface.name));
 }
 
+void ReferenceValidator::visit(FunctionCall &call)
+{
+       if(!call.declaration && !call.constructor)
+               error(call, format("Call to undeclared function '%s'", call.name));
+       TraversingVisitor::visit(call);
+}
+
 void ReferenceValidator::visit(VariableDeclaration &var)
 {
        if(!var.type_declaration)
index a8c6f11c6a8e12602431abb6fd22a93b280e55fd..35cc049c8d0809edbb007cca63b35d42e560e483 100644 (file)
@@ -82,6 +82,7 @@ private:
        virtual void visit(VariableReference &);
        virtual void visit(MemberAccess &);
        virtual void visit(InterfaceBlockReference &);
+       virtual void visit(FunctionCall &);
        virtual void visit(VariableDeclaration &);
        virtual void visit(InterfaceBlock &);
        virtual void visit(FunctionDeclaration &);