diff options
author | Ken Thompson <ken@golang.org> | 2008-12-11 16:09:45 -0800 |
---|---|---|
committer | Ken Thompson <ken@golang.org> | 2008-12-11 16:09:45 -0800 |
commit | 89a14599a46dbde1a35952dcad53c0d617f5a0c8 (patch) | |
tree | 4de8a31ebfa8034995e82022a39580ba2a17a84a /src/cmd/gc/dcl.c | |
parent | c38560290081bcd114e1b2e97e3b8ee97d8233ea (diff) | |
download | golang-89a14599a46dbde1a35952dcad53c0d617f5a0c8.tar.gz |
restrict declarations of type map/chan/string
(they must be pointers)
R=r
OCL=21009
CL=21009
Diffstat (limited to 'src/cmd/gc/dcl.c')
-rw-r--r-- | src/cmd/gc/dcl.c | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/src/cmd/gc/dcl.c b/src/cmd/gc/dcl.c index c2754f0da..5e50d1e78 100644 --- a/src/cmd/gc/dcl.c +++ b/src/cmd/gc/dcl.c @@ -483,8 +483,18 @@ loop: if(n->op != ODCLFIELD || n->type == T) fatal("stotype: oops %N\n", n); - if(n->type->etype == TARRAY && n->type->bound < 0) - yyerror("type of a structure field cannot be an open array"); + switch(n->type->etype) { + case TARRAY: + if(n->type->bound < 0) + yyerror("type of a structure field cannot be an open array"); + break; + + case TCHAN: + case TMAP: + case TSTRING: + yyerror("%T can exist only in pointer form", n->type); + break; + } switch(n->val.ctype) { case CTSTR: @@ -732,6 +742,15 @@ addvar(Node *n, Type *t, int ctxt) pushdcl(s); } + if(t != T) { + switch(t->etype) { + case TCHAN: + case TMAP: + case TSTRING: + yyerror("%T can exist only in pointer form", t); + } + } + redeclare("variable", s); s->vargen = gen; s->oname = n; |