Commit 858c0393 by Nicolas Capens Committed by Nicolas Capens

Initialize array size on error.

The array size is set using the value returned by arraySizeErrorCheck, even when an error occurred, so don't leave it uninitialized. Bug chromium:801648 Change-Id: If2af27c5f61dca2931796f1681dce61ab6a44341 Reviewed-on: https://swiftshader-review.googlesource.com/18368Tested-by: 's avatarNicolas Capens <nicolascapens@google.com> Reviewed-by: 's avatarAlexis Hétu <sugoi@google.com>
parent 0f4c4f8d
...@@ -802,6 +802,7 @@ bool TParseContext::arraySizeErrorCheck(const TSourceLoc &line, TIntermTyped* ex ...@@ -802,6 +802,7 @@ bool TParseContext::arraySizeErrorCheck(const TSourceLoc &line, TIntermTyped* ex
if (expr->getQualifier() != EvqConstExpr || constant == 0 || !constant->isScalarInt()) if (expr->getQualifier() != EvqConstExpr || constant == 0 || !constant->isScalarInt())
{ {
error(line, "array size must be a constant integer expression", ""); error(line, "array size must be a constant integer expression", "");
size = 1;
return true; return true;
} }
...@@ -1485,7 +1486,7 @@ TIntermAggregate *TParseContext::parseSingleArrayDeclaration(TPublicType &public ...@@ -1485,7 +1486,7 @@ TIntermAggregate *TParseContext::parseSingleArrayDeclaration(TPublicType &public
TType arrayType(publicType); TType arrayType(publicType);
int size; int size = 0;
if(arraySizeErrorCheck(identifierLocation, indexExpression, size)) if(arraySizeErrorCheck(identifierLocation, indexExpression, size))
{ {
recover(); recover();
...@@ -1666,7 +1667,7 @@ TIntermAggregate *TParseContext::parseArrayDeclarator(TPublicType &publicType, T ...@@ -1666,7 +1667,7 @@ TIntermAggregate *TParseContext::parseArrayDeclarator(TPublicType &publicType, T
else else
{ {
TType arrayType = TType(publicType); TType arrayType = TType(publicType);
int size; int size = 0;
if(arraySizeErrorCheck(arrayLocation, indexExpression, size)) if(arraySizeErrorCheck(arrayLocation, indexExpression, size))
{ {
recover(); recover();
......
...@@ -728,7 +728,7 @@ parameter_declarator ...@@ -728,7 +728,7 @@ parameter_declarator
if (context->reservedErrorCheck(@2, *$2.string)) if (context->reservedErrorCheck(@2, *$2.string))
context->recover(); context->recover();
int size; int size = 0;
if (context->arraySizeErrorCheck(@3, $4, size)) if (context->arraySizeErrorCheck(@3, $4, size))
context->recover(); context->recover();
$1.setArray(true, size); $1.setArray(true, size);
...@@ -1069,7 +1069,7 @@ type_specifier_no_prec ...@@ -1069,7 +1069,7 @@ type_specifier_no_prec
if (context->arrayTypeErrorCheck(@2, $1)) if (context->arrayTypeErrorCheck(@2, $1))
context->recover(); context->recover();
else { else {
int size; int size = 0;
if (context->arraySizeErrorCheck(@2, $3, size)) if (context->arraySizeErrorCheck(@2, $3, size))
context->recover(); context->recover();
$$.setArray(true, size); $$.setArray(true, size);
...@@ -1385,7 +1385,7 @@ struct_declarator ...@@ -1385,7 +1385,7 @@ struct_declarator
context->recover(); context->recover();
TType* type = new TType(EbtVoid, EbpUndefined); TType* type = new TType(EbtVoid, EbpUndefined);
int size; int size = 0;
if (context->arraySizeErrorCheck($3->getLine(), $3, size)) if (context->arraySizeErrorCheck($3->getLine(), $3, size))
context->recover(); context->recover();
type->setArraySize(size); type->setArraySize(size);
......
...@@ -3249,7 +3249,7 @@ yyreduce: ...@@ -3249,7 +3249,7 @@ yyreduce:
if (context->reservedErrorCheck((yylsp[-3]), *(yyvsp[-3].lex).string)) if (context->reservedErrorCheck((yylsp[-3]), *(yyvsp[-3].lex).string))
context->recover(); context->recover();
int size; int size = 0;
if (context->arraySizeErrorCheck((yylsp[-2]), (yyvsp[-1].interm.intermTypedNode), size)) if (context->arraySizeErrorCheck((yylsp[-2]), (yyvsp[-1].interm.intermTypedNode), size))
context->recover(); context->recover();
(yyvsp[-4].interm.type).setArray(true, size); (yyvsp[-4].interm.type).setArray(true, size);
...@@ -3816,7 +3816,7 @@ yyreduce: ...@@ -3816,7 +3816,7 @@ yyreduce:
if (context->arrayTypeErrorCheck((yylsp[-2]), (yyvsp[-3].interm.type))) if (context->arrayTypeErrorCheck((yylsp[-2]), (yyvsp[-3].interm.type)))
context->recover(); context->recover();
else { else {
int size; int size = 0;
if (context->arraySizeErrorCheck((yylsp[-2]), (yyvsp[-1].interm.intermTypedNode), size)) if (context->arraySizeErrorCheck((yylsp[-2]), (yyvsp[-1].interm.intermTypedNode), size))
context->recover(); context->recover();
(yyval.interm.type).setArray(true, size); (yyval.interm.type).setArray(true, size);
...@@ -4401,7 +4401,7 @@ yyreduce: ...@@ -4401,7 +4401,7 @@ yyreduce:
context->recover(); context->recover();
TType* type = new TType(EbtVoid, EbpUndefined); TType* type = new TType(EbtVoid, EbpUndefined);
int size; int size = 0;
if (context->arraySizeErrorCheck((yyvsp[-1].interm.intermTypedNode)->getLine(), (yyvsp[-1].interm.intermTypedNode), size)) if (context->arraySizeErrorCheck((yyvsp[-1].interm.intermTypedNode)->getLine(), (yyvsp[-1].interm.intermTypedNode), size))
context->recover(); context->recover();
type->setArraySize(size); type->setArraySize(size);
......
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