diff options
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/Lex/PPMacroExpansion.cpp | 3 | ||||
-rw-r--r-- | clang/lib/Lex/Pragma.cpp | 7 | ||||
-rw-r--r-- | clang/lib/Lex/Preprocessor.cpp | 7 | ||||
-rw-r--r-- | clang/lib/Parse/ParseDecl.cpp | 3 | ||||
-rw-r--r-- | clang/lib/Parse/ParseDeclCXX.cpp | 3 | ||||
-rw-r--r-- | clang/lib/Parse/Parser.cpp | 3 |
6 files changed, 18 insertions, 8 deletions
diff --git a/clang/lib/Lex/PPMacroExpansion.cpp b/clang/lib/Lex/PPMacroExpansion.cpp index 9f962b027fc..6baa593e788 100644 --- a/clang/lib/Lex/PPMacroExpansion.cpp +++ b/clang/lib/Lex/PPMacroExpansion.cpp @@ -1290,7 +1290,8 @@ void Preprocessor::ExpandBuiltinMacro(Token &Tok) { LexUnexpandedToken(Tok); std::string WarningName; SourceLocation StrStartLoc = Tok.getLocation(); - if (!FinishLexStringLiteral(Tok, WarningName, /*MacroExpansion=*/false)) { + if (!FinishLexStringLiteral(Tok, WarningName, "'__has_warning'", + /*MacroExpansion=*/false)) { // Eat tokens until ')'. while (Tok.isNot(tok::r_paren) && Tok.isNot(tok::eod) diff --git a/clang/lib/Lex/Pragma.cpp b/clang/lib/Lex/Pragma.cpp index 0c1c9dbee51..783588e1f7f 100644 --- a/clang/lib/Lex/Pragma.cpp +++ b/clang/lib/Lex/Pragma.cpp @@ -503,6 +503,7 @@ void Preprocessor::HandlePragmaComment(Token &Tok) { Lex(Tok); std::string ArgumentString; if (Tok.is(tok::comma) && !LexStringLiteral(Tok, ArgumentString, + "pragma comment", /*MacroExpansion=*/true)) return; @@ -559,7 +560,8 @@ void Preprocessor::HandlePragmaMessage(Token &Tok) { } std::string MessageString; - if (!FinishLexStringLiteral(Tok, MessageString, /*MacroExpansion=*/true)) + if (!FinishLexStringLiteral(Tok, MessageString, "pragma message", + /*MacroExpansion=*/true)) return; if (ExpectClosingParen) { @@ -1039,7 +1041,8 @@ public: SourceLocation StringLoc = Tok.getLocation(); std::string WarningName; - if (!PP.FinishLexStringLiteral(Tok, WarningName, /*MacroExpansion=*/false)) + if (!PP.FinishLexStringLiteral(Tok, WarningName, "pragma diagnostic", + /*MacroExpansion=*/false)) return; if (Tok.isNot(tok::eod)) { diff --git a/clang/lib/Lex/Preprocessor.cpp b/clang/lib/Lex/Preprocessor.cpp index 52d6bb6a83b..94885841057 100644 --- a/clang/lib/Lex/Preprocessor.cpp +++ b/clang/lib/Lex/Preprocessor.cpp @@ -691,10 +691,12 @@ void Preprocessor::LexAfterModuleImport(Token &Result) { } bool Preprocessor::FinishLexStringLiteral(Token &Result, std::string &String, + const char *DiagnosticTag, bool AllowMacroExpansion) { // We need at least one string literal. if (Result.isNot(tok::string_literal)) { - Diag(Result, diag::err_expected_string_literal); + Diag(Result, diag::err_expected_string_literal) + << /*Source='in...'*/0 << DiagnosticTag; return false; } @@ -720,7 +722,8 @@ bool Preprocessor::FinishLexStringLiteral(Token &Result, std::string &String, return false; if (Literal.Pascal) { - Diag(StrToks[0].getLocation(), diag::err_expected_string_literal); + Diag(StrToks[0].getLocation(), diag::err_expected_string_literal) + << /*Source='in...'*/0 << DiagnosticTag; return false; } diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp index d898447ab5c..7c5b1531407 100644 --- a/clang/lib/Parse/ParseDecl.cpp +++ b/clang/lib/Parse/ParseDecl.cpp @@ -735,7 +735,8 @@ void Parser::ParseAvailabilityAttribute(IdentifierInfo &Availability, ConsumeToken(); if (Keyword == Ident_message) { if (!isTokenStringLiteral()) { - Diag(Tok, diag::err_expected_string_literal); + Diag(Tok, diag::err_expected_string_literal) + << /*Source='availability attribute'*/2; SkipUntil(tok::r_paren); return; } diff --git a/clang/lib/Parse/ParseDeclCXX.cpp b/clang/lib/Parse/ParseDeclCXX.cpp index 0d785af3efd..b8ebd9b6a7e 100644 --- a/clang/lib/Parse/ParseDeclCXX.cpp +++ b/clang/lib/Parse/ParseDeclCXX.cpp @@ -637,7 +637,8 @@ Decl *Parser::ParseStaticAssertDeclaration(SourceLocation &DeclEnd){ return 0; if (!isTokenStringLiteral()) { - Diag(Tok, diag::err_expected_string_literal); + Diag(Tok, diag::err_expected_string_literal) + << /*Source='static_assert'*/1; SkipMalformedDecl(); return 0; } diff --git a/clang/lib/Parse/Parser.cpp b/clang/lib/Parse/Parser.cpp index f4cdd619cef..dfffe8150f2 100644 --- a/clang/lib/Parse/Parser.cpp +++ b/clang/lib/Parse/Parser.cpp @@ -1263,7 +1263,8 @@ Parser::ExprResult Parser::ParseAsmStringLiteral() { return ExprError(); } default: - Diag(Tok, diag::err_expected_string_literal); + Diag(Tok, diag::err_expected_string_literal) + << /*Source='in...'*/0 << "'asm'"; return ExprError(); } |