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 <bclayton@google.com> Kokoro: Kokoro <noreply+kokoro@google.com> Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
This commit is contained in:
parent
2fc56a1c63
commit
9313aab0fd
|
@ -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",
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1730,36 +1730,6 @@ Maybe<const ast::CaseSelector*> ParserImpl::case_selector() {
|
|||
return create<ast::CaseSelector>(p.source(), expr.value);
|
||||
}
|
||||
|
||||
// case_body
|
||||
// :
|
||||
// | statement case_body
|
||||
Maybe<const ast::BlockStatement*> 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<ast::BlockStatement>(Source{}, stmts, utils::Empty);
|
||||
}
|
||||
|
||||
// loop_statement
|
||||
// : LOOP BRACKET_LEFT statements continuing_statement? BRACKET_RIGHT
|
||||
Maybe<const ast::LoopStatement*> ParserImpl::loop_statement() {
|
||||
|
|
|
@ -509,9 +509,6 @@ class ParserImpl {
|
|||
/// Parses a `case_selector` grammar element
|
||||
/// @returns the selector
|
||||
Maybe<const ast::CaseSelector*> case_selector();
|
||||
/// Parses a `case_body` grammar element
|
||||
/// @returns the parsed statements
|
||||
Maybe<const ast::BlockStatement*> case_body();
|
||||
/// Parses a `func_call_statement` grammar element
|
||||
/// @returns the parsed function call or nullptr
|
||||
Maybe<const ast::CallStatement*> func_call_statement();
|
||||
|
|
|
@ -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<ast::VariableDeclStatement>());
|
||||
EXPECT_TRUE(e->statements[1]->Is<ast::AssignmentStatement>());
|
||||
}
|
||||
|
||||
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
|
Loading…
Reference in New Issue