aboutsummaryrefslogtreecommitdiff
path: root/test/Lexer/string-literal-errors.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2012-09-08 07:16:20 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2012-09-08 07:16:20 +0000
commite5f0588840b20897631cc8110344fd2745ef4caa (patch)
tree8fb7656a4564a1c23cb52532ca9622efe9f9ba67 /test/Lexer/string-literal-errors.cpp
parent49f9434a4a69d56779aa37feb2d85e06e7289fce (diff)
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
Diffstat (limited to 'test/Lexer/string-literal-errors.cpp')
-rw-r--r--test/Lexer/string-literal-errors.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/test/Lexer/string-literal-errors.cpp b/test/Lexer/string-literal-errors.cpp
new file mode 100644
index 0000000000..be574c2a55
--- /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: {{^ \^~$}}
+}