From: Richard Smith Date: Mon, 5 Mar 2012 04:06:25 +0000 (+0000) Subject: More tests for r152012. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d4f9f9dfdfa36f2e45c2ad0f4be304737d0f7f64;p=clang More tests for r152012. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152013 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/test/CXX/lex/lex.literal/lex.ext/p10.cpp b/test/CXX/lex/lex.literal/lex.ext/p10.cpp new file mode 100644 index 0000000000..7fbd9f8e4b --- /dev/null +++ b/test/CXX/lex/lex.literal/lex.ext/p10.cpp @@ -0,0 +1,15 @@ +// RUN: %clang_cc1 -std=c++11 -verify %s + +using size_t = decltype(sizeof(int)); +void operator "" wibble(const char *); // expected-warning {{preempted}} +void operator "" wibble(const char *, size_t); // expected-warning {{preempted}} + +template +void f() { + // A program containing a reserved ud-suffix is ill-formed. + // FIXME: Reject these for the right reason. + 123wibble; // expected-error {{suffix 'wibble'}} + 123.0wibble; // expected-error {{suffix 'wibble'}} + ""wibble; // expected-warning {{unused}} + R"x("hello")x"wibble; // expected-warning {{unused}} +} diff --git a/test/CXX/lex/lex.literal/lex.ext/p8.cpp b/test/CXX/lex/lex.literal/lex.ext/p8.cpp new file mode 100644 index 0000000000..2833769d73 --- /dev/null +++ b/test/CXX/lex/lex.literal/lex.ext/p8.cpp @@ -0,0 +1,19 @@ +// RUN: %clang_cc1 -std=c++11 -verify %s + +constexpr const char *operator "" _id(const char *p) { return p; } +constexpr const char *s = "foo"_id "bar" "baz"_id "quux"; + +constexpr bool streq(const char *p, const char *q) { + return *p == *q && (!*p || streq(p+1, q+1)); +} +static_assert(streq(s, "foobarbazquux"), ""); + +constexpr const char *operator "" _trim(const char *p) { + return *p == ' ' ? operator "" _trim(p + 1) : p; +} +constexpr const char *t = " " " "_trim " foo"; +// FIXME: once we implement the semantics of user-defined literals, this should +// pass. +static_assert(streq(s, "foo"), ""); // expected-error {{static_assert}} + +const char *u = "foo" "bar"_id "baz" "quux"_di "corge"; // expected-error {{differing user-defined suffixes ('_id' and '_di') in string literal concatenation}} diff --git a/test/CXX/lex/lex.literal/lex.ext/p9.cpp b/test/CXX/lex/lex.literal/lex.ext/p9.cpp new file mode 100644 index 0000000000..e3de34df9e --- /dev/null +++ b/test/CXX/lex/lex.literal/lex.ext/p9.cpp @@ -0,0 +1,15 @@ +// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s + +using size_t = decltype(sizeof(int)); +void operator "" _x(const wchar_t *, size_t); + +namespace std_example { + +int main() { + // FIXME: once we implement the semantics of literal operators, this warning + // should vanish. + L"A" "B" "C"_x; // expected-warning {{expression result unused}} + "P"_x "Q" "R"_y; // expected-error {{differing user-defined suffixes ('_x' and '_y') in string literal concatenation}} +} + +}