| 1 |
// errorcheck -0 -m |
| 2 |
|
| 3 |
// Copyright 2024 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 |
// Test no inlining of function calls in testing.B.Loop. |
| 8 |
// See issue #61515. |
| 9 |
|
| 10 |
package foo |
| 11 |
|
| 12 |
import "testing" |
| 13 |
|
| 14 |
func caninline(x int) int { // ERROR "can inline caninline" |
| 15 |
return x |
| 16 |
} |
| 17 |
|
| 18 |
func test(b *testing.B) { // ERROR "leaking param: b" |
| 19 |
for i := 0; i < b.N; i++ { |
| 20 |
caninline(1) // ERROR "inlining call to caninline" |
| 21 |
} |
| 22 |
for b.Loop() { // ERROR "skip inlining within testing.B.loop" "inlining call to testing\.\(\*B\)\.Loop" |
| 23 |
caninline(1) |
| 24 |
} |
| 25 |
for i := 0; i < b.N; i++ { |
| 26 |
caninline(1) // ERROR "inlining call to caninline" |
| 27 |
} |
| 28 |
for b.Loop() { // ERROR "skip inlining within testing.B.loop" "inlining call to testing\.\(\*B\)\.Loop" |
| 29 |
caninline(1) |
| 30 |
} |
| 31 |
for i := 0; i < b.N; i++ { |
| 32 |
caninline(1) // ERROR "inlining call to caninline" |
| 33 |
} |
| 34 |
for b.Loop() { // ERROR "skip inlining within testing.B.loop" "inlining call to testing\.\(\*B\)\.Loop" |
| 35 |
caninline(1) |
| 36 |
} |
| 37 |
} |