summaryrefslogtreecommitdiff
path: root/gcc/go/gofrontend/lex.cc
diff options
context:
space:
mode:
authorian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>2012-01-23 23:55:31 +0000
committerian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>2012-01-23 23:55:31 +0000
commit7d83409086556232adbe25c1406be29ec68402e8 (patch)
treeed963d480affb07d364c84b0b56a97f7bb92427b /gcc/go/gofrontend/lex.cc
parentc1e8b3edf7b5038f070c7a9732e58d066081a636 (diff)
downloadgcc-7d83409086556232adbe25c1406be29ec68402e8.tar.gz
compiler: Give an error if a variable is defined but not used.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@183458 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/go/gofrontend/lex.cc')
-rw-r--r--gcc/go/gofrontend/lex.cc14
1 files changed, 14 insertions, 0 deletions
diff --git a/gcc/go/gofrontend/lex.cc b/gcc/go/gofrontend/lex.cc
index af23e9be162..d46334f17a7 100644
--- a/gcc/go/gofrontend/lex.cc
+++ b/gcc/go/gofrontend/lex.cc
@@ -866,6 +866,7 @@ Lex::gather_identifier()
this->lineoff_ = p - this->linebuf_;
const char* pnext = this->advance_one_utf8_char(p, &ci,
&issued_error);
+ bool is_invalid = false;
if (!Lex::is_unicode_letter(ci) && !Lex::is_unicode_digit(ci))
{
// There is no valid place for a non-ASCII character
@@ -876,6 +877,7 @@ Lex::gather_identifier()
error_at(this->location(),
"invalid character 0x%x in identifier",
ci);
+ is_invalid = true;
}
if (is_first)
{
@@ -887,6 +889,8 @@ Lex::gather_identifier()
buf.assign(pstart, p - pstart);
has_non_ascii_char = true;
}
+ if (is_invalid && !Lex::is_invalid_identifier(buf))
+ buf.append("$INVALID$");
p = pnext;
char ubuf[50];
// This assumes that all assemblers can handle an identifier
@@ -2312,3 +2316,13 @@ Lex::is_exported_name(const std::string& name)
return Lex::is_unicode_uppercase(ci);
}
}
+
+// Return whether the identifier NAME contains an invalid character.
+// This is based on how we handle invalid characters in
+// gather_identifier.
+
+bool
+Lex::is_invalid_identifier(const std::string& name)
+{
+ return name.find("$INVALID$") != std::string::npos;
+}