summaryrefslogtreecommitdiff
path: root/src/cmd/gc/dcl.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/cmd/gc/dcl.c')
-rw-r--r--src/cmd/gc/dcl.c26
1 files changed, 10 insertions, 16 deletions
diff --git a/src/cmd/gc/dcl.c b/src/cmd/gc/dcl.c
index 335d056a0..7290f9d3b 100644
--- a/src/cmd/gc/dcl.c
+++ b/src/cmd/gc/dcl.c
@@ -39,6 +39,7 @@ push(void)
Sym *d;
d = mal(sizeof(*d));
+ d->lastlineno = lineno;
d->link = dclstack;
dclstack = d;
return d;
@@ -60,6 +61,7 @@ void
popdcl(void)
{
Sym *d, *s;
+ int lno;
// if(dflag())
// print("revert\n");
@@ -68,7 +70,9 @@ popdcl(void)
if(d->name == nil)
break;
s = pkglookup(d->name, d->pkg);
+ lno = s->lastlineno;
dcopy(s, d);
+ d->lastlineno = lno;
if(dflag())
print("\t%L pop %S %p\n", lineno, s, s->def);
}
@@ -81,19 +85,12 @@ popdcl(void)
void
poptodcl(void)
{
- Sym *d, *s;
-
- for(d=dclstack; d!=S; d=d->link) {
- if(d->name == nil)
- break;
- s = pkglookup(d->name, d->pkg);
- dcopy(s, d);
- if(dflag())
- print("\t%L pop %S\n", lineno, s);
- }
- if(d == S)
- fatal("poptodcl: no mark");
- dclstack = d;
+ // pop the old marker and push a new one
+ // (cannot reuse the existing one)
+ // because we use the markers to identify blocks
+ // for the goto restriction checks.
+ popdcl();
+ markdcl();
}
void
@@ -1241,10 +1238,7 @@ funccompile(Node *n, int isclosure)
stksize = 0;
dclcontext = PAUTO;
funcdepth = n->funcdepth + 1;
- hasgoto = 0;
compile(n);
- if(hasgoto)
- clearstk();
curfn = nil;
funcdepth = 0;
dclcontext = PEXTERN;