mirror of
https://github.com/golang/go
synced 2024-11-24 16:50:13 -07:00
29483b3dae
Enable a bunch of types2-related error tests to run successfully, so they no longer have to be disabled in run.go. - directive.go: split it into directive.go and directive2.go, since the possible errors are now split across the parser and noder2, so they can't all be reported in one file. - linkname2.go: similarly, split it into linkname2.go and linkname3.go for the same reason. - issue16428.go, issue17645.go, issue47201.dir/bo.go: handle slightly different wording by types2 - issue5609.go: handle slight different error (array length must be integer vs. array bound too large). - float_lit3.go: handle slightly different wording (overflows float vs cannot convert to float) I purposely didn't try to fix tests yet where there are extra or missing errors on different lines, since that is not easy to make work for both -G=3 and -G=0. In a later change, will flip to make the types2 version match correctly, vs. the -G=0 version. Change-Id: I6079ff258e3b90146335b9995764e3b1b56cda59 Reviewed-on: https://go-review.googlesource.com/c/go/+/368455 Trust: Dan Scales <danscales@google.com> Run-TryBot: Dan Scales <danscales@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
72 lines
1.3 KiB
Go
72 lines
1.3 KiB
Go
// 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.
|
|
|
|
// Verify that misplaced directives are diagnosed.
|
|
|
|
//go:noinline // ERROR "misplaced compiler directive"
|
|
|
|
//go:noinline // ERROR "misplaced compiler directive"
|
|
package main
|
|
|
|
//go:nosplit
|
|
func f1() {}
|
|
|
|
//go:nosplit
|
|
//go:noinline
|
|
func f2() {}
|
|
|
|
//go:noinline // ERROR "misplaced compiler directive"
|
|
|
|
//go:noinline // ERROR "misplaced compiler directive"
|
|
var x int
|
|
|
|
//go:noinline // ERROR "misplaced compiler directive"
|
|
const c = 1
|
|
|
|
//go:noinline // ERROR "misplaced compiler directive"
|
|
type T int
|
|
|
|
// ok
|
|
//go:notinheap
|
|
type T1 int
|
|
|
|
type (
|
|
//go:notinheap
|
|
//go:noinline // ERROR "misplaced compiler directive"
|
|
T2 int
|
|
T2b int
|
|
//go:notinheap
|
|
T2c int
|
|
//go:noinline // ERROR "misplaced compiler directive"
|
|
T3 int
|
|
)
|
|
|
|
//go:noinline
|
|
func f() {
|
|
x := 1
|
|
|
|
{
|
|
_ = x
|
|
}
|
|
//go:noinline // ERROR "misplaced compiler directive"
|
|
var y int
|
|
_ = y
|
|
|
|
//go:noinline // ERROR "misplaced compiler directive"
|
|
const c = 1
|
|
|
|
_ = func() {}
|
|
|
|
//go:noinline // ERROR "misplaced compiler directive"
|
|
// ok:
|
|
//go:notinheap
|
|
type T int
|
|
}
|
|
|
|
// someday there might be a directive that can apply to type aliases, but go:notinheap doesn't.
|
|
//go:notinheap // ERROR "misplaced compiler directive"
|
|
type T6 = int
|