Patchwork [gccgo] Permit omitting lower bound in a slice expression

login
register
mail settings
Submitter Ian Taylor
Date Sept. 10, 2010, 11:19 p.m.
Message ID <mcrd3sl89vq.fsf@google.com>
Download mbox | patch
Permalink /patch/64477/
State New
Headers show

Comments

Ian Taylor - Sept. 10, 2010, 11:19 p.m.
The Go language was tweaked to permit omitting the lower bound in a
slice expression.  This patch implements that for gccgo.  Committed to
gccgo branch.

Ian

Patch

diff -r f46918ae9445 go/parse.cc
--- a/go/parse.cc	Fri Sep 10 11:41:29 2010 -0700
+++ b/go/parse.cc	Fri Sep 10 16:17:39 2010 -0700
@@ -2653,8 +2653,10 @@ 
     start = this->expression(PRECEDENCE_NORMAL, false, true, NULL);
   else
     {
-      this->error("missing lower bound in slice expression");
-      start = Expression::make_error(this->location());
+      mpz_t zero;
+      mpz_init_set_ui(zero, 0);
+      start = Expression::make_integer(&zero, NULL, location);
+      mpz_clear(zero);
     }
 
   Expression* end = NULL;