add \n characters to the scratch buffer *before* returned tokens.
This prevents caret diagnostics from the scratch buffer from
including other tokens in the scratch buffer that occurred beforei
them.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66375 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/test/Misc/caret-diags.c b/test/Misc/caret-diags.c
new file mode 100644
index 0000000..e6ec03a
--- /dev/null
+++ b/test/Misc/caret-diags.c
@@ -0,0 +1,12 @@
+// RUN: clang -fsyntax-only %s 2>&1 | not grep keyXXXX
+// This should not show keyXXXX in the caret diag output. This once
+// happened because the two tokens ended up in the scratch buffer and
+// the caret diag from the scratch buffer included the previous token.
+#define M(name) \
+ if (name ## XXXX != name ## _sb);
+
+void foo() {
+ int keyXXXX;
+ M(key);
+}
+