Validator: Change the error message for v-0031

It previously said:

"a struct containing a runtime-sized array must be in the 'storage' storage class"

This had be looking at the variable's storage class, when the error was actually trying to tell me I needed `[[block]]` on the struct declaration.

Change-Id: I7a23a0c0c35508bdac20c808d2635592638dfa77
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/40602
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Sarah Mashayekhi <sarahmashay@google.com>
This commit is contained in:
Ben Clayton 2021-02-08 21:14:52 +00:00 committed by Commit Bot service account
parent a51aa1f805
commit 4c51d97a5c
2 changed files with 4 additions and 4 deletions

View File

@ -318,9 +318,9 @@ bool ValidatorImpl::ValidateConstructedTypes(
return false;
}
if (!st->IsBlockDecorated()) {
add_error(member->source(), "v-0031",
add_error(member->source(), "v-0015",
"a struct containing a runtime-sized array "
"must be in the 'storage' storage class: '" +
"requires the [[block]] attribute: '" +
program_->Symbols().NameFor(st->symbol()) + "'");
return false;
}

View File

@ -79,8 +79,8 @@ TEST_F(ValidatorTypeTest, RuntimeArrayIsLastNoBlock_Fail) {
EXPECT_FALSE(v.ValidateConstructedTypes(program->AST().ConstructedTypes()));
EXPECT_EQ(v.error(),
"v-0031: a struct containing a runtime-sized array must be "
"in the 'storage' storage class: 'Foo'");
"v-0015: a struct containing a runtime-sized array requires the "
"[[block]] attribute: 'Foo'");
}
TEST_F(ValidatorTypeTest, RuntimeArrayIsNotLast_Fail) {