mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-11-15 14:58:09 +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
@@ -43,21 +43,49 @@ import Cpp;
|
||||
// HLSL extension, or by mapping to a `std::array` parameter.
|
||||
|
||||
// TODO: These diagnostics are very bad.
|
||||
// CHECK:STDERR: fail_todo_array_var_param.carbon:[[@LINE+4]]:1-48: error: semantics TODO: `by-var array parameter` [SemanticsTodo]
|
||||
// CHECK:STDERR: ╭─┤ fail_todo_array_var_param.carbon:[[@LINE+14]]:1
|
||||
// CHECK:STDERR: -> │ fn FArrayVarParam(var a: array(i32, 5)) -> i32 { return a[2]; }
|
||||
// CHECK:STDERR: · ━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━
|
||||
// CHECK:STDERR: · ┗━━┫ error: semantics TODO: `by-var array parameter`
|
||||
// CHECK:STDERR: · ┃ [SemanticsTodo]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
// CHECK:STDERR: fail_todo_array_var_param.carbon:[[@LINE+2]]:1-48: error: semantics TODO: `failed to map C++ type to Carbon` [SemanticsTodo]
|
||||
// CHECK:STDERR: ╭─┤ fail_todo_array_var_param.carbon:[[@LINE+7]]:1
|
||||
// CHECK:STDERR: -> │ fn FArrayVarParam(var a: array(i32, 5)) -> i32 { return a[2]; }
|
||||
// CHECK:STDERR: · ━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
||||
// CHECK:STDERR: · ┗━━┫ error: semantics TODO: `failed to map C++ type to Carbon`
|
||||
// CHECK:STDERR: · ┃ [SemanticsTodo]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
fn FArrayVarParam(var a: array(i32, 5)) -> i32 { return a[2]; }
|
||||
|
||||
inline Cpp '''
|
||||
int GArrayVarParam() {
|
||||
//@dump-sem-ir-begin
|
||||
// CHECK:STDERR: fail_todo_array_var_param.carbon:[[@LINE+7]]:10: error: no member named 'FArrayVarParam' in namespace 'Carbon'; did you mean 'GArrayVarParam'? [CppInteropParseError]
|
||||
// CHECK:STDERR: fail_todo_array_var_param.carbon:[[@LINE+6]]:10-31: note: replace with `GArrayVarParam` [CppInteropFixItReplacement]
|
||||
// CHECK:STDERR: fail_todo_array_var_param.carbon:[[@LINE-4]]:5: note: 'GArrayVarParam' declared here [CppInteropParseNote]
|
||||
// CHECK:STDERR: ╭─┤ fail_todo_array_var_param.carbon:[[@LINE+25]]:10
|
||||
// CHECK:STDERR: │ int GArrayVarParam() {
|
||||
// CHECK:STDERR: · ┬
|
||||
// CHECK:STDERR: · ╰──┤ 'GArrayVarParam' declared here [CppInteropParseNote]
|
||||
// CHECK:STDERR: ┆
|
||||
// CHECK:STDERR: -> │ return Carbon::FArrayVarParam({1, 2, 3, 4, 5});
|
||||
// CHECK:STDERR: · ┳─────────────────────
|
||||
// CHECK:STDERR: · ┗━━┫ error: no member named 'FArrayVarParam' in namespace 'Carbon'; did
|
||||
// CHECK:STDERR: · │ ┃ you mean 'GArrayVarParam'?
|
||||
// CHECK:STDERR: · │ ┃ [CppInteropParseError]
|
||||
// CHECK:STDERR: · ╰────┤ replace with `GArrayVarParam` [CppInteropFixItReplacement]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
// CHECK:STDERR: fail_todo_array_var_param.carbon:[[@LINE+3]]:33-47: error: too many arguments to function call, expected 0, have 1 [CppInteropParseError]
|
||||
// CHECK:STDERR: fail_todo_array_var_param.carbon:[[@LINE-7]]:5: note: 'GArrayVarParam' declared here [CppInteropParseNote]
|
||||
// CHECK:STDERR: ╭─┤ fail_todo_array_var_param.carbon:[[@LINE+12]]:33
|
||||
// CHECK:STDERR: │ int GArrayVarParam() {
|
||||
// CHECK:STDERR: · ┬
|
||||
// CHECK:STDERR: · ╰──┤ 'GArrayVarParam' declared here [CppInteropParseNote]
|
||||
// CHECK:STDERR: ┆
|
||||
// CHECK:STDERR: -> │ return Carbon::FArrayVarParam({1, 2, 3, 4, 5});
|
||||
// CHECK:STDERR: · ────────────── ┳━━━━━━━━━━━━━━
|
||||
// CHECK:STDERR: · ┗━━┫ error: too many arguments to function call,
|
||||
// CHECK:STDERR: · ┃ expected 0, have 1
|
||||
// CHECK:STDERR: · ┃ [CppInteropParseError]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
return Carbon::FArrayVarParam({1, 2, 3, 4, 5});
|
||||
//@dump-sem-ir-end
|
||||
@@ -73,7 +101,12 @@ import Cpp;
|
||||
// types, as C++ does not have such return types.
|
||||
// TODO: Support this, perhaps by returning a `std::array`.
|
||||
|
||||
// CHECK:STDERR: fail_todo_array_return.carbon:[[@LINE+2]]:1-36: error: semantics TODO: `array return type` [SemanticsTodo]
|
||||
// CHECK:STDERR: ╭─┤ fail_todo_array_return.carbon:[[@LINE+7]]:1
|
||||
// CHECK:STDERR: -> │ fn FArrayReturn() -> array(i32, 5) {
|
||||
// CHECK:STDERR: · ━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━
|
||||
// CHECK:STDERR: · ┗━━┫ error: semantics TODO: `array return type`
|
||||
// CHECK:STDERR: · ┃ [SemanticsTodo]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
fn FArrayReturn() -> array(i32, 5) {
|
||||
return (1, 2, 3, 4, 5);
|
||||
@@ -81,12 +114,26 @@ fn FArrayReturn() -> array(i32, 5) {
|
||||
|
||||
inline Cpp '''
|
||||
int GArrayReturn() {
|
||||
// CHECK:STDERR: fail_todo_array_return.carbon:[[@LINE+4]]:16: error: no member named 'FArrayReturn' in namespace 'Carbon'; did you mean 'GArrayReturn'? [CppInteropParseError]
|
||||
// CHECK:STDERR: fail_todo_array_return.carbon:[[@LINE+3]]:16-35: note: replace with `GArrayReturn` [CppInteropFixItReplacement]
|
||||
// CHECK:STDERR: fail_todo_array_return.carbon:[[@LINE-3]]:5: note: 'GArrayReturn' declared here [CppInteropParseNote]
|
||||
// CHECK:STDERR: ╭─┤ fail_todo_array_return.carbon:[[@LINE+13]]:16
|
||||
// CHECK:STDERR: │ int GArrayReturn() {
|
||||
// CHECK:STDERR: · ┬
|
||||
// CHECK:STDERR: · ╰──┤ 'GArrayReturn' declared here [CppInteropParseNote]
|
||||
// CHECK:STDERR: ┆
|
||||
// CHECK:STDERR: -> │ auto &&arr = Carbon::FArrayReturn();
|
||||
// CHECK:STDERR: · ┳───────────────────
|
||||
// CHECK:STDERR: · ┗━━┫ error: no member named 'FArrayReturn' in namespace 'Carbon';
|
||||
// CHECK:STDERR: · │ ┃ did you mean 'GArrayReturn'?
|
||||
// CHECK:STDERR: · │ ┃ [CppInteropParseError]
|
||||
// CHECK:STDERR: · ╰────┤ replace with `GArrayReturn` [CppInteropFixItReplacement]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
auto &&arr = Carbon::FArrayReturn();
|
||||
// CHECK:STDERR: fail_todo_array_return.carbon:[[@LINE+2]]:13: error: subscripted value is not an array, pointer, or vector [CppInteropParseError]
|
||||
// CHECK:STDERR: ╭─┤ fail_todo_array_return.carbon:[[@LINE+7]]:13
|
||||
// CHECK:STDERR: -> │ return arr[0];
|
||||
// CHECK:STDERR: · ──╴╻╶
|
||||
// CHECK:STDERR: · ┗━━┫ error: subscripted value is not an array, pointer, or vector
|
||||
// CHECK:STDERR: · ┃ [CppInteropParseError]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
return arr[0];
|
||||
}
|
||||
|
||||
@@ -36,10 +36,29 @@ class FactoryIsMethod {
|
||||
|
||||
inline Cpp '''
|
||||
void CallFactoryIsMethod() {
|
||||
// CHECK:STDERR: fail_factory_is_method.carbon:[[@LINE+5]]:27: error: no matching constructor for initialization of 'Carbon::FactoryIsMethod' (aka 'Carbon::Main::FactoryIsMethod') [CppInteropParseError]
|
||||
// CHECK:STDERR: fail_factory_is_method.carbon:[[@LINE-7]]:23: note: candidate constructor (the implicit copy constructor) not viable: no known conversion from 'int' to 'const FactoryIsMethod' for 1st argument [CppInteropParseNote]
|
||||
// CHECK:STDERR: fail_factory_is_method.carbon:[[@LINE-8]]:23: note: candidate constructor (the implicit move constructor) not viable: no known conversion from 'int' to 'FactoryIsMethod' for 1st argument [CppInteropParseNote]
|
||||
// CHECK:STDERR: fail_factory_is_method.carbon:[[@LINE-9]]:23: note: candidate constructor (the implicit default constructor) not viable: requires 0 arguments, but 1 was provided [CppInteropParseNote]
|
||||
// CHECK:STDERR: ╭─┤ fail_factory_is_method.carbon:[[@LINE+24]]:27
|
||||
// CHECK:STDERR: │ class FactoryIsMethod {
|
||||
// CHECK:STDERR: · ┬
|
||||
// CHECK:STDERR: · ╰──┤ candidate constructor (the implicit copy constructor)
|
||||
// CHECK:STDERR: · │ │ not viable: no known conversion from 'int' to 'const
|
||||
// CHECK:STDERR: · │ │ FactoryIsMethod' for 1st argument
|
||||
// CHECK:STDERR: · │ │ [CppInteropParseNote]
|
||||
// CHECK:STDERR: · ╰────┤ candidate constructor (the implicit move
|
||||
// CHECK:STDERR: · │ │ constructor) not viable: no known conversion from
|
||||
// CHECK:STDERR: · │ │ 'int' to 'FactoryIsMethod' for 1st argument
|
||||
// CHECK:STDERR: · │ │ [CppInteropParseNote]
|
||||
// CHECK:STDERR: · ╰──────┤ candidate constructor (the implicit default
|
||||
// CHECK:STDERR: · │ constructor) not viable: requires 0 arguments,
|
||||
// CHECK:STDERR: · │ but 1 was provided
|
||||
// CHECK:STDERR: · │ [CppInteropParseNote]
|
||||
// CHECK:STDERR: ┆
|
||||
// CHECK:STDERR: -> │ Carbon::FactoryIsMethod a(42);
|
||||
// CHECK:STDERR: · ┳ ──
|
||||
// CHECK:STDERR: · ┗━━┫ error: no matching constructor for initialization
|
||||
// CHECK:STDERR: · ┃ of 'Carbon::FactoryIsMethod' (aka
|
||||
// CHECK:STDERR: · ┃ 'Carbon::Main::FactoryIsMethod')
|
||||
// CHECK:STDERR: · ┃ [CppInteropParseError]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
Carbon::FactoryIsMethod a(42);
|
||||
}
|
||||
@@ -56,10 +75,32 @@ class FactoryDoesntReturnSelf {
|
||||
|
||||
inline Cpp '''
|
||||
void CallFactoryDoesntReturnSelf() {
|
||||
// CHECK:STDERR: fail_factory_doesnt_return_self.carbon:[[@LINE+5]]:35: error: no matching constructor for initialization of 'Carbon::FactoryDoesntReturnSelf' (aka 'Carbon::Main::FactoryDoesntReturnSelf') [CppInteropParseError]
|
||||
// CHECK:STDERR: fail_factory_doesnt_return_self.carbon:[[@LINE-7]]:31: note: candidate constructor (the implicit copy constructor) not viable: no known conversion from 'int' to 'const FactoryDoesntReturnSelf' for 1st argument [CppInteropParseNote]
|
||||
// CHECK:STDERR: fail_factory_doesnt_return_self.carbon:[[@LINE-8]]:31: note: candidate constructor (the implicit move constructor) not viable: no known conversion from 'int' to 'FactoryDoesntReturnSelf' for 1st argument [CppInteropParseNote]
|
||||
// CHECK:STDERR: fail_factory_doesnt_return_self.carbon:[[@LINE-9]]:31: note: candidate constructor (the implicit default constructor) not viable: requires 0 arguments, but 1 was provided [CppInteropParseNote]
|
||||
// CHECK:STDERR: ╭─┤ fail_factory_doesnt_return_self.carbon:[[@LINE+27]]:35
|
||||
// CHECK:STDERR: │ class FactoryDoesntReturnSelf {
|
||||
// CHECK:STDERR: · ┬
|
||||
// CHECK:STDERR: · ╰──┤ candidate constructor (the implicit copy
|
||||
// CHECK:STDERR: · │ │ constructor) not viable: no known conversion
|
||||
// CHECK:STDERR: · │ │ from 'int' to 'const FactoryDoesntReturnSelf'
|
||||
// CHECK:STDERR: · │ │ for 1st argument
|
||||
// CHECK:STDERR: · │ │ [CppInteropParseNote]
|
||||
// CHECK:STDERR: · ╰────┤ candidate constructor (the implicit move
|
||||
// CHECK:STDERR: · │ │ constructor) not viable: no known
|
||||
// CHECK:STDERR: · │ │ conversion from 'int' to
|
||||
// CHECK:STDERR: · │ │ 'FactoryDoesntReturnSelf' for 1st argument
|
||||
// CHECK:STDERR: · │ │ [CppInteropParseNote]
|
||||
// CHECK:STDERR: · ╰──────┤ candidate constructor (the implicit
|
||||
// CHECK:STDERR: · │ default constructor) not viable: requires
|
||||
// CHECK:STDERR: · │ 0 arguments, but 1 was provided
|
||||
// CHECK:STDERR: · │ [CppInteropParseNote]
|
||||
// CHECK:STDERR: ┆
|
||||
// CHECK:STDERR: -> │ Carbon::FactoryDoesntReturnSelf a(42);
|
||||
// CHECK:STDERR: · ┳ ──
|
||||
// CHECK:STDERR: · ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
|
||||
// CHECK:STDERR: · ┃ error: no matching constructor for initialization of
|
||||
// CHECK:STDERR: · ┃ 'Carbon::FactoryDoesntReturnSelf' (aka
|
||||
// CHECK:STDERR: · ┃ 'Carbon::Main::FactoryDoesntReturnSelf')
|
||||
// CHECK:STDERR: · ┃ [CppInteropParseError]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
Carbon::FactoryDoesntReturnSelf a(42);
|
||||
}
|
||||
@@ -76,10 +117,32 @@ class FactoryReturnsByRef {
|
||||
|
||||
inline Cpp '''
|
||||
void CallFactoryReturnsByRef() {
|
||||
// CHECK:STDERR: fail_factory_returns_by_ref.carbon:[[@LINE+5]]:31: error: no matching constructor for initialization of 'Carbon::FactoryReturnsByRef' (aka 'Carbon::Main::FactoryReturnsByRef') [CppInteropParseError]
|
||||
// CHECK:STDERR: fail_factory_returns_by_ref.carbon:[[@LINE-7]]:27: note: candidate constructor (the implicit copy constructor) not viable: no known conversion from 'int' to 'const FactoryReturnsByRef' for 1st argument [CppInteropParseNote]
|
||||
// CHECK:STDERR: fail_factory_returns_by_ref.carbon:[[@LINE-8]]:27: note: candidate constructor (the implicit move constructor) not viable: no known conversion from 'int' to 'FactoryReturnsByRef' for 1st argument [CppInteropParseNote]
|
||||
// CHECK:STDERR: fail_factory_returns_by_ref.carbon:[[@LINE-9]]:27: note: candidate constructor (the implicit default constructor) not viable: requires 0 arguments, but 1 was provided [CppInteropParseNote]
|
||||
// CHECK:STDERR: ╭─┤ fail_factory_returns_by_ref.carbon:[[@LINE+27]]:31
|
||||
// CHECK:STDERR: │ class FactoryReturnsByRef {
|
||||
// CHECK:STDERR: · ┬
|
||||
// CHECK:STDERR: · ╰──┤ candidate constructor (the implicit copy
|
||||
// CHECK:STDERR: · │ │ constructor) not viable: no known conversion from
|
||||
// CHECK:STDERR: · │ │ 'int' to 'const FactoryReturnsByRef' for 1st
|
||||
// CHECK:STDERR: · │ │ argument
|
||||
// CHECK:STDERR: · │ │ [CppInteropParseNote]
|
||||
// CHECK:STDERR: · ╰────┤ candidate constructor (the implicit move
|
||||
// CHECK:STDERR: · │ │ constructor) not viable: no known conversion
|
||||
// CHECK:STDERR: · │ │ from 'int' to 'FactoryReturnsByRef' for 1st
|
||||
// CHECK:STDERR: · │ │ argument
|
||||
// CHECK:STDERR: · │ │ [CppInteropParseNote]
|
||||
// CHECK:STDERR: · ╰──────┤ candidate constructor (the implicit default
|
||||
// CHECK:STDERR: · │ constructor) not viable: requires 0
|
||||
// CHECK:STDERR: · │ arguments, but 1 was provided
|
||||
// CHECK:STDERR: · │ [CppInteropParseNote]
|
||||
// CHECK:STDERR: ┆
|
||||
// CHECK:STDERR: -> │ Carbon::FactoryReturnsByRef a(42);
|
||||
// CHECK:STDERR: · ┳ ──
|
||||
// CHECK:STDERR: · ┗━━┫ error: no matching constructor for
|
||||
// CHECK:STDERR: · ┃ initialization of
|
||||
// CHECK:STDERR: · ┃ 'Carbon::FactoryReturnsByRef' (aka
|
||||
// CHECK:STDERR: · ┃ 'Carbon::Main::FactoryReturnsByRef')
|
||||
// CHECK:STDERR: · ┃ [CppInteropParseError]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
Carbon::FactoryReturnsByRef a(42);
|
||||
}
|
||||
@@ -91,7 +154,12 @@ library "[[@TEST_NAME]]";
|
||||
import Cpp;
|
||||
|
||||
class GenericConstructor {
|
||||
// CHECK:STDERR: fail_todo_call_generic_constructor.carbon:[[@LINE+2]]:3-48: error: semantics TODO: `support exporting generic member functions` [SemanticsTodo]
|
||||
// CHECK:STDERR: ╭─┤ fail_todo_call_generic_constructor.carbon:[[@LINE+7]]:3
|
||||
// CHECK:STDERR: -> │ fn GenericConstructor[T: type](_: T) -> Self {
|
||||
// CHECK:STDERR: · ━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
||||
// CHECK:STDERR: · ┗━━┫ error: semantics TODO: `support exporting generic member functions`
|
||||
// CHECK:STDERR: · ┃ [SemanticsTodo]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
fn GenericConstructor[T: type](_: T) -> Self {
|
||||
return {};
|
||||
@@ -100,10 +168,32 @@ class GenericConstructor {
|
||||
|
||||
inline Cpp '''
|
||||
void CallGenericConstructor() {
|
||||
// CHECK:STDERR: fail_todo_call_generic_constructor.carbon:[[@LINE+5]]:30: error: no matching constructor for initialization of 'Carbon::GenericConstructor' (aka 'Carbon::Main::GenericConstructor') [CppInteropParseError]
|
||||
// CHECK:STDERR: fail_todo_call_generic_constructor.carbon:[[@LINE-11]]:26: note: candidate constructor (the implicit copy constructor) not viable: no known conversion from 'int' to 'const GenericConstructor' for 1st argument [CppInteropParseNote]
|
||||
// CHECK:STDERR: fail_todo_call_generic_constructor.carbon:[[@LINE-12]]:26: note: candidate constructor (the implicit move constructor) not viable: no known conversion from 'int' to 'GenericConstructor' for 1st argument [CppInteropParseNote]
|
||||
// CHECK:STDERR: fail_todo_call_generic_constructor.carbon:[[@LINE-13]]:26: note: candidate constructor (the implicit default constructor) not viable: requires 0 arguments, but 1 was provided [CppInteropParseNote]
|
||||
// CHECK:STDERR: ╭─┤ fail_todo_call_generic_constructor.carbon:[[@LINE+27]]:30
|
||||
// CHECK:STDERR: │ class GenericConstructor {
|
||||
// CHECK:STDERR: · ┬
|
||||
// CHECK:STDERR: · ╰──┤ candidate constructor (the implicit copy
|
||||
// CHECK:STDERR: · │ │ constructor) not viable: no known conversion from
|
||||
// CHECK:STDERR: · │ │ 'int' to 'const GenericConstructor' for 1st
|
||||
// CHECK:STDERR: · │ │ argument
|
||||
// CHECK:STDERR: · │ │ [CppInteropParseNote]
|
||||
// CHECK:STDERR: · ╰────┤ candidate constructor (the implicit move
|
||||
// CHECK:STDERR: · │ │ constructor) not viable: no known conversion
|
||||
// CHECK:STDERR: · │ │ from 'int' to 'GenericConstructor' for 1st
|
||||
// CHECK:STDERR: · │ │ argument
|
||||
// CHECK:STDERR: · │ │ [CppInteropParseNote]
|
||||
// CHECK:STDERR: · ╰──────┤ candidate constructor (the implicit default
|
||||
// CHECK:STDERR: · │ constructor) not viable: requires 0 arguments,
|
||||
// CHECK:STDERR: · │ but 1 was provided
|
||||
// CHECK:STDERR: · │ [CppInteropParseNote]
|
||||
// CHECK:STDERR: ┆
|
||||
// CHECK:STDERR: -> │ Carbon::GenericConstructor b(0);
|
||||
// CHECK:STDERR: · ┳ ─
|
||||
// CHECK:STDERR: · ┗━━┫ error: no matching constructor for
|
||||
// CHECK:STDERR: · ┃ initialization of
|
||||
// CHECK:STDERR: · ┃ 'Carbon::GenericConstructor' (aka
|
||||
// CHECK:STDERR: · ┃ 'Carbon::Main::GenericConstructor')
|
||||
// CHECK:STDERR: · ┃ [CppInteropParseError]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
Carbon::GenericConstructor b(0);
|
||||
}
|
||||
@@ -115,7 +205,12 @@ library "[[@TEST_NAME]]";
|
||||
import Cpp;
|
||||
|
||||
class GenericClass(T: type) {
|
||||
// CHECK:STDERR: fail_todo_call_generic_class_constructor.carbon:[[@LINE+2]]:3-33: error: semantics TODO: `non-class non-namespace name scope` [SemanticsTodo]
|
||||
// CHECK:STDERR: ╭─┤ fail_todo_call_generic_class_constructor.carbon:[[@LINE+7]]:3
|
||||
// CHECK:STDERR: -> │ fn GenericClass(_: T) -> Self {
|
||||
// CHECK:STDERR: · ━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━
|
||||
// CHECK:STDERR: · ┗━━┫ error: semantics TODO: `non-class non-namespace name scope`
|
||||
// CHECK:STDERR: · ┃ [SemanticsTodo]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
fn GenericClass(_: T) -> Self {
|
||||
return {};
|
||||
@@ -124,10 +219,31 @@ class GenericClass(T: type) {
|
||||
|
||||
inline Cpp '''
|
||||
void CallGenericClass() {
|
||||
// CHECK:STDERR: fail_todo_call_generic_class_constructor.carbon:[[@LINE+5]]:29: error: no matching constructor for initialization of 'Carbon::GenericClass<int>' [CppInteropParseError]
|
||||
// CHECK:STDERR: fail_todo_call_generic_class_constructor.carbon:[[@LINE-11]]:29: note: candidate constructor (the implicit copy constructor) not viable: no known conversion from 'int' to 'const GenericClass<int>' for 1st argument [CppInteropParseNote]
|
||||
// CHECK:STDERR: fail_todo_call_generic_class_constructor.carbon:[[@LINE-12]]:29: note: candidate constructor (the implicit move constructor) not viable: no known conversion from 'int' to 'GenericClass<int>' for 1st argument [CppInteropParseNote]
|
||||
// CHECK:STDERR: fail_todo_call_generic_class_constructor.carbon:[[@LINE-13]]:29: note: candidate constructor (the implicit default constructor) not viable: requires 0 arguments, but 1 was provided [CppInteropParseNote]
|
||||
// CHECK:STDERR: ╭─┤ fail_todo_call_generic_class_constructor.carbon:[[@LINE+26]]:29
|
||||
// CHECK:STDERR: │ class GenericClass(T: type) {
|
||||
// CHECK:STDERR: · ┬
|
||||
// CHECK:STDERR: · ╰──┤ candidate constructor (the implicit copy
|
||||
// CHECK:STDERR: · │ │ constructor) not viable: no known conversion
|
||||
// CHECK:STDERR: · │ │ from 'int' to 'const GenericClass<int>' for 1st
|
||||
// CHECK:STDERR: · │ │ argument
|
||||
// CHECK:STDERR: · │ │ [CppInteropParseNote]
|
||||
// CHECK:STDERR: · ╰────┤ candidate constructor (the implicit move
|
||||
// CHECK:STDERR: · │ │ constructor) not viable: no known conversion
|
||||
// CHECK:STDERR: · │ │ from 'int' to 'GenericClass<int>' for 1st
|
||||
// CHECK:STDERR: · │ │ argument
|
||||
// CHECK:STDERR: · │ │ [CppInteropParseNote]
|
||||
// CHECK:STDERR: · ╰──────┤ candidate constructor (the implicit default
|
||||
// CHECK:STDERR: · │ constructor) not viable: requires 0
|
||||
// CHECK:STDERR: · │ arguments, but 1 was provided
|
||||
// CHECK:STDERR: · │ [CppInteropParseNote]
|
||||
// CHECK:STDERR: ┆
|
||||
// CHECK:STDERR: -> │ Carbon::GenericClass<int> c(0);
|
||||
// CHECK:STDERR: · ┳ ─
|
||||
// CHECK:STDERR: · ┗━━┫ error: no matching constructor for
|
||||
// CHECK:STDERR: · ┃ initialization of
|
||||
// CHECK:STDERR: · ┃ 'Carbon::GenericClass<int>'
|
||||
// CHECK:STDERR: · ┃ [CppInteropParseError]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
Carbon::GenericClass<int> c(0);
|
||||
}
|
||||
|
||||
@@ -89,16 +89,21 @@ void CallUsingF() { UsingF(); }
|
||||
// --- other_generic.carbon
|
||||
|
||||
package OtherGeneric;
|
||||
// CHECK:STDERR: ╷ ╭── imported from: fail_todo_generic.carbon [InImport]
|
||||
// CHECK:STDERR: ├─┤ other_generic.carbon:[[@LINE+8]]:1
|
||||
// CHECK:STDERR: -> │ fn HasGenericArg(generic T: type, a: T) { a; }
|
||||
// CHECK:STDERR: · ━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━
|
||||
// CHECK:STDERR: · ┗━━┫ error: 1 argument passed to function expecting 2 arguments
|
||||
// CHECK:STDERR: · │ ┃ [CallArgCountMismatch]
|
||||
// CHECK:STDERR: · ╰────┤ calling function declared here [InCallToEntity]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
fn HasGenericArg(generic T: type, a: T) { a; }
|
||||
|
||||
// --- fail_todo_generic.carbon
|
||||
|
||||
library "[[@TEST_NAME]]";
|
||||
|
||||
// CHECK:STDERR: imported from: fail_todo_generic.carbon:[[@LINE+4]]:1 [InImport]
|
||||
// CHECK:STDERR: other_generic.carbon:3:1-41: error: 1 argument passed to function expecting 2 arguments [CallArgCountMismatch]
|
||||
// CHECK:STDERR: other_generic.carbon:3:1-41: note: calling function declared here [InCallToEntity]
|
||||
// CHECK:STDERR:
|
||||
import OtherGeneric;
|
||||
import Cpp inline '''
|
||||
void CallHasGenericArg() {
|
||||
|
||||
@@ -75,15 +75,29 @@ Carbon::B CallInterfaceF() {
|
||||
library "[[@TEST_NAME]]";
|
||||
import Cpp;
|
||||
|
||||
// CHECK:STDERR: fail_todo_non_type_generic.carbon:[[@LINE+2]]:1-30: error: semantics TODO: `binding maps to a non-type template parameter` [SemanticsTodo]
|
||||
// CHECK:STDERR: ╭─┤ fail_todo_non_type_generic.carbon:[[@LINE+7]]:1
|
||||
// CHECK:STDERR: -> │ fn NonTypeF[unused N: i32]() {}
|
||||
// CHECK:STDERR: · ━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━
|
||||
// CHECK:STDERR: · ┗━━┫ error: semantics TODO: `binding maps to a non-type template parameter`
|
||||
// CHECK:STDERR: · ┃ [SemanticsTodo]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
fn NonTypeF[unused N: i32]() {}
|
||||
|
||||
inline Cpp '''
|
||||
void CallNonTypeF() {
|
||||
// CHECK:STDERR: fail_todo_non_type_generic.carbon:[[@LINE+4]]:11-18: error: no member named 'NonTypeF' in namespace 'Carbon' [CppInteropParseError]
|
||||
// CHECK:STDERR: ╭─┤ fail_todo_non_type_generic.carbon:[[@LINE+13]]:11
|
||||
// CHECK:STDERR: -> │ Carbon::NonTypeF<3>();
|
||||
// CHECK:STDERR: · ━━━━┳━━━
|
||||
// CHECK:STDERR: · ┗━━┫ error: no member named 'NonTypeF' in namespace 'Carbon'
|
||||
// CHECK:STDERR: · ┃ [CppInteropParseError]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
// CHECK:STDERR: fail_todo_non_type_generic.carbon:[[@LINE+2]]:23: error: expected expression [CppInteropParseError]
|
||||
// CHECK:STDERR: ╭─┤ fail_todo_non_type_generic.carbon:[[@LINE+6]]:23
|
||||
// CHECK:STDERR: -> │ Carbon::NonTypeF<3>();
|
||||
// CHECK:STDERR: · ┳
|
||||
// CHECK:STDERR: · ┗━━┫ error: expected expression [CppInteropParseError]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
Carbon::NonTypeF<3>();
|
||||
}
|
||||
@@ -108,7 +122,12 @@ library "[[@TEST_NAME]]";
|
||||
import Cpp;
|
||||
|
||||
class EnclosingA(T: type) {
|
||||
// CHECK:STDERR: fail_todo_enclosing_generic.carbon:[[@LINE+2]]:3-34: error: semantics TODO: `non-class non-namespace name scope` [SemanticsTodo]
|
||||
// CHECK:STDERR: ╭─┤ fail_todo_enclosing_generic.carbon:[[@LINE+7]]:3
|
||||
// CHECK:STDERR: -> │ fn MemberF[U: type](x: T, y: U);
|
||||
// CHECK:STDERR: · ━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━
|
||||
// CHECK:STDERR: · ┗━━┫ error: semantics TODO: `non-class non-namespace name scope`
|
||||
// CHECK:STDERR: · ┃ [SemanticsTodo]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
fn MemberF[U: type](x: T, y: U);
|
||||
}
|
||||
@@ -120,7 +139,12 @@ void CallEnclosingF() {
|
||||
// is to test a generic function within an enclosing generic scope.
|
||||
//
|
||||
Carbon::EnclosingB b;
|
||||
// CHECK:STDERR: fail_todo_enclosing_generic.carbon:[[@LINE+2]]:5: error: no member named 'MemberF' in 'Carbon::Main::EnclosingA<int>' [CppInteropParseError]
|
||||
// CHECK:STDERR: ╭─┤ fail_todo_enclosing_generic.carbon:[[@LINE+7]]:5
|
||||
// CHECK:STDERR: -> │ b.MemberF(1, 2);
|
||||
// CHECK:STDERR: · ─ ┳
|
||||
// CHECK:STDERR: · ┗━━┫ error: no member named 'MemberF' in 'Carbon::Main::EnclosingA<int>'
|
||||
// CHECK:STDERR: · ┃ [CppInteropParseError]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
b.MemberF(1, 2);
|
||||
}
|
||||
@@ -130,15 +154,31 @@ void CallEnclosingF() {
|
||||
library "[[@TEST_NAME]]";
|
||||
import Cpp;
|
||||
|
||||
// CHECK:STDERR: fail_generic_unsupported_type.carbon:[[@LINE+2]]:1-39: error: semantics TODO: `failed to import C++ type` [SemanticsTodo]
|
||||
// CHECK:STDERR: ╭─┤ fail_generic_unsupported_type.carbon:[[@LINE+7]]:1
|
||||
// CHECK:STDERR: -> │ fn UnsupportedF[T: type](unused t: T) {}
|
||||
// CHECK:STDERR: · ━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━
|
||||
// CHECK:STDERR: · ┗━━┫ error: semantics TODO: `failed to import C++ type`
|
||||
// CHECK:STDERR: · ┃ [SemanticsTodo]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
fn UnsupportedF[T: type](unused t: T) {}
|
||||
|
||||
inline Cpp '''
|
||||
void CallUnsupportedF() {
|
||||
volatile int x;
|
||||
// CHECK:STDERR: fail_generic_unsupported_type.carbon:[[@LINE+3]]:3-22: error: no matching function for call to 'UnsupportedF' [CppInteropParseError]
|
||||
// CHECK:STDERR: fail_generic_unsupported_type.carbon:[[@LINE-6]]:39: note: candidate template ignored: substitution failure [with T = volatile int] [CppInteropParseNote]
|
||||
// CHECK:STDERR: ╭─┤ fail_generic_unsupported_type.carbon:[[@LINE+14]]:3
|
||||
// CHECK:STDERR: │ fn UnsupportedF[T: type](unused t: T) {}
|
||||
// CHECK:STDERR: · ┬
|
||||
// CHECK:STDERR: · ╰──┤ candidate template ignored:
|
||||
// CHECK:STDERR: · │ substitution failure [with T =
|
||||
// CHECK:STDERR: · │ volatile int]
|
||||
// CHECK:STDERR: · │ [CppInteropParseNote]
|
||||
// CHECK:STDERR: ┆
|
||||
// CHECK:STDERR: -> │ Carbon::UnsupportedF(x);
|
||||
// CHECK:STDERR: · ━━━━━━━━━━┳━━━━━━━━━
|
||||
// CHECK:STDERR: · ┗━━┫ error: no matching function for call to 'UnsupportedF'
|
||||
// CHECK:STDERR: · ┃ [CppInteropParseError]
|
||||
// CHECK:STDERR: ╰────
|
||||
// CHECK:STDERR:
|
||||
Carbon::UnsupportedF(x);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user