]> Cypherpunks repositories - gostls13.git/commitdiff
print(1<<x)
authorRuss Cox <rsc@golang.org>
Mon, 27 Jul 2009 23:17:09 +0000 (16:17 -0700)
committerRuss Cox <rsc@golang.org>
Mon, 27 Jul 2009 23:17:09 +0000 (16:17 -0700)
R=ken
OCL=32252
CL=32252

src/cmd/gc/const.c
src/cmd/gc/walk.c
test/fixedbugs/bug174.go [new file with mode: 0644]

index cc58a2c1709ff3cf486d67f75ed57b0ca6f16039..73a23bf83a6aa1adc3ac53774d51319dc3431f2d 100644 (file)
@@ -94,7 +94,7 @@ convlit1(Node **np, Type *t, int explicit)
                break;
        case OLSH:
        case ORSH:
-               convlit(&n->left, t);
+               convlit1(&n->left, t, explicit);
                n->type = n->left->type;
                return;
        }
index 31db1e7b4c2febb426bb99942dcd5d35fd19da1d..2402ef3b629f63b920e1a4e2132bf89c23faedd9 100644 (file)
@@ -858,7 +858,8 @@ reswitch:
                defaultlit(&n->right, types[TUINT]);
                if(n->left->type == T || n->right->type == T)
                        goto ret;
-               if(issigned[n->right->type->etype] || !isint[n->right->type->etype])
+               et = n->right->type->etype;
+               if(issigned[et] || !isint[et])
                        goto badt;
                // check of n->left->type happens in second switch.
                break;
@@ -2500,14 +2501,14 @@ prcompat(NodeList *all, int fmt, int dopanic)
                        switch(n->val.ctype) {
                        case CTINT:
                                defaultlit(&n, types[TINT64]);
-                               l->n = n;
                                break;
                        case CTFLT:
                                defaultlit(&n, types[TFLOAT64]);
-                               l->n = n;
                                break;
                        }
                }
+               defaultlit(&n, nil);
+               l->n = n;
                if(n->type == T)
                        continue;
 
diff --git a/test/fixedbugs/bug174.go b/test/fixedbugs/bug174.go
new file mode 100644 (file)
index 0000000..7ff8655
--- /dev/null
@@ -0,0 +1,12 @@
+// $G $D/$F.go || echo BUG: bug174
+
+// 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 main() {
+       var x uint;
+       println(1<<x);
+}