From b01755a5e2c184fdee3047f3a99caa2b90881fd0 Mon Sep 17 00:00:00 2001 From: Umar Arshad Date: Fri, 12 Aug 2016 14:28:17 -0400 Subject: [PATCH] OpUndef can appear in type declaration section --- source/val/ValidationState.cpp | 1 + test/Validate.Layout.cpp | 23 ++++++++++++++++++++--- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/source/val/ValidationState.cpp b/source/val/ValidationState.cpp index adb4753dc..9cfe2da3b 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 05c55a29a..6ae7c0717 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) {