* decl.c (make_typename_type): s/parameters/arguments/.
[official-gcc.git] / gcc / testsuite / g++.dg / cpp0x / constexpr-fold1.C
blob414a0dacf995132620b915129d6dfa5080c72074
1 // PR c++/65642
2 // { dg-do compile { target c++11 } }
4 // Check we're able to evaluate these.
6 #define SA(X) static_assert((X),#X)
8 constexpr char s[] = "abc";
9 constexpr int t[] = { 'a', 'b', 'c', '\0' };
11 constexpr char
12 fn1 (const char *p)
14   return *(p + 1);
17 constexpr char
18 fn2 (const char *p)
20   return p[1];
23 constexpr int
24 fn3 (const int *p)
26   return *(p + 1);
29 constexpr int
30 fn4 (const int *p)
32   return p[1];
35 constexpr auto c1 = fn1 (&s[0]);
36 constexpr auto c2 = fn1 (&s[1]);
37 constexpr auto c3 = fn1 (&s[2]);
39 SA (c1 == 'b');
40 SA (c2 == 'c');
41 SA (c3 == '\0');
43 constexpr auto d1 = fn2 (&s[0]);
44 constexpr auto d2 = fn2 (&s[1]);
45 constexpr auto d3 = fn2 (&s[2]);
47 SA (d1 == 'b');
48 SA (d2 == 'c');
49 SA (d3 == '\0');
51 constexpr auto e1 = fn3 (&t[0]);
52 constexpr auto e2 = fn3 (&t[1]);
53 constexpr auto e3 = fn3 (&t[2]);
55 SA (e1 == 'b');
56 SA (e2 == 'c');
57 SA (e3 == '\0');
59 constexpr auto f1 = fn4 (&t[0]);
60 constexpr auto f2 = fn4 (&t[1]);
61 constexpr auto f3 = fn4 (&t[2]);
63 SA (f1 == 'b');
64 SA (f2 == 'c');
65 SA (f3 == '\0');