Commit 8d8b108a by Olli Etuaho

Disallow local function prototypes

Function prototypes should not be allowed inside other functions according to ESSL 3.00.4 section 4.2.4. BUG=angleproject:1068 TEST=angle_unittests, dEQP-GLES*.functional.shaders.functions.invalid.local_function_proto* Change-Id: I54160da4d49b92a6cd7cbee020e67733963d4e10 Reviewed-on: https://chromium-review.googlesource.com/320091 Tryjob-Request: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org> Tested-by: 's avatarOlli Etuaho <oetuaho@nvidia.com>
parent 5d653186
...@@ -1968,6 +1968,14 @@ TIntermAggregate *TParseContext::addFunctionPrototypeDeclaration(const TFunction ...@@ -1968,6 +1968,14 @@ TIntermAggregate *TParseContext::addFunctionPrototypeDeclaration(const TFunction
prototype->setOp(EOpPrototype); prototype->setOp(EOpPrototype);
symbolTable.pop(); symbolTable.pop();
if (!symbolTable.atGlobalLevel())
{
// ESSL 3.00.4 section 4.2.4.
error(location, "local function prototype declarations are not allowed", "function");
recover();
}
return prototype; return prototype;
} }
......
...@@ -1494,3 +1494,22 @@ TEST_F(MalformedShaderTest, DuplicatePrototypeESSL3) ...@@ -1494,3 +1494,22 @@ TEST_F(MalformedShaderTest, DuplicatePrototypeESSL3)
FAIL() << "Shader compilation failed, expecting success " << mInfoLog; FAIL() << "Shader compilation failed, expecting success " << mInfoLog;
} }
} }
// Shaders with a local function prototype should be rejected.
// ESSL 3.00.4 section 4.2.4.
TEST_F(MalformedShaderTest, LocalFunctionPrototype)
{
const std::string &shaderString =
"#version 300 es\n"
"precision mediump float;\n"
"out vec4 my_FragColor;\n"
"void main()\n"
"{\n"
" void foo();\n"
" my_FragColor = vec4(0.0);\n"
"}\n";
if (compile(shaderString))
{
FAIL() << "Shader compilation succeeded, expecting failure " << mInfoLog;
}
}
...@@ -246,8 +246,6 @@ ...@@ -246,8 +246,6 @@
1143 MAC : dEQP-GLES2.functional.texture.specification.basic_copyteximage2d.cube_* = FAIL 1143 MAC : dEQP-GLES2.functional.texture.specification.basic_copyteximage2d.cube_* = FAIL
// Windows and Linux failures // Windows and Linux failures
1015 WIN LINUX : dEQP-GLES2.functional.shaders.functions.invalid.local_function_prototype_vertex = FAIL
1015 WIN LINUX : dEQP-GLES2.functional.shaders.functions.invalid.local_function_prototype_fragment = FAIL
1020 WIN LINUX : dEQP-GLES2.functional.texture.mipmap.cube.projected.linear_linear = FAIL 1020 WIN LINUX : dEQP-GLES2.functional.texture.mipmap.cube.projected.linear_linear = FAIL
504 WIN LINUX : dEQP-GLES2.functional.uniform_api.value.assigned.by_value.render.nested_structs_arrays.sampler2D_samplerCube_* = FAIL 504 WIN LINUX : dEQP-GLES2.functional.uniform_api.value.assigned.by_value.render.nested_structs_arrays.sampler2D_samplerCube_* = FAIL
......
...@@ -47,8 +47,6 @@ ...@@ -47,8 +47,6 @@
// TODO(jmadill): triage these into permanent and temporary failures // TODO(jmadill): triage these into permanent and temporary failures
1089 WIN : dEQP-GLES3.functional.shaders.functions.invalid.local_function_prototype_vertex = FAIL
1089 WIN : dEQP-GLES3.functional.shaders.functions.invalid.local_function_prototype_fragment = FAIL
1091 WIN : dEQP-GLES3.functional.shaders.loops.for_constant_iterations.nested_sequence_vertex = FAIL 1091 WIN : dEQP-GLES3.functional.shaders.loops.for_constant_iterations.nested_sequence_vertex = FAIL
1091 WIN : dEQP-GLES3.functional.shaders.loops.for_constant_iterations.nested_sequence_fragment = FAIL 1091 WIN : dEQP-GLES3.functional.shaders.loops.for_constant_iterations.nested_sequence_fragment = FAIL
1091 WIN : dEQP-GLES3.functional.shaders.loops.for_constant_iterations.nested_tricky_dataflow_1_vertex = FAIL 1091 WIN : dEQP-GLES3.functional.shaders.loops.for_constant_iterations.nested_tricky_dataflow_1_vertex = FAIL
......
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