summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2009-12-03 01:12:02 -0800
committerRuss Cox <rsc@golang.org>2009-12-03 01:12:02 -0800
commit56b84b90259ea8c6e3450c24713f2b885f995d35 (patch)
treef4612be11e407e0e7bb3bc14823cc23580515006
parent4208d02d7dabecb1552b9d6d8b647f8a5d2b15c1 (diff)
downloadgo-56b84b90259ea8c6e3450c24713f2b885f995d35.tar.gz
gc: recursive type error
Fixes issue 245. R=ken2 http://codereview.appspot.com/164094
-rw-r--r--src/cmd/gc/align.c3
-rw-r--r--src/cmd/gc/typecheck.c2
-rw-r--r--test/fixedbugs/bug224.go10
3 files changed, 15 insertions, 0 deletions
diff --git a/src/cmd/gc/align.c b/src/cmd/gc/align.c
index b74ac0f29..cf0851646 100644
--- a/src/cmd/gc/align.c
+++ b/src/cmd/gc/align.c
@@ -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'])
diff --git a/src/cmd/gc/typecheck.c b/src/cmd/gc/typecheck.c
index 0fd359b31..76147e48f 100644
--- a/src/cmd/gc/typecheck.c
+++ b/src/cmd/gc/typecheck.c
@@ -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
index 000000000..11ee57ecf
--- /dev/null
+++ b/test/fixedbugs/bug224.go
@@ -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"
+