[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 <dneto@google.com>
Reviewed-by: David Neto <dneto@google.com>
This commit is contained in:
Sarah Mashayekhi 2020-09-30 20:12:50 +00:00 committed by Commit Bot service account
parent 00000b57e8
commit 60a272a86e
2 changed files with 15 additions and 17 deletions

View File

@ -64,7 +64,7 @@ TEST_F(ValidateControlBlockTest, SwitchSelectorExpressionNoneIntegerType_Fail) {
EXPECT_TRUE(td()->DetermineStatements(block.get())) << td()->error(); EXPECT_TRUE(td()->DetermineStatements(block.get())) << td()->error();
EXPECT_FALSE(v()->ValidateStatements(block.get())); EXPECT_FALSE(v()->ValidateStatements(block.get()));
EXPECT_EQ(v()->error(), 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"); "of a scalar integer type");
} }
@ -177,7 +177,7 @@ TEST_F(ValidateControlBlockTest,
EXPECT_TRUE(td()->DetermineStatements(block.get())) << td()->error(); EXPECT_TRUE(td()->DetermineStatements(block.get())) << td()->error();
EXPECT_FALSE(v()->ValidateStatements(block.get())); EXPECT_FALSE(v()->ValidateStatements(block.get()));
EXPECT_EQ(v()->error(), 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."); "type as the selector expression.");
} }
@ -216,7 +216,7 @@ TEST_F(ValidateControlBlockTest,
EXPECT_TRUE(td()->DetermineStatements(block.get())) << td()->error(); EXPECT_TRUE(td()->DetermineStatements(block.get())) << td()->error();
EXPECT_FALSE(v()->ValidateStatements(block.get())); EXPECT_FALSE(v()->ValidateStatements(block.get()));
EXPECT_EQ(v()->error(), 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."); "type as the selector expression.");
} }
@ -261,7 +261,7 @@ TEST_F(ValidateControlBlockTest, NonUniqueCaseSelectorValueUint_Fail) {
EXPECT_TRUE(td()->DetermineStatements(block.get())) << td()->error(); EXPECT_TRUE(td()->DetermineStatements(block.get())) << td()->error();
EXPECT_FALSE(v()->ValidateStatements(block.get())); EXPECT_FALSE(v()->ValidateStatements(block.get()));
EXPECT_EQ(v()->error(), 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'"); "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_TRUE(td()->DetermineStatements(block.get())) << td()->error();
EXPECT_FALSE(v()->ValidateStatements(block.get())); EXPECT_FALSE(v()->ValidateStatements(block.get()));
EXPECT_EQ( EXPECT_EQ(v()->error(),
v()->error(), "12:34: v-0027: a literal value must not appear more than once in "
"12:34: v-switch04: a literal value must not appear more than once in " "the case selectors for a switch statement: '10'");
"the case selectors for a switch statement: '10'");
} }
TEST_F(ValidateControlBlockTest, LastClauseLastStatementIsFallthrough_Fail) { TEST_F(ValidateControlBlockTest, LastClauseLastStatementIsFallthrough_Fail) {
@ -341,7 +340,7 @@ TEST_F(ValidateControlBlockTest, LastClauseLastStatementIsFallthrough_Fail) {
EXPECT_TRUE(td()->DetermineStatements(block.get())) << td()->error(); EXPECT_TRUE(td()->DetermineStatements(block.get())) << td()->error();
EXPECT_FALSE(v()->ValidateStatements(block.get())); EXPECT_FALSE(v()->ValidateStatements(block.get()));
EXPECT_EQ(v()->error(), 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"); "last statement in last clause of a switch");
} }

View File

@ -250,7 +250,7 @@ bool ValidatorImpl::ValidateSwitch(const ast::SwitchStatement* s) {
auto* cond_type = s->condition()->result_type()->UnwrapAliasPtrAlias(); auto* cond_type = s->condition()->result_type()->UnwrapAliasPtrAlias();
if (!(cond_type->IsI32() || cond_type->IsU32())) { if (!(cond_type->IsI32() || cond_type->IsU32())) {
set_error(s->condition()->source(), 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"); "scalar integer type");
return false; return false;
} }
@ -270,7 +270,7 @@ bool ValidatorImpl::ValidateSwitch(const ast::SwitchStatement* s) {
auto* selector_ptr = selector.get(); auto* selector_ptr = selector.get();
if (cond_type != selector_ptr->type()) { if (cond_type != selector_ptr->type()) {
set_error(case_stmt.get()->source(), 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."); "type as the selector expression.");
return false; return false;
} }
@ -282,11 +282,10 @@ bool ValidatorImpl::ValidateSwitch(const ast::SwitchStatement* s) {
auto v_str = selector_ptr->type()->IsU32() auto v_str = selector_ptr->type()->IsU32()
? selector_ptr->AsUint()->to_str() ? selector_ptr->AsUint()->to_str()
: selector_ptr->AsSint()->to_str(); : selector_ptr->AsSint()->to_str();
set_error( set_error(case_stmt.get()->source(),
case_stmt.get()->source(), "v-0027: a literal value must not appear more than once in "
"v-switch04: a literal value must not appear more than once in " "the case selectors for a switch statement: '" +
"the case selectors for a switch statement: '" + v_str + "'");
v_str + "'");
return false; return false;
} }
selector_set.emplace(v); 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(); auto* last_stmt_of_last_clause = last_clause->AsCase()->body()->last();
if (last_stmt_of_last_clause && last_stmt_of_last_clause->IsFallthrough()) { if (last_stmt_of_last_clause && last_stmt_of_last_clause->IsFallthrough()) {
set_error(last_stmt_of_last_clause->source(), 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"); "the last statement in last clause of a switch");
return false; return false;
} }