From: Ian Lance Taylor Date: Thu, 20 Sep 2012 00:54:30 +0000 (+0000) Subject: compiler: Give error for byte-order-mark in middle of file. X-Git-Tag: misc/gccgo-go1_1_2~735 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e29941cef2ac3ed3af5e0e6f9b443ada129fa4ec;p=thirdparty%2Fgcc.git compiler: Give error for byte-order-mark in middle of file. From-SVN: r191507 --- diff --git a/gcc/go/gofrontend/lex.cc b/gcc/go/gofrontend/lex.cc index fa9db1f29aca..25aaeb794a55 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; }