[cfe-commits] r88847 - in /cfe/trunk: lib/Sema/SemaDeclCXX.cpp test/SemaCXX/constructor-initializer.cpp
Douglas Gregor
dgregor at apple.com
Sun Nov 15 00:51:13 PST 2009
Author: dgregor
Date: Sun Nov 15 02:51:10 2009
New Revision: 88847
URL: http://llvm.org/viewvc/llvm-project?rev=88847&view=rev
Log:
Don't gratuitously mark the default constructors of base or member initializers as used
Modified:
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/test/SemaCXX/constructor-initializer.cpp
Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=88847&r1=88846&r2=88847&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Sun Nov 15 02:51:10 2009
@@ -1266,13 +1266,8 @@
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 @@
// 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 @@
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;
}
Modified: cfe/trunk/test/SemaCXX/constructor-initializer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/constructor-initializer.cpp?rev=88847&r1=88846&r2=88847&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/constructor-initializer.cpp (original)
+++ cfe/trunk/test/SemaCXX/constructor-initializer.cpp Sun Nov 15 02:51:10 2009
@@ -158,3 +158,18 @@
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;
+};
More information about the cfe-commits
mailing list