From 4c3ba6c1944e6a4758f1b3a0aec8a7ff4c561051 Mon Sep 17 00:00:00 2001 From: Eli Friedman Date: Sun, 24 May 2009 19:25:46 +0000 Subject: [PATCH] Make sure an invalid concatentaion doesn't insert whitespace before the RHS. Fixes assembler-with-cpp issue reported on cfe-dev. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72370 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Lex/TokenLexer.cpp | 6 +++++- test/Preprocessor/assembler-with-cpp.c | 5 +++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/Lex/TokenLexer.cpp b/lib/Lex/TokenLexer.cpp index f1af42aea5..65d083dffd 100644 --- a/lib/Lex/TokenLexer.cpp +++ b/lib/Lex/TokenLexer.cpp @@ -223,7 +223,11 @@ void TokenLexer::ExpandFunctionArguments() { // If the next token was supposed to get leading whitespace, ensure it has // it now. if (CurTok.hasLeadingSpace() || NextTokGetsSpace) { - ResultToks[ResultToks.size()-NumToks].setFlag(Token::LeadingSpace); + // Exception: the RHS of a paste doesn't get whitespace. This allows + // constructs like conacatenating a period and an identifer to work + // correctly in assembler-with-cpp. + if (!PasteBefore) + ResultToks[ResultToks.size()-NumToks].setFlag(Token::LeadingSpace); NextTokGetsSpace = false; } continue; diff --git a/test/Preprocessor/assembler-with-cpp.c b/test/Preprocessor/assembler-with-cpp.c index 885e67b98c..bb16880578 100644 --- a/test/Preprocessor/assembler-with-cpp.c +++ b/test/Preprocessor/assembler-with-cpp.c @@ -63,4 +63,9 @@ T7(foo) // RUN: grep 'T6 #nostring' %t && // RUN: grep 'T7 "foo"' %t && +// Concatenation with period doesn't leave a space +// RUN: grep '.T8' %t && +#define T8(A,B) A ## B +T8(.,T8) + // RUN: true -- 2.40.0