summaryrefslogtreecommitdiffstats
path: root/test/linkname2.go
blob: 43e66a584958bbb03fd2177b01b20f87c62c6871 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// errorcheck

// Copyright 2020 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

// Tests that errors are reported for misuse of linkname.
package p

import _ "unsafe"

type t int

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 "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
//go:linkname t notvarfunc
//go:linkname x duplicate