Check delegating constructors for using uninitialized fields.

llvm-svn: 217716
This commit is contained in:
Richard Trieu 2014-09-12 22:47:58 +00:00
parent b8536b1db8
commit 8a0c9e6247
2 changed files with 18 additions and 0 deletions

View File

@ -3623,6 +3623,8 @@ Sema::SetDelegatingInitializer(CXXConstructorDecl *Constructor,
DelegatingCtorDecls.push_back(Constructor);
DiagnoseUninitializedFields(*this, Constructor);
return false;
}

View 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;
};
}