| 1 |
// { dg-do run { target c++11 } } |
| 2 |
// { dg-skip-if "requires hosted libstdc++ for cassert" { ! hostedlib } } |
| 3 |
|
| 4 |
// Make sure embedded quotes are not a problem for string and char literals. |
| 5 |
|
| 6 |
#include <cstdint> |
| 7 |
#include <cassert> |
| 8 |
|
| 9 |
int operator ""_embedchar(char) |
| 10 |
{ return 41; } |
| 11 |
|
| 12 |
int operator ""_embedstr(const char*, std::size_t len) |
| 13 |
{ return 42 + len; } |
| 14 |
|
| 15 |
void |
| 16 |
test() |
| 17 |
{ |
| 18 |
int i = '\''_embedchar; |
| 19 |
|
| 20 |
int j = "\""_embedstr; |
| 21 |
assert(j == 43); |
| 22 |
|
| 23 |
int k = "foo\""_embedstr; |
| 24 |
assert(k == 46); |
| 25 |
|
| 26 |
int l = "\"bar"_embedstr; |
| 27 |
assert(l == 46); |
| 28 |
} |
| 29 |
|
| 30 |
int |
| 31 |
main() |
| 32 |
{ |
| 33 |
test(); |
| 34 |
} |