FAQ
Reviewers: dsymonds,

Message:
Hello dsymonds (cc: golang-dev@googlegroups.com),

I'd like you to review this change to
https://go.googlecode.com/hg/


Description:
cmd/gc: fix a spurious -u compile error

Fixes issue 4082.

Please review this at http://codereview.appspot.com/6545055/

Affected files:
M src/cmd/gc/go.h
M src/cmd/gc/reflect.c
M src/cmd/gc/typecheck.c


Index: src/cmd/gc/go.h
===================================================================
--- a/src/cmd/gc/go.h
+++ b/src/cmd/gc/go.h
@@ -919,6 +919,7 @@
EXTERN int funcdepth;
EXTERN int typecheckok;
EXTERN int compiling_runtime;
+EXTERN int compiling_wrappers;

/*
* y.tab.c
Index: src/cmd/gc/reflect.c
===================================================================
--- a/src/cmd/gc/reflect.c
+++ b/src/cmd/gc/reflect.c
@@ -210,22 +210,26 @@
// 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: src/cmd/gc/typecheck.c
===================================================================
--- a/src/cmd/gc/typecheck.c
+++ b/src/cmd/gc/typecheck.c
@@ -1536,9 +1536,7 @@
}
}

- // 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);

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-dev @
categoriesgo
postedSep 21, '12 at 3:28p
activeSep 22, '12 at 1:12a
posts3
users2
websitegolang.org

2 users in discussion

Rsc: 2 posts David Symonds: 1 post

People

Translate

site design / logo © 2022 Grokbase