aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaDecl.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2009-05-15 17:59:04 +0000
committerDouglas Gregor <dgregor@apple.com>2009-05-15 17:59:04 +0000
commite2c31ff0bc622e6fd7d47d7e08b53840f3be6c89 (patch)
tree4c9ea00c55f5164b5db73832a702b744401a7561 /lib/Sema/SemaDecl.cpp
parent7a0ba875a7dcee94ec74fa79b7f8a247d200a76c (diff)
Call ActOnStartOfFunctionDecl/ActOnFinishFunctionBody when
instantiating the definition of a function from a template. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71869 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaDecl.cpp')
-rw-r--r--lib/Sema/SemaDecl.cpp15
1 files changed, 11 insertions, 4 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index feb9595736..860dda001f 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/lib/Sema/SemaDecl.cpp
@@ -3002,7 +3002,8 @@ Sema::DeclPtrTy Sema::ActOnStartOfFunctionDef(Scope *FnBodyScope, DeclPtrTy D) {
Diag(FD->getLocation(), diag::warn_missing_prototype) << FD;
}
- PushDeclContext(FnBodyScope, FD);
+ if (FnBodyScope)
+ PushDeclContext(FnBodyScope, FD);
// Check the validity of our function parameters
CheckParmsForFunctionDef(FD);
@@ -3013,7 +3014,7 @@ Sema::DeclPtrTy Sema::ActOnStartOfFunctionDef(Scope *FnBodyScope, DeclPtrTy D) {
Param->setOwningFunction(FD);
// If this has an identifier, add it to the scope stack.
- if (Param->getIdentifier())
+ if (Param->getIdentifier() && FnBodyScope)
PushOnScopeChains(Param, FnBodyScope);
}
@@ -3039,8 +3040,12 @@ Sema::DeclPtrTy Sema::ActOnStartOfFunctionDef(Scope *FnBodyScope, DeclPtrTy D) {
return DeclPtrTy::make(FD);
}
-
Sema::DeclPtrTy Sema::ActOnFinishFunctionBody(DeclPtrTy D, StmtArg BodyArg) {
+ return ActOnFinishFunctionBody(D, move(BodyArg), false);
+}
+
+Sema::DeclPtrTy Sema::ActOnFinishFunctionBody(DeclPtrTy D, StmtArg BodyArg,
+ bool IsInstantiation) {
Decl *dcl = D.getAs<Decl>();
Stmt *Body = BodyArg.takeAs<Stmt>();
if (FunctionDecl *FD = dyn_cast_or_null<FunctionDecl>(dcl)) {
@@ -3053,7 +3058,9 @@ Sema::DeclPtrTy Sema::ActOnFinishFunctionBody(DeclPtrTy D, StmtArg BodyArg) {
Body->Destroy(Context);
return DeclPtrTy();
}
- PopDeclContext();
+ if (!IsInstantiation)
+ PopDeclContext();
+
// Verify and clean out per-function state.
assert(&getLabelMap() == &FunctionLabelMap && "Didn't pop block right?");