forked from OSchip/llvm-project
Don't gratuitously mark the default constructors of base or member initializers as used
llvm-svn: 88847
This commit is contained in:
parent
54fdb417fe
commit
598caeee37
|
@ -1266,13 +1266,8 @@ Sema::SetBaseOrMemberInitializers(CXXConstructorDecl *Constructor,
|
|||
E = ClassDecl->vbases_end(); VBase != E; ++VBase) {
|
||||
if (VBase->getType()->isDependentType())
|
||||
continue;
|
||||
if (CXXBaseOrMemberInitializer *Value =
|
||||
AllBaseFields.lookup(VBase->getType()->getAs<RecordType>())) {
|
||||
CXXRecordDecl *BaseDecl =
|
||||
cast<CXXRecordDecl>(VBase->getType()->getAs<RecordType>()->getDecl());
|
||||
assert(BaseDecl && "SetBaseOrMemberInitializers - BaseDecl null");
|
||||
if (CXXConstructorDecl *Ctor = BaseDecl->getDefaultConstructor(Context))
|
||||
MarkDeclarationReferenced(Value->getSourceLocation(), Ctor);
|
||||
if (CXXBaseOrMemberInitializer *Value
|
||||
= AllBaseFields.lookup(VBase->getType()->getAs<RecordType>())) {
|
||||
AllToInit.push_back(Value);
|
||||
}
|
||||
else {
|
||||
|
@ -1319,13 +1314,8 @@ Sema::SetBaseOrMemberInitializers(CXXConstructorDecl *Constructor,
|
|||
// Skip dependent types.
|
||||
if (Base->getType()->isDependentType())
|
||||
continue;
|
||||
if (CXXBaseOrMemberInitializer *Value =
|
||||
AllBaseFields.lookup(Base->getType()->getAs<RecordType>())) {
|
||||
CXXRecordDecl *BaseDecl =
|
||||
cast<CXXRecordDecl>(Base->getType()->getAs<RecordType>()->getDecl());
|
||||
assert(BaseDecl && "SetBaseOrMemberInitializers - BaseDecl null");
|
||||
if (CXXConstructorDecl *Ctor = BaseDecl->getDefaultConstructor(Context))
|
||||
MarkDeclarationReferenced(Value->getSourceLocation(), Ctor);
|
||||
if (CXXBaseOrMemberInitializer *Value
|
||||
= AllBaseFields.lookup(Base->getType()->getAs<RecordType>())) {
|
||||
AllToInit.push_back(Value);
|
||||
}
|
||||
else {
|
||||
|
@ -1388,14 +1378,6 @@ Sema::SetBaseOrMemberInitializers(CXXConstructorDecl *Constructor,
|
|||
continue;
|
||||
}
|
||||
if (CXXBaseOrMemberInitializer *Value = AllBaseFields.lookup(*Field)) {
|
||||
QualType FT = (*Field)->getType();
|
||||
if (const RecordType* RT = FT->getAs<RecordType>()) {
|
||||
CXXRecordDecl *FieldRecDecl = cast<CXXRecordDecl>(RT->getDecl());
|
||||
assert(FieldRecDecl && "SetBaseOrMemberInitializers - BaseDecl null");
|
||||
if (CXXConstructorDecl *Ctor =
|
||||
FieldRecDecl->getDefaultConstructor(Context))
|
||||
MarkDeclarationReferenced(Value->getSourceLocation(), Ctor);
|
||||
}
|
||||
AllToInit.push_back(Value);
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -158,3 +158,18 @@ class CopyConstructorTest {
|
|||
B(B), // expected-warning {{field is uninitialized when used here}}
|
||||
C(rhs.C || C) { } // expected-warning {{field is uninitialized when used here}}
|
||||
};
|
||||
|
||||
// Make sure we aren't marking default constructors when we shouldn't be.
|
||||
template<typename T>
|
||||
struct NDC {
|
||||
T &ref;
|
||||
|
||||
NDC() { }
|
||||
NDC(T &ref) : ref(ref) { }
|
||||
};
|
||||
|
||||
struct X0 : NDC<int> {
|
||||
X0(int &ref) : NDC<int>(ref), ndc(ref) { }
|
||||
|
||||
NDC<int> ndc;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue