xref: /minix3/external/bsd/llvm/dist/clang/test/SemaCXX/illegal-member-initialization.cpp (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -fsyntax-only -verify %s
2*f4a2713aSLionel Sambuc 
3*f4a2713aSLionel Sambuc struct A {
AA4*f4a2713aSLionel Sambuc    A() : value(), cvalue() { } // expected-error {{reference to type 'int' requires an initializer}}
5*f4a2713aSLionel Sambuc    int &value;
6*f4a2713aSLionel Sambuc    const int cvalue;
7*f4a2713aSLionel Sambuc };
8*f4a2713aSLionel Sambuc 
9*f4a2713aSLionel Sambuc struct B {
10*f4a2713aSLionel Sambuc };
11*f4a2713aSLionel Sambuc 
12*f4a2713aSLionel Sambuc struct X {
XX13*f4a2713aSLionel Sambuc    X() { }      // expected-error {{constructor for 'X' must explicitly initialize the reference member 'value'}} \
14*f4a2713aSLionel Sambuc                 // expected-error {{constructor for 'X' must explicitly initialize the const member 'cvalue'}} \
15*f4a2713aSLionel Sambuc                 // expected-error {{constructor for 'X' must explicitly initialize the reference member 'b'}} \
16*f4a2713aSLionel Sambuc                 // expected-error {{constructor for 'X' must explicitly initialize the const member 'cb'}}
17*f4a2713aSLionel Sambuc    int &value; // expected-note{{declared here}}
18*f4a2713aSLionel Sambuc    const int cvalue; // expected-note{{declared here}}
19*f4a2713aSLionel Sambuc    B& b; // expected-note{{declared here}}
20*f4a2713aSLionel Sambuc    const B cb; // expected-note{{declared here}}
21*f4a2713aSLionel Sambuc };
22*f4a2713aSLionel Sambuc 
23*f4a2713aSLionel Sambuc 
24*f4a2713aSLionel Sambuc // PR5924
25*f4a2713aSLionel Sambuc struct bar {};
26*f4a2713aSLionel Sambuc bar xxx();
27*f4a2713aSLionel Sambuc 
28*f4a2713aSLionel Sambuc struct foo {
29*f4a2713aSLionel Sambuc   foo_t a;  // expected-error {{unknown type name 'foo_t'}}
foofoo30*f4a2713aSLionel Sambuc   foo() : a(xxx()) {}  // no error here.
31*f4a2713aSLionel Sambuc };
32