]> granicus.if.org Git - clang/commitdiff
Add using shadow decls to the "instantiated locals" map, fixing PR5847.
authorJohn McCall <rjmccall@apple.com>
Tue, 22 Dec 2009 22:26:37 +0000 (22:26 +0000)
committerJohn McCall <rjmccall@apple.com>
Tue, 22 Dec 2009 22:26:37 +0000 (22:26 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91928 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaTemplateInstantiateDecl.cpp
test/SemaTemplate/instantiate-using-decl.cpp

index 2ca4810055e8727ee65740d547ce04b26a01322a..18a73250a529d0f768edf44052201eb34826c4cc 100644 (file)
@@ -1161,6 +1161,8 @@ Decl *TemplateDeclInstantiator::VisitUsingDecl(UsingDecl *D) {
   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 @@ Decl *TemplateDeclInstantiator::VisitUsingDecl(UsingDecl *D) {
     UsingShadowDecl *InstShadow
       = SemaRef.BuildUsingShadowDecl(/*Scope*/ 0, NewUD, InstTarget);
     SemaRef.Context.setInstantiatedFromUsingShadowDecl(InstShadow, Shadow);
+
+    if (isFunctionScope)
+      SemaRef.CurrentInstantiationScope->InstantiatedLocal(Shadow, InstShadow);
   }
 
   return NewUD;
index 6bbfe65ee01eb3e521b79c463cbe33cb5d087929..a4394aa21f6e50b690963bd5faca3a86e58587e1 100644 (file)
@@ -47,3 +47,17 @@ namespace test1 {
     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 *);
+}