Skip to content

Commit 3ea6ee2

Browse files
authored
Merge pull request #72760 from gottesmm/pr-9f0fef6eb535d1e5860df021c272806b2a8494f8
[silgen] Emit the location of the original function def if SILGen is erroring on a duplicate symbol definition.
2 parents 1f09be9 + 19c72ac commit 3ea6ee2

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

include/swift/AST/DiagnosticsSIL.def

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ ERROR(bridging_objcbridgeable_broken,none,
4646
ERROR(sil_function_redefinition,none,
4747
"multiple definitions of symbol '%0'",
4848
(StringRef))
49+
NOTE(sil_function_redefinition_note,none,
50+
"other definition here",
51+
())
4952

5053
ERROR(invalid_sil_builtin,none,
5154
"INTERNAL ERROR: invalid use of builtin: %0",

lib/SILGen/SILGen.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -813,6 +813,8 @@ void SILGenModule::emitFunctionDefinition(SILDeclRef constant, SILFunction *f) {
813813
if (!f->empty()) {
814814
diagnose(constant.getAsRegularLocation(), diag::sil_function_redefinition,
815815
f->getName());
816+
if (f->hasLocation())
817+
diagnose(f->getLocation(), diag::sil_function_redefinition_note);
816818
return;
817819
}
818820

test/SILGen/diagnose_duplicate_functions.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// RUN: %target-swift-emit-silgen %s -o /dev/null -verify
22

33
@_silgen_name("foo")
4-
func a(_ x: Int) -> Int {
4+
func a(_ x: Int) -> Int { // expected-note {{other definition here}}
55
return x
66
}
77

@@ -11,7 +11,7 @@ func b(_ x: Int) -> Int { // expected-error {{multiple definitions of symbol 'fo
1111
}
1212

1313
@_cdecl("bar")
14-
func c(_ x: Int) -> Int {
14+
func c(_ x: Int) -> Int { // expected-note {{other definition here}}
1515
return x
1616
}
1717

0 commit comments

Comments
 (0)