summaryrefslogtreecommitdiff
path: root/misc
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2013-05-23 22:51:07 -0700
committerIan Lance Taylor <iant@golang.org>2013-05-23 22:51:07 -0700
commitf0d1d530e5c661e77e4e43dabb4c283d28ac70f9 (patch)
treeb445433c5b71fd2e013c981af64b0292ec941e8f /misc
parent048c5cf3470f64caeffa0ae36f5066b13efb53be (diff)
downloadgo-f0d1d530e5c661e77e4e43dabb4c283d28ac70f9.tar.gz
cmd/cgo: use intgo, not int, for string and slice structures
Fixes issue 5548. R=golang-dev, minux.ma CC=golang-dev https://codereview.appspot.com/9643044
Diffstat (limited to 'misc')
-rw-r--r--misc/cgo/test/cgo_test.go1
-rw-r--r--misc/cgo/test/issue5548.go26
-rw-r--r--misc/cgo/test/issue5548_c.c24
3 files changed, 51 insertions, 0 deletions
diff --git a/misc/cgo/test/cgo_test.go b/misc/cgo/test/cgo_test.go
index 14e1224e9..66c454f8e 100644
--- a/misc/cgo/test/cgo_test.go
+++ b/misc/cgo/test/cgo_test.go
@@ -40,5 +40,6 @@ func TestCallbackCallers(t *testing.T) { testCallbackCallers(t) }
func Test5227(t *testing.T) { test5227(t) }
func TestCflags(t *testing.T) { testCflags(t) }
func Test5337(t *testing.T) { test5337(t) }
+func Test5548(t *testing.T) { test5548(t) }
func BenchmarkCgoCall(b *testing.B) { benchCgoCall(b) }
diff --git a/misc/cgo/test/issue5548.go b/misc/cgo/test/issue5548.go
new file mode 100644
index 000000000..b41f46562
--- /dev/null
+++ b/misc/cgo/test/issue5548.go
@@ -0,0 +1,26 @@
+// Copyright 2013 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 "testing"
+
+/*
+extern int issue5548_in_c(void);
+*/
+import "C"
+
+//export issue5548FromC
+func issue5548FromC(s string, i int) int {
+ if len(s) == 4 && s == "test" && i == 42 {
+ return 1
+ }
+ return 0
+}
+
+func test5548(t *testing.T) {
+ if C.issue5548_in_c() == 0 {
+ t.Fail()
+ }
+}
diff --git a/misc/cgo/test/issue5548_c.c b/misc/cgo/test/issue5548_c.c
new file mode 100644
index 000000000..ee9c45934
--- /dev/null
+++ b/misc/cgo/test/issue5548_c.c
@@ -0,0 +1,24 @@
+// Copyright 2013 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.
+
+#include "_cgo_export.h"
+
+static void clobber_stack() {
+ volatile char a[1024];
+ int i;
+ for(i = 0; i < sizeof a; i++)
+ a[i] = 0xff;
+}
+
+static int call_go() {
+ GoString s;
+ s.p = "test";
+ s.n = 4;
+ return issue5548FromC(s, 42);
+}
+
+int issue5548_in_c() {
+ clobber_stack();
+ return call_go();
+}