1
0
mirror of https://github.com/golang/go synced 2024-11-17 12:04:43 -07:00

cmd/5c: fix handling of side effects when assigning a struct literal.

Also undo revision a5b96b602690 used to workaround the bug.

Fixes #4643.

R=rsc, golang-dev, dave, minux.ma, lucio.dere, bradfitz
CC=golang-dev
https://golang.org/cl/7090043
This commit is contained in:
Rémy Oudompheng 2013-01-12 09:16:50 +01:00
parent dc75670ae2
commit c13866db7f
2 changed files with 6 additions and 10 deletions

View File

@ -950,9 +950,9 @@ sugen(Node *n, Node *nn, int32 w)
case OSTRUCT: case OSTRUCT:
/* /*
* rewrite so lhs has no fn call * rewrite so lhs has no side effect.
*/ */
if(nn != Z && nn->complex >= FNX) { if(nn != Z && side(nn)) {
nod1 = *n; nod1 = *n;
nod1.type = typ(TIND, n->type); nod1.type = typ(TIND, n->type);
regret(&nod2, &nod1); regret(&nod2, &nod1);

View File

@ -338,8 +338,7 @@ flushptrbuf(PtrTarget *ptrbuf, PtrTarget **ptrbufpos, Obj **_wp, Workbuf **_wbuf
if((bits & (bitAllocated|bitMarked)) != bitAllocated) if((bits & (bitAllocated|bitMarked)) != bitAllocated)
continue; continue;
*bitbufpos = (BitTarget){obj, ti, bitp, shift}; *bitbufpos++ = (BitTarget){obj, ti, bitp, shift};
bitbufpos++;
} }
runtime·lock(&lock); runtime·lock(&lock);
@ -542,8 +541,7 @@ scanblock(Workbuf *wbuf, Obj *wp, uintptr nobj, bool keepworking)
// iface->tab // iface->tab
if((void*)iface->tab >= arena_start && (void*)iface->tab < arena_used) { if((void*)iface->tab >= arena_start && (void*)iface->tab < arena_used) {
*ptrbufpos = (PtrTarget){iface->tab, (uintptr)itabtype->gc}; *ptrbufpos++ = (PtrTarget){iface->tab, (uintptr)itabtype->gc};
ptrbufpos++;
if(ptrbufpos == ptrbuf_end) if(ptrbufpos == ptrbuf_end)
flushptrbuf(ptrbuf, &ptrbufpos, &wp, &wbuf, &nobj, bitbuf); flushptrbuf(ptrbuf, &ptrbufpos, &wp, &wbuf, &nobj, bitbuf);
} }
@ -570,8 +568,7 @@ scanblock(Workbuf *wbuf, Obj *wp, uintptr nobj, bool keepworking)
stack_top.b += PtrSize; stack_top.b += PtrSize;
obj = *(byte**)i; obj = *(byte**)i;
if(obj >= arena_start && obj < arena_used) { if(obj >= arena_start && obj < arena_used) {
*ptrbufpos = (PtrTarget){obj, 0}; *ptrbufpos++ = (PtrTarget){obj, 0};
ptrbufpos++;
if(ptrbufpos == ptrbuf_end) if(ptrbufpos == ptrbuf_end)
flushptrbuf(ptrbuf, &ptrbufpos, &wp, &wbuf, &nobj, bitbuf); flushptrbuf(ptrbuf, &ptrbufpos, &wp, &wbuf, &nobj, bitbuf);
} }
@ -657,8 +654,7 @@ scanblock(Workbuf *wbuf, Obj *wp, uintptr nobj, bool keepworking)
} }
if(obj >= arena_start && obj < arena_used) { if(obj >= arena_start && obj < arena_used) {
*ptrbufpos = (PtrTarget){obj, objti}; *ptrbufpos++ = (PtrTarget){obj, objti};
ptrbufpos++;
if(ptrbufpos == ptrbuf_end) if(ptrbufpos == ptrbuf_end)
flushptrbuf(ptrbuf, &ptrbufpos, &wp, &wbuf, &nobj, bitbuf); flushptrbuf(ptrbuf, &ptrbufpos, &wp, &wbuf, &nobj, bitbuf);
} }