From 7d38b88d773beb9ec1d2e7842e4334969b2b8561 Mon Sep 17 00:00:00 2001 From: James Price Date: Mon, 21 Mar 2022 16:09:17 +0000 Subject: [PATCH] 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 Kokoro: Kokoro --- docs/tint/origin-trial-changes.md | 1 + src/tint/reader/wgsl/lexer.cc | 2 - src/tint/reader/wgsl/lexer_test.cc | 1 - src/tint/reader/wgsl/parser_impl.cc | 3 - .../wgsl/parser_impl_elseif_stmt_test.cc | 62 ------------------- src/tint/reader/wgsl/token.cc | 2 - src/tint/reader/wgsl/token.h | 2 - 7 files changed, 1 insertion(+), 72 deletions(-) diff --git a/docs/tint/origin-trial-changes.md b/docs/tint/origin-trial-changes.md index ff3c4f6136..fb48d13101 100644 --- a/docs/tint/origin-trial-changes.md +++ b/docs/tint/origin-trial-changes.md @@ -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 diff --git a/src/tint/reader/wgsl/lexer.cc b/src/tint/reader/wgsl/lexer.cc index 1d013756f2..e6a01daa83 100644 --- a/src/tint/reader/wgsl/lexer.cc +++ b/src/tint/reader/wgsl/lexer.cc @@ -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") diff --git a/src/tint/reader/wgsl/lexer_test.cc b/src/tint/reader/wgsl/lexer_test.cc index f9354e443e..08336914eb 100644 --- a/src/tint/reader/wgsl/lexer_test.cc +++ b/src/tint/reader/wgsl/lexer_test.cc @@ -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}, diff --git a/src/tint/reader/wgsl/parser_impl.cc b/src/tint/reader/wgsl/parser_impl.cc index 0f62a2fe30..20e8d3828e 100644 --- a/src/tint/reader/wgsl/parser_impl.cc +++ b/src/tint/reader/wgsl/parser_impl.cc @@ -1684,9 +1684,6 @@ Expect 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; } diff --git a/src/tint/reader/wgsl/parser_impl_elseif_stmt_test.cc b/src/tint/reader/wgsl/parser_impl_elseif_stmt_test.cc index 8608771211..56d978fab1 100644 --- a/src/tint/reader/wgsl/parser_impl_elseif_stmt_test.cc +++ b/src/tint/reader/wgsl/parser_impl_elseif_stmt_test.cc @@ -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()); - ASSERT_NE(e.value[0]->condition, nullptr); - ASSERT_TRUE(e.value[0]->condition->Is()); - 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()); - ASSERT_NE(e.value[0]->condition, nullptr); - ASSERT_TRUE(e.value[0]->condition->Is()); - EXPECT_EQ(e.value[0]->body->statements.size(), 2u); - - ASSERT_TRUE(e.value[1]->Is()); - ASSERT_NE(e.value[1]->condition, nullptr); - ASSERT_TRUE(e.value[1]->condition->Is()); - 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 diff --git a/src/tint/reader/wgsl/token.cc b/src/tint/reader/wgsl/token.cc index 266907ea48..c873e179b6 100644 --- a/src/tint/reader/wgsl/token.cc +++ b/src/tint/reader/wgsl/token.cc @@ -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: diff --git a/src/tint/reader/wgsl/token.h b/src/tint/reader/wgsl/token.h index dcc01677c2..b25fb60622 100644 --- a/src/tint/reader/wgsl/token.h +++ b/src/tint/reader/wgsl/token.h @@ -141,8 +141,6 @@ class Token { kDefault, /// A 'else' kElse, - /// A 'elseif' - kElseIf, /// A 'f32' kF32, /// A 'fallthrough'