[cfe-commits] r152013 - in /cfe/trunk/test/CXX/lex/lex.literal/lex.ext: p10.cpp p8.cpp p9.cpp

Richard Smith richard-llvm at metafoo.co.uk
Sun Mar 4 20:06:25 PST 2012


Author: rsmith
Date: Sun Mar  4 22:06:25 2012
New Revision: 152013

URL: http://llvm.org/viewvc/llvm-project?rev=152013&view=rev
Log:
More tests for r152012.

Added:
    cfe/trunk/test/CXX/lex/lex.literal/lex.ext/p10.cpp
    cfe/trunk/test/CXX/lex/lex.literal/lex.ext/p8.cpp
    cfe/trunk/test/CXX/lex/lex.literal/lex.ext/p9.cpp

Added: cfe/trunk/test/CXX/lex/lex.literal/lex.ext/p10.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/lex/lex.literal/lex.ext/p10.cpp?rev=152013&view=auto
==============================================================================
--- cfe/trunk/test/CXX/lex/lex.literal/lex.ext/p10.cpp (added)
+++ cfe/trunk/test/CXX/lex/lex.literal/lex.ext/p10.cpp Sun Mar  4 22:06:25 2012
@@ -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<typename T>
+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}}
+}

Added: cfe/trunk/test/CXX/lex/lex.literal/lex.ext/p8.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/lex/lex.literal/lex.ext/p8.cpp?rev=152013&view=auto
==============================================================================
--- cfe/trunk/test/CXX/lex/lex.literal/lex.ext/p8.cpp (added)
+++ cfe/trunk/test/CXX/lex/lex.literal/lex.ext/p8.cpp Sun Mar  4 22:06:25 2012
@@ -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}}

Added: cfe/trunk/test/CXX/lex/lex.literal/lex.ext/p9.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/lex/lex.literal/lex.ext/p9.cpp?rev=152013&view=auto
==============================================================================
--- cfe/trunk/test/CXX/lex/lex.literal/lex.ext/p9.cpp (added)
+++ cfe/trunk/test/CXX/lex/lex.literal/lex.ext/p9.cpp Sun Mar  4 22:06:25 2012
@@ -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}}
+}
+
+}





More information about the cfe-commits mailing list