When finishing a function definition, leave the function definition *after*
doing all the cleanup tasks and checks.  This gives us the proper context for
checking access to base and member destructors.

llvm-svn: 99559
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index d449951..9bdcf09 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -4336,8 +4336,6 @@
     Body->Destroy(Context);
     return DeclPtrTy();
   }
-  if (!IsInstantiation)
-    PopDeclContext();
 
   // Verify and clean out per-function state.
 
@@ -4419,6 +4417,9 @@
     assert(ExprTemporaries.empty() && "Leftover temporaries in function");
   }
   
+  if (!IsInstantiation)
+    PopDeclContext();
+
   PopFunctionOrBlockScope();
   
   // If any errors have occurred, clear out any temporaries that may have