]> Cypherpunks repositories - gostls13.git/commitdiff
cgo no longer translates function args that are void* into
authorEden Li <eden.li@gmail.com>
Wed, 18 Nov 2009 07:42:21 +0000 (23:42 -0800)
committerRuss Cox <rsc@golang.org>
Wed, 18 Nov 2009 07:42:21 +0000 (23:42 -0800)
unsafe.Pointer.
Fixes #254.

R=rsc
https://golang.org/cl/157060

src/cmd/cgo/gcc.go

index d6b5c6bc85434f9908f2352c6403cb5ae5417537..79dcd29a9657ac39500f906e24aa5f83749b4f78 100644 (file)
@@ -552,7 +552,11 @@ func (c *typeConv) FuncArg(dtype dwarf.Type) *Type {
                // is type T defined as *X, simulate a little of the
                // laxness of C by making the argument *X instead of T.
                if ptr, ok := base(dt.Type).(*dwarf.PtrType); ok {
-                       return c.Type(ptr)
+                       // Unless the typedef happens to point to void* since
+                       // Go has special rules around using unsafe.Pointer.
+                       if _, void := base(ptr.Type).(*dwarf.VoidType); !void {
+                               return c.Type(ptr)
+                       }
                }
        }
        return t;