Source file test/directive.go
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 // Verify that misplaced directives are diagnosed. 8 9 //go:noinline // ERROR "misplaced compiler directive" 10 11 //go:noinline // ERROR "misplaced compiler directive" 12 package main 13 14 //go:nosplit 15 func f1() {} 16 17 //go:nosplit 18 //go:noinline 19 func f2() {} 20 21 //go:noinline // ERROR "misplaced compiler directive" 22 23 //go:noinline // ERROR "misplaced compiler directive" 24 var x int 25 26 //go:noinline // ERROR "misplaced compiler directive" 27 const c = 1 28 29 //go:noinline // ERROR "misplaced compiler directive" 30 type T int 31 32 type ( 33 //go:noinline // ERROR "misplaced compiler directive" 34 T2 int 35 //go:noinline // ERROR "misplaced compiler directive" 36 T3 int 37 ) 38 39 //go:noinline 40 func f() { 41 x := 1 42 43 { 44 _ = x 45 } 46 //go:noinline // ERROR "misplaced compiler directive" 47 var y int 48 _ = y 49 50 //go:noinline // ERROR "misplaced compiler directive" 51 const c = 1 52 53 _ = func() {} 54 55 //go:noinline // ERROR "misplaced compiler directive" 56 type T int 57 } 58