diff --git a/src/resolver/resolver.cc b/src/resolver/resolver.cc index b980b965e3..264b41be1c 100644 --- a/src/resolver/resolver.cc +++ b/src/resolver/resolver.cc @@ -979,8 +979,8 @@ bool Resolver::ValidateGlobalVariable(const VariableInfo* info) { if (info->storage_class != ast::StorageClass::kStorage && info->declaration->declared_access() != ast::Access::kUndefined) { AddError( - "variables declared not declared in the storage class must " - "not declare an access control", + "variables not in storage class must not declare an access " + "mode", info->declaration->source()); return false; } diff --git a/src/resolver/storage_class_validation_test.cc b/src/resolver/storage_class_validation_test.cc index 2d75c1f581..89fa428cb8 100644 --- a/src/resolver/storage_class_validation_test.cc +++ b/src/resolver/storage_class_validation_test.cc @@ -99,6 +99,18 @@ TEST_F(ResolverStorageClassValidationTest, StorageBufferBoolAlias) { R"(56:78 error: variables declared in the storage class must be of a structure type)"); } +TEST_F(ResolverStorageClassValidationTest, NotStorage_AccessMode) { + // var g : a; + Global(Source{{56, 78}}, "g", ty.i32(), ast::StorageClass::kPrivate, + ast::Access::kRead); + + ASSERT_FALSE(r()->Resolve()); + + EXPECT_EQ( + r()->error(), + R"(56:78 error: variables not in storage class must not declare an access mode)"); +} + TEST_F(ResolverStorageClassValidationTest, StorageBufferNoBlockDecoration) { // struct S { x : i32 }; // var g : S;