| 1 |
// errorcheck |
| 2 |
|
| 3 |
// Copyright 2020 The Go Authors. All rights reserved. |
| 4 |
// Use of this source code is governed by a BSD-style |
| 5 |
// license that can be found in the LICENSE file. |
| 6 |
|
| 7 |
// Tests that errors are reported for misuse of linkname. |
| 8 |
package p |
| 9 |
|
| 10 |
import _ "unsafe" |
| 11 |
|
| 12 |
type t int |
| 13 |
|
| 14 |
var x, y int |
| 15 |
|
| 16 |
func F[T any](T) {} |
| 17 |
|
| 18 |
//go:linkname x ok |
| 19 |
|
| 20 |
// ERROR "//go:linkname must refer to declared function or variable" |
| 21 |
// ERROR "//go:linkname must refer to declared function or variable" |
| 22 |
// ERROR "duplicate //go:linkname for x" |
| 23 |
// ERROR "//go:linkname reference of an instantiation is not allowed" |
| 24 |
|
| 25 |
//line linkname3.go:20 |
| 26 |
//go:linkname nonexist nonexist |
| 27 |
//go:linkname t notvarfunc |
| 28 |
//go:linkname x duplicate |
| 29 |
//go:linkname i F[go.shape.int] |