diff options
author | Alp Toker <alp@nuanti.com> | 2014-05-21 06:13:51 +0000 |
---|---|---|
committer | Alp Toker <alp@nuanti.com> | 2014-05-21 06:13:51 +0000 |
commit | 4f6988e4874e78ff109af7053d7b98c2f591788b (patch) | |
tree | b3047b66733453298d7f63b35b29500e31a2c22c /lib/Lex/PPExpressions.cpp | |
parent | d685fc0eccf468b6d16204965b92f7ed65ee62b2 (diff) |
Preprocessor: support defined() with operator names for MS compatibility
Also flesh out missing tests, improve diagnostic QOI and fix a couple of corner
cases found in the process.
Fixes PR10606.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@209276 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Lex/PPExpressions.cpp')
-rw-r--r-- | lib/Lex/PPExpressions.cpp | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/lib/Lex/PPExpressions.cpp b/lib/Lex/PPExpressions.cpp index 8be7a54f82..2260bf98f7 100644 --- a/lib/Lex/PPExpressions.cpp +++ b/lib/Lex/PPExpressions.cpp @@ -81,7 +81,6 @@ struct DefinedTracker { /// EvaluateDefined - Process a 'defined(sym)' expression. static bool EvaluateDefined(PPValue &Result, Token &PeekTok, DefinedTracker &DT, bool ValueLive, Preprocessor &PP) { - IdentifierInfo *II; SourceLocation beginLoc(PeekTok.getLocation()); Result.setBegin(beginLoc); @@ -102,14 +101,13 @@ static bool EvaluateDefined(PPValue &Result, Token &PeekTok, DefinedTracker &DT, PP.setCodeCompletionReached(); PP.LexUnexpandedNonComment(PeekTok); } - + // If we don't have a pp-identifier now, this is an error. - if ((II = PeekTok.getIdentifierInfo()) == nullptr) { - PP.Diag(PeekTok, diag::err_pp_defined_requires_identifier); + if (PP.CheckMacroName(PeekTok, 0)) return true; - } // Otherwise, we got an identifier, is it defined to something? + IdentifierInfo *II = PeekTok.getIdentifierInfo(); Result.Val = II->hasMacroDefinition(); Result.Val.setIsUnsigned(false); // Result is signed intmax_t. |