aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@gcc.gnu.org>2012-09-20 00:54:30 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2012-09-20 00:54:30 +0000
commite29941cef2ac3ed3af5e0e6f9b443ada129fa4ec (patch)
tree8684bfd3ff7726e4ed537914fc18fc642471fe89 /gcc
parentf8f72892e8e371f75b430c070f518cada22b8318 (diff)
downloadgcc-e29941cef2ac3ed3af5e0e6f9b443ada129fa4ec.zip
gcc-e29941cef2ac3ed3af5e0e6f9b443ada129fa4ec.tar.gz
gcc-e29941cef2ac3ed3af5e0e6f9b443ada129fa4ec.tar.bz2
compiler: Give error for byte-order-mark in middle of file.
From-SVN: r191507
Diffstat (limited to 'gcc')
-rw-r--r--gcc/go/gofrontend/lex.cc10
1 files changed, 9 insertions, 1 deletions
diff --git a/gcc/go/gofrontend/lex.cc b/gcc/go/gofrontend/lex.cc
index fa9db1f..25aaeb7 100644
--- a/gcc/go/gofrontend/lex.cc
+++ b/gcc/go/gofrontend/lex.cc
@@ -726,7 +726,7 @@ Lex::next_token()
&issued_error);
// Ignore byte order mark at start of file.
- if (ci == 0xfeff && this->lineno_ == 1 && this->lineoff_ == 0)
+ if (ci == 0xfeff)
{
p = pnext;
break;
@@ -840,6 +840,14 @@ Lex::advance_one_utf8_char(const char* p, unsigned int* value,
*issued_error = true;
return p + 1;
}
+
+ // Warn about byte order mark, except at start of file.
+ if (*value == 0xfeff && (this->lineno_ != 1 || this->lineoff_ != 0))
+ {
+ error_at(this->location(), "Unicode (UTF-8) BOM in middle of file");
+ *issued_error = true;
+ }
+
return p + adv;
}