This patch by Chris Manghane fixes the Go frontend to accept numeric
literals with leading zeroes, even if they don't turn out to be octal.
This fixes https://golang.org/issue/11532 and
https://golang.org/issue/11533 . Bootstrapped and ran Go testsuite on
x86_64-unknown-linux-gnu. Committed to mainline.
Ian
Index: gcc/go/gofrontend/MERGE
===================================================================
--- gcc/go/gofrontend/MERGE (revision 227191)
+++ gcc/go/gofrontend/MERGE (working copy)
@@ -1,4 +1,4 @@
-14ca4b6130b9a7132d132f418e9ea283b3a52c08
+f97d579fa8431af5cfde9b0a48604caabfd09377
The first line of this file holds the git revision number of the last
merge done from the gofrontend repository.
Index: gcc/go/gofrontend/lex.cc
===================================================================
--- gcc/go/gofrontend/lex.cc (revision 226846)
+++ gcc/go/gofrontend/lex.cc (working copy)
@@ -1047,7 +1047,7 @@ Lex::gather_number()
pnum = p;
while (p < pend)
{
- if (*p < '0' || *p > '7')
+ if (*p < '0' || *p > '9')
break;
++p;
}
@@ -1060,7 +1060,13 @@ Lex::gather_number()
std::string s(pnum, p - pnum);
mpz_t val;
int r = mpz_init_set_str(val, s.c_str(), base);
- go_assert(r == 0);
+ if (r != 0)
+ {
+ if (base == 8)
+ error_at(this->location(), "invalid octal literal");
+ else
+ error_at(this->location(), "invalid hex literal");
+ }
if (neg)
mpz_neg(val, val);