mirror of
https://github.com/golang/go
synced 2024-11-25 06:17:58 -07:00
bug28
fix code generation bug in second index of string slice. SVN=114255
This commit is contained in:
parent
0b62cb61ca
commit
c69d54e7cd
25
src/c/gen.c
25
src/c/gen.c
@ -245,7 +245,7 @@ void
|
|||||||
cgen(Node *n)
|
cgen(Node *n)
|
||||||
{
|
{
|
||||||
long lno;
|
long lno;
|
||||||
Node *nl, *nr, *r, *r1;
|
Node *nl, *nr, *r;
|
||||||
int a;
|
int a;
|
||||||
Prog *p1, *p2, *p3;
|
Prog *p1, *p2, *p3;
|
||||||
|
|
||||||
@ -358,21 +358,14 @@ cgen(Node *n)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case OSLICE:
|
case OSLICE:
|
||||||
nl = n->left;
|
nl = n->left; // name
|
||||||
nr = n->right;
|
nr = n->right;
|
||||||
|
|
||||||
r = nr->left;
|
r = nr->right; // index2
|
||||||
if(usesptr(nr->left)) {
|
if(!r->addable) {
|
||||||
cgen(nr->left);
|
cgen(r);
|
||||||
r = tempname(nr->left->type);
|
r = tempname(r->type);
|
||||||
gopcodet(PSTORE, nr->left->type, r);
|
gopcodet(PSTORE, r->type, r);
|
||||||
}
|
|
||||||
|
|
||||||
r1 = nr->right;
|
|
||||||
if(!nr->right->addable) {
|
|
||||||
cgen(nr->right);
|
|
||||||
r1 = tempname(nr->right->type);
|
|
||||||
gopcodet(PSTORE, nr->right->type, r1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// string into PTADDR
|
// string into PTADDR
|
||||||
@ -385,8 +378,8 @@ cgen(Node *n)
|
|||||||
// offset in int reg
|
// offset in int reg
|
||||||
cgen(nr->left);
|
cgen(nr->left);
|
||||||
|
|
||||||
// len addressed
|
// index 2 addressed
|
||||||
gopcodet(PSLICE, nr->left->type, nr->right);
|
gopcodet(PSLICE, r->type, r);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case OINDEXPTR:
|
case OINDEXPTR:
|
||||||
|
Loading…
Reference in New Issue
Block a user