Commit c29f4e00 authored by Russ Cox's avatar Russ Cox

cmd/gc: fix a spurious -u compile error

Fixes #4082.

R=dsymonds
CC=golang-dev
https://golang.org/cl/6545055
parent f934bb8e
...@@ -919,6 +919,7 @@ EXTERN int32 thunk; ...@@ -919,6 +919,7 @@ EXTERN int32 thunk;
EXTERN int funcdepth; EXTERN int funcdepth;
EXTERN int typecheckok; EXTERN int typecheckok;
EXTERN int compiling_runtime; EXTERN int compiling_runtime;
EXTERN int compiling_wrappers;
/* /*
* y.tab.c * y.tab.c
......
...@@ -210,22 +210,26 @@ methods(Type *t) ...@@ -210,22 +210,26 @@ methods(Type *t)
// but we can generate more efficient code // but we can generate more efficient code
// using genembedtramp if all that is necessary // using genembedtramp if all that is necessary
// is a pointer adjustment and a JMP. // is a pointer adjustment and a JMP.
compiling_wrappers = 1;
if(isptr[it->etype] && isptr[this->etype] if(isptr[it->etype] && isptr[this->etype]
&& f->embedded && !isifacemethod(f->type)) && f->embedded && !isifacemethod(f->type))
genembedtramp(it, f, a->isym, 1); genembedtramp(it, f, a->isym, 1);
else else
genwrapper(it, f, a->isym, 1); genwrapper(it, f, a->isym, 1);
compiling_wrappers = 0;
} }
} }
if(!(a->tsym->flags & SymSiggen)) { if(!(a->tsym->flags & SymSiggen)) {
a->tsym->flags |= SymSiggen; a->tsym->flags |= SymSiggen;
if(!eqtype(this, t)) { if(!eqtype(this, t)) {
compiling_wrappers = 1;
if(isptr[t->etype] && isptr[this->etype] if(isptr[t->etype] && isptr[this->etype]
&& f->embedded && !isifacemethod(f->type)) && f->embedded && !isifacemethod(f->type))
genembedtramp(t, f, a->tsym, 0); genembedtramp(t, f, a->tsym, 0);
else else
genwrapper(t, f, a->tsym, 0); genwrapper(t, f, a->tsym, 0);
compiling_wrappers = 0;
} }
} }
} }
......
...@@ -1536,9 +1536,7 @@ ret: ...@@ -1536,9 +1536,7 @@ ret:
} }
} }
// TODO(rsc): should not need to check importpkg, if(safemode && !incannedimport && !importpkg && !compiling_wrappers && t && t->etype == TUNSAFEPTR)
// but reflect mentions unsafe.Pointer.
if(safemode && !incannedimport && !importpkg && t && t->etype == TUNSAFEPTR)
yyerror("cannot use unsafe.Pointer"); yyerror("cannot use unsafe.Pointer");
evconst(n); evconst(n);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment