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:
Chandler Carruth authored and GitHub committed 2026-11-05 07:19:59 +00:00
1 parent 0b7059a360
commit d0badecd2a
888 files changed
+39731 -12799

No files matched your search

@@ -24,10 +24,22 @@ class B {
inline Cpp '''
void F() {
auto b = Carbon::B::Make();
// CHECK:STDERR: fail_access_exported_private_var.carbon:[[@LINE+5]]:5: error: 'a' is a private member of 'Carbon::Main::B' [CppInteropParseError]
// CHECK:STDERR: fail_access_exported_private_var.carbon:[[@LINE-7]]:16: note: implicitly declared private here [CppInteropParseNote]
// CHECK:STDERR: ╭─┤ fail_access_exported_private_var.carbon:[[@LINE+17]]:5
// CHECK:STDERR: │ private var a: A = {};
// CHECK:STDERR: · ┬
// CHECK:STDERR: · ╰──┤ implicitly declared private here [CppInteropParseNote]
// CHECK:STDERR: ┆
// CHECK:STDERR: -> │ b.a;
// CHECK:STDERR: · ┳
// CHECK:STDERR: · ┗━━┫ error: 'a' is a private member of 'Carbon::Main::B'
// CHECK:STDERR: · ┃ [CppInteropParseError]
// CHECK:STDERR: ╰────
// CHECK:STDERR:
// CHECK:STDERR: fail_access_exported_private_var.carbon:[[@LINE+2]]:5: warning: expression result unused [CppInteropParseWarning]
// CHECK:STDERR: ╭─┤ fail_access_exported_private_var.carbon:[[@LINE+6]]:5
// CHECK:STDERR: -> │ b.a;
// CHECK:STDERR: · ─ ┳
// CHECK:STDERR: · ┗━━┫ warning: expression result unused [CppInteropParseWarning]
// CHECK:STDERR: ╰────
// CHECK:STDERR:
b.a;
}
@@ -47,8 +59,16 @@ class B {
inline Cpp '''
void G() {
auto b = Carbon::B::Make();
// CHECK:STDERR: fail_access_exported_private_method.carbon:[[@LINE+3]]:5: error: 'F' is a private member of 'Carbon::Main::B' [CppInteropParseError]
// CHECK:STDERR: fail_access_exported_private_method.carbon:[[@LINE-7]]:18: note: implicitly declared private here [CppInteropParseNote]
// CHECK:STDERR: ╭─┤ fail_access_exported_private_method.carbon:[[@LINE+11]]:5
// CHECK:STDERR: │ private fn F() {}
// CHECK:STDERR: · ┬
// CHECK:STDERR: · ╰──┤ implicitly declared private here [CppInteropParseNote]
// CHECK:STDERR: ┆
// CHECK:STDERR: -> │ b.F();
// CHECK:STDERR: · ┳
// CHECK:STDERR: · ┗━━┫ error: 'F' is a private member of 'Carbon::Main::B'
// CHECK:STDERR: · ┃ [CppInteropParseError]
// CHECK:STDERR: ╰────
// CHECK:STDERR:
b.F();
}
@@ -71,10 +91,22 @@ fn MakeB() -> B(A) {
inline Cpp '''
void F() {
auto b = Carbon::MakeB();
// CHECK:STDERR: fail_access_exported_private_var_in_generic.carbon:[[@LINE+5]]:5: error: 'a' is a private member of 'Carbon::Main::B<Carbon::Main::A>' [CppInteropParseError]
// CHECK:STDERR: fail_access_exported_private_var_in_generic.carbon:[[@LINE-11]]:16: note: implicitly declared private here [CppInteropParseNote]
// CHECK:STDERR: ╭─┤ fail_access_exported_private_var_in_generic.carbon:[[@LINE+17]]:5
// CHECK:STDERR: │ private var a: A = {};
// CHECK:STDERR: · ┬
// CHECK:STDERR: · ╰──┤ implicitly declared private here [CppInteropParseNote]
// CHECK:STDERR: ┆
// CHECK:STDERR: -> │ b.a;
// CHECK:STDERR: · ┳
// CHECK:STDERR: · ┗━━┫ error: 'a' is a private member of 'Carbon::Main::B<Carbon::Main::A>'
// CHECK:STDERR: · ┃ [CppInteropParseError]
// CHECK:STDERR: ╰────
// CHECK:STDERR:
// CHECK:STDERR: fail_access_exported_private_var_in_generic.carbon:[[@LINE+2]]:5: warning: expression result unused [CppInteropParseWarning]
// CHECK:STDERR: ╭─┤ fail_access_exported_private_var_in_generic.carbon:[[@LINE+6]]:5
// CHECK:STDERR: -> │ b.a;
// CHECK:STDERR: · ─ ┳
// CHECK:STDERR: · ┗━━┫ warning: expression result unused [CppInteropParseWarning]
// CHECK:STDERR: ╰────
// CHECK:STDERR:
b.a;
}
@@ -88,7 +120,12 @@ class A {}
class B(T: type) {
// TODO: exporting of methods in generics is not yet supported.
// CHECK:STDERR: fail_todo_access_exported_private_method_in_generic.carbon:[[@LINE+2]]:3-18: error: semantics TODO: `non-class non-namespace name scope` [SemanticsTodo]
// CHECK:STDERR: ╭─┤ fail_todo_access_exported_private_method_in_generic.carbon:[[@LINE+7]]:3
// CHECK:STDERR: -> │ private fn F() {}
// CHECK:STDERR: · ━━━━━━━━┳━━━━━━━
// CHECK:STDERR: · ┗━━┫ error: semantics TODO: `non-class non-namespace name scope`
// CHECK:STDERR: · ┃ [SemanticsTodo]
// CHECK:STDERR: ╰────
// CHECK:STDERR:
private fn F() {}
}
@@ -101,7 +138,12 @@ inline Cpp '''
void F() {
auto b = Carbon::MakeB();
// TODO: this error should be that `F` is a private member of `B`.
// CHECK:STDERR: fail_todo_access_exported_private_method_in_generic.carbon:[[@LINE+2]]:5: error: no member named 'F' in 'Carbon::Main::B<Carbon::Main::A>' [CppInteropParseError]
// CHECK:STDERR: ╭─┤ fail_todo_access_exported_private_method_in_generic.carbon:[[@LINE+7]]:5
// CHECK:STDERR: -> │ b.F();
// CHECK:STDERR: · ─ ┳
// CHECK:STDERR: · ┗━━┫ error: no member named 'F' in 'Carbon::Main::B<Carbon::Main::A>'
// CHECK:STDERR: · ┃ [CppInteropParseError]
// CHECK:STDERR: ╰────
// CHECK:STDERR:
b.F();
}
+113 -17
View File
@@ -62,8 +62,16 @@ import Cpp;
class FinalClass {}
inline Cpp '''
// CHECK:STDERR: fail_derive_from_final.carbon:[[@LINE+3]]:12: error: base 'FinalClass' is marked 'final' [CppInteropParseError]
// CHECK:STDERR: fail_derive_from_final.carbon:[[@LINE-4]]:18: note: 'FinalClass' declared here [CppInteropParseNote]
// CHECK:STDERR: ╭─┤ fail_derive_from_final.carbon:[[@LINE+11]]:12
// CHECK:STDERR: │ class FinalClass {}
// CHECK:STDERR: · ┬
// CHECK:STDERR: · ╰──┤ 'FinalClass' declared here [CppInteropParseNote]
// CHECK:STDERR: ┆
// CHECK:STDERR: -> │ struct A : Carbon::FinalClass {};
// CHECK:STDERR: · ┳
// CHECK:STDERR: · ┗━━┫ error: base 'FinalClass' is marked 'final'
// CHECK:STDERR: · ┃ [CppInteropParseError]
// CHECK:STDERR: ╰────
// CHECK:STDERR:
struct A : Carbon::FinalClass {};
''';
@@ -80,16 +88,40 @@ struct VirtualDestructor {
};
''';
// CHECK:STDERR: fail_abstract.carbon:[[@LINE+3]]:1-34: error: cannot convert type `AbstractWithVdtor` into type implementing `Core.Destroy` [ConversionFailureTypeToFacet]
// CHECK:STDERR: min_prelude/parts/destroy.carbon:32:1-39: note: while deducing parameters of generic declared here [DeductionGenericHere]
// CHECK:STDERR: ╭─┤ fail_abstract.carbon:[[@LINE+14]]:1
// CHECK:STDERR: -> │ abstract class AbstractWithVdtor {
// CHECK:STDERR: · ┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// CHECK:STDERR: · ┗━━┫ error: cannot convert type `AbstractWithVdtor` into type implementing
// CHECK:STDERR: · ┃ `Core.Destroy`
// CHECK:STDERR: · ┃ [ConversionFailureTypeToFacet]
// CHECK:STDERR: ┆
// CHECK:STDERR: ├─┤ min_prelude/parts/destroy.carbon
// CHECK:STDERR: │ fn SelfDestruct[T: Destroy](ref t: T) {
// CHECK:STDERR: · ───────────────────┬───────────────────
// CHECK:STDERR: · ╰──┤ while deducing parameters of generic declared here
// CHECK:STDERR: · │ [DeductionGenericHere]
// CHECK:STDERR: ╰────
// CHECK:STDERR:
abstract class AbstractWithVdtor {
extend base: Cpp.VirtualDestructor;
}
inline Cpp '''
// CHECK:STDERR: fail_abstract.carbon:[[@LINE+3]]:27: error: variable type 'Carbon::AbstractWithVdtor' (aka 'Carbon::Main::AbstractWithVdtor') is an abstract class [CppInteropParseError]
// CHECK:STDERR: fail_abstract.carbon:[[@LINE-6]]:34: note: unimplemented pure virtual method '~AbstractWithVdtor' in 'AbstractWithVdtor' [CppInteropParseNote]
// CHECK:STDERR: ╭─┤ fail_abstract.carbon:[[@LINE+16]]:27
// CHECK:STDERR: │ abstract class AbstractWithVdtor {
// CHECK:STDERR: · ┬
// CHECK:STDERR: · ╰──┤ unimplemented pure virtual method
// CHECK:STDERR: · │ '~AbstractWithVdtor' in
// CHECK:STDERR: · │ 'AbstractWithVdtor'
// CHECK:STDERR: · │ [CppInteropParseNote]
// CHECK:STDERR: ┆
// CHECK:STDERR: -> │ Carbon::AbstractWithVdtor x;
// CHECK:STDERR: · ┳
// CHECK:STDERR: · ┗━━┫ error: variable type 'Carbon::AbstractWithVdtor'
// CHECK:STDERR: · ┃ (aka 'Carbon::Main::AbstractWithVdtor') is
// CHECK:STDERR: · ┃ an abstract class
// CHECK:STDERR: · ┃ [CppInteropParseError]
// CHECK:STDERR: ╰────
// CHECK:STDERR:
Carbon::AbstractWithVdtor x;
''';
@@ -101,10 +133,28 @@ import Cpp;
// TODO: Find a way to export this to C++ as an abstract class, despite not
// having a vptr.
// CHECK:STDERR: fail_todo_abstract_nonvirtual_dtor.carbon:[[@LINE+5]]:1-39: error: semantics TODO: `exporting abstract class with no abstract methods and non-virtual destructor to C++` [SemanticsTodo]
// CHECK:STDERR: ╭─┤ fail_todo_abstract_nonvirtual_dtor.carbon:[[@LINE+23]]:1
// CHECK:STDERR: -> │ abstract class AbstractNonvirtualDtor {}
// CHECK:STDERR: · ━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━
// CHECK:STDERR: · ┏━━━━━━━━━━━━━━━━━━┛
// CHECK:STDERR: · ┃ error: semantics TODO:
// CHECK:STDERR: · ┃ `exporting abstract class with no abstract methods and non-virtual destructor to C++`
// CHECK:STDERR: · ┃ [SemanticsTodo]
// CHECK:STDERR: ╰────
// CHECK:STDERR:
// CHECK:STDERR: fail_todo_abstract_nonvirtual_dtor.carbon:[[@LINE+3]]:1-39: error: cannot convert type `AbstractNonvirtualDtor` into type implementing `Core.Destroy` [ConversionFailureTypeToFacet]
// CHECK:STDERR: min_prelude/parts/destroy.carbon:32:1-39: note: while deducing parameters of generic declared here [DeductionGenericHere]
// CHECK:STDERR: ╭─┤ fail_todo_abstract_nonvirtual_dtor.carbon:[[@LINE+14]]:1
// CHECK:STDERR: -> │ abstract class AbstractNonvirtualDtor {}
// CHECK:STDERR: · ┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// CHECK:STDERR: · ┗━━┫ error: cannot convert type `AbstractNonvirtualDtor` into type implementing
// CHECK:STDERR: · ┃ `Core.Destroy`
// CHECK:STDERR: · ┃ [ConversionFailureTypeToFacet]
// CHECK:STDERR: ┆
// CHECK:STDERR: ├─┤ min_prelude/parts/destroy.carbon
// CHECK:STDERR: │ fn SelfDestruct[T: Destroy](ref t: T) {
// CHECK:STDERR: · ───────────────────┬───────────────────
// CHECK:STDERR: · ╰──┤ while deducing parameters of generic declared here
// CHECK:STDERR: · │ [DeductionGenericHere]
// CHECK:STDERR: ╰────
// CHECK:STDERR:
abstract class AbstractNonvirtualDtor {}
@@ -120,8 +170,19 @@ import Cpp;
// TODO: We should support generating a base subobject destructor for an
// abstract class, even though we refuse to generate a complete object
// destructor.
// CHECK:STDERR: fail_todo_abstract_nonvirtual_dtor_but_virtual_fns.carbon:[[@LINE+3]]:1-41: error: cannot convert type `AbstractWithMethodNoVptr` into type implementing `Core.Destroy` [ConversionFailureTypeToFacet]
// CHECK:STDERR: min_prelude/parts/destroy.carbon:32:1-39: note: while deducing parameters of generic declared here [DeductionGenericHere]
// CHECK:STDERR: ╭─┤ fail_todo_abstract_nonvirtual_dtor_but_virtual_fns.carbon:[[@LINE+14]]:1
// CHECK:STDERR: -> │ abstract class AbstractWithMethodNoVptr {
// CHECK:STDERR: · ┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// CHECK:STDERR: · ┗━━┫ error: cannot convert type `AbstractWithMethodNoVptr` into type
// CHECK:STDERR: · ┃ implementing `Core.Destroy`
// CHECK:STDERR: · ┃ [ConversionFailureTypeToFacet]
// CHECK:STDERR: ┆
// CHECK:STDERR: ├─┤ min_prelude/parts/destroy.carbon
// CHECK:STDERR: │ fn SelfDestruct[T: Destroy](ref t: T) {
// CHECK:STDERR: · ───────────────────┬───────────────────
// CHECK:STDERR: · ╰──┤ while deducing parameters of generic declared here
// CHECK:STDERR: · │ [DeductionGenericHere]
// CHECK:STDERR: ╰────
// CHECK:STDERR:
abstract class AbstractWithMethodNoVptr {
abstract fn F(self);
@@ -140,16 +201,40 @@ import Cpp;
// TODO: We should support generating a base subobject destructor for an
// abstract class, even though we refuse to generate a complete object
// destructor.
// CHECK:STDERR: fail_variable_with_abstract_method.carbon:[[@LINE+3]]:1-35: error: cannot convert type `AbstractWithMethod` into type implementing `Core.Destroy` [ConversionFailureTypeToFacet]
// CHECK:STDERR: min_prelude/parts/destroy.carbon:32:1-39: note: while deducing parameters of generic declared here [DeductionGenericHere]
// CHECK:STDERR: ╭─┤ fail_variable_with_abstract_method.carbon:[[@LINE+14]]:1
// CHECK:STDERR: -> │ abstract class AbstractWithMethod {
// CHECK:STDERR: · ┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// CHECK:STDERR: · ┗━━┫ error: cannot convert type `AbstractWithMethod` into type implementing
// CHECK:STDERR: · ┃ `Core.Destroy`
// CHECK:STDERR: · ┃ [ConversionFailureTypeToFacet]
// CHECK:STDERR: ┆
// CHECK:STDERR: ├─┤ min_prelude/parts/destroy.carbon
// CHECK:STDERR: │ fn SelfDestruct[T: Destroy](ref t: T) {
// CHECK:STDERR: · ───────────────────┬───────────────────
// CHECK:STDERR: · ╰──┤ while deducing parameters of generic declared here
// CHECK:STDERR: · │ [DeductionGenericHere]
// CHECK:STDERR: ╰────
// CHECK:STDERR:
abstract class AbstractWithMethod {
abstract fn F(self);
}
inline Cpp '''
// CHECK:STDERR: fail_variable_with_abstract_method.carbon:[[@LINE+3]]:28: error: variable type 'Carbon::AbstractWithMethod' (aka 'Carbon::Main::AbstractWithMethod') is an abstract class [CppInteropParseError]
// CHECK:STDERR: fail_variable_with_abstract_method.carbon:[[@LINE-5]]:22: note: unimplemented pure virtual method 'F' in 'AbstractWithMethod' [CppInteropParseNote]
// CHECK:STDERR: ╭─┤ fail_variable_with_abstract_method.carbon:[[@LINE+16]]:28
// CHECK:STDERR: │ abstract fn F(self);
// CHECK:STDERR: · ┬
// CHECK:STDERR: · ╰──┤ unimplemented pure virtual method 'F' in
// CHECK:STDERR: · │ 'AbstractWithMethod'
// CHECK:STDERR: · │ [CppInteropParseNote]
// CHECK:STDERR: ┆
// CHECK:STDERR: -> │ Carbon::AbstractWithMethod x_abstract;
// CHECK:STDERR: · ┳
// CHECK:STDERR: · ┗━━┫ error: variable type
// CHECK:STDERR: · ┃ 'Carbon::AbstractWithMethod' (aka
// CHECK:STDERR: · ┃ 'Carbon::Main::AbstractWithMethod') is an
// CHECK:STDERR: · ┃ abstract class
// CHECK:STDERR: · ┃ [CppInteropParseError]
// CHECK:STDERR: ╰────
// CHECK:STDERR:
Carbon::AbstractWithMethod x_abstract;
''';
@@ -162,8 +247,19 @@ import Cpp;
// TODO: We should support generating a base subobject destructor for an
// abstract class, even though we refuse to generate a complete object
// destructor.
// CHECK:STDERR: fail_todo_abstract_method_overridden_in_cpp.carbon:[[@LINE+3]]:1-35: error: cannot convert type `AbstractToOverride` into type implementing `Core.Destroy` [ConversionFailureTypeToFacet]
// CHECK:STDERR: min_prelude/parts/destroy.carbon:32:1-39: note: while deducing parameters of generic declared here [DeductionGenericHere]
// CHECK:STDERR: ╭─┤ fail_todo_abstract_method_overridden_in_cpp.carbon:[[@LINE+14]]:1
// CHECK:STDERR: -> │ abstract class AbstractToOverride {
// CHECK:STDERR: · ┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// CHECK:STDERR: · ┗━━┫ error: cannot convert type `AbstractToOverride` into type implementing
// CHECK:STDERR: · ┃ `Core.Destroy`
// CHECK:STDERR: · ┃ [ConversionFailureTypeToFacet]
// CHECK:STDERR: ┆
// CHECK:STDERR: ├─┤ min_prelude/parts/destroy.carbon
// CHECK:STDERR: │ fn SelfDestruct[T: Destroy](ref t: T) {
// CHECK:STDERR: · ───────────────────┬───────────────────
// CHECK:STDERR: · ╰──┤ while deducing parameters of generic declared here
// CHECK:STDERR: · │ [DeductionGenericHere]
// CHECK:STDERR: ╰────
// CHECK:STDERR:
abstract class AbstractToOverride {
abstract fn F(ref self);
@@ -59,13 +59,30 @@ library "[[@TEST_NAME]]";
import Cpp;
// CHECK:STDERR: fail_incomplete_concrete.carbon:[[@LINE+2]]:1-26: error: class was forward declared here [ClassForwardDeclaredHere]
// CHECK:STDERR: ╭─┤ fail_incomplete_concrete.carbon:[[@LINE+7]]:1
// CHECK:STDERR: -> │ class IncompleteConcreteA;
// CHECK:STDERR: · ━━━━━━━━━━━━━┳━━━━━━━━━━━━
// CHECK:STDERR: · ┗━━┫ error: class was forward declared here
// CHECK:STDERR: · ┃ [ClassForwardDeclaredHere]
// CHECK:STDERR: ╰────
// CHECK:STDERR:
class IncompleteConcreteA;
inline Cpp '''
// CHECK:STDERR: fail_incomplete_concrete.carbon:[[@LINE+3]]:29: error: variable has incomplete type 'Carbon::IncompleteConcreteA' (aka 'Carbon::Main::IncompleteConcreteA') [CppInteropParseError]
// CHECK:STDERR: fail_incomplete_concrete.carbon:[[@LINE-4]]:26: note: forward declaration of 'Carbon::Main::IncompleteConcreteA' [CppInteropParseNote]
// CHECK:STDERR: ╭─┤ fail_incomplete_concrete.carbon:[[@LINE+15]]:29
// CHECK:STDERR: │ class IncompleteConcreteA;
// CHECK:STDERR: · ┬
// CHECK:STDERR: · ╰──┤ forward declaration of
// CHECK:STDERR: · │ 'Carbon::Main::IncompleteConcreteA'
// CHECK:STDERR: · │ [CppInteropParseNote]
// CHECK:STDERR: ┆
// CHECK:STDERR: -> │ Carbon::IncompleteConcreteA incomplete_concrete_a;
// CHECK:STDERR: · ┳
// CHECK:STDERR: · ┗━━┫ error: variable has incomplete type
// CHECK:STDERR: · ┃ 'Carbon::IncompleteConcreteA' (aka
// CHECK:STDERR: · ┃ 'Carbon::Main::IncompleteConcreteA')
// CHECK:STDERR: · ┃ [CppInteropParseError]
// CHECK:STDERR: ╰────
// CHECK:STDERR:
Carbon::IncompleteConcreteA incomplete_concrete_a;
''';
@@ -75,7 +92,12 @@ library "[[@TEST_NAME]]";
import Cpp;
// CHECK:STDERR: fail_todo_monomorphization_failure.carbon:[[@LINE+2]]:1-17: error: semantics TODO: `binding maps to a non-type template parameter` [SemanticsTodo]
// CHECK:STDERR: ╭─┤ fail_todo_monomorphization_failure.carbon:[[@LINE+7]]:1
// CHECK:STDERR: -> │ class B(N: i32) {
// CHECK:STDERR: · ━━━━━┳━━━━━━━━━━━
// CHECK:STDERR: · ┗━━┫ error: semantics TODO: `binding maps to a non-type template parameter`
// CHECK:STDERR: · ┃ [SemanticsTodo]
// CHECK:STDERR: ╰────
// CHECK:STDERR:
class B(N: i32) {
var a: array(i8, N);
@@ -86,9 +108,18 @@ class B(N: i32) {
alias T = B(-1);
inline Cpp '''
// CHECK:STDERR: fail_todo_monomorphization_failure.carbon:[[@LINE+4]]:1: error: semantics TODO: `interop with unsupported type` [SemanticsTodo]
// CHECK:STDERR: ╭─┤ fail_todo_monomorphization_failure.carbon:[[@LINE+13]]:1
// CHECK:STDERR: -> │ Carbon::T t;
// CHECK:STDERR: · ┳
// CHECK:STDERR: · ┗━━┫ error: semantics TODO: `interop with unsupported type` [SemanticsTodo]
// CHECK:STDERR: ╰────
// CHECK:STDERR:
// CHECK:STDERR: fail_todo_monomorphization_failure.carbon:[[@LINE+2]]:9: error: no type named 'T' in namespace 'Carbon' [CppInteropParseError]
// CHECK:STDERR: ╭─┤ fail_todo_monomorphization_failure.carbon:[[@LINE+7]]:9
// CHECK:STDERR: -> │ Carbon::T t;
// CHECK:STDERR: · ───────╴╻
// CHECK:STDERR: · ┗━━┫ error: no type named 'T' in namespace 'Carbon'
// CHECK:STDERR: · ┃ [CppInteropParseError]
// CHECK:STDERR: ╰────
// CHECK:STDERR:
Carbon::T t;
''';
@@ -75,10 +75,20 @@ class EmptyClass {}
inline Cpp '''
void AccessNonexistentField() {
Carbon::EmptyClass a;
// CHECK:STDERR: fail_nonexistent_field.carbon:[[@LINE+2]]:5: error: no member named 'x' in 'Carbon::Main::EmptyClass' [CppInteropParseError]
// CHECK:STDERR: ╭─┤ fail_nonexistent_field.carbon:[[@LINE+7]]:5
// CHECK:STDERR: -> │ a.x = 12;
// CHECK:STDERR: · ─ ┳
// CHECK:STDERR: · ┗━━┫ error: no member named 'x' in 'Carbon::Main::EmptyClass'
// CHECK:STDERR: · ┃ [CppInteropParseError]
// CHECK:STDERR: ╰────
// CHECK:STDERR:
a.x = 12;
// CHECK:STDERR: fail_nonexistent_field.carbon:[[@LINE+2]]:5: error: no member named 'y' in 'Carbon::Main::EmptyClass' [CppInteropParseError]
// CHECK:STDERR: ╭─┤ fail_nonexistent_field.carbon:[[@LINE+7]]:5
// CHECK:STDERR: -> │ a.y = 34;
// CHECK:STDERR: · ─ ┳
// CHECK:STDERR: · ┗━━┫ error: no member named 'y' in 'Carbon::Main::EmptyClass'
// CHECK:STDERR: · ┃ [CppInteropParseError]
// CHECK:STDERR: ╰────
// CHECK:STDERR:
a.y = 34;
}
@@ -89,10 +99,20 @@ library "[[@TEST_NAME]]";
import Cpp;
class UnsupportedFieldType {
// CHECK:STDERR: fail_unsupported_field_type.carbon:[[@LINE+2]]:7-11: error: semantics TODO: `failed to map Carbon type to C++` [SemanticsTodo]
// CHECK:STDERR: ╭─┤ fail_unsupported_field_type.carbon:[[@LINE+7]]:7
// CHECK:STDERR: -> │ var x: ();
// CHECK:STDERR: · ━━┳━━
// CHECK:STDERR: · ┗━━┫ error: semantics TODO: `failed to map Carbon type to C++`
// CHECK:STDERR: · ┃ [SemanticsTodo]
// CHECK:STDERR: ╰────
// CHECK:STDERR:
var x: ();
// CHECK:STDERR: fail_unsupported_field_type.carbon:[[@LINE+2]]:7-11: error: semantics TODO: `failed to map Carbon type to C++` [SemanticsTodo]
// CHECK:STDERR: ╭─┤ fail_unsupported_field_type.carbon:[[@LINE+7]]:7
// CHECK:STDERR: -> │ var y: ();
// CHECK:STDERR: · ━━┳━━
// CHECK:STDERR: · ┗━━┫ error: semantics TODO: `failed to map Carbon type to C++`
// CHECK:STDERR: · ┃ [SemanticsTodo]
// CHECK:STDERR: ╰────
// CHECK:STDERR:
var y: ();
}
@@ -100,10 +120,20 @@ class UnsupportedFieldType {
inline Cpp '''
void AccessUnsupportedField() {
Carbon::UnsupportedFieldType a;
// CHECK:STDERR: fail_unsupported_field_type.carbon:[[@LINE+2]]:5: error: no member named 'x' in 'Carbon::Main::UnsupportedFieldType' [CppInteropParseError]
// CHECK:STDERR: ╭─┤ fail_unsupported_field_type.carbon:[[@LINE+7]]:5
// CHECK:STDERR: -> │ a.x;
// CHECK:STDERR: · ─ ┳
// CHECK:STDERR: · ┗━━┫ error: no member named 'x' in 'Carbon::Main::UnsupportedFieldType'
// CHECK:STDERR: · ┃ [CppInteropParseError]
// CHECK:STDERR: ╰────
// CHECK:STDERR:
a.x;
// CHECK:STDERR: fail_unsupported_field_type.carbon:[[@LINE+2]]:5: error: no member named 'y' in 'Carbon::Main::UnsupportedFieldType' [CppInteropParseError]
// CHECK:STDERR: ╭─┤ fail_unsupported_field_type.carbon:[[@LINE+7]]:5
// CHECK:STDERR: -> │ a.y;
// CHECK:STDERR: · ─ ┳
// CHECK:STDERR: · ┗━━┫ error: no member named 'y' in 'Carbon::Main::UnsupportedFieldType'
// CHECK:STDERR: · ┃ [CppInteropParseError]
// CHECK:STDERR: ╰────
// CHECK:STDERR:
a.y;
}
@@ -120,7 +150,12 @@ class AdaptedClass {
inline Cpp '''
void AccessAdaptedField() {
Carbon::AdaptedClass a;
// CHECK:STDERR: fail_adapter.carbon:[[@LINE+2]]:5: error: no member named 'x' in 'Carbon::Main::AdaptedClass' [CppInteropParseError]
// CHECK:STDERR: ╭─┤ fail_adapter.carbon:[[@LINE+7]]:5
// CHECK:STDERR: -> │ a.x = 12;
// CHECK:STDERR: · ─ ┳
// CHECK:STDERR: · ┗━━┫ error: no member named 'x' in 'Carbon::Main::AdaptedClass'
// CHECK:STDERR: · ┃ [CppInteropParseError]
// CHECK:STDERR: ╰────
// CHECK:STDERR:
a.x = 12;
}
@@ -132,7 +167,11 @@ import Cpp;
// This should not cause a crash.
class InvalidBaseClass {
// CHECK:STDERR: fail_invalid.carbon:[[@LINE+2]]:16-21: error: name `Whoops` not found [NameNotFound]
// CHECK:STDERR: ╭─┤ fail_invalid.carbon:[[@LINE+6]]:16
// CHECK:STDERR: -> │ extend base: Whoops;
// CHECK:STDERR: · ━━━┳━━
// CHECK:STDERR: · ┗━━┫ error: name `Whoops` not found [NameNotFound]
// CHECK:STDERR: ╰────
// CHECK:STDERR:
extend base: Whoops;
}
@@ -156,8 +195,17 @@ class ClassWithPrivateField {
inline Cpp '''
int AccessPrivateField() {
auto c = Carbon::ClassWithPrivateField::Make();
// CHECK:STDERR: fail_private_field.carbon:[[@LINE+3]]:12: error: 'x' is a private member of 'Carbon::Main::ClassWithPrivateField' [CppInteropParseError]
// CHECK:STDERR: fail_private_field.carbon:[[@LINE-7]]:16: note: implicitly declared private here [CppInteropParseNote]
// CHECK:STDERR: ╭─┤ fail_private_field.carbon:[[@LINE+12]]:12
// CHECK:STDERR: │ private var x: i32;
// CHECK:STDERR: · ┬
// CHECK:STDERR: · ╰──┤ implicitly declared private here [CppInteropParseNote]
// CHECK:STDERR: ┆
// CHECK:STDERR: -> │ return c.x;
// CHECK:STDERR: · ┳
// CHECK:STDERR: · ┗━━┫ error: 'x' is a private member of
// CHECK:STDERR: · ┃ 'Carbon::Main::ClassWithPrivateField'
// CHECK:STDERR: · ┃ [CppInteropParseError]
// CHECK:STDERR: ╰────
// CHECK:STDERR:
return c.x;
}
@@ -45,7 +45,12 @@ void FSpecific() {
library "[[@TEST_NAME]]";
import Cpp;
// CHECK:STDERR: fail_unsupported_specific_arg.carbon:[[@LINE+2]]:1-33: error: semantics TODO: `failed to map specific type arg to C++` [SemanticsTodo]
// CHECK:STDERR: ╭─┤ fail_unsupported_specific_arg.carbon:[[@LINE+7]]:1
// CHECK:STDERR: -> │ class UnsupportedClass(T: type) {
// CHECK:STDERR: · ━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━
// CHECK:STDERR: · ┗━━┫ error: semantics TODO: `failed to map specific type arg to C++`
// CHECK:STDERR: · ┃ [SemanticsTodo]
// CHECK:STDERR: ╰────
// CHECK:STDERR:
class UnsupportedClass(T: type) {
var t: T;
@@ -54,9 +59,19 @@ alias AliasEmptyTuple = UnsupportedClass(());
inline Cpp '''
void FUnsupported() {
// CHECK:STDERR: fail_unsupported_specific_arg.carbon:[[@LINE+4]]:11: error: semantics TODO: `interop with unsupported type` [SemanticsTodo]
// CHECK:STDERR: ╭─┤ fail_unsupported_specific_arg.carbon:[[@LINE+14]]:11
// CHECK:STDERR: -> │ Carbon::AliasEmptyTuple a;
// CHECK:STDERR: · ┳
// CHECK:STDERR: · ┗━━┫ error: semantics TODO: `interop with unsupported type`
// CHECK:STDERR: · ┃ [SemanticsTodo]
// CHECK:STDERR: ╰────
// CHECK:STDERR:
// CHECK:STDERR: fail_unsupported_specific_arg.carbon:[[@LINE+2]]:11: error: no type named 'AliasEmptyTuple' in namespace 'Carbon' [CppInteropParseError]
// CHECK:STDERR: ╭─┤ fail_unsupported_specific_arg.carbon:[[@LINE+7]]:11
// CHECK:STDERR: -> │ Carbon::AliasEmptyTuple a;
// CHECK:STDERR: · ───────╴╻
// CHECK:STDERR: · ┗━━┫ error: no type named 'AliasEmptyTuple' in namespace 'Carbon'
// CHECK:STDERR: · ┃ [CppInteropParseError]
// CHECK:STDERR: ╰────
// CHECK:STDERR:
Carbon::AliasEmptyTuple a;
a.t = 123;
@@ -68,7 +83,12 @@ library "[[@TEST_NAME]]";
import Cpp;
class ClassWithMethod(T: type) {
// CHECK:STDERR: fail_todo_generic_class_method_call.carbon:[[@LINE+2]]:3-25: error: semantics TODO: `non-class non-namespace name scope` [SemanticsTodo]
// CHECK:STDERR: ╭─┤ fail_todo_generic_class_method_call.carbon:[[@LINE+7]]:3
// CHECK:STDERR: -> │ fn M(unused ref self) {}
// CHECK:STDERR: · ━━━━━━━━━━━┳━━━━━━━━━━━
// CHECK:STDERR: · ┗━━┫ error: semantics TODO: `non-class non-namespace name scope`
// CHECK:STDERR: · ┃ [SemanticsTodo]
// CHECK:STDERR: ╰────
// CHECK:STDERR:
fn M(unused ref self) {}
}
@@ -76,7 +96,12 @@ class ClassWithMethod(T: type) {
inline Cpp '''
void FMethodCall() {
Carbon::ClassWithMethod<int> c;
// CHECK:STDERR: fail_todo_generic_class_method_call.carbon:[[@LINE+2]]:5: error: no member named 'M' in 'Carbon::Main::ClassWithMethod<int>' [CppInteropParseError]
// CHECK:STDERR: ╭─┤ fail_todo_generic_class_method_call.carbon:[[@LINE+7]]:5
// CHECK:STDERR: -> │ c.M();
// CHECK:STDERR: · ─ ┳
// CHECK:STDERR: · ┗━━┫ error: no member named 'M' in 'Carbon::Main::ClassWithMethod<int>'
// CHECK:STDERR: · ┃ [CppInteropParseError]
// CHECK:STDERR: ╰────
// CHECK:STDERR:
c.M();
}
@@ -92,8 +92,17 @@ class RefMethodRValueClass {
inline Cpp '''
void RefMethodRValue() {
// CHECK:STDERR: fail_ref_method_rvalue.carbon:[[@LINE+3]]:3: error: 'this' argument to member function 'M' is an rvalue, but function has non-const lvalue ref-qualifier [CppInteropParseError]
// CHECK:STDERR: fail_ref_method_rvalue.carbon:[[@LINE-6]]:17: note: 'M' declared here [CppInteropParseNote]
// CHECK:STDERR: ╭─┤ fail_ref_method_rvalue.carbon:[[@LINE+12]]:3
// CHECK:STDERR: │ fn M(ref self);
// CHECK:STDERR: · ┬
// CHECK:STDERR: · ╰──┤ 'M' declared here [CppInteropParseNote]
// CHECK:STDERR: ┆
// CHECK:STDERR: -> │ Carbon::RefMethodRValueClass().M();
// CHECK:STDERR: · ┳
// CHECK:STDERR: · ┗━━┫ error: 'this' argument to member function 'M' is an rvalue, but function
// CHECK:STDERR: · ┃ has non-const lvalue ref-qualifier
// CHECK:STDERR: · ┃ [CppInteropParseError]
// CHECK:STDERR: ╰────
// CHECK:STDERR:
Carbon::RefMethodRValueClass().M();
}
@@ -109,8 +118,19 @@ class RefMethodConstLValueClass {
inline Cpp '''
void RefMethodConstLValue(const Carbon::RefMethodConstLValueClass& c) {
// CHECK:STDERR: fail_ref_method_const_lvalue.carbon:[[@LINE+3]]:3: error: 'this' argument to member function 'M' has type 'const Carbon::RefMethodConstLValueClass' (aka 'const Carbon::Main::RefMethodConstLValueClass'), but function is not marked const [CppInteropParseError]
// CHECK:STDERR: fail_ref_method_const_lvalue.carbon:[[@LINE-6]]:17: note: 'M' declared here [CppInteropParseNote]
// CHECK:STDERR: ╭─┤ fail_ref_method_const_lvalue.carbon:[[@LINE+14]]:3
// CHECK:STDERR: │ fn M(ref self);
// CHECK:STDERR: · ┬
// CHECK:STDERR: · ╰──┤ 'M' declared here [CppInteropParseNote]
// CHECK:STDERR: ┆
// CHECK:STDERR: -> │ c.M();
// CHECK:STDERR: · ┳
// CHECK:STDERR: · ┗━━┫ error: 'this' argument to member function 'M' has type 'const
// CHECK:STDERR: · ┃ Carbon::RefMethodConstLValueClass' (aka 'const
// CHECK:STDERR: · ┃ Carbon::Main::RefMethodConstLValueClass'), but function is not
// CHECK:STDERR: · ┃ marked const
// CHECK:STDERR: · ┃ [CppInteropParseError]
// CHECK:STDERR: ╰────
// CHECK:STDERR:
c.M();
}
@@ -72,7 +72,13 @@ struct VBase {
class A {}
// CHECK:STDERR: fail_todo_generic.carbon:[[@LINE+2]]:1-25: error: semantics TODO: `generic class overriding methods from a C++ virtual class` [SemanticsTodo]
// CHECK:STDERR: ╭─┤ fail_todo_generic.carbon:[[@LINE+8]]:1
// CHECK:STDERR: -> │ class GenericZ(T: type) {
// CHECK:STDERR: · ┳━━━━━━━━━━━━━━━━━━━━━━━━
// CHECK:STDERR: · ┗━━┫ error: semantics TODO:
// CHECK:STDERR: · ┃ `generic class overriding methods from a C++ virtual class`
// CHECK:STDERR: · ┃ [SemanticsTodo]
// CHECK:STDERR: ╰────
// CHECK:STDERR:
class GenericZ(T: type) {
extend base: Cpp.VBase;
@@ -34,8 +34,18 @@ class PrivateClass {
inline Cpp '''
int PrivateStatic() {
// CHECK:STDERR: fail_static_private.carbon:[[@LINE+3]]:32: error: 'x' is a private member of 'Carbon::Main::PrivateClass' [CppInteropParseError]
// CHECK:STDERR: fail_static_private.carbon:[[@LINE-6]]:23: note: implicitly declared private here [CppInteropParseNote]
// CHECK:STDERR: ╭─┤ fail_static_private.carbon:[[@LINE+13]]:32
// CHECK:STDERR: │ private static var x: i32 = 123;
// CHECK:STDERR: · ┬
// CHECK:STDERR: · ╰──┤ implicitly declared private here
// CHECK:STDERR: · │ [CppInteropParseNote]
// CHECK:STDERR: ┆
// CHECK:STDERR: -> │ return Carbon::PrivateClass::x;
// CHECK:STDERR: · ┳
// CHECK:STDERR: · ┗━━┫ error: 'x' is a private member of
// CHECK:STDERR: · ┃ 'Carbon::Main::PrivateClass'
// CHECK:STDERR: · ┃ [CppInteropParseError]
// CHECK:STDERR: ╰────
// CHECK:STDERR:
return Carbon::PrivateClass::x;
}