]> granicus.if.org Git - clang/commitdiff
My original patch missed the virtual-base case for destroying
authorJohn McCall <rjmccall@apple.com>
Mon, 9 Apr 2012 21:51:56 +0000 (21:51 +0000)
committerJohn McCall <rjmccall@apple.com>
Mon, 9 Apr 2012 21:51:56 +0000 (21:51 +0000)
base-class subojects.

Incidentally, thinking about virtual bases makes it clear to me that
we're not appropriately computing the access to the virtual base's
member because we're not computing the best possible access to the
virtual base at all;  in fact, we're basically assuming it's public.
I'll file a separate PR about that.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154346 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaDeclCXX.cpp
test/CXX/class.access/class.protected/p1.cpp

index 704ff834b469d8c7994ffd43f623fb0226ab3ee4..847f03c948a363184adabff002715b101755d9b8 100644 (file)
@@ -3356,7 +3356,7 @@ Sema::MarkBaseAndMemberDestructorsReferenced(SourceLocation Location,
        E = ClassDecl->vbases_end(); VBase != E; ++VBase) {
 
     // Bases are always records in a well-formed non-dependent class.
-    const RecordType *RT = VBase->getType()->getAs<RecordType>();
+    const RecordType *RT = VBase->getType()->castAs<RecordType>();
 
     // Ignore direct virtual bases.
     if (DirectVirtualBases.count(RT))
@@ -3373,7 +3373,8 @@ Sema::MarkBaseAndMemberDestructorsReferenced(SourceLocation Location,
     assert(Dtor && "No dtor found for BaseClassDecl!");
     CheckDestructorAccess(ClassDecl->getLocation(), Dtor,
                           PDiag(diag::err_access_dtor_vbase)
-                            << VBase->getType());
+                            << VBase->getType(),
+                          Context.getTypeDeclType(ClassDecl));
 
     MarkFunctionReferenced(Location, const_cast<CXXDestructorDecl*>(Dtor));
     DiagnoseUseOfDecl(Dtor, Location);
index 75c3ffffe82ec6bd7e59080ef67c41a41703baec..c9491e1196f9a8ab1f1f0f661a02d1ac21f35d3b 100644 (file)
@@ -501,3 +501,19 @@ namespace test15 {
     }
   };
 }
+
+namespace test16 {
+  class A {
+  protected:
+    ~A();
+  };
+
+  class B : public virtual A {
+  public:
+    ~B() {}
+  };
+
+  class C : public B {
+    ~C() {}
+  };
+}