Fix #1879: Check for valid variable before checking for unsized arrays.
The order of error checking was not quite being correct (maybe there is no correct ordering, when many checks must be done and they affect each other). So, check for block-name reuse twice.
This commit is contained in:
parent
34953810a6
commit
664ad418f8
4 changed files with 17 additions and 7 deletions
|
|
@ -1661,6 +1661,8 @@ public:
|
|||
virtual bool isImage() const { return basicType == EbtSampler && getSampler().isImage(); }
|
||||
virtual bool isSubpass() const { return basicType == EbtSampler && getSampler().isSubpass(); }
|
||||
virtual bool isTexture() const { return basicType == EbtSampler && getSampler().isTexture(); }
|
||||
// Check the block-name convention of creating a block without populating it's members:
|
||||
virtual bool isUnusableName() const { return isStruct() && structure == nullptr; }
|
||||
virtual bool isParameterized() const { return typeParameters != nullptr; }
|
||||
#ifdef GLSLANG_WEB
|
||||
bool isAtomic() const { return false; }
|
||||
|
|
|
|||
|
|
@ -319,10 +319,15 @@ TIntermTyped* TParseContext::handleVariable(const TSourceLoc& loc, TSymbol* symb
|
|||
// If this is a variable or a block, check it and all it contains, but if this
|
||||
// is a member of an anonymous block, check the whole block, as the whole block
|
||||
// will need to be copied up if it contains an unsized array.
|
||||
if (symbol->getType().containsUnsizedArray() ||
|
||||
(symbol->getAsAnonMember() &&
|
||||
symbol->getAsAnonMember()->getAnonContainer().getType().containsUnsizedArray()))
|
||||
makeEditable(symbol);
|
||||
//
|
||||
// This check is being done before the block-name check further down, so guard
|
||||
// for that too.
|
||||
if (!symbol->getType().isUnusableName()) {
|
||||
if (symbol->getType().containsUnsizedArray() ||
|
||||
(symbol->getAsAnonMember() &&
|
||||
symbol->getAsAnonMember()->getAnonContainer().getType().containsUnsizedArray()))
|
||||
makeEditable(symbol);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
@ -347,8 +352,7 @@ TIntermTyped* TParseContext::handleVariable(const TSourceLoc& loc, TSymbol* symb
|
|||
// See if it was a variable.
|
||||
variable = symbol ? symbol->getAsVariable() : nullptr;
|
||||
if (variable) {
|
||||
if ((variable->getType().getBasicType() == EbtBlock ||
|
||||
variable->getType().getBasicType() == EbtStruct) && variable->getType().getStruct() == nullptr) {
|
||||
if (variable->getType().isUnusableName()) {
|
||||
error(loc, "cannot be used (maybe an instance name is needed)", string->c_str(), "");
|
||||
variable = nullptr;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue