From 9bbb07ddec63e5e747f1cd9dbf82b7504b29dd09 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Wed, 25 Jan 2017 10:19:33 -0500 Subject: [dev.typealias] cmd/compile, reflect: fix struct field names for embedded byte, rune Will also fix type aliases. Fixes #17766. For #18130. Change-Id: I9e1584d47128782152e06abd0a30ef423d5c30d2 Reviewed-on: https://go-review.googlesource.com/35732 Run-TryBot: Russ Cox Reviewed-by: Robert Griesemer --- src/runtime/cgocall.go | 2 +- src/runtime/type.go | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) (limited to 'src/runtime') diff --git a/src/runtime/cgocall.go b/src/runtime/cgocall.go index 69e29ef976..879e786231 100644 --- a/src/runtime/cgocall.go +++ b/src/runtime/cgocall.go @@ -531,7 +531,7 @@ func cgoCheckArg(t *_type, p unsafe.Pointer, indir, top bool, msg string) { return } for _, f := range st.fields { - cgoCheckArg(f.typ, add(p, f.offset), true, top, msg) + cgoCheckArg(f.typ, add(p, f.offset()), true, top, msg) } case kindPtr, kindUnsafePointer: if indir { diff --git a/src/runtime/type.go b/src/runtime/type.go index 3ecc54c72c..10442eff69 100644 --- a/src/runtime/type.go +++ b/src/runtime/type.go @@ -390,9 +390,13 @@ type ptrtype struct { } type structfield struct { - name name - typ *_type - offset uintptr + name name + typ *_type + offsetAnon uintptr +} + +func (f *structfield) offset() uintptr { + return f.offsetAnon >> 1 } type structtype struct { @@ -650,7 +654,7 @@ func typesEqual(t, v *_type) bool { if tf.name.tag() != vf.name.tag() { return false } - if tf.offset != vf.offset { + if tf.offsetAnon != vf.offsetAnon { return false } } -- cgit v1.3