diff options
author | Ian Lance Taylor <iant@golang.org> | 2020-12-23 09:57:37 -0800 |
---|---|---|
committer | Ian Lance Taylor <iant@golang.org> | 2020-12-30 15:13:24 -0800 |
commit | cfcbb4227fb20191e04eb8d7766ae6202f526afd (patch) | |
tree | e2effea96f6f204451779f044415c2385e45042b /libgo/misc/cgo/testgodefs | |
parent | 0696141107d61483f38482b941549959a0d7f613 (diff) | |
download | gcc-cfcbb4227fb20191e04eb8d7766ae6202f526afd.zip gcc-cfcbb4227fb20191e04eb8d7766ae6202f526afd.tar.gz gcc-cfcbb4227fb20191e04eb8d7766ae6202f526afd.tar.bz2 |
libgo: update to Go1.16beta1 release
This does not yet include support for the //go:embed directive added
in this release.
* Makefile.am (check-runtime): Don't create check-runtime-dir.
(mostlyclean-local): Don't remove check-runtime-dir.
(check-go-tool, check-vet): Copy in go.mod and modules.txt.
(check-cgo-test, check-carchive-test): Add go.mod file.
* Makefile.in: Regenerate.
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/280172
Diffstat (limited to 'libgo/misc/cgo/testgodefs')
-rw-r--r-- | libgo/misc/cgo/testgodefs/testdata/bitfields.go | 31 | ||||
-rw-r--r-- | libgo/misc/cgo/testgodefs/testdata/main.go | 28 | ||||
-rw-r--r-- | libgo/misc/cgo/testgodefs/testgodefs_test.go | 1 |
3 files changed, 60 insertions, 0 deletions
diff --git a/libgo/misc/cgo/testgodefs/testdata/bitfields.go b/libgo/misc/cgo/testgodefs/testdata/bitfields.go new file mode 100644 index 0000000..6a9724d --- /dev/null +++ b/libgo/misc/cgo/testgodefs/testdata/bitfields.go @@ -0,0 +1,31 @@ +// Copyright 2020 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 main + +// This file tests that we don't generate an incorrect field location +// for a bitfield that appears aligned. + +/* +struct bitfields { + unsigned int B1 : 5; + unsigned int B2 : 1; + unsigned int B3 : 1; + unsigned int B4 : 1; + unsigned int Short1 : 16; // misaligned on 8 bit boundary + unsigned int B5 : 1; + unsigned int B6 : 1; + unsigned int B7 : 1; + unsigned int B8 : 1; + unsigned int B9 : 1; + unsigned int B10 : 3; + unsigned int Short2 : 16; // alignment is OK + unsigned int Short3 : 16; // alignment is OK +}; +*/ +import "C" + +type bitfields C.struct_bitfields diff --git a/libgo/misc/cgo/testgodefs/testdata/main.go b/libgo/misc/cgo/testgodefs/testdata/main.go index 2e1ad33..4a3f6a7 100644 --- a/libgo/misc/cgo/testgodefs/testdata/main.go +++ b/libgo/misc/cgo/testgodefs/testdata/main.go @@ -4,6 +4,12 @@ package main +import ( + "fmt" + "os" + "reflect" +) + // Test that the struct field in anonunion.go was promoted. var v1 T var v2 = v1.L @@ -23,4 +29,26 @@ var v7 = S{} var _ = issue38649{X: 0} func main() { + pass := true + + // The Go translation of bitfields should not have any of the + // bitfield types. The order in which bitfields are laid out + // in memory is implementation defined, so we can't easily + // know how a bitfield should correspond to a Go type, even if + // it appears to be aligned correctly. + bitfieldType := reflect.TypeOf(bitfields{}) + check := func(name string) { + _, ok := bitfieldType.FieldByName(name) + if ok { + fmt.Fprintf(os.Stderr, "found unexpected bitfields field %s\n", name) + pass = false + } + } + check("Short1") + check("Short2") + check("Short3") + + if !pass { + os.Exit(1) + } } diff --git a/libgo/misc/cgo/testgodefs/testgodefs_test.go b/libgo/misc/cgo/testgodefs/testgodefs_test.go index e4085f9..4c2312c 100644 --- a/libgo/misc/cgo/testgodefs/testgodefs_test.go +++ b/libgo/misc/cgo/testgodefs/testgodefs_test.go @@ -19,6 +19,7 @@ import ( // import "C" block. Add more tests here. var filePrefixes = []string{ "anonunion", + "bitfields", "issue8478", "fieldtypedef", "issue37479", |