mirror of
https://github.com/golang/go
synced 2024-11-18 22:34:45 -07:00
go/analysis/passes/asmdecl: fix a panic under go1.10
Now that asmdecl is not in the standard repo, we must not assume that types.SizesFor knows about all architectures and panic if it does not. This change makes it print a warning and assume 64-bit norms. Change-Id: Idacad350b2fc9343adfb32539fec7003b39380ed Reviewed-on: https://go-review.googlesource.com/c/141679 Reviewed-by: Michael Matloob <matloob@golang.org> Run-TryBot: Michael Matloob <matloob@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
parent
d1d6d0cbb6
commit
c0eb142035
@ -11,6 +11,7 @@ import (
|
|||||||
"go/build"
|
"go/build"
|
||||||
"go/token"
|
"go/token"
|
||||||
"go/types"
|
"go/types"
|
||||||
|
"log"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
@ -107,7 +108,13 @@ func init() {
|
|||||||
for _, arch := range arches {
|
for _, arch := range arches {
|
||||||
arch.sizes = types.SizesFor("gc", arch.name)
|
arch.sizes = types.SizesFor("gc", arch.name)
|
||||||
if arch.sizes == nil {
|
if arch.sizes == nil {
|
||||||
panic("missing SizesFor for gc/" + arch.name)
|
// TODO(adonovan): fix: now that asmdecl is not in the standard
|
||||||
|
// library we cannot assume types.SizesFor is consistent with arches.
|
||||||
|
// For now, assume 64-bit norms and print a warning.
|
||||||
|
// But this warning should really be deferred until we attempt to use
|
||||||
|
// arch, which is very unlikely.
|
||||||
|
arch.sizes = types.SizesFor("gc", "amd64")
|
||||||
|
log.Printf("unknown architecture %s", arch.name)
|
||||||
}
|
}
|
||||||
arch.intSize = int(arch.sizes.Sizeof(types.Typ[types.Int]))
|
arch.intSize = int(arch.sizes.Sizeof(types.Typ[types.Int]))
|
||||||
arch.ptrSize = int(arch.sizes.Sizeof(types.Typ[types.UnsafePointer]))
|
arch.ptrSize = int(arch.sizes.Sizeof(types.Typ[types.UnsafePointer]))
|
||||||
|
Loading…
Reference in New Issue
Block a user