[cfe-commits] r91928 - in /cfe/trunk: lib/Sema/SemaTemplateInstantiateDecl.cpp test/SemaTemplate/instantiate-using-decl.cpp

John McCall rjmccall at apple.com
Tue Dec 22 14:26:45 PST 2009


Author: rjmccall
Date: Tue Dec 22 16:26:37 2009
New Revision: 91928

URL: http://llvm.org/viewvc/llvm-project?rev=91928&view=rev
Log:
Add using shadow decls to the "instantiated locals" map, fixing PR5847.


Modified:
    cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
    cfe/trunk/test/SemaTemplate/instantiate-using-decl.cpp

Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp?rev=91928&r1=91927&r2=91928&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp Tue Dec 22 16:26:37 2009
@@ -1161,6 +1161,8 @@
   if (NewUD->isInvalidDecl())
     return NewUD;
 
+  bool isFunctionScope = Owner->isFunctionOrMethod();
+
   // Process the shadow decls.
   for (UsingDecl::shadow_iterator I = D->shadow_begin(), E = D->shadow_end();
          I != E; ++I) {
@@ -1176,6 +1178,9 @@
     UsingShadowDecl *InstShadow
       = SemaRef.BuildUsingShadowDecl(/*Scope*/ 0, NewUD, InstTarget);
     SemaRef.Context.setInstantiatedFromUsingShadowDecl(InstShadow, Shadow);
+
+    if (isFunctionScope)
+      SemaRef.CurrentInstantiationScope->InstantiatedLocal(Shadow, InstShadow);
   }
 
   return NewUD;

Modified: cfe/trunk/test/SemaTemplate/instantiate-using-decl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/instantiate-using-decl.cpp?rev=91928&r1=91927&r2=91928&view=diff

==============================================================================
--- cfe/trunk/test/SemaTemplate/instantiate-using-decl.cpp (original)
+++ cfe/trunk/test/SemaTemplate/instantiate-using-decl.cpp Tue Dec 22 16:26:37 2009
@@ -47,3 +47,17 @@
     Knot().Visit((struct Object3*) 0); // expected-error {{no matching member function for call}}
   }
 }
+
+// PR5847
+namespace test2 {
+  namespace ns {
+    void foo();
+  }
+
+  template <class T> void bar(T* ptr) {
+    using ns::foo;
+    foo();
+  }
+
+  template void bar(char *);
+}





More information about the cfe-commits mailing list