summaryrefslogtreecommitdiffstats
path: root/clang/test/SemaCXX/warn-reorder-ctor-initialization.cpp
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2009-07-10 20:13:23 +0000
committerFariborz Jahanian <fjahanian@apple.com>2009-07-10 20:13:23 +0000
commit3554b5a37c79551fc48f7322a95b817781ca6f1b (patch)
tree6e7b216aaaf2f5bd8beeb1176be8edac0a5cfd47 /clang/test/SemaCXX/warn-reorder-ctor-initialization.cpp
parent48d983c86e6bcc028bd8071e6f1a228ad8f550da (diff)
downloadbcm5719-llvm-3554b5a37c79551fc48f7322a95b817781ca6f1b.tar.gz
bcm5719-llvm-3554b5a37c79551fc48f7322a95b817781ca6f1b.zip
Patch to build list of inherited virtual base classes
in their order of construction for each class and use it to to check on propery order of base class construction under -Wreorder option. llvm-svn: 75270
Diffstat (limited to 'clang/test/SemaCXX/warn-reorder-ctor-initialization.cpp')
-rw-r--r--clang/test/SemaCXX/warn-reorder-ctor-initialization.cpp70
1 files changed, 64 insertions, 6 deletions
diff --git a/clang/test/SemaCXX/warn-reorder-ctor-initialization.cpp b/clang/test/SemaCXX/warn-reorder-ctor-initialization.cpp
index 83b671010c3..107c89355e6 100644
--- a/clang/test/SemaCXX/warn-reorder-ctor-initialization.cpp
+++ b/clang/test/SemaCXX/warn-reorder-ctor-initialization.cpp
@@ -1,18 +1,76 @@
// RUN: clang-cc -fsyntax-only -Wreorder -verify %s
-struct B {};
+struct BB {};
-struct B1 {};
+struct BB1 {};
-class complex : public B, B1 {
+class complex : public BB, BB1 {
public:
complex() : s2(1), // expected-warning {{member 's2' will be initialized after}}
s1(1) , // expected-note {{field s1}}
s3(3), // expected-warning {{member 's3' will be initialized after}}
- B1(), // expected-note {{base 'struct B1'}} \
- // expected-warning {{base class 'struct B1' will be initialized after}}
- B() {} // expected-note {{base 'struct B'}}
+ BB1(), // expected-note {{base 'struct BB1'}} \
+ // expected-warning {{base class 'struct BB1' will be initialized after}}
+ BB() {} // expected-note {{base 'struct BB'}}
int s1;
int s2;
int s3;
};
+
+
+// testing virtual bases.
+
+
+struct V {
+ V();
+};
+
+struct A : public virtual V {
+ A();
+};
+
+struct B : public virtual V {
+ B();
+};
+
+struct Diamond : public A, public B {
+ Diamond() : A(), B() {}
+};
+
+
+struct C : public A, public B, private virtual V {
+ C() { }
+};
+
+
+struct D : public A, public B {
+ D() : A(), V() { } // expected-warning {{base class 'struct A' will be initialized after}} \
+ // expected-note {{base 'struct V'}}
+};
+
+
+struct E : public A, public B, private virtual V {
+ E() : A(), V() { } // expected-warning {{base class 'struct A' will be initialized after}} \
+ // expected-note {{base 'struct V'}}
+};
+
+
+struct A1 {
+ A1();
+};
+
+struct B1 {
+ B1();
+};
+
+struct F : public A1, public B1, private virtual V {
+ F() : A1(), V() { } // expected-warning {{base class 'struct A1' will be initialized after}} \
+ // expected-note {{base 'struct V'}}
+};
+
+struct X : public virtual A, virtual V, public virtual B {
+ X(): A(), V(), B() {} // expected-warning {{base class 'struct A' will be initialized after}} \
+ // expected-note {{base 'struct V'}}
+};
+
+
OpenPOWER on IntegriCloud