]> Cypherpunks repositories - gostls13.git/commitdiff
gc: recursive type error
authorRuss Cox <rsc@golang.org>
Thu, 3 Dec 2009 09:12:02 +0000 (01:12 -0800)
committerRuss Cox <rsc@golang.org>
Thu, 3 Dec 2009 09:12:02 +0000 (01:12 -0800)
Fixes #245.

R=ken2
https://golang.org/cl/164094

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

index b74ac0f29f8778a2df021259c8c68a282800541b..cf085164657556f7c82828dc1dc70be444ef7686 100644 (file)
@@ -205,6 +205,9 @@ dowidth(Type *t)
                checkwidth(t->down);
                break;
        case TFORW:             // should have been filled in
+               yyerror("invalid recursive type %T", t);
+               w = 1;  // anything will do
+               break;
        case TANY:
                // dummy type; should be replaced before use.
                if(!debug['A'])
index 0fd359b31980e38f28cbf31351e16bcdea1b820d..76147e48f025dc07eee3471755a0713186cc6e1e 100644 (file)
@@ -1039,6 +1039,8 @@ reswitch:
        case ODCLTYPE:
                ok |= Etop;
                typecheck(&n->left, Etype);
+               if(!incannedimport)
+                       checkwidth(n->left->type);
                goto ret;
        }
 
diff --git a/test/fixedbugs/bug224.go b/test/fixedbugs/bug224.go
new file mode 100644 (file)
index 0000000..11ee57e
--- /dev/null
@@ -0,0 +1,10 @@
+// errchk $G $D/$F.go
+
+// Copyright 2009 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 T T               // ERROR "recursive"
+