// RUN: %clang_cc1 -std=c++11 -verify %s -fms-extensions -triple x86_64-apple-darwin9.0.0
// A ud-suffix cannot be used on string literals in a whole bunch of contexts:
# 1 "foo"_bar 1 // expected-error {{user-defined suffix cannot be used here}}
#ident "foo"_bar // expected-error {{user-defined suffix cannot be used here}}
_Pragma // expected-error {{user-defined suffix cannot be used here}}
_Pragma // expected-error {{user-defined suffix cannot be used here}}
extern "C++"_x // expected-error {{user-defined suffix cannot be used here}}
int
static_assert; // expected-error {{user-defined suffix cannot be used here}}
int ; // expected-error {{user-defined suffix cannot be used here}}
// A ud-suffix cannot be used on character literals in preprocessor constant
// expressions:
// A ud-suffix cannot be used on integer literals in preprocessor constant
// expressions:
// But they can appear in expressions.
constexpr char
constexpr wchar_t
constexpr char16_t
constexpr char32_t
using size_t = decltype;
constexpr const char
constexpr const wchar_t
constexpr const char16_t
constexpr const char32_t
constexpr unsigned long long
constexpr long double
;
S<"a"_id> sa;
S<L"b"_id> sb;
S<u8"c"_id> sc;
S<u"d"_id> sd;
S<U"e"_id> se;
S<'w'_id> sw;
S<L'x'_id> sx;
S<u'y'_id> sy;
S<U'z'_id> sz;
S<100_id> sn;
S<1.3_id> sf;
void
// Test source location for suffix is known
const char *p =
"foo\nbar" R"x(
erk
flux
)x" "eep\x1f"\
_no_such_suffix // expected-error {{'operator""_no_such_suffix'}}
"and a bit more"
"and another suffix"_no_such_suffix;
char c =
'\x14'\
_no_such_suffix; // expected-error {{'operator""_no_such_suffix'}}
int &r =
1234567\
_no_such_suffix; // expected-error {{'operator""_no_such_suffix'}}
int k =
1234567.89\
_no_such_suffix; // expected-error {{'operator""_no_such_suffix'}}
// Make sure we handle more interesting ways of writing a string literal which
// is "" in translation phase 7.
void operator "\
" ; // ok
void operator R"xyzzy()xyzzy" ; // ok
void operator"" "" R"()" "" ; // ok
void ; // ok
// Ensure we diagnose the bad cases.
void operator "\0" ; // expected-error {{must be '""'}}
void operator L"" ; // expected-error {{cannot have an encoding prefix}}
void operator "" ""
U"" // expected-error {{cannot have an encoding prefix}}
"" ;
void operator "" u8"" "\u0123" "hello"_all_of_the_things ""; // expected-error {{must be '""'}}
// Make sure we treat UCNs and UTF-8 as equivalent.
int // expected-note {{previous}}
int hundred_µs = 50_µs + 50_\u00b5s;
int operator""_\ // expected-error {{redefinition of 'operator""_µs'}}
int operator""_\ // expected-note {{previous}}
int hundred_Å = 50.0_Å + 50._\U0000212B;
int // expected-error {{redefinition of 'operator""_Å'}}
int // expected-note {{previous}}
int 𐀀 = '4'_𐀀 + '2'_\U00010000;
int operator""_\ // expected-error {{redefinition of 'operator""_𐀀'}}
// These all declare the same function.
int operator""_℮""_\u212e""_\U0000212e"";
int operator""_\u212e""_\U0000212e""_℮"";
int operator""_\U0000212e""_℮""_\u212e"";
int operator""_\u;
int operator""_\N;
int mix_ucn_utf8 = ""_℮""_\u212e""_\U0000212e"";
void operator""_℮"" // expected-error {{differing user-defined suffixes ('_℮' and '_ℯ') in string literal concatenation}}
void operator""_℮""_\ // expected-error {{differing user-defined suffixes ('_℮' and '_ℯ') in string literal concatenation}}
void operator""_\u212e"" // expected-error {{differing user-defined suffixes ('_℮' and '_ℯ') in string literal concatenation}}
void operator""_\u212e""_\ // expected-error {{differing user-defined suffixes ('_℮' and '_ℯ') in string literal concatenation}}
void operator""_℮""_℮ // expected-note {{previous}}
void operator""_\u212e""_\ // expected-error {{redefinition}}
constexpr int operator""_¢ // expected-error {{character <U+00A2> not allowed in an identifier}}
constexpr int operator""_¢ // expected-error {{character <U+00A2> not allowed in an identifier}}
static_assert; // expected-error 2{{character <U+00A2> not allowed in an identifier}}