cmd/vet: fix unnamed FP check

While we're here, silence a print about failure to import fmt.
When it prints, it looks like a problem, and in fact the result
is never used in vet.

Change-Id: I76121b335026a2b09637608b997517be94fd167c
Reviewed-on: https://go-review.googlesource.com/5573
Reviewed-by: Rob Pike <r@golang.org>
This commit is contained in:
Russ Cox 2015-02-23 10:57:19 -05:00
parent 4e75c2682b
commit c7a00958ec
2 changed files with 14 additions and 3 deletions

View File

@ -81,7 +81,7 @@ var (
asmTEXT = re(`\bTEXT\b.*·([^\(]+)\(SB\)(?:\s*,\s*([0-9A-Z|+]+))?(?:\s*,\s*\$(-?[0-9]+)(?:-([0-9]+))?)?`)
asmDATA = re(`\b(DATA|GLOBL)\b`)
asmNamedFP = re(`([a-zA-Z0-9_\xFF-\x{10FFFF}]+)(?:\+([0-9]+))\(FP\)`)
asmUnnamedFP = re(`[^+\-0-9]](([0-9]+)\(FP\))`)
asmUnnamedFP = re(`[^+\-0-9](([0-9]+)\(FP\))`)
asmSP = re(`[^+\-0-9](([0-9]+)\(([A-Z0-9]+)\))`)
asmOpcode = re(`^\s*(?:[A-Z0-9a-z_]+:)?\s*([A-Z]+)\s*([^,]*)(?:,\s*(.*))?`)
power64Suff = re(`([BHWD])(ZU|Z|U|BR)?$`)
@ -191,6 +191,9 @@ Files:
localSize += archDef.intSize
}
argSize, _ = strconv.Atoi(m[4])
if fn == nil && !strings.Contains(fnName, "<>") {
badf("function %s missing Go declaration", fnName)
}
wroteSP = false
haveRetArg = false
continue
@ -252,7 +255,13 @@ Files:
}
for _, m := range asmUnnamedFP.FindAllStringSubmatch(line, -1) {
badf("use of unnamed argument %s", m[1])
off, _ := strconv.Atoi(m[2])
v := fn.varByOffset[off]
if v != nil {
badf("use of unnamed argument %s; offset %d is %s+%d(FP)", m[1], off, v.name, v.off)
} else {
badf("use of unnamed argument %s", m[1])
}
}
for _, m := range asmNamedFP.FindAllStringSubmatch(line, -1) {

View File

@ -37,7 +37,9 @@ func init() {
func importType(path, name string) types.Type {
pkg, err := types.DefaultImport(imports, path)
if err != nil {
warnf("import failed: %v", err)
// This can happen if fmt hasn't been compiled yet.
// Since nothing uses formatterType anyway, don't complain.
//warnf("import failed: %v", err)
return nil
}
if obj, ok := pkg.Scope().Lookup(name).(*types.TypeName); ok {