5g, 6g, 8g: generate code for string index
instead of calling function.
R=ken2
CC=golang-dev
https://golang.org/cl/2762041
diff --git a/src/cmd/gc/typecheck.c b/src/cmd/gc/typecheck.c
index 6148337..c4f0826 100644
--- a/src/cmd/gc/typecheck.c
+++ b/src/cmd/gc/typecheck.c
@@ -614,7 +614,6 @@
if(n->right->type != T && !isint[n->right->type->etype])
yyerror("non-integer string index %#N", n->right);
n->type = types[TUINT8];
- n->op = OINDEXSTR;
break;
}
goto ret;
@@ -2052,6 +2051,8 @@
case OINDEX:
if(isfixedarray(n->left->type))
return islvalue(n->left);
+ if(n->left->type != T && n->left->type->etype == TSTRING)
+ return 0;
// fall through
case OIND:
case ODOTPTR: