[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"
|
"type"
|
||||||
"u32"
|
"u32"
|
||||||
"uniform"
|
"uniform"
|
||||||
"uniform_constant"
|
|
||||||
"var"
|
"var"
|
||||||
"vec2"
|
"vec2"
|
||||||
"vec3"
|
"vec3"
|
||||||
|
|
|
@ -673,8 +673,6 @@ Token Lexer::check_keyword(const Source& source, const std::string& str) {
|
||||||
return {Token::Type::kU32, source, "u32"};
|
return {Token::Type::kU32, source, "u32"};
|
||||||
if (str == "uniform")
|
if (str == "uniform")
|
||||||
return {Token::Type::kUniform, source, "uniform"};
|
return {Token::Type::kUniform, source, "uniform"};
|
||||||
if (str == "uniform_constant")
|
|
||||||
return {Token::Type::kUniformConstant, source, "uniform_constant"};
|
|
||||||
if (str == "var")
|
if (str == "var")
|
||||||
return {Token::Type::kVar, source, "var"};
|
return {Token::Type::kVar, source, "var"};
|
||||||
if (str == "vec2")
|
if (str == "vec2")
|
||||||
|
|
|
@ -518,7 +518,6 @@ INSTANTIATE_TEST_SUITE_P(
|
||||||
TokenData{"type", Token::Type::kType},
|
TokenData{"type", Token::Type::kType},
|
||||||
TokenData{"u32", Token::Type::kU32},
|
TokenData{"u32", Token::Type::kU32},
|
||||||
TokenData{"uniform", Token::Type::kUniform},
|
TokenData{"uniform", Token::Type::kUniform},
|
||||||
TokenData{"uniform_constant", Token::Type::kUniformConstant},
|
|
||||||
TokenData{"var", Token::Type::kVar},
|
TokenData{"var", Token::Type::kVar},
|
||||||
TokenData{"vec2", Token::Type::kVec2},
|
TokenData{"vec2", Token::Type::kVec2},
|
||||||
TokenData{"vec3", Token::Type::kVec3},
|
TokenData{"vec3", Token::Type::kVec3},
|
||||||
|
|
|
@ -459,7 +459,12 @@ Maybe<ParserImpl::VarDeclInfo> ParserImpl::variable_decl() {
|
||||||
|
|
||||||
if (decl->type->UnwrapAll()->is_handle()) {
|
if (decl->type->UnwrapAll()->is_handle()) {
|
||||||
// handle types implicitly have the `UniformConstant` storage class.
|
// 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;
|
sc = ast::StorageClass::kUniformConstant;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1049,7 +1054,6 @@ Expect<type::Type*> ParserImpl::expect_type_decl_matrix(Token t) {
|
||||||
// | OUTPUT
|
// | OUTPUT
|
||||||
// | UNIFORM
|
// | UNIFORM
|
||||||
// | WORKGROUP
|
// | WORKGROUP
|
||||||
// | UNIFORM_CONSTANT
|
|
||||||
// | STORAGE
|
// | STORAGE
|
||||||
// | IMAGE
|
// | IMAGE
|
||||||
// | PRIVATE
|
// | PRIVATE
|
||||||
|
@ -1070,9 +1074,6 @@ Expect<ast::StorageClass> ParserImpl::expect_storage_class(
|
||||||
if (match(Token::Type::kWorkgroup))
|
if (match(Token::Type::kWorkgroup))
|
||||||
return {ast::StorageClass::kWorkgroup, source};
|
return {ast::StorageClass::kWorkgroup, source};
|
||||||
|
|
||||||
if (match(Token::Type::kUniformConstant))
|
|
||||||
return {ast::StorageClass::kUniformConstant, source};
|
|
||||||
|
|
||||||
if (match(Token::Type::kStorage))
|
if (match(Token::Type::kStorage))
|
||||||
return {ast::StorageClass::kStorage, source};
|
return {ast::StorageClass::kStorage, source};
|
||||||
|
|
||||||
|
|
|
@ -1110,8 +1110,7 @@ TEST_F(ParserImplErrorTest, GlobalDeclVarVectorMissingType) {
|
||||||
" ^\n");
|
" ^\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ParserImplErrorTest, DISABLED_GlobalDeclSamplerExplicitStorageClass) {
|
TEST_F(ParserImplErrorTest, GlobalDeclSamplerExplicitStorageClass) {
|
||||||
// TODO(jrprice): Enable this once downstream users have caught up.
|
|
||||||
EXPECT(
|
EXPECT(
|
||||||
"var<uniform> x : sampler;",
|
"var<uniform> x : sampler;",
|
||||||
"test.wgsl:1:5 error: sampler variables must not have a storage class\n"
|
"test.wgsl:1:5 error: sampler variables must not have a storage class\n"
|
||||||
|
@ -1119,11 +1118,10 @@ TEST_F(ParserImplErrorTest, DISABLED_GlobalDeclSamplerExplicitStorageClass) {
|
||||||
" ^^^^^^^\n");
|
" ^^^^^^^\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ParserImplErrorTest, DISABLED_GlobalDeclTextureExplicitStorageClass) {
|
TEST_F(ParserImplErrorTest, GlobalDeclTextureExplicitStorageClass) {
|
||||||
// TODO(jrprice): Enable this once downstream users have caught up.
|
EXPECT("var<uniform> x : [[access(read)]] texture_1d<f32>;",
|
||||||
EXPECT(
|
"test.wgsl:1:5 error: texture_1d<f32> variables must not have a "
|
||||||
"var<uniform> x : [[access(read)]] texture_1d<f32>;",
|
"storage class\n"
|
||||||
"test.wgsl:1:5 error: texture variables must not have a storage class\n"
|
|
||||||
"var<uniform> x : [[access(read)]] texture_1d<f32>;\n"
|
"var<uniform> x : [[access(read)]] texture_1d<f32>;\n"
|
||||||
" ^^^^^^^\n");
|
" ^^^^^^^\n");
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,8 +50,6 @@ INSTANTIATE_TEST_SUITE_P(
|
||||||
StorageClassData{"out", ast::StorageClass::kOutput},
|
StorageClassData{"out", ast::StorageClass::kOutput},
|
||||||
StorageClassData{"uniform", ast::StorageClass::kUniform},
|
StorageClassData{"uniform", ast::StorageClass::kUniform},
|
||||||
StorageClassData{"workgroup", ast::StorageClass::kWorkgroup},
|
StorageClassData{"workgroup", ast::StorageClass::kWorkgroup},
|
||||||
StorageClassData{"uniform_constant",
|
|
||||||
ast::StorageClass::kUniformConstant},
|
|
||||||
StorageClassData{"storage", ast::StorageClass::kStorage},
|
StorageClassData{"storage", ast::StorageClass::kStorage},
|
||||||
StorageClassData{"storage_buffer", ast::StorageClass::kStorage},
|
StorageClassData{"storage_buffer", ast::StorageClass::kStorage},
|
||||||
StorageClassData{"image", ast::StorageClass::kImage},
|
StorageClassData{"image", ast::StorageClass::kImage},
|
||||||
|
|
|
@ -52,8 +52,6 @@ INSTANTIATE_TEST_SUITE_P(
|
||||||
VariableStorageData{"out", ast::StorageClass::kOutput},
|
VariableStorageData{"out", ast::StorageClass::kOutput},
|
||||||
VariableStorageData{"uniform", ast::StorageClass::kUniform},
|
VariableStorageData{"uniform", ast::StorageClass::kUniform},
|
||||||
VariableStorageData{"workgroup", ast::StorageClass::kWorkgroup},
|
VariableStorageData{"workgroup", ast::StorageClass::kWorkgroup},
|
||||||
VariableStorageData{"uniform_constant",
|
|
||||||
ast::StorageClass::kUniformConstant},
|
|
||||||
VariableStorageData{"storage", ast::StorageClass::kStorage},
|
VariableStorageData{"storage", ast::StorageClass::kStorage},
|
||||||
VariableStorageData{"storage_buffer", ast::StorageClass::kStorage},
|
VariableStorageData{"storage_buffer", ast::StorageClass::kStorage},
|
||||||
VariableStorageData{"image", ast::StorageClass::kImage},
|
VariableStorageData{"image", ast::StorageClass::kImage},
|
||||||
|
|
|
@ -297,8 +297,6 @@ std::string Token::TypeToName(Type type) {
|
||||||
return "u32";
|
return "u32";
|
||||||
case Token::Type::kUniform:
|
case Token::Type::kUniform:
|
||||||
return "uniform";
|
return "uniform";
|
||||||
case Token::Type::kUniformConstant:
|
|
||||||
return "uniform_constant";
|
|
||||||
case Token::Type::kVar:
|
case Token::Type::kVar:
|
||||||
return "var";
|
return "var";
|
||||||
case Token::Type::kVec2:
|
case Token::Type::kVec2:
|
||||||
|
|
|
@ -305,8 +305,6 @@ class Token {
|
||||||
kU32,
|
kU32,
|
||||||
/// A 'uniform'
|
/// A 'uniform'
|
||||||
kUniform,
|
kUniform,
|
||||||
/// A 'uniform_constant'
|
|
||||||
kUniformConstant,
|
|
||||||
/// A 'var'
|
/// A 'var'
|
||||||
kVar,
|
kVar,
|
||||||
/// A 'vec2'
|
/// A 'vec2'
|
||||||
|
@ -664,8 +662,6 @@ class Token {
|
||||||
bool IsU32() const { return type_ == Type::kU32; }
|
bool IsU32() const { return type_ == Type::kU32; }
|
||||||
/// @returns true if token is a 'uniform'
|
/// @returns true if token is a 'uniform'
|
||||||
bool IsUniform() const { return type_ == Type::kUniform; }
|
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'
|
/// @returns true if token is a 'var'
|
||||||
bool IsVar() const { return type_ == Type::kVar; }
|
bool IsVar() const { return type_ == Type::kVar; }
|
||||||
/// @returns true if token is a 'vec2'
|
/// @returns true if token is a 'vec2'
|
||||||
|
|
Loading…
Reference in New Issue