summaryrefslogtreecommitdiffstats
path: root/clang/Lex/Lexer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang/Lex/Lexer.cpp')
-rw-r--r--clang/Lex/Lexer.cpp23
1 files changed, 14 insertions, 9 deletions
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);
OpenPOWER on IntegriCloud