From 9313aab0fdba908ee85068eadac873656ba275e5 Mon Sep 17 00:00:00 2001 From: Ben Clayton Date: Wed, 15 Mar 2023 15:54:25 +0000 Subject: [PATCH] tint/reader/wgsl: Remove case_body() This was not used. Change-Id: Ic79993be201a2f02c6dc2dc8d92d1aea2f382fe4 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/124221 Commit-Queue: Ben Clayton Kokoro: Kokoro Reviewed-by: Dan Sinclair --- src/tint/BUILD.gn | 1 - src/tint/CMakeLists.txt | 1 - src/tint/reader/wgsl/parser_impl.cc | 30 ----------- src/tint/reader/wgsl/parser_impl.h | 3 -- .../reader/wgsl/parser_impl_case_body_test.cc | 53 ------------------- 5 files changed, 88 deletions(-) delete mode 100644 src/tint/reader/wgsl/parser_impl_case_body_test.cc diff --git a/src/tint/BUILD.gn b/src/tint/BUILD.gn index 20c999c7b5..b065ed0a49 100644 --- a/src/tint/BUILD.gn +++ b/src/tint/BUILD.gn @@ -1751,7 +1751,6 @@ if (tint_build_unittests) { "reader/wgsl/parser_impl_break_stmt_test.cc", "reader/wgsl/parser_impl_bug_cases_test.cc", "reader/wgsl/parser_impl_call_stmt_test.cc", - "reader/wgsl/parser_impl_case_body_test.cc", "reader/wgsl/parser_impl_compound_stmt_test.cc", "reader/wgsl/parser_impl_const_literal_test.cc", "reader/wgsl/parser_impl_continue_stmt_test.cc", diff --git a/src/tint/CMakeLists.txt b/src/tint/CMakeLists.txt index 47f13ea00c..d9b94694f6 100644 --- a/src/tint/CMakeLists.txt +++ b/src/tint/CMakeLists.txt @@ -1104,7 +1104,6 @@ if(TINT_BUILD_TESTS) reader/wgsl/parser_impl_break_stmt_test.cc reader/wgsl/parser_impl_bug_cases_test.cc reader/wgsl/parser_impl_call_stmt_test.cc - reader/wgsl/parser_impl_case_body_test.cc reader/wgsl/parser_impl_compound_stmt_test.cc reader/wgsl/parser_impl_const_literal_test.cc reader/wgsl/parser_impl_continue_stmt_test.cc diff --git a/src/tint/reader/wgsl/parser_impl.cc b/src/tint/reader/wgsl/parser_impl.cc index e4a8367cf9..38d9aa2b32 100644 --- a/src/tint/reader/wgsl/parser_impl.cc +++ b/src/tint/reader/wgsl/parser_impl.cc @@ -1730,36 +1730,6 @@ Maybe ParserImpl::case_selector() { return create(p.source(), expr.value); } -// case_body -// : -// | statement case_body -Maybe ParserImpl::case_body() { - StatementList stmts; - while (continue_parsing()) { - Source source; - if (match(Token::Type::kFallthrough, &source)) { - return add_error( - source, - "fallthrough is not premitted in WGSL. " - "Case can accept multiple selectors if the existing case bodies are empty. " - "(e.g. `case 1, 2, 3:`) " - "`default` is a valid case selector value. (e.g. `case 1, default:`)"); - } - - auto stmt = statement(); - if (stmt.errored) { - return Failure::kErrored; - } - if (!stmt.matched) { - break; - } - - stmts.Push(stmt.value); - } - - return create(Source{}, stmts, utils::Empty); -} - // loop_statement // : LOOP BRACKET_LEFT statements continuing_statement? BRACKET_RIGHT Maybe ParserImpl::loop_statement() { diff --git a/src/tint/reader/wgsl/parser_impl.h b/src/tint/reader/wgsl/parser_impl.h index d7b787bf61..7ad2e6f653 100644 --- a/src/tint/reader/wgsl/parser_impl.h +++ b/src/tint/reader/wgsl/parser_impl.h @@ -509,9 +509,6 @@ class ParserImpl { /// Parses a `case_selector` grammar element /// @returns the selector Maybe case_selector(); - /// Parses a `case_body` grammar element - /// @returns the parsed statements - Maybe case_body(); /// Parses a `func_call_statement` grammar element /// @returns the parsed function call or nullptr Maybe func_call_statement(); diff --git a/src/tint/reader/wgsl/parser_impl_case_body_test.cc b/src/tint/reader/wgsl/parser_impl_case_body_test.cc deleted file mode 100644 index 4d60e2352f..0000000000 --- a/src/tint/reader/wgsl/parser_impl_case_body_test.cc +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright 2020 The Tint Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "src/tint/reader/wgsl/parser_impl_test_helper.h" - -namespace tint::reader::wgsl { -namespace { - -TEST_F(ParserImplTest, CaseBody_Empty) { - auto p = parser(""); - auto e = p->case_body(); - ASSERT_FALSE(p->has_error()) << p->error(); - EXPECT_FALSE(e.errored); - EXPECT_TRUE(e.matched); - EXPECT_EQ(e->statements.Length(), 0u); -} - -TEST_F(ParserImplTest, CaseBody_Statements) { - auto p = parser(R"( - var a: i32; - a = 2;)"); - - auto e = p->case_body(); - ASSERT_FALSE(p->has_error()) << p->error(); - EXPECT_FALSE(e.errored); - EXPECT_TRUE(e.matched); - ASSERT_EQ(e->statements.Length(), 2u); - EXPECT_TRUE(e->statements[0]->Is()); - EXPECT_TRUE(e->statements[1]->Is()); -} - -TEST_F(ParserImplTest, CaseBody_InvalidStatement) { - auto p = parser("a ="); - auto e = p->case_body(); - EXPECT_TRUE(p->has_error()); - EXPECT_TRUE(e.errored); - EXPECT_FALSE(e.matched); - EXPECT_EQ(e.value, nullptr); -} - -} // namespace -} // namespace tint::reader::wgsl