Change-Id: I90c8e12a0be05d82bf6e147b5249859518f35c14
Reviewed-on: https://go-review.googlesource.com/c/go/+/394074
Run-TryBot: Alberto Donizetti <alb.donizetti@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Trust: Keith Randall <khr@golang.org>
return true
}
- case ir.OSELECT,
- ir.OGO,
+ case ir.OGO,
ir.ODEFER,
ir.ODCLTYPE, // can't print yet
ir.OTAILCALL:
ir.EditChildren(m, subst.edit)
if subst.newclofn == nil {
- // Translate any label on FOR, RANGE loops or SWITCH
+ // Translate any label on FOR, RANGE loops, SWITCH or SELECT
switch m.Op() {
case ir.OFOR:
m := m.(*ir.ForStmt)
m := m.(*ir.SwitchStmt)
m.Label = translateLabel(m.Label)
return m
- }
+ case ir.OSELECT:
+ m := m.(*ir.SelectStmt)
+ m.Label = translateLabel(m.Label)
+ return m
+ }
}
switch m := m.(type) {
import (
"runtime"
+ "time"
"unsafe"
)
func conv1(v uint64) uint64 { // ERROR "can inline conv1"
return uint64(uint64(uint64(uint64(uint64(uint64(uint64(uint64(uint64(uint64(uint64(v)))))))))))
}
+
+func select1(x, y chan bool) int { // ERROR "can inline select1" "x does not escape" "y does not escape"
+ select {
+ case <-x:
+ return 1
+ case <-y:
+ return 2
+ }
+}
+
+func select2(x chan bool) { // ERROR "can inline select2" "x does not escape"
+loop: // test that labeled select can be inlined.
+ select {
+ case <-x:
+ break loop
+ case <-time.After(time.Second): // ERROR "inlining call to time.After"
+ }
+}
+
+func inlineSelect2(x, y chan bool) { // ERROR "x does not escape" "y does not escape"
+loop:
+ for i := 0; i < 5; i++ {
+ if i == 3 {
+ break loop
+ }
+ select2(x) // ERROR "inlining call to select2" "inlining call to time.After"
+ }
+}