summaryrefslogtreecommitdiff
path: root/src/cmd/gc/range.c
diff options
context:
space:
mode:
authorMichael Stapelberg <stapelberg@debian.org>2013-03-04 21:27:36 +0100
committerMichael Stapelberg <michael@stapelberg.de>2013-03-04 21:27:36 +0100
commit04b08da9af0c450d645ab7389d1467308cfc2db8 (patch)
treedb247935fa4f2f94408edc3acd5d0d4f997aa0d8 /src/cmd/gc/range.c
parent917c5fb8ec48e22459d77e3849e6d388f93d3260 (diff)
downloadgolang-04b08da9af0c450d645ab7389d1467308cfc2db8.tar.gz
Imported Upstream version 1.1~hg20130304upstream/1.1_hg20130304
Diffstat (limited to 'src/cmd/gc/range.c')
-rw-r--r--src/cmd/gc/range.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/cmd/gc/range.c b/src/cmd/gc/range.c
index d301e4e4f..50c4617c0 100644
--- a/src/cmd/gc/range.c
+++ b/src/cmd/gc/range.c
@@ -72,6 +72,15 @@ typecheckrange(Node *n)
if(n->list->next)
v2 = n->list->next->n;
+ // this is not only a optimization but also a requirement in the spec.
+ // "if the second iteration variable is the blank identifier, the range
+ // clause is equivalent to the same clause with only the first variable
+ // present."
+ if(isblank(v2)) {
+ n->list = list1(v1);
+ v2 = N;
+ }
+
if(v1->defn == n)
v1->type = t1;
else if(v1->type != T && assignop(t1, v1->type, &why) == 0)
@@ -145,7 +154,7 @@ walkrange(Node *n)
if(v2) {
hp = temp(ptrto(n->type->type));
tmp = nod(OINDEX, ha, nodintconst(0));
- tmp->etype = 1; // no bounds check
+ tmp->bounded = 1;
init = list(init, nod(OAS, hp, nod(OADDR, tmp, N)));
}