| 1 |
// { dg-do run { target c++11 } } |
| 2 |
// { dg-additional-options "-Wno-error=normalized -Wno-deprecated-literal-operator" } |
| 3 |
// { dg-require-effective-target ucn } |
| 4 |
// { dg-skip-if "requires hosted libstdc++ for cstring" { ! hostedlib } } |
| 5 |
|
| 6 |
#include <cstring> |
| 7 |
#include <cstddef> |
| 8 |
using namespace std; |
| 9 |
|
| 10 |
constexpr unsigned long long operator ""_π (unsigned long long x) |
| 11 |
{ |
| 12 |
return 3 * x; |
| 13 |
} |
| 14 |
|
| 15 |
/* Historically we didn't parse properly as part of the "" token, so check that |
| 16 |
as well. */ |
| 17 |
constexpr unsigned long long operator ""_Π2 (unsigned long long x) |
| 18 |
{ |
| 19 |
return 4 * x; |
| 20 |
} |
| 21 |
|
| 22 |
char x1[1_π]; |
| 23 |
char x2[2_Π2]; |
| 24 |
|
| 25 |
static_assert (sizeof x1 == 3, "test1"); |
| 26 |
static_assert (sizeof x2 == 8, "test2"); |
| 27 |
|
| 28 |
const char * operator ""_1σ (const char *s, size_t) |
| 29 |
{ |
| 30 |
return s + 1; |
| 31 |
} |
| 32 |
|
| 33 |
const char * operator ""_Σ2 (const char *s, size_t) |
| 34 |
{ |
| 35 |
return s + 2; |
| 36 |
} |
| 37 |
|
| 38 |
const char * operator ""_\U000000e61 (const char *s, size_t) |
| 39 |
{ |
| 40 |
return "ae"; |
| 41 |
} |
| 42 |
|
| 43 |
const char* operator ""_\u01532 (const char *s, size_t) |
| 44 |
{ |
| 45 |
return "oe"; |
| 46 |
} |
| 47 |
|
| 48 |
bool operator ""_\u0BC7\u0BBE (unsigned long long); // { dg-warning "not in NFC" } |
| 49 |
bool operator ""_\u0B47\U00000B3E (unsigned long long); // { dg-warning "not in NFC" } |
| 50 |
|
| 51 |
#define xτy |
| 52 |
const char * str = ""xτy; // { dg-warning "invalid suffix on literal" } |
| 53 |
|
| 54 |
int main() |
| 55 |
{ |
| 56 |
if (3_π != 9) |
| 57 |
__builtin_abort (); |
| 58 |
if (4_Π2 != 16) |
| 59 |
__builtin_abort (); |
| 60 |
if (strcmp ("abc"_1σ, "bc")) |
| 61 |
__builtin_abort (); |
| 62 |
if (strcmp ("abcd"_Σ2, "cd")) |
| 63 |
__builtin_abort (); |
| 64 |
if (strcmp (R"(abcdef)"_1σ, "bcdef")) |
| 65 |
__builtin_abort (); |
| 66 |
if (strcmp (R"(abc |
| 67 |
def)"_1σ, "bc\ndef")) |
| 68 |
__builtin_abort (); |
| 69 |
if (strcmp (R"(abcdef)"_Σ2, "cdef")) |
| 70 |
__builtin_abort (); |
| 71 |
if (strcmp ("xyz"_æ1, "ae")) |
| 72 |
__builtin_abort (); |
| 73 |
if (strcmp ("xyz"_œ2, "oe")) |
| 74 |
__builtin_abort (); |
| 75 |
} |