From 1dc4a3dfd6f99f28d73a3d7ebd6285fe6dd7187f Mon Sep 17 00:00:00 2001 From: David Blaikie Date: Mon, 18 Mar 2013 23:22:28 +0000 Subject: PR15539: Record "evaluating if/elif condition" flag in the right place The previous implementation missed the case where the elif condition was evaluated from the context of an #ifdef that was false causing PR15539. llvm-svn: 177345 --- clang/lib/Lex/PPExpressions.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'clang/lib/Lex/PPExpressions.cpp') diff --git a/clang/lib/Lex/PPExpressions.cpp b/clang/lib/Lex/PPExpressions.cpp index 49f4cbf71a2..27ad7b4a1ba 100644 --- a/clang/lib/Lex/PPExpressions.cpp +++ b/clang/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 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 -- cgit v1.2.3