]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/vet: don't crash in cgo checker if type is unknown
authorIan Lance Taylor <iant@golang.org>
Tue, 2 Feb 2016 21:23:32 +0000 (13:23 -0800)
committerRuss Cox <rsc@golang.org>
Wed, 3 Feb 2016 03:34:02 +0000 (03:34 +0000)
Fixes #14201.

Change-Id: Ib61f8c00cae72463f59b90ae199fbdc1e7422a79
Reviewed-on: https://go-review.googlesource.com/19174
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Hudson-Doyle <michael.hudson@canonical.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
src/cmd/vet/cgo.go
src/cmd/vet/testdata/cgo2.go [new file with mode: 0644]

index 8807952b48ab867767e506400b196ab4a90a8cd8..1985a86fe0100146138a674e53620e8dbf4b7a1a 100644 (file)
@@ -72,6 +72,9 @@ func cgoBaseType(f *File, arg ast.Expr) types.Type {
                }
                // Here arg is *f(v).
                t := f.pkg.types[call.Fun].Type
+               if t == nil {
+                       break
+               }
                ptr, ok := t.Underlying().(*types.Pointer)
                if !ok {
                        break
diff --git a/src/cmd/vet/testdata/cgo2.go b/src/cmd/vet/testdata/cgo2.go
new file mode 100644 (file)
index 0000000..276aea9
--- /dev/null
@@ -0,0 +1,9 @@
+// Copyright 2016 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.
+
+// Test the cgo checker on a file that doesn't use cgo.
+
+package testdata
+
+var _ = C.f(*p(**p))