From: John McCall Date: Thu, 25 Mar 2010 22:08:03 +0000 (+0000) Subject: When finishing a function definition, leave the function definition *after* X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=90f97892eb8b2ecfcf633c9df01e2504686d4d96;p=clang 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99559 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index d449951c98..9bdcf09b29 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -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 diff --git a/test/CXX/class.access/p4.cpp b/test/CXX/class.access/p4.cpp index 0c87c07e06..07ecc6caf0 100644 --- a/test/CXX/class.access/p4.cpp +++ b/test/CXX/class.access/p4.cpp @@ -283,3 +283,15 @@ namespace test10 { }; }; } + +namespace test11 { + class A { + protected: virtual ~A(); + }; + + class B : public A { + ~B(); + }; + + B::~B() {}; +}