aboutsummaryrefslogtreecommitdiff
path: root/test/Parser/cxx11-user-defined-literals.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2012-03-08 23:06:02 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2012-03-08 23:06:02 +0000
commit33762775706e81c17ca774102ceda36049ecc593 (patch)
tree6a4c41f4294bf4771264e733d061404ed75e7a8c /test/Parser/cxx11-user-defined-literals.cpp
parent1e5bc4ffb2db5b575fb28d7ebffb6bb36b034162 (diff)
Fix a couple of issues with literal-operator-id parsing, and provide recovery
for a few kinds of error. Specifically: Since we're after translation phase 6, the "" token might be formed by multiple source-level string literals. Checking the token width is not a correct way of detecting empty string literals, due to escaped newlines. Diagnose and recover from a missing space between "" and suffix, and from string literals other than "", which are followed by a suffix. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152348 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Parser/cxx11-user-defined-literals.cpp')
-rw-r--r--test/Parser/cxx11-user-defined-literals.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/test/Parser/cxx11-user-defined-literals.cpp b/test/Parser/cxx11-user-defined-literals.cpp
index b34680d080..7a4df2b459 100644
--- a/test/Parser/cxx11-user-defined-literals.cpp
+++ b/test/Parser/cxx11-user-defined-literals.cpp
@@ -92,3 +92,21 @@ _no_such_suffix; // expected-error {{'_no_such_suffix'}}
int k =
1234567.89\
_no_such_suffix; // expected-error {{'_no_such_suffix'}}
+
+// Make sure we handle more interesting ways of writing a string literal which
+// is "" in translation phase 7.
+void operator "\
+" _foo(unsigned long long); // ok
+
+void operator R"xyzzy()xyzzy" _foo(long double); // ok
+
+void operator"" "" R"()" "" _foo(const char *); // ok
+
+// Ensure we diagnose the bad cases.
+void operator "\0" _non_empty(const char *); // expected-error {{must be '""'}}
+void operator ""_no_space(const char *); // expected-error {{C++11 requires a space}}
+void operator L"" _not_char(const char *); // expected-error {{cannot have an encoding prefix}}
+void operator "" ""
+U"" // expected-error {{cannot have an encoding prefix}}
+"" _also_not_char(const char *);
+void operator "" u8"" "\u0123" "hello"_all_of_the_things ""(const char*); // expected-error {{must be '""'}}