forked from OSchip/llvm-project
More block instantiation stuff. Set variable/param DeclContext
to block context when first instantiating them. llvm-svn: 108266
This commit is contained in:
parent
76a6b663a3
commit
a6c7efec2b
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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() &&
|
||||
|
|
|
@ -31,3 +31,29 @@ void test2(void)
|
|||
{
|
||||
foo(100, 'a');
|
||||
}
|
||||
|
||||
namespace rdar6182276 {
|
||||
extern "C" {
|
||||
int printf(const char *, ...);
|
||||
}
|
||||
|
||||
template <typename T> T foo(T t)
|
||||
{
|
||||
void (^testing)(int) = ^(int bar) { printf("bar is %d\n", bar); };
|
||||
printf("bar is\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
template <typename T> void gorf(T t)
|
||||
{
|
||||
foo(t);
|
||||
}
|
||||
|
||||
|
||||
void test(void)
|
||||
{
|
||||
gorf(2);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue