diff options
Diffstat (limited to 'Lex')
-rw-r--r-- | Lex/Preprocessor.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/Lex/Preprocessor.cpp b/Lex/Preprocessor.cpp index b51222cefd..f43eae1c98 100644 --- a/Lex/Preprocessor.cpp +++ b/Lex/Preprocessor.cpp @@ -2121,8 +2121,13 @@ void Preprocessor::HandleIfdefDirective(Token &Result, bool isIfndef, ReadMacroName(MacroNameTok); // Error reading macro name? If so, diagnostic already issued. - if (MacroNameTok.getKind() == tok::eom) + if (MacroNameTok.getKind() == tok::eom) { + // Skip code until we get to #endif. This helps with recovery by not + // emitting an error when the #endif is reached. + SkipExcludedConditionalBlock(DirectiveTok.getLocation(), + /*Foundnonskip*/false, /*FoundElse*/false); return; + } // Check to see if this is the last token on the #if[n]def line. CheckEndOfDirective(isIfndef ? "#ifndef" : "#ifdef"); |