From 15562a0c458fd655b6907c285951085f38270e27 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Tue, 9 Mar 2021 19:17:36 +0200 Subject: [PATCH] Require GLSL functions to be declared before use --- source/glsl/validate.cpp | 7 +++++++ source/glsl/validate.h | 1 + 2 files changed, 8 insertions(+) diff --git a/source/glsl/validate.cpp b/source/glsl/validate.cpp index 91d1de99..1458d01e 100644 --- a/source/glsl/validate.cpp +++ b/source/glsl/validate.cpp @@ -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) diff --git a/source/glsl/validate.h b/source/glsl/validate.h index a8c6f11c..35cc049c 100644 --- a/source/glsl/validate.h +++ b/source/glsl/validate.h @@ -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 &); -- 2.45.2