]> granicus.if.org Git - clang/commitdiff
When instantiating a function declaration within a function template,
authorDouglas Gregor <dgregor@apple.com>
Fri, 21 May 2010 21:25:08 +0000 (21:25 +0000)
committerDouglas Gregor <dgregor@apple.com>
Fri, 21 May 2010 21:25:08 +0000 (21:25 +0000)
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
test/SemaTemplate/instantiate-function-2.cpp

index e8cbb66694ff62e3d46e9b143e562cf728502027..10d2bb119d3340125ef6c71d97ee3b100db2e374 100644 (file)
@@ -970,6 +970,7 @@ Decl *TemplateDeclInstantiator::VisitFunctionDecl(FunctionDecl *D,
     isFriend = (D->getFriendObjectKind() != Decl::FOK_None);
 
   bool MergeWithParentScope = (TemplateParams != 0) ||
+    Owner->isFunctionOrMethod() ||
     !(isa<Decl>(Owner) && 
       cast<Decl>(Owner)->isDefinedOutsideFunctionOrMethod());
   Sema::LocalInstantiationScope Scope(SemaRef, MergeWithParentScope);
index 6318facfc0ea8ea9348de61125bf74184e9a5434..afca358784442fb39baf31736aa2f352c1d9c18f 100644 (file)
@@ -10,3 +10,13 @@ void f() {
   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>();
+}