mirror of
https://github.com/KhronosGroup/SPIRV-Tools
synced 2024-12-26 01:31:06 +00:00
Catch invalid input type to OpConvertUToPtr (#2078)
Fixes https://crbug.com/906426 * Fails validation if the input operand is a type * Added a test
This commit is contained in:
parent
8cd2a9d187
commit
f5b4a8eee3
@ -248,7 +248,7 @@ spv_result_t ConversionPass(ValidationState_t& _, const Instruction* inst) {
|
|||||||
<< spvOpcodeString(opcode);
|
<< spvOpcodeString(opcode);
|
||||||
|
|
||||||
const uint32_t input_type = _.GetOperandTypeId(inst, 2);
|
const uint32_t input_type = _.GetOperandTypeId(inst, 2);
|
||||||
if (!_.IsIntScalarType(input_type))
|
if (!input_type || !_.IsIntScalarType(input_type))
|
||||||
return _.diag(SPV_ERROR_INVALID_DATA, inst)
|
return _.diag(SPV_ERROR_INVALID_DATA, inst)
|
||||||
<< "Expected int scalar as input: " << spvOpcodeString(opcode);
|
<< "Expected int scalar as input: " << spvOpcodeString(opcode);
|
||||||
break;
|
break;
|
||||||
|
@ -1279,6 +1279,29 @@ TEST_F(ValidateConversion, BitcastDifferentTotalBitWidth) {
|
|||||||
"Bitcast"));
|
"Bitcast"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(ValidateConversion, ConvertUToPtrInputIsAType) {
|
||||||
|
const std::string spirv = R"(
|
||||||
|
OpCapability Addresses
|
||||||
|
OpCapability Shader
|
||||||
|
OpCapability Linkage
|
||||||
|
OpMemoryModel Logical GLSL450
|
||||||
|
%int = OpTypeInt 32 0
|
||||||
|
%ptr_int = OpTypePointer Function %int
|
||||||
|
%void = OpTypeVoid
|
||||||
|
%voidfn = OpTypeFunction %void
|
||||||
|
%func = OpFunction %void None %voidfn
|
||||||
|
%entry = OpLabel
|
||||||
|
%1 = OpConvertUToPtr %ptr_int %int
|
||||||
|
OpReturn
|
||||||
|
OpFunctionEnd
|
||||||
|
)";
|
||||||
|
|
||||||
|
CompileSuccessfully(spirv);
|
||||||
|
EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
|
||||||
|
EXPECT_THAT(getDiagnosticString(),
|
||||||
|
HasSubstr("Expected int scalar as input: ConvertUToPtr"));
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
} // namespace val
|
} // namespace val
|
||||||
} // namespace spvtools
|
} // namespace spvtools
|
||||||
|
Loading…
Reference in New Issue
Block a user