aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/Sema/SemaTemplateInstantiate.cpp4
-rw-r--r--lib/Sema/SemaTemplateInstantiateDecl.cpp3
-rw-r--r--lib/Sema/TreeTransform.h4
3 files changed, 7 insertions, 4 deletions
diff --git a/lib/Sema/SemaTemplateInstantiate.cpp b/lib/Sema/SemaTemplateInstantiate.cpp
index 6db0916e44..539b4c409f 100644
--- a/lib/Sema/SemaTemplateInstantiate.cpp
+++ b/lib/Sema/SemaTemplateInstantiate.cpp
@@ -1067,6 +1067,10 @@ ParmVarDecl *Sema::SubstParmVarDecl(ParmVarDecl *OldParm,
NewParm->setHasInheritedDefaultArg(OldParm->hasInheritedDefaultArg());
CurrentInstantiationScope->InstantiatedLocal(OldParm, NewParm);
+ // Set DeclContext if inside a Block.
+ if (BlockScopeInfo *CurBlock = getCurBlock())
+ NewParm->setDeclContext(CurBlock->TheDecl);
+
return NewParm;
}
diff --git a/lib/Sema/SemaTemplateInstantiateDecl.cpp b/lib/Sema/SemaTemplateInstantiateDecl.cpp
index 2fd3528532..b80e824bfd 100644
--- a/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ b/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -400,6 +400,9 @@ Decl *TemplateDeclInstantiator::VisitVarDecl(VarDecl *D) {
SemaRef.CurrentInstantiationScope->InstantiatedLocal(D, Var);
}
InstantiateAttrs(D, Var);
+ // Set DeclContext if inside a Block.
+ if (BlockScopeInfo *CurBlock = SemaRef.getCurBlock())
+ D->setDeclContext(CurBlock->TheDecl);
// Link instantiations of static data members back to the template from
// which they were instantiated.
diff --git a/lib/Sema/TreeTransform.h b/lib/Sema/TreeTransform.h
index 132d04927b..17103c515f 100644
--- a/lib/Sema/TreeTransform.h
+++ b/lib/Sema/TreeTransform.h
@@ -4198,10 +4198,6 @@ TreeTransform<Derived>::TransformDeclRefExpr(DeclRefExpr *E) {
if (!ND)
return SemaRef.ExprError();
- // Set DeclContext if inside a Block.
- if (BlockScopeInfo *CurBlock = SemaRef.getCurBlock())
- ND->setDeclContext(CurBlock->TheDecl);
-
if (!getDerived().AlwaysRebuild() &&
Qualifier == E->getQualifier() &&
ND == E->getDecl() &&