r217716 - Check delegating constructors for using uninitialized fields.
Richard Trieu
rtrieu at google.com
Fri Sep 12 15:47:59 PDT 2014
Author: rtrieu
Date: Fri Sep 12 17:47:58 2014
New Revision: 217716
URL: http://llvm.org/viewvc/llvm-project?rev=217716&view=rev
Log:
Check delegating constructors for using uninitialized fields.
Modified:
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/test/SemaCXX/uninitialized.cpp
Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=217716&r1=217715&r2=217716&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Fri Sep 12 17:47:58 2014
@@ -3623,6 +3623,8 @@ Sema::SetDelegatingInitializer(CXXConstr
DelegatingCtorDecls.push_back(Constructor);
+ DiagnoseUninitializedFields(*this, Constructor);
+
return false;
}
Modified: cfe/trunk/test/SemaCXX/uninitialized.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/uninitialized.cpp?rev=217716&r1=217715&r2=217716&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/uninitialized.cpp (original)
+++ cfe/trunk/test/SemaCXX/uninitialized.cpp Fri Sep 12 17:47:58 2014
@@ -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 at -1 {{field 'x' is uninitialized when used here}}
+ A(char (*)[2]) : A(x, x) {}
+ // expected-warning at -1 {{field 'x' is uninitialized when used here}}
+
+ A(char (*)[3]) : A(x, 0) {}
+
+ int x;
+ };
+}
More information about the cfe-commits
mailing list