aboutsummaryrefslogtreecommitdiff
path: root/test/SemaCXX/illegal-member-initialization.cpp
blob: 2d7c73d68a3f82e1c028b3ce1d2ea4b6ae25a2d8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// RUN: clang-cc -fsyntax-only -verify %s 

struct A {
   A() : value(), cvalue() { } // expected-error {{cannot initialize the member to null in default constructor because reference member 'value' cannot be null-initialized}} \
                               // expected-error {{constructor for 'struct A' must explicitly initialize the reference member 'value'}}
   int &value; // expected-note{{declared at}} {{expected-note{{declared at}}
   const int cvalue;
};

struct B {
};

struct X {
   X() { }      // expected-error {{constructor for 'struct X' must explicitly initialize the reference member 'value'}} \
                // expected-error {{constructor for 'struct X' must explicitly initialize the const member 'cvalue'}} \
                // expected-error {{constructor for 'struct X' must explicitly initialize the reference member 'b'}} \
                // expected-error {{constructor for 'struct X' must explicitly initialize the const member 'cb'}}
   int &value; // expected-note{{declared at}}
   const int cvalue; // expected-note{{declared at}}
   B& b; // expected-note{{declared at}}
   const B cb; // expected-note{{declared at}}
};