From: Umar Arshad Date: Fri, 12 Aug 2016 18:28:17 +0000 (-0400) Subject: OpUndef can appear in type declaration section X-Git-Tag: upstream/2018.6~1125 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b01755a5e2c184fdee3047f3a99caa2b90881fd0;p=platform%2Fupstream%2FSPIRV-Tools.git OpUndef can appear in type declaration section --- diff --git a/source/val/ValidationState.cpp b/source/val/ValidationState.cpp index adb4753..9cfe2da 100644 --- a/source/val/ValidationState.cpp +++ b/source/val/ValidationState.cpp @@ -122,6 +122,7 @@ bool IsInstructionInLayoutSection(ModuleLayoutSection layout, SpvOp op) { case SpvOpVariable: case SpvOpLine: case SpvOpNoLine: + case SpvOpUndef: out = true; break; default: break; diff --git a/test/Validate.Layout.cpp b/test/Validate.Layout.cpp index 05c55a2..6ae7c07 100644 --- a/test/Validate.Layout.cpp +++ b/test/Validate.Layout.cpp @@ -313,7 +313,7 @@ TEST_F(ValidateLayout, FuncParameterNotImmediatlyAfterFuncBad) { ASSERT_EQ(SPV_ERROR_INVALID_LAYOUT, ValidateInstructions()); } -TEST_F(ValidateLayout, InstructionAppearBeforeFunctionDefinition) { +TEST_F(ValidateLayout, OpUndefCanAppearInTypeDeclarationSection) { string str = R"( OpCapability Kernel OpMemoryModel Logical OpenCL @@ -328,8 +328,25 @@ TEST_F(ValidateLayout, InstructionAppearBeforeFunctionDefinition) { )"; CompileSuccessfully(str); - ASSERT_EQ(SPV_ERROR_INVALID_LAYOUT, ValidateInstructions()); - EXPECT_THAT(getDiagnosticString(), StrEq("Undef must appear in a block")); + ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); +} + +TEST_F(ValidateLayout, OpUndefCanAppearInBlock) { + string str = R"( + OpCapability Kernel + OpMemoryModel Logical OpenCL +%voidt = OpTypeVoid +%uintt = OpTypeInt 32 0 +%funct = OpTypeFunction %voidt +%func = OpFunction %voidt None %funct +%entry = OpLabel +%udef = OpUndef %uintt + OpReturn + OpFunctionEnd +)"; + + CompileSuccessfully(str); + ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()); } TEST_F(ValidateLayout, MissingFunctionEndForFunctionWithBody) {