p8-0x.cpp revision 7a614d8380297fcd2bc23986241905d97222948c
1// RUN: %clang_cc1 -std=c++0x -fsyntax-only -verify %s
2
3int n;
4struct S {
5  int &a; // expected-note 2{{here}}
6  int &b = n;
7
8  S() {} // expected-error {{constructor for 'S' must explicitly initialize the reference member 'a'}}
9  S(int) : a(n) {} // ok
10  S(char) : b(n) {} // expected-error {{constructor for 'S' must explicitly initialize the reference member 'a'}}
11  S(double) : a(n), b(n) {} // ok
12};
13
14union U {
15  int a = 0;
16  char b = 'x';
17
18  // FIXME: these should all be rejected
19  U() {} // desired-error {{at most one member of a union may be initialized}}
20  U(int) : a(1) {} // desired-error {{at most one member of a union may be initialized}}
21  U(char) : b('y') {} // desired-error {{at most one member of a union may be initialized}}
22  U(double) : a(1), b('y') {} // desired-error {{at most one member of a union may be initialized}}
23};
24