]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/cgo: fix for function taking pointer typedef
authorJess Frazelle <me@jessfraz.com>
Tue, 18 Jul 2017 03:41:40 +0000 (23:41 -0400)
committerRuss Cox <rsc@golang.org>
Wed, 29 Nov 2017 16:12:45 +0000 (16:12 +0000)
Fixes #19832

Change-Id: I7ce39c2c435d4716d8a42ac6784b4c87874c0e13
Reviewed-on: https://go-review.googlesource.com/49490
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
misc/cgo/test/issue19832.go [new file with mode: 0644]
src/cmd/cgo/gcc.go

diff --git a/misc/cgo/test/issue19832.go b/misc/cgo/test/issue19832.go
new file mode 100644 (file)
index 0000000..4458777
--- /dev/null
@@ -0,0 +1,16 @@
+// Copyright 2015 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.
+
+// Issue 19832. Functions taking a pointer typedef were being expanded and triggering a compiler error.
+
+package cgotest
+
+// typedef struct { int i; } *PS;
+// void T19832(PS p) {}
+import "C"
+import "testing"
+
+func test19832(t *testing.T) {
+       C.T19832(nil)
+}
index 77a59c6633aeaa26f83927aa720f9dfb3fa190c9..a59892ef0082a263aa5c3c7732deb08fdfd4c649 100644 (file)
@@ -2227,6 +2227,12 @@ func (c *typeConv) FuncArg(dtype dwarf.Type, pos token.Pos) *Type {
                                break
                        }
 
+                       // If we already know the typedef for t just use that.
+                       // See issue 19832.
+                       if def := typedef[t.Go.(*ast.Ident).Name]; def != nil {
+                               break
+                       }
+
                        t = c.Type(ptr, pos)
                        if t == nil {
                                return nil