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,32 +9,32 @@
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/pointer/fail_deref_not_pointer.carbon
fn Deref(n: i32) {
// CHECK:STDERR: fail_deref_not_pointer.carbon:[[@LINE+4]]:3: error(DerefOfNonPointer): cannot dereference operand of non-pointer type `i32`
// CHECK:STDERR: fail_deref_not_pointer.carbon:[[@LINE+4]]:3: error: cannot dereference operand of non-pointer type `i32` [DerefOfNonPointer]
// CHECK:STDERR: *n;
// CHECK:STDERR: ^
// CHECK:STDERR:
*n;
// CHECK:STDERR: fail_deref_not_pointer.carbon:[[@LINE+4]]:4: error(ArrowOperatorOfNonPointer): cannot apply `->` operator to non-pointer type `i32`
// CHECK:STDERR: fail_deref_not_pointer.carbon:[[@LINE+4]]:4: error: cannot apply `->` operator to non-pointer type `i32` [ArrowOperatorOfNonPointer]
// CHECK:STDERR: n->foo;
// CHECK:STDERR: ^~
// CHECK:STDERR:
n->foo;
// CHECK:STDERR: fail_deref_not_pointer.carbon:[[@LINE+4]]:3: error(DerefOfNonPointer): cannot dereference operand of non-pointer type `()`
// CHECK:STDERR: fail_deref_not_pointer.carbon:[[@LINE+4]]:3: error: cannot dereference operand of non-pointer type `()` [DerefOfNonPointer]
// CHECK:STDERR: *();
// CHECK:STDERR: ^
// CHECK:STDERR:
*();
// CHECK:STDERR: fail_deref_not_pointer.carbon:[[@LINE+4]]:5: error(ArrowOperatorOfNonPointer): cannot apply `->` operator to non-pointer type `()`
// CHECK:STDERR: fail_deref_not_pointer.carbon:[[@LINE+4]]:5: error: cannot apply `->` operator to non-pointer type `()` [ArrowOperatorOfNonPointer]
// CHECK:STDERR: ()->foo;
// CHECK:STDERR: ^~
// CHECK:STDERR:
()->foo;
// CHECK:STDERR: fail_deref_not_pointer.carbon:[[@LINE+4]]:3: error(DerefOfNonPointer): cannot dereference operand of non-pointer type `{}`
// CHECK:STDERR: fail_deref_not_pointer.carbon:[[@LINE+4]]:3: error: cannot dereference operand of non-pointer type `{}` [DerefOfNonPointer]
// CHECK:STDERR: *{};
// CHECK:STDERR: ^
// CHECK:STDERR:
*{};
// CHECK:STDERR: fail_deref_not_pointer.carbon:[[@LINE+3]]:5: error(ArrowOperatorOfNonPointer): cannot apply `->` operator to non-pointer type `{}`
// CHECK:STDERR: fail_deref_not_pointer.carbon:[[@LINE+3]]:5: error: cannot apply `->` operator to non-pointer type `{}` [ArrowOperatorOfNonPointer]
// CHECK:STDERR: {}->foo;
// CHECK:STDERR: ^~
{}->foo;