Commit ef7fb388 by Olli Etuaho Committed by Commit Bot

Size const unsized arrays without an initializer

The array size for unsized arrays needs to be sanitized in all cases, since subsequent checks on array indexing depend on all arrays being sized. BUG=chromium:781729 TEST=angle_unittests Change-Id: I3af6c08bb249a19f7c2ef169c877a2b863eb31d3 Reviewed-on: https://chromium-review.googlesource.com/757101 Commit-Queue: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org>
parent 1734e171
......@@ -1061,7 +1061,6 @@ void TParseContext::checkCanBeDeclaredWithoutInitializer(const TSourceLoc &line,
{
error(line, "variables with qualifier 'const' must be initialized", identifier.c_str());
}
return;
}
// This will make the type sized if it isn't sized yet.
checkIsNotUnsizedArray(line, "implicitly sized arrays need to be initialized",
......
......@@ -5274,3 +5274,21 @@ TEST_F(FragmentShaderValidationTest, NamedStructDefinitionAsParameterType)
FAIL() << "Shader compilation succeeded, expecting failure:\n" << mInfoLog;
}
}
// Test that an unsized const array doesn't assert.
TEST_F(FragmentShaderValidationTest, UnsizedConstArray)
{
const std::string &shaderString =
R"(#version 300 es
void main()
{
const int t[];
t[0];
})";
if (compile(shaderString))
{
FAIL() << "Shader compilation succeeded, expecting failure:\n" << 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