aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2020-12-14 21:26:33 -0800
committerIan Lance Taylor <iant@golang.org>2020-12-15 12:54:25 -0800
commitf23753c710d54fdf6f6c6cbe93c5b0fdbf209fc8 (patch)
treef2d7daa0ca6fad7cbabafb17eb5461198edd99d8 /gcc
parenta582a319c1015f1f604b107bd25075f01d5a7e67 (diff)
downloadgcc-f23753c710d54fdf6f6c6cbe93c5b0fdbf209fc8.zip
gcc-f23753c710d54fdf6f6c6cbe93c5b0fdbf209fc8.tar.gz
gcc-f23753c710d54fdf6f6c6cbe93c5b0fdbf209fc8.tar.bz2
compiler: better error for unexpected digit
A digit character is not invalid in general, but it's not permitted at the start of an identifier. Report a better error message. The test case is issue11359.go in the source repo. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/278174
Diffstat (limited to 'gcc')
-rw-r--r--gcc/go/gofrontend/MERGE2
-rw-r--r--gcc/go/gofrontend/lex.cc7
2 files changed, 8 insertions, 1 deletions
diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE
index 681debb..1bada25 100644
--- a/gcc/go/gofrontend/MERGE
+++ b/gcc/go/gofrontend/MERGE
@@ -1,4 +1,4 @@
-3e8f49a2137a87fdaba51c3002ddbe41ab18ed46
+8b913a1865e36d4bd105f29aa0b12264a4e03515
The first line of this file holds the git revision number of the last
merge done from the gofrontend repository.
diff --git a/gcc/go/gofrontend/lex.cc b/gcc/go/gofrontend/lex.cc
index 156a90c..e71b8cd 100644
--- a/gcc/go/gofrontend/lex.cc
+++ b/gcc/go/gofrontend/lex.cc
@@ -743,6 +743,13 @@ Lex::next_token()
if (Lex::is_unicode_letter(ci))
return this->gather_identifier();
+ if (!issued_error && Lex::is_unicode_digit(ci))
+ {
+ go_error_at(this->location(),
+ "identifier cannot begin with digit");
+ issued_error = true;
+ }
+
if (!issued_error)
go_error_at(this->location(),
"invalid character 0x%x in input file",