[cfe-commits] r104386 - in /cfe/trunk: lib/Sema/SemaTemplateInstantiateDecl.cpp test/SemaTemplate/instantiate-function-2.cpp
Douglas Gregor
dgregor at apple.com
Fri May 21 14:25:08 PDT 2010
Author: dgregor
Date: Fri May 21 16:25:08 2010
New Revision: 104386
URL: http://llvm.org/viewvc/llvm-project?rev=104386&view=rev
Log:
When instantiating a function declaration within a function template,
be sure to merge its parameter scope with its parent's scope. Fixes
PR7184.
Modified:
cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
cfe/trunk/test/SemaTemplate/instantiate-function-2.cpp
Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp?rev=104386&r1=104385&r2=104386&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp Fri May 21 16:25:08 2010
@@ -970,6 +970,7 @@
isFriend = (D->getFriendObjectKind() != Decl::FOK_None);
bool MergeWithParentScope = (TemplateParams != 0) ||
+ Owner->isFunctionOrMethod() ||
!(isa<Decl>(Owner) &&
cast<Decl>(Owner)->isDefinedOutsideFunctionOrMethod());
Sema::LocalInstantiationScope Scope(SemaRef, MergeWithParentScope);
Modified: cfe/trunk/test/SemaTemplate/instantiate-function-2.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/instantiate-function-2.cpp?rev=104386&r1=104385&r2=104386&view=diff
==============================================================================
--- cfe/trunk/test/SemaTemplate/instantiate-function-2.cpp (original)
+++ cfe/trunk/test/SemaTemplate/instantiate-function-2.cpp Fri May 21 16:25:08 2010
@@ -10,3 +10,13 @@
S<int> s1;
S<int> s2(10);
}
+
+namespace PR7184 {
+ template<typename T>
+ void f() {
+ typedef T type;
+ void g(int array[sizeof(type)]);
+ }
+
+ template void f<int>();
+}
More information about the cfe-commits
mailing list