aboutsummaryrefslogtreecommitdiff
path: root/misc/cgo/errors
diff options
context:
space:
mode:
authorDaniel Morsing <daniel.morsing@gmail.com>2014-03-27 20:23:16 +0000
committerDaniel Morsing <daniel.morsing@gmail.com>2014-03-27 20:23:16 +0000
commit0f82cfd3f0ef84b553cd0f1e8cd578b3c29ea5d9 (patch)
tree5f97c7296e641fcd1335018240be3a0de5daefc9 /misc/cgo/errors
parent444dd26bf4c585ce71dfcd9e581865ba3047dc75 (diff)
downloadgo-0f82cfd3f0ef84b553cd0f1e8cd578b3c29ea5d9.tar.xz
cmd/cgo: enforce typing of 0-sized types
cgo represents all 0-sized and unsized types internally as [0]byte. This means that pointers to incomplete types would be interchangable, even if given a name by typedef. Fixes #7409. LGTM=iant R=golang-codereviews, bradfitz, iant CC=golang-codereviews https://golang.org/cl/76450043
Diffstat (limited to 'misc/cgo/errors')
-rw-r--r--misc/cgo/errors/err3.go18
-rwxr-xr-xmisc/cgo/errors/test.bash1
2 files changed, 19 insertions, 0 deletions
diff --git a/misc/cgo/errors/err3.go b/misc/cgo/errors/err3.go
new file mode 100644
index 0000000000..3680a4a4c1
--- /dev/null
+++ b/misc/cgo/errors/err3.go
@@ -0,0 +1,18 @@
+// Copyright 2014 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 main
+
+/*
+typedef struct foo foo_t;
+typedef struct bar bar_t;
+
+foo_t *foop;
+*/
+import "C"
+
+func main() {
+ x := (*C.bar_t)(nil)
+ C.foop = x // ERROR HERE
+}
diff --git a/misc/cgo/errors/test.bash b/misc/cgo/errors/test.bash
index 697ae2fed2..f0f60c8445 100755
--- a/misc/cgo/errors/test.bash
+++ b/misc/cgo/errors/test.bash
@@ -26,6 +26,7 @@ check() {
check err1.go
check err2.go
+check err3.go
rm -rf errs _obj
exit 0