[cfe-commits] r154346 - in /cfe/trunk: lib/Sema/SemaDeclCXX.cpp test/CXX/class.access/class.protected/p1.cpp

John McCall rjmccall at apple.com
Mon Apr 9 14:51:56 PDT 2012


Author: rjmccall
Date: Mon Apr  9 16:51:56 2012
New Revision: 154346

URL: http://llvm.org/viewvc/llvm-project?rev=154346&view=rev
Log:
My original patch missed the virtual-base case for destroying
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.

Modified:
    cfe/trunk/lib/Sema/SemaDeclCXX.cpp
    cfe/trunk/test/CXX/class.access/class.protected/p1.cpp

Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=154346&r1=154345&r2=154346&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Mon Apr  9 16:51:56 2012
@@ -3356,7 +3356,7 @@
        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 @@
     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);

Modified: cfe/trunk/test/CXX/class.access/class.protected/p1.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/class.access/class.protected/p1.cpp?rev=154346&r1=154345&r2=154346&view=diff
==============================================================================
--- cfe/trunk/test/CXX/class.access/class.protected/p1.cpp (original)
+++ cfe/trunk/test/CXX/class.access/class.protected/p1.cpp Mon Apr  9 16:51:56 2012
@@ -501,3 +501,19 @@
     }
   };
 }
+
+namespace test16 {
+  class A {
+  protected:
+    ~A();
+  };
+
+  class B : public virtual A {
+  public:
+    ~B() {}
+  };
+
+  class C : public B {
+    ~C() {}
+  };
+}





More information about the cfe-commits mailing list