summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/cpp0x/constexpr-static.C
blob: 8ed2b5e82edc7f01d80c72cd46402cface602128 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// Test for constant initialization of non-literal class (e.g. mutex)
// { dg-options "-std=c++0x -save-temps" }
// { dg-do run }

struct A
{
  int i;
  constexpr A(int _i): i(_i) { }
  A(const A&);		       // non-trivial copy ctor makes A non-literal
};

A a(42);	    // constexpr constructor allows constant initialization
A ar[3] = { { 1 }, { 2 }, { 3 } };
// { dg-final { scan-assembler-not "static_initialization" } }
// { dg-final cleanup-saved-temps }

int main()
{
  if (a.i != 42
      || ar[0].i != 1
      || ar[1].i != 2
      || ar[2].i != 3)
    return 1;
}