mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-11-26 16:11:19 +00:00
Switch tests to use the rendered form of diagnostics (#8070)
Historically, we disabled the rendered form in tests outside of `toolchain/diagnostics`. The idea was to keep tests shorter and avoid very long chains of autoupdate before stabilizing due to all the line numbers and other artifacts in the rendered form. This PR adds `--diagnostic-line-numbers=[all|first]` and defaults to `first` in tests. This keeps the rendered form so that we can easily code review that form and the visual cues it does or doesn't provide. But it removes all but the first location's line numbers to provide significantly more stability in tests. By default, tests get the full unicode line-drawing form of diagnostics so we can ensure all of the artifacts there make sense with the specific case being diagnosed, but we do retain some focused ASCII-rendering tests to ensure that fallback remains usable. There are some issues here that will be fixed in subsequent PRs. Notably, we try to keep the frame together in the check lines, and so force some parts to use the first location. This largely works, but fails in some edge cases, causing the entire frame to be located incorrectly. There is a TODO about this that we need to fix, and it only occurs 6 times across the test suite, so it didn't seem worth front-loading a fix for here. Assisted-by: Claude Code
This commit is contained in:
1 parent
0b7059a360
commit
d0badecd2a
888 files changed
+39731
-12799
No files matched your search
+64
-14
@@ -47,9 +47,21 @@ class X {}
|
||||
|
||||
fn TakeNonConst(p: X*);
|
||||
|
||||
// CHECK:STDERR: fail_removed_qualifiers.carbon:[[@LINE+4]]:38: error: cannot implicitly convert expression of type `const X*` to `X*` [ConversionFailure]
|
||||
// CHECK:STDERR: fail_removed_qualifiers.carbon:[[@LINE+3]]:38: note: type `const X*` does not implement interface `Core.ImplicitAs(X*)` [MissingImplInMemberAccessInContext]
|
||||
// CHECK:STDERR: fail_removed_qualifiers.carbon:[[@LINE-4]]:17-21: note: initializing function parameter [InCallToFunctionParam]
|
||||
// CHECK:STDERR: ╭─┤ fail_removed_qualifiers.carbon:[[@LINE+16]]:38
|
||||
// CHECK:STDERR: │ fn TakeNonConst(p: X*);
|
||||
// CHECK:STDERR: · ──┬──
|
||||
// CHECK:STDERR: · ╰──┤ initializing function parameter [InCallToFunctionParam]
|
||||
// CHECK:STDERR: ┆
|
||||
// CHECK:STDERR: -> │ fn Const(p: const X*) { TakeNonConst(p); }
|
||||
// CHECK:STDERR: · ┳
|
||||
// CHECK:STDERR: · ┗━━┫ error: cannot implicitly convert
|
||||
// CHECK:STDERR: · │ ┃ expression of type `const X*`
|
||||
// CHECK:STDERR: · │ ┃ to `X*`
|
||||
// CHECK:STDERR: · │ ┃ [ConversionFailure]
|
||||
// CHECK:STDERR: · ╰────┤ type `const X*` does not implement
|
||||
// CHECK:STDERR: · │ interface `Core.ImplicitAs(X*)`
|
||||
// CHECK:STDERR: · │ [MissingImplInMemberAccessInContext]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
fn Const(p: const X*) { TakeNonConst(p); }
|
||||
|
||||
@@ -65,9 +77,21 @@ fn TakeConstConst(p: const (const X*)*);
|
||||
|
||||
fn NonConstNonConst(p: X**) {
|
||||
//@dump-sem-ir-begin
|
||||
// CHECK:STDERR: fail_todo_nested_qualifiers.carbon:[[@LINE+4]]:18: error: cannot implicitly convert expression of type `X**` to `const (const X*)*` [ConversionFailure]
|
||||
// CHECK:STDERR: fail_todo_nested_qualifiers.carbon:[[@LINE+3]]:18: note: type `X**` does not implement interface `Core.ImplicitAs(const (const X*)*)` [MissingImplInMemberAccessInContext]
|
||||
// CHECK:STDERR: fail_todo_nested_qualifiers.carbon:[[@LINE-8]]:19-38: note: initializing function parameter [InCallToFunctionParam]
|
||||
// CHECK:STDERR: ╭─┤ fail_todo_nested_qualifiers.carbon:[[@LINE+16]]:18
|
||||
// CHECK:STDERR: │ fn TakeConstConst(p: const (const X*)*);
|
||||
// CHECK:STDERR: · ──────────┬─────────
|
||||
// CHECK:STDERR: · ╰──┤ initializing function parameter
|
||||
// CHECK:STDERR: · │ [InCallToFunctionParam]
|
||||
// CHECK:STDERR: ┆
|
||||
// CHECK:STDERR: -> │ TakeConstConst(p);
|
||||
// CHECK:STDERR: · ┳
|
||||
// CHECK:STDERR: · ┗━━┫ error: cannot implicitly convert expression of type `X**`
|
||||
// CHECK:STDERR: · │ ┃ to `const (const X*)*`
|
||||
// CHECK:STDERR: · │ ┃ [ConversionFailure]
|
||||
// CHECK:STDERR: · ╰────┤ type `X**` does not implement interface
|
||||
// CHECK:STDERR: · │ `Core.ImplicitAs(const (const X*)*)`
|
||||
// CHECK:STDERR: · │ [MissingImplInMemberAccessInContext]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
TakeConstConst(p);
|
||||
//@dump-sem-ir-end
|
||||
@@ -75,9 +99,21 @@ fn NonConstNonConst(p: X**) {
|
||||
|
||||
fn ConstNonConst(p: const (X*)*) {
|
||||
//@dump-sem-ir-begin
|
||||
// CHECK:STDERR: fail_todo_nested_qualifiers.carbon:[[@LINE+4]]:18: error: cannot implicitly convert expression of type `const (X*)*` to `const (const X*)*` [ConversionFailure]
|
||||
// CHECK:STDERR: fail_todo_nested_qualifiers.carbon:[[@LINE+3]]:18: note: type `const (X*)*` does not implement interface `Core.ImplicitAs(const (const X*)*)` [MissingImplInMemberAccessInContext]
|
||||
// CHECK:STDERR: fail_todo_nested_qualifiers.carbon:[[@LINE-18]]:19-38: note: initializing function parameter [InCallToFunctionParam]
|
||||
// CHECK:STDERR: ╭─┤ fail_todo_nested_qualifiers.carbon:[[@LINE+16]]:18
|
||||
// CHECK:STDERR: │ fn TakeConstConst(p: const (const X*)*);
|
||||
// CHECK:STDERR: · ──────────┬─────────
|
||||
// CHECK:STDERR: · ╰──┤ initializing function parameter
|
||||
// CHECK:STDERR: · │ [InCallToFunctionParam]
|
||||
// CHECK:STDERR: ┆
|
||||
// CHECK:STDERR: -> │ TakeConstConst(p);
|
||||
// CHECK:STDERR: · ┳
|
||||
// CHECK:STDERR: · ┗━━┫ error: cannot implicitly convert expression of type
|
||||
// CHECK:STDERR: · │ ┃ `const (X*)*` to `const (const X*)*`
|
||||
// CHECK:STDERR: · │ ┃ [ConversionFailure]
|
||||
// CHECK:STDERR: · ╰────┤ type `const (X*)*` does not implement interface
|
||||
// CHECK:STDERR: · │ `Core.ImplicitAs(const (const X*)*)`
|
||||
// CHECK:STDERR: · │ [MissingImplInMemberAccessInContext]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
TakeConstConst(p);
|
||||
//@dump-sem-ir-end
|
||||
@@ -91,9 +127,23 @@ class X {}
|
||||
|
||||
fn TakeNonConstConst(p: (const X*)*);
|
||||
|
||||
// CHECK:STDERR: fail_nested_added_qualifiers.carbon:[[@LINE+4]]:49: error: cannot implicitly convert expression of type `X**` to `const X**` [ConversionFailure]
|
||||
// CHECK:STDERR: fail_nested_added_qualifiers.carbon:[[@LINE+3]]:49: note: type `X**` does not implement interface `Core.ImplicitAs(const X**)` [MissingImplInMemberAccessInContext]
|
||||
// CHECK:STDERR: fail_nested_added_qualifiers.carbon:[[@LINE-4]]:22-35: note: initializing function parameter [InCallToFunctionParam]
|
||||
// CHECK:STDERR: ╭─┤ fail_nested_added_qualifiers.carbon:[[@LINE+18]]:49
|
||||
// CHECK:STDERR: │ fn TakeNonConstConst(p: (const X*)*);
|
||||
// CHECK:STDERR: · ───────┬──────
|
||||
// CHECK:STDERR: · ╰──┤ initializing function parameter
|
||||
// CHECK:STDERR: · │ [InCallToFunctionParam]
|
||||
// CHECK:STDERR: ┆
|
||||
// CHECK:STDERR: -> │ fn NonConstNonConst(p: X**) { TakeNonConstConst(p); }
|
||||
// CHECK:STDERR: · ┳
|
||||
// CHECK:STDERR: · ┗━━┫ error: cannot implicitly
|
||||
// CHECK:STDERR: · │ ┃ convert expression
|
||||
// CHECK:STDERR: · │ ┃ of type `X**` to
|
||||
// CHECK:STDERR: · │ ┃ `const X**`
|
||||
// CHECK:STDERR: · │ ┃ [ConversionFailure]
|
||||
// CHECK:STDERR: · ╭───────────────────────────────────────────────╯
|
||||
// CHECK:STDERR: · │ type `X**` does not implement interface `Core.ImplicitAs(const X**)`
|
||||
// CHECK:STDERR: · │ [MissingImplInMemberAccessInContext]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
fn NonConstNonConst(p: X**) { TakeNonConstConst(p); }
|
||||
|
||||
@@ -170,7 +220,7 @@ fn NonConstNonConst(p: X**) { TakeNonConstConst(p); }
|
||||
// CHECK:STDOUT: !entry:
|
||||
// CHECK:STDOUT: %TakeConstConst.ref: %TakeConstConst.type = name_ref TakeConstConst, file.%TakeConstConst.decl [concrete = constants.%TakeConstConst]
|
||||
// CHECK:STDOUT: %p.ref: %ptr.9ae = name_ref p, %p
|
||||
// CHECK:STDOUT: %.loc16: %ptr.b53 = converted %p.ref, <error> [concrete = <error>]
|
||||
// CHECK:STDOUT: %.loc28: %ptr.b53 = converted %p.ref, <error> [concrete = <error>]
|
||||
// CHECK:STDOUT: %TakeConstConst.call: init %empty_tuple.type = call %TakeConstConst.ref(<error>)
|
||||
// CHECK:STDOUT: <elided>
|
||||
// CHECK:STDOUT: }
|
||||
@@ -179,7 +229,7 @@ fn NonConstNonConst(p: X**) { TakeNonConstConst(p); }
|
||||
// CHECK:STDOUT: !entry:
|
||||
// CHECK:STDOUT: %TakeConstConst.ref: %TakeConstConst.type = name_ref TakeConstConst, file.%TakeConstConst.decl [concrete = constants.%TakeConstConst]
|
||||
// CHECK:STDOUT: %p.ref: %ptr.060 = name_ref p, %p
|
||||
// CHECK:STDOUT: %.loc26: %ptr.b53 = converted %p.ref, <error> [concrete = <error>]
|
||||
// CHECK:STDOUT: %.loc50: %ptr.b53 = converted %p.ref, <error> [concrete = <error>]
|
||||
// CHECK:STDOUT: %TakeConstConst.call: init %empty_tuple.type = call %TakeConstConst.ref(<error>)
|
||||
// CHECK:STDOUT: <elided>
|
||||
// CHECK:STDOUT: }
|
||||
|
||||
@@ -13,12 +13,24 @@
|
||||
// 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+2]]:4-13: error: name `undeclared` not found [NameNotFound]
|
||||
// CHECK:STDERR: ╭─┤ fail_address_of_error.carbon:[[@LINE+6]]:4
|
||||
// CHECK:STDERR: -> │ &undeclared;
|
||||
// CHECK:STDERR: · ━━━━━┳━━━━
|
||||
// CHECK:STDERR: · ┗━━┫ error: name `undeclared` not found [NameNotFound]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
&undeclared;
|
||||
// CHECK:STDERR: fail_address_of_error.carbon:[[@LINE+4]]:6-15: error: name `undeclared` not found [NameNotFound]
|
||||
// CHECK:STDERR: ╭─┤ fail_address_of_error.carbon:[[@LINE+12]]:6
|
||||
// CHECK:STDERR: -> │ &(&undeclared);
|
||||
// CHECK:STDERR: · ━━━━━┳━━━━
|
||||
// CHECK:STDERR: · ┗━━┫ error: name `undeclared` not found [NameNotFound]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
// CHECK:STDERR: fail_address_of_error.carbon:[[@LINE+2]]:3: error: cannot take the address of non-reference expression [AddrOfNonRef]
|
||||
// CHECK:STDERR: ╭─┤ fail_address_of_error.carbon:[[@LINE+6]]:3
|
||||
// CHECK:STDERR: -> │ &(&undeclared);
|
||||
// CHECK:STDERR: · ┳
|
||||
// CHECK:STDERR: · ┗━━┫ error: cannot take the address of non-reference expression [AddrOfNonRef]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
&(&undeclared);
|
||||
}
|
||||
@@ -50,11 +62,11 @@ fn Test() {
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: fn @Test() {
|
||||
// CHECK:STDOUT: !entry:
|
||||
// CHECK:STDOUT: %undeclared.ref.loc18: <error> = name_ref undeclared, <error> [concrete = <error>]
|
||||
// CHECK:STDOUT: %addr.loc18: <error> = addr_of %undeclared.ref.loc18 [concrete = <error>]
|
||||
// CHECK:STDOUT: %undeclared.ref.loc23: <error> = name_ref undeclared, <error> [concrete = <error>]
|
||||
// CHECK:STDOUT: %addr.loc23_5: <error> = addr_of %undeclared.ref.loc23 [concrete = <error>]
|
||||
// CHECK:STDOUT: %addr.loc23_3: <error> = addr_of <error> [concrete = <error>]
|
||||
// CHECK:STDOUT: %undeclared.ref.loc22: <error> = name_ref undeclared, <error> [concrete = <error>]
|
||||
// CHECK:STDOUT: %addr.loc22: <error> = addr_of %undeclared.ref.loc22 [concrete = <error>]
|
||||
// CHECK:STDOUT: %undeclared.ref.loc35: <error> = name_ref undeclared, <error> [concrete = <error>]
|
||||
// CHECK:STDOUT: %addr.loc35_5: <error> = addr_of %undeclared.ref.loc35 [concrete = <error>]
|
||||
// CHECK:STDOUT: %addr.loc35_3: <error> = addr_of <error> [concrete = <error>]
|
||||
// CHECK:STDOUT: return
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
+72
-14
@@ -15,61 +15,119 @@ fn G() -> i32;
|
||||
fn H() -> {.a: i32};
|
||||
|
||||
fn AddressOfLiteral() {
|
||||
// CHECK:STDERR: fail_address_of_value.carbon:[[@LINE+2]]:3: error: cannot take the address of non-reference expression [AddrOfNonRef]
|
||||
// CHECK:STDERR: ╭─┤ fail_address_of_value.carbon:[[@LINE+6]]:3
|
||||
// CHECK:STDERR: -> │ &0;
|
||||
// CHECK:STDERR: · ┳
|
||||
// CHECK:STDERR: · ┗━━┫ error: cannot take the address of non-reference expression [AddrOfNonRef]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
&0;
|
||||
// CHECK:STDERR: fail_address_of_value.carbon:[[@LINE+2]]:3: error: cannot take the address of non-reference expression [AddrOfNonRef]
|
||||
// CHECK:STDERR: ╭─┤ fail_address_of_value.carbon:[[@LINE+6]]:3
|
||||
// CHECK:STDERR: -> │ &true;
|
||||
// CHECK:STDERR: · ┳
|
||||
// CHECK:STDERR: · ┗━━┫ error: cannot take the address of non-reference expression [AddrOfNonRef]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
&true;
|
||||
// CHECK:STDERR: fail_address_of_value.carbon:[[@LINE+2]]:3: error: cannot take the address of non-reference expression [AddrOfNonRef]
|
||||
// CHECK:STDERR: ╭─┤ fail_address_of_value.carbon:[[@LINE+6]]:3
|
||||
// CHECK:STDERR: -> │ &1.0;
|
||||
// CHECK:STDERR: · ┳
|
||||
// CHECK:STDERR: · ┗━━┫ error: cannot take the address of non-reference expression [AddrOfNonRef]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
&1.0;
|
||||
// CHECK:STDERR: fail_address_of_value.carbon:[[@LINE+2]]:3: error: cannot take the address of non-reference expression [AddrOfNonRef]
|
||||
// CHECK:STDERR: ╭─┤ fail_address_of_value.carbon:[[@LINE+6]]:3
|
||||
// CHECK:STDERR: -> │ &"Hello";
|
||||
// CHECK:STDERR: · ┳
|
||||
// CHECK:STDERR: · ┗━━┫ error: cannot take the address of non-reference expression [AddrOfNonRef]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
&"Hello";
|
||||
// CHECK:STDERR: fail_address_of_value.carbon:[[@LINE+2]]:3: error: cannot take the address of non-reference expression [AddrOfNonRef]
|
||||
// CHECK:STDERR: ╭─┤ fail_address_of_value.carbon:[[@LINE+6]]:3
|
||||
// CHECK:STDERR: -> │ &(1, 2);
|
||||
// CHECK:STDERR: · ┳
|
||||
// CHECK:STDERR: · ┗━━┫ error: cannot take the address of non-reference expression [AddrOfNonRef]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
&(1, 2);
|
||||
// CHECK:STDERR: fail_address_of_value.carbon:[[@LINE+2]]:3: error: cannot take the address of non-reference expression [AddrOfNonRef]
|
||||
// CHECK:STDERR: ╭─┤ fail_address_of_value.carbon:[[@LINE+6]]:3
|
||||
// CHECK:STDERR: -> │ &{.a = 5};
|
||||
// CHECK:STDERR: · ┳
|
||||
// CHECK:STDERR: · ┗━━┫ error: cannot take the address of non-reference expression [AddrOfNonRef]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
&{.a = 5};
|
||||
}
|
||||
|
||||
fn AddressOfOperator() {
|
||||
// CHECK:STDERR: fail_address_of_value.carbon:[[@LINE+2]]:3: error: cannot take the address of non-reference expression [AddrOfNonRef]
|
||||
// CHECK:STDERR: ╭─┤ fail_address_of_value.carbon:[[@LINE+6]]:3
|
||||
// CHECK:STDERR: -> │ &(true and false);
|
||||
// CHECK:STDERR: · ┳
|
||||
// CHECK:STDERR: · ┗━━┫ error: cannot take the address of non-reference expression [AddrOfNonRef]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
&(true and false);
|
||||
// CHECK:STDERR: fail_address_of_value.carbon:[[@LINE+2]]:3: error: cannot take the address of non-reference expression [AddrOfNonRef]
|
||||
// CHECK:STDERR: ╭─┤ fail_address_of_value.carbon:[[@LINE+6]]:3
|
||||
// CHECK:STDERR: -> │ &H().a;
|
||||
// CHECK:STDERR: · ┳
|
||||
// CHECK:STDERR: · ┗━━┫ error: cannot take the address of non-reference expression [AddrOfNonRef]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
&H().a;
|
||||
// CHECK:STDERR: fail_address_of_value.carbon:[[@LINE+2]]:3: error: cannot take the address of non-reference expression [AddrOfNonRef]
|
||||
// CHECK:STDERR: ╭─┤ fail_address_of_value.carbon:[[@LINE+6]]:3
|
||||
// CHECK:STDERR: -> │ &(not true);
|
||||
// CHECK:STDERR: · ┳
|
||||
// CHECK:STDERR: · ┗━━┫ error: cannot take the address of non-reference expression [AddrOfNonRef]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
&(not true);
|
||||
}
|
||||
|
||||
fn AddressOfCall() {
|
||||
// CHECK:STDERR: fail_address_of_value.carbon:[[@LINE+2]]:3: error: cannot take the address of non-reference expression [AddrOfNonRef]
|
||||
// CHECK:STDERR: ╭─┤ fail_address_of_value.carbon:[[@LINE+6]]:3
|
||||
// CHECK:STDERR: -> │ &G();
|
||||
// CHECK:STDERR: · ┳
|
||||
// CHECK:STDERR: · ┗━━┫ error: cannot take the address of non-reference expression [AddrOfNonRef]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
&G();
|
||||
}
|
||||
|
||||
fn AddressOfType() {
|
||||
// CHECK:STDERR: fail_address_of_value.carbon:[[@LINE+2]]:3: error: cannot take the address of non-reference expression [AddrOfNonRef]
|
||||
// CHECK:STDERR: ╭─┤ fail_address_of_value.carbon:[[@LINE+6]]:3
|
||||
// CHECK:STDERR: -> │ &i32;
|
||||
// CHECK:STDERR: · ┳
|
||||
// CHECK:STDERR: · ┗━━┫ error: cannot take the address of non-reference expression [AddrOfNonRef]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
&i32;
|
||||
// CHECK:STDERR: fail_address_of_value.carbon:[[@LINE+2]]:3: error: cannot take the address of non-reference expression [AddrOfNonRef]
|
||||
// CHECK:STDERR: ╭─┤ fail_address_of_value.carbon:[[@LINE+6]]:3
|
||||
// CHECK:STDERR: -> │ &(const i32*);
|
||||
// CHECK:STDERR: · ┳
|
||||
// CHECK:STDERR: · ┗━━┫ error: cannot take the address of non-reference expression [AddrOfNonRef]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
&(const i32*);
|
||||
}
|
||||
|
||||
fn AddressOfTupleElementValue() {
|
||||
// CHECK:STDERR: fail_address_of_value.carbon:[[@LINE+2]]:3: error: cannot take the address of non-reference expression [AddrOfNonRef]
|
||||
// CHECK:STDERR: ╭─┤ fail_address_of_value.carbon:[[@LINE+6]]:3
|
||||
// CHECK:STDERR: -> │ &((1, 2).0);
|
||||
// CHECK:STDERR: · ┳
|
||||
// CHECK:STDERR: · ┗━━┫ error: cannot take the address of non-reference expression [AddrOfNonRef]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
&((1, 2).0);
|
||||
}
|
||||
|
||||
fn AddressOfParam(param: i32) {
|
||||
// CHECK:STDERR: fail_address_of_value.carbon:[[@LINE+2]]:33: error: cannot take the address of non-reference expression [AddrOfNonRef]
|
||||
// CHECK:STDERR: ╭─┤ fail_address_of_value.carbon:[[@LINE+8]]:33
|
||||
// CHECK:STDERR: -> │ var unused param_addr: i32* = ¶m;
|
||||
// CHECK:STDERR: · ┳
|
||||
// CHECK:STDERR: · ┗━━┫ error: cannot take the address of
|
||||
// CHECK:STDERR: · ┃ non-reference expression
|
||||
// CHECK:STDERR: · ┃ [AddrOfNonRef]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
var unused param_addr: i32* = ¶m;
|
||||
}
|
||||
+16
-8
@@ -12,10 +12,18 @@
|
||||
// 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+2]]:15-24: error: name `undeclared` not found [NameNotFound]
|
||||
// CHECK:STDERR: ╭─┤ fail_deref_error.carbon:[[@LINE+6]]:15
|
||||
// CHECK:STDERR: -> │ let n: i32 = *undeclared;
|
||||
// CHECK:STDERR: · ━━━━━┳━━━━
|
||||
// CHECK:STDERR: · ┗━━┫ error: name `undeclared` not found [NameNotFound]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
let n: i32 = *undeclared;
|
||||
// CHECK:STDERR: fail_deref_error.carbon:[[@LINE+2]]:15-24: error: name `undeclared` not found [NameNotFound]
|
||||
// CHECK:STDERR: ╭─┤ fail_deref_error.carbon:[[@LINE+6]]:15
|
||||
// CHECK:STDERR: -> │ let n2: i32 = undeclared->foo;
|
||||
// CHECK:STDERR: · ━━━━━┳━━━━
|
||||
// CHECK:STDERR: · ┗━━┫ error: name `undeclared` not found [NameNotFound]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
let n2: i32 = undeclared->foo;
|
||||
|
||||
@@ -49,12 +57,12 @@ let n2: i32 = undeclared->foo;
|
||||
// CHECK:STDOUT: .n2 = %n2
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: %Core.import = import Core
|
||||
// CHECK:STDOUT: %i32.loc17: type = type_literal constants.%i32 [concrete = constants.%i32]
|
||||
// CHECK:STDOUT: %i32.loc21: type = type_literal constants.%i32 [concrete = constants.%i32]
|
||||
// CHECK:STDOUT: %n: %i32 = wrapper_binding n, <error> [concrete = <error>]
|
||||
// CHECK:STDOUT: name_binding_decl {
|
||||
// CHECK:STDOUT: %n.patt: %pattern_type.d94 = value_binding_pattern n [concrete = constants.%n.patt]
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: %i32.loc20: type = type_literal constants.%i32 [concrete = constants.%i32]
|
||||
// CHECK:STDOUT: %i32.loc28: type = type_literal constants.%i32 [concrete = constants.%i32]
|
||||
// CHECK:STDOUT: %n2: %i32 = wrapper_binding n2, <error> [concrete = <error>]
|
||||
// CHECK:STDOUT: name_binding_decl {
|
||||
// CHECK:STDOUT: %n2.patt: %pattern_type.d94 = value_binding_pattern n2 [concrete = constants.%n2.patt]
|
||||
@@ -63,10 +71,10 @@ let n2: i32 = undeclared->foo;
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: fn @__global_init() {
|
||||
// CHECK:STDOUT: !entry:
|
||||
// CHECK:STDOUT: %undeclared.ref.loc17: <error> = name_ref undeclared, <error> [concrete = <error>]
|
||||
// CHECK:STDOUT: %.loc17: ref <error> = deref <error> [concrete = <error>]
|
||||
// CHECK:STDOUT: %undeclared.ref.loc20: <error> = name_ref undeclared, <error> [concrete = <error>]
|
||||
// CHECK:STDOUT: %.loc20: ref <error> = deref <error> [concrete = <error>]
|
||||
// CHECK:STDOUT: %undeclared.ref.loc21: <error> = name_ref undeclared, <error> [concrete = <error>]
|
||||
// CHECK:STDOUT: %.loc21: ref <error> = deref <error> [concrete = <error>]
|
||||
// CHECK:STDOUT: %undeclared.ref.loc28: <error> = name_ref undeclared, <error> [concrete = <error>]
|
||||
// CHECK:STDOUT: %.loc28: ref <error> = deref <error> [concrete = <error>]
|
||||
// CHECK:STDOUT: %foo.ref: <error> = name_ref foo, <error> [concrete = <error>]
|
||||
// CHECK:STDOUT: return
|
||||
// CHECK:STDOUT: }
|
||||
|
||||
+16
-6
@@ -13,10 +13,20 @@
|
||||
// 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+2]]:3: error: cannot dereference operand of non-pointer type `<type of A>` [DerefOfNonPointer]
|
||||
// CHECK:STDERR: ╭─┤ fail_deref_function.carbon:[[@LINE+7]]:3
|
||||
// CHECK:STDERR: -> │ *A;
|
||||
// CHECK:STDERR: · ┳
|
||||
// CHECK:STDERR: · ┗━━┫ error: cannot dereference operand of non-pointer type `<type of A>`
|
||||
// CHECK:STDERR: · ┃ [DerefOfNonPointer]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
*A;
|
||||
// CHECK:STDERR: fail_deref_function.carbon:[[@LINE+2]]:4-5: error: cannot apply `->` operator to non-pointer type `<type of A>` [ArrowOperatorOfNonPointer]
|
||||
// CHECK:STDERR: ╭─┤ fail_deref_function.carbon:[[@LINE+7]]:4
|
||||
// CHECK:STDERR: -> │ A->foo;
|
||||
// CHECK:STDERR: · ━┳
|
||||
// CHECK:STDERR: · ┗━━┫ error: cannot apply `->` operator to non-pointer type `<type of A>`
|
||||
// CHECK:STDERR: · ┃ [ArrowOperatorOfNonPointer]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
A->foo;
|
||||
}
|
||||
@@ -47,10 +57,10 @@ fn A() {
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: fn @A() {
|
||||
// CHECK:STDOUT: !entry:
|
||||
// CHECK:STDOUT: %A.ref.loc18: %A.type = name_ref A, file.%A.decl [concrete = constants.%A]
|
||||
// CHECK:STDOUT: %.loc18: ref <error> = deref %A.ref.loc18 [concrete = <error>]
|
||||
// CHECK:STDOUT: %A.ref.loc21: %A.type = name_ref A, file.%A.decl [concrete = constants.%A]
|
||||
// CHECK:STDOUT: %.loc21: ref <error> = deref %A.ref.loc21 [concrete = <error>]
|
||||
// CHECK:STDOUT: %A.ref.loc23: %A.type = name_ref A, file.%A.decl [concrete = constants.%A]
|
||||
// CHECK:STDOUT: %.loc23: ref <error> = deref %A.ref.loc23 [concrete = <error>]
|
||||
// CHECK:STDOUT: %A.ref.loc31: %A.type = name_ref A, file.%A.decl [concrete = constants.%A]
|
||||
// CHECK:STDOUT: %.loc31: ref <error> = deref %A.ref.loc31 [concrete = <error>]
|
||||
// CHECK:STDOUT: %foo.ref: <error> = name_ref foo, <error> [concrete = <error>]
|
||||
// CHECK:STDOUT: return
|
||||
// CHECK:STDOUT: }
|
||||
|
||||
@@ -15,10 +15,18 @@
|
||||
namespace A;
|
||||
|
||||
fn F() {
|
||||
// CHECK:STDERR: fail_deref_namespace.carbon:[[@LINE+2]]:4: error: expression cannot be used as a value [UseOfNonExprAsValue]
|
||||
// CHECK:STDERR: ╭─┤ fail_deref_namespace.carbon:[[@LINE+6]]:4
|
||||
// CHECK:STDERR: -> │ *A;
|
||||
// CHECK:STDERR: · ┳
|
||||
// CHECK:STDERR: · ┗━━┫ error: expression cannot be used as a value [UseOfNonExprAsValue]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
*A;
|
||||
// CHECK:STDERR: fail_deref_namespace.carbon:[[@LINE+2]]:3: error: expression cannot be used as a value [UseOfNonExprAsValue]
|
||||
// CHECK:STDERR: ╭─┤ fail_deref_namespace.carbon:[[@LINE+6]]:3
|
||||
// CHECK:STDERR: -> │ A->foo;
|
||||
// CHECK:STDERR: · ┳
|
||||
// CHECK:STDERR: · ┗━━┫ error: expression cannot be used as a value [UseOfNonExprAsValue]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
A->foo;
|
||||
}
|
||||
@@ -51,10 +59,10 @@ fn F() {
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: fn @F() {
|
||||
// CHECK:STDOUT: !entry:
|
||||
// CHECK:STDOUT: %A.ref.loc20: <namespace> = name_ref A, file.%A [concrete = file.%A]
|
||||
// CHECK:STDOUT: %.loc20: ref <error> = deref <error> [concrete = <error>]
|
||||
// CHECK:STDOUT: %A.ref.loc23: <namespace> = name_ref A, file.%A [concrete = file.%A]
|
||||
// CHECK:STDOUT: %.loc23: ref <error> = deref <error> [concrete = <error>]
|
||||
// CHECK:STDOUT: %A.ref.loc24: <namespace> = name_ref A, file.%A [concrete = file.%A]
|
||||
// CHECK:STDOUT: %.loc24: ref <error> = deref <error> [concrete = <error>]
|
||||
// CHECK:STDOUT: %A.ref.loc31: <namespace> = name_ref A, file.%A [concrete = file.%A]
|
||||
// CHECK:STDOUT: %.loc31: ref <error> = deref <error> [concrete = <error>]
|
||||
// CHECK:STDOUT: %foo.ref: <error> = name_ref foo, <error> [concrete = <error>]
|
||||
// CHECK:STDOUT: return
|
||||
// CHECK:STDOUT: }
|
||||
|
||||
+59
-29
@@ -13,22 +13,52 @@
|
||||
// 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+2]]:3: error: cannot dereference operand of non-pointer type `i32` [DerefOfNonPointer]
|
||||
// CHECK:STDERR: ╭─┤ fail_deref_not_pointer.carbon:[[@LINE+7]]:3
|
||||
// CHECK:STDERR: -> │ *n;
|
||||
// CHECK:STDERR: · ┳
|
||||
// CHECK:STDERR: · ┗━━┫ error: cannot dereference operand of non-pointer type `i32`
|
||||
// CHECK:STDERR: · ┃ [DerefOfNonPointer]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
*n;
|
||||
// CHECK:STDERR: fail_deref_not_pointer.carbon:[[@LINE+2]]:4-5: error: cannot apply `->` operator to non-pointer type `i32` [ArrowOperatorOfNonPointer]
|
||||
// CHECK:STDERR: ╭─┤ fail_deref_not_pointer.carbon:[[@LINE+7]]:4
|
||||
// CHECK:STDERR: -> │ n->foo;
|
||||
// CHECK:STDERR: · ━┳
|
||||
// CHECK:STDERR: · ┗━━┫ error: cannot apply `->` operator to non-pointer type `i32`
|
||||
// CHECK:STDERR: · ┃ [ArrowOperatorOfNonPointer]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
n->foo;
|
||||
// CHECK:STDERR: fail_deref_not_pointer.carbon:[[@LINE+2]]:3: error: cannot dereference operand of non-pointer type `()` [DerefOfNonPointer]
|
||||
// CHECK:STDERR: ╭─┤ fail_deref_not_pointer.carbon:[[@LINE+7]]:3
|
||||
// CHECK:STDERR: -> │ *();
|
||||
// CHECK:STDERR: · ┳
|
||||
// CHECK:STDERR: · ┗━━┫ error: cannot dereference operand of non-pointer type `()`
|
||||
// CHECK:STDERR: · ┃ [DerefOfNonPointer]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
*();
|
||||
// CHECK:STDERR: fail_deref_not_pointer.carbon:[[@LINE+2]]:5-6: error: cannot apply `->` operator to non-pointer type `()` [ArrowOperatorOfNonPointer]
|
||||
// CHECK:STDERR: ╭─┤ fail_deref_not_pointer.carbon:[[@LINE+7]]:5
|
||||
// CHECK:STDERR: -> │ ()->foo;
|
||||
// CHECK:STDERR: · ━┳
|
||||
// CHECK:STDERR: · ┗━━┫ error: cannot apply `->` operator to non-pointer type `()`
|
||||
// CHECK:STDERR: · ┃ [ArrowOperatorOfNonPointer]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
()->foo;
|
||||
// CHECK:STDERR: fail_deref_not_pointer.carbon:[[@LINE+2]]:3: error: cannot dereference operand of non-pointer type `{}` [DerefOfNonPointer]
|
||||
// CHECK:STDERR: ╭─┤ fail_deref_not_pointer.carbon:[[@LINE+7]]:3
|
||||
// CHECK:STDERR: -> │ *{};
|
||||
// CHECK:STDERR: · ┳
|
||||
// CHECK:STDERR: · ┗━━┫ error: cannot dereference operand of non-pointer type `{}`
|
||||
// CHECK:STDERR: · ┃ [DerefOfNonPointer]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
*{};
|
||||
// CHECK:STDERR: fail_deref_not_pointer.carbon:[[@LINE+2]]:5-6: error: cannot apply `->` operator to non-pointer type `{}` [ArrowOperatorOfNonPointer]
|
||||
// CHECK:STDERR: ╭─┤ fail_deref_not_pointer.carbon:[[@LINE+7]]:5
|
||||
// CHECK:STDERR: -> │ {}->foo;
|
||||
// CHECK:STDERR: · ━┳
|
||||
// CHECK:STDERR: · ┗━━┫ error: cannot apply `->` operator to non-pointer type `{}`
|
||||
// CHECK:STDERR: · ┃ [ArrowOperatorOfNonPointer]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
{}->foo;
|
||||
}
|
||||
@@ -79,29 +109,29 @@ fn Deref(n: i32) {
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: fn @Deref(%n.param: %i32) {
|
||||
// CHECK:STDOUT: !entry:
|
||||
// CHECK:STDOUT: %n.ref.loc18: %i32 = name_ref n, %n
|
||||
// CHECK:STDOUT: %.loc18: ref <error> = deref %n.ref.loc18
|
||||
// CHECK:STDOUT: %n.ref.loc21: %i32 = name_ref n, %n
|
||||
// CHECK:STDOUT: %.loc21: ref <error> = deref %n.ref.loc21
|
||||
// CHECK:STDOUT: %foo.ref.loc21: <error> = name_ref foo, <error> [concrete = <error>]
|
||||
// CHECK:STDOUT: %.loc24_5.1: %empty_tuple.type = tuple_literal () [concrete = constants.%empty_tuple]
|
||||
// CHECK:STDOUT: %empty_tuple.loc24: %empty_tuple.type = tuple_value () [concrete = constants.%empty_tuple]
|
||||
// CHECK:STDOUT: %.loc24_5.2: %empty_tuple.type = converted %.loc24_5.1, %empty_tuple.loc24 [concrete = constants.%empty_tuple]
|
||||
// CHECK:STDOUT: %.loc24_3: ref <error> = deref %.loc24_5.2 [concrete = <error>]
|
||||
// CHECK:STDOUT: %.loc27_4.1: %empty_tuple.type = tuple_literal () [concrete = constants.%empty_tuple]
|
||||
// CHECK:STDOUT: %empty_tuple.loc27: %empty_tuple.type = tuple_value () [concrete = constants.%empty_tuple]
|
||||
// CHECK:STDOUT: %.loc27_4.2: %empty_tuple.type = converted %.loc27_4.1, %empty_tuple.loc27 [concrete = constants.%empty_tuple]
|
||||
// CHECK:STDOUT: %.loc27_5: ref <error> = deref %.loc27_4.2 [concrete = <error>]
|
||||
// CHECK:STDOUT: %foo.ref.loc27: <error> = name_ref foo, <error> [concrete = <error>]
|
||||
// CHECK:STDOUT: %.loc30_5.1: %empty_struct_type = struct_literal () [concrete = constants.%empty_struct]
|
||||
// CHECK:STDOUT: %empty_struct.loc30: %empty_struct_type = struct_value () [concrete = constants.%empty_struct]
|
||||
// CHECK:STDOUT: %.loc30_5.2: %empty_struct_type = converted %.loc30_5.1, %empty_struct.loc30 [concrete = constants.%empty_struct]
|
||||
// CHECK:STDOUT: %.loc30_3: ref <error> = deref %.loc30_5.2 [concrete = <error>]
|
||||
// CHECK:STDOUT: %.loc33_4.1: %empty_struct_type = struct_literal () [concrete = constants.%empty_struct]
|
||||
// CHECK:STDOUT: %empty_struct.loc33: %empty_struct_type = struct_value () [concrete = constants.%empty_struct]
|
||||
// CHECK:STDOUT: %.loc33_4.2: %empty_struct_type = converted %.loc33_4.1, %empty_struct.loc33 [concrete = constants.%empty_struct]
|
||||
// CHECK:STDOUT: %.loc33_5: ref <error> = deref %.loc33_4.2 [concrete = <error>]
|
||||
// CHECK:STDOUT: %foo.ref.loc33: <error> = name_ref foo, <error> [concrete = <error>]
|
||||
// CHECK:STDOUT: %n.ref.loc23: %i32 = name_ref n, %n
|
||||
// CHECK:STDOUT: %.loc23: ref <error> = deref %n.ref.loc23
|
||||
// CHECK:STDOUT: %n.ref.loc31: %i32 = name_ref n, %n
|
||||
// CHECK:STDOUT: %.loc31: ref <error> = deref %n.ref.loc31
|
||||
// CHECK:STDOUT: %foo.ref.loc31: <error> = name_ref foo, <error> [concrete = <error>]
|
||||
// CHECK:STDOUT: %.loc39_5.1: %empty_tuple.type = tuple_literal () [concrete = constants.%empty_tuple]
|
||||
// CHECK:STDOUT: %empty_tuple.loc39: %empty_tuple.type = tuple_value () [concrete = constants.%empty_tuple]
|
||||
// CHECK:STDOUT: %.loc39_5.2: %empty_tuple.type = converted %.loc39_5.1, %empty_tuple.loc39 [concrete = constants.%empty_tuple]
|
||||
// CHECK:STDOUT: %.loc39_3: ref <error> = deref %.loc39_5.2 [concrete = <error>]
|
||||
// CHECK:STDOUT: %.loc47_4.1: %empty_tuple.type = tuple_literal () [concrete = constants.%empty_tuple]
|
||||
// CHECK:STDOUT: %empty_tuple.loc47: %empty_tuple.type = tuple_value () [concrete = constants.%empty_tuple]
|
||||
// CHECK:STDOUT: %.loc47_4.2: %empty_tuple.type = converted %.loc47_4.1, %empty_tuple.loc47 [concrete = constants.%empty_tuple]
|
||||
// CHECK:STDOUT: %.loc47_5: ref <error> = deref %.loc47_4.2 [concrete = <error>]
|
||||
// CHECK:STDOUT: %foo.ref.loc47: <error> = name_ref foo, <error> [concrete = <error>]
|
||||
// CHECK:STDOUT: %.loc55_5.1: %empty_struct_type = struct_literal () [concrete = constants.%empty_struct]
|
||||
// CHECK:STDOUT: %empty_struct.loc55: %empty_struct_type = struct_value () [concrete = constants.%empty_struct]
|
||||
// CHECK:STDOUT: %.loc55_5.2: %empty_struct_type = converted %.loc55_5.1, %empty_struct.loc55 [concrete = constants.%empty_struct]
|
||||
// CHECK:STDOUT: %.loc55_3: ref <error> = deref %.loc55_5.2 [concrete = <error>]
|
||||
// CHECK:STDOUT: %.loc63_4.1: %empty_struct_type = struct_literal () [concrete = constants.%empty_struct]
|
||||
// CHECK:STDOUT: %empty_struct.loc63: %empty_struct_type = struct_value () [concrete = constants.%empty_struct]
|
||||
// CHECK:STDOUT: %.loc63_4.2: %empty_struct_type = converted %.loc63_4.1, %empty_struct.loc63 [concrete = constants.%empty_struct]
|
||||
// CHECK:STDOUT: %.loc63_5: ref <error> = deref %.loc63_4.2 [concrete = <error>]
|
||||
// CHECK:STDOUT: %foo.ref.loc63: <error> = name_ref foo, <error> [concrete = <error>]
|
||||
// CHECK:STDOUT: return
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
+18
-7
@@ -12,11 +12,22 @@
|
||||
// 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+3]]:8: error: cannot dereference operand of non-pointer type `type` [DerefOfNonPointer]
|
||||
// CHECK:STDERR: fail_deref_type.carbon:[[@LINE+2]]:8: note: to form a pointer type, write the `*` after the pointee type [DerefOfType]
|
||||
// CHECK:STDERR: ╭─┤ fail_deref_type.carbon:[[@LINE+9]]:8
|
||||
// CHECK:STDERR: -> │ var p: *i32;
|
||||
// CHECK:STDERR: · ┳
|
||||
// CHECK:STDERR: · ┗━━┫ error: cannot dereference operand of non-pointer type `type`
|
||||
// CHECK:STDERR: · │ ┃ [DerefOfNonPointer]
|
||||
// CHECK:STDERR: · ╰────┤ to form a pointer type, write the `*` after the pointee type
|
||||
// CHECK:STDERR: · │ [DerefOfType]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
var p: *i32;
|
||||
// CHECK:STDERR: fail_deref_type.carbon:[[@LINE+2]]:12-13: error: cannot apply `->` operator to non-pointer type `type` [ArrowOperatorOfNonPointer]
|
||||
// CHECK:STDERR: ╭─┤ fail_deref_type.carbon:[[@LINE+7]]:12
|
||||
// CHECK:STDERR: -> │ var p2: i32->foo;
|
||||
// CHECK:STDERR: · ━┳
|
||||
// CHECK:STDERR: · ┗━━┫ error: cannot apply `->` operator to non-pointer type `type`
|
||||
// CHECK:STDERR: · ┃ [ArrowOperatorOfNonPointer]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
var p2: i32->foo;
|
||||
|
||||
@@ -48,8 +59,8 @@ var p2: i32->foo;
|
||||
// CHECK:STDOUT: %Core.import = import Core
|
||||
// CHECK:STDOUT: %p.var: ref <error> = var_storage %p.var_patt [concrete = <error>]
|
||||
// CHECK:STDOUT: %.1: <error> = splice_block <error> [concrete = <error>] {
|
||||
// CHECK:STDOUT: %i32.loc18: type = type_literal constants.%i32 [concrete = constants.%i32]
|
||||
// CHECK:STDOUT: %.loc18: ref <error> = deref %i32.loc18 [concrete = <error>]
|
||||
// CHECK:STDOUT: %i32.loc24: type = type_literal constants.%i32 [concrete = constants.%i32]
|
||||
// CHECK:STDOUT: %.loc24: ref <error> = deref %i32.loc24 [concrete = <error>]
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: %p: <error> = wrapper_binding p, <error> [concrete = <error>]
|
||||
// CHECK:STDOUT: name_binding_decl {
|
||||
@@ -58,8 +69,8 @@ var p2: i32->foo;
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: %p2.var: ref <error> = var_storage %p2.var_patt [concrete = <error>]
|
||||
// CHECK:STDOUT: %.2: <error> = splice_block <error> [concrete = <error>] {
|
||||
// CHECK:STDOUT: %i32.loc21: type = type_literal constants.%i32 [concrete = constants.%i32]
|
||||
// CHECK:STDOUT: %.loc21: ref <error> = deref %i32.loc21 [concrete = <error>]
|
||||
// CHECK:STDOUT: %i32.loc32: type = type_literal constants.%i32 [concrete = constants.%i32]
|
||||
// CHECK:STDOUT: %.loc32: ref <error> = deref %i32.loc32 [concrete = <error>]
|
||||
// CHECK:STDOUT: %foo.ref: <error> = name_ref foo, <error> [concrete = <error>]
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: %p2: <error> = wrapper_binding p2, <error> [concrete = <error>]
|
||||
|
||||
+11
-3
@@ -13,8 +13,16 @@
|
||||
// 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+3]]:3-11: error: cannot implicitly convert expression of type `const {}*` to `const ({}*)` [ConversionFailure]
|
||||
// CHECK:STDERR: fail_type_mismatch.carbon:[[@LINE+2]]:3-11: note: type `const {}*` does not implement interface `Core.ImplicitAs(const ({}*))` [MissingImplInMemberAccessInContext]
|
||||
// CHECK:STDERR: ╭─┤ fail_type_mismatch.carbon:[[@LINE+11]]:3
|
||||
// CHECK:STDERR: -> │ return p;
|
||||
// CHECK:STDERR: · ┳━━━━━━━━
|
||||
// CHECK:STDERR: · ┗━━┫ error: cannot implicitly convert expression of type `const {}*` to
|
||||
// CHECK:STDERR: · │ ┃ `const ({}*)`
|
||||
// CHECK:STDERR: · │ ┃ [ConversionFailure]
|
||||
// CHECK:STDERR: · ╰────┤ type `const {}*` does not implement interface
|
||||
// CHECK:STDERR: · │ `Core.ImplicitAs(const ({}*))`
|
||||
// CHECK:STDERR: · │ [MissingImplInMemberAccessInContext]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
return p;
|
||||
}
|
||||
@@ -84,7 +92,7 @@ fn ConstMismatch(p: const {}*) -> const ({}*) {
|
||||
// CHECK:STDOUT: fn @ConstMismatch(%p.param: %ptr.bf9) -> out %return.param: %const.987 {
|
||||
// CHECK:STDOUT: !entry:
|
||||
// CHECK:STDOUT: %p.ref: %ptr.bf9 = name_ref p, %p
|
||||
// CHECK:STDOUT: %.loc19: %const.987 = converted %p.ref, <error> [concrete = <error>]
|
||||
// CHECK:STDOUT: %.loc27: %const.987 = converted %p.ref, <error> [concrete = <error>]
|
||||
// CHECK:STDOUT: return <error>
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
Reference in new issue
Block a user