diff options
Diffstat (limited to 'contrib/llvm/tools/clang/lib/Lex/PPExpressions.cpp')
-rw-r--r-- | contrib/llvm/tools/clang/lib/Lex/PPExpressions.cpp | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/contrib/llvm/tools/clang/lib/Lex/PPExpressions.cpp b/contrib/llvm/tools/clang/lib/Lex/PPExpressions.cpp index 87c0a6a..2260bf9 100644 --- a/contrib/llvm/tools/clang/lib/Lex/PPExpressions.cpp +++ b/contrib/llvm/tools/clang/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,18 +101,17 @@ 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()) == 0) { - 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. - MacroDirective *Macro = 0; + MacroDirective *Macro = nullptr; // If there is a macro, mark it used. if (Result.Val != 0 && ValueLive) { Macro = PP.getMacroDirective(II); @@ -130,8 +128,9 @@ static bool EvaluateDefined(PPValue &Result, Token &PeekTok, DefinedTracker &DT, PP.LexUnexpandedNonComment(PeekTok); if (PeekTok.isNot(tok::r_paren)) { - PP.Diag(PeekTok.getLocation(), diag::err_pp_missing_rparen) << "defined"; - PP.Diag(LParenLoc, diag::note_matching) << "("; + PP.Diag(PeekTok.getLocation(), diag::err_pp_expected_after) + << "'defined'" << tok::r_paren; + PP.Diag(LParenLoc, diag::note_matching) << tok::l_paren; return true; } // Consume the ). @@ -257,9 +256,10 @@ static bool EvaluateValue(PPValue &Result, Token &PeekTok, DefinedTracker &DT, // large that it is unsigned" e.g. on 12345678901234567890 where intmax_t // is 64-bits. if (!Literal.isUnsigned && Result.Val.isNegative()) { - // Don't warn for a hex or octal literal: 0x8000..0 shouldn't warn. + // Octal, hexadecimal, and binary literals are implicitly unsigned if + // the value does not fit into a signed integer type. if (ValueLive && Literal.getRadix() == 10) - PP.Diag(PeekTok, diag::warn_integer_too_large_for_signed); + PP.Diag(PeekTok, diag::ext_integer_too_large_for_signed); Result.Val.setIsUnsigned(true); } } @@ -342,7 +342,7 @@ static bool EvaluateValue(PPValue &Result, Token &PeekTok, DefinedTracker &DT, if (PeekTok.isNot(tok::r_paren)) { PP.Diag(PeekTok.getLocation(), diag::err_pp_expected_rparen) << Result.getRange(); - PP.Diag(Start, diag::note_matching) << "("; + PP.Diag(Start, diag::note_matching) << tok::l_paren; return true; } DT.State = DefinedTracker::Unknown; @@ -680,9 +680,9 @@ static bool EvaluateDirectiveSubExpr(PPValue &LHS, unsigned MinPrec, case tok::question: { // Parse the : part of the expression. if (PeekTok.isNot(tok::colon)) { - PP.Diag(PeekTok.getLocation(), diag::err_expected_colon) - << LHS.getRange(), RHS.getRange(); - PP.Diag(OpLoc, diag::note_matching) << "?"; + PP.Diag(PeekTok.getLocation(), diag::err_expected) + << tok::colon << LHS.getRange() << RHS.getRange(); + PP.Diag(OpLoc, diag::note_matching) << tok::question; return true; } // Consume the :. |