diff options
| author | Richard Smith <richard-llvm@metafoo.co.uk> | 2012-03-08 23:06:02 +0000 |
|---|---|---|
| committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2012-03-08 23:06:02 +0000 |
| commit | 7d182a7909881f5555db0f519843681a7252f79d (patch) | |
| tree | 852efa4a708a02a27e955c24f47b933075495f99 /clang/test | |
| parent | f7fc1d48595d946929908c2fb3658450b2a2cebe (diff) | |
| download | bcm5719-llvm-7d182a7909881f5555db0f519843681a7252f79d.tar.gz bcm5719-llvm-7d182a7909881f5555db0f519843681a7252f79d.zip | |
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.
llvm-svn: 152348
Diffstat (limited to 'clang/test')
| -rw-r--r-- | clang/test/FixIt/fixit-cxx0x.cpp | 12 | ||||
| -rw-r--r-- | clang/test/Parser/cxx11-user-defined-literals.cpp | 18 |
2 files changed, 30 insertions, 0 deletions
diff --git a/clang/test/FixIt/fixit-cxx0x.cpp b/clang/test/FixIt/fixit-cxx0x.cpp index 2bf9b20326e..dcd9f74a108 100644 --- a/clang/test/FixIt/fixit-cxx0x.cpp +++ b/clang/test/FixIt/fixit-cxx0x.cpp @@ -65,3 +65,15 @@ void S2::f(int i) { const char *p = "foo"bar; // expected-error {{requires a space between}} #define ord - '0' int k = '4'ord; // expected-error {{requires a space between}} + +void operator""_x(char); // expected-error {{requires a space}} +void operator"x" _y(char); // expected-error {{must be '""'}} +void operator L"" _z(char); // expected-error {{encoding prefix}} +void operator "x" "y" U"z" ""_whoops "z" "y"(char); // expected-error {{must be '""'}} + +void f() { + 'a'_x; + 'b'_y; + 'c'_z; + 'd'_whoops; +} diff --git a/clang/test/Parser/cxx11-user-defined-literals.cpp b/clang/test/Parser/cxx11-user-defined-literals.cpp index b34680d080f..7a4df2b4596 100644 --- a/clang/test/Parser/cxx11-user-defined-literals.cpp +++ b/clang/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 '""'}} |

