Commit 47fadcb9 by Olli Etuaho

Remove code related to redeclaration of arrays

It should not be possible to redeclare arrays. This seems to be another thing left over from earlier erroneous code which allowed declaring unsized arrays. TEST=angle_unittests BUG=angleproject:941 Change-Id: I711565230b35df077f268cec6fdeac6c4c03b4cd Reviewed-on: https://chromium-review.googlesource.com/264672Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Tested-by: 's avatarOlli Etuaho <oetuaho@nvidia.com>
parent 3739d235
...@@ -781,8 +781,8 @@ bool TParseContext::arrayTypeErrorCheck(const TSourceLoc& line, TPublicType type ...@@ -781,8 +781,8 @@ bool TParseContext::arrayTypeErrorCheck(const TSourceLoc& line, TPublicType type
} }
// //
// Do all the semantic checking for declaring an array, with and // Do all the semantic checking for declaring an array,
// without a size, and make the right changes to the symbol table. // and make the right changes to the symbol table.
// //
// size == 0 means no specified size. // size == 0 means no specified size.
// //
...@@ -790,11 +790,6 @@ bool TParseContext::arrayTypeErrorCheck(const TSourceLoc& line, TPublicType type ...@@ -790,11 +790,6 @@ bool TParseContext::arrayTypeErrorCheck(const TSourceLoc& line, TPublicType type
// //
bool TParseContext::arrayErrorCheck(const TSourceLoc& line, const TString& identifier, const TPublicType &type, TVariable*& variable) bool TParseContext::arrayErrorCheck(const TSourceLoc& line, const TString& identifier, const TPublicType &type, TVariable*& variable)
{ {
//
// Don't check for reserved word use until after we know it's not in the symbol table,
// because reserved arrays can be redeclared.
//
bool builtIn = false; bool builtIn = false;
bool sameScope = false; bool sameScope = false;
TSymbol* symbol = symbolTable.find(identifier, 0, &builtIn, &sameScope); TSymbol* symbol = symbolTable.find(identifier, 0, &builtIn, &sameScope);
...@@ -827,31 +822,13 @@ bool TParseContext::arrayErrorCheck(const TSourceLoc& line, const TString& ident ...@@ -827,31 +822,13 @@ bool TParseContext::arrayErrorCheck(const TSourceLoc& line, const TString& ident
error(line, "INTERNAL ERROR inserting new symbol", identifier.c_str()); error(line, "INTERNAL ERROR inserting new symbol", identifier.c_str());
return true; return true;
} }
} else {
if (! symbol->isVariable()) {
error(line, "variable expected", identifier.c_str());
return true;
} }
else
variable = static_cast<TVariable*>(symbol); {
if (! variable->getType().isArray()) { error(line, "redeclaration of an array", identifier.c_str());
error(line, "redeclaring non-array as array", identifier.c_str());
return true;
}
if (variable->getType().getArraySize() > 0) {
error(line, "redeclaration of array with size", identifier.c_str());
return true;
}
if (! variable->getType().sameElementType(TType(type))) {
error(line, "redeclaration of array with a different type", identifier.c_str());
return true; return true;
} }
if (type.arraySize)
variable->getType().setArraySize(type.arraySize);
}
if (voidErrorCheck(line, identifier, type)) if (voidErrorCheck(line, identifier, type))
return true; return true;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment