summaryrefslogtreecommitdiff
path: root/test/SemaCXX/constructor-initializer.cpp
diff options
context:
space:
mode:
authorRoman Divacky <rdivacky@FreeBSD.org>2009-11-05 17:18:09 +0000
committerRoman Divacky <rdivacky@FreeBSD.org>2009-11-05 17:18:09 +0000
commit8f57cb0305232cb53fff00ef151ca716766f3437 (patch)
tree8b316eca843681b024034db1125707173b9adb4a /test/SemaCXX/constructor-initializer.cpp
parent51fb8b013e7734b795139f49d3b1f77c539be20a (diff)
Notes
Diffstat (limited to 'test/SemaCXX/constructor-initializer.cpp')
-rw-r--r--test/SemaCXX/constructor-initializer.cpp33
1 files changed, 33 insertions, 0 deletions
diff --git a/test/SemaCXX/constructor-initializer.cpp b/test/SemaCXX/constructor-initializer.cpp
index b86a27d66d98..20cf35b293b6 100644
--- a/test/SemaCXX/constructor-initializer.cpp
+++ b/test/SemaCXX/constructor-initializer.cpp
@@ -122,3 +122,36 @@ struct Q {
float *pf;
};
+
+// A silly class used to demonstrate field-is-uninitialized in constructors with
+// multiple params.
+class TwoInOne { TwoInOne(TwoInOne a, TwoInOne b) {} };
+class InitializeUsingSelfTest {
+ bool A;
+ char* B;
+ int C;
+ TwoInOne D;
+ InitializeUsingSelfTest(int E)
+ : A(A), // expected-warning {{field is uninitialized when used here}}
+ B((((B)))), // expected-warning {{field is uninitialized when used here}}
+ C(A && InitializeUsingSelfTest::C), // expected-warning {{field is uninitialized when used here}}
+ D(D, // expected-warning {{field is uninitialized when used here}}
+ D) {} // expected-warning {{field is uninitialized when used here}}
+};
+
+int IntWrapper(int i) { return 0; };
+class InitializeUsingSelfExceptions {
+ int A;
+ int B;
+ InitializeUsingSelfExceptions(int B)
+ : A(IntWrapper(A)), // Due to a conservative implementation, we do not report warnings inside function/ctor calls even though it is possible to do so.
+ B(B) {} // Not a warning; B is a local variable.
+};
+
+class CopyConstructorTest {
+ bool A, B, C;
+ CopyConstructorTest(const CopyConstructorTest& rhs)
+ : A(rhs.A),
+ B(B), // expected-warning {{field is uninitialized when used here}}
+ C(rhs.C || C) { } // expected-warning {{field is uninitialized when used here}}
+};