]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/gc: fix invalid indirect error at statement level
authorShenghou Ma <minux.ma@gmail.com>
Mon, 26 Nov 2012 17:46:54 +0000 (01:46 +0800)
committerShenghou Ma <minux.ma@gmail.com>
Mon, 26 Nov 2012 17:46:54 +0000 (01:46 +0800)
Fixes #4429.

R=golang-dev, remyoudompheng, daniel.morsing, rsc
CC=golang-dev
https://golang.org/cl/6850097

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

index 2d1dbd75f1b23eda450204a390e7fbdf4841f3af..3b32de21167f851f46309023dca53a354c27839b 100644 (file)
@@ -482,7 +482,7 @@ reswitch:
                        n->left = N;
                        goto ret;
                }
-               if((top & Erv) && !isptr[t->etype]) {
+               if((top & (Erv | Etop)) && !isptr[t->etype]) {
                        yyerror("invalid indirect of %lN", n->left);
                        goto error;
                }
diff --git a/test/fixedbugs/issue4429.go b/test/fixedbugs/issue4429.go
new file mode 100644 (file)
index 0000000..8a93b02
--- /dev/null
@@ -0,0 +1,16 @@
+// 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 p
+
+type a struct {
+  a int
+}
+
+func main() {
+  av := a{};
+  *a(av); // ERROR "invalid indirect"
+}