summaryrefslogtreecommitdiff
path: root/src/cmd/gc/walk.c
diff options
context:
space:
mode:
authorOndřej Surý <ondrej@sury.org>2011-02-14 13:23:51 +0100
committerOndřej Surý <ondrej@sury.org>2011-02-14 13:23:51 +0100
commit758ff64c69e34965f8af5b2d6ffd65e8d7ab2150 (patch)
tree6d6b34f8c678862fe9b56c945a7b63f68502c245 /src/cmd/gc/walk.c
parent3e45412327a2654a77944249962b3652e6142299 (diff)
downloadgolang-upstream/2011-02-01.1.tar.gz
Imported Upstream version 2011-02-01.1upstream/2011-02-01.1
Diffstat (limited to 'src/cmd/gc/walk.c')
-rw-r--r--src/cmd/gc/walk.c24
1 files changed, 13 insertions, 11 deletions
diff --git a/src/cmd/gc/walk.c b/src/cmd/gc/walk.c
index fa3e5d5e4..b32b6fff5 100644
--- a/src/cmd/gc/walk.c
+++ b/src/cmd/gc/walk.c
@@ -269,9 +269,15 @@ walkdef(Node *n)
}
t = n->type;
if(t != T) {
- convlit(&e, t);
- if(!okforconst[t->etype])
+ if(!okforconst[t->etype]) {
yyerror("invalid constant type %T", t);
+ goto ret;
+ }
+ if(!isideal(e->type) && !eqtype(t, e->type)) {
+ yyerror("cannot use %+N as type %T in const initializer", e, t);
+ goto ret;
+ }
+ convlit(&e, t);
}
n->val = e->val;
n->type = e->type;
@@ -397,7 +403,7 @@ walkstmt(Node **np)
case OAS:
case OAS2:
case OAS2DOTTYPE:
- case OAS2RECV:
+ case OAS2RECVCLOSED:
case OAS2FUNC:
case OAS2MAPW:
case OAS2MAPR:
@@ -664,7 +670,7 @@ walkexpr(Node **np, NodeList **init)
case OGE:
case OGT:
case OADD:
- case OCMPLX:
+ case OCOMPLEX:
walkexpr(&n->left, init);
walkexpr(&n->right, init);
goto ret;
@@ -816,14 +822,14 @@ walkexpr(Node **np, NodeList **init)
n = liststmt(concat(concat(list1(r), ll), lpost));
goto ret;
- case OAS2RECV:
- // a,b = <-c
+ case OAS2RECVCLOSED:
+ // a = <-c; b = closed(c) but atomic
*init = concat(*init, n->ninit);
n->ninit = nil;
r = n->rlist->n;
walkexprlistsafe(n->list, init);
walkexpr(&r->left, init);
- fn = chanfn("chanrecv2", 2, r->left->type);
+ fn = chanfn("chanrecv3", 2, r->left->type);
r = mkcall1(fn, getoutargx(fn->type), init, r->left);
n->rlist->n = r;
n->op = OAS2FUNC;
@@ -1401,10 +1407,6 @@ walkexpr(Node **np, NodeList **init)
n = mkcall1(chanfn("chansend1", 2, n->left->type), T, init, n->left, n->right);
goto ret;
- case OSENDNB:
- n = mkcall1(chanfn("chansend2", 2, n->left->type), n->type, init, n->left, n->right);
- goto ret;
-
case OCLOSURE:
n = walkclosure(n, init);
goto ret;