summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEden Li <eden.li@gmail.com>2009-11-23 22:02:12 -0800
committerEden Li <eden.li@gmail.com>2009-11-23 22:02:12 -0800
commit3cb0c26b5715da56eb9c6b526038962d57fae6f9 (patch)
treedde4a13e5129b7e093b97583eac7b96874878bf5
parent8b82e06f3621f78c5d526e1b12c075a79a34218d (diff)
downloadgolang-3cb0c26b5715da56eb9c6b526038962d57fae6f9.tar.gz
cgo translates empty function arguments into void instead of dying with 'unexpected type: ...'.
Fixes issue 162. R=rsc http://codereview.appspot.com/157147 Committer: Russ Cox <rsc@golang.org>
-rw-r--r--src/cmd/cgo/gcc.go9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/cmd/cgo/gcc.go b/src/cmd/cgo/gcc.go
index 7614f5a3b..d2a7eeadd 100644
--- a/src/cmd/cgo/gcc.go
+++ b/src/cmd/cgo/gcc.go
@@ -571,6 +571,15 @@ func (c *typeConv) FuncType(dtype *dwarf.FuncType) *FuncType {
p := make([]*Type, len(dtype.ParamType));
gp := make([]*ast.Field, len(dtype.ParamType));
for i, f := range dtype.ParamType {
+ // gcc's DWARF generator outputs a single DotDotDotType parameter for
+ // function pointers that specify no parameters (e.g. void
+ // (*__cgo_0)()). Treat this special case as void. This case is
+ // invalid according to ISO C anyway (i.e. void (*__cgo_1)(...) is not
+ // legal).
+ if _, ok := f.(*dwarf.DotDotDotType); ok && i == 0 {
+ p, gp = nil, nil;
+ break;
+ }
p[i] = c.FuncArg(f);
gp[i] = &ast.Field{Type: p[i].Go};
}