Sync keyword/reserved word list.
This CL updates the keyword/reserved word list in Tint to match latest
spec. The two differences are:
* `bitcast` is left as a keyword until we make the grammar update
* `fallthrough` is left a keyword for error purposes.
Bug: tint:1823
Change-Id: I5a33c78d21f56e0d0e2efa0114af810f2ebb8c87
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/122960
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
diff --git a/src/tint/reader/wgsl/parser_impl.cc b/src/tint/reader/wgsl/parser_impl.cc
index 693e1b3..7649a0b 100644
--- a/src/tint/reader/wgsl/parser_impl.cc
+++ b/src/tint/reader/wgsl/parser_impl.cc
@@ -73,21 +73,19 @@
// https://gpuweb.github.io/gpuweb/wgsl.html#reserved-keywords
bool is_reserved(const Token& t) {
- return t == "CompileShader" || t == "ComputeShader" || t == "DomainShader" ||
- t == "GeometryShader" || t == "Hullshader" || t == "NULL" || t == "Self" ||
- t == "abstract" || t == "active" || t == "alignas" || t == "alignof" || t == "as" ||
- t == "asm" || t == "asm_fragment" || t == "async" || t == "attribute" || t == "auto" ||
- t == "await" || t == "become" || t == "binding_array" || t == "cast" || t == "catch" ||
- t == "class" || t == "co_await" || t == "co_return" || t == "co_yield" ||
- t == "coherent" || t == "column_major" || t == "common" || t == "compile" ||
- t == "compile_fragment" || t == "concept" || t == "const_cast" || t == "consteval" ||
- t == "constexpr" || t == "constinit" || t == "crate" || t == "debugger" ||
- t == "decltype" || t == "delete" || t == "demote" || t == "demote_to_helper" ||
- t == "do" || t == "dynamic_cast" || t == "enum" || t == "explicit" || t == "export" ||
- t == "extends" || t == "extern" || t == "external" || t == "filter" || t == "final" ||
- t == "finally" || t == "friend" || t == "from" || t == "fxgroup" || t == "get" ||
- t == "goto" || t == "groupshared" || t == "handle" || t == "highp" || t == "impl" ||
- t == "implements" || t == "import" || t == "inline" || t == "inout" ||
+ return t == "NULL" || t == "Self" || t == "abstract" || t == "active" || t == "alignas" ||
+ t == "alignof" || t == "as" || t == "asm" || t == "asm_fragment" || t == "async" ||
+ t == "attribute" || t == "auto" || t == "await" || t == "become" ||
+ t == "binding_array" || t == "cast" || t == "catch" || t == "class" || t == "co_await" ||
+ t == "co_return" || t == "co_yield" || t == "coherent" || t == "column_major" ||
+ t == "common" || t == "compile" || t == "compile_fragment" || t == "concept" ||
+ t == "const_cast" || t == "consteval" || t == "constexpr" || t == "constinit" ||
+ t == "crate" || t == "debugger" || t == "decltype" || t == "delete" || t == "demote" ||
+ t == "demote_to_helper" || t == "do" || t == "dynamic_cast" || t == "enum" ||
+ t == "explicit" || t == "export" || t == "extends" || t == "extern" || t == "external" ||
+ t == "filter" || t == "final" || t == "finally" || t == "friend" || t == "from" ||
+ t == "fxgroup" || t == "get" || t == "goto" || t == "groupshared" || t == "highp" ||
+ t == "impl" || t == "implements" || t == "import" || t == "inline" ||
t == "instanceof" || t == "interface" || t == "layout" || t == "lowp" || t == "macro" ||
t == "macro_rules" || t == "match" || t == "mediump" || t == "meta" || t == "mod" ||
t == "module" || t == "move" || t == "mut" || t == "mutable" || t == "namespace" ||
@@ -97,8 +95,8 @@
t == "partition" || t == "pass" || t == "patch" || t == "pixelfragment" ||
t == "precise" || t == "precision" || t == "premerge" || t == "priv" ||
t == "protected" || t == "pub" || t == "public" || t == "readonly" || t == "ref" ||
- t == "regardless" || t == "register" || t == "reinterpret_cast" || t == "resource" ||
- t == "restrict" || t == "self" || t == "set" || t == "shared" || t == "signed" ||
+ t == "regardless" || t == "register" || t == "reinterpret_cast" || t == "require" ||
+ t == "resource" || t == "restrict" || t == "self" || t == "set" || t == "shared" ||
t == "sizeof" || t == "smooth" || t == "snorm" || t == "static" ||
t == "static_assert" || t == "static_cast" || t == "std" || t == "subroutine" ||
t == "super" || t == "target" || t == "template" || t == "this" || t == "thread_local" ||
diff --git a/src/tint/reader/wgsl/parser_impl_reserved_keyword_test.cc b/src/tint/reader/wgsl/parser_impl_reserved_keyword_test.cc
index 647bb44..50f43ea 100644
--- a/src/tint/reader/wgsl/parser_impl_reserved_keyword_test.cc
+++ b/src/tint/reader/wgsl/parser_impl_reserved_keyword_test.cc
@@ -85,11 +85,7 @@
}
INSTANTIATE_TEST_SUITE_P(ParserImplReservedKeywordTest,
ParserImplReservedKeywordTest,
- testing::Values("ComputeShader",
- "DomainShader",
- "GeometryShader",
- "Hullshader",
- "NULL",
+ testing::Values("NULL",
"Self",
"abstract",
"active",
@@ -143,13 +139,11 @@
"get",
"goto",
"groupshared",
- "handle",
"highp",
"impl",
"implements",
"import",
"inline",
- "inout",
"instanceof",
"interface",
"layout",
@@ -198,7 +192,6 @@
"self",
"set",
"shared",
- "signed",
"sizeof",
"smooth",
"snorm",
diff --git a/src/tint/reader/wgsl/token.h b/src/tint/reader/wgsl/token.h
index 43f6831..19bdd40 100644
--- a/src/tint/reader/wgsl/token.h
+++ b/src/tint/reader/wgsl/token.h
@@ -165,17 +165,19 @@
kContinue,
/// A 'continuing'
kContinuing,
+ /// A 'default'
+ kDefault,
/// A 'diagnostic'
kDiagnostic,
/// A 'discard'
kDiscard,
- /// A 'default'
- kDefault,
/// A 'else'
kElse,
/// A 'enable'
kEnable,
/// A 'fallthrough'
+ // Note, this isn't a keyword, but a reserved word. We match it as a keyword in order to
+ // provide better diagnostics in case a `fallthrough` is added to a case body.
kFallthrough,
/// A 'false'
kFalse,
@@ -191,10 +193,10 @@
kLoop,
/// A 'override'
kOverride,
- /// A 'return'
- kReturn,
/// A 'requires'
kRequires,
+ /// A 'return'
+ kReturn,
/// A 'struct'
kStruct,
/// A 'switch'