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
@@ -83,33 +83,34 @@ var s: Cpp.Simple({} as C) = Cpp.MakeSimple123();
library "[[@TEST_NAME]]";
import Cpp inline '''
template<bool B> struct Struct {};
Struct<true> MakeStruct() { return Struct<true>(); }
template<bool B> struct BoolStruct {};
BoolStruct<true> MakeBoolStruct() { return BoolStruct<true>(); }
''';
var s: Cpp.Struct(true) = Cpp.MakeStruct();
var s: Cpp.BoolStruct(true) = Cpp.MakeBoolStruct();
// --- float.carbon
library "[[@TEST_NAME]]";
import Cpp inline '''
template<float N> struct Struct {};
Struct<123.5f> MakeStruct() { return Struct<123.5f>(); }
template<float N> struct FloatStruct {};
FloatStruct<123.5f> MakeFloatStruct() { return FloatStruct<123.5f>(); }
''';
let v: Cpp.Struct(123.5) = Cpp.MakeStruct();
let v: Cpp.FloatStruct(123.5) = Cpp.MakeFloatStruct();
// --- pointer.carbon
library "[[@TEST_NAME]]";
import Cpp inline '''
template<const int* _Nonnull P> struct Struct {};
template<const int* _Nonnull P> struct PtrStruct {};
static int i = 123;
Struct<&i> MakeStruct() { return Struct<&i>(); }
PtrStruct<&i> MakePtrStruct() { return PtrStruct<&i>(); }
''';
let xyz: Cpp.Struct(&Cpp.i) = Cpp.MakeStruct();
let xyz: Cpp.PtrStruct(&Cpp.i) = Cpp.MakePtrStruct();
// --- valid.carbon