Commit 7e1197e0 by Jiawei Shao Committed by Commit Bot

Fix crash when indexing unsupported interface blocks by variable

This patch intends to fix a compiler crash when indexing an unsupported interface blocks. We should not use UNREACHABLE() here because the compiler will continue parsing when this kind of error is generated. Instead, we use an ASSERT to ensure the compile error must have been reported before when the parsing reaches here. BUG=chromium:758159 Change-Id: I4bc63316d156d51f721123fe963106d1e81d8d32 Reviewed-on: https://chromium-review.googlesource.com/631797Reviewed-by: 's avatarOlli Etuaho <oetuaho@nvidia.com> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
parent 97577623
......@@ -3799,7 +3799,9 @@ TIntermTyped *TParseContext::addIndexExpression(TIntermTyped *baseExpression,
"[");
break;
default:
UNREACHABLE();
// We can reach here only in error cases.
ASSERT(mDiagnostics->numErrors() > 0);
break;
}
}
else if (baseExpression->getQualifier() == EvqFragmentOut)
......
......@@ -4626,3 +4626,68 @@ TEST_F(FragmentShaderOESGeometryShaderValidationTest,
}
}
}
// Test that declaring and using an interface block with 'const' qualifier is not allowed.
TEST_F(VertexShaderValidationTest, InterfaceBlockUsingConstQualifier)
{
const std::string &shaderString =
"#version 310 es\n"
"const block\n"
"{\n"
" vec2 value;\n"
"} ConstBlock[2];\n"
"void main()\n"
"{\n"
" int i = 0;\n"
" vec2 value1 = ConstBlock[i].value;\n"
"}\n";
if (compile(shaderString))
{
FAIL() << "Shader compilation succeeded, expecting failure:\n" << mInfoLog;
}
}
// Test that using shader io blocks without declaration of GL_OES_shader_io_block is not allowed.
TEST_F(VertexShaderValidationTest, IOBlockWithoutExtension)
{
const std::string &shaderString =
"#version 310 es\n"
"out block\n"
"{\n"
" vec2 value;\n"
"} VSOutput[2];\n"
"void main()\n"
"{\n"
" int i = 0;\n"
" vec2 value1 = VSOutput[i].value;\n"
"}\n";
if (compile(shaderString))
{
FAIL() << "Shader compilation succeeded, expecting failure:\n" << mInfoLog;
}
}
// Test that using shader io blocks without declaration of GL_OES_shader_io_block is not allowed.
TEST_F(FragmentShaderValidationTest, IOBlockWithoutExtension)
{
const std::string &shaderString =
"#version 310 es\n"
"precision mediump float;\n"
"in block\n"
"{\n"
" vec4 i_color;\n"
"} FSInput[2];\n"
"out vec4 o_color;\n"
"void main()\n"
"{\n"
" int i = 0;\n"
" o_color = FSInput[i].i_color;"
"}\n";
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