]> granicus.if.org Git - clang/commitdiff
When finishing a function definition, leave the function definition *after*
authorJohn McCall <rjmccall@apple.com>
Thu, 25 Mar 2010 22:08:03 +0000 (22:08 +0000)
committerJohn McCall <rjmccall@apple.com>
Thu, 25 Mar 2010 22:08:03 +0000 (22:08 +0000)
doing all the cleanup tasks and checks.  This gives us the proper context for
checking access to base and member destructors.

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

lib/Sema/SemaDecl.cpp
test/CXX/class.access/p4.cpp

index d449951c98045a7e601bbef67d0ea7a77b1ec116..9bdcf09b29677923d70b16362eed84c05dbb43cd 100644 (file)
@@ -4336,8 +4336,6 @@ Sema::DeclPtrTy Sema::ActOnFinishFunctionBody(DeclPtrTy D, StmtArg BodyArg,
     Body->Destroy(Context);
     return DeclPtrTy();
   }
-  if (!IsInstantiation)
-    PopDeclContext();
 
   // Verify and clean out per-function state.
 
@@ -4419,6 +4417,9 @@ Sema::DeclPtrTy Sema::ActOnFinishFunctionBody(DeclPtrTy D, StmtArg BodyArg,
     assert(ExprTemporaries.empty() && "Leftover temporaries in function");
   }
   
+  if (!IsInstantiation)
+    PopDeclContext();
+
   PopFunctionOrBlockScope();
   
   // If any errors have occurred, clear out any temporaries that may have
index 0c87c07e06405a3bee300ab2480057c25288c349..07ecc6caf0a5fe4846def093018ff175f6214aad 100644 (file)
@@ -283,3 +283,15 @@ namespace test10 {
     };
   };
 }
+
+namespace test11 {
+  class A {
+    protected: virtual ~A();
+  };
+
+  class B : public A {
+    ~B();
+  };
+
+  B::~B() {};
+}