]> Cypherpunks repositories - gostls13.git/commitdiff
gc: fix handling of types inside function bodies
authorRuss Cox <rsc@golang.org>
Thu, 15 Jul 2010 21:25:50 +0000 (14:25 -0700)
committerRuss Cox <rsc@golang.org>
Thu, 15 Jul 2010 21:25:50 +0000 (14:25 -0700)
Fixes #849.
Fixes #920.

R=ken2
CC=golang-dev
https://golang.org/cl/1841042

src/cmd/gc/align.c
src/cmd/gc/walk.c
test/fixedbugs/bug286.go [moved from test/bugs/bug286.go with 100% similarity]
test/fixedbugs/bug290.go [new file with mode: 0644]
test/golden.out

index 1b9112d69a3f0be36d556f34dc6dfc6c06b18f6b..1d68b55a006f53cdde7b9a591d92d9071d1aa595 100644 (file)
@@ -351,8 +351,8 @@ void
 defercheckwidth(void)
 {
        // we get out of sync on syntax errors, so don't be pedantic.
-       // if(defercalc)
-       //      fatal("defercheckwidth");
+       if(defercalc && nerrors == 0)
+               fatal("defercheckwidth");
        defercalc = 1;
 }
 
index 2e233bfdd919df0b5a7fc81d35f657f55ea079ee..8b8096400e623b4fa16da11ff82e4abb4ba3e92d 100644 (file)
@@ -292,10 +292,14 @@ walkdef(Node *n)
                break;
 
        case OTYPE:
+               if(curfn)
+                       defercheckwidth();
                n->walkdef = 1;
                n->type = typ(TFORW);
                n->type->sym = n->sym;
                walkdeftype(n);
+               if(curfn)
+                       resumecheckwidth();
                break;
 
        case OPACK:
similarity index 100%
rename from test/bugs/bug286.go
rename to test/fixedbugs/bug286.go
diff --git a/test/fixedbugs/bug290.go b/test/fixedbugs/bug290.go
new file mode 100644 (file)
index 0000000..80437c7
--- /dev/null
@@ -0,0 +1,15 @@
+// $G $D/$F.go && $L $F.$A && ./$A.out
+
+// Copyright 2010 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.
+
+// http://code.google.com/p/go/issues/detail?id=920
+
+package main
+
+type X struct { x []X }
+
+func main() {
+       type Y struct { x []Y } // used to get invalid recursive type
+}
index 82e85340a5f89f83377b021b5ff6a47852353e13..1bed6599a8d27bb8726e78d03c8984bef1bfd9da 100644 (file)
@@ -180,10 +180,3 @@ BUG: bug260 failed
 
 =========== bugs/bug274.go
 BUG: errchk: command succeeded unexpectedly
-
-=========== bugs/bug286.go
-test2 called g
-panic: wrong method called
-
-panic PC=xxx
-BUG: bug286 failed