When a bad UTF-8 encoding or bogus escape sequence is encountered in a
string literal, produce a diagnostic pointing at the erroneous character
range, not at the start of the literal.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@163459 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/test/Lexer/string-literal-errors.cpp b/test/Lexer/string-literal-errors.cpp
new file mode 100644
index 0000000..be574c2
--- /dev/null
+++ b/test/Lexer/string-literal-errors.cpp
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -fsyntax-only %s 2>&1 | FileCheck -strict-whitespace %s
+
+void foo() {
+  (void)"\q \u123z \x \U \U123 \U12345 \u123 \xyzzy \777 \U"
+  // CHECK: {{^  \(void\)"\\q \\u123z \\x \\U \\U123 \\U12345 \\u123 \\xyzzy \\777 \\U"$}}
+  //
+  //              (void)"\q \u123z \x \U \U123 \U12345 \u123 \xyzzy \777 \U"
+  // CHECK: {{^         \^~$}}
+  // CHECK: {{^            \^~~~~$}}
+  // CHECK: {{^                   \^~$}}
+  // CHECK: {{^                      \^~$}}
+  // CHECK: {{^                         \^~~~~$}}
+  // CHECK: {{^                               \^~~~~~~$}}
+  // CHECK: {{^                                       \^~~~~$}}
+  // CHECK: {{^                                             \^~$}}
+  // CHECK: {{^                                                    \^~~~$}}
+  // CHECK: {{^                                                         \^~$}}
+
+  "123 \x \z";
+  // CHECK: {{^  "123 \\x \\z";$}}
+  //
+  //              "123 \x \z";
+  // CHECK: {{^       \^~$}}
+  // CHECK: {{^          \^~$}}
+}