diff options
Diffstat (limited to 'clang/lib/Lex/Pragma.cpp')
-rw-r--r-- | clang/lib/Lex/Pragma.cpp | 12 |
1 files changed, 11 insertions, 1 deletions
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(); |