summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/cmd/compile/internal/gc/inl.go5
-rw-r--r--test/inline_variadic.go19
2 files changed, 21 insertions, 3 deletions
diff --git a/src/cmd/compile/internal/gc/inl.go b/src/cmd/compile/internal/gc/inl.go
index 59a047fdf2..d8f1f24536 100644
--- a/src/cmd/compile/internal/gc/inl.go
+++ b/src/cmd/compile/internal/gc/inl.go
@@ -781,10 +781,9 @@ func mkinlcall1(n *Node, fn *Node, isddd bool) *Node {
as.Right = nodnil()
as.Right.Type = varargtype
} else {
- vararrtype := typArray(varargtype.Elem(), int64(varargcount))
- as.Right = nod(OCOMPLIT, nil, typenod(vararrtype))
+ varslicetype := typSlice(varargtype.Elem())
+ as.Right = nod(OCOMPLIT, nil, typenod(varslicetype))
as.Right.List.Set(varargs)
- as.Right = nod(OSLICE, as.Right, nil)
}
as = typecheck(as, Etop)
diff --git a/test/inline_variadic.go b/test/inline_variadic.go
new file mode 100644
index 0000000000..6466c2b093
--- /dev/null
+++ b/test/inline_variadic.go
@@ -0,0 +1,19 @@
+// errorcheck -0 -m -l=3
+
+// Copyright 2016 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.
+
+// Test more aggressive inlining (-l=3 allows variadic functions)
+// See issue #18116.
+
+package foo
+
+func head(xs ...string) string { // ERROR "can inline head" "leaking param: xs to result"
+ return xs[0]
+}
+
+func f() string { // ERROR "can inline f"
+ x := head("hello", "world") // ERROR "inlining call to head" "\[\]string literal does not escape"
+ return x
+}