mirror of
https://github.com/KhronosGroup/SPIRV-Tools
synced 2024-12-26 01:31:06 +00:00
Disallow forward references in arrays (#3093)
Fixes https://crbug.com/1031049 * Disallow forward references in arrays * Add a test
This commit is contained in:
parent
31acc78821
commit
a466b99dbb
@ -503,9 +503,6 @@ std::function<bool(unsigned)> spvOperandCanBeForwardDeclaredFunction(
|
||||
case SpvOpTypeForwardPointer:
|
||||
out = [](unsigned index) { return index == 0; };
|
||||
break;
|
||||
case SpvOpTypeArray:
|
||||
out = [](unsigned index) { return index == 1; };
|
||||
break;
|
||||
default:
|
||||
out = [](unsigned) { return false; };
|
||||
break;
|
||||
|
@ -6572,6 +6572,25 @@ TEST_F(ValidateIdWithMessage, MissingForwardPointer) {
|
||||
"Operand 3[%_ptr_Uniform__struct_2] requires a previous definition"));
|
||||
}
|
||||
|
||||
TEST_F(ValidateIdWithMessage, ArrayTypeForwardReference) {
|
||||
const std::string spirv = R"(
|
||||
OpCapability Linkage
|
||||
OpCapability MinLod
|
||||
OpCapability GenericPointer
|
||||
OpMemoryModel Logical Simple
|
||||
OpName %_ptr_Input__arr_9_uint_7 "ptr"
|
||||
%uint = OpTypeInt 32 0
|
||||
%uint_7 = OpConstant %uint 7
|
||||
%_arr_9_uint_7 = OpTypeArray %_ptr_Input__arr_9_uint_7 %uint_7
|
||||
%_ptr_Input__arr_9_uint_7 = OpTypePointer Input %_arr_9_uint_7
|
||||
)";
|
||||
|
||||
CompileSuccessfully(spirv);
|
||||
EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions());
|
||||
EXPECT_THAT(getDiagnosticString(),
|
||||
HasSubstr("ID 1[%ptr] has not been defined"));
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace val
|
||||
} // namespace spvtools
|
||||
|
Loading…
Reference in New Issue
Block a user