[release-branch.go1.13] go/analysis/passes/printf: allow %x/%X for float/complex types

These verbs are supported as of Go 1.13.

Updates golang/go#34993.
For golang/go#39287.

Change-Id: Ib7892e45b51073e3771bebb652a8fe3a1c6ae3c6
Reviewed-on: https://go-review.googlesource.com/c/tools/+/202041
Run-TryBot: Caleb Spare <cespare@gmail.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
(cherry picked from commit 04252eccb9d565ac559eee6a62be04f927675aab)
Reviewed-on: https://go-review.googlesource.com/c/tools/+/237942
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
diff --git a/go/analysis/passes/printf/printf.go b/go/analysis/passes/printf/printf.go
index f59e95d..27f1fc6 100644
--- a/go/analysis/passes/printf/printf.go
+++ b/go/analysis/passes/printf/printf.go
@@ -740,8 +740,8 @@
 	{'U', "-#", argRune | argInt},
 	{'v', allFlags, anyType},
 	{'w', noFlag, anyType},
-	{'x', sharpNumFlag, argRune | argInt | argString | argPointer},
-	{'X', sharpNumFlag, argRune | argInt | argString | argPointer},
+	{'x', sharpNumFlag, argRune | argInt | argString | argPointer | argFloat | argComplex},
+	{'X', sharpNumFlag, argRune | argInt | argString | argPointer | argFloat | argComplex},
 }
 
 // okPrintfArg compares the formatState to the arguments actually present,
diff --git a/go/analysis/passes/printf/testdata/src/a/a.go b/go/analysis/passes/printf/testdata/src/a/a.go
index b783f10..39867ca 100644
--- a/go/analysis/passes/printf/testdata/src/a/a.go
+++ b/go/analysis/passes/printf/testdata/src/a/a.go
@@ -84,8 +84,8 @@
 	fmt.Printf("%T %T", 3, i)
 	fmt.Printf("%U %U", 3, i)
 	fmt.Printf("%v %v", 3, i)
-	fmt.Printf("%x %x %x %x", 3, i, "hi", s)
-	fmt.Printf("%X %X %X %X", 3, i, "hi", s)
+	fmt.Printf("%x %x %x %x %x %x %x", 3, i, "hi", s, x, c, fslice)
+	fmt.Printf("%X %X %X %X %X %X %X", 3, i, "hi", s, x, c, fslice)
 	fmt.Printf("%.*s %d %g", 3, "hi", 23, 2.3)
 	fmt.Printf("%s", &stringerv)
 	fmt.Printf("%v", &stringerv)
@@ -129,7 +129,6 @@
 	fmt.Printf("%t", 23)                        // want "Printf format %t has arg 23 of wrong type int"
 	fmt.Printf("%U", x)                         // want "Printf format %U has arg x of wrong type float64"
 	fmt.Printf("%x", nil)                       // want "Printf format %x has arg nil of wrong type untyped nil"
-	fmt.Printf("%X", 2.3)                       // want "Printf format %X has arg 2.3 of wrong type float64"
 	fmt.Printf("%s", stringerv)                 // want "Printf format %s has arg stringerv of wrong type a.ptrStringer"
 	fmt.Printf("%t", stringerv)                 // want "Printf format %t has arg stringerv of wrong type a.ptrStringer"
 	fmt.Printf("%s", embeddedStringerv)         // want "Printf format %s has arg embeddedStringerv of wrong type a.embeddedStringer"