summaryrefslogtreecommitdiff
path: root/libgo/go/reflect
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2020-07-17 12:30:51 -0700
committerIan Lance Taylor <iant@golang.org>2020-07-17 14:28:28 -0700
commitd5dfd4793febee6526e9ca84e06b5e207e0fbcee (patch)
tree67ee8ec7e6ad1697dfa1546524756140af9c8664 /libgo/go/reflect
parentf1b6e46c417224887c2f21baa6d4c538a25fe9fb (diff)
downloadgcc-d5dfd4793febee6526e9ca84e06b5e207e0fbcee.tar.gz
libgo: update to Go 1.14.6 release
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/243317
Diffstat (limited to 'libgo/go/reflect')
-rw-r--r--libgo/go/reflect/all_test.go6
-rw-r--r--libgo/go/reflect/deepequal.go16
-rw-r--r--libgo/go/reflect/type.go1
-rw-r--r--libgo/go/reflect/value.go1
4 files changed, 22 insertions, 2 deletions
diff --git a/libgo/go/reflect/all_test.go b/libgo/go/reflect/all_test.go
index 33d02aea849..e5ec052f7de 100644
--- a/libgo/go/reflect/all_test.go
+++ b/libgo/go/reflect/all_test.go
@@ -789,6 +789,11 @@ var loop1, loop2 Loop
var loopy1, loopy2 Loopy
var cycleMap1, cycleMap2, cycleMap3 map[string]interface{}
+type structWithSelfPtr struct {
+ p *structWithSelfPtr
+ s string
+}
+
func init() {
loop1 = &loop2
loop2 = &loop1
@@ -845,6 +850,7 @@ var deepEqualTests = []DeepEqualTest{
{[]float64{math.NaN()}, self{}, true},
{map[float64]float64{math.NaN(): 1}, map[float64]float64{1: 2}, false},
{map[float64]float64{math.NaN(): 1}, self{}, true},
+ {&structWithSelfPtr{p: &structWithSelfPtr{s: "a"}}, &structWithSelfPtr{p: &structWithSelfPtr{s: "b"}}, false},
// Nil vs empty: not the same.
{[]int{}, []int(nil), false},
diff --git a/libgo/go/reflect/deepequal.go b/libgo/go/reflect/deepequal.go
index f2d46165b50..8a2bf8b09e2 100644
--- a/libgo/go/reflect/deepequal.go
+++ b/libgo/go/reflect/deepequal.go
@@ -45,8 +45,20 @@ func deepValueEqual(v1, v2 Value, visited map[visit]bool, depth int) bool {
}
if hard(v1, v2) {
- addr1 := v1.ptr
- addr2 := v2.ptr
+ // For a Ptr or Map value, we need to check flagIndir,
+ // which we do by calling the pointer method.
+ // For Slice or Interface, flagIndir is always set,
+ // and using v.ptr suffices.
+ ptrval := func(v Value) unsafe.Pointer {
+ switch v.Kind() {
+ case Ptr, Map:
+ return v.pointer()
+ default:
+ return v.ptr
+ }
+ }
+ addr1 := ptrval(v1)
+ addr2 := ptrval(v2)
if uintptr(addr1) > uintptr(addr2) {
// Canonicalize order to reduce number of entries in visited.
// Assumes non-moving garbage collector.
diff --git a/libgo/go/reflect/type.go b/libgo/go/reflect/type.go
index 9c003a43dd9..2ce1901f556 100644
--- a/libgo/go/reflect/type.go
+++ b/libgo/go/reflect/type.go
@@ -2477,6 +2477,7 @@ func ifaceIndir(t *rtype) bool {
return t.kind&kindDirectIface == 0
}
+// Note: this type must agree with runtime.bitvector.
type bitVector struct {
n uint32 // number of bits
data []byte
diff --git a/libgo/go/reflect/value.go b/libgo/go/reflect/value.go
index 147a9c47298..7c6a3e8a935 100644
--- a/libgo/go/reflect/value.go
+++ b/libgo/go/reflect/value.go
@@ -2175,6 +2175,7 @@ func NewAt(typ Type, p unsafe.Pointer) Value {
// assignTo returns a value v that can be assigned directly to typ.
// It panics if v is not assignable to typ.
// For a conversion to an interface type, target is a suggested scratch space to use.
+// target must be initialized memory (or nil).
func (v Value) assignTo(context string, dst *rtype, target unsafe.Pointer) Value {
if v.flag&flagMethod != 0 {
v = makeMethodValue(context, v)