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
This commit is contained in:
John McCall 2010-03-25 22:08:03 +00:00
parent f9c4585c80
commit e99d5f3044
2 changed files with 15 additions and 2 deletions

View 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

View File

@ -283,3 +283,15 @@ namespace test10 {
};
};
}
namespace test11 {
class A {
protected: virtual ~A();
};
class B : public A {
~B();
};
B::~B() {};
}