Daniel Dunbar | a572887 | 2009-12-15 20:14:24 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -verify %s |
Fariborz Jahanian | 80545ad | 2009-09-03 19:36:46 +0000 | [diff] [blame] | 2 | |
| 3 | struct A { |
| 4 | A() : value(), cvalue() { } // expected-error {{cannot initialize the member to null in default constructor because reference member 'value' cannot be null-initialized}} \ |
| 5 | // expected-error {{constructor for 'struct A' must explicitly initialize the reference member 'value'}} |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 6 | int &value; // expected-note{{declared at}} {{expected-note{{declared at}} |
Fariborz Jahanian | 80545ad | 2009-09-03 19:36:46 +0000 | [diff] [blame] | 7 | const int cvalue; |
| 8 | }; |
| 9 | |
| 10 | struct B { |
| 11 | }; |
| 12 | |
| 13 | struct X { |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 14 | X() { } // expected-error {{constructor for 'struct X' must explicitly initialize the reference member 'value'}} \ |
| 15 | // expected-error {{constructor for 'struct X' must explicitly initialize the const member 'cvalue'}} \ |
| 16 | // expected-error {{constructor for 'struct X' must explicitly initialize the reference member 'b'}} \ |
| 17 | // expected-error {{constructor for 'struct X' must explicitly initialize the const member 'cb'}} |
Fariborz Jahanian | 80545ad | 2009-09-03 19:36:46 +0000 | [diff] [blame] | 18 | int &value; // expected-note{{declared at}} |
| 19 | const int cvalue; // expected-note{{declared at}} |
| 20 | B& b; // expected-note{{declared at}} |
| 21 | const B cb; // expected-note{{declared at}} |
| 22 | }; |
Chris Lattner | 8c3f890 | 2009-12-31 03:10:55 +0000 | [diff] [blame^] | 23 | |
| 24 | |
| 25 | // PR5924 |
| 26 | struct bar {}; |
| 27 | bar xxx(); |
| 28 | |
| 29 | struct foo { |
| 30 | foo_t a; // expected-error {{unknown type name 'foo_t'}} |
| 31 | foo() : a(xxx()) {} // no error here. |
| 32 | }; |