OSDN Git Service

2012-12-15 Richard Guenther <rguenther@suse.de>
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / g++.dg / cpp0x / constexpr-data1.C
1 // { dg-do compile }
2 // { dg-options "-std=gnu++0x" }
3
4 // From N2235
5
6 // 1
7 struct A2
8 {
9   static const int eights = 888;
10   static constexpr int nines = 999;
11 };
12
13 A2 a;
14
15 // 2
16 struct pixel
17 {
18   int x, y;
19 };
20 constexpr pixel ur = { 1294, 1024 }; // OK
21
22 // p4
23 struct Length
24 {
25    explicit constexpr Length(int i = 0) : val(i) { }
26 private:
27    int val;
28 };
29
30 constexpr int myabs(int x)
31 { return x < 0 ? -x : x; }    // OK
32
33 Length l(myabs(-97)); // OK
34
35 // p6
36 class debug_flag
37 {
38 public:
39    explicit debug_flag(bool);
40    constexpr bool is_on(); // { dg-error "enclosing class .* not a literal type" }
41 private:
42    bool flag;
43 };