From 40baf7558775cf890f7dc6c1e0ac3001b45d02b4 Mon Sep 17 00:00:00 2001 From: David Symonds Date: Tue, 30 Jul 2013 13:41:07 +1000 Subject: [PATCH] cmd/vet: Avoid warning on pointer to invalid types. TBR=r CC=golang-dev https://golang.org/cl/12038051 --- cmd/vet/types.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cmd/vet/types.go b/cmd/vet/types.go index bd43f955cda..263f8534e96 100644 --- a/cmd/vet/types.go +++ b/cmd/vet/types.go @@ -113,6 +113,14 @@ func (f *File) matchArgType(t printfArgType, typ types.Type, arg ast.Expr) bool return t&argPointer != 0 || f.matchArgType(t, typ.Elem(), arg) case *types.Pointer: + // Ugly, but dealing with an edge case: a known pointer to an invalid type, + // probably something from a failed import. + if typ.Elem().String() == "invalid type" { + if *verbose { + f.Warnf(arg.Pos(), "printf argument %v is pointer to invalid or unknown type", f.gofmt(arg)) + } + return true // special case + } return t&argPointer != 0 case *types.Basic: