]> Cypherpunks repositories - gostls13.git/commitdiff
gc: improve unsafe.Pointer type-check error messages
authorRyan Hitchman <hitchmanr@gmail.com>
Fri, 6 Jan 2012 22:34:16 +0000 (14:34 -0800)
committerIan Lance Taylor <iant@golang.org>
Fri, 6 Jan 2012 22:34:16 +0000 (14:34 -0800)
Fixes #2627.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/5498088

src/cmd/gc/typecheck.c
test/fixedbugs/bug390.go [new file with mode: 0644]

index 077f9bbb6f45ac4d0b5b3bb464d7cf6706cc8e64..bbe1b2864391611a3fc5ea9ee5b4ec1bc0f59552 100644 (file)
@@ -79,6 +79,7 @@ static char* _typekind[] = {
        [TSTRING]       = "string",
        [TPTR32]        = "pointer",
        [TPTR64]        = "pointer",
+       [TUNSAFEPTR]    = "unsafe.Pointer",
        [TSTRUCT]       = "struct",
        [TINTER]        = "interface",
        [TCHAN]         = "chan",
diff --git a/test/fixedbugs/bug390.go b/test/fixedbugs/bug390.go
new file mode 100644 (file)
index 0000000..9ee5bc9
--- /dev/null
@@ -0,0 +1,16 @@
+// errchk $G -e $D/$F.go
+
+// Copyright 2011 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.
+
+// Issue 2627 -- unsafe.Pointer type isn't handled nicely in some errors
+
+package main
+
+import "unsafe"
+
+func main() {
+       var x *int
+       _ = unsafe.Pointer(x) - unsafe.Pointer(x) // ERROR "operator - not defined on unsafe.Pointer"
+}