================ @@ -3165,7 +3165,17 @@ bool Lexer::LexEndOfFile(Token &Result, const char *CurPtr) { // C99 5.1.1.2p2: If the file is non-empty and didn't end in a newline, issue // a pedwarn. - if (CurPtr != BufferStart && (CurPtr[-1] != '\n' && CurPtr[-1] != '\r')) { + if (CurPtr != BufferStart) { + StringRef LastNewline; + if (CurPtr[-1] == '\r' || CurPtr[-1] == '\n') { + LastNewline = StringRef(CurPtr - 1, 1); + if (CurPtr - 1 != BufferStart && CurPtr[-2] != CurPtr[-1] && + (CurPtr[-2] == '\r' || CurPtr[-2] == '\n')) { + // \r\n or \n\r is one newline ---------------- cor3ntin wrote:
treating `\n\r` as a single new line is correct-ish as this was a convention on the BBC Micro (and it is consistent with our existing behavior) As for conformance, neither standard specify what is a new line ( work on https://isocpp.org/files/papers/P2348R3.pdf is stalled) @tahonermann https://github.com/llvm/llvm-project/pull/97585 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits