mirror of
				https://github.com/golang/go.git
				synced 2025-10-31 16:50:58 +00:00 
			
		
		
		
	 ec2ea40b31
			
		
	
	
		ec2ea40b31
		
	
	
	
	
		
			
			So it won't be visible outside of runtime package. There are changes to
make tests happy:
 - For test/directive*.go files, using "go:noinline" for testing misplaced
 directives instead.
 - Restrict test/fixedbugs/bug515.go for gccgo only.
 - For test/notinheap{2,3}.go, using runtime/cgo.Incomplete for marking
 the type as not-in-heap. Though it's somewhat clumsy, it's the easiest
 way to keep the test errors for not-in-heap types until we can cleanup
 further.
 - test/typeparam/mdempsky/11.go is about defined type in user code marked
 as go:notinheap, which can't happen after this CL, though.
Fixes #46731
Change-Id: I869f5b2230c8a2a363feeec042e7723bbc416e8e
Reviewed-on: https://go-review.googlesource.com/c/go/+/421882
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Joedian Reid <joedian@golang.org>
Reviewed-by: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
		
	
			
		
			
				
	
	
		
			57 lines
		
	
	
	
		
			1.1 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			57 lines
		
	
	
	
		
			1.1 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
 | |
| 
 | |
| type (
 | |
| 	//go:noinline // ERROR "misplaced compiler directive"
 | |
| 	T2 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"
 | |
| 	type T int
 | |
| }
 |