Rename and rearrange entities in tests to avoid name reuse (#7656)

Fix a bunch of cases where we use the same external name to mean
multiple different things in the same test. We've historically gotten
away with this, but under `--share-cpp-ast`, it becomes an error, at
least if the entity is either defined in, or used from, C++ code.

Assisted-by: Gemini via Antigravity (original change) and Claude Code
(suggested edits in review)

---------

Co-authored-by: Chandler Carruth <chandlerc@gmail.com>
This commit is contained in:
Richard Smith
2026-08-21 01:36:40 +00:00
committed by GitHub
co-authored by Chandler Carruth
parent 6eb900dff5
commit c588eadb57
53 changed files with 7794 additions and 7705 deletions
@@ -15,19 +15,19 @@ library "[[@TEST_NAME]]";
import Cpp;
fn F(a: array(i32, 5)) -> i32 { return a[2]; }
fn FArrayValueParam(a: array(i32, 5)) -> i32 { return a[2]; }
inline Cpp '''
int G() {
int GArrayValueParam() {
int arr[5];
//@dump-sem-ir-begin
return Carbon::F(arr);
return Carbon::FArrayValueParam(arr);
//@dump-sem-ir-end
}
int H() {
int HArrayValueParam() {
//@dump-sem-ir-begin
return Carbon::F({1, 2, 3, 4, 5});
return Carbon::FArrayValueParam({1, 2, 3, 4, 5});
//@dump-sem-ir-end
}
''';
@@ -44,23 +44,34 @@ import Cpp;
// TODO: These diagnostics are very bad.
// CHECK:STDERR: fail_todo_array_var_param.carbon:[[@LINE+8]]:1: error: semantics TODO: `by-var array parameter` [SemanticsTodo]
// CHECK:STDERR: fn F(var a: array(i32, 5)) -> i32 { return a[2]; }
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR: fn FArrayVarParam(var a: array(i32, 5)) -> i32 { return a[2]; }
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR:
// CHECK:STDERR: fail_todo_array_var_param.carbon:[[@LINE+4]]:1: error: semantics TODO: `failed to map C++ type to Carbon` [SemanticsTodo]
// CHECK:STDERR: fn F(var a: array(i32, 5)) -> i32 { return a[2]; }
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR: fn FArrayVarParam(var a: array(i32, 5)) -> i32 { return a[2]; }
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR:
fn F(var a: array(i32, 5)) -> i32 { return a[2]; }
fn FArrayVarParam(var a: array(i32, 5)) -> i32 { return a[2]; }
inline Cpp '''
int G() {
int GArrayVarParam() {
//@dump-sem-ir-begin
// CHECK:STDERR: fail_todo_array_var_param.carbon:[[@LINE+4]]:18: error: no member named 'F' in namespace 'Carbon' [CppInteropParseError]
// CHECK:STDERR: 28 | return Carbon::F({1, 2, 3, 4, 5});
// CHECK:STDERR: | ^
// CHECK:STDERR: fail_todo_array_var_param.carbon:[[@LINE+15]]:10: error: no member named 'FArrayVarParam' in namespace 'Carbon'; did you mean 'GArrayVarParam'? [CppInteropParseError]
// CHECK:STDERR: 39 | return Carbon::FArrayVarParam({1, 2, 3, 4, 5});
// CHECK:STDERR: | ^~~~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR: | GArrayVarParam
// CHECK:STDERR: fail_todo_array_var_param.carbon:[[@LINE-6]]:5: note: 'GArrayVarParam' declared here [CppInteropParseNote]
// CHECK:STDERR: 22 | int GArrayVarParam() {
// CHECK:STDERR: | ^
// CHECK:STDERR:
return Carbon::F({1, 2, 3, 4, 5});
// CHECK:STDERR: fail_todo_array_var_param.carbon:[[@LINE+7]]:33: error: too many arguments to function call, expected 0, have 1 [CppInteropParseError]
// CHECK:STDERR: 39 | return Carbon::FArrayVarParam({1, 2, 3, 4, 5});
// CHECK:STDERR: | ~~~~~~~~~~~~~~ ^~~~~~~~~~~~~~~
// CHECK:STDERR: fail_todo_array_var_param.carbon:[[@LINE-13]]:5: note: 'GArrayVarParam' declared here [CppInteropParseNote]
// CHECK:STDERR: 22 | int GArrayVarParam() {
// CHECK:STDERR: | ^
// CHECK:STDERR:
return Carbon::FArrayVarParam({1, 2, 3, 4, 5});
//@dump-sem-ir-end
}
''';
@@ -75,20 +86,28 @@ import Cpp;
// TODO: Support this, perhaps by returning a `std::array`.
// CHECK:STDERR: fail_todo_array_return.carbon:[[@LINE+4]]:1: error: semantics TODO: `array return type` [SemanticsTodo]
// CHECK:STDERR: fn F() -> array(i32, 5) {
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR: fn FArrayReturn() -> array(i32, 5) {
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR:
fn F() -> array(i32, 5) {
fn FArrayReturn() -> array(i32, 5) {
return (1, 2, 3, 4, 5);
}
inline Cpp '''
int G() {
// CHECK:STDERR: fail_todo_array_return.carbon:[[@LINE+4]]:24: error: no member named 'F' in namespace 'Carbon' [CppInteropParseError]
// CHECK:STDERR: 23 | auto &&arr = Carbon::F();
// CHECK:STDERR: | ^
int GArrayReturn() {
// CHECK:STDERR: fail_todo_array_return.carbon:[[@LINE+8]]:16: error: no member named 'FArrayReturn' in namespace 'Carbon'; did you mean 'GArrayReturn'? [CppInteropParseError]
// CHECK:STDERR: 27 | auto &&arr = Carbon::FArrayReturn();
// CHECK:STDERR: | ^~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR: | GArrayReturn
// CHECK:STDERR: fail_todo_array_return.carbon:[[@LINE-5]]:5: note: 'GArrayReturn' declared here [CppInteropParseNote]
// CHECK:STDERR: 18 | int GArrayReturn() {
// CHECK:STDERR: | ^
// CHECK:STDERR:
auto &&arr = Carbon::FArrayReturn();
// CHECK:STDERR: fail_todo_array_return.carbon:[[@LINE+4]]:13: error: subscripted value is not an array, pointer, or vector [CppInteropParseError]
// CHECK:STDERR: 32 | return arr[0];
// CHECK:STDERR: | ~~~^~
// CHECK:STDERR:
auto &&arr = Carbon::F();
return arr[0];
}
''';
@@ -20,7 +20,7 @@ class OneArg {
}
inline Cpp '''
void f() {
void CallOneArg() {
Carbon::OneArg a(42);
}
''';
@@ -30,26 +30,26 @@ library "[[@TEST_NAME]]";
import Cpp;
class OneArg {
fn OneArg(self, i: i32) -> Self;
class FactoryIsMethod {
fn FactoryIsMethod(self, i: i32) -> Self;
}
inline Cpp '''
void f() {
// CHECK:STDERR: fail_factory_is_method.carbon:[[@LINE+13]]:18: error: no matching constructor for initialization of 'Carbon::OneArg' [CppInteropParseError]
// CHECK:STDERR: 24 | Carbon::OneArg a(42);
// CHECK:STDERR: | ^ ~~
// CHECK:STDERR: fail_factory_is_method.carbon:[[@LINE-9]]:14: note: candidate constructor (the implicit copy constructor) not viable: no known conversion from 'int' to 'const OneArg' for 1st argument [CppInteropParseNote]
// CHECK:STDERR: 5 | class OneArg {
// CHECK:STDERR: | ^
// CHECK:STDERR: fail_factory_is_method.carbon:[[@LINE-12]]:14: note: candidate constructor (the implicit move constructor) not viable: no known conversion from 'int' to 'OneArg' for 1st argument [CppInteropParseNote]
// CHECK:STDERR: 5 | class OneArg {
// CHECK:STDERR: | ^
// CHECK:STDERR: fail_factory_is_method.carbon:[[@LINE-15]]:14: note: candidate constructor (the implicit default constructor) not viable: requires 0 arguments, but 1 was provided [CppInteropParseNote]
// CHECK:STDERR: 5 | class OneArg {
// CHECK:STDERR: | ^
void CallFactoryIsMethod() {
// CHECK:STDERR: fail_factory_is_method.carbon:[[@LINE+13]]:27: error: no matching constructor for initialization of 'Carbon::FactoryIsMethod' [CppInteropParseError]
// CHECK:STDERR: 24 | Carbon::FactoryIsMethod a(42);
// CHECK:STDERR: | ^ ~~
// CHECK:STDERR: fail_factory_is_method.carbon:[[@LINE-9]]:23: note: candidate constructor (the implicit copy constructor) not viable: no known conversion from 'int' to 'const FactoryIsMethod' for 1st argument [CppInteropParseNote]
// CHECK:STDERR: 5 | class FactoryIsMethod {
// CHECK:STDERR: | ^
// CHECK:STDERR: fail_factory_is_method.carbon:[[@LINE-12]]:23: note: candidate constructor (the implicit move constructor) not viable: no known conversion from 'int' to 'FactoryIsMethod' for 1st argument [CppInteropParseNote]
// CHECK:STDERR: 5 | class FactoryIsMethod {
// CHECK:STDERR: | ^
// CHECK:STDERR: fail_factory_is_method.carbon:[[@LINE-15]]:23: note: candidate constructor (the implicit default constructor) not viable: requires 0 arguments, but 1 was provided [CppInteropParseNote]
// CHECK:STDERR: 5 | class FactoryIsMethod {
// CHECK:STDERR: | ^
// CHECK:STDERR:
Carbon::OneArg a(42);
Carbon::FactoryIsMethod a(42);
}
''';
@@ -58,26 +58,26 @@ library "[[@TEST_NAME]]";
import Cpp;
class OneArg {
fn OneArg(i: i32) -> i32;
class FactoryDoesntReturnSelf {
fn FactoryDoesntReturnSelf(i: i32) -> i32;
}
inline Cpp '''
void f() {
// CHECK:STDERR: fail_factory_doesnt_return_self.carbon:[[@LINE+13]]:18: error: no matching constructor for initialization of 'Carbon::OneArg' [CppInteropParseError]
// CHECK:STDERR: 24 | Carbon::OneArg a(42);
// CHECK:STDERR: | ^ ~~
// CHECK:STDERR: fail_factory_doesnt_return_self.carbon:[[@LINE-9]]:14: note: candidate constructor (the implicit copy constructor) not viable: no known conversion from 'int' to 'const OneArg' for 1st argument [CppInteropParseNote]
// CHECK:STDERR: 5 | class OneArg {
// CHECK:STDERR: | ^
// CHECK:STDERR: fail_factory_doesnt_return_self.carbon:[[@LINE-12]]:14: note: candidate constructor (the implicit move constructor) not viable: no known conversion from 'int' to 'OneArg' for 1st argument [CppInteropParseNote]
// CHECK:STDERR: 5 | class OneArg {
// CHECK:STDERR: | ^
// CHECK:STDERR: fail_factory_doesnt_return_self.carbon:[[@LINE-15]]:14: note: candidate constructor (the implicit default constructor) not viable: requires 0 arguments, but 1 was provided [CppInteropParseNote]
// CHECK:STDERR: 5 | class OneArg {
// CHECK:STDERR: | ^
void CallFactoryDoesntReturnSelf() {
// CHECK:STDERR: fail_factory_doesnt_return_self.carbon:[[@LINE+13]]:35: error: no matching constructor for initialization of 'Carbon::FactoryDoesntReturnSelf' [CppInteropParseError]
// CHECK:STDERR: 24 | Carbon::FactoryDoesntReturnSelf a(42);
// CHECK:STDERR: | ^ ~~
// CHECK:STDERR: fail_factory_doesnt_return_self.carbon:[[@LINE-9]]:31: note: candidate constructor (the implicit copy constructor) not viable: no known conversion from 'int' to 'const FactoryDoesntReturnSelf' for 1st argument [CppInteropParseNote]
// CHECK:STDERR: 5 | class FactoryDoesntReturnSelf {
// CHECK:STDERR: | ^
// CHECK:STDERR: fail_factory_doesnt_return_self.carbon:[[@LINE-12]]:31: note: candidate constructor (the implicit move constructor) not viable: no known conversion from 'int' to 'FactoryDoesntReturnSelf' for 1st argument [CppInteropParseNote]
// CHECK:STDERR: 5 | class FactoryDoesntReturnSelf {
// CHECK:STDERR: | ^
// CHECK:STDERR: fail_factory_doesnt_return_self.carbon:[[@LINE-15]]:31: note: candidate constructor (the implicit default constructor) not viable: requires 0 arguments, but 1 was provided [CppInteropParseNote]
// CHECK:STDERR: 5 | class FactoryDoesntReturnSelf {
// CHECK:STDERR: | ^
// CHECK:STDERR:
Carbon::OneArg a(42);
Carbon::FactoryDoesntReturnSelf a(42);
}
''';
@@ -86,26 +86,26 @@ library "[[@TEST_NAME]]";
import Cpp;
class OneArg {
fn OneArg(i: i32) -> ref Self;
class FactoryReturnsByRef {
fn FactoryReturnsByRef(i: i32) -> ref Self;
}
inline Cpp '''
void f() {
// CHECK:STDERR: fail_factory_returns_by_ref.carbon:[[@LINE+13]]:18: error: no matching constructor for initialization of 'Carbon::OneArg' [CppInteropParseError]
// CHECK:STDERR: 24 | Carbon::OneArg a(42);
// CHECK:STDERR: | ^ ~~
// CHECK:STDERR: fail_factory_returns_by_ref.carbon:[[@LINE-9]]:14: note: candidate constructor (the implicit copy constructor) not viable: no known conversion from 'int' to 'const OneArg' for 1st argument [CppInteropParseNote]
// CHECK:STDERR: 5 | class OneArg {
// CHECK:STDERR: | ^
// CHECK:STDERR: fail_factory_returns_by_ref.carbon:[[@LINE-12]]:14: note: candidate constructor (the implicit move constructor) not viable: no known conversion from 'int' to 'OneArg' for 1st argument [CppInteropParseNote]
// CHECK:STDERR: 5 | class OneArg {
// CHECK:STDERR: | ^
// CHECK:STDERR: fail_factory_returns_by_ref.carbon:[[@LINE-15]]:14: note: candidate constructor (the implicit default constructor) not viable: requires 0 arguments, but 1 was provided [CppInteropParseNote]
// CHECK:STDERR: 5 | class OneArg {
// CHECK:STDERR: | ^
void CallFactoryReturnsByRef() {
// CHECK:STDERR: fail_factory_returns_by_ref.carbon:[[@LINE+13]]:31: error: no matching constructor for initialization of 'Carbon::FactoryReturnsByRef' [CppInteropParseError]
// CHECK:STDERR: 24 | Carbon::FactoryReturnsByRef a(42);
// CHECK:STDERR: | ^ ~~
// CHECK:STDERR: fail_factory_returns_by_ref.carbon:[[@LINE-9]]:27: note: candidate constructor (the implicit copy constructor) not viable: no known conversion from 'int' to 'const FactoryReturnsByRef' for 1st argument [CppInteropParseNote]
// CHECK:STDERR: 5 | class FactoryReturnsByRef {
// CHECK:STDERR: | ^
// CHECK:STDERR: fail_factory_returns_by_ref.carbon:[[@LINE-12]]:27: note: candidate constructor (the implicit move constructor) not viable: no known conversion from 'int' to 'FactoryReturnsByRef' for 1st argument [CppInteropParseNote]
// CHECK:STDERR: 5 | class FactoryReturnsByRef {
// CHECK:STDERR: | ^
// CHECK:STDERR: fail_factory_returns_by_ref.carbon:[[@LINE-15]]:27: note: candidate constructor (the implicit default constructor) not viable: requires 0 arguments, but 1 was provided [CppInteropParseNote]
// CHECK:STDERR: 5 | class FactoryReturnsByRef {
// CHECK:STDERR: | ^
// CHECK:STDERR:
Carbon::OneArg a(42);
Carbon::FactoryReturnsByRef a(42);
}
''';
@@ -125,7 +125,7 @@ class GenericConstructor {
}
inline Cpp '''
void f() {
void CallGenericConstructor() {
// CHECK:STDERR: fail_todo_call_generic_constructor.carbon:[[@LINE+13]]:30: error: no matching constructor for initialization of 'Carbon::GenericConstructor' [CppInteropParseError]
// CHECK:STDERR: 30 | Carbon::GenericConstructor b(0);
// CHECK:STDERR: | ^ ~
@@ -159,7 +159,7 @@ class GenericClass(T: type) {
}
inline Cpp '''
void f() {
void CallGenericClass() {
// CHECK:STDERR: fail_todo_call_generic_class_constructor.carbon:[[@LINE+13]]:29: error: no matching constructor for initialization of 'Carbon::GenericClass<int>' [CppInteropParseError]
// CHECK:STDERR: 30 | Carbon::GenericClass<int> c(0);
// CHECK:STDERR: | ^ ~
@@ -10,46 +10,51 @@
// TIP: To dump output, run:
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/interop/cpp/function/export/function.carbon
// --- other.carbon
// --- other_function.carbon
package Other;
package OtherFunction;
fn F1() {}
fn F2() -> i32 { return 0; }
fn F3(_: i32) {}
fn HasGenericArg(generic T: type, a: T) { a; }
fn HasDeducedArg[T: type](a: T) { a; }
// --- function.carbon
library "[[@TEST_NAME]]";
import Other;
import OtherFunction;
import Cpp inline '''
void G() {
Carbon::Other::F1();
void CallF1() {
Carbon::OtherFunction::F1();
}
''';
// --- other_return_int.carbon
package OtherReturnInt;
fn F2() -> i32 { return 0; }
// --- return_int.carbon
library "[[@TEST_NAME]]";
import Other;
import OtherReturnInt;
import Cpp inline '''
int G() {
return Carbon::Other::F2();
int CallF2() {
return Carbon::OtherReturnInt::F2();
}
''';
// --- other_args.carbon
package OtherArgs;
fn F3(_: i32) {}
// --- args.carbon
library "[[@TEST_NAME]]";
import Other;
import OtherArgs;
import Cpp inline '''
void G() {
Carbon::Other::F3(123);
void CallF3() {
Carbon::OtherArgs::F3(123);
}
''';
@@ -59,12 +64,12 @@ library "[[@TEST_NAME]]";
import Cpp;
fn F(ref n: i32);
fn RefF(ref n: i32);
inline Cpp '''
void G() {
void CallRefF() {
int n = 0;
Carbon::F(n);
Carbon::RefF(n);
}
''';
@@ -74,40 +79,50 @@ library "[[@TEST_NAME]]";
import Cpp;
fn F();
fn UsingF();
inline Cpp '''
using Carbon::F;
void G() { F(); }
using Carbon::UsingF;
void CallUsingF() { UsingF(); }
''';
// --- other_generic.carbon
package OtherGeneric;
fn HasGenericArg(generic T: type, a: T) { a; }
// --- fail_todo_generic.carbon
library "[[@TEST_NAME]]";
// CHECK:STDERR: fail_todo_generic.carbon:[[@LINE+9]]:1: in import [InImport]
// CHECK:STDERR: other.carbon:7:1: error: 1 argument passed to function expecting 2 arguments [CallArgCountMismatch]
// CHECK:STDERR: other_generic.carbon:3:1: error: 1 argument passed to function expecting 2 arguments [CallArgCountMismatch]
// CHECK:STDERR: fn HasGenericArg(generic T: type, a: T) { a; }
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR: fail_todo_generic.carbon:[[@LINE+5]]:1: in import [InImport]
// CHECK:STDERR: other.carbon:7:1: note: calling function declared here [InCallToEntity]
// CHECK:STDERR: other_generic.carbon:3:1: note: calling function declared here [InCallToEntity]
// CHECK:STDERR: fn HasGenericArg(generic T: type, a: T) { a; }
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR:
import Other;
import OtherGeneric;
import Cpp inline '''
void G() {
Carbon::Other::HasGenericArg<int>(123);
void CallHasGenericArg() {
Carbon::OtherGeneric::HasGenericArg<int>(123);
}
''';
// --- other_deduced.carbon
package OtherDeduced;
fn HasDeducedArg[T: type](a: T) { a; }
// --- deduced.carbon
library "[[@TEST_NAME]]";
import Other;
import OtherDeduced;
import Cpp inline '''
void G() {
Carbon::Other::HasDeducedArg(123);
void CallHasDeducedArg() {
Carbon::OtherDeduced::HasDeducedArg(123);
}
''';
@@ -39,7 +39,7 @@ fn F[T: I](t: T) -> T {
}
inline Cpp '''
Carbon::B G() {
Carbon::B CallInterfaceF() {
Carbon::A a;
Carbon::B b;
Carbon::F(a);
@@ -53,22 +53,22 @@ library "[[@TEST_NAME]]";
import Cpp;
// CHECK:STDERR: fail_todo_non_type_generic.carbon:[[@LINE+4]]:1: error: semantics TODO: `binding maps to a non-type template parameter` [SemanticsTodo]
// CHECK:STDERR: fn F[unused N: i32]() {}
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR: fn NonTypeF[unused N: i32]() {}
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR:
fn F[unused N: i32]() {}
fn NonTypeF[unused N: i32]() {}
inline Cpp '''
void G() {
// CHECK:STDERR: fail_todo_non_type_generic.carbon:[[@LINE+8]]:11: error: no member named 'F' in namespace 'Carbon' [CppInteropParseError]
// CHECK:STDERR: 20 | Carbon::F<3>();
// CHECK:STDERR: | ^
void CallNonTypeF() {
// CHECK:STDERR: fail_todo_non_type_generic.carbon:[[@LINE+8]]:11: error: no member named 'NonTypeF' in namespace 'Carbon' [CppInteropParseError]
// CHECK:STDERR: 20 | Carbon::NonTypeF<3>();
// CHECK:STDERR: | ^~~~~~~~
// CHECK:STDERR:
// CHECK:STDERR: fail_todo_non_type_generic.carbon:[[@LINE+4]]:16: error: expected expression [CppInteropParseError]
// CHECK:STDERR: 20 | Carbon::F<3>();
// CHECK:STDERR: | ^
// CHECK:STDERR: fail_todo_non_type_generic.carbon:[[@LINE+4]]:23: error: expected expression [CppInteropParseError]
// CHECK:STDERR: 20 | Carbon::NonTypeF<3>();
// CHECK:STDERR: | ^
// CHECK:STDERR:
Carbon::F<3>();
Carbon::NonTypeF<3>();
}
''';
@@ -76,13 +76,13 @@ void G() {
library "[[@TEST_NAME]]";
import Cpp;
fn F[T: type](unused t: T*) {}
fn PointerF[T: type](unused t: T*) {}
inline Cpp '''
void G() {
void CallPointerF() {
int x = 0;
int* _Nonnull p = &x;
Carbon::F(p);
Carbon::PointerF(p);
}
''';
@@ -90,26 +90,26 @@ void G() {
library "[[@TEST_NAME]]";
import Cpp;
class A(T: type) {
class EnclosingA(T: type) {
// CHECK:STDERR: fail_todo_enclosing_generic.carbon:[[@LINE+4]]:3: error: semantics TODO: `non-class non-namespace name scope` [SemanticsTodo]
// CHECK:STDERR: fn F[U: type](x: T, y: U);
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR: fn MemberF[U: type](x: T, y: U);
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR:
fn F[U: type](x: T, y: U);
fn MemberF[U: type](x: T, y: U);
}
alias B = A(i32);
alias EnclosingB = EnclosingA(i32);
inline Cpp '''
void f() {
// TODO: this currently fails because `B` can't be imported, but the intent
void CallEnclosingF() {
// TODO: this currently fails because `EnclosingB` can't be imported, but the intent
// is to test a generic function within an enclosing generic scope.
//
Carbon::B b;
// CHECK:STDERR: fail_todo_enclosing_generic.carbon:[[@LINE+4]]:5: error: no member named 'F' in 'Carbon::A<int>' [CppInteropParseError]
// CHECK:STDERR: 23 | b.F(1, 2);
Carbon::EnclosingB b;
// CHECK:STDERR: fail_todo_enclosing_generic.carbon:[[@LINE+4]]:5: error: no member named 'MemberF' in 'Carbon::EnclosingA<int>' [CppInteropParseError]
// CHECK:STDERR: 23 | b.MemberF(1, 2);
// CHECK:STDERR: | ~ ^
// CHECK:STDERR:
b.F(1, 2);
b.MemberF(1, 2);
}
''';
@@ -118,22 +118,22 @@ library "[[@TEST_NAME]]";
import Cpp;
// CHECK:STDERR: fail_generic_unsupported_type.carbon:[[@LINE+4]]:1: error: semantics TODO: `failed to import C++ type` [SemanticsTodo]
// CHECK:STDERR: fn F[T: type](unused t: T) {}
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR: fn UnsupportedF[T: type](unused t: T) {}
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR:
fn F[T: type](unused t: T) {}
fn UnsupportedF[T: type](unused t: T) {}
inline Cpp '''
void G() {
void CallUnsupportedF() {
volatile int x;
// CHECK:STDERR: fail_generic_unsupported_type.carbon:[[@LINE+7]]:3: error: no matching function for call to 'F' [CppInteropParseError]
// CHECK:STDERR: 20 | Carbon::F(x);
// CHECK:STDERR: | ^~~~~~~~~
// CHECK:STDERR: fail_generic_unsupported_type.carbon:[[@LINE-8]]:28: note: candidate template ignored: substitution failure [with T = volatile int] [CppInteropParseNote]
// CHECK:STDERR: 8 | fn F[T: type](unused t: T) {}
// CHECK:STDERR: | ^
// CHECK:STDERR: fail_generic_unsupported_type.carbon:[[@LINE+7]]:3: error: no matching function for call to 'UnsupportedF' [CppInteropParseError]
// CHECK:STDERR: 20 | Carbon::UnsupportedF(x);
// CHECK:STDERR: | ^~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR: fail_generic_unsupported_type.carbon:[[@LINE-8]]:39: note: candidate template ignored: substitution failure [with T = volatile int] [CppInteropParseNote]
// CHECK:STDERR: 8 | fn UnsupportedF[T: type](unused t: T) {}
// CHECK:STDERR: | ^
// CHECK:STDERR:
Carbon::F(x);
Carbon::UnsupportedF(x);
}
''';
@@ -274,7 +274,7 @@ void G() {
// CHECK:STDOUT: %.loc24_23.1: %I.type = converted %A.decl, %I.facet.loc24_23.1 [concrete = constants.%I.facet.f31]
// CHECK:STDOUT: %I.facet.loc24_23.2: %I.type = facet_value %B.decl, (constants.%I.impl_witness.b14) [concrete = constants.%I.facet.a68]
// CHECK:STDOUT: %.loc24_23.2: %I.type = converted %B.decl, %I.facet.loc24_23.2 [concrete = constants.%I.facet.a68]
// CHECK:STDOUT: inline_cpp "Carbon::B G() {\n Carbon::A a;\n Carbon::B b;\n Carbon::F(a);\n return Carbon::F(b);\n}\n"
// CHECK:STDOUT: inline_cpp "Carbon::B CallInterfaceF() {\n Carbon::A a;\n Carbon::B b;\n Carbon::F(a);\n return Carbon::F(b);\n}\n"
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: interface @I {