aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/g++.old-deja/g++.law/init1.C
blob: bdcc49434a4e647683982e5277a9cbebdc03fdcc (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
25
26
// { dg-do assemble  }
// { dg-prune-output "non-static data member initializers" }
// GROUPS passed initialization
class foo {
public:
  int data;
  foo(int dat) { data = dat; }
};

class bar {
public:
  foo f[3] = { 1, 2, 3 };   // works: f[0] = 1, f[1] = 2, f[2] = 3 // { dg-error "" "" { target { ! c++11 } } } ANSI C++ forbids initialization of member f;
};

class bar2 {
public:
      foo f[3] = { foo(1), foo(2), foo(3) }; // { dg-error "" "" { target { ! c++11 } } } ANSI C++ forbids initialization of member f;
  // does not compile -- error: field initializer is not constant
};

int main(void)
{
  foo f[3] = { foo(1), foo(2), foo(3) };
  // standard C++ ... and it works too! :)
  return 0;
}