aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.8/gcc/go/gofrontend/lex.cc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc-4.8/gcc/go/gofrontend/lex.cc')
-rw-r--r--gcc-4.8/gcc/go/gofrontend/lex.cc21
1 files changed, 21 insertions, 0 deletions
diff --git a/gcc-4.8/gcc/go/gofrontend/lex.cc b/gcc-4.8/gcc/go/gofrontend/lex.cc
index 22a1f6e2a..d03c4bde2 100644
--- a/gcc-4.8/gcc/go/gofrontend/lex.cc
+++ b/gcc-4.8/gcc/go/gofrontend/lex.cc
@@ -873,7 +873,28 @@ Lex::gather_identifier()
&& (cc < 'a' || cc > 'z')
&& cc != '_'
&& (cc < '0' || cc > '9'))
+ {
+ // Check for an invalid character here, as we get better
+ // error behaviour if we swallow them as part of the
+ // identifier we are building.
+ if ((cc >= ' ' && cc < 0x7f)
+ || cc == '\t'
+ || cc == '\r'
+ || cc == '\n')
break;
+
+ this->lineoff_ = p - this->linebuf_;
+ error_at(this->location(),
+ "invalid character 0x%x in identifier",
+ cc);
+ if (!has_non_ascii_char)
+ {
+ buf.assign(pstart, p - pstart);
+ has_non_ascii_char = true;
+ }
+ if (!Lex::is_invalid_identifier(buf))
+ buf.append("$INVALID$");
+ }
++p;
if (is_first)
{