Move diagnostic kind name to the end of the diagnostic. (#4437)

Also surround it in square brackets rather than parentheses. This
matches the format used by Clang and GCC, and means diagnostics will
still match the `file:line:col: error: ` pattern used by some IDE tools.

Before:
```console
fail_builtins.carbon:11:11: error(AliasRequiresNameRef): alias initializer must be a name reference
```

After:
```console
fail_builtins.carbon:11:11: error: alias initializer must be a name reference [AliasRequiresNameRef]
```

Also tighten up test regex to only match on `STDERR` lines that list a
file name.
This commit is contained in:
Richard Smith
2024-10-23 16:56:23 +00:00
committed by GitHub
parent f206072216
commit 2e63da1a40
528 changed files with 1929 additions and 1928 deletions
@@ -9,7 +9,7 @@
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/parse/testdata/if_expr/fail_condition_missing.carbon
fn F() {
// CHECK:STDERR: fail_condition_missing.carbon:[[@LINE+3]]:18: error(ExpectedExpr): expected expression
// CHECK:STDERR: fail_condition_missing.carbon:[[@LINE+3]]:18: error: expected expression [ExpectedExpr]
// CHECK:STDERR: var n: i32 = if;
// CHECK:STDERR: ^
var n: i32 = if;
@@ -9,7 +9,7 @@
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/parse/testdata/if_expr/fail_else_expr_missing.carbon
fn F() {
// CHECK:STDERR: fail_else_expr_missing.carbon:[[@LINE+3]]:35: error(ExpectedExpr): expected expression
// CHECK:STDERR: fail_else_expr_missing.carbon:[[@LINE+3]]:35: error: expected expression [ExpectedExpr]
// CHECK:STDERR: var n: i32 = if true then 1 else;
// CHECK:STDERR: ^
var n: i32 = if true then 1 else;
+1 -1
View File
@@ -9,7 +9,7 @@
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/parse/testdata/if_expr/fail_else_missing.carbon
fn F() {
// CHECK:STDERR: fail_else_missing.carbon:[[@LINE+3]]:30: error(ExpectedElseAfterIf): expected `else` after `if ... then ...`
// CHECK:STDERR: fail_else_missing.carbon:[[@LINE+3]]:30: error: expected `else` after `if ... then ...` [ExpectedElseAfterIf]
// CHECK:STDERR: var n: i32 = if true then 1;
// CHECK:STDERR: ^
var n: i32 = if true then 1;
@@ -9,7 +9,7 @@
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/parse/testdata/if_expr/fail_then_expr_missing.carbon
fn F() {
// CHECK:STDERR: fail_then_expr_missing.carbon:[[@LINE+3]]:28: error(ExpectedExpr): expected expression
// CHECK:STDERR: fail_then_expr_missing.carbon:[[@LINE+3]]:28: error: expected expression [ExpectedExpr]
// CHECK:STDERR: var n: i32 = if true then;
// CHECK:STDERR: ^
var n: i32 = if true then;
+1 -1
View File
@@ -9,7 +9,7 @@
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/parse/testdata/if_expr/fail_then_missing.carbon
fn F() {
// CHECK:STDERR: fail_then_missing.carbon:[[@LINE+3]]:23: error(ExpectedThenAfterIf): expected `then` after `if` condition
// CHECK:STDERR: fail_then_missing.carbon:[[@LINE+3]]:23: error: expected `then` after `if` condition [ExpectedThenAfterIf]
// CHECK:STDERR: var n: i32 = if true;
// CHECK:STDERR: ^
var n: i32 = if true;
+3 -3
View File
@@ -9,15 +9,15 @@
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/parse/testdata/if_expr/fail_top_level_if.carbon
fn F() {
// CHECK:STDERR: fail_top_level_if.carbon:[[@LINE+11]]:6: error(ExpectedParenAfter): expected `(` after `if`
// CHECK:STDERR: fail_top_level_if.carbon:[[@LINE+11]]:6: error: expected `(` after `if` [ExpectedParenAfter]
// CHECK:STDERR: if true then 1 else 2;
// CHECK:STDERR: ^~~~
// CHECK:STDERR:
// CHECK:STDERR: fail_top_level_if.carbon:[[@LINE+7]]:11: error(ExpectedCodeBlock): expected braced code block
// CHECK:STDERR: fail_top_level_if.carbon:[[@LINE+7]]:11: error: expected braced code block [ExpectedCodeBlock]
// CHECK:STDERR: if true then 1 else 2;
// CHECK:STDERR: ^~~~
// CHECK:STDERR:
// CHECK:STDERR: fail_top_level_if.carbon:[[@LINE+3]]:11: error(ExpectedExpr): expected expression
// CHECK:STDERR: fail_top_level_if.carbon:[[@LINE+3]]:11: error: expected expression [ExpectedExpr]
// CHECK:STDERR: if true then 1 else 2;
// CHECK:STDERR: ^~~~
if true then 1 else 2;