]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/cgo: visit cgo type inside ellipsis node
authorHiroshi Ioka <hirochachacha@gmail.com>
Mon, 30 Apr 2018 08:36:23 +0000 (17:36 +0900)
committerIan Lance Taylor <iant@golang.org>
Tue, 1 May 2018 00:44:48 +0000 (00:44 +0000)
Fixes #25143

Change-Id: Ide654fe70651fda827cdeeaaa73d2a1f8aefd7e7
Reviewed-on: https://go-review.googlesource.com/110159
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

misc/cgo/test/cgo_test.go
misc/cgo/test/issue25143.go [new file with mode: 0644]
src/cmd/cgo/ast.go

index bcea630ad20eab1316fa663318277020d473a98c..4462df0059875d7755e0d6c0c25f4f26606c8ec0 100644 (file)
@@ -88,6 +88,7 @@ func Test6907Go(t *testing.T)                { test6907Go(t) }
 func Test21897(t *testing.T)                 { test21897(t) }
 func Test22906(t *testing.T)                 { test22906(t) }
 func Test24206(t *testing.T)                 { test24206(t) }
+func Test25143(t *testing.T)                 { test25143(t) }
 
 func BenchmarkCgoCall(b *testing.B)  { benchCgoCall(b) }
 func BenchmarkGoString(b *testing.B) { benchGoString(b) }
diff --git a/misc/cgo/test/issue25143.go b/misc/cgo/test/issue25143.go
new file mode 100644 (file)
index 0000000..607bfe4
--- /dev/null
@@ -0,0 +1,22 @@
+// Copyright 2018 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 cgotest
+
+import "C"
+import "testing"
+
+func issue25143sum(ns ...C.int) C.int {
+       total := C.int(0)
+       for _, n := range ns {
+               total += n
+       }
+       return total
+}
+
+func test25143(t *testing.T) {
+       if got, want := issue25143sum(1, 2, 3), C.int(6); got != want {
+               t.Errorf("issue25143sum(1, 2, 3) == %v, expected %v", got, want)
+       }
+}
index 58e0ee78cb74cc8c77f27b172e943f81d523ec05..8dceb25ca6c30e3c1a7875338d479c57eb388240 100644 (file)
@@ -356,6 +356,7 @@ func (f *File) walk(x interface{}, context astContext, visit func(*File, interfa
        case *ast.BadExpr:
        case *ast.Ident:
        case *ast.Ellipsis:
+               f.walk(&n.Elt, ctxType, visit)
        case *ast.BasicLit:
        case *ast.FuncLit:
                f.walk(n.Type, ctxType, visit)