Fix constructing void array zero nodes

Correctly sized void arrays can be needed after parsing has recovered
from an error and the code is trying to evaluate the constant value of
a node. Since now we just have a generic EOpConstruct op instead of
different ops for different types, we can simply remove the special
handling for void arrays in CreateZeroNode to create the arrays in the
correct size.

BUG=chromium:890581
TEST=angle_unittests

Change-Id: I48d96c9ef1d695cd8583a845fd4bd24a7aaf535c
Reviewed-on: https://chromium-review.googlesource.com/c/1264515
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
This commit is contained in:
Olli Etuaho 2018-10-05 13:23:03 +03:00 коммит произвёл Commit Bot
Родитель 2343836c42
Коммит 5476e805a3
2 изменённых файлов: 20 добавлений и 12 удалений

Просмотреть файл

@ -86,18 +86,6 @@ TIntermTyped *CreateZeroNode(const TType &type)
return node;
}
if (type.getBasicType() == EbtVoid)
{
// Void array. This happens only on error condition, similarly to the case above. We don't
// have a constructor operator for void, so this needs special handling. We'll end up with a
// value without the array type, but that should not be a problem.
while (constType.isArray())
{
constType.toArrayElementType();
}
return CreateZeroNode(constType);
}
TIntermSequence *arguments = new TIntermSequence();
if (type.isArray())

Просмотреть файл

@ -6034,3 +6034,23 @@ TEST_F(FragmentShaderValidationTest, ValueFromConstantArrayAsArraySize)
FAIL() << "Shader compilation failed, expecting success:\n" << mInfoLog;
}
}
// Test that an invalid struct with void fields doesn't crash or assert when used in a comma
// operator. This is a regression test.
TEST_F(FragmentShaderValidationTest, InvalidStructWithVoidFieldsInComma)
{
// The struct needed the two fields for the bug to repro.
const std::string &shaderString =
R"(#version 300 es
precision highp float;
struct T { void a[8], c; };
void main() {
0.0, T();
})";
if (compile(shaderString))
{
FAIL() << "Shader compilation succeeded, expecting failure:\n" << mInfoLog;
}
}