forked from OSchip/llvm-project
If we see an invalid #ifdef directive, enter a conditional compilation region
so that we don't emit an error on the #endif. Suggestion by Neil. llvm-svn: 42258
This commit is contained in:
parent
7d98b23f1a
commit
d05e44e74e
|
@ -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");
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
/* RUN: clang %s 2>&1 | grep error: | count 1
|
||||
*/
|
||||
|
||||
#ifdef
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue