diff options
author | Michael Stapelberg <stapelberg@debian.org> | 2013-12-03 09:43:15 +0100 |
---|---|---|
committer | Michael Stapelberg <stapelberg@debian.org> | 2013-12-03 09:43:15 +0100 |
commit | 64d2a7c8945ba05af859901f5e248f1befdd8621 (patch) | |
tree | 013fcb7e9e3296ecdda876012252c36bd6bcb063 /misc/cgo/testcdefs/cdefstest.go | |
parent | b901efe83e212f0c34c769c079e41373da12d723 (diff) | |
download | golang-64d2a7c8945ba05af859901f5e248f1befdd8621.tar.gz |
Imported Upstream version 1.2upstream/1.2
Diffstat (limited to 'misc/cgo/testcdefs/cdefstest.go')
-rw-r--r-- | misc/cgo/testcdefs/cdefstest.go | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/misc/cgo/testcdefs/cdefstest.go b/misc/cgo/testcdefs/cdefstest.go new file mode 100644 index 000000000..e6305b77d --- /dev/null +++ b/misc/cgo/testcdefs/cdefstest.go @@ -0,0 +1,41 @@ +// 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. +// +// +build ignore + +package cgotest + +/* +// This file tests a bug found in the cgo -cdefs tool that incorrectly +// translated Go pointer arrays generated by the cgo godefs tool back into C +// pointer arrays. +// +// The comments below show how the type is translated from gcc-style C into Go +// and back into C for both the buggy version and the correct version + +struct cdefsTest { + // This was already being handled correctly + // Correct: -> Array [20]int8 -> int8 array[20] + char array1[20]; + + // Buggy: -> Array [20][20]int8 -> [20]int8 array[20] + // Correct: -> Array [20][20]int8 -> int8 array[20][20] + char array2[20][20]; + + // Buggy: -> Array [20]*int8 -> *int8 array[20] + // Correct: -> Array [20]*int8 -> int8 *array[20] + char *array3[20]; + + // Buggy: -> Array [20][20]*int8 -> [20]*int8 array[20] + // Correct: -> Array [20]**int8 -> int8 *array[20][20] + char *array4[20][20]; + + // Buggy: -> Array [20][20]**int8 -> [20]**int8 array[20] + // Correct: -> Array [20][20]**int8 -> int8 **array[20][20] + char **array5[20][20]; +}; +*/ +import "C" + +type CdefsTest C.struct_cdefsTest |