diff options
-rw-r--r-- | lib/Lex/PPDirectives.cpp | 2 | ||||
-rw-r--r-- | lib/Lex/PPExpressions.cpp | 2 | ||||
-rw-r--r-- | test/Preprocessor/has_include.c | 9 |
3 files changed, 11 insertions, 2 deletions
diff --git a/lib/Lex/PPDirectives.cpp b/lib/Lex/PPDirectives.cpp index 8379ca8719..e19eb31335 100644 --- a/lib/Lex/PPDirectives.cpp +++ b/lib/Lex/PPDirectives.cpp @@ -2082,7 +2082,6 @@ void Preprocessor::HandleIfdefDirective(Token &Result, bool isIfndef, /// void Preprocessor::HandleIfDirective(Token &IfToken, bool ReadAnyTokensBeforeDirective) { - SaveAndRestore<bool> PPDir(ParsingIfOrElifDirective, true); ++NumIf; // Parse and evaluate the conditional expression. @@ -2174,7 +2173,6 @@ void Preprocessor::HandleElseDirective(Token &Result) { /// HandleElifDirective - Implements the \#elif directive. /// void Preprocessor::HandleElifDirective(Token &ElifToken) { - SaveAndRestore<bool> PPDir(ParsingIfOrElifDirective, true); ++NumElse; // #elif directive in a non-skipping conditional... start skipping. diff --git a/lib/Lex/PPExpressions.cpp b/lib/Lex/PPExpressions.cpp index 49f4cbf71a..27ad7b4a1b 100644 --- a/lib/Lex/PPExpressions.cpp +++ b/lib/Lex/PPExpressions.cpp @@ -24,6 +24,7 @@ #include "clang/Lex/MacroInfo.h" #include "llvm/ADT/APSInt.h" #include "llvm/Support/ErrorHandling.h" +#include "llvm/Support/SaveAndRestore.h" using namespace clang; namespace { @@ -730,6 +731,7 @@ static bool EvaluateDirectiveSubExpr(PPValue &LHS, unsigned MinPrec, /// to "!defined(X)" return X in IfNDefMacro. bool Preprocessor:: EvaluateDirectiveExpression(IdentifierInfo *&IfNDefMacro) { + SaveAndRestore<bool> PPDir(ParsingIfOrElifDirective, true); // Save the current state of 'DisableMacroExpansion' and reset it to false. If // 'DisableMacroExpansion' is true, then we must be in a macro argument list // in which case a directive is undefined behavior. We want macros to be able diff --git a/test/Preprocessor/has_include.c b/test/Preprocessor/has_include.c index 7cc67fac03..131e51919f 100644 --- a/test/Preprocessor/has_include.c +++ b/test/Preprocessor/has_include.c @@ -176,3 +176,12 @@ __has_include #else #error "__has_include failed (9)." #endif + +#if FOO +#elif __has_include(<foo>) +#endif + +// PR15539 +#ifdef FOO +#elif __has_include(<foo>) +#endif |