]> gcc.gnu.org Git - gcc.git/blame - gcc/testsuite/g++.dg/cpp0x/constexpr-data2.C
re PR c++/47504 ([C++0x] some constexpr calculations erroneously overflow when using...
[gcc.git] / gcc / testsuite / g++.dg / cpp0x / constexpr-data2.C
CommitLineData
4790fd98 1// { dg-do compile }
fa2200cb
JM
2// { dg-options "-std=gnu++0x" }
3
4template<typename _Tp, _Tp v>
5 struct A3
6 {
7 typedef _Tp value_type;
8 typedef A3<value_type,v> type;
9
10 static constexpr value_type value = v;
11
12 constexpr operator value_type() { return value; }
13 };
14
15// Partial specialization.
16template<typename _Tp, _Tp v>
17 struct A3<_Tp*, v>
18 {
19 typedef _Tp* value_type;
20 typedef A3<value_type,v> type;
21
22 static constexpr value_type value = v;
23
24 constexpr operator value_type() { return value; }
25 };
26
27// Explicit specialization.
28template<>
29 struct A3<unsigned short, 0>
30 {
31 typedef unsigned short value_type;
32 typedef A3<value_type, 0> type;
33
34 static constexpr value_type value = 0;
35
36 constexpr operator value_type() { return value; }
37 };
38
39// Explicitly instantiate.
40template struct A3<int, 415>;
41
42// Extern explicitly instantiate.
43extern template struct A3<int, 510>;
44
45// Use.
46A3<int, 1111> a31;
fa2200cb 47A3<char, 9999> a32; // { dg-warning "overflow" }
This page took 0.295599 seconds and 5 git commands to generate.