[wgsl-reader] Disallow explicit storage classes on handle types
Downstream users have all caught up to the change. Remove the "uniform_constant" token from the WGSL parser. Fixed: tint:332 Change-Id: I046f93d5e6c26b89d419763e73b1ca583250570f Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/45462 Auto-Submit: James Price <jrprice@google.com> Kokoro: Kokoro <noreply+kokoro@google.com> Reviewed-by: Ben Clayton <bclayton@google.com> Commit-Queue: Ben Clayton <bclayton@google.com>
This commit is contained in:
parent
eae161cd9f
commit
b225851eef
|
@ -101,7 +101,6 @@
|
|||
"type"
|
||||
"u32"
|
||||
"uniform"
|
||||
"uniform_constant"
|
||||
"var"
|
||||
"vec2"
|
||||
"vec3"
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -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},
|
||||
|
|
|
@ -459,7 +459,12 @@ Maybe<ParserImpl::VarDeclInfo> 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<type::Type*> ParserImpl::expect_type_decl_matrix(Token t) {
|
|||
// | OUTPUT
|
||||
// | UNIFORM
|
||||
// | WORKGROUP
|
||||
// | UNIFORM_CONSTANT
|
||||
// | STORAGE
|
||||
// | IMAGE
|
||||
// | PRIVATE
|
||||
|
@ -1070,9 +1074,6 @@ Expect<ast::StorageClass> 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};
|
||||
|
||||
|
|
|
@ -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<uniform> 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<uniform> x : [[access(read)]] texture_1d<f32>;",
|
||||
"test.wgsl:1:5 error: texture variables must not have a storage class\n"
|
||||
"var<uniform> x : [[access(read)]] texture_1d<f32>;\n"
|
||||
" ^^^^^^^\n");
|
||||
TEST_F(ParserImplErrorTest, GlobalDeclTextureExplicitStorageClass) {
|
||||
EXPECT("var<uniform> x : [[access(read)]] texture_1d<f32>;",
|
||||
"test.wgsl:1:5 error: texture_1d<f32> variables must not have a "
|
||||
"storage class\n"
|
||||
"var<uniform> x : [[access(read)]] texture_1d<f32>;\n"
|
||||
" ^^^^^^^\n");
|
||||
}
|
||||
|
||||
TEST_F(ParserImplErrorTest, IfStmtMissingLParen) {
|
||||
|
|
|
@ -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},
|
||||
|
|
|
@ -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},
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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'
|
||||
|
|
Loading…
Reference in New Issue