mirror of
https://github.com/golang/go
synced 2024-11-14 06:10:24 -07:00
cmd/compile: make -asmhdr work with type aliases
For "type T = U" we were accidentally emitting a #define for "U__size" instead of "T__size". Fixes #22877. Change-Id: I5ed6757d697753ed6d944077c16150759f6e1285 Reviewed-on: https://go-review.googlesource.com/80759 Run-TryBot: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
parent
07a2ffaf0b
commit
2f588ff08f
@ -387,10 +387,10 @@ func dumpasmhdr() {
|
|||||||
if !t.IsStruct() || t.StructType().Map != nil || t.IsFuncArgStruct() {
|
if !t.IsStruct() || t.StructType().Map != nil || t.IsFuncArgStruct() {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
fmt.Fprintf(b, "#define %s__size %d\n", t.Sym.Name, int(t.Width))
|
fmt.Fprintf(b, "#define %s__size %d\n", n.Sym.Name, int(t.Width))
|
||||||
for _, t := range t.Fields().Slice() {
|
for _, f := range t.Fields().Slice() {
|
||||||
if !t.Sym.IsBlank() {
|
if !f.Sym.IsBlank() {
|
||||||
fmt.Fprintf(b, "#define %s_%s %d\n", n.Sym.Name, t.Sym.Name, int(t.Offset))
|
fmt.Fprintf(b, "#define %s_%s %d\n", n.Sym.Name, f.Sym.Name, int(f.Offset))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
14
test/fixedbugs/issue22877.dir/p.go
Normal file
14
test/fixedbugs/issue22877.dir/p.go
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
// Copyright 2017 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 main
|
||||||
|
|
||||||
|
type S struct{ i int }
|
||||||
|
type SS = S
|
||||||
|
|
||||||
|
func sub()
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
sub()
|
||||||
|
}
|
8
test/fixedbugs/issue22877.dir/p.s
Normal file
8
test/fixedbugs/issue22877.dir/p.s
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
// Copyright 2017 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.
|
||||||
|
|
||||||
|
#include "go_asm.h"
|
||||||
|
|
||||||
|
TEXT ·sub(SB), 0, $0
|
||||||
|
RET
|
7
test/fixedbugs/issue22877.go
Normal file
7
test/fixedbugs/issue22877.go
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
// builddir
|
||||||
|
|
||||||
|
// Copyright 2017 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 ignored
|
@ -736,6 +736,9 @@ func (t *test) run() {
|
|||||||
}
|
}
|
||||||
var objs []string
|
var objs []string
|
||||||
cmd := []string{"go", "tool", "compile", "-e", "-D", ".", "-I", ".", "-o", "go.o"}
|
cmd := []string{"go", "tool", "compile", "-e", "-D", ".", "-I", ".", "-o", "go.o"}
|
||||||
|
if len(asms) > 0 {
|
||||||
|
cmd = append(cmd, "-asmhdr", "go_asm.h")
|
||||||
|
}
|
||||||
for _, file := range gos {
|
for _, file := range gos {
|
||||||
cmd = append(cmd, filepath.Join(longdir, file.Name()))
|
cmd = append(cmd, filepath.Join(longdir, file.Name()))
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user