Skip to content
Snippets Groups Projects
Commit 2a1b1c68 authored by Richard Smith's avatar Richard Smith
Browse files

More tests for r152012.

llvm-svn: 152013
parent e18f0faf
No related branches found
No related tags found
No related merge requests found
// 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}}
}
// 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}}
// 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}}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment