From 4181ceb89a2d538712c81826da610e7e8583e9a5 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Mon, 8 Mar 2021 19:18:22 +0200 Subject: [PATCH] Validate member names --- 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 c4e0a9bd..4523b746 100644 --- a/source/glsl/validate.cpp +++ b/source/glsl/validate.cpp @@ -196,6 +196,13 @@ void ReferenceValidator::visit(VariableReference &var) error(var, format("Use of unlinked input variable '%s'", var.name)); } +void ReferenceValidator::visit(MemberAccess &memacc) +{ + if(memacc.left->type && !memacc.declaration) + error(memacc, format("Use of undeclared member '%s'", memacc.member)); + TraversingVisitor::visit(memacc); +} + void ReferenceValidator::visit(InterfaceBlockReference &iface) { /* An interface block reference without a declaration should be impossible diff --git a/source/glsl/validate.h b/source/glsl/validate.h index 2efb5199..b6497327 100644 --- a/source/glsl/validate.h +++ b/source/glsl/validate.h @@ -76,6 +76,7 @@ private: virtual void visit(BasicTypeDeclaration &); virtual void visit(ImageTypeDeclaration &); virtual void visit(VariableReference &); + virtual void visit(MemberAccess &); virtual void visit(InterfaceBlockReference &); virtual void visit(VariableDeclaration &); virtual void visit(InterfaceBlock &); -- 2.45.2