mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-06 07:24:42 +01:00
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:
@@ -9,16 +9,16 @@
|
||||
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/pointer/fail_address_of_error.carbon
|
||||
|
||||
fn Test() {
|
||||
// CHECK:STDERR: fail_address_of_error.carbon:[[@LINE+4]]:4: error(NameNotFound): name `undeclared` not found
|
||||
// CHECK:STDERR: fail_address_of_error.carbon:[[@LINE+4]]:4: error: name `undeclared` not found [NameNotFound]
|
||||
// CHECK:STDERR: &undeclared;
|
||||
// CHECK:STDERR: ^~~~~~~~~~
|
||||
// CHECK:STDERR:
|
||||
&undeclared;
|
||||
// CHECK:STDERR: fail_address_of_error.carbon:[[@LINE+7]]:3: error(AddrOfNonRef): cannot take the address of non-reference expression
|
||||
// CHECK:STDERR: fail_address_of_error.carbon:[[@LINE+7]]:3: error: cannot take the address of non-reference expression [AddrOfNonRef]
|
||||
// CHECK:STDERR: &(&undeclared);
|
||||
// CHECK:STDERR: ^
|
||||
// CHECK:STDERR:
|
||||
// CHECK:STDERR: fail_address_of_error.carbon:[[@LINE+3]]:6: error(NameNotFound): name `undeclared` not found
|
||||
// CHECK:STDERR: fail_address_of_error.carbon:[[@LINE+3]]:6: error: name `undeclared` not found [NameNotFound]
|
||||
// CHECK:STDERR: &(&undeclared);
|
||||
// CHECK:STDERR: ^~~~~~~~~~
|
||||
&(&undeclared);
|
||||
|
||||
+14
-14
@@ -13,32 +13,32 @@ fn G() -> i32;
|
||||
fn H() -> {.a: i32};
|
||||
|
||||
fn AddressOfLiteral() {
|
||||
// CHECK:STDERR: fail_address_of_value.carbon:[[@LINE+4]]:3: error(AddrOfNonRef): cannot take the address of non-reference expression
|
||||
// CHECK:STDERR: fail_address_of_value.carbon:[[@LINE+4]]:3: error: cannot take the address of non-reference expression [AddrOfNonRef]
|
||||
// CHECK:STDERR: &0;
|
||||
// CHECK:STDERR: ^
|
||||
// CHECK:STDERR:
|
||||
&0;
|
||||
// CHECK:STDERR: fail_address_of_value.carbon:[[@LINE+4]]:3: error(AddrOfNonRef): cannot take the address of non-reference expression
|
||||
// CHECK:STDERR: fail_address_of_value.carbon:[[@LINE+4]]:3: error: cannot take the address of non-reference expression [AddrOfNonRef]
|
||||
// CHECK:STDERR: &true;
|
||||
// CHECK:STDERR: ^
|
||||
// CHECK:STDERR:
|
||||
&true;
|
||||
// CHECK:STDERR: fail_address_of_value.carbon:[[@LINE+4]]:3: error(AddrOfNonRef): cannot take the address of non-reference expression
|
||||
// CHECK:STDERR: fail_address_of_value.carbon:[[@LINE+4]]:3: error: cannot take the address of non-reference expression [AddrOfNonRef]
|
||||
// CHECK:STDERR: &1.0;
|
||||
// CHECK:STDERR: ^
|
||||
// CHECK:STDERR:
|
||||
&1.0;
|
||||
// CHECK:STDERR: fail_address_of_value.carbon:[[@LINE+4]]:3: error(AddrOfNonRef): cannot take the address of non-reference expression
|
||||
// CHECK:STDERR: fail_address_of_value.carbon:[[@LINE+4]]:3: error: cannot take the address of non-reference expression [AddrOfNonRef]
|
||||
// CHECK:STDERR: &"Hello";
|
||||
// CHECK:STDERR: ^
|
||||
// CHECK:STDERR:
|
||||
&"Hello";
|
||||
// CHECK:STDERR: fail_address_of_value.carbon:[[@LINE+4]]:3: error(AddrOfNonRef): cannot take the address of non-reference expression
|
||||
// CHECK:STDERR: fail_address_of_value.carbon:[[@LINE+4]]:3: error: cannot take the address of non-reference expression [AddrOfNonRef]
|
||||
// CHECK:STDERR: &(1, 2);
|
||||
// CHECK:STDERR: ^
|
||||
// CHECK:STDERR:
|
||||
&(1, 2);
|
||||
// CHECK:STDERR: fail_address_of_value.carbon:[[@LINE+4]]:3: error(AddrOfNonRef): cannot take the address of non-reference expression
|
||||
// CHECK:STDERR: fail_address_of_value.carbon:[[@LINE+4]]:3: error: cannot take the address of non-reference expression [AddrOfNonRef]
|
||||
// CHECK:STDERR: &{.a = 5};
|
||||
// CHECK:STDERR: ^
|
||||
// CHECK:STDERR:
|
||||
@@ -46,17 +46,17 @@ fn AddressOfLiteral() {
|
||||
}
|
||||
|
||||
fn AddressOfOperator() {
|
||||
// CHECK:STDERR: fail_address_of_value.carbon:[[@LINE+4]]:3: error(AddrOfNonRef): cannot take the address of non-reference expression
|
||||
// CHECK:STDERR: fail_address_of_value.carbon:[[@LINE+4]]:3: error: cannot take the address of non-reference expression [AddrOfNonRef]
|
||||
// CHECK:STDERR: &(true and false);
|
||||
// CHECK:STDERR: ^
|
||||
// CHECK:STDERR:
|
||||
&(true and false);
|
||||
// CHECK:STDERR: fail_address_of_value.carbon:[[@LINE+4]]:3: error(AddrOfEphemeralRef): cannot take the address of a temporary object
|
||||
// CHECK:STDERR: fail_address_of_value.carbon:[[@LINE+4]]:3: error: cannot take the address of a temporary object [AddrOfEphemeralRef]
|
||||
// CHECK:STDERR: &H().a;
|
||||
// CHECK:STDERR: ^
|
||||
// CHECK:STDERR:
|
||||
&H().a;
|
||||
// CHECK:STDERR: fail_address_of_value.carbon:[[@LINE+4]]:3: error(AddrOfNonRef): cannot take the address of non-reference expression
|
||||
// CHECK:STDERR: fail_address_of_value.carbon:[[@LINE+4]]:3: error: cannot take the address of non-reference expression [AddrOfNonRef]
|
||||
// CHECK:STDERR: &(not true);
|
||||
// CHECK:STDERR: ^
|
||||
// CHECK:STDERR:
|
||||
@@ -64,7 +64,7 @@ fn AddressOfOperator() {
|
||||
}
|
||||
|
||||
fn AddressOfCall() {
|
||||
// CHECK:STDERR: fail_address_of_value.carbon:[[@LINE+4]]:3: error(AddrOfNonRef): cannot take the address of non-reference expression
|
||||
// CHECK:STDERR: fail_address_of_value.carbon:[[@LINE+4]]:3: error: cannot take the address of non-reference expression [AddrOfNonRef]
|
||||
// CHECK:STDERR: &G();
|
||||
// CHECK:STDERR: ^
|
||||
// CHECK:STDERR:
|
||||
@@ -72,12 +72,12 @@ fn AddressOfCall() {
|
||||
}
|
||||
|
||||
fn AddressOfType() {
|
||||
// CHECK:STDERR: fail_address_of_value.carbon:[[@LINE+4]]:3: error(AddrOfNonRef): cannot take the address of non-reference expression
|
||||
// CHECK:STDERR: fail_address_of_value.carbon:[[@LINE+4]]:3: error: cannot take the address of non-reference expression [AddrOfNonRef]
|
||||
// CHECK:STDERR: &i32;
|
||||
// CHECK:STDERR: ^
|
||||
// CHECK:STDERR:
|
||||
&i32;
|
||||
// CHECK:STDERR: fail_address_of_value.carbon:[[@LINE+4]]:3: error(AddrOfNonRef): cannot take the address of non-reference expression
|
||||
// CHECK:STDERR: fail_address_of_value.carbon:[[@LINE+4]]:3: error: cannot take the address of non-reference expression [AddrOfNonRef]
|
||||
// CHECK:STDERR: &(const i32*);
|
||||
// CHECK:STDERR: ^
|
||||
// CHECK:STDERR:
|
||||
@@ -85,7 +85,7 @@ fn AddressOfType() {
|
||||
}
|
||||
|
||||
fn AddressOfTupleElementValue() {
|
||||
// CHECK:STDERR: fail_address_of_value.carbon:[[@LINE+4]]:3: error(AddrOfNonRef): cannot take the address of non-reference expression
|
||||
// CHECK:STDERR: fail_address_of_value.carbon:[[@LINE+4]]:3: error: cannot take the address of non-reference expression [AddrOfNonRef]
|
||||
// CHECK:STDERR: &((1, 2).0);
|
||||
// CHECK:STDERR: ^
|
||||
// CHECK:STDERR:
|
||||
@@ -93,7 +93,7 @@ fn AddressOfTupleElementValue() {
|
||||
}
|
||||
|
||||
fn AddressOfParam(param: i32) {
|
||||
// CHECK:STDERR: fail_address_of_value.carbon:[[@LINE+3]]:26: error(AddrOfNonRef): cannot take the address of non-reference expression
|
||||
// CHECK:STDERR: fail_address_of_value.carbon:[[@LINE+3]]:26: error: cannot take the address of non-reference expression [AddrOfNonRef]
|
||||
// CHECK:STDERR: var param_addr: i32* = ¶m;
|
||||
// CHECK:STDERR: ^
|
||||
var param_addr: i32* = ¶m;
|
||||
|
||||
@@ -8,12 +8,12 @@
|
||||
// TIP: To dump output, run:
|
||||
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/pointer/fail_deref_error.carbon
|
||||
|
||||
// CHECK:STDERR: fail_deref_error.carbon:[[@LINE+4]]:15: error(NameNotFound): name `undeclared` not found
|
||||
// CHECK:STDERR: fail_deref_error.carbon:[[@LINE+4]]:15: error: name `undeclared` not found [NameNotFound]
|
||||
// CHECK:STDERR: let n: i32 = *undeclared;
|
||||
// CHECK:STDERR: ^~~~~~~~~~
|
||||
// CHECK:STDERR:
|
||||
let n: i32 = *undeclared;
|
||||
// CHECK:STDERR: fail_deref_error.carbon:[[@LINE+3]]:15: error(NameNotFound): name `undeclared` not found
|
||||
// CHECK:STDERR: fail_deref_error.carbon:[[@LINE+3]]:15: error: name `undeclared` not found [NameNotFound]
|
||||
// CHECK:STDERR: let n2: i32 = undeclared->foo;
|
||||
// CHECK:STDERR: ^~~~~~~~~~
|
||||
let n2: i32 = undeclared->foo;
|
||||
|
||||
@@ -9,12 +9,12 @@
|
||||
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/pointer/fail_deref_function.carbon
|
||||
|
||||
fn A() {
|
||||
// CHECK:STDERR: fail_deref_function.carbon:[[@LINE+4]]:4: error(UseOfNonExprAsValue): expression cannot be used as a value
|
||||
// CHECK:STDERR: fail_deref_function.carbon:[[@LINE+4]]:4: error: expression cannot be used as a value [UseOfNonExprAsValue]
|
||||
// CHECK:STDERR: *A;
|
||||
// CHECK:STDERR: ^
|
||||
// CHECK:STDERR:
|
||||
*A;
|
||||
// CHECK:STDERR: fail_deref_function.carbon:[[@LINE+3]]:3: error(UseOfNonExprAsValue): expression cannot be used as a value
|
||||
// CHECK:STDERR: fail_deref_function.carbon:[[@LINE+3]]:3: error: expression cannot be used as a value [UseOfNonExprAsValue]
|
||||
// CHECK:STDERR: A->foo;
|
||||
// CHECK:STDERR: ^
|
||||
A->foo;
|
||||
|
||||
@@ -11,12 +11,12 @@
|
||||
namespace A;
|
||||
|
||||
fn F() {
|
||||
// CHECK:STDERR: fail_deref_namespace.carbon:[[@LINE+4]]:4: error(UseOfNonExprAsValue): expression cannot be used as a value
|
||||
// CHECK:STDERR: fail_deref_namespace.carbon:[[@LINE+4]]:4: error: expression cannot be used as a value [UseOfNonExprAsValue]
|
||||
// CHECK:STDERR: *A;
|
||||
// CHECK:STDERR: ^
|
||||
// CHECK:STDERR:
|
||||
*A;
|
||||
// CHECK:STDERR: fail_deref_namespace.carbon:[[@LINE+3]]:3: error(UseOfNonExprAsValue): expression cannot be used as a value
|
||||
// CHECK:STDERR: fail_deref_namespace.carbon:[[@LINE+3]]:3: error: expression cannot be used as a value [UseOfNonExprAsValue]
|
||||
// CHECK:STDERR: A->foo;
|
||||
// CHECK:STDERR: ^
|
||||
A->foo;
|
||||
|
||||
@@ -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;
|
||||
|
||||
+3
-3
@@ -8,15 +8,15 @@
|
||||
// TIP: To dump output, run:
|
||||
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/pointer/fail_deref_type.carbon
|
||||
|
||||
// CHECK:STDERR: fail_deref_type.carbon:[[@LINE+7]]:8: error(DerefOfNonPointer): cannot dereference operand of non-pointer type `type`
|
||||
// CHECK:STDERR: fail_deref_type.carbon:[[@LINE+7]]:8: error: cannot dereference operand of non-pointer type `type` [DerefOfNonPointer]
|
||||
// CHECK:STDERR: var p: *i32;
|
||||
// CHECK:STDERR: ^
|
||||
// CHECK:STDERR: fail_deref_type.carbon:[[@LINE+4]]:8: note(DerefOfType): to form a pointer type, write the `*` after the pointee type
|
||||
// CHECK:STDERR: fail_deref_type.carbon:[[@LINE+4]]:8: note: to form a pointer type, write the `*` after the pointee type [DerefOfType]
|
||||
// CHECK:STDERR: var p: *i32;
|
||||
// CHECK:STDERR: ^
|
||||
// CHECK:STDERR:
|
||||
var p: *i32;
|
||||
// CHECK:STDERR: fail_deref_type.carbon:[[@LINE+3]]:12: error(ArrowOperatorOfNonPointer): cannot apply `->` operator to non-pointer type `type`
|
||||
// CHECK:STDERR: fail_deref_type.carbon:[[@LINE+3]]:12: error: cannot apply `->` operator to non-pointer type `type` [ArrowOperatorOfNonPointer]
|
||||
// CHECK:STDERR: var p2: i32->foo;
|
||||
// CHECK:STDERR: ^~
|
||||
var p2: i32->foo;
|
||||
|
||||
@@ -9,10 +9,10 @@
|
||||
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/pointer/fail_type_mismatch.carbon
|
||||
|
||||
fn ConstMismatch(p: const {}*) -> const ({}*) {
|
||||
// CHECK:STDERR: fail_type_mismatch.carbon:[[@LINE+6]]:3: error(ImplicitAsConversionFailure): cannot implicitly convert from `const {}*` to `const ({}*)`
|
||||
// CHECK:STDERR: fail_type_mismatch.carbon:[[@LINE+6]]:3: error: cannot implicitly convert from `const {}*` to `const ({}*)` [ImplicitAsConversionFailure]
|
||||
// CHECK:STDERR: return p;
|
||||
// CHECK:STDERR: ^~~~~~~~~
|
||||
// CHECK:STDERR: fail_type_mismatch.carbon:[[@LINE+3]]:3: note(MissingImplInMemberAccessNote): type `const {}*` does not implement interface `ImplicitAs`
|
||||
// CHECK:STDERR: fail_type_mismatch.carbon:[[@LINE+3]]:3: note: type `const {}*` does not implement interface `ImplicitAs` [MissingImplInMemberAccessNote]
|
||||
// CHECK:STDERR: return p;
|
||||
// CHECK:STDERR: ^~~~~~~~~
|
||||
return p;
|
||||
|
||||
Reference in New Issue
Block a user