Remove support for the elseif keyword

This was deprecated in M99 and can now be removed.

Fixed: tint:1289
Change-Id: I6513360c5615609a3cc36ae28d5ef8ebddece710
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/83964
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
This commit is contained in:
James Price 2022-03-21 16:09:17 +00:00
parent dfc1a2c081
commit 7d38b88d77
7 changed files with 1 additions and 72 deletions

View File

@ -7,6 +7,7 @@
* The `@block` attribute has been removed. [tint:1324](crbug.com/tint/1324)
* The `@stride` attribute has been removed. [tint:1381](crbug.com/tint/1381)
* Attributes using `[[attribute]]` syntax are no longer supported. [tint:1382](crbug.com/tint/1382)
* The `elseif` keyword is no longer supported. [tint:1289](crbug.com/tint/1289)
## Changes for M101

View File

@ -971,8 +971,6 @@ Token Lexer::check_keyword(const Source& source, std::string_view str) {
return {Token::Type::kDefault, source, "default"};
if (str == "else")
return {Token::Type::kElse, source, "else"};
if (str == "elseif")
return {Token::Type::kElseIf, source, "elseif"};
if (str == "f32")
return {Token::Type::kF32, source, "f32"};
if (str == "fallthrough")

View File

@ -865,7 +865,6 @@ INSTANTIATE_TEST_SUITE_P(
TokenData{"default", Token::Type::kDefault},
TokenData{"discard", Token::Type::kDiscard},
TokenData{"else", Token::Type::kElse},
TokenData{"elseif", Token::Type::kElseIf},
TokenData{"f32", Token::Type::kF32},
TokenData{"fallthrough", Token::Type::kFallthrough},
TokenData{"false", Token::Type::kFalse},

View File

@ -1684,9 +1684,6 @@ Expect<ast::ElseStatementList> ParserImpl::else_stmts() {
bool else_if = false;
if (match(Token::Type::kElse, &start)) {
else_if = match(Token::Type::kIf);
} else if (match(Token::Type::kElseIf, &start)) {
deprecated(start, "'elseif' is now 'else if'");
else_if = true;
} else {
break;
}

View File

@ -64,68 +64,6 @@ TEST_F(ParserImplTest, ElseStmts_MissingBody) {
EXPECT_EQ(p->error(), "1:15: expected '{'");
}
////////////////////////////////////////////////////////////////////////////////
// The tests below use the deprecated 'elseif' syntax
////////////////////////////////////////////////////////////////////////////////
TEST_F(ParserImplTest, DEPRECATED_ElseStmts) {
auto p = parser("elseif (a == 4) { a = b; c = d; }");
auto e = p->else_stmts();
EXPECT_FALSE(p->has_error()) << p->error();
EXPECT_EQ(
p->error(),
R"(1:1: use of deprecated language feature: 'elseif' is now 'else if')");
ASSERT_EQ(e.value.size(), 1u);
ASSERT_TRUE(e.value[0]->Is<ast::ElseStatement>());
ASSERT_NE(e.value[0]->condition, nullptr);
ASSERT_TRUE(e.value[0]->condition->Is<ast::BinaryExpression>());
EXPECT_EQ(e.value[0]->body->statements.size(), 2u);
}
TEST_F(ParserImplTest, DEPRECATED_ElseStmts_Multiple) {
auto p = parser("elseif (a == 4) { a = b; c = d; } elseif(c) { d = 2; }");
auto e = p->else_stmts();
EXPECT_FALSE(p->has_error()) << p->error();
EXPECT_EQ(
p->error(),
R"(1:1: use of deprecated language feature: 'elseif' is now 'else if'
1:35: use of deprecated language feature: 'elseif' is now 'else if')");
ASSERT_EQ(e.value.size(), 2u);
ASSERT_TRUE(e.value[0]->Is<ast::ElseStatement>());
ASSERT_NE(e.value[0]->condition, nullptr);
ASSERT_TRUE(e.value[0]->condition->Is<ast::BinaryExpression>());
EXPECT_EQ(e.value[0]->body->statements.size(), 2u);
ASSERT_TRUE(e.value[1]->Is<ast::ElseStatement>());
ASSERT_NE(e.value[1]->condition, nullptr);
ASSERT_TRUE(e.value[1]->condition->Is<ast::IdentifierExpression>());
EXPECT_EQ(e.value[1]->body->statements.size(), 1u);
}
TEST_F(ParserImplTest, DEPRECATED_ElseStmts_InvalidBody) {
auto p = parser("elseif (true) { fn main() {}}");
auto e = p->else_stmts();
EXPECT_TRUE(e.errored);
EXPECT_TRUE(p->has_error());
EXPECT_EQ(
p->error(),
R"(1:1: use of deprecated language feature: 'elseif' is now 'else if'
1:17: expected '}')");
}
TEST_F(ParserImplTest, DEPRECATED_ElseStmts_MissingBody) {
auto p = parser("elseif (true)");
auto e = p->else_stmts();
EXPECT_TRUE(e.errored);
EXPECT_TRUE(p->has_error());
EXPECT_EQ(
p->error(),
R"(1:1: use of deprecated language feature: 'elseif' is now 'else if'
1:14: expected '{')");
}
} // namespace
} // namespace wgsl
} // namespace reader

View File

@ -131,8 +131,6 @@ std::string_view Token::TypeToName(Type type) {
return "default";
case Token::Type::kElse:
return "else";
case Token::Type::kElseIf:
return "elseif";
case Token::Type::kF32:
return "f32";
case Token::Type::kFallthrough:

View File

@ -141,8 +141,6 @@ class Token {
kDefault,
/// A 'else'
kElse,
/// A 'elseif'
kElseIf,
/// A 'f32'
kF32,
/// A 'fallthrough'