switch n.Op {
// Call is okay if inlinable and we have the budget for the body.
case OCALLFUNC:
- if isIntrinsicCall(n) {
- v.budget--
- break
- }
// Functions that call runtime.getcaller{pc,sp} can not be inlined
// because getcaller{pc,sp} expect a pointer to the caller's first argument.
//
}
}
+ if isIntrinsicCall(n) {
+ v.budget--
+ break
+ }
+
if fn := n.Left.Func; fn != nil && fn.Inl != nil {
v.budget -= fn.Inl.Cost
break
// dirs are the directories to look for *.go files in.
// TODO(bradfitz): just use all directories?
- dirs = []string{".", "ken", "chan", "interface", "syntax", "dwarf", "fixedbugs", "codegen"}
+ dirs = []string{".", "ken", "chan", "interface", "syntax", "dwarf", "fixedbugs", "codegen", "runtime"}
// ratec controls the max number of tests running at a time.
ratec chan bool
--- /dev/null
+// Copyright 2019 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.
+
+The runtime directory contains tests that specifically need
+to be compiled as-if in the runtime package. For error-check
+tests, these require the additional flags -+ and -p=runtime.
--- /dev/null
+// errorcheck -0 -+ -p=runtime -m -newescape=true
+
+// Copyright 2019 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.
+
+package runtime
+
+// A function that calls runtime.getcallerpc or runtime.getcallersp()
+// cannot be inlined, no matter how small it is.
+
+func getcallerpc() uintptr
+func getcallersp() uintptr
+
+func pc() uintptr {
+ return getcallerpc() + 1
+}
+
+func cpc() uintptr { // ERROR "can inline cpc"
+ return pc() + 2
+}
+
+func sp() uintptr {
+ return getcallersp() + 3
+}
+
+func csp() uintptr { // ERROR "can inline csp"
+ return sp() + 4
+}