blob: 8512a9f7bb3a6c62ccf74a97d1d0b39d94b66fb1 [file] [log] [blame]
Richard Smith7a614d82011-06-11 17:19:42 +00001// 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};