From d8aee0e81bb12ec08d63628204371b366f336764 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Tue, 11 Jul 2006 05:04:55 +0000 Subject: Implement "lparen scanning" for lexer buffers, by making "skipping lexing" completely reversible. This implements tests 3/4 of test/Preprocessor/macro_fn_lparen_scan.c llvm-svn: 38699 --- clang/Lex/Lexer.cpp | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'clang/Lex/Lexer.cpp') diff --git a/clang/Lex/Lexer.cpp b/clang/Lex/Lexer.cpp index 967d4e76758..893ff04d82e 100644 --- a/clang/Lex/Lexer.cpp +++ b/clang/Lex/Lexer.cpp @@ -896,16 +896,21 @@ void Lexer::LexEndOfFile(LexerToken &Result, const char *CurPtr) { return; } - // If we are in a #if directive, emit an error. - while (!ConditionalStack.empty()) { - PP.Diag(ConditionalStack.back().IfLoc, - diag::err_pp_unterminated_conditional); - ConditionalStack.pop_back(); - } + // If we aren't skipping, issue diagnostics. If we are skipping, let the + // skipping code do this: there are multiple possible reasons for skipping, + // and not all want these diagnostics. + if (!PP.isSkipping()) { + // If we are in a #if directive, emit an error. + while (!ConditionalStack.empty()) { + PP.Diag(ConditionalStack.back().IfLoc, + diag::err_pp_unterminated_conditional); + ConditionalStack.pop_back(); + } - // If the file was empty or didn't end in a newline, issue a pedwarn. - if (CurPtr[-1] != '\n' && CurPtr[-1] != '\r') - Diag(BufferEnd, diag::ext_no_newline_eof); + // If the file was empty or didn't end in a newline, issue a pedwarn. + if (CurPtr[-1] != '\n' && CurPtr[-1] != '\r') + Diag(BufferEnd, diag::ext_no_newline_eof); + } BufferPtr = CurPtr; PP.HandleEndOfFile(Result); -- cgit v1.2.3