]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: fix test/typeparam/mdempsky/4.go for -G=3
authorwdvxdr <wdvxdr1123@gmail.com>
Fri, 10 Sep 2021 12:56:29 +0000 (20:56 +0800)
committerDan Scales <danscales@google.com>
Tue, 14 Sep 2021 23:03:28 +0000 (23:03 +0000)
Change-Id: I894ee000561a3c6afede8df697b1bce4576ceef0
Reviewed-on: https://go-review.googlesource.com/c/go/+/349012
Reviewed-by: Dan Scales <danscales@google.com>
Trust: Dan Scales <danscales@google.com>
Trust: Keith Randall <khr@golang.org>

src/cmd/compile/internal/typecheck/iimport.go
test/run.go

index 6eec94a98499a6ec998bc3104dc1f5e7f11ed3c4..b3a0eb8871ab427fbf0febef5952983cc78c0902 100644 (file)
@@ -1166,10 +1166,26 @@ func (r *importReader) stmtList() []ir.Node {
                if n.Op() == ir.OBLOCK {
                        n := n.(*ir.BlockStmt)
                        list = append(list, n.List...)
-               } else {
-                       list = append(list, n)
+                       continue
                }
-
+               if len(list) > 0 {
+                       // check for an optional label that can only immediately
+                       // precede a for/range/select/switch statement.
+                       if last := list[len(list)-1]; last.Op() == ir.OLABEL {
+                               label := last.(*ir.LabelStmt).Label
+                               switch n.Op() {
+                               case ir.OFOR:
+                                       n.(*ir.ForStmt).Label = label
+                               case ir.ORANGE:
+                                       n.(*ir.RangeStmt).Label = label
+                               case ir.OSELECT:
+                                       n.(*ir.SelectStmt).Label = label
+                               case ir.OSWITCH:
+                                       n.(*ir.SwitchStmt).Label = label
+                               }
+                       }
+               }
+               list = append(list, n)
        }
        return list
 }
index 790b54bfd2c2185eb74f3e6e5c2eaee666944621..3fb87af397ce1953a5932b9a6f7555a492278388 100644 (file)
@@ -2187,8 +2187,6 @@ var g3Failures = setOf(
        "writebarrier.go", // correct diagnostics, but different lines (probably irgen's fault)
 
        "typeparam/nested.go", // -G=3 doesn't support function-local types with generics
-
-       "typeparam/mdempsky/4.go", // -G=3 can't export functions with labeled breaks in loops
 )
 
 var unifiedFailures = setOf(