]> Cypherpunks repositories - gostls13.git/commitdiff
catch
authorRuss Cox <rsc@golang.org>
Mon, 27 Jul 2009 21:55:14 +0000 (14:55 -0700)
committerRuss Cox <rsc@golang.org>
Mon, 27 Jul 2009 21:55:14 +0000 (14:55 -0700)
a := true;
a |= a;
in the front end.

R=ken
OCL=32240
CL=32243

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

index be3f0b9cb72652e5fa243aa4f8ee11320f54b2bf..047ae099288c451accd58d66e18c2b5d4c7e00b8 100644 (file)
@@ -338,7 +338,7 @@ walkexpr(Node *n, int top, NodeList **init)
        NodeList *ll, *lr;
        Type *t;
        Sym *s;
-       int et, cl, cr, typeok;
+       int et, cl, cr, typeok, op;
        int32 lno;
 
        if(n == N)
@@ -1252,7 +1252,10 @@ reswitch:
  * ======== second switch ========
  */
 
-       switch(n->op) {
+       op = n->op;
+       if(op == OASOP)
+               op = n->etype;
+       switch(op) {
        default:
                fatal("walkexpr: switch 2 unknown op %N", n, init);
                goto ret;
@@ -1423,7 +1426,10 @@ badt:
                badtype(n->op, n->left->type, T);
                goto ret;
        }
-       badtype(n->op, n->left->type, n->right->type);
+       op = n->op;
+       if(op == OASOP)
+               op = n->etype;
+       badtype(op, n->left->type, n->right->type);
        goto ret;
 
 ret:
diff --git a/test/fixedbugs/bug172.go b/test/fixedbugs/bug172.go
new file mode 100644 (file)
index 0000000..2ee2614
--- /dev/null
@@ -0,0 +1,12 @@
+// 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
+
+func f() {
+       a := true;
+       a |= a; // ERROR "illegal.*OR"
+}