From: Eli Friedman Date: Wed, 27 May 2009 22:00:37 +0000 (+0000) Subject: Make the bad paste diagnostic print the entire pasted token. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=cfcceab862141b7cc3df42ced5f421d76e536a36;p=clang Make the bad paste diagnostic print the entire pasted token. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72497 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Lex/TokenLexer.cpp b/lib/Lex/TokenLexer.cpp index 5675f3f7c0..318c57cc5f 100644 --- a/lib/Lex/TokenLexer.cpp +++ b/lib/Lex/TokenLexer.cpp @@ -473,7 +473,7 @@ 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) - << std::string(Buffer.begin(), Buffer.end()-1); + << std::string(Buffer.begin(), Buffer.end()); // Do not consume the RHS. --CurToken; diff --git a/test/Preprocessor/macro_paste_bad.c b/test/Preprocessor/macro_paste_bad.c index b43d70b0c4..c3b6179021 100644 --- a/test/Preprocessor/macro_paste_bad.c +++ b/test/Preprocessor/macro_paste_bad.c @@ -1,7 +1,9 @@ // RUN: clang-cc -Eonly -verify -pedantic %s // pasting ""x"" and ""+"" does not give a valid preprocessing token -#define XYZ x ## + // expected-error {{pasting formed 'x', an invalid preprocessing token}} +#define XYZ x ## + // expected-error {{pasting formed 'x+', an invalid preprocessing token}} XYZ +#define XXYZ . ## test // expected-error {{pasting formed '.test', an invalid preprocessing token}} +XXYZ // GCC PR 20077