mirror of
https://github.com/golang/go
synced 2024-11-24 01:20:08 -07:00
fc6bcdee79
Consider functions with an ODCLCONST for inlining and modify exprfmt to ignore those nodes when exporting. Don't add symbols to the export list if there is no definition. This occurs when OLITERAL symbols are looked up via Pkglookup for non-exported symbols. Fixes #7655 Change-Id: I1de827850f4c69e58107447314fe7433e378e069 Reviewed-on: https://go-review.googlesource.com/20773 Run-TryBot: Todd Neal <todd@tneal.org> Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org>
39 lines
980 B
Go
39 lines
980 B
Go
// errorcheck -0 -m
|
|
|
|
// Copyright 2015 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.
|
|
|
|
// Test, using compiler diagnostic flags, that inlining is working.
|
|
// Compiles but does not run.
|
|
|
|
package foo
|
|
|
|
import "unsafe"
|
|
|
|
func add2(p *byte, n uintptr) *byte { // ERROR "can inline add2" "leaking param: p to result"
|
|
return (*byte)(add1(unsafe.Pointer(p), n)) // ERROR "inlining call to add1"
|
|
}
|
|
|
|
func add1(p unsafe.Pointer, x uintptr) unsafe.Pointer { // ERROR "can inline add1" "leaking param: p to result"
|
|
return unsafe.Pointer(uintptr(p) + x)
|
|
}
|
|
|
|
func f(x *byte) *byte { // ERROR "can inline f" "leaking param: x to result"
|
|
return add2(x, 1) // ERROR "inlining call to add2" "inlining call to add1"
|
|
}
|
|
|
|
//go:noinline
|
|
func g(x int) int {
|
|
return x + 1
|
|
}
|
|
|
|
func h(x int) int { // ERROR "can inline h"
|
|
return x + 2
|
|
}
|
|
|
|
func i(x int) int { // ERROR "can inline i"
|
|
const y = 2
|
|
return x + y
|
|
}
|