From 78a5a0d7d8b2ac108c334daadbac90ce96ae7a8d Mon Sep 17 00:00:00 2001 From: John Kessenich Date: Mon, 20 Jul 2015 11:35:51 -0600 Subject: [PATCH] Front end: Prevent use of a block name, which has no other use in a shader. --- glslang/MachineIndependent/ParseHelper.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/glslang/MachineIndependent/ParseHelper.cpp b/glslang/MachineIndependent/ParseHelper.cpp index 86356778..25d129a1 100644 --- a/glslang/MachineIndependent/ParseHelper.cpp +++ b/glslang/MachineIndependent/ParseHelper.cpp @@ -448,8 +448,16 @@ TIntermTyped* TParseContext::handleVariable(TSourceLoc loc, TSymbol* symbol, con // The symbol table search was done in the lexical phase. // See if it was a variable. variable = symbol ? symbol->getAsVariable() : 0; - if (symbol && ! variable) - error(loc, "variable name expected", string->c_str(), ""); + if (variable) { + if ((variable->getType().getBasicType() == EbtBlock || + variable->getType().getBasicType() == EbtStruct) && variable->getType().getStruct() == nullptr) { + error(loc, "cannot be used (maybe an instance name is needed)", string->c_str(), ""); + variable = nullptr; + } + } else { + if (symbol) + error(loc, "variable name expected", string->c_str(), ""); + } // Recovery, if it wasn't found or was not a variable. if (! variable)