Black Lives Matter. Support the Equal Justice Initiative.

Source file test/linkname2.go

Documentation: test

     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  //go:linkname x ok
    17  
    18  // ERROR "//go:linkname requires linkname argument or -p compiler flag"
    19  // BAD: want error "//go:linkname must refer to declared function or variable"
    20  // BAD: want error "//go:linkname must refer to declared function or variable"
    21  // ERROR "duplicate //go:linkname for x"
    22  
    23  // The two BAD lines are just waiting for #42938 before we can
    24  // re-enable the errors.
    25  
    26  //line linkname2.go:18
    27  //go:linkname y
    28  //go:linkname nonexist nonexist
    29  //go:linkname t notvarfunc
    30  //go:linkname x duplicate
    31  

View as plain text