1
0
mirror of https://github.com/golang/go synced 2024-11-24 04:10:14 -07:00
go/test/fixedbugs/issue49100.go
Dan Scales b8da7e4c4c cmd/compile: fix inlining of labeled for loops
There is already a mechanism using inlgen to rename labels insided
inlined functions so that they are unique and don't clash with loops in
the outer function. This is used for OLABEL and OGOTO. Now that we are
doing inlining of OFOR loops, we need to do this translation for OBREAK,
OCONTINUE, and OFOR. I also added the translation for ORANGE loops, in
anticipation of a CL that will allow inlining of ORANGE for loops.

Fixes #49100

Change-Id: I2ccddc3350370825c386965f4a1e4bc54d3c369b
Reviewed-on: https://go-review.googlesource.com/c/go/+/357649
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Trust: Dan Scales <danscales@google.com>
2021-10-21 19:08:43 +00:00

28 lines
377 B
Go

// run
// 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.
package main
func f(j int) {
loop:
for i := 0; i < 4; i++ {
if i == 1 {
continue loop
}
println(j, i)
}
}
func main() {
loop:
for j := 0; j < 5; j++ {
f(j)
if j == 3 {
break loop
}
}
}