File tree 5 files changed +48
-3
lines changed
src/cmd/compile/internal/inline
5 files changed +48
-3
lines changed Original file line number Diff line number Diff line change @@ -358,8 +358,7 @@ func (v *hairyVisitor) doNode(n ir.Node) bool {
358
358
return true
359
359
}
360
360
361
- case ir .ORANGE ,
362
- ir .OSELECT ,
361
+ case ir .OSELECT ,
363
362
ir .OGO ,
364
363
ir .ODEFER ,
365
364
ir .ODCLTYPE , // can't print yet
Original file line number Diff line number Diff line change
1
+ // run
2
+
3
+ // Copyright 2021 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
+ package main
8
+
9
+ func r (j int ) {
10
+ loop:
11
+ for i , c := range "goclang" {
12
+ if i == 2 {
13
+ continue loop
14
+ }
15
+ println (string (c ))
16
+ }
17
+ }
18
+
19
+ func main () {
20
+ loop:
21
+ for j := 0 ; j < 4 ; j ++ {
22
+ r (j )
23
+ if j == 0 {
24
+ break loop
25
+ }
26
+ }
27
+ }
Original file line number Diff line number Diff line change
1
+ g
2
+ o
3
+ l
4
+ a
5
+ n
6
+ g
Original file line number Diff line number Diff line change @@ -160,6 +160,19 @@ func switchType(x interface{}) int { // ERROR "can inline switchType" "x does no
160
160
}
161
161
}
162
162
163
+ func inlineRangeIntoMe (data []int ) { // ERROR "can inline inlineRangeIntoMe" "data does not escape"
164
+ rangeFunc (data , 12 ) // ERROR "inlining call to rangeFunc"
165
+ }
166
+
167
+ func rangeFunc (xs []int , b int ) int { // ERROR "can inline rangeFunc" "xs does not escape"
168
+ for i , x := range xs {
169
+ if x == b {
170
+ return i
171
+ }
172
+ }
173
+ return - 1
174
+ }
175
+
163
176
type T struct {}
164
177
165
178
func (T ) meth (int , int ) {} // ERROR "can inline T.meth"
Original file line number Diff line number Diff line change 1
1
package x
2
2
3
- func indexByte (xs []byte , b byte ) int { // ERROR "xs does not escape"
3
+ func indexByte (xs []byte , b byte ) int { // ERROR "xs does not escape" "can inline indexByte"
4
4
for i , x := range xs {
5
5
if x == b {
6
6
return i
You can’t perform that action at this time.
0 commit comments