diff options
Diffstat (limited to 'clang/lib/Lex')
-rw-r--r-- | clang/lib/Lex/LiteralSupport.cpp | 2 | ||||
-rw-r--r-- | clang/lib/Lex/Pragma.cpp | 12 |
2 files changed, 12 insertions, 2 deletions
diff --git a/clang/lib/Lex/LiteralSupport.cpp b/clang/lib/Lex/LiteralSupport.cpp index a62508e..5b08d7f 100644 --- a/clang/lib/Lex/LiteralSupport.cpp +++ b/clang/lib/Lex/LiteralSupport.cpp @@ -1467,7 +1467,7 @@ void NumericLiteralParser::ParseNumberStartingWithZero(SourceLocation TokLoc) { if (s != PossibleNewDigitStart) DigitsBegin = PossibleNewDigitStart; else - IsSingleZero = (s == ThisTokEnd); // Is the only thing we've seen a 0? + IsSingleZero = (s == ThisTokBegin + 1); if (s == ThisTokEnd) return; // Done, simple octal number like 01234 diff --git a/clang/lib/Lex/Pragma.cpp b/clang/lib/Lex/Pragma.cpp index 01c85e6..bba3c89 100644 --- a/clang/lib/Lex/Pragma.cpp +++ b/clang/lib/Lex/Pragma.cpp @@ -591,7 +591,8 @@ IdentifierInfo *Preprocessor::ParsePragmaPushOrPopMacro(Token &Tok) { } // Remember the macro string. - std::string StrVal = getSpelling(Tok); + Token StrTok = Tok; + std::string StrVal = getSpelling(StrTok); // Read the ')'. Lex(Tok); @@ -604,6 +605,15 @@ IdentifierInfo *Preprocessor::ParsePragmaPushOrPopMacro(Token &Tok) { assert(StrVal[0] == '"' && StrVal[StrVal.size()-1] == '"' && "Invalid string token!"); + if (StrVal.size() <= 2) { + Diag(StrTok.getLocation(), diag::warn_pargma_push_pop_macro_empty_string) + << SourceRange( + StrTok.getLocation(), + StrTok.getLocation().getLocWithOffset(StrTok.getLength())) + << PragmaTok.getIdentifierInfo()->isStr("pop_macro"); + return nullptr; + } + // Create a Token from the string. Token MacroTok; MacroTok.startToken(); |