summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2012-03-05 04:06:25 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2012-03-05 04:06:25 +0000
commit2a1b1c68f350ea98b2e3d01083ce174d3e8ab4c9 (patch)
tree49cd5e682d92d5b842a15d84ed8354dfe156d950 /clang
parente18f0faff242cd08b1b90930731dd9a8ee066d4f (diff)
downloadbcm5719-llvm-2a1b1c68f350ea98b2e3d01083ce174d3e8ab4c9.tar.gz
bcm5719-llvm-2a1b1c68f350ea98b2e3d01083ce174d3e8ab4c9.zip
More tests for r152012.
llvm-svn: 152013
Diffstat (limited to 'clang')
-rw-r--r--clang/test/CXX/lex/lex.literal/lex.ext/p10.cpp15
-rw-r--r--clang/test/CXX/lex/lex.literal/lex.ext/p8.cpp19
-rw-r--r--clang/test/CXX/lex/lex.literal/lex.ext/p9.cpp15
3 files changed, 49 insertions, 0 deletions
diff --git a/clang/test/CXX/lex/lex.literal/lex.ext/p10.cpp b/clang/test/CXX/lex/lex.literal/lex.ext/p10.cpp
new file mode 100644
index 00000000000..7fbd9f8e4be
--- /dev/null
+++ b/clang/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<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}}
+}
diff --git a/clang/test/CXX/lex/lex.literal/lex.ext/p8.cpp b/clang/test/CXX/lex/lex.literal/lex.ext/p8.cpp
new file mode 100644
index 00000000000..2833769d73a
--- /dev/null
+++ b/clang/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/clang/test/CXX/lex/lex.literal/lex.ext/p9.cpp b/clang/test/CXX/lex/lex.literal/lex.ext/p9.cpp
new file mode 100644
index 00000000000..e3de34df9e9
--- /dev/null
+++ b/clang/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}}
+}
+
+}
OpenPOWER on IntegriCloud