Diagnostics: Add error code to the Diagnostic

Allows this to be formatted similarly to the severity.

Change-Id: I74cd863d8f1d94089ce753ab76a2c70784eb5553
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/33938
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
This commit is contained in:
Ben Clayton
2020-11-26 17:49:22 +00:00
committed by Commit Bot service account
parent 61ec48b99e
commit f32a3c1f35
9 changed files with 167 additions and 140 deletions

View File

@@ -61,7 +61,7 @@ TEST_F(ValidateControlBlockTest, SwitchSelectorExpressionNoneIntegerType_Fail) {
EXPECT_TRUE(td()->DetermineStatements(block)) << td()->error();
EXPECT_FALSE(v()->ValidateStatements(block));
EXPECT_EQ(v()->error(),
"12:34: v-0025: switch statement selector expression must be "
"12:34 v-0025: switch statement selector expression must be "
"of a scalar integer type");
}
@@ -90,7 +90,7 @@ TEST_F(ValidateControlBlockTest, SwitchWithoutDefault_Fail) {
EXPECT_TRUE(td()->DetermineStatements(block)) << td()->error();
EXPECT_FALSE(v()->ValidateStatements(block));
EXPECT_EQ(v()->error(),
"12:34: v-0008: switch statement must have exactly one default "
"12:34 v-0008: switch statement must have exactly one default "
"clause");
}
@@ -132,7 +132,7 @@ TEST_F(ValidateControlBlockTest, SwitchWithTwoDefault_Fail) {
EXPECT_TRUE(td()->DetermineStatements(block)) << td()->error();
EXPECT_FALSE(v()->ValidateStatements(block));
EXPECT_EQ(v()->error(),
"12:34: v-0008: switch statement must have exactly one default "
"12:34 v-0008: switch statement must have exactly one default "
"clause");
}
@@ -168,7 +168,7 @@ TEST_F(ValidateControlBlockTest,
EXPECT_TRUE(td()->DetermineStatements(block)) << td()->error();
EXPECT_FALSE(v()->ValidateStatements(block));
EXPECT_EQ(v()->error(),
"12:34: v-0026: 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.");
}
@@ -204,7 +204,7 @@ TEST_F(ValidateControlBlockTest,
EXPECT_TRUE(td()->DetermineStatements(block)) << td()->error();
EXPECT_FALSE(v()->ValidateStatements(block));
EXPECT_EQ(v()->error(),
"12:34: v-0026: 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.");
}
@@ -245,7 +245,7 @@ TEST_F(ValidateControlBlockTest, NonUniqueCaseSelectorValueUint_Fail) {
EXPECT_TRUE(td()->DetermineStatements(block)) << td()->error();
EXPECT_FALSE(v()->ValidateStatements(block));
EXPECT_EQ(v()->error(),
"12:34: v-0027: 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'");
}
@@ -288,7 +288,7 @@ TEST_F(ValidateControlBlockTest, NonUniqueCaseSelectorValueSint_Fail) {
EXPECT_TRUE(td()->DetermineStatements(block)) << td()->error();
EXPECT_FALSE(v()->ValidateStatements(block));
EXPECT_EQ(v()->error(),
"12:34: v-0027: a literal value must not appear more than once in "
"12:34 v-0027: a literal value must not appear more than once in "
"the case selectors for a switch statement: '10'");
}
@@ -317,7 +317,7 @@ TEST_F(ValidateControlBlockTest, LastClauseLastStatementIsFallthrough_Fail) {
EXPECT_TRUE(td()->DetermineStatements(block)) << td()->error();
EXPECT_FALSE(v()->ValidateStatements(block));
EXPECT_EQ(v()->error(),
"12:34: v-0028: 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");
}