From: Ehsan Nasiri Date: Tue, 17 Jan 2017 21:28:59 +0000 (-0500) Subject: Fixes issue #493. X-Git-Tag: upstream/2018.6~969 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=eb7d2534df92ff036dd3090bc60cc8476169fe3a;p=platform%2Fupstream%2FSPIRV-Tools.git Fixes issue #493. Check function call operands and return type agree with the called function type. The validation code exists. I have fixed the unit tests. --- diff --git a/test/val/val_id_test.cpp b/test/val/val_id_test.cpp index 94b7cdb..b318fe5 100644 --- a/test/val/val_id_test.cpp +++ b/test/val/val_id_test.cpp @@ -2467,7 +2467,7 @@ TEST_F(ValidateIdWithMessage, OpFunctionCallResultTypeBad) { %6 = OpFunction %2 None %3 %7 = OpFunctionParameter %2 %8 = OpLabel -%9 = OpLoad %2 %7 +%9 = OpIAdd %2 %7 %7 OpReturnValue %9 OpFunctionEnd @@ -2478,6 +2478,9 @@ TEST_F(ValidateIdWithMessage, OpFunctionCallResultTypeBad) { OpFunctionEnd)"; CompileSuccessfully(spirv.c_str()); EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("OpFunctionCall Result Type '1's type does not " + "match Function '2's return type.")); } TEST_F(ValidateIdWithMessage, OpFunctionCallFunctionBad) { string spirv = kGLSL450MemoryModel + R"( @@ -2494,6 +2497,8 @@ TEST_F(ValidateIdWithMessage, OpFunctionCallFunctionBad) { OpFunctionEnd)"; CompileSuccessfully(spirv.c_str()); EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("OpFunctionCall Function '5' is not a function.")); } TEST_F(ValidateIdWithMessage, OpFunctionCallArgumentTypeBad) { string spirv = kGLSL450MemoryModel + R"( @@ -2509,7 +2514,7 @@ TEST_F(ValidateIdWithMessage, OpFunctionCallArgumentTypeBad) { %6 = OpFunction %2 None %3 %7 = OpFunctionParameter %2 %8 = OpLabel -%9 = OpLoad %2 %7 +%9 = OpIAdd %2 %7 %7 OpReturnValue %9 OpFunctionEnd @@ -2520,6 +2525,9 @@ TEST_F(ValidateIdWithMessage, OpFunctionCallArgumentTypeBad) { OpFunctionEnd)"; CompileSuccessfully(spirv.c_str()); EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions()); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("OpFunctionCall Argument '7's type does not match " + "Function '2's parameter type.")); } // Valid: OpSampledImage result is used in the same block by