aboutsummaryrefslogtreecommitdiff
path: root/test/Analysis/objcpp-uninitialized-object.mm
diff options
context:
space:
mode:
Diffstat (limited to 'test/Analysis/objcpp-uninitialized-object.mm')
-rw-r--r--test/Analysis/objcpp-uninitialized-object.mm32
1 files changed, 32 insertions, 0 deletions
diff --git a/test/Analysis/objcpp-uninitialized-object.mm b/test/Analysis/objcpp-uninitialized-object.mm
new file mode 100644
index 000000000000..8ea4b56998fc
--- /dev/null
+++ b/test/Analysis/objcpp-uninitialized-object.mm
@@ -0,0 +1,32 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.cplusplus.UninitializedObject -std=c++11 -fblocks -verify %s
+
+typedef void (^myBlock) ();
+
+struct StructWithBlock {
+ int a;
+ myBlock z; // expected-note{{uninitialized field 'this->z'}}
+
+ StructWithBlock() : a(0), z(^{}) {}
+
+ // Miss initialization of field `z`.
+ StructWithBlock(int pA) : a(pA) {} // expected-warning{{1 uninitialized field at the end of the constructor call}}
+
+};
+
+void warnOnUninitializedBlock() {
+ StructWithBlock a(10);
+}
+
+void noWarningWhenInitialized() {
+ StructWithBlock a;
+}
+
+struct StructWithId {
+ int a;
+ id z; // expected-note{{uninitialized pointer 'this->z'}}
+ StructWithId() : a(0) {} // expected-warning{{1 uninitialized field at the end of the constructor call}}
+};
+
+void warnOnUninitializedId() {
+ StructWithId s;
+}