diff --git a/fuzzers/dictionary.txt b/fuzzers/dictionary.txt index baccbb819d..d1394348a9 100644 --- a/fuzzers/dictionary.txt +++ b/fuzzers/dictionary.txt @@ -101,7 +101,6 @@ "type" "u32" "uniform" -"uniform_constant" "var" "vec2" "vec3" diff --git a/src/reader/wgsl/lexer.cc b/src/reader/wgsl/lexer.cc index 76cc3e9c60..4ce36f0d0f 100644 --- a/src/reader/wgsl/lexer.cc +++ b/src/reader/wgsl/lexer.cc @@ -673,8 +673,6 @@ Token Lexer::check_keyword(const Source& source, const std::string& str) { return {Token::Type::kU32, source, "u32"}; if (str == "uniform") return {Token::Type::kUniform, source, "uniform"}; - if (str == "uniform_constant") - return {Token::Type::kUniformConstant, source, "uniform_constant"}; if (str == "var") return {Token::Type::kVar, source, "var"}; if (str == "vec2") diff --git a/src/reader/wgsl/lexer_test.cc b/src/reader/wgsl/lexer_test.cc index 5d01df1c8a..1d80b29935 100644 --- a/src/reader/wgsl/lexer_test.cc +++ b/src/reader/wgsl/lexer_test.cc @@ -518,7 +518,6 @@ INSTANTIATE_TEST_SUITE_P( TokenData{"type", Token::Type::kType}, TokenData{"u32", Token::Type::kU32}, TokenData{"uniform", Token::Type::kUniform}, - TokenData{"uniform_constant", Token::Type::kUniformConstant}, TokenData{"var", Token::Type::kVar}, TokenData{"vec2", Token::Type::kVec2}, TokenData{"vec3", Token::Type::kVec3}, diff --git a/src/reader/wgsl/parser_impl.cc b/src/reader/wgsl/parser_impl.cc index 6010c47c8e..53036cbb75 100644 --- a/src/reader/wgsl/parser_impl.cc +++ b/src/reader/wgsl/parser_impl.cc @@ -459,7 +459,12 @@ Maybe ParserImpl::variable_decl() { if (decl->type->UnwrapAll()->is_handle()) { // handle types implicitly have the `UniformConstant` storage class. - // TODO(jrprice): Produce an error if an explicit storage class is provided. + if (explicit_sc.matched) { + return add_error( + explicit_sc.source, + decl->type->UnwrapAll()->FriendlyName(builder_.Symbols()) + + " variables must not have a storage class"); + } sc = ast::StorageClass::kUniformConstant; } @@ -1049,7 +1054,6 @@ Expect ParserImpl::expect_type_decl_matrix(Token t) { // | OUTPUT // | UNIFORM // | WORKGROUP -// | UNIFORM_CONSTANT // | STORAGE // | IMAGE // | PRIVATE @@ -1070,9 +1074,6 @@ Expect ParserImpl::expect_storage_class( if (match(Token::Type::kWorkgroup)) return {ast::StorageClass::kWorkgroup, source}; - if (match(Token::Type::kUniformConstant)) - return {ast::StorageClass::kUniformConstant, source}; - if (match(Token::Type::kStorage)) return {ast::StorageClass::kStorage, source}; diff --git a/src/reader/wgsl/parser_impl_error_msg_test.cc b/src/reader/wgsl/parser_impl_error_msg_test.cc index 00cd58f915..4dd48712ca 100644 --- a/src/reader/wgsl/parser_impl_error_msg_test.cc +++ b/src/reader/wgsl/parser_impl_error_msg_test.cc @@ -1110,8 +1110,7 @@ TEST_F(ParserImplErrorTest, GlobalDeclVarVectorMissingType) { " ^\n"); } -TEST_F(ParserImplErrorTest, DISABLED_GlobalDeclSamplerExplicitStorageClass) { - // TODO(jrprice): Enable this once downstream users have caught up. +TEST_F(ParserImplErrorTest, GlobalDeclSamplerExplicitStorageClass) { EXPECT( "var x : sampler;", "test.wgsl:1:5 error: sampler variables must not have a storage class\n" @@ -1119,13 +1118,12 @@ TEST_F(ParserImplErrorTest, DISABLED_GlobalDeclSamplerExplicitStorageClass) { " ^^^^^^^\n"); } -TEST_F(ParserImplErrorTest, DISABLED_GlobalDeclTextureExplicitStorageClass) { - // TODO(jrprice): Enable this once downstream users have caught up. - EXPECT( - "var x : [[access(read)]] texture_1d;", - "test.wgsl:1:5 error: texture variables must not have a storage class\n" - "var x : [[access(read)]] texture_1d;\n" - " ^^^^^^^\n"); +TEST_F(ParserImplErrorTest, GlobalDeclTextureExplicitStorageClass) { + EXPECT("var x : [[access(read)]] texture_1d;", + "test.wgsl:1:5 error: texture_1d variables must not have a " + "storage class\n" + "var x : [[access(read)]] texture_1d;\n" + " ^^^^^^^\n"); } TEST_F(ParserImplErrorTest, IfStmtMissingLParen) { diff --git a/src/reader/wgsl/parser_impl_storage_class_test.cc b/src/reader/wgsl/parser_impl_storage_class_test.cc index 13fce4a333..2f5ad3a4d1 100644 --- a/src/reader/wgsl/parser_impl_storage_class_test.cc +++ b/src/reader/wgsl/parser_impl_storage_class_test.cc @@ -50,8 +50,6 @@ INSTANTIATE_TEST_SUITE_P( StorageClassData{"out", ast::StorageClass::kOutput}, StorageClassData{"uniform", ast::StorageClass::kUniform}, StorageClassData{"workgroup", ast::StorageClass::kWorkgroup}, - StorageClassData{"uniform_constant", - ast::StorageClass::kUniformConstant}, StorageClassData{"storage", ast::StorageClass::kStorage}, StorageClassData{"storage_buffer", ast::StorageClass::kStorage}, StorageClassData{"image", ast::StorageClass::kImage}, diff --git a/src/reader/wgsl/parser_impl_variable_storage_decoration_test.cc b/src/reader/wgsl/parser_impl_variable_storage_decoration_test.cc index a015b332e9..889f631782 100644 --- a/src/reader/wgsl/parser_impl_variable_storage_decoration_test.cc +++ b/src/reader/wgsl/parser_impl_variable_storage_decoration_test.cc @@ -52,8 +52,6 @@ INSTANTIATE_TEST_SUITE_P( VariableStorageData{"out", ast::StorageClass::kOutput}, VariableStorageData{"uniform", ast::StorageClass::kUniform}, VariableStorageData{"workgroup", ast::StorageClass::kWorkgroup}, - VariableStorageData{"uniform_constant", - ast::StorageClass::kUniformConstant}, VariableStorageData{"storage", ast::StorageClass::kStorage}, VariableStorageData{"storage_buffer", ast::StorageClass::kStorage}, VariableStorageData{"image", ast::StorageClass::kImage}, diff --git a/src/reader/wgsl/token.cc b/src/reader/wgsl/token.cc index 9f8b28d5c6..cf28d6e57f 100644 --- a/src/reader/wgsl/token.cc +++ b/src/reader/wgsl/token.cc @@ -297,8 +297,6 @@ std::string Token::TypeToName(Type type) { return "u32"; case Token::Type::kUniform: return "uniform"; - case Token::Type::kUniformConstant: - return "uniform_constant"; case Token::Type::kVar: return "var"; case Token::Type::kVec2: diff --git a/src/reader/wgsl/token.h b/src/reader/wgsl/token.h index 13e582e890..e7de5daf57 100644 --- a/src/reader/wgsl/token.h +++ b/src/reader/wgsl/token.h @@ -305,8 +305,6 @@ class Token { kU32, /// A 'uniform' kUniform, - /// A 'uniform_constant' - kUniformConstant, /// A 'var' kVar, /// A 'vec2' @@ -664,8 +662,6 @@ class Token { bool IsU32() const { return type_ == Type::kU32; } /// @returns true if token is a 'uniform' bool IsUniform() const { return type_ == Type::kUniform; } - /// @returns true if token is a 'uniform_constant' - bool IsUniformConstant() const { return type_ == Type::kUniformConstant; } /// @returns true if token is a 'var' bool IsVar() const { return type_ == Type::kVar; } /// @returns true if token is a 'vec2'