When diagnosing a duplicate name, point to the name instead of the instruction (#4953)

Left TODOs where more work is necessary before this change can be
applied or its impact can be verified.

Includes #4952, to avoid regression in some cases.

Similar to #4938. See
https://discord.com/channels/655572317891461132/655578254970716160/1339007384361762857.
This commit is contained in:
Boaz Brickner
2025-02-14 19:21:50 +00:00
committed by GitHub
parent 986a2a064c
commit dd7c64bad0
24 changed files with 58 additions and 50 deletions
@@ -16,9 +16,9 @@ library "[[@TEST_NAME]]";
import Cpp library "header.h";
// CHECK:STDERR: fail_duplicate_cpp_name.carbon:[[@LINE+7]]:1: error: duplicate name being declared in the same scope [NameDeclDuplicate]
// CHECK:STDERR: fail_duplicate_cpp_name.carbon:[[@LINE+7]]:11: error: duplicate name being declared in the same scope [NameDeclDuplicate]
// CHECK:STDERR: namespace Cpp;
// CHECK:STDERR: ^~~~~~~~~~~~~~
// CHECK:STDERR: ^~~
// CHECK:STDERR: fail_duplicate_cpp_name.carbon:[[@LINE-5]]:1: note: name is previously declared here [NameDeclPrevious]
// CHECK:STDERR: import Cpp library "header.h";
// CHECK:STDERR: ^~~~~~