]> Cypherpunks repositories - gostls13.git/commitdiff
[dev.unified] test: extract different inline test between unified and non-unified
authorCuong Manh Le <cuong.manhle.vn@gmail.com>
Tue, 14 Jun 2022 02:04:55 +0000 (09:04 +0700)
committerGopher Robot <gobot@golang.org>
Wed, 15 Jun 2022 21:22:56 +0000 (21:22 +0000)
Unified IR records the inline nodes position right at the position of
the inline call, while the old inliner always records at the position of
the original nodes.

We want to keep non-unified working up through go 1.20, thus this CL
extract the inline test case that is different in Unified IR and the old
inliner.

Updates #53058

Change-Id: I14b0ee99fe797d34f27cfec068982790c64ac263
Reviewed-on: https://go-review.googlesource.com/c/go/+/411935
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
test/inline.go
test/inline_nounified.go [new file with mode: 0644]
test/inline_unified.go [new file with mode: 0644]
test/run.go

index 400898bceeb284dca30506e3d54717055ad58495..04ba16858fa1bcb61a2b892ffc1b316333f85209 100644 (file)
@@ -107,18 +107,6 @@ func q(x int) int { // ERROR "can inline q"
        return foo()                       // ERROR "inlining call to q.func1"
 }
 
-func r(z int) int {
-       foo := func(x int) int { // ERROR "can inline r.func1" "func literal does not escape"
-               return x + z
-       }
-       bar := func(x int) int { // ERROR "func literal does not escape" "can inline r.func2"
-               return x + func(y int) int { // ERROR "can inline r.func2.1" "can inline r.func3"
-                       return 2*y + x*z
-               }(x) // ERROR "inlining call to r.func2.1"
-       }
-       return foo(42) + bar(42) // ERROR "inlining call to r.func1" "inlining call to r.func2" "inlining call to r.func3"
-}
-
 func s0(x int) int { // ERROR "can inline s0"
        foo := func() { // ERROR "can inline s0.func1" "func literal does not escape"
                x = x + 1
diff --git a/test/inline_nounified.go b/test/inline_nounified.go
new file mode 100644 (file)
index 0000000..7a9fc10
--- /dev/null
@@ -0,0 +1,21 @@
+// errorcheckwithauto -0 -m -d=inlfuncswithclosures=1
+//go:build !goexperiment.unified
+// +build !goexperiment.unified
+
+// Copyright 2022 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 foo
+
+func r(z int) int {
+       foo := func(x int) int { // ERROR "can inline r.func1" "func literal does not escape"
+               return x + z
+       }
+       bar := func(x int) int { // ERROR "func literal does not escape" "can inline r.func2"
+               return x + func(y int) int { // ERROR "can inline r.func2.1" "can inline r.func3"
+                       return 2*y + x*z
+               }(x) // ERROR "inlining call to r.func2.1"
+       }
+       return foo(42) + bar(42) // ERROR "inlining call to r.func1" "inlining call to r.func2" "inlining call to r.func3"
+}
diff --git a/test/inline_unified.go b/test/inline_unified.go
new file mode 100644 (file)
index 0000000..ff70e44
--- /dev/null
@@ -0,0 +1,21 @@
+// errorcheckwithauto -0 -m -d=inlfuncswithclosures=1
+//go:build goexperiment.unified
+// +build goexperiment.unified
+
+// Copyright 2022 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 foo
+
+func r(z int) int {
+       foo := func(x int) int { // ERROR "can inline r.func1" "func literal does not escape"
+               return x + z
+       }
+       bar := func(x int) int { // ERROR "func literal does not escape" "can inline r.func2"
+               return x + func(y int) int { // ERROR "can inline r.func2.1"
+                       return 2*y + x*z
+               }(x) // ERROR "inlining call to r.func2.1"
+       }
+       return foo(42) + bar(42) // ERROR "inlining call to r.func1" "inlining call to r.func2" "can inline r.func3" "inlining call to r.func3"
+}
index c8e8ab9dfc63345400ab08c747dc03f82cf1f8fe..b0156fbbf8200bb24fe865146971ac47520bcba5 100644 (file)
@@ -1997,7 +1997,6 @@ var _ = setOf(
 var unifiedFailures = setOf(
        "closure3.go", // unified IR numbers closures differently than -d=inlfuncswithclosures
        "escape4.go",  // unified IR can inline f5 and f6; test doesn't expect this
-       "inline.go",   // unified IR reports function literal diagnostics on different lines than -d=inlfuncswithclosures
 
        "typeparam/issue47631.go", // unified IR can handle local type declarations
 )