forked from OSchip/llvm-project
Check delegating constructors for using uninitialized fields.
llvm-svn: 217716
This commit is contained in:
parent
b8536b1db8
commit
8a0c9e6247
|
@ -3623,6 +3623,8 @@ Sema::SetDelegatingInitializer(CXXConstructorDecl *Constructor,
|
|||
|
||||
DelegatingCtorDecls.push_back(Constructor);
|
||||
|
||||
DiagnoseUninitializedFields(*this, Constructor);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue