1 // RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
2 
3 int n;
4 struct S {
5   int &a; // expected-note 2{{here}}
6   int &b = n;
7 
8   union {
9     const int k = 42;
10   };
11 
12   S() {} // expected-error {{constructor for 'S' must explicitly initialize the reference member 'a'}}
13   S(int) : a(n) {} // ok
14   S(char) : b(n) {} // expected-error {{constructor for 'S' must explicitly initialize the reference member 'a'}}
15   S(double) : a(n), b(n) {} // ok
16 } s(0);
17 
18 union U {
19   int a = 0; // desired-note 5 {{previous initialization is here}}
20   char b = 'x';
21 
22   // FIXME: these should all be rejected
23   U() {} // desired-error {{initializing multiple members of union}}
24   U(int) : a(1) {} // desired-error {{initializing multiple members of union}}
25   U(char) : b('y') {} // desired-error {{initializing multiple members of union}}
26   // this expected note should be removed & the note should appear on the
27   // declaration of 'a' when this set of cases is handled correctly.
28   U(double) : a(1), // expected-note{{previous initialization is here}} desired-error {{initializing multiple members of union}}
29               b('y') {} // expected-error{{initializing multiple members of union}}
30 };
31 
32 // PR10954: variant members do not acquire an implicit initializer.
33 namespace VariantMembers {
34   struct NoDefaultCtor {
35     NoDefaultCtor(int);
36   };
37   union V {
38     NoDefaultCtor ndc;
39     int n;
40 
41     V() {}
42     V(int n) : n(n) {}
43     V(int n, bool) : ndc(n) {}
44   };
45   struct K {
46     union {
47       NoDefaultCtor ndc;
48       int n;
49     };
50     K() {}
51     K(int n) : n(n) {}
52     K(int n, bool) : ndc(n) {}
53   };
54   struct Nested {
55     Nested() {}
56     union {
57       struct {
58         NoDefaultCtor ndc;
59       };
60     };
61   };
62 }
63