mirror of
https://github.com/golang/go
synced 2024-11-26 16:07:00 -07:00
b5b2cf519f
Since when go/types,types2 do not know about build constraints, and runtime/cgo.Incomplete is only available on platforms that support cgo. These tests are also failing on aix with failure from linker, so disable them on aix to make builder green. The fix for aix is tracked in #54814 Updates #46731 Updates #54814 Change-Id: I5d6f6e29a8196efc6c457ea64525350fc6b20309 Reviewed-on: https://go-review.googlesource.com/c/go/+/427394 Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Bryan Mills <bcmills@google.com> Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
60 lines
790 B
Go
60 lines
790 B
Go
// run
|
|
|
|
// 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 cgo && !aix
|
|
|
|
package main
|
|
|
|
import "runtime/cgo"
|
|
|
|
type iface interface {
|
|
Get() int
|
|
}
|
|
|
|
type notInHeap struct {
|
|
_ cgo.Incomplete
|
|
i int
|
|
}
|
|
|
|
type myInt struct {
|
|
f *notInHeap
|
|
}
|
|
|
|
func (mi myInt) Get() int {
|
|
return int(mi.f.i)
|
|
}
|
|
|
|
type embed struct {
|
|
*myInt
|
|
}
|
|
|
|
var val = 1234
|
|
|
|
var valNotInHeap = notInHeap{i: val}
|
|
|
|
func main() {
|
|
i := val
|
|
check(i)
|
|
mi := myInt{f: &valNotInHeap}
|
|
check(mi.Get())
|
|
ifv := iface(mi)
|
|
check(ifv.Get())
|
|
ifv = iface(&mi)
|
|
check(ifv.Get())
|
|
em := embed{&mi}
|
|
check(em.Get())
|
|
ifv = em
|
|
check(ifv.Get())
|
|
ifv = &em
|
|
check(ifv.Get())
|
|
}
|
|
|
|
func check(v int) {
|
|
if v != val {
|
|
panic(v)
|
|
}
|
|
}
|