summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2009-09-02 23:26:13 -0700
committerRuss Cox <rsc@golang.org>2009-09-02 23:26:13 -0700
commit9ea53ab97e7b49159b03910ce8bd5568b7ac0c54 (patch)
tree21d8bf0cbef667e11ae465a64b1e8b3a2169758f
parent334105876672c0a6507a4946ab8c43ba57499de2 (diff)
downloadgolang-9ea53ab97e7b49159b03910ce8bd5568b7ac0c54.tar.gz
fix one bug involving [...] constructors.
added iant's bug202 (in main code) and ken's bug203 (in init function). bug187 remains at large. R=ken OCL=34293 CL=34293
-rw-r--r--src/cmd/gc/align.c5
-rw-r--r--src/cmd/gc/subr.c2
-rw-r--r--src/cmd/gc/typecheck.c3
-rw-r--r--test/fixedbugs/bug202.go16
-rw-r--r--test/fixedbugs/bug203.go20
5 files changed, 44 insertions, 2 deletions
diff --git a/src/cmd/gc/align.c b/src/cmd/gc/align.c
index 9a013ca6e..c7c1dfd62 100644
--- a/src/cmd/gc/align.c
+++ b/src/cmd/gc/align.c
@@ -199,9 +199,12 @@ dowidth(Type *t)
if(t->type == T)
break;
dowidth(t->type);
- w = sizeof_Array;
if(t->bound >= 0)
w = t->bound * t->type->width;
+ else if(t->bound == -1)
+ w = sizeof_Array;
+ else
+ fatal("dowidth %T", t); // probably [...]T
break;
case TSTRUCT:
diff --git a/src/cmd/gc/subr.c b/src/cmd/gc/subr.c
index 9f160d456..8b7556015 100644
--- a/src/cmd/gc/subr.c
+++ b/src/cmd/gc/subr.c
@@ -1061,6 +1061,8 @@ Tpretty(Fmt *fp, Type *t)
case TARRAY:
if(t->bound >= 0)
return fmtprint(fp, "[%d]%T", (int)t->bound, t->type);
+ if(t->bound == -100)
+ return fmtprint(fp, "[...]%T", t->type);
return fmtprint(fp, "[]%T", t->type);
case TINTER:
diff --git a/src/cmd/gc/typecheck.c b/src/cmd/gc/typecheck.c
index 9f0beb559..67c6777cf 100644
--- a/src/cmd/gc/typecheck.c
+++ b/src/cmd/gc/typecheck.c
@@ -159,7 +159,8 @@ reswitch:
n->type = t;
n->left = N;
n->right = N;
- checkwidth(t);
+ if(t->bound != -100)
+ checkwidth(t);
break;
case OTMAP:
diff --git a/test/fixedbugs/bug202.go b/test/fixedbugs/bug202.go
new file mode 100644
index 000000000..7e5cc7a3f
--- /dev/null
+++ b/test/fixedbugs/bug202.go
@@ -0,0 +1,16 @@
+// $G $D/$F.go && $L $F.$A && ./$A.out || echo BUG should run
+
+// 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
+func f() {
+ v := [...]string{"a", "b"};
+}
+func main() {
+ f();
+}
+
+
+ \ No newline at end of file
diff --git a/test/fixedbugs/bug203.go b/test/fixedbugs/bug203.go
new file mode 100644
index 000000000..5b04b2efb
--- /dev/null
+++ b/test/fixedbugs/bug203.go
@@ -0,0 +1,20 @@
+// $G $D/$F.go && $L $F.$A && ./$A.out
+
+// 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
+
+var s [8]string
+
+func
+init()
+{
+ s = [...]string{ "now", "is", "the", "time", "to", "fix", "this", "bug"}
+}
+
+func
+main()
+{
+}