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
@@ -14,13 +14,13 @@
library "[[@TEST_NAME]]";
import Cpp;
class C(T: type) {
class GenericClass(T: type) {
var t: T;
}
inline Cpp '''
void F() {
Carbon::C<int> c;
void FGeneric() {
Carbon::GenericClass<int> c;
c.t = 123;
}
''';
@@ -29,14 +29,14 @@ void F() {
library "[[@TEST_NAME]]";
import Cpp;
class C(T: type) {
class SpecificClass(T: type) {
var t: T;
}
alias A = C(i32);
alias AliasInt = SpecificClass(i32);
inline Cpp '''
void F() {
Carbon::A a;
void FSpecific() {
Carbon::AliasInt a;
a.t = 123;
}
''';
@@ -46,25 +46,25 @@ library "[[@TEST_NAME]]";
import Cpp;
// CHECK:STDERR: fail_unsupported_specific_arg.carbon:[[@LINE+4]]:1: error: semantics TODO: `failed to map specific type arg to C++` [SemanticsTodo]
// CHECK:STDERR: class C(T: type) {
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~
// CHECK:STDERR: class UnsupportedClass(T: type) {
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR:
class C(T: type) {
class UnsupportedClass(T: type) {
var t: T;
}
alias A = C(());
alias AliasEmptyTuple = UnsupportedClass(());
inline Cpp '''
void F() {
void FUnsupported() {
// CHECK:STDERR: fail_unsupported_specific_arg.carbon:[[@LINE+8]]:11: error: semantics TODO: `interop with unsupported type` [SemanticsTodo]
// CHECK:STDERR: Carbon::A a;
// CHECK:STDERR: Carbon::AliasEmptyTuple a;
// CHECK:STDERR: ^
// CHECK:STDERR:
// CHECK:STDERR: fail_unsupported_specific_arg.carbon:[[@LINE+4]]:11: error: no type named 'A' in namespace 'Carbon' [CppInteropParseError]
// CHECK:STDERR: 23 | Carbon::A a;
// CHECK:STDERR: fail_unsupported_specific_arg.carbon:[[@LINE+4]]:11: error: no type named 'AliasEmptyTuple' in namespace 'Carbon' [CppInteropParseError]
// CHECK:STDERR: 23 | Carbon::AliasEmptyTuple a;
// CHECK:STDERR: | ~~~~~~~~^
// CHECK:STDERR:
Carbon::A a;
Carbon::AliasEmptyTuple a;
a.t = 123;
}
''';
@@ -73,7 +73,7 @@ void F() {
library "[[@TEST_NAME]]";
import Cpp;
class C(T: type) {
class ClassWithMethod(T: type) {
// CHECK:STDERR: fail_todo_generic_class_method_call.carbon:[[@LINE+4]]:3: error: semantics TODO: `non-class non-namespace name scope` [SemanticsTodo]
// CHECK:STDERR: fn M(unused ref self) {}
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~
@@ -82,9 +82,9 @@ class C(T: type) {
}
inline Cpp '''
void F() {
Carbon::C<int> c;
// CHECK:STDERR: fail_todo_generic_class_method_call.carbon:[[@LINE+4]]:5: error: no member named 'M' in 'Carbon::C<int>' [CppInteropParseError]
void FMethodCall() {
Carbon::ClassWithMethod<int> c;
// CHECK:STDERR: fail_todo_generic_class_method_call.carbon:[[@LINE+4]]:5: error: no member named 'M' in 'Carbon::ClassWithMethod<int>' [CppInteropParseError]
// CHECK:STDERR: 19 | c.M();
// CHECK:STDERR: | ~ ^
// CHECK:STDERR: