freebsd-skq/test/SemaCXX/illegal-member-initialization.cpp

32 lines
1021 B
C++
Raw Normal View History

2010-01-01 10:34:51 +00:00
// RUN: %clang_cc1 -fsyntax-only -verify %s
2009-10-14 18:03:49 +00:00
struct A {
2010-02-16 09:31:36 +00:00
A() : value(), cvalue() { } // expected-error {{reference to type 'int' requires an initializer}}
int &value;
2009-10-14 18:03:49 +00:00
const int cvalue;
};
struct B {
};
struct X {
2010-03-10 17:45:58 +00:00
X() { } // expected-error {{constructor for 'X' must explicitly initialize the reference member 'value'}} \
// expected-error {{constructor for 'X' must explicitly initialize the const member 'cvalue'}} \
// expected-error {{constructor for 'X' must explicitly initialize the reference member 'b'}} \
// expected-error {{constructor for 'X' must explicitly initialize the const member 'cb'}}
2009-10-14 18:03:49 +00:00
int &value; // expected-note{{declared at}}
const int cvalue; // expected-note{{declared at}}
B& b; // expected-note{{declared at}}
2010-02-16 09:31:36 +00:00
const B cb; // expected-note{{declared here}}
2009-10-14 18:03:49 +00:00
};
2010-01-01 10:34:51 +00:00
// PR5924
struct bar {};
bar xxx();
struct foo {
foo_t a; // expected-error {{unknown type name 'foo_t'}}
foo() : a(xxx()) {} // no error here.
};