From 60a272a86e089c8f8ebb056fa216e0cb294da82f Mon Sep 17 00:00:00 2001 From: Sarah Mashayekhi Date: Wed, 30 Sep 2020 20:12:50 +0000 Subject: [PATCH] [validation] Update switch error numbers fix clang error Bug: tint: 6 Change-Id: Ib387258387e1f5069585a7fe3af3990df6fc8ddd Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/29043 Commit-Queue: David Neto Reviewed-by: David Neto --- src/validator_control_block_test.cc | 17 ++++++++--------- src/validator_impl.cc | 15 +++++++-------- 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/src/validator_control_block_test.cc b/src/validator_control_block_test.cc index 9cbfb76c0e..da45cc1423 100644 --- a/src/validator_control_block_test.cc +++ b/src/validator_control_block_test.cc @@ -64,7 +64,7 @@ TEST_F(ValidateControlBlockTest, SwitchSelectorExpressionNoneIntegerType_Fail) { EXPECT_TRUE(td()->DetermineStatements(block.get())) << td()->error(); EXPECT_FALSE(v()->ValidateStatements(block.get())); EXPECT_EQ(v()->error(), - "12:34: v-switch01: switch statement selector expression must be " + "12:34: v-0025: switch statement selector expression must be " "of a scalar integer type"); } @@ -177,7 +177,7 @@ TEST_F(ValidateControlBlockTest, EXPECT_TRUE(td()->DetermineStatements(block.get())) << td()->error(); EXPECT_FALSE(v()->ValidateStatements(block.get())); EXPECT_EQ(v()->error(), - "12:34: v-switch03: the case selector values must have the same " + "12:34: v-0026: the case selector values must have the same " "type as the selector expression."); } @@ -216,7 +216,7 @@ TEST_F(ValidateControlBlockTest, EXPECT_TRUE(td()->DetermineStatements(block.get())) << td()->error(); EXPECT_FALSE(v()->ValidateStatements(block.get())); EXPECT_EQ(v()->error(), - "12:34: v-switch03: the case selector values must have the same " + "12:34: v-0026: the case selector values must have the same " "type as the selector expression."); } @@ -261,7 +261,7 @@ TEST_F(ValidateControlBlockTest, NonUniqueCaseSelectorValueUint_Fail) { EXPECT_TRUE(td()->DetermineStatements(block.get())) << td()->error(); EXPECT_FALSE(v()->ValidateStatements(block.get())); EXPECT_EQ(v()->error(), - "12:34: v-switch04: a literal value must not appear more than once " + "12:34: v-0027: a literal value must not appear more than once " "in the case selectors for a switch statement: '2'"); } @@ -307,10 +307,9 @@ TEST_F(ValidateControlBlockTest, NonUniqueCaseSelectorValueSint_Fail) { EXPECT_TRUE(td()->DetermineStatements(block.get())) << td()->error(); EXPECT_FALSE(v()->ValidateStatements(block.get())); - EXPECT_EQ( - v()->error(), - "12:34: v-switch04: a literal value must not appear more than once in " - "the case selectors for a switch statement: '10'"); + EXPECT_EQ(v()->error(), + "12:34: v-0027: a literal value must not appear more than once in " + "the case selectors for a switch statement: '10'"); } TEST_F(ValidateControlBlockTest, LastClauseLastStatementIsFallthrough_Fail) { @@ -341,7 +340,7 @@ TEST_F(ValidateControlBlockTest, LastClauseLastStatementIsFallthrough_Fail) { EXPECT_TRUE(td()->DetermineStatements(block.get())) << td()->error(); EXPECT_FALSE(v()->ValidateStatements(block.get())); EXPECT_EQ(v()->error(), - "12:34: v-switch05: a fallthrough statement must not appear as the " + "12:34: v-0028: a fallthrough statement must not appear as the " "last statement in last clause of a switch"); } diff --git a/src/validator_impl.cc b/src/validator_impl.cc index a7e58d15cb..624793c98b 100644 --- a/src/validator_impl.cc +++ b/src/validator_impl.cc @@ -250,7 +250,7 @@ bool ValidatorImpl::ValidateSwitch(const ast::SwitchStatement* s) { auto* cond_type = s->condition()->result_type()->UnwrapAliasPtrAlias(); if (!(cond_type->IsI32() || cond_type->IsU32())) { set_error(s->condition()->source(), - "v-switch01: switch statement selector expression must be of a " + "v-0025: switch statement selector expression must be of a " "scalar integer type"); return false; } @@ -270,7 +270,7 @@ bool ValidatorImpl::ValidateSwitch(const ast::SwitchStatement* s) { auto* selector_ptr = selector.get(); if (cond_type != selector_ptr->type()) { set_error(case_stmt.get()->source(), - "v-switch03: the case selector values must have the same " + "v-0026: the case selector values must have the same " "type as the selector expression."); return false; } @@ -282,11 +282,10 @@ bool ValidatorImpl::ValidateSwitch(const ast::SwitchStatement* s) { auto v_str = selector_ptr->type()->IsU32() ? selector_ptr->AsUint()->to_str() : selector_ptr->AsSint()->to_str(); - set_error( - case_stmt.get()->source(), - "v-switch04: a literal value must not appear more than once in " - "the case selectors for a switch statement: '" + - v_str + "'"); + set_error(case_stmt.get()->source(), + "v-0027: a literal value must not appear more than once in " + "the case selectors for a switch statement: '" + + v_str + "'"); return false; } selector_set.emplace(v); @@ -303,7 +302,7 @@ bool ValidatorImpl::ValidateSwitch(const ast::SwitchStatement* s) { auto* last_stmt_of_last_clause = last_clause->AsCase()->body()->last(); if (last_stmt_of_last_clause && last_stmt_of_last_clause->IsFallthrough()) { set_error(last_stmt_of_last_clause->source(), - "v-switch05: a fallthrough statement must not appear as " + "v-0028: a fallthrough statement must not appear as " "the last statement in last clause of a switch"); return false; }