From aa3cd5abb9f647d3b258799723fb2ecc3c6d2309 Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Tue, 10 Nov 2015 14:29:35 -0500 Subject: [PATCH] Optional typed literal number should be concrete in BinaryParser. --- source/binary.cpp | 1 + test/BinaryToText.cpp | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/source/binary.cpp b/source/binary.cpp index f3df4ad7c..94e51a27e 100644 --- a/source/binary.cpp +++ b/source/binary.cpp @@ -451,6 +451,7 @@ spv_result_t Parser::parseOperand(spv_parsed_instruction_t* inst, case SPV_OPERAND_TYPE_TYPED_LITERAL_NUMBER: case SPV_OPERAND_TYPE_OPTIONAL_TYPED_LITERAL_INTEGER: + parsed_operand.type = SPV_OPERAND_TYPE_TYPED_LITERAL_NUMBER; if (inst->opcode == SpvOpSwitch) { // The literal operands have the same type as the value // referenced by the selector Id. diff --git a/test/BinaryToText.cpp b/test/BinaryToText.cpp index eb1cd1f68..61e6ab6e5 100644 --- a/test/BinaryToText.cpp +++ b/test/BinaryToText.cpp @@ -497,4 +497,14 @@ TEST_F(MaskSorting, MasksAreSortedFromLSBToMSB) { " %5 %6 %7 %8 %9 %10 %11 %12 %13\n")); } +using OperandTypeTest = spvtest::TextToBinaryTest; + +TEST_F(OperandTypeTest, OptionalTypedLiteralNumber) { + const std::string input = + "%1 = OpTypeInt 32 0\n" + "%2 = OpConstant %1 42\n" + "OpSwitch %2 %3 100 %4\n"; + EXPECT_EQ(input, EncodeAndDecodeSuccessfully(input)); +} + } // anonymous namespace