aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/Lex/Lexer.cpp7
-rw-r--r--test/Lexer/escape_newline.c3
2 files changed, 10 insertions, 0 deletions
diff --git a/lib/Lex/Lexer.cpp b/lib/Lex/Lexer.cpp
index 25e320df51..acb5b8a797 100644
--- a/lib/Lex/Lexer.cpp
+++ b/lib/Lex/Lexer.cpp
@@ -1171,6 +1171,10 @@ Slash:
// Found backslash<whitespace><newline>. Parse the char after it.
Size += EscapedNewLineSize;
Ptr += EscapedNewLineSize;
+
+ if (Ptr[0] == '\0')
+ return '\\';
+
// Use slow version to accumulate a correct size field.
return getCharAndSizeSlow(Ptr, Size, Tok);
}
@@ -1222,6 +1226,9 @@ Slash:
Size += EscapedNewLineSize;
Ptr += EscapedNewLineSize;
+ if (Ptr[0] == '\0')
+ return '\\';
+
// Use slow version to accumulate a correct size field.
return getCharAndSizeSlowNoWarn(Ptr, Size, Features);
}
diff --git a/test/Lexer/escape_newline.c b/test/Lexer/escape_newline.c
index 43ba41795d..5e3002859c 100644
--- a/test/Lexer/escape_newline.c
+++ b/test/Lexer/escape_newline.c
@@ -1,7 +1,10 @@
// RUN: %clang_cc1 -E -trigraphs %s | grep -- ' ->'
// RUN: %clang_cc1 -E -trigraphs %s 2>&1 | grep 'backslash and newline separated by space'
// RUN: %clang_cc1 -E -trigraphs %s 2>&1 | grep 'trigraph converted'
+// RUN: %clang_cc1 -E -CC -trigraphs %s
// This is an ugly way to spell a -> token.
-??/
>
+
+// \