diff options
| author | Russ Cox <rsc@golang.org> | 2010-06-12 11:17:24 -0700 |
|---|---|---|
| committer | Russ Cox <rsc@golang.org> | 2010-06-12 11:17:24 -0700 |
| commit | 171e56e8ce55c0937e4f4fe0487c0e69ddac2f74 (patch) | |
| tree | 791790d4d7d3f5aabc0cf1235a9ff2a4e40c0e66 /src/cmd/gc/dcl.c | |
| parent | 5cc45168f9d5aa01db50aa19ce69e39fc4967541 (diff) | |
| download | golang-171e56e8ce55c0937e4f4fe0487c0e69ddac2f74.tar.gz | |
gc: less aggressive name binding, for better line numbers in errors
Cleans up a few other corner cases too.
R=ken2
CC=golang-dev
http://codereview.appspot.com/1592045
Diffstat (limited to 'src/cmd/gc/dcl.c')
| -rw-r--r-- | src/cmd/gc/dcl.c | 24 |
1 files changed, 4 insertions, 20 deletions
diff --git a/src/cmd/gc/dcl.c b/src/cmd/gc/dcl.c index 48391d510..fadd4a039 100644 --- a/src/cmd/gc/dcl.c +++ b/src/cmd/gc/dcl.c @@ -430,24 +430,13 @@ newname(Sym *s) /* * this generates a new name node for a name - * being declared. if at the top level, it might return - * an ONONAME node created by an earlier reference. + * being declared. */ Node* dclname(Sym *s) { Node *n; - // top-level name: might already have been - // referred to, in which case s->def is already - // set to an ONONAME. - if(dclcontext == PEXTERN && s->block <= 1) { - if(s->def == N) - oldname(s); - if(s->def->op == ONONAME) - return s->def; - } - n = newname(s); n->op = ONONAME; // caller will correct it return n; @@ -484,12 +473,12 @@ oldname(Sym *s) if(n == N) { // maybe a top-level name will come along // to give this a definition later. + // walkdef will check s->def again once + // all the input source has been processed. n = newname(s); n->op = ONONAME; - s->def = n; + n->iota = iota; // save current iota value in const declarations } - if(n->oldref < 100) - n->oldref++; if(curfn != nil && n->funcdepth > 0 && n->funcdepth != funcdepth && n->op == ONAME) { // inner func is referring to var in outer func. // @@ -587,11 +576,6 @@ colasdefn(NodeList *left, Node *defn) if(n->sym->block == block) continue; - // If we created an ONONAME just for this :=, - // delete it, to avoid confusion with top-level imports. - if(n->op == ONONAME && n->oldref < 100 && --n->oldref == 0) - n->sym->def = N; - nnew++; n = newname(n->sym); declare(n, dclcontext); |
