]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/gc: more robust checking of OIND nodes.
authorDaniel Morsing <daniel.morsing@gmail.com>
Fri, 18 Jan 2013 21:46:10 +0000 (22:46 +0100)
committerDaniel Morsing <daniel.morsing@gmail.com>
Fri, 18 Jan 2013 21:46:10 +0000 (22:46 +0100)
Fixes #4610.

R=golang-dev, remyoudompheng, rsc
CC=golang-dev, nigeltao
https://golang.org/cl/7058057

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

index d77dd878cb9d32f10cd26313b025c23f5beb6cb1..d00e436719f88b41c2fee88db19bbb853ba56055 100644 (file)
@@ -482,9 +482,12 @@ reswitch:
                        n->left = N;
                        goto ret;
                }
-               if((top & (Erv | Etop)) && !isptr[t->etype]) {
-                       yyerror("invalid indirect of %lN", n->left);
-                       goto error;
+               if(!isptr[t->etype]) {
+                       if(top & (Erv | Etop)) {
+                               yyerror("invalid indirect of %lN", n->left);
+                               goto error;
+                       }
+                       goto ret;
                }
                ok |= Erv;
                n->type = t->type;
diff --git a/test/fixedbugs/issue4610.go b/test/fixedbugs/issue4610.go
new file mode 100644 (file)
index 0000000..bc6bfe7
--- /dev/null
@@ -0,0 +1,17 @@
+// errorcheck
+
+// Copyright 2012 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.
+
+package main
+
+type bar struct {
+       x int
+}
+
+func main() {
+       var foo bar
+       _ = &foo{} // ERROR "is not a type"
+}
+