summaryrefslogtreecommitdiffstats
path: root/test/SemaCXX/illegal-member-initialization.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'test/SemaCXX/illegal-member-initialization.cpp')
-rw-r--r--test/SemaCXX/illegal-member-initialization.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/test/SemaCXX/illegal-member-initialization.cpp b/test/SemaCXX/illegal-member-initialization.cpp
new file mode 100644
index 0000000..2d7c73d
--- /dev/null
+++ b/test/SemaCXX/illegal-member-initialization.cpp
@@ -0,0 +1,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}}
+};
OpenPOWER on IntegriCloud