diff mbox

Go patch committed: Don't treat 0x123i as 123i

Message ID mcripg7j005.fsf@dhcp-172-18-216-180.mtv.corp.google.com
State New
Headers show

Commit Message

Ian Lance Taylor May 7, 2012, 6:53 p.m. UTC
This patch from Rémy Oudompheng fixes the Go frontend lexer to not treat
0x123i as 123i.  Bootstrapped and ran Go testsuite on
x86_64-unknown-linux-gnu.  Committed to mainline and 4.7 branch.

Ian
diff mbox

Patch

diff -r 8671bcd0c298 go/lex.cc
--- a/go/lex.cc	Mon May 07 11:35:33 2012 -0700
+++ b/go/lex.cc	Mon May 07 11:50:46 2012 -0700
@@ -1012,7 +1012,9 @@ 
 	    }
 	}
 
-      if (*p != '.' && *p != 'i' && !Lex::could_be_exponent(p, pend))
+      // A partial token that looks like an octal literal might actually be the
+      // beginning of a floating-point or imaginary literal.
+      if (base == 16 || (*p != '.' && *p != 'i' && !Lex::could_be_exponent(p, pend)))
 	{
 	  std::string s(pnum, p - pnum);
 	  mpz_t val;