p8.cpp revision d4f9f9dfdfa36f2e45c2ad0f4be304737d0f7f64
1// RUN: %clang_cc1 -std=c++11 -verify %s 2 3constexpr const char *operator "" _id(const char *p) { return p; } 4constexpr const char *s = "foo"_id "bar" "baz"_id "quux"; 5 6constexpr bool streq(const char *p, const char *q) { 7 return *p == *q && (!*p || streq(p+1, q+1)); 8} 9static_assert(streq(s, "foobarbazquux"), ""); 10 11constexpr const char *operator "" _trim(const char *p) { 12 return *p == ' ' ? operator "" _trim(p + 1) : p; 13} 14constexpr const char *t = " " " "_trim " foo"; 15// FIXME: once we implement the semantics of user-defined literals, this should 16// pass. 17static_assert(streq(s, "foo"), ""); // expected-error {{static_assert}} 18 19const char *u = "foo" "bar"_id "baz" "quux"_di "corge"; // expected-error {{differing user-defined suffixes ('_id' and '_di') in string literal concatenation}} 20