From e8689404a7ba46acb491702fa8554c1394223325 Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Mon, 18 Jul 2011 07:23:52 -0700 Subject: [PATCH] cgo: add missing semicolon in generated struct This affected certain signatures needing padding like: //export Foo func Foo() (int, C.long) { ... } R=golang-dev, rsc CC=golang-dev https://golang.org/cl/4745047 --- misc/cgo/test/Makefile | 1 + misc/cgo/test/exports.go | 12 ++++++++++++ src/cmd/cgo/out.go | 2 +- 3 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 misc/cgo/test/exports.go diff --git a/misc/cgo/test/Makefile b/misc/cgo/test/Makefile index 43c45f416e2..f26f972898b 100644 --- a/misc/cgo/test/Makefile +++ b/misc/cgo/test/Makefile @@ -11,6 +11,7 @@ CGOFILES=\ basic.go\ callback.go\ env.go\ + exports.go\ issue1222.go\ issue1328.go\ issue1560.go\ diff --git a/misc/cgo/test/exports.go b/misc/cgo/test/exports.go new file mode 100644 index 00000000000..f96c60b004e --- /dev/null +++ b/misc/cgo/test/exports.go @@ -0,0 +1,12 @@ +// Copyright 2011 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" + +//export ReturnIntLong +func ReturnIntLong() (int, C.long) { + return 1, 2 +} diff --git a/src/cmd/cgo/out.go b/src/cmd/cgo/out.go index 59998073223..1dde2d935d9 100644 --- a/src/cmd/cgo/out.go +++ b/src/cmd/cgo/out.go @@ -412,7 +412,7 @@ func (p *Package) writeExports(fgo2, fc, fm *os.File) { t := p.cgoType(atype) if off%t.Align != 0 { pad := t.Align - off%t.Align - ctype += fmt.Sprintf("\t\tchar __pad%d[%d]\n", npad, pad) + ctype += fmt.Sprintf("\t\tchar __pad%d[%d];\n", npad, pad) off += pad npad++ }