]> Cypherpunks repositories - gostls13.git/commitdiff
fix one bug involving [...] constructors.
authorRuss Cox <rsc@golang.org>
Thu, 3 Sep 2009 06:26:13 +0000 (23:26 -0700)
committerRuss Cox <rsc@golang.org>
Thu, 3 Sep 2009 06:26:13 +0000 (23:26 -0700)
added iant's bug202 (in main code)
and ken's bug203 (in init function).
bug187 remains at large.

R=ken
OCL=34293
CL=34293

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

index 9a013ca6e253da199daf7ce016f147ca62524027..c7c1dfd6224d912dd72f73ebc97a0dcbcd5b312d 100644 (file)
@@ -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:
index 9f160d456dd791b11a21d2a46663ee61c066d25b..8b75560158cb7653d5f8f6c3df8640dff08594e0 100644 (file)
@@ -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:
index 9f0beb559f1e100fe6264aae2d6c0e1b77b06dc7..67c6777cf99a288a76c9f6b72af32df068395c99 100644 (file)
@@ -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 (file)
index 0000000..7e5cc7a
--- /dev/null
@@ -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 (file)
index 0000000..5b04b2e
--- /dev/null
@@ -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()
+{
+}