Richard Smith | 7a614d8 | 2011-06-11 17:19:42 +0000 | [diff] [blame^] | 1 | // RUN: %clang_cc1 -std=c++0x -fsyntax-only -verify %s |
| 2 | |
| 3 | int n; |
| 4 | struct 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 | |
| 14 | union 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 | }; |