When instantiating a function-local variable definition, introduce the

mapping from the declaration in the template to the instantiated
declaration before transforming the initializer, in case some crazy
lunatic decides to use a variable in its own initializer. Fixes PR7016.

llvm-svn: 102945
This commit is contained in:
Douglas Gregor 2010-05-03 20:22:41 +00:00
parent acc59c3ec9
commit 70b21be380
2 changed files with 8 additions and 0 deletions

View File

@ -365,6 +365,9 @@ Decl *TemplateDeclInstantiator::VisitVarDecl(VarDecl *D) {
Owner->makeDeclVisibleInContext(Var);
} else {
Owner->addDecl(Var);
if (Owner->isFunctionOrMethod())
SemaRef.CurrentInstantiationScope->InstantiatedLocal(D, Var);
}
// Link instantiations of static data members back to the template from

View File

@ -220,3 +220,8 @@ namespace test0 {
template <class T> class A { void foo(T array[10]); };
template class A<int>;
}
namespace PR7016 {
template<typename T> void f() { T x = x; }
template void f<int>();
}