Commit 7af63727 by Olli Etuaho Committed by Commit Bot

Fix nullptr dereference on struct parameter error

Function parameter name string does not necessarily exist, so it's better to use the function name as the token in the error message. BUG=chromium:784158 TEST=angle_unittests Change-Id: I8f3b8604fd702bdc9486b8d721a5f60de1ff3fa7 Reviewed-on: https://chromium-review.googlesource.com/765972Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
parent c4eca923
...@@ -3318,7 +3318,7 @@ TFunction *TParseContext::parseFunctionDeclarator(const TSourceLoc &location, TF ...@@ -3318,7 +3318,7 @@ TFunction *TParseContext::parseFunctionDeclarator(const TSourceLoc &location, TF
{ {
// ESSL 3.00.6 section 12.10. // ESSL 3.00.6 section 12.10.
error(location, "Function parameter type cannot be a structure definition", error(location, "Function parameter type cannot be a structure definition",
param.name->c_str()); function->getName().c_str());
} }
} }
......
...@@ -5275,6 +5275,32 @@ TEST_F(FragmentShaderValidationTest, NamedStructDefinitionAsParameterType) ...@@ -5275,6 +5275,32 @@ TEST_F(FragmentShaderValidationTest, NamedStructDefinitionAsParameterType)
} }
} }
// Test that a named struct definition is not allowed as a function parameter type.
// ESSL 3.00.6 section 12.10. ESSL 3.10 January 2016 section 13.10.
TEST_F(FragmentShaderValidationTest, StructDefinitionAsTypeOfParameterWithoutName)
{
const std::string &shaderString =
R"(#version 300 es
precision highp float;
out vec4 my_FragColor;
float foo(struct S { float field; } /* no parameter name */)
{
return 1.0;
}
void main()
{
my_FragColor = vec4(0, 1, 0, 1);
})";
if (compile(shaderString))
{
FAIL() << "Shader compilation succeeded, expecting failure:\n" << mInfoLog;
}
}
// Test that an unsized const array doesn't assert. // Test that an unsized const array doesn't assert.
TEST_F(FragmentShaderValidationTest, UnsizedConstArray) TEST_F(FragmentShaderValidationTest, UnsizedConstArray)
{ {
......
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