]> granicus.if.org Git - clang/commitdiff
Check delegating constructors for using uninitialized fields.
authorRichard Trieu <rtrieu@google.com>
Fri, 12 Sep 2014 22:47:58 +0000 (22:47 +0000)
committerRichard Trieu <rtrieu@google.com>
Fri, 12 Sep 2014 22:47:58 +0000 (22:47 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@217716 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaDeclCXX.cpp
test/SemaCXX/uninitialized.cpp

index 858f2c70b035ab04f27bdd23d1e2dd9a5354f38a..006a3c49d7ca7a0c38f17b54e76f625159aef878 100644 (file)
@@ -3623,6 +3623,8 @@ Sema::SetDelegatingInitializer(CXXConstructorDecl *Constructor,
 
   DelegatingCtorDecls.push_back(Constructor);
 
+  DiagnoseUninitializedFields(*this, Constructor);
+
   return false;
 }
 
index 8d0338c3d83c637fd658db0d94da46e6beaf433f..bb2ecabfc8a6780a4858eea5715b9663f28956c6 100644 (file)
@@ -861,3 +861,19 @@ namespace base_class {
     C() : A(y = 4), x(y) {}
   };
 }
+
+namespace delegating_constructor {
+  struct A {
+    A(int);
+    A(int&, int);
+
+    A(char (*)[1]) : A(x) {}
+    // expected-warning@-1 {{field 'x' is uninitialized when used here}}
+    A(char (*)[2]) : A(x, x) {}
+    // expected-warning@-1 {{field 'x' is uninitialized when used here}}
+
+    A(char (*)[3]) : A(x, 0) {}
+
+    int x;
+  };
+}