diff options
author | Ian Lance Taylor <iant@golang.org> | 2022-02-11 14:53:56 -0800 |
---|---|---|
committer | Ian Lance Taylor <iant@golang.org> | 2022-02-11 15:01:19 -0800 |
commit | 8dc2499aa62f768c6395c9754b8cabc1ce25c494 (patch) | |
tree | 43d7fd2bbfd7ad8c9625a718a5e8718889351994 /libgo/misc/cgo/test | |
parent | 9a56779dbc4e2d9c15be8d31e36f2f59be7331a8 (diff) | |
download | gcc-8dc2499aa62f768c6395c9754b8cabc1ce25c494.zip gcc-8dc2499aa62f768c6395c9754b8cabc1ce25c494.tar.gz gcc-8dc2499aa62f768c6395c9754b8cabc1ce25c494.tar.bz2 |
libgo: update to Go1.18beta2
gotools/
* Makefile.am (go_cmd_cgo_files): Add ast_go118.go
(check-go-tool): Copy golang.org/x/tools directories.
* Makefile.in: Regenerate.
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/384695
Diffstat (limited to 'libgo/misc/cgo/test')
-rw-r--r-- | libgo/misc/cgo/test/cgo_test.go | 2 | ||||
-rw-r--r-- | libgo/misc/cgo/test/cgo_thread_lock.go | 1 | ||||
-rw-r--r-- | libgo/misc/cgo/test/cgo_unix_test.go | 1 | ||||
-rw-r--r-- | libgo/misc/cgo/test/issue18146.go | 1 | ||||
-rw-r--r-- | libgo/misc/cgo/test/issue21897.go | 1 | ||||
-rw-r--r-- | libgo/misc/cgo/test/issue21897b.go | 1 | ||||
-rw-r--r-- | libgo/misc/cgo/test/issue4029.go | 4 | ||||
-rw-r--r-- | libgo/misc/cgo/test/issue4029w.go | 1 | ||||
-rw-r--r-- | libgo/misc/cgo/test/issue42018.go | 14 | ||||
-rw-r--r-- | libgo/misc/cgo/test/issue42018_windows.go | 46 | ||||
-rw-r--r-- | libgo/misc/cgo/test/issue8517.go | 1 | ||||
-rw-r--r-- | libgo/misc/cgo/test/issue8694.go | 1 | ||||
-rw-r--r-- | libgo/misc/cgo/test/sigaltstack.go | 1 | ||||
-rw-r--r-- | libgo/misc/cgo/test/sigprocmask.go | 1 | ||||
-rw-r--r-- | libgo/misc/cgo/test/test.go | 5 | ||||
-rw-r--r-- | libgo/misc/cgo/test/test_unix.go | 1 | ||||
-rw-r--r-- | libgo/misc/cgo/test/testdata/issue43639.go | 9 | ||||
-rw-r--r-- | libgo/misc/cgo/test/testdata/issue43639/a.go | 8 | ||||
-rw-r--r-- | libgo/misc/cgo/test/testdata/issue9400_linux.go | 9 | ||||
-rw-r--r-- | libgo/misc/cgo/test/testx.go | 24 | ||||
-rw-r--r-- | libgo/misc/cgo/test/typeparam.go | 21 |
21 files changed, 152 insertions, 1 deletions
diff --git a/libgo/misc/cgo/test/cgo_test.go b/libgo/misc/cgo/test/cgo_test.go index 143f23f..774277e 100644 --- a/libgo/misc/cgo/test/cgo_test.go +++ b/libgo/misc/cgo/test/cgo_test.go @@ -59,7 +59,9 @@ func Test28896(t *testing.T) { test28896(t) } func Test30065(t *testing.T) { test30065(t) } func Test32579(t *testing.T) { test32579(t) } func Test31891(t *testing.T) { test31891(t) } +func Test42018(t *testing.T) { test42018(t) } func Test45451(t *testing.T) { test45451(t) } +func Test49633(t *testing.T) { test49633(t) } func TestAlign(t *testing.T) { testAlign(t) } func TestAtol(t *testing.T) { testAtol(t) } func TestBlocking(t *testing.T) { testBlocking(t) } diff --git a/libgo/misc/cgo/test/cgo_thread_lock.go b/libgo/misc/cgo/test/cgo_thread_lock.go index b105068..3b9ac84 100644 --- a/libgo/misc/cgo/test/cgo_thread_lock.go +++ b/libgo/misc/cgo/test/cgo_thread_lock.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build linux && freebsd && openbsd // +build linux,freebsd,openbsd package cgotest diff --git a/libgo/misc/cgo/test/cgo_unix_test.go b/libgo/misc/cgo/test/cgo_unix_test.go index e3d5916..a324503 100644 --- a/libgo/misc/cgo/test/cgo_unix_test.go +++ b/libgo/misc/cgo/test/cgo_unix_test.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build !windows // +build !windows package cgotest diff --git a/libgo/misc/cgo/test/issue18146.go b/libgo/misc/cgo/test/issue18146.go index f92d6c7..e50f9ae 100644 --- a/libgo/misc/cgo/test/issue18146.go +++ b/libgo/misc/cgo/test/issue18146.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build !windows // +build !windows // Issue 18146: pthread_create failure during syscall.Exec. diff --git a/libgo/misc/cgo/test/issue21897.go b/libgo/misc/cgo/test/issue21897.go index d13246b..8f39252 100644 --- a/libgo/misc/cgo/test/issue21897.go +++ b/libgo/misc/cgo/test/issue21897.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build darwin && cgo && !internal // +build darwin,cgo,!internal package cgotest diff --git a/libgo/misc/cgo/test/issue21897b.go b/libgo/misc/cgo/test/issue21897b.go index 08b5f4d..50aece3 100644 --- a/libgo/misc/cgo/test/issue21897b.go +++ b/libgo/misc/cgo/test/issue21897b.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build !darwin || !cgo || internal // +build !darwin !cgo internal package cgotest diff --git a/libgo/misc/cgo/test/issue4029.go b/libgo/misc/cgo/test/issue4029.go index b2d1318..90ca08c 100644 --- a/libgo/misc/cgo/test/issue4029.go +++ b/libgo/misc/cgo/test/issue4029.go @@ -2,7 +2,9 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build !windows,!static +//go:build !windows && !static && (!darwin || (!internal_pie && !arm64)) +// +build !windows +// +build !static // +build !darwin !internal_pie,!arm64 // Excluded in darwin internal linking PIE mode, as dynamic export is not diff --git a/libgo/misc/cgo/test/issue4029w.go b/libgo/misc/cgo/test/issue4029w.go index b969bdd..c2f5948 100644 --- a/libgo/misc/cgo/test/issue4029w.go +++ b/libgo/misc/cgo/test/issue4029w.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build windows || static || (darwin && internal_pie) || (darwin && arm64) // +build windows static darwin,internal_pie darwin,arm64 package cgotest diff --git a/libgo/misc/cgo/test/issue42018.go b/libgo/misc/cgo/test/issue42018.go new file mode 100644 index 0000000..fab686a --- /dev/null +++ b/libgo/misc/cgo/test/issue42018.go @@ -0,0 +1,14 @@ +// Copyright 2021 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. + +//go:build !windows +// +build !windows + +package cgotest + +import "testing" + +func test42018(t *testing.T) { + t.Skip("skipping Windows-only test") +} diff --git a/libgo/misc/cgo/test/issue42018_windows.go b/libgo/misc/cgo/test/issue42018_windows.go new file mode 100644 index 0000000..8f4570a --- /dev/null +++ b/libgo/misc/cgo/test/issue42018_windows.go @@ -0,0 +1,46 @@ +// Copyright 2021 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 + +/* +typedef void *HANDLE; + +struct HWND__{int unused;}; typedef struct HWND__ *HWND; +*/ +import "C" + +import ( + "testing" + "unsafe" +) + +func test42018(t *testing.T) { + // Test that Windows handles are marked go:notinheap, by growing the + // stack and checking for pointer adjustments. Trick from + // test/fixedbugs/issue40954.go. + var i int + handle := C.HANDLE(unsafe.Pointer(uintptr(unsafe.Pointer(&i)))) + recurseHANDLE(100, handle, uintptr(unsafe.Pointer(&i))) + hwnd := C.HWND(unsafe.Pointer(uintptr(unsafe.Pointer(&i)))) + recurseHWND(400, hwnd, uintptr(unsafe.Pointer(&i))) +} + +func recurseHANDLE(n int, p C.HANDLE, v uintptr) { + if n > 0 { + recurseHANDLE(n-1, p, v) + } + if uintptr(unsafe.Pointer(p)) != v { + panic("adjusted notinheap pointer") + } +} + +func recurseHWND(n int, p C.HWND, v uintptr) { + if n > 0 { + recurseHWND(n-1, p, v) + } + if uintptr(unsafe.Pointer(p)) != v { + panic("adjusted notinheap pointer") + } +} diff --git a/libgo/misc/cgo/test/issue8517.go b/libgo/misc/cgo/test/issue8517.go index 4e431df..7316ab0 100644 --- a/libgo/misc/cgo/test/issue8517.go +++ b/libgo/misc/cgo/test/issue8517.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build !windows // +build !windows package cgotest diff --git a/libgo/misc/cgo/test/issue8694.go b/libgo/misc/cgo/test/issue8694.go index 89be7ea..19071ce 100644 --- a/libgo/misc/cgo/test/issue8694.go +++ b/libgo/misc/cgo/test/issue8694.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build !android // +build !android package cgotest diff --git a/libgo/misc/cgo/test/sigaltstack.go b/libgo/misc/cgo/test/sigaltstack.go index 034cc4b..6b37189 100644 --- a/libgo/misc/cgo/test/sigaltstack.go +++ b/libgo/misc/cgo/test/sigaltstack.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build !windows && !android // +build !windows,!android // Test that the Go runtime still works if C code changes the signal stack. diff --git a/libgo/misc/cgo/test/sigprocmask.go b/libgo/misc/cgo/test/sigprocmask.go index e2b939f..983734c 100644 --- a/libgo/misc/cgo/test/sigprocmask.go +++ b/libgo/misc/cgo/test/sigprocmask.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build !windows // +build !windows package cgotest diff --git a/libgo/misc/cgo/test/test.go b/libgo/misc/cgo/test/test.go index 3b8f548..dd81f77 100644 --- a/libgo/misc/cgo/test/test.go +++ b/libgo/misc/cgo/test/test.go @@ -915,6 +915,11 @@ void issue40494(enum Enum40494 e, union Union40494* up) {} // Issue 45451, bad handling of go:notinheap types. typedef struct issue45451Undefined issue45451; + +// Issue 49633, example of cgo.Handle with void*. +extern void GoFunc49633(void*); +void cfunc49633(void *context) { GoFunc49633(context); } + */ import "C" diff --git a/libgo/misc/cgo/test/test_unix.go b/libgo/misc/cgo/test/test_unix.go index 4a23446..831b9ca 100644 --- a/libgo/misc/cgo/test/test_unix.go +++ b/libgo/misc/cgo/test/test_unix.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build !windows // +build !windows package cgotest diff --git a/libgo/misc/cgo/test/testdata/issue43639.go b/libgo/misc/cgo/test/testdata/issue43639.go new file mode 100644 index 0000000..e755fbd --- /dev/null +++ b/libgo/misc/cgo/test/testdata/issue43639.go @@ -0,0 +1,9 @@ +// Copyright 2021 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 + +// Issue 43639: No runtime test needed, make sure package cgotest/issue43639 compiles well. + +import _ "cgotest/issue43639" diff --git a/libgo/misc/cgo/test/testdata/issue43639/a.go b/libgo/misc/cgo/test/testdata/issue43639/a.go new file mode 100644 index 0000000..fe37d5e --- /dev/null +++ b/libgo/misc/cgo/test/testdata/issue43639/a.go @@ -0,0 +1,8 @@ +// Copyright 2021 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 issue43639 + +// #cgo CFLAGS: -W -Wall -Werror +import "C" diff --git a/libgo/misc/cgo/test/testdata/issue9400_linux.go b/libgo/misc/cgo/test/testdata/issue9400_linux.go index e94a9bb..051b9ab 100644 --- a/libgo/misc/cgo/test/testdata/issue9400_linux.go +++ b/libgo/misc/cgo/test/testdata/issue9400_linux.go @@ -15,6 +15,7 @@ import "C" import ( "runtime" + "runtime/debug" "sync/atomic" "testing" @@ -46,6 +47,14 @@ func test9400(t *testing.T) { big[i] = pattern } + // Disable GC for the duration of the test. + // This avoids a potential GC deadlock when spinning in uninterruptable ASM below #49695. + defer debug.SetGCPercent(debug.SetGCPercent(-1)) + // SetGCPercent waits until the mark phase is over, but the runtime + // also preempts at the start of the sweep phase, so make sure that's + // done too. See #49695. + runtime.GC() + // Temporarily rewind the stack and trigger SIGSETXID issue9400.RewindAndSetgid() diff --git a/libgo/misc/cgo/test/testx.go b/libgo/misc/cgo/test/testx.go index 823c3e13..8ec84a8 100644 --- a/libgo/misc/cgo/test/testx.go +++ b/libgo/misc/cgo/test/testx.go @@ -113,6 +113,7 @@ typedef struct { int i; } Issue38408, *PIssue38408; +extern void cfunc49633(void*); // definition is in test.go */ import "C" @@ -554,3 +555,26 @@ func GoFunc37033(handle C.uintptr_t) { // A typedef pointer can be used as the element type. // No runtime test; just make sure it compiles. var _ C.PIssue38408 = &C.Issue38408{i: 1} + +// issue 49633, example use of cgo.Handle with void* + +type data49633 struct { + msg string +} + +//export GoFunc49633 +func GoFunc49633(context unsafe.Pointer) { + h := *(*cgo.Handle)(context) + v := h.Value().(*data49633) + v.msg = "hello" +} + +func test49633(t *testing.T) { + v := &data49633{} + h := cgo.NewHandle(v) + defer h.Delete() + C.cfunc49633(unsafe.Pointer(&h)) + if v.msg != "hello" { + t.Errorf("msg = %q, want 'hello'", v.msg) + } +} diff --git a/libgo/misc/cgo/test/typeparam.go b/libgo/misc/cgo/test/typeparam.go new file mode 100644 index 0000000..9291005 --- /dev/null +++ b/libgo/misc/cgo/test/typeparam.go @@ -0,0 +1,21 @@ +// Copyright 2021 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 + +// #include <stddef.h> +import "C" + +/* FIXME: Commented out for gofrontend. + +func generic[T, U any](t T, u U) {} + +func useGeneric() { + const zero C.size_t = 0 + + generic(zero, zero) + generic[C.size_t, C.size_t](0, 0) +} + +*/ |