aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/Lex/TokenLexer.cpp4
-rw-r--r--test/Preprocessor/assembler-with-cpp.c11
2 files changed, 14 insertions, 1 deletions
diff --git a/lib/Lex/TokenLexer.cpp b/lib/Lex/TokenLexer.cpp
index 1935914e0e..ec48690b35 100644
--- a/lib/Lex/TokenLexer.cpp
+++ b/lib/Lex/TokenLexer.cpp
@@ -448,7 +448,9 @@ bool TokenLexer::PasteTokens(Token &Tok) {
if (!PP.getLangOptions().AsmPreprocessor)
PP.Diag(PasteOpLoc, diag::err_pp_bad_paste)
<< std::string(Buffer.begin(), Buffer.end()-1);
- return false;
+
+ // Do not consume the RHS.
+ --CurToken;
}
// Turn ## into 'unknown' to avoid # ## # from looking like a paste
diff --git a/test/Preprocessor/assembler-with-cpp.c b/test/Preprocessor/assembler-with-cpp.c
index 2f520ecf07..ecb77e5f96 100644
--- a/test/Preprocessor/assembler-with-cpp.c
+++ b/test/Preprocessor/assembler-with-cpp.c
@@ -33,4 +33,15 @@
// RUN: grep "4: ''" %t &&
4: ''
+
+// Portions of invalid pasting should still expand as macros.
+// rdar://6709206
+// RUN: grep "5: expanded (" %t &&
+#define M4 expanded
+#define M5() M4 ## (
+
+5: M5()
+
+
+
// RUN: true