]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/gc: fix a spurious -u compile error
authorRuss Cox <rsc@golang.org>
Sat, 22 Sep 2012 01:12:41 +0000 (21:12 -0400)
committerRuss Cox <rsc@golang.org>
Sat, 22 Sep 2012 01:12:41 +0000 (21:12 -0400)
Fixes #4082.

R=dsymonds
CC=golang-dev
https://golang.org/cl/6545055

src/cmd/gc/go.h
src/cmd/gc/reflect.c
src/cmd/gc/typecheck.c

index 67793bd4358ac80f3b32e06a5fd1e7c8a72cc489..37ed4fa0da90d7d9b99e780a234599e041441031 100644 (file)
@@ -919,6 +919,7 @@ EXTERN      int32   thunk;
 EXTERN int     funcdepth;
 EXTERN int     typecheckok;
 EXTERN int     compiling_runtime;
+EXTERN int     compiling_wrappers;
 
 /*
  *     y.tab.c
index f38f58b9cc6f6a955da68d61b14c796149769a4e..52b38d71670945762a9aa561ace80a5aafc28a6a 100644 (file)
@@ -210,22 +210,26 @@ methods(Type *t)
                                // but we can generate more efficient code
                                // using genembedtramp if all that is necessary
                                // is a pointer adjustment and a JMP.
+                               compiling_wrappers = 1;
                                if(isptr[it->etype] && isptr[this->etype]
                                && f->embedded && !isifacemethod(f->type))
                                        genembedtramp(it, f, a->isym, 1);
                                else
                                        genwrapper(it, f, a->isym, 1);
+                               compiling_wrappers = 0;
                        }
                }
 
                if(!(a->tsym->flags & SymSiggen)) {
                        a->tsym->flags |= SymSiggen;
                        if(!eqtype(this, t)) {
+                               compiling_wrappers = 1;
                                if(isptr[t->etype] && isptr[this->etype]
                                && f->embedded && !isifacemethod(f->type))
                                        genembedtramp(t, f, a->tsym, 0);
                                else
                                        genwrapper(t, f, a->tsym, 0);
+                               compiling_wrappers = 0;
                        }
                }
        }
index eeb46e2aa7edcee3aa0aa2553d49f50851775aef..74ed84b134e7a847ed82df2c5a754c2c121bf18c 100644 (file)
@@ -1536,9 +1536,7 @@ ret:
                }
        }
 
-       // TODO(rsc): should not need to check importpkg,
-       // but reflect mentions unsafe.Pointer.
-       if(safemode && !incannedimport && !importpkg && t && t->etype == TUNSAFEPTR)
+       if(safemode && !incannedimport && !importpkg && !compiling_wrappers && t && t->etype == TUNSAFEPTR)
                yyerror("cannot use unsafe.Pointer");
 
        evconst(n);