]> git.ipfire.org Git - thirdparty/gcc.git/blobdiff - libgo/go/reflect/value.go
libgo: update to Go1.14beta1
[thirdparty/gcc.git] / libgo / go / reflect / value.go
index 15a502465f78cab1391c7763bfb0c5a41fd5b339..147a9c472983f16a920f558c4517f968a95be5c2 100644 (file)
@@ -884,7 +884,7 @@ func (v Value) IsNil() bool {
 // IsValid reports whether v represents a value.
 // It returns false if v is the zero Value.
 // If IsValid returns false, all other methods except String panic.
-// Most functions and methods never return an invalid value.
+// Most functions and methods never return an invalid Value.
 // If one does, its documentation states the conditions explicitly.
 func (v Value) IsValid() bool {
        return v.flag != 0
@@ -1225,6 +1225,11 @@ func (v Value) OverflowUint(x uint64) bool {
        panic(&ValueError{"reflect.Value.OverflowUint", v.kind()})
 }
 
+//go:nocheckptr
+// This prevents inlining Value.Pointer when -d=checkptr is enabled,
+// which ensures cmd/compile can recognize unsafe.Pointer(v.Pointer())
+// and make an exception.
+
 // Pointer returns v's value as a uintptr.
 // It returns uintptr instead of unsafe.Pointer so that
 // code using reflect cannot obtain unsafe.Pointers
@@ -1722,6 +1727,11 @@ func (v Value) Uint() uint64 {
        panic(&ValueError{"reflect.Value.Uint", v.kind()})
 }
 
+//go:nocheckptr
+// This prevents inlining Value.UnsafeAddr when -d=checkptr is enabled,
+// which ensures cmd/compile can recognize unsafe.Pointer(v.UnsafeAddr())
+// and make an exception.
+
 // UnsafeAddr returns a pointer to v's data.
 // It is for advanced clients that also import the "unsafe" package.
 // It panics if v is not addressable.
@@ -2274,6 +2284,11 @@ func convertOp(dst, src *rtype) func(Value, Type) Value {
                                return cvtRunesString
                        }
                }
+
+       case Chan:
+               if dst.Kind() == Chan && specialChannelAssignability(dst, src) {
+                       return cvtDirect
+               }
        }
 
        // dst and src have same underlying type.