[cfe-commits] r102945 - in /cfe/trunk: lib/Sema/SemaTemplateInstantiateDecl.cpp test/SemaTemplate/instantiate-function-1.cpp
Douglas Gregor
dgregor at apple.com
Mon May 3 13:22:41 PDT 2010
Author: dgregor
Date: Mon May 3 15:22:41 2010
New Revision: 102945
URL: http://llvm.org/viewvc/llvm-project?rev=102945&view=rev
Log:
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.
Modified:
cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
cfe/trunk/test/SemaTemplate/instantiate-function-1.cpp
Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp?rev=102945&r1=102944&r2=102945&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp Mon May 3 15:22:41 2010
@@ -365,6 +365,9 @@
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
Modified: cfe/trunk/test/SemaTemplate/instantiate-function-1.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/instantiate-function-1.cpp?rev=102945&r1=102944&r2=102945&view=diff
==============================================================================
--- cfe/trunk/test/SemaTemplate/instantiate-function-1.cpp (original)
+++ cfe/trunk/test/SemaTemplate/instantiate-function-1.cpp Mon May 3 15:22:41 2010
@@ -220,3 +220,8 @@
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>();
+}
More information about the cfe-commits
mailing list