summaryrefslogtreecommitdiff
path: root/misc
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2014-06-02 12:55:43 -0700
committerIan Lance Taylor <iant@golang.org>2014-06-02 12:55:43 -0700
commita697cd6c3b8bc2b4ee10c89176108f085a059560 (patch)
tree9b54e81219af2618963d739fff2e3f2d77ba4a9a /misc
parent40a6a08802a1b4c7beeaa56a3e460c0328b2cb21 (diff)
downloadgo-a697cd6c3b8bc2b4ee10c89176108f085a059560.tar.gz
cmd/cgo: use same Go type for typedef to anonymous struct
If we see a typedef to an anonymous struct more than once, presumably in two different Go files that import "C", use the same Go type name. Fixes issue 8133. LGTM=rsc R=rsc CC=golang-codereviews https://codereview.appspot.com/102080043
Diffstat (limited to 'misc')
-rw-r--r--misc/cgo/test/issue8331.h7
-rw-r--r--misc/cgo/test/issue8331a.go15
-rw-r--r--misc/cgo/test/issue8331b.go13
3 files changed, 35 insertions, 0 deletions
diff --git a/misc/cgo/test/issue8331.h b/misc/cgo/test/issue8331.h
new file mode 100644
index 000000000..936ae9d5c
--- /dev/null
+++ b/misc/cgo/test/issue8331.h
@@ -0,0 +1,7 @@
+// 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.
+
+typedef struct {
+ int i;
+} issue8331;
diff --git a/misc/cgo/test/issue8331a.go b/misc/cgo/test/issue8331a.go
new file mode 100644
index 000000000..7fa55be43
--- /dev/null
+++ b/misc/cgo/test/issue8331a.go
@@ -0,0 +1,15 @@
+// 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.
+
+// Issue 8331. A typedef of an unnamed struct is the same struct when
+// #include'd twice. No runtime test; just make sure it compiles.
+
+package cgotest
+
+// #include "issue8331.h"
+import "C"
+
+func issue8331a() C.issue8331 {
+ return issue8331Var
+}
diff --git a/misc/cgo/test/issue8331b.go b/misc/cgo/test/issue8331b.go
new file mode 100644
index 000000000..d52aed63e
--- /dev/null
+++ b/misc/cgo/test/issue8331b.go
@@ -0,0 +1,13 @@
+// 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.
+
+// Issue 8331. A typedef of an unnamed struct is the same struct when
+// #include'd twice. No runtime test; just make sure it compiles.
+
+package cgotest
+
+// #include "issue8331.h"
+import "C"
+
+var issue8331Var C.issue8331