Commit 5476e805 by Olli Etuaho Committed by Commit Bot

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/1264515Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
parent 2343836c
......@@ -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;
}
}
\ No newline at end of file
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