From e29941cef2ac3ed3af5e0e6f9b443ada129fa4ec Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Thu, 20 Sep 2012 00:54:30 +0000 Subject: [PATCH] compiler: Give error for byte-order-mark in middle of file. From-SVN: r191507 --- gcc/go/gofrontend/lex.cc | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/gcc/go/gofrontend/lex.cc b/gcc/go/gofrontend/lex.cc index fa9db1f29ac..25aaeb794a5 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; } -- 2.30.2