Skip to content

Commit

Permalink
cmd/compile: resolve the TODO of processPragmas
Browse files Browse the repository at this point in the history
Change-Id: Id723ecc2480aea2d8acb4d3e05db4a6c8eef9cc8
Reviewed-on: https://go-review.googlesource.com/c/go/+/333109
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Trust: Matthew Dempsky <mdempsky@google.com>
Trust: Cherry Mui <cherryyz@google.com>
  • Loading branch information
WangLeonard authored and josharian committed Oct 28, 2021
1 parent 12dc48f commit b2fe2eb
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 7 deletions.
3 changes: 1 addition & 2 deletions src/cmd/compile/internal/noder/noder.go
Original file line number Diff line number Diff line change
Expand Up @@ -323,8 +323,7 @@ func (p *noder) processPragmas() {
}
n := ir.AsNode(typecheck.Lookup(l.local).Def)
if n == nil || n.Op() != ir.ONAME {
// TODO(mdempsky): Change to p.errorAt before Go 1.17 release.
// base.WarnfAt(p.makeXPos(l.pos), "//go:linkname must refer to declared function or variable (will be an error in Go 1.17)")
p.errorAt(l.pos, "//go:linkname must refer to declared function or variable")
continue
}
if n.Sym().Linkname != "" {
Expand Down
1 change: 1 addition & 0 deletions src/cmd/cover/testdata/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ package main
import _ "unsafe" // for go:linkname

//go:linkname some_name some_name
var some_name int

const anything = 1e9 // Just some unlikely value that means "we got here, don't care how often"

Expand Down
7 changes: 2 additions & 5 deletions test/linkname2.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,10 @@ var x, y int
//go:linkname x ok

// ERROR "//go:linkname requires linkname argument or -p compiler flag"
// BAD: want error "//go:linkname must refer to declared function or variable"
// BAD: want error "//go:linkname must refer to declared function or variable"
// ERROR "//go:linkname must refer to declared function or variable"
// ERROR "//go:linkname must refer to declared function or variable"
// ERROR "duplicate //go:linkname for x"

// The two BAD lines are just waiting for #42938 before we can
// re-enable the errors.

//line linkname2.go:18
//go:linkname y
//go:linkname nonexist nonexist
Expand Down

0 comments on commit b2fe2eb

Please sign in to comment.