aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaTemplateInstantiateDecl.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2010-09-29 17:58:28 +0000
committerDouglas Gregor <dgregor@apple.com>2010-09-29 17:58:28 +0000
commit1b398205267ea69f35230eea50e0225db22ebb7e (patch)
tree9da998f2b8883aeebc9430715c850418c689e370 /lib/Sema/SemaTemplateInstantiateDecl.cpp
parent640cf37c9432031412a9d3b8c2abcdff4f7f0e97 (diff)
Fix handling of dependent nested namespace specifiers in UsingDecls
during template instantiation, from Martin Vejnar! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@115051 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaTemplateInstantiateDecl.cpp')
-rw-r--r--lib/Sema/SemaTemplateInstantiateDecl.cpp24
1 files changed, 20 insertions, 4 deletions
diff --git a/lib/Sema/SemaTemplateInstantiateDecl.cpp b/lib/Sema/SemaTemplateInstantiateDecl.cpp
index d87629151e..d0df7fae75 100644
--- a/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ b/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -1558,8 +1558,24 @@ Decl *TemplateDeclInstantiator::VisitUsingDirectiveDecl(UsingDirectiveDecl *D) {
}
Decl *TemplateDeclInstantiator::VisitUsingDecl(UsingDecl *D) {
- // The nested name specifier is non-dependent, so no transformation
- // is required. The same holds for the name info.
+
+ // The nested name specifier may be dependent, for example
+ // template <typename T> struct t {
+ // struct s1 { T f1(); };
+ // struct s2 : s1 { using s1::f1; };
+ // };
+ // template struct t<int>;
+ // Here, in using s1::f1, s1 refers to t<T>::s1;
+ // we need to substitute for t<int>::s1.
+ NestedNameSpecifier *NNS =
+ SemaRef.SubstNestedNameSpecifier(D->getTargetNestedNameDecl(),
+ D->getNestedNameRange(),
+ TemplateArgs);
+ if (!NNS)
+ return 0;
+
+ // The name info is non-dependent, so no transformation
+ // is required.
DeclarationNameInfo NameInfo = D->getNameInfo();
// We only need to do redeclaration lookups if we're in a class
@@ -1573,12 +1589,12 @@ Decl *TemplateDeclInstantiator::VisitUsingDecl(UsingDecl *D) {
UsingDecl *NewUD = UsingDecl::Create(SemaRef.Context, Owner,
D->getNestedNameRange(),
D->getUsingLocation(),
- D->getTargetNestedNameDecl(),
+ NNS,
NameInfo,
D->isTypeName());
CXXScopeSpec SS;
- SS.setScopeRep(D->getTargetNestedNameDecl());
+ SS.setScopeRep(NNS);
SS.setRange(D->getNestedNameRange());
if (CheckRedeclaration) {