Commit 193c0950 by Olli Etuaho Committed by Commit Bot

Fix assert when attempting to create a void array node

TIntermTyped::CreateZero can be reached with a void array type in an error case. Handle this gracefully instead of asserting. Also remove an assert that wasn't really checking anything in CreateZero. type.isScalar() || type.isVector() || type.isMatrix() can only be false in case of a struct, and struct type was being checked in the condition on the line above. BUG=chromium:717385 TEST=angle_unittests Change-Id: Iff0811d18d399d7b32b2b46deea5df172412eb8c Reviewed-on: https://chromium-review.googlesource.com/492887Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
parent be849e4f
......@@ -564,8 +564,6 @@ TIntermTyped *TIntermTyped::CreateZero(const TType &type)
if (!type.isArray() && type.getBasicType() != EbtStruct)
{
ASSERT(type.isScalar() || type.isVector() || type.isMatrix());
size_t size = constType.getObjectSize();
TConstantUnion *u = new TConstantUnion[size];
for (size_t i = 0; i < size; ++i)
......@@ -599,6 +597,15 @@ TIntermTyped *TIntermTyped::CreateZero(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.
constType.clearArrayness();
return CreateZero(constType);
}
TIntermSequence *arguments = new TIntermSequence();
if (type.isArray())
......
......@@ -3707,3 +3707,25 @@ TEST_F(FragmentShaderValidationTest, SamplerUniformBindingESSL300)
FAIL() << "Shader compilation succeeded, expecting failure " << mInfoLog;
}
}
// Attempting to construct a struct containing a void array should fail without asserting.
TEST_F(FragmentShaderValidationTest, ConstructStructContainingVoidArray)
{
const std::string &shaderString =
"#version 300 es\n"
"precision mediump float;\n"
"out vec4 outFrag;\n"
"struct S\n"
"{\n"
" void A[1];\n"
"} s = S();\n"
"void main()\n"
"{\n"
" outFrag = vec4(0.0);\n"
"}\n";
if (compile(shaderString))
{
FAIL() << "Shader compilation succeeded, expecting failure " << mInfoLog;
}
}
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