Merge from mainline (165734:167278).
[official-gcc/graphite-test-results.git] / gcc / testsuite / g++.dg / cpp0x / constexpr-data2.C
blob4d4ce780f3675ce7498062f9846f50f299b7d968
1 // { dg-do "compile" }
2 // { dg-options "-std=gnu++0x" }
4 template<typename _Tp, _Tp v>
5   struct A3
6   {
7     typedef _Tp value_type;
8     typedef A3<value_type,v> type;
10     static constexpr value_type value = v;
12     constexpr operator value_type() { return value; }
13   };
15 // Partial specialization.
16 template<typename _Tp, _Tp v>
17   struct A3<_Tp*, v>
18   {
19     typedef _Tp* value_type;
20     typedef A3<value_type,v> type;
22     static constexpr value_type value = v;
24     constexpr operator value_type() { return value; }
25   };
27 // Explicit specialization.
28 template<>
29   struct A3<unsigned short, 0>
30   {
31     typedef unsigned short value_type;
32     typedef A3<value_type, 0> type;
34     static constexpr value_type value = 0;
36     constexpr operator value_type() { return value; }
37   };
39 // Explicitly instantiate.
40 template struct A3<int, 415>;
42 // Extern explicitly instantiate.
43 extern template struct A3<int, 510>;
45 // Use.
46 A3<int, 1111> a31;
47 // FIXME should this be an error?
48 A3<char, 9999> a32;             // { dg-warning "overflow" }