1
0
mirror of https://github.com/golang/go synced 2024-11-23 08:40:08 -07:00

[dev.typeparams] cmd/compile: report functions declared in Go and assembly

This CL reuses the symabi wrapper information to warn when a function
is defined both in Go (i.e., has a function declaration with a body)
and in assembly (i.e., has a TEXT instruction).

This will eventually produce a linker error anyway, but we can provide
a slightly nicer error message earlier.

Change-Id: Ia107f813343c0b10f4cd1013e7c72e67149ee52e
Reviewed-on: https://go-review.googlesource.com/c/go/+/333454
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
This commit is contained in:
Matthew Dempsky 2021-07-07 23:32:49 -07:00
parent 5059aed9dd
commit a12ad27119

View File

@ -152,6 +152,9 @@ func (s *SymABIs) GenABIWrappers() {
// Apply definitions.
defABI, hasDefABI := s.defs[symName]
if hasDefABI {
if len(fn.Body) != 0 {
base.ErrorfAt(fn.Pos(), "%v defined in both Go and assembly", fn)
}
fn.ABI = defABI
}