Debian Codegraph @

gcc/testsuite/g++.dg/cpp0x/pr61038.C

raw
1 // PR c++/61038
2 // { dg-do compile { target c++11 } }
3 // { dg-skip-if "requires hosted libstdc++ for cstring" { ! hostedlib } }
4
5 #include <cstring>
6 #include <cstdlib>
7
8 void
9 operator ""_s(const char *, size_t)
10 { }
11
12 void
13 operator ""_t(const char)
14 { }
15
16 #define QUOTE(s) #s
17 #define QQUOTE(s) QUOTE(s)
18
19 int
20 main()
21 {
22 const char *s = QQUOTE(QUOTE("hello"_s));
23 const char *t = QUOTE("\"hello\"_s");
24 if (strcmp(s, t) != 0)
25 abort();
26
27 const char *c = QQUOTE(QUOTE('"'_t));
28 const char *d = QUOTE("'\"'_t");
29 if (strcmp(c, d) != 0)
30 abort();
31
32 const char *e = QQUOTE(QUOTE('\''_t));
33 const char *f = QUOTE("'\\''_t");
34 if (strcmp(e, f) != 0)
35 abort();
36
37 const char *g = QQUOTE(QUOTE('\\'_t));
38 const char *h = QUOTE("'\\\\'_t");
39 if (strcmp(g, h) != 0)
40 abort();
41 }