From 4c51d97a5ca9066f2abeb3562c7ffb27953de76f Mon Sep 17 00:00:00 2001 From: Ben Clayton Date: Mon, 8 Feb 2021 21:14:52 +0000 Subject: [PATCH] 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 Reviewed-by: Sarah Mashayekhi --- src/validator/validator_impl.cc | 4 ++-- src/validator/validator_type_test.cc | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/validator/validator_impl.cc b/src/validator/validator_impl.cc index 16da3e3bd9..ecad8efef7 100644 --- a/src/validator/validator_impl.cc +++ b/src/validator/validator_impl.cc @@ -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; } diff --git a/src/validator/validator_type_test.cc b/src/validator/validator_type_test.cc index 306182a674..5f136eaadf 100644 --- a/src/validator/validator_type_test.cc +++ b/src/validator/validator_type_test.cc @@ -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) {