diff --git a/docs/tint/origin-trial-changes.md b/docs/tint/origin-trial-changes.md index 4641068297..fadeb2dac0 100644 --- a/docs/tint/origin-trial-changes.md +++ b/docs/tint/origin-trial-changes.md @@ -7,6 +7,7 @@ * The `sig` member of the return type of `frexp()` has been renamed to `fract`. [tint:1766](crbug.com/tint/1766) * Calling a function with multiple pointer arguments that alias each other is now a error. [tint:1675](crbug.com/tint/1675) * `type` deprecation has been removed. `alias` must be used now. [tint:1812](crbug.com/tint/1812) +* `static_assert` deprecation has been removed. `const_assert` must now be used. [tint:1807](crbug.com/tint/1807) ## Changes for M111 diff --git a/src/tint/reader/wgsl/lexer.cc b/src/tint/reader/wgsl/lexer.cc index 58bbd58dfa..74c1dba941 100644 --- a/src/tint/reader/wgsl/lexer.cc +++ b/src/tint/reader/wgsl/lexer.cc @@ -1181,9 +1181,6 @@ Token Lexer::check_keyword(const Source& source, std::string_view str) { if (str == "return") { return {Token::Type::kReturn, source, "return"}; } - if (str == "static_assert") { - return {Token::Type::kStaticAssert, source, "static_assert"}; - } if (str == "struct") { return {Token::Type::kStruct, source, "struct"}; } diff --git a/src/tint/reader/wgsl/lexer_test.cc b/src/tint/reader/wgsl/lexer_test.cc index 4eec80bc89..5a3fd6dc91 100644 --- a/src/tint/reader/wgsl/lexer_test.cc +++ b/src/tint/reader/wgsl/lexer_test.cc @@ -1078,7 +1078,6 @@ INSTANTIATE_TEST_SUITE_P(LexerTest, TokenData{"loop", Token::Type::kLoop}, TokenData{"override", Token::Type::kOverride}, TokenData{"return", Token::Type::kReturn}, - TokenData{"static_assert", Token::Type::kStaticAssert}, TokenData{"struct", Token::Type::kStruct}, TokenData{"switch", Token::Type::kSwitch}, TokenData{"true", Token::Type::kTrue}, diff --git a/src/tint/reader/wgsl/parser_impl.cc b/src/tint/reader/wgsl/parser_impl.cc index c4c90ca2c8..3317ab4ebe 100644 --- a/src/tint/reader/wgsl/parser_impl.cc +++ b/src/tint/reader/wgsl/parser_impl.cc @@ -97,13 +97,13 @@ bool is_reserved(const Token& t) { 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_cast" || t == "std" || t == "subroutine" || t == "super" || t == "target" || - t == "template" || t == "this" || t == "thread_local" || t == "throw" || t == "trait" || - t == "try" || t == "type" || 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"; + 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 == "type" || 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. @@ -946,11 +946,7 @@ Expect ParserImpl::expect_struct_member() { // : STATIC_ASSERT expression Maybe ParserImpl::const_assert_statement() { Source start; - if (match(Token::Type::kConstAssert, &start)) { - // matched - } else if (match(Token::Type::kStaticAssert, &start)) { - deprecated(start, "'static_assert' has been renamed to 'const_assert'"); - } else { + if (!match(Token::Type::kConstAssert, &start)) { return Failure::kNoMatch; } diff --git a/src/tint/reader/wgsl/parser_impl_error_msg_test.cc b/src/tint/reader/wgsl/parser_impl_error_msg_test.cc index 472763592c..98001d110b 100644 --- a/src/tint/reader/wgsl/parser_impl_error_msg_test.cc +++ b/src/tint/reader/wgsl/parser_impl_error_msg_test.cc @@ -351,90 +351,6 @@ fn f() { const_assert true } )"); } -// TODO(crbug.com/tint/1807) -TEST_F(ParserImplErrorTest, DEPRECATED_FunctionDeclStaticAssertMissingCondThenEOF) { - EXPECT( - "fn f() { static_assert }", - R"(test.wgsl:1:10 warning: use of deprecated language feature: 'static_assert' has been renamed to 'const_assert' -fn f() { static_assert } - ^^^^^^^^^^^^^ - -test.wgsl:1:24 error: unable to parse condition expression -fn f() { static_assert } - ^ -)"); -} - -// TODO(crbug.com/tint/1807) -TEST_F(ParserImplErrorTest, DEPRECATED_FunctionDeclStaticAssertMissingCondThenSemicolon) { - EXPECT( - "fn f() { static_assert; }", - R"(test.wgsl:1:10 warning: use of deprecated language feature: 'static_assert' has been renamed to 'const_assert' -fn f() { static_assert; } - ^^^^^^^^^^^^^ - -test.wgsl:1:23 error: unable to parse condition expression -fn f() { static_assert; } - ^ -)"); -} - -// TODO(crbug.com/tint/1807) -TEST_F(ParserImplErrorTest, DEPRECATED_FunctionDeclStaticAssertMissingCondThenLet) { - EXPECT( - "fn f() { static_assert\nlet x = 0; }", - R"(test.wgsl:1:10 warning: use of deprecated language feature: 'static_assert' has been renamed to 'const_assert' -fn f() { static_assert - ^^^^^^^^^^^^^ - -test.wgsl:2:1 error: unable to parse condition expression -let x = 0; } -^^^ -)"); -} - -// TODO(crbug.com/tint/1807) -TEST_F(ParserImplErrorTest, DEPRECATED_FunctionDeclStaticAssertMissingLParen) { - EXPECT( - "fn f() { static_assert true);", - R"(test.wgsl:1:10 warning: use of deprecated language feature: 'static_assert' has been renamed to 'const_assert' -fn f() { static_assert true); - ^^^^^^^^^^^^^ - -test.wgsl:1:28 error: expected ';' for statement -fn f() { static_assert true); - ^ -)"); -} - -// TODO(crbug.com/tint/1807) -TEST_F(ParserImplErrorTest, DEPRECATED_FunctionDeclStaticAssertMissingRParen) { - EXPECT( - "fn f() { static_assert (true;", - R"(test.wgsl:1:10 warning: use of deprecated language feature: 'static_assert' has been renamed to 'const_assert' -fn f() { static_assert (true; - ^^^^^^^^^^^^^ - -test.wgsl:1:29 error: expected ')' -fn f() { static_assert (true; - ^ -)"); -} - -// TODO(crbug.com/tint/1807) -TEST_F(ParserImplErrorTest, DEPRECATED_FunctionDeclStaticAssertMissingSemicolon) { - EXPECT( - "fn f() { static_assert true }", - R"(test.wgsl:1:10 warning: use of deprecated language feature: 'static_assert' has been renamed to 'const_assert' -fn f() { static_assert true } - ^^^^^^^^^^^^^ - -test.wgsl:1:29 error: expected ';' for statement -fn f() { static_assert true } - ^ -)"); -} - TEST_F(ParserImplErrorTest, FunctionDeclWorkgroupSizeXInvalid) { EXPECT("@workgroup_size() fn f() {}", R"(test.wgsl:1:17 error: expected workgroup_size x parameter @@ -706,84 +622,6 @@ const_assert true const_assert true; )"); } -// TODO(crbug.com/tint/1807): DEPRECATED -TEST_F(ParserImplErrorTest, DEPRECATED_GlobalDeclStaticAssertMissingCondThenEOF) { - EXPECT("const_assert", R"(test.wgsl:1:13 error: unable to parse condition expression -const_assert - ^ -)"); -} - -// TODO(crbug.com/tint/1807): DEPRECATED -TEST_F(ParserImplErrorTest, DEPRECATED_GlobalDeclStaticAssertMissingCondThenSemicolon) { - EXPECT( - "static_assert;", - R"(test.wgsl:1:1 warning: use of deprecated language feature: 'static_assert' has been renamed to 'const_assert' -static_assert; -^^^^^^^^^^^^^ - -test.wgsl:1:14 error: unable to parse condition expression -static_assert; - ^ -)"); -} - -// TODO(crbug.com/tint/1807): DEPRECATED -TEST_F(ParserImplErrorTest, DEPRECATED_GlobalDeclStaticAssertMissingCondThenAlias) { - EXPECT( - "static_assert\nalias T = i32;", - R"(test.wgsl:1:1 warning: use of deprecated language feature: 'static_assert' has been renamed to 'const_assert' -static_assert -^^^^^^^^^^^^^ - -test.wgsl:2:1 error: unable to parse condition expression -alias T = i32; -^^^^^ -)"); -} - -// TODO(crbug.com/tint/1807): DEPRECATED -TEST_F(ParserImplErrorTest, DEPRECATED_GlobalDeclStaticAssertMissingLParen) { - EXPECT( - "static_assert true);", - R"(test.wgsl:1:1 warning: use of deprecated language feature: 'static_assert' has been renamed to 'const_assert' -static_assert true); -^^^^^^^^^^^^^ - -test.wgsl:1:19 error: expected ';' for const assertion declaration -static_assert true); - ^ -)"); -} - -// TODO(crbug.com/tint/1807): DEPRECATED -TEST_F(ParserImplErrorTest, DEPRECATED_GlobalDeclStaticAssertMissingRParen) { - EXPECT( - "static_assert (true;", - R"(test.wgsl:1:1 warning: use of deprecated language feature: 'static_assert' has been renamed to 'const_assert' -static_assert (true; -^^^^^^^^^^^^^ - -test.wgsl:1:20 error: expected ')' -static_assert (true; - ^ -)"); -} - -// TODO(crbug.com/tint/1807): DEPRECATED -TEST_F(ParserImplErrorTest, DEPRECATED_GlobalDeclStaticAssertMissingSemicolon) { - EXPECT( - "static_assert true static_assert true;", - R"(test.wgsl:1:1 warning: use of deprecated language feature: 'static_assert' has been renamed to 'const_assert' -static_assert true static_assert true; -^^^^^^^^^^^^^ - -test.wgsl:1:20 error: expected ';' for const assertion declaration -static_assert true static_assert true; - ^^^^^^^^^^^^^ -)"); -} - TEST_F(ParserImplErrorTest, GlobalDeclStorageTextureMissingGreaterThan) { EXPECT("var x : texture_storage_2dcondition->source.range.end.column, 19u); } -// TODO(crbug.com/tint/1807) -TEST_F(ParserImplTest, DEPRECATED_GlobalDecl_StaticAssert_WithParen) { - auto p = parser("static_assert(true);"); - p->global_decl(); - ASSERT_FALSE(p->has_error()) << p->error(); - - auto program = p->program(); - ASSERT_EQ(program.AST().ConstAsserts().Length(), 1u); - auto* sa = program.AST().ConstAsserts()[0]; - EXPECT_EQ(sa->source.range.begin.line, 1u); - EXPECT_EQ(sa->source.range.begin.column, 1u); - EXPECT_EQ(sa->source.range.end.line, 1u); - EXPECT_EQ(sa->source.range.end.column, 20u); - - EXPECT_TRUE(sa->condition->Is()); - EXPECT_EQ(sa->condition->source.range.begin.line, 1u); - EXPECT_EQ(sa->condition->source.range.begin.column, 15u); - EXPECT_EQ(sa->condition->source.range.end.line, 1u); - EXPECT_EQ(sa->condition->source.range.end.column, 19u); -} - -// TODO(crbug.com/tint/1807) -TEST_F(ParserImplTest, DEPRECATED_GlobalDecl_StaticAssert_WithoutParen) { - auto p = parser("static_assert true;"); - p->global_decl(); - ASSERT_FALSE(p->has_error()) << p->error(); - - auto program = p->program(); - ASSERT_EQ(program.AST().ConstAsserts().Length(), 1u); - auto* sa = program.AST().ConstAsserts()[0]; - EXPECT_TRUE(sa->condition->Is()); - - EXPECT_EQ(sa->source.range.begin.line, 1u); - EXPECT_EQ(sa->source.range.begin.column, 1u); - EXPECT_EQ(sa->source.range.end.line, 1u); - EXPECT_EQ(sa->source.range.end.column, 20u); - - EXPECT_TRUE(sa->condition->Is()); - EXPECT_EQ(sa->condition->source.range.begin.line, 1u); - EXPECT_EQ(sa->condition->source.range.begin.column, 16u); - EXPECT_EQ(sa->condition->source.range.end.line, 1u); - EXPECT_EQ(sa->condition->source.range.end.column, 20u); -} - } // namespace } // namespace tint::reader::wgsl 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 5efd0b8a8b..57429db407 100644 --- a/src/tint/reader/wgsl/parser_impl_reserved_keyword_test.cc +++ b/src/tint/reader/wgsl/parser_impl_reserved_keyword_test.cc @@ -205,6 +205,7 @@ INSTANTIATE_TEST_SUITE_P(ParserImplReservedKeywordTest, "smooth", "snorm", "static", + "static_assert", "static_cast", "std", "subroutine", @@ -216,7 +217,6 @@ INSTANTIATE_TEST_SUITE_P(ParserImplReservedKeywordTest, "throw", "trait", "try", - "type", "typedef", "typeid", "typename", diff --git a/src/tint/reader/wgsl/parser_impl_statement_test.cc b/src/tint/reader/wgsl/parser_impl_statement_test.cc index 7371b81557..634bfb439b 100644 --- a/src/tint/reader/wgsl/parser_impl_statement_test.cc +++ b/src/tint/reader/wgsl/parser_impl_statement_test.cc @@ -314,50 +314,6 @@ TEST_F(ParserImplTest, Statement_ConstAssert_WithoutParen) { EXPECT_EQ(sa->condition->source.range.end.column, 19u); } -// TODO(crbug.com/tint/1807) -TEST_F(ParserImplTest, DEPRECATED_Statement_StaticAssert_WithParen) { - auto p = parser("static_assert(true);"); - auto e = p->statement(); - ASSERT_FALSE(p->has_error()) << p->error(); - EXPECT_TRUE(e.matched); - EXPECT_FALSE(e.errored); - - auto* sa = As(e.value); - ASSERT_NE(sa, nullptr); - EXPECT_EQ(sa->source.range.begin.line, 1u); - EXPECT_EQ(sa->source.range.begin.column, 1u); - EXPECT_EQ(sa->source.range.end.line, 1u); - EXPECT_EQ(sa->source.range.end.column, 20u); - - EXPECT_TRUE(sa->condition->Is()); - EXPECT_EQ(sa->condition->source.range.begin.line, 1u); - EXPECT_EQ(sa->condition->source.range.begin.column, 15u); - EXPECT_EQ(sa->condition->source.range.end.line, 1u); - EXPECT_EQ(sa->condition->source.range.end.column, 19u); -} - -// TODO(crbug.com/tint/1807) -TEST_F(ParserImplTest, DEPRECATED_Statement_StaticAssert_WithoutParen) { - auto p = parser("static_assert true;"); - auto e = p->statement(); - ASSERT_FALSE(p->has_error()) << p->error(); - EXPECT_TRUE(e.matched); - EXPECT_FALSE(e.errored); - - auto* sa = As(e.value); - ASSERT_NE(sa, nullptr); - EXPECT_EQ(sa->source.range.begin.line, 1u); - EXPECT_EQ(sa->source.range.begin.column, 1u); - EXPECT_EQ(sa->source.range.end.line, 1u); - EXPECT_EQ(sa->source.range.end.column, 20u); - - EXPECT_TRUE(sa->condition->Is()); - EXPECT_EQ(sa->condition->source.range.begin.line, 1u); - EXPECT_EQ(sa->condition->source.range.begin.column, 16u); - EXPECT_EQ(sa->condition->source.range.end.line, 1u); - EXPECT_EQ(sa->condition->source.range.end.column, 20u); -} - TEST_F(ParserImplTest, Statement_UnexpectedAttributes) { auto p = parser("@diagnostic(off, derivative_uniformity) return;"); auto e = p->statement(); diff --git a/src/tint/reader/wgsl/token.cc b/src/tint/reader/wgsl/token.cc index 5935adcde6..822f83466a 100644 --- a/src/tint/reader/wgsl/token.cc +++ b/src/tint/reader/wgsl/token.cc @@ -181,8 +181,6 @@ std::string_view Token::TypeToName(Type type) { return "override"; case Token::Type::kReturn: return "return"; - case Token::Type::kStaticAssert: - return "static_assert"; case Token::Type::kStruct: return "struct"; case Token::Type::kSwitch: diff --git a/src/tint/reader/wgsl/token.h b/src/tint/reader/wgsl/token.h index fe816a6a74..2e9998d768 100644 --- a/src/tint/reader/wgsl/token.h +++ b/src/tint/reader/wgsl/token.h @@ -193,8 +193,6 @@ class Token { kOverride, /// A 'return' kReturn, - /// A 'static_assert' - kStaticAssert, /// A 'struct' kStruct, /// A 'switch'