Sync reserved token list to WGSL spec.

This CL updates the list of reserved words to match the WGSL spec. The
use of a reserved word is changed from an error to a deprecation at the
moment be cause the majority of the list would be new errors.

Bug: tint:1633 tint:1624
Change-Id: I498db41689cdd666dfb291b1a6761a1182c87ec8
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/98042
Reviewed-by: David Neto <dneto@google.com>
Reviewed-by: Ben Clayton <bclayton@chromium.org>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
This commit is contained in:
dan sinclair 2022-08-03 02:49:28 +00:00 committed by Dawn LUCI CQ
parent cc5dc15304
commit 6f8d945dd6
56 changed files with 612 additions and 445 deletions

View File

@ -1195,9 +1195,6 @@ Token Lexer::check_keyword(const Source& source, std::string_view str) {
if (str == "if") {
return {Token::Type::kIf, source, "if"};
}
if (str == "import") {
return {Token::Type::kImport, source, "import"};
}
if (str == "let") {
return {Token::Type::kLet, source, "let"};
}

View File

@ -1129,7 +1129,6 @@ INSTANTIATE_TEST_SUITE_P(
TokenData{"for", Token::Type::kFor},
TokenData{"i32", Token::Type::kI32},
TokenData{"if", Token::Type::kIf},
TokenData{"import", Token::Type::kImport},
TokenData{"let", Token::Type::kLet},
TokenData{"loop", Token::Type::kLoop},
TokenData{"mat2x2", Token::Type::kMat2x2},

View File

@ -84,10 +84,40 @@ const char kWorkgroupSizeAttribute[] = "workgroup_size";
// https://gpuweb.github.io/gpuweb/wgsl.html#reserved-keywords
bool is_reserved(const Token& t) {
return t == "asm" || t == "bf16" || t == "do" || t == "enum" || t == "f64" || t == "handle" ||
t == "i8" || t == "i16" || t == "i64" || t == "mat" || t == "premerge" ||
t == "regardless" || t == "typedef" || t == "u8" || t == "u16" || t == "u64" ||
t == "unless" || t == "using" || t == "vec" || t == "void" || t == "while";
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" ||
t == "instanceof" || t == "interface" || t == "invariant" || t == "layout" ||
t == "line" || t == "lineadj" || 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" || t == "new" ||
t == "nil" || t == "noexcept" || t == "noinline" || t == "nointerpolation" ||
t == "noperspective" || t == "null" || t == "nullptr" || t == "of" || t == "operator" ||
t == "package" || t == "packoffset" || t == "partition" || t == "pass" || t == "patch" ||
t == "pixelfragment" || t == "point" || 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 == "requires" || t == "resource" || t == "restrict" ||
t == "self" || t == "set" || t == "shared" || t == "signed" || 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" || t == "throw" || t == "trait" ||
t == "try" || t == "typedef" || t == "typeid" || t == "typename" || t == "typeof" ||
t == "union" || t == "unless" || t == "unorm" || t == "unsafe" || t == "unsized" ||
t == "use" || t == "using" || t == "varying" || t == "virtual" || t == "volatile" ||
t == "wgsl" || t == "where" || t == "with" || t == "writeonly" || t == "yield";
}
/// Enter-exit counters for block token types.
@ -3441,7 +3471,7 @@ Expect<std::string> ParserImpl::expect_ident(std::string_view use) {
next();
if (is_reserved(t)) {
return add_error(t.source(), "'" + t.to_str() + "' is a reserved keyword");
deprecated(t.source(), "'" + t.to_str() + "' is a reserved keyword");
}
return {t.to_str(), t.source()};

View File

@ -21,88 +21,233 @@ using ParserImplReservedKeywordTest = ParserImplTestWithParam<std::string>;
TEST_P(ParserImplReservedKeywordTest, Function) {
auto name = GetParam();
auto p = parser("fn " + name + "() {}");
EXPECT_FALSE(p->Parse());
EXPECT_TRUE(p->has_error());
EXPECT_EQ(p->error(), "1:4: '" + name + "' is a reserved keyword");
EXPECT_TRUE(p->Parse());
EXPECT_FALSE(p->has_error());
EXPECT_EQ(p->error(),
"1:4: use of deprecated language feature: '" + name + "' is a reserved keyword");
}
TEST_P(ParserImplReservedKeywordTest, ModuleConst) {
auto name = GetParam();
auto p = parser("const " + name + " : i32 = 1;");
EXPECT_FALSE(p->Parse());
EXPECT_TRUE(p->has_error());
EXPECT_EQ(p->error(), "1:7: '" + name + "' is a reserved keyword");
EXPECT_TRUE(p->Parse());
EXPECT_FALSE(p->has_error());
EXPECT_EQ(p->error(),
"1:7: use of deprecated language feature: '" + name + "' is a reserved keyword");
}
TEST_P(ParserImplReservedKeywordTest, ModuleVar) {
auto name = GetParam();
auto p = parser("var " + name + " : i32 = 1;");
EXPECT_FALSE(p->Parse());
EXPECT_TRUE(p->has_error());
EXPECT_EQ(p->error(), "1:5: '" + name + "' is a reserved keyword");
EXPECT_TRUE(p->Parse());
EXPECT_FALSE(p->has_error());
EXPECT_EQ(p->error(),
"1:5: use of deprecated language feature: '" + name + "' is a reserved keyword");
}
TEST_P(ParserImplReservedKeywordTest, FunctionLet) {
auto name = GetParam();
auto p = parser("fn f() { let " + name + " : i32 = 1; }");
EXPECT_FALSE(p->Parse());
EXPECT_TRUE(p->has_error());
EXPECT_EQ(p->error(), "1:14: '" + name + "' is a reserved keyword");
EXPECT_TRUE(p->Parse());
EXPECT_FALSE(p->has_error());
EXPECT_EQ(p->error(),
"1:14: use of deprecated language feature: '" + name + "' is a reserved keyword");
}
TEST_P(ParserImplReservedKeywordTest, FunctionVar) {
auto name = GetParam();
auto p = parser("fn f() { var " + name + " : i32 = 1; }");
EXPECT_FALSE(p->Parse());
EXPECT_TRUE(p->has_error());
EXPECT_EQ(p->error(), "1:14: '" + name + "' is a reserved keyword");
EXPECT_TRUE(p->Parse());
EXPECT_FALSE(p->has_error());
EXPECT_EQ(p->error(),
"1:14: use of deprecated language feature: '" + name + "' is a reserved keyword");
}
TEST_P(ParserImplReservedKeywordTest, FunctionParam) {
auto name = GetParam();
auto p = parser("fn f(" + name + " : i32) {}");
EXPECT_FALSE(p->Parse());
EXPECT_TRUE(p->has_error());
EXPECT_EQ(p->error(), "1:6: '" + name + "' is a reserved keyword");
EXPECT_TRUE(p->Parse());
EXPECT_FALSE(p->has_error());
EXPECT_EQ(p->error(),
"1:6: use of deprecated language feature: '" + name + "' is a reserved keyword");
}
TEST_P(ParserImplReservedKeywordTest, Struct) {
auto name = GetParam();
auto p = parser("struct " + name + " {};");
EXPECT_FALSE(p->Parse());
EXPECT_TRUE(p->has_error());
EXPECT_EQ(p->error(), "1:8: '" + name + "' is a reserved keyword");
EXPECT_TRUE(p->Parse());
EXPECT_FALSE(p->has_error());
EXPECT_EQ(p->error(),
"1:8: use of deprecated language feature: '" + name + "' is a reserved keyword");
}
TEST_P(ParserImplReservedKeywordTest, StructMember) {
auto name = GetParam();
auto p = parser("struct S { " + name + " : i32, };");
EXPECT_FALSE(p->Parse());
EXPECT_TRUE(p->has_error());
EXPECT_EQ(p->error(), "1:12: '" + name + "' is a reserved keyword");
EXPECT_TRUE(p->Parse());
EXPECT_FALSE(p->has_error());
EXPECT_EQ(p->error(),
"1:12: use of deprecated language feature: '" + name + "' is a reserved keyword");
}
TEST_P(ParserImplReservedKeywordTest, Alias) {
auto name = GetParam();
auto p = parser("type " + name + " = i32;");
EXPECT_FALSE(p->Parse());
EXPECT_TRUE(p->has_error());
EXPECT_EQ(p->error(), "1:6: '" + name + "' is a reserved keyword");
EXPECT_TRUE(p->Parse());
EXPECT_FALSE(p->has_error());
EXPECT_EQ(p->error(),
"1:6: use of deprecated language feature: '" + name + "' is a reserved keyword");
}
INSTANTIATE_TEST_SUITE_P(ParserImplReservedKeywordTest,
ParserImplReservedKeywordTest,
testing::Values("asm",
"bf16",
testing::Values("ComputeShader",
"DomainShader",
"GeometryShader",
"Hullshader",
"NULL",
"Self",
"abstract",
"active",
"alignas",
"alignof",
"as",
"asm",
"asm_fragment",
"async",
"attribute",
"auto",
"await",
"become",
"binding_array",
"cast",
"catch",
"class",
"co_await",
"co_return",
"co_yield",
"coherent",
"column_major",
"common",
"compile",
"compile_fragment",
"concept",
"const_cast",
"consteval",
"constexpr",
"constinit",
"crate",
"debugger",
"decltype",
"delete",
"demote",
"demote_to_helper",
"do",
"dynamic_cast",
"enum",
"f64",
"explicit",
"export",
"extends",
"extern",
"external",
"filter",
"final",
"finally",
"friend",
"from",
"fxgroup",
"get",
"goto",
"groupshared",
"handle",
"i8",
"i16",
"i64",
"mat",
"highp",
"impl",
"implements",
"import",
"inline",
"inout",
"instanceof",
"interface",
"invariant",
"layout",
"line",
"lineadj",
"lowp",
"macro",
"macro_rules",
"match",
"mediump",
"meta",
"mod",
"module",
"move",
"mut",
"mutable",
"namespace",
"new",
"nil",
"noexcept",
"noinline",
"nointerpolation",
"noperspective",
"null",
"nullptr",
"of",
"operator",
"package",
"packoffset",
"partition",
"pass",
"patch",
"pixelfragment",
"point",
"precise",
"precision",
"premerge",
"priv",
"protected",
"pub",
"public",
"readonly",
"ref",
"regardless",
"register",
"reinterpret_cast",
"requires",
"resource",
"restrict",
"self",
"set",
"shared",
"signed",
"sizeof",
"smooth",
"snorm",
"static",
"static_assert",
"static_cast",
"std",
"subroutine",
"super",
"target",
"template",
"this",
"thread_local",
"throw",
"trait",
"try",
"typedef",
"u8",
"u16",
"u64",
"typeid",
"typename",
"typeof",
"union",
"unless",
"unorm",
"unsafe",
"unsized",
"use",
"using",
"vec",
"void"));
"varying",
"virtual",
"volatile",
"wgsl",
"where",
"with",
"writeonly",
"yield"
));
} // namespace
} // namespace tint::reader::wgsl

View File

@ -177,8 +177,6 @@ std::string_view Token::TypeToName(Type type) {
return "i32";
case Token::Type::kIf:
return "if";
case Token::Type::kImport:
return "import";
case Token::Type::kLet:
return "let";
case Token::Type::kLoop:

View File

@ -187,8 +187,6 @@ class Token {
kI32,
/// A 'if'
kIf,
/// A 'import'
kImport,
/// A 'let'
kLet,
/// A 'loop'

View File

@ -328,10 +328,10 @@ fn frag_main() {
INSTANTIATE_TEST_SUITE_P(RenamerTestGlsl,
RenamerTestGlsl,
testing::Values("active",
testing::Values( // "active", // Also reserved in WGSL
// "asm", // WGSL keyword
"atomic_uint",
"attribute",
// "attribute", // Also reserved in WGSL
// "bool", // WGSL keyword
// "break", // WGSL keyword
"buffer",
@ -339,11 +339,11 @@ INSTANTIATE_TEST_SUITE_P(RenamerTestGlsl,
"bvec3",
"bvec4",
// "case", // WGSL keyword
"cast",
// "cast", // Also reserved in WGSL
"centroid",
"class",
"coherent",
"common",
// "class", // Also reserved in WGSL
// "coherent", // Also reserved in WGSL
// "common", // Also reserved in WGSL
// "const", // WGSL keyword
// "continue", // WGSL keyword
// "default", // WGSL keyword
@ -367,10 +367,10 @@ INSTANTIATE_TEST_SUITE_P(RenamerTestGlsl,
"dvec4",
// "else" // WGSL keyword
// "enum", // WGSL keyword
"extern",
"external",
// "extern", // Also reserved in WGSL
// "external", // Also reserved in WGSL
// "false", // WGSL keyword
"filter",
// "filter", // Also reserved in WGSL
"fixed",
"flat",
"float",
@ -404,9 +404,9 @@ INSTANTIATE_TEST_SUITE_P(RenamerTestGlsl,
"gl_VertexID",
"gl_WorkGroupID",
"gl_WorkGroupSize",
"goto",
// "goto", // Also reserved in WGSL
"half",
"highp",
// "highp", // Also reserved in WGSL
"hvec2",
"hvec3",
"hvec4",
@ -434,12 +434,12 @@ INSTANTIATE_TEST_SUITE_P(RenamerTestGlsl,
"imageCube",
"imageCubeArray",
"in",
"inline",
"inout",
// "inline", // Also reserved in WGSL
// "inout", // Also reserved in WGSL
"input",
"int",
"interface",
"invariant",
// "interface", // Also reserved in WGSL
// "invariant", // Also reserved in WGSL
"isampler1D",
"isampler1DArray",
"isampler2D",
@ -454,9 +454,9 @@ INSTANTIATE_TEST_SUITE_P(RenamerTestGlsl,
"ivec2",
"ivec3",
"ivec4",
"layout",
// "layout", // Also reserved in WGSL
"long",
"lowp",
// "lowp", // Also reserved in WGSL
// "mat2x2", // WGSL keyword
// "mat2x3", // WGSL keyword
// "mat2x4", // WGSL keyword
@ -469,20 +469,20 @@ INSTANTIATE_TEST_SUITE_P(RenamerTestGlsl,
// "mat4x2", // WGSL keyword
// "mat4x3", // WGSL keyword
// "mat4x4", // WGSL keyword
"mediump",
"namespace",
"noinline",
"noperspective",
// "mediump", // Also reserved in WGSL
// "namespace", // Also reserved in WGSL
// "noinline", // Also reserved in WGSL
// "noperspective", // Also reserved in WGSL
"out",
"output",
"partition",
"patch",
"precise",
"precision",
"public",
"readonly",
"resource",
"restrict",
// "partition", // Also reserved in WGSL
// "patch", // Also reserved in WGSL
// "precise", // Also reserved in WGSL
// "precision", // Also reserved in WGSL
// "public", // Also reserved in WGSL
// "readonly", // Also reserved in WGSL
// "resource", // Also reserved in WGSL
// "restrict", // Also reserved in WGSL
// "return", // WGSL keyword
"sample",
"sampler1D",
@ -504,17 +504,17 @@ INSTANTIATE_TEST_SUITE_P(RenamerTestGlsl,
"samplerCubeArray",
"samplerCubeArrayShadow",
"samplerCubeShadow",
"shared",
// "shared" // Also reserved in WGSL,
"short",
"sizeof",
"smooth",
"static",
// "sizeof", // Also reserved in WGSL
// "smooth", // Also reserved in WGSL
// "static", // Also reserved in WGSL
// "struct", // WGSL keyword
"subroutine",
// "subroutine", // Also reserved in WGSL
"superp",
// "switch", // WGSL keyword
"template",
"this",
// "template", // Also reserved in WGSL
// "this", // Also reserved in WGSL
// "true", // WGSL keyword
// "typedef", // WGSL keyword
"uimage1D",
@ -530,7 +530,7 @@ INSTANTIATE_TEST_SUITE_P(RenamerTestGlsl,
"uimageCubeArray",
"uint",
// "uniform", // WGSL keyword
"union",
// "union", // Also reserved in WGSL
"unsigned",
"usampler1D",
"usampler1DArray",
@ -547,14 +547,14 @@ INSTANTIATE_TEST_SUITE_P(RenamerTestGlsl,
"uvec2",
"uvec3",
"uvec4",
"varying",
// "varying", // Also reserved in WGSL
// "vec2", // WGSL keyword
// "vec3", // WGSL keyword
// "vec4", // WGSL keyword
// "void", // WGSL keyword
"volatile",
// "volatile", // Also reserved in WGSL
// "while", // WGSL keyword
"writeonly",
// "writeonly", // Also reserved in WGSL
kUnicodeIdentifier));
INSTANTIATE_TEST_SUITE_P(RenamerTestHlsl,
@ -575,8 +575,8 @@ INSTANTIATE_TEST_SUITE_P(RenamerTestHlsl,
"COLOR",
"CheckAccessFullyMapped",
"ComparisonFunc",
"CompileShader",
"ComputeShader",
// "CompileShader", // Also reserved in WGSL
// "ComputeShader", // Also reserved in WGSL
"ConsumeStructuredBuffer",
"D3DCOLORtoUBYTE4",
"DEPTH",
@ -584,18 +584,18 @@ INSTANTIATE_TEST_SUITE_P(RenamerTestHlsl,
"DepthStencilView",
"DeviceMemoryBarrier",
"DeviceMemroyBarrierWithGroupSync",
"DomainShader",
// "DomainShader", // Also reserved in WGSL
"EvaluateAttributeAtCentroid",
"EvaluateAttributeAtSample",
"EvaluateAttributeSnapped",
"FOG",
"Filter",
"GeometryShader",
// "GeometryShader", // Also reserved in WGSL
"GetRenderTargetSampleCount",
"GetRenderTargetSamplePosition",
"GroupMemoryBarrier",
"GroupMemroyBarrierWithGroupSync",
"Hullshader",
// "Hullshader", // Also reserved in WGSL
"InputPatch",
"InterlockedAdd",
"InterlockedAnd",
@ -612,7 +612,7 @@ INSTANTIATE_TEST_SUITE_P(RenamerTestHlsl,
"MinLOD",
"MipLODBias",
"NORMAL",
"NULL",
// "NULL", // Also reserved in WGSL
"Normal",
"OutputPatch",
"POSITION",
@ -703,11 +703,11 @@ INSTANTIATE_TEST_SUITE_P(RenamerTestHlsl,
// "asin", // WGSL builtin
"asint",
// "asm", // WGSL keyword
"asm_fragment",
// "asm_fragment", // Also reserved in WGSL
"asuint",
// "atan", // WGSL builtin
// "atan2", // WGSL builtin
"auto",
// "auto", // Also reserved in WGSL
// "bool", // WGSL keyword
"bool1",
"bool1x1",
@ -733,19 +733,19 @@ INSTANTIATE_TEST_SUITE_P(RenamerTestHlsl,
// "break", // WGSL keyword
// "call", // WGSL builtin
// "case", // WGSL keyword
"catch",
// "catch", // Also reserved in WGSL
"cbuffer",
// "ceil", // WGSL builtin
"centroid",
"char",
// "clamp", // WGSL builtin
"class",
// "class", // Also reserved in WGSL
"clip",
"column_major",
"compile",
"compile_fragment",
// "column_major", // Also reserved in WGSL
// "compile", // Also reserved in WGSL
// "compile_fragment", // Also reserved in WGSL
// "const", // WGSL keyword
"const_cast",
// "const_cast", // Also reserved in WGSL
// "continue", // WGSL keyword
// "cos", // WGSL builtin
// "cosh", // WGSL builtin
@ -759,7 +759,7 @@ INSTANTIATE_TEST_SUITE_P(RenamerTestHlsl,
"ddy_fine",
// "default", // WGSL keyword
"degrees",
"delete",
// "delete", // Also reserved in WGSL
// "determinant", // WGSL builtin
// "discard", // WGSL keyword
// "distance", // WGSL builtin
@ -808,15 +808,15 @@ INSTANTIATE_TEST_SUITE_P(RenamerTestHlsl,
"dword4x2",
"dword4x3",
"dword4x4",
"dynamic_cast",
// "dynamic_cast", // Also reserved in WGSL
// "else", // WGSL keyword
// "enum", // WGSL keyword
"errorf",
// "exp", // WGSL builtin
// "exp2", // WGSL builtin
"explicit",
"export",
"extern",
// "explicit", // Also reserved in WGSL
// "export", // Also reserved in WGSL
// "extern", // Also reserved in WGSL
"f16to32",
"f32tof16",
// "faceforward", // WGSL builtin
@ -853,11 +853,11 @@ INSTANTIATE_TEST_SUITE_P(RenamerTestHlsl,
"forcecase",
"frac",
// "frexp", // WGSL builtin
"friend",
// "friend", // Also reserved in WGSL
// "fwidth", // WGSL builtin
"fxgroup",
"goto",
"groupshared",
// "fxgroup", // Also reserved in WGSL
// "goto", // Also reserved in WGSL
// "groupshared", // Also reserved in WGSL
"half",
"half1",
"half1x1",
@ -881,8 +881,8 @@ INSTANTIATE_TEST_SUITE_P(RenamerTestHlsl,
"half4x4",
// "if", // WGSL keyword
// "in", // WGSL keyword
"inline",
"inout",
// "inline", // Also reserved in WGSL
// "inout", // Also reserved in WGSL
"int",
"int1",
"int1x1",
@ -904,15 +904,15 @@ INSTANTIATE_TEST_SUITE_P(RenamerTestHlsl,
"int4x2",
"int4x3",
"int4x4",
"interface",
// "interface", // Also reserved in WGSL
"isfinite",
"isinf",
"isnan",
// "ldexp", // WGSL builtin
// "length", // WGSL builtin
"lerp",
"line",
"lineadj",
// "line", // Also reserved in WGSL
// "lineadj", // Also reserved in WGSL
"linear",
"lit",
// "log", // WGSL builtin
@ -1032,33 +1032,33 @@ INSTANTIATE_TEST_SUITE_P(RenamerTestHlsl,
// "modf", // WGSL builtin
"msad4",
"mul",
"mutable",
"namespace",
"new",
"nointerpolation",
// "mutable", // Also reserved in WGSL
// "namespace", // Also reserved in WGSL
// "new", // Also reserved in WGSL
// "nointerpolation", // Also reserved in WGSL
"noise",
"noperspective",
// "noperspective", // Also reserved in WGSL
// "normalize", // WGSL builtin
"numthreads",
"operator",
// "operator", // Also reserved in WGSL
// "out", // WGSL keyword
"packoffset",
"pass",
"pixelfragment",
// "packoffset", // Also reserved in WGSL
// "pass", // Also reserved in WGSL
// "pixelfragment", // Also reserved in WGSL
"pixelshader",
"point",
// "point", // Also reserved in WGSL
// "pow", // WGSL builtin
"precise",
// "precise", // Also reserved in WGSL
"printf",
// "private", // WGSL keyword
"protected",
"public",
// "protected", // Also reserved in WGSL
// "public", // Also reserved in WGSL
"radians",
"rcp",
// "reflect", // WGSL builtin
"refract",
"register",
"reinterpret_cast",
// "register", // Also reserved in WGSL
// "reinterpret_cast", // Also reserved in WGSL
// "return", // WGSL keyword
// "reversebits", // WGSL builtin
// "round", // WGSL builtin
@ -1071,21 +1071,21 @@ INSTANTIATE_TEST_SUITE_P(RenamerTestHlsl,
"samplerCUBE",
"sampler_state",
"saturate",
"shared",
// "shared", // Also reserved in WGSL
"short",
// "sign", // WGSL builtin
"signed",
// "signed", // Also reserved in WGSL
// "sin", // WGSL builtin
"sincos",
// "sinh", // WGSL builtin
"sizeof",
// "sizeof", // Also reserved in WGSL
// "smoothstep", // WGSL builtin
"snorm",
// "snorm", // Also reserved in WGSL
// "sqrt", // WGSL builtin
"stateblock",
"stateblock_state",
"static",
"static_cast",
// "static", // Also reserved in WGSL
// "static_cast", // Also reserved in WGSL
// "step", // WGSL builtin
"string",
// "struct", // WGSL keyword
@ -1096,7 +1096,7 @@ INSTANTIATE_TEST_SUITE_P(RenamerTestHlsl,
"technique",
"technique10",
"technique11",
"template",
// "template", // Also reserved in WGSL
"tex1D",
"tex1Dbias",
"tex1Dgrad",
@ -1127,16 +1127,16 @@ INSTANTIATE_TEST_SUITE_P(RenamerTestHlsl,
"texture3D",
"textureCube",
"textureCubeArray",
"this",
"throw",
// "this", // Also reserved in WGSL
// "throw", // Also reserved in WGSL
"transpose",
"triangle",
"triangleadj",
// "true", // WGSL keyword
// "trunc", // WGSL builtin
"try",
// "try", // Also reserved in WGSL
// "typedef", // WGSL keyword
"typename",
// "typename", // Also reserved in WGSL
"uint",
"uint1",
"uint1x1",
@ -1159,17 +1159,17 @@ INSTANTIATE_TEST_SUITE_P(RenamerTestHlsl,
"uint4x3",
"uint4x4",
// "uniform", // WGSL keyword
"union",
"unorm",
// "union", // Also reserved in WGSL
// "unorm", // Also reserved in WGSL
"unroll",
"unsigned",
// "using", // WGSL reserved keyword
"vector",
"vertexfragment",
"vertexshader",
"virtual",
// "virtual", // Also reserved in WGSL
// "void", // WGSL keyword
"volatile",
// "volatile", // Also reserved in WGSL
// "while" // WGSL reserved keyword
kUnicodeIdentifier));
@ -1178,87 +1178,87 @@ INSTANTIATE_TEST_SUITE_P(
RenamerTestMsl,
testing::Values(
// c++14 spec
"alignas",
"alignof",
// "alignas", // Also reserved in WGSL
// "alignof", // Also reserved in WGSL
"and",
"and_eq",
// "asm", // Also reserved in WGSL
"auto",
// "auto", // Also reserved in WGSL
"bitand",
"bitor",
// "bool", // Also used in WGSL
// "break", // Also used in WGSL
// "case", // Also used in WGSL
"catch",
// "catch", // Also reserved in WGSL
"char",
"char16_t",
"char32_t",
"class",
// "class", // Also reserved in WGSL
"compl",
// "const", // Also used in WGSL
"const_cast",
"constexpr",
// "const_cast", // Also reserved in WGSL
// "constexpr", // Also reserved in WGSL
// "continue", // Also used in WGSL
"decltype",
// "decltype", // Also reserved in WGSL
// "default", // Also used in WGSL
"delete",
// "delete", // Also reserved in WGSL
// "do", // Also used in WGSL
"double",
"dynamic_cast",
// "dynamic_cast", // Also reserved in WGSL
// "else", // Also used in WGSL
// "enum", // Also used in WGSL
"explicit",
"extern",
// "explicit", // Also reserved in WGSL
// "extern", // Also reserved in WGSL
// "false", // Also used in WGSL
"final",
// "final", // Also reserved in WGSL
"float",
// "for", // Also used in WGSL
"friend",
"goto",
// "friend", // Also reserved in WGSL
// "goto", // Also reserved in WGSL
// "if", // Also used in WGSL
"inline",
// "inline", // Also reserved in WGSL
"int",
"long",
"mutable",
"namespace",
"new",
"noexcept",
// "mutable", // Also reserved in WGSL
// "namespace", // Also reserved in WGSL
// "new", // Also reserved in WGSL
// "noexcept", // Also reserved in WGSL
"not",
"not_eq",
"nullptr",
"operator",
// "nullptr", // Also reserved in WGSL
// "operator", // Also reserved in WGSL
"or",
"or_eq",
// "override", // Also used in WGSL
// "private", // Also used in WGSL
"protected",
"public",
"register",
"reinterpret_cast",
// "protected", // Also reserved in WGSL
// "public", // Also reserved in WGSL
// "register", // Also reserved in WGSL
// "reinterpret_cast", // Also reserved in WGSL
// "return", // Also used in WGSL
"short",
"signed",
"sizeof",
"static",
"static_assert",
"static_cast",
// "signed", // Also reserved in WGSL
// "sizeof", // Also reserved in WGSL
// "static", // Also reserved in WGSL
// "static_assert", // Also reserved in WGSL
// "static_cast", // Also reserved in WGSL
// "struct", // Also used in WGSL
// "switch", // Also used in WGSL
"template",
"this",
"thread_local",
"throw",
// "template", // Also reserved in WGSL
// "this", // Also reserved in WGSL
// "thread_local", // Also reserved in WGSL
// "throw", // Also reserved in WGSL
// "true", // Also used in WGSL
"try",
// "try", // Also reserved in WGSL
// "typedef", // Also used in WGSL
"typeid",
"typename",
"union",
// "typeid", // Also reserved in WGSL
// "typename", // Also reserved in WGSL
// "union", // Also reserved in WGSL
"unsigned",
// "using", // WGSL reserved keyword
"virtual",
// "virtual", // Also reserved in WGSL
// "void", // Also used in WGSL
"volatile",
// "volatile", // Also reserved in WGSL
"wchar_t",
// "while", // WGSL reserved keyword
"xor",

View File

@ -2,7 +2,7 @@ type ArrayExplicitStride = array<i32, 2>;
type ArrayImplicitStride = array<i32, 2>;
fn foo() {
var explicit : ArrayExplicitStride;
var implict : ArrayImplicitStride;
implict = explicit;
var explicitStride : ArrayExplicitStride;
var implictStride : ArrayImplicitStride;
implictStride = explicitStride;
}

View File

@ -4,7 +4,7 @@ void unused_entry_point() {
}
void foo() {
int tint_symbol[2] = (int[2])0;
int implict[2] = (int[2])0;
implict = tint_symbol;
int explicitStride[2] = (int[2])0;
int implictStride[2] = (int[2])0;
implictStride = explicitStride;
}

View File

@ -4,7 +4,7 @@ void unused_entry_point() {
}
void foo() {
int tint_symbol[2] = (int[2])0;
int implict[2] = (int[2])0;
implict = tint_symbol;
int explicitStride[2] = (int[2])0;
int implictStride[2] = (int[2])0;
implictStride = explicitStride;
}

View File

@ -5,8 +5,8 @@ void unused_entry_point() {
return;
}
void foo() {
int explicit[2] = int[2](0, 0);
int implict[2] = int[2](0, 0);
implict = explicit;
int explicitStride[2] = int[2](0, 0);
int implictStride[2] = int[2](0, 0);
implictStride = explicitStride;
}

View File

@ -15,8 +15,8 @@ struct tint_array {
};
void foo() {
tint_array<int, 2> tint_symbol = {};
tint_array<int, 2> implict = {};
implict = tint_symbol;
tint_array<int, 2> explicitStride = {};
tint_array<int, 2> implictStride = {};
implictStride = explicitStride;
}

View File

@ -9,8 +9,8 @@
OpExecutionMode %unused_entry_point LocalSize 1 1 1
OpName %unused_entry_point "unused_entry_point"
OpName %foo "foo"
OpName %explicit "explicit"
OpName %implict "implict"
OpName %explicitStride "explicitStride"
OpName %implictStride "implictStride"
OpDecorate %_arr_int_uint_2 ArrayStride 4
%void = OpTypeVoid
%1 = OpTypeFunction %void
@ -26,9 +26,9 @@
OpFunctionEnd
%foo = OpFunction %void None %1
%6 = OpLabel
%explicit = OpVariable %_ptr_Function__arr_int_uint_2 Function %13
%implict = OpVariable %_ptr_Function__arr_int_uint_2 Function %13
%15 = OpLoad %_arr_int_uint_2 %explicit
OpStore %implict %15
%explicitStride = OpVariable %_ptr_Function__arr_int_uint_2 Function %13
%implictStride = OpVariable %_ptr_Function__arr_int_uint_2 Function %13
%15 = OpLoad %_arr_int_uint_2 %explicitStride
OpStore %implictStride %15
OpReturn
OpFunctionEnd

View File

@ -3,7 +3,7 @@ type ArrayExplicitStride = array<i32, 2>;
type ArrayImplicitStride = array<i32, 2>;
fn foo() {
var explicit : ArrayExplicitStride;
var implict : ArrayImplicitStride;
implict = explicit;
var explicitStride : ArrayExplicitStride;
var implictStride : ArrayImplicitStride;
implictStride = explicitStride;
}

View File

@ -3,5 +3,5 @@ var<private> I : i32;
@compute @workgroup_size(1)
fn main() {
let i : i32 = I;
let use : i32 = i + 1;
let u : i32 = i + 1;
}

View File

@ -2,6 +2,6 @@ static int I = 0;
[numthreads(1, 1, 1)]
void main() {
const int use = (I + 1);
const int u = (I + 1);
return;
}

View File

@ -2,6 +2,6 @@ static int I = 0;
[numthreads(1, 1, 1)]
void main() {
const int use = (I + 1);
const int u = (I + 1);
return;
}

View File

@ -2,7 +2,7 @@
int I = 0;
void tint_symbol() {
int use = (I + 1);
int u = (I + 1);
}
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;

View File

@ -4,7 +4,7 @@ using namespace metal;
kernel void tint_symbol() {
thread int tint_symbol_1 = 0;
int const i = tint_symbol_1;
int const use = as_type<int>((as_type<uint>(i) + as_type<uint>(1)));
int const u = as_type<int>((as_type<uint>(i) + as_type<uint>(1)));
return;
}

View File

@ -3,5 +3,5 @@ var<private> I : i32;
@compute @workgroup_size(1)
fn main() {
let i : i32 = I;
let use : i32 = (i + 1);
let u : i32 = (i + 1);
}

View File

@ -1,5 +1,5 @@
@compute @workgroup_size(1)
fn main() {
var i : i32 = 123;
let use : i32 = i + 1;
let u : i32 = i + 1;
}

View File

@ -1,6 +1,6 @@
[numthreads(1, 1, 1)]
void main() {
int i = 123;
const int use = (i + 1);
const int u = (i + 1);
return;
}

View File

@ -1,6 +1,6 @@
[numthreads(1, 1, 1)]
void main() {
int i = 123;
const int use = (i + 1);
const int u = (i + 1);
return;
}

View File

@ -2,7 +2,7 @@
void tint_symbol() {
int i = 123;
int use = (i + 1);
int u = (i + 1);
}
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;

View File

@ -3,7 +3,7 @@
using namespace metal;
kernel void tint_symbol() {
int i = 123;
int const use = as_type<int>((as_type<uint>(i) + as_type<uint>(1)));
int const u = as_type<int>((as_type<uint>(i) + as_type<uint>(1)));
return;
}

View File

@ -1,5 +1,5 @@
@compute @workgroup_size(1)
fn main() {
var i : i32 = 123;
let use : i32 = (i + 1);
let u : i32 = (i + 1);
}

View File

@ -2,5 +2,5 @@
fn main() {
var i : i32 = 123;
let p : ptr<function, i32> = &i;
let use : i32 = *p + 1;
let u : i32 = *p + 1;
}

View File

@ -1,6 +1,6 @@
[numthreads(1, 1, 1)]
void main() {
int i = 123;
const int use = (i + 1);
const int u = (i + 1);
return;
}

View File

@ -1,6 +1,6 @@
[numthreads(1, 1, 1)]
void main() {
int i = 123;
const int use = (i + 1);
const int u = (i + 1);
return;
}

View File

@ -2,7 +2,7 @@
void tint_symbol() {
int i = 123;
int use = (i + 1);
int u = (i + 1);
}
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;

View File

@ -3,7 +3,7 @@
using namespace metal;
kernel void tint_symbol() {
int i = 123;
int const use = as_type<int>((as_type<uint>(i) + as_type<uint>(1)));
int const u = as_type<int>((as_type<uint>(i) + as_type<uint>(1)));
return;
}

View File

@ -2,5 +2,5 @@
fn main() {
var i : i32 = 123;
let p : ptr<function, i32> = &(i);
let use : i32 = (*(p) + 1);
let u : i32 = (*(p) + 1);
}

View File

@ -3,5 +3,5 @@ var<private> i : i32 = 123;
@compute @workgroup_size(1)
fn main() {
let p : ptr<private, i32> = &i;
let use : i32 = *p + 1;
let u : i32 = *p + 1;
}

View File

@ -2,6 +2,6 @@ static int i = 123;
[numthreads(1, 1, 1)]
void main() {
const int use = (i + 1);
const int u = (i + 1);
return;
}

View File

@ -2,6 +2,6 @@ static int i = 123;
[numthreads(1, 1, 1)]
void main() {
const int use = (i + 1);
const int u = (i + 1);
return;
}

View File

@ -2,7 +2,7 @@
int i = 123;
void tint_symbol() {
int use = (i + 1);
int u = (i + 1);
}
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;

View File

@ -3,7 +3,7 @@
using namespace metal;
kernel void tint_symbol() {
thread int tint_symbol_1 = 123;
int const use = as_type<int>((as_type<uint>(tint_symbol_1) + as_type<uint>(1)));
int const u = as_type<int>((as_type<uint>(tint_symbol_1) + as_type<uint>(1)));
return;
}

View File

@ -3,5 +3,5 @@ var<private> i : i32 = 123;
@compute @workgroup_size(1)
fn main() {
let p : ptr<private, i32> = &(i);
let use : i32 = (*(p) + 1);
let u : i32 = (*(p) + 1);
}

View File

@ -8,5 +8,5 @@ var<storage, read_write> v : S;
@compute @workgroup_size(1)
fn main() {
let p : ptr<storage, i32, read_write> = &v.a;
let use : i32 = *p + 1;
let u : i32 = *p + 1;
}

View File

@ -2,6 +2,6 @@ RWByteAddressBuffer v : register(u0, space0);
[numthreads(1, 1, 1)]
void main() {
const int use = (asint(v.Load(0u)) + 1);
const int u = (asint(v.Load(0u)) + 1);
return;
}

View File

@ -2,6 +2,6 @@ RWByteAddressBuffer v : register(u0, space0);
[numthreads(1, 1, 1)]
void main() {
const int use = (asint(v.Load(0u)) + 1);
const int u = (asint(v.Load(0u)) + 1);
return;
}

View File

@ -8,7 +8,7 @@ layout(binding = 0, std430) buffer S_1 {
int a;
} v;
void tint_symbol() {
int use = (v.a + 1);
int u = (v.a + 1);
}
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;

View File

@ -6,7 +6,7 @@ struct S {
};
kernel void tint_symbol(device S* tint_symbol_1 [[buffer(0)]]) {
int const use = as_type<int>((as_type<uint>((*(tint_symbol_1)).a) + as_type<uint>(1)));
int const u = as_type<int>((as_type<uint>((*(tint_symbol_1)).a) + as_type<uint>(1)));
return;
}

View File

@ -7,5 +7,5 @@ struct S {
@compute @workgroup_size(1)
fn main() {
let p : ptr<storage, i32, read_write> = &(v.a);
let use : i32 = (*(p) + 1);
let u : i32 = (*(p) + 1);
}

View File

@ -8,5 +8,5 @@ var<uniform> v : S;
@compute @workgroup_size(1)
fn main() {
let p : ptr<uniform, i32> = &v.a;
let use : i32 = *p + 1;
let u : i32 = *p + 1;
}

View File

@ -4,6 +4,6 @@ cbuffer cbuffer_v : register(b0, space0) {
[numthreads(1, 1, 1)]
void main() {
const int use = (asint(v[0].x) + 1);
const int u = (asint(v[0].x) + 1);
return;
}

View File

@ -4,6 +4,6 @@ cbuffer cbuffer_v : register(b0, space0) {
[numthreads(1, 1, 1)]
void main() {
const int use = (asint(v[0].x) + 1);
const int u = (asint(v[0].x) + 1);
return;
}

View File

@ -9,7 +9,7 @@ layout(binding = 0) uniform S_1 {
} v;
void tint_symbol() {
int use = (v.a + 1);
int u = (v.a + 1);
}
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;

View File

@ -6,7 +6,7 @@ struct S {
};
kernel void tint_symbol(const constant S* tint_symbol_1 [[buffer(0)]]) {
int const use = as_type<int>((as_type<uint>((*(tint_symbol_1)).a) + as_type<uint>(1)));
int const u = as_type<int>((as_type<uint>((*(tint_symbol_1)).a) + as_type<uint>(1)));
return;
}

View File

@ -7,5 +7,5 @@ struct S {
@compute @workgroup_size(1)
fn main() {
let p : ptr<uniform, i32> = &(v.a);
let use : i32 = (*(p) + 1);
let u : i32 = (*(p) + 1);
}

View File

@ -4,5 +4,5 @@ var<workgroup> i : i32;
fn main() {
i = 123;
let p : ptr<workgroup, i32> = &i;
let use : i32 = *p + 1;
let u : i32 = *p + 1;
}

View File

@ -10,7 +10,7 @@ void main_inner(uint local_invocation_index) {
}
GroupMemoryBarrierWithGroupSync();
i = 123;
const int use = (i + 1);
const int u = (i + 1);
}
[numthreads(1, 1, 1)]

View File

@ -10,7 +10,7 @@ void main_inner(uint local_invocation_index) {
}
GroupMemoryBarrierWithGroupSync();
i = 123;
const int use = (i + 1);
const int u = (i + 1);
}
[numthreads(1, 1, 1)]

View File

@ -7,7 +7,7 @@ void tint_symbol(uint local_invocation_index) {
}
barrier();
i = 123;
int use = (i + 1);
int u = (i + 1);
}
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;

View File

@ -7,7 +7,7 @@ void tint_symbol_inner(uint local_invocation_index, threadgroup int* const tint_
}
threadgroup_barrier(mem_flags::mem_threadgroup);
*(tint_symbol_1) = 123;
int const use = as_type<int>((as_type<uint>(*(tint_symbol_1)) + as_type<uint>(1)));
int const u = as_type<int>((as_type<uint>(*(tint_symbol_1)) + as_type<uint>(1)));
}
kernel void tint_symbol(uint local_invocation_index [[thread_index_in_threadgroup]]) {

View File

@ -4,5 +4,5 @@ var<workgroup> i : i32;
fn main() {
i = 123;
let p : ptr<workgroup, i32> = &(i);
let use : i32 = (*(p) + 1);
let u : i32 = (*(p) + 1);
}