forked from OSchip/llvm-project
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:
parent
acc59c3ec9
commit
70b21be380
|
@ -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
|
||||
|
|
|
@ -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>();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue