From b212d9a8e10308cde5b7a1ce07bd59d8df14fa06 Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Fri, 21 May 2010 21:25:08 +0000 Subject: [PATCH] When instantiating a function declaration within a function template, be sure to merge its parameter scope with its parent's scope. Fixes PR7184. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@104386 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Sema/SemaTemplateInstantiateDecl.cpp | 1 + test/SemaTemplate/instantiate-function-2.cpp | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/lib/Sema/SemaTemplateInstantiateDecl.cpp b/lib/Sema/SemaTemplateInstantiateDecl.cpp index e8cbb66694..10d2bb119d 100644 --- a/lib/Sema/SemaTemplateInstantiateDecl.cpp +++ b/lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -970,6 +970,7 @@ Decl *TemplateDeclInstantiator::VisitFunctionDecl(FunctionDecl *D, isFriend = (D->getFriendObjectKind() != Decl::FOK_None); bool MergeWithParentScope = (TemplateParams != 0) || + Owner->isFunctionOrMethod() || !(isa(Owner) && cast(Owner)->isDefinedOutsideFunctionOrMethod()); Sema::LocalInstantiationScope Scope(SemaRef, MergeWithParentScope); diff --git a/test/SemaTemplate/instantiate-function-2.cpp b/test/SemaTemplate/instantiate-function-2.cpp index 6318facfc0..afca358784 100644 --- a/test/SemaTemplate/instantiate-function-2.cpp +++ b/test/SemaTemplate/instantiate-function-2.cpp @@ -10,3 +10,13 @@ void f() { S s1; S s2(10); } + +namespace PR7184 { + template + void f() { + typedef T type; + void g(int array[sizeof(type)]); + } + + template void f(); +} -- 2.40.0