aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnders Carlsson <andersca@mac.com>2010-05-27 18:51:01 +0000
committerAnders Carlsson <andersca@mac.com>2010-05-27 18:51:01 +0000
commit0a87b377d9a8af87ebc99585be96aac2d36ccfcb (patch)
tree24c5e398ad4734dc8f2469cce2f7843e0b314e71
parent78673d9f910e8dfe13248c2426c51d8f9fb28572 (diff)
When null-initializing bases with data member pointers, don't assert on virtual bases. Just initialize them to null.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@104868 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/CodeGen/CGExprConstant.cpp12
-rw-r--r--test/CodeGenCXX/pointers-to-data-members.cpp21
2 files changed, 31 insertions, 2 deletions
diff --git a/lib/CodeGen/CGExprConstant.cpp b/lib/CodeGen/CGExprConstant.cpp
index 551a47aa9f..978964d843 100644
--- a/lib/CodeGen/CGExprConstant.cpp
+++ b/lib/CodeGen/CGExprConstant.cpp
@@ -1009,7 +1009,11 @@ FillInNullDataMemberPointers(CodeGenModule &CGM, QualType T,
// Go through all bases and fill in any null pointer to data members.
for (CXXRecordDecl::base_class_const_iterator I = RD->bases_begin(),
E = RD->bases_end(); I != E; ++I) {
- assert(!I->isVirtual() && "Should not see virtual bases here!");
+ if (I->isVirtual()) {
+ // FIXME: We should initialize null pointer to data members in virtual
+ // bases here.
+ continue;
+ }
const CXXRecordDecl *BaseDecl =
cast<CXXRecordDecl>(I->getType()->getAs<RecordType>()->getDecl());
@@ -1088,7 +1092,11 @@ llvm::Constant *CodeGenModule::EmitNullConstant(QualType T) {
// Go through all bases and fill in any null pointer to data members.
for (CXXRecordDecl::base_class_const_iterator I = RD->bases_begin(),
E = RD->bases_end(); I != E; ++I) {
- assert(!I->isVirtual() && "Should not see virtual bases here!");
+ if (I->isVirtual()) {
+ // FIXME: We should initialize null pointer to data members in virtual
+ // bases here.
+ continue;
+ }
const CXXRecordDecl *BaseDecl =
cast<CXXRecordDecl>(I->getType()->getAs<RecordType>()->getDecl());
diff --git a/test/CodeGenCXX/pointers-to-data-members.cpp b/test/CodeGenCXX/pointers-to-data-members.cpp
index affe1f7d18..e0e4e0c026 100644
--- a/test/CodeGenCXX/pointers-to-data-members.cpp
+++ b/test/CodeGenCXX/pointers-to-data-members.cpp
@@ -151,3 +151,24 @@ bool check2() {
}
}
+
+namespace VirtualBases {
+
+struct A {
+ char c;
+ int A::*i;
+};
+
+// FIXME: A::i should be initialized to -1 here.
+struct B : virtual A { };
+B b;
+
+// FIXME: A::i should be initialized to -1 here.
+struct C : virtual A { int A::*i; };
+C c;
+
+// FIXME: C::A::i should be initialized to -1 here.
+struct D : C { int A::*i; };
+D d;
+
+}