Remove `static_assert` deprecation.

The `static_assert` builtin has been replaced with `const_assert`. This
CL removes the deprecation.

Bug: tint:1807
Change-Id: Ibcdc75e167bf6c1a6f74c295d9dcac7fff884d3a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/120580
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
This commit is contained in:
dan sinclair 2023-02-21 18:44:16 +00:00 committed by Dawn LUCI CQ
parent 0aa2cef37e
commit b92ff39724
10 changed files with 10 additions and 271 deletions

View File

@ -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

View File

@ -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"};
}

View File

@ -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},

View File

@ -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<const ast::StructMember*> ParserImpl::expect_struct_member() {
// : STATIC_ASSERT expression
Maybe<const ast::ConstAssert*> 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;
}

View File

@ -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_2d<r32uint, read;",
R"(test.wgsl:1:27 error: expected ';' for variable declaration

View File

@ -253,49 +253,5 @@ TEST_F(ParserImplTest, GlobalDecl_ConstAssert_WithoutParen) {
EXPECT_EQ(sa->condition->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<ast::BoolLiteralExpression>());
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<ast::BoolLiteralExpression>());
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<ast::BoolLiteralExpression>());
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

View File

@ -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",

View File

@ -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<ast::ConstAssert>(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<ast::BoolLiteralExpression>());
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<ast::ConstAssert>(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<ast::BoolLiteralExpression>());
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();

View File

@ -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:

View File

@ -193,8 +193,6 @@ class Token {
kOverride,
/// A 'return'
kReturn,
/// A 'static_assert'
kStaticAssert,
/// A 'struct'
kStruct,
/// A 'switch'