aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn McCall <rjmccall@apple.com>2009-12-22 22:26:37 +0000
committerJohn McCall <rjmccall@apple.com>2009-12-22 22:26:37 +0000
commit323c310efa0abd7a786b0303501186b5f33eb8d7 (patch)
tree0e26bd9e87409bb7fe4ca1ecdc182bcd3ac6f3a3
parent90f9382b3e97afa55e6aaaa4ab31c7473a8c7bb9 (diff)
Add using shadow decls to the "instantiated locals" map, fixing PR5847.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91928 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Sema/SemaTemplateInstantiateDecl.cpp5
-rw-r--r--test/SemaTemplate/instantiate-using-decl.cpp14
2 files changed, 19 insertions, 0 deletions
diff --git a/lib/Sema/SemaTemplateInstantiateDecl.cpp b/lib/Sema/SemaTemplateInstantiateDecl.cpp
index 2ca4810055..18a73250a5 100644
--- a/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ b/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -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;
diff --git a/test/SemaTemplate/instantiate-using-decl.cpp b/test/SemaTemplate/instantiate-using-decl.cpp
index 6bbfe65ee0..a4394aa21f 100644
--- a/test/SemaTemplate/instantiate-using-decl.cpp
+++ b/test/SemaTemplate/instantiate-using-decl.cpp
@@ -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 *);
+}