Improve an error message in the assembler (#5219)

Signed-off-by: Kevin Petit <kevin.petit@arm.com>
This commit is contained in:
Kévin Petit 2023-05-15 14:56:48 +01:00 committed by GitHub
parent 7c39951f6e
commit 17a26b45ff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 4 deletions

View File

@ -544,7 +544,8 @@ spv_result_t spvTextEncodeOpcode(const spvtools::AssemblyGrammar& grammar,
std::string equal_sign;
error = context->getWord(&equal_sign, &nextPosition);
if ("=" != equal_sign)
return context->diagnostic() << "'=' expected after result id.";
return context->diagnostic() << "'=' expected after result id but found '"
<< equal_sign << "'.";
// The <opcode> after the '=' sign.
context->setPosition(nextPosition);

View File

@ -41,7 +41,7 @@ TEST_F(OpTypePipeStorageTest, ArgumentCount) {
Eq(MakeInstruction(spv::Op::OpTypePipeStorage, {1})));
EXPECT_THAT(CompileFailure("%res = OpTypePipeStorage %1 %2 %3 %4 %5",
SPV_ENV_UNIVERSAL_1_1),
Eq("'=' expected after result id."));
Eq("'=' expected after result id but found '%2'."));
}
using OpConstantPipeStorageTest = spvtest::TextToBinaryTest;
@ -72,7 +72,7 @@ TEST_F(OpConstantPipeStorageTest, ArgumentCount) {
Eq(MakeInstruction(spv::Op::OpConstantPipeStorage, {1, 2, 3, 4, 5})));
EXPECT_THAT(CompileFailure("%1 = OpConstantPipeStorage %2 3 4 5 %6 %7",
SPV_ENV_UNIVERSAL_1_1),
Eq("'=' expected after result id."));
Eq("'=' expected after result id but found '%7'."));
}
TEST_F(OpConstantPipeStorageTest, ArgumentTypes) {
@ -118,7 +118,7 @@ TEST_F(OpCreatePipeFromPipeStorageTest, ArgumentCount) {
Eq(MakeInstruction(spv::Op::OpCreatePipeFromPipeStorage, {1, 2, 3})));
EXPECT_THAT(CompileFailure("%1 = OpCreatePipeFromPipeStorage %2 %3 %4 %5",
SPV_ENV_UNIVERSAL_1_1),
Eq("'=' expected after result id."));
Eq("'=' expected after result id but found '%5'."));
}
TEST_F(OpCreatePipeFromPipeStorageTest, ArgumentTypes) {