summaryrefslogtreecommitdiffstats
path: root/clang/lib/Lex/TokenLexer.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-05-28 05:39:39 +0000
committerChris Lattner <sabre@nondot.org>2009-05-28 05:39:39 +0000
commit7f4153dbee0c01ca839f04fd10eb939785914d8e (patch)
treed705c3462d0672e44c679033fb87ae81b86320fc /clang/lib/Lex/TokenLexer.cpp
parent1f906448bc2103be26b216a38e5c7121f4585230 (diff)
downloadbcm5719-llvm-7f4153dbee0c01ca839f04fd10eb939785914d8e.tar.gz
bcm5719-llvm-7f4153dbee0c01ca839f04fd10eb939785914d8e.zip
fix the "pasting formed 'a]', an invalid preprocessing token"
diagnostic to include the full instantiation location for the invalid paste. For: #define foo(a, b) a ## b #define bar(x) foo(x, ]) bar(a) bar(zdy) Instead of: t.c:3:22: error: pasting formed 'a]', an invalid preprocessing token #define foo(a, b) a ## b ^ t.c:3:22: error: pasting formed 'zdy]', an invalid preprocessing token we now produce: t.c:7:1: error: pasting formed 'a]', an invalid preprocessing token bar(a) ^ t.c:4:16: note: instantiated from: #define bar(x) foo(x, ]) ^ t.c:3:22: note: instantiated from: #define foo(a, b) a ## b ^ t.c:8:1: error: pasting formed 'zdy]', an invalid preprocessing token bar(zdy) ^ t.c:4:16: note: instantiated from: #define bar(x) foo(x, ]) ^ t.c:3:22: note: instantiated from: #define foo(a, b) a ## b ^ llvm-svn: 72519
Diffstat (limited to 'clang/lib/Lex/TokenLexer.cpp')
-rw-r--r--clang/lib/Lex/TokenLexer.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/clang/lib/Lex/TokenLexer.cpp b/clang/lib/Lex/TokenLexer.cpp
index 318c57cc5f2..f9f93867c85 100644
--- a/clang/lib/Lex/TokenLexer.cpp
+++ b/clang/lib/Lex/TokenLexer.cpp
@@ -471,9 +471,16 @@ bool TokenLexer::PasteTokens(Token &Tok) {
}
// Do not emit the warning when preprocessing assembler code.
- if (!PP.getLangOptions().AsmPreprocessor)
- PP.Diag(PasteOpLoc, diag::err_pp_bad_paste)
+ if (!PP.getLangOptions().AsmPreprocessor) {
+ // Explicitly convert the token location to have proper instantiation
+ // information so that the user knows where it came from.
+ SourceManager &SM = PP.getSourceManager();
+ SourceLocation Loc =
+ SM.createInstantiationLoc(PasteOpLoc, InstantiateLocStart,
+ InstantiateLocEnd, 2);
+ PP.Diag(Loc, diag::err_pp_bad_paste)
<< std::string(Buffer.begin(), Buffer.end());
+ }
// Do not consume the RHS.
--CurToken;
OpenPOWER on IntegriCloud