<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">Nice catch! <div><br><div><div>On Mar 18, 2013, at 4:22 PM, David Blaikie <<a href="mailto:dblaikie@gmail.com">dblaikie@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;">Author: dblaikie<br>Date: Mon Mar 18 18:22:28 2013<br>New Revision: 177345<br><br>URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project?rev=177345&view=rev">http://llvm.org/viewvc/llvm-project?rev=177345&view=rev</a><br>Log:<br>PR15539: Record "evaluating if/elif condition" flag in the right place<br><br>The previous implementation missed the case where the elif condition was<br>evaluated from the context of an #ifdef that was false causing PR15539.<br><br>Modified:<br>   cfe/trunk/lib/Lex/PPDirectives.cpp<br>   cfe/trunk/lib/Lex/PPExpressions.cpp<br>   cfe/trunk/test/Preprocessor/has_include.c<br><br>Modified: cfe/trunk/lib/Lex/PPDirectives.cpp<br>URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPDirectives.cpp?rev=177345&r1=177344&r2=177345&view=diff">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPDirectives.cpp?rev=177345&r1=177344&r2=177345&view=diff</a><br>==============================================================================<br>--- cfe/trunk/lib/Lex/PPDirectives.cpp (original)<br>+++ cfe/trunk/lib/Lex/PPDirectives.cpp Mon Mar 18 18:22:28 2013<br>@@ -2082,7 +2082,6 @@ void Preprocessor::HandleIfdefDirective(<br>///<br>void Preprocessor::HandleIfDirective(Token &IfToken,<br>                                     bool ReadAnyTokensBeforeDirective) {<br>-  SaveAndRestore<bool> PPDir(ParsingIfOrElifDirective, true);<br>  ++NumIf;<br><br>  // Parse and evaluate the conditional expression.<br>@@ -2174,7 +2173,6 @@ void Preprocessor::HandleElseDirective(T<br>/// HandleElifDirective - Implements the \#elif directive.<br>///<br>void Preprocessor::HandleElifDirective(Token &ElifToken) {<br>-  SaveAndRestore<bool> PPDir(ParsingIfOrElifDirective, true);<br>  ++NumElse;<br><br>  // #elif directive in a non-skipping conditional... start skipping.<br><br>Modified: cfe/trunk/lib/Lex/PPExpressions.cpp<br>URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPExpressions.cpp?rev=177345&r1=177344&r2=177345&view=diff">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPExpressions.cpp?rev=177345&r1=177344&r2=177345&view=diff</a><br>==============================================================================<br>--- cfe/trunk/lib/Lex/PPExpressions.cpp (original)<br>+++ cfe/trunk/lib/Lex/PPExpressions.cpp Mon Mar 18 18:22:28 2013<br>@@ -24,6 +24,7 @@<br>#include "clang/Lex/MacroInfo.h"<br>#include "llvm/ADT/APSInt.h"<br>#include "llvm/Support/ErrorHandling.h"<br>+#include "llvm/Support/SaveAndRestore.h"<br>using namespace clang;<br><br>namespace {<br>@@ -730,6 +731,7 @@ static bool EvaluateDirectiveSubExpr(PPV<br>/// to "!defined(X)" return X in IfNDefMacro.<br>bool Preprocessor::<br>EvaluateDirectiveExpression(IdentifierInfo *&IfNDefMacro) {<br>+  SaveAndRestore<bool> PPDir(ParsingIfOrElifDirective, true);<br>  // Save the current state of 'DisableMacroExpansion' and reset it to false. If<br>  // 'DisableMacroExpansion' is true, then we must be in a macro argument list<br>  // in which case a directive is undefined behavior.  We want macros to be able<br><br>Modified: cfe/trunk/test/Preprocessor/has_include.c<br>URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/has_include.c?rev=177345&r1=177344&r2=177345&view=diff">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/has_include.c?rev=177345&r1=177344&r2=177345&view=diff</a><br>==============================================================================<br>--- cfe/trunk/test/Preprocessor/has_include.c (original)<br>+++ cfe/trunk/test/Preprocessor/has_include.c Mon Mar 18 18:22:28 2013<br>@@ -176,3 +176,12 @@ __has_include<br>#else<br>  #error "__has_include failed (9)."<br>#endif<br>+<br>+#if FOO<br>+#elif __has_include(<foo>)<br>+#endif<br>+<br>+// PR15539<br>+#ifdef FOO<br>+#elif __has_include(<foo>)<br>+#endif<br><br><br>_______________________________________________<br>cfe-commits mailing list<br><a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br><a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a></div></blockquote></div><br></div></body></html>