diff options
| author | Douglas Gregor <dgregor@apple.com> | 2009-11-17 06:07:40 +0000 |
|---|---|---|
| committer | Douglas Gregor <dgregor@apple.com> | 2009-11-17 06:07:40 +0000 |
| commit | e0b2866147045ac2be59497a23438b783167c4e9 (patch) | |
| tree | e98b6dc4055c79194859324d6ad09e30dd1b00aa | |
| parent | 629f6bb95dc7934e3c96a6728aad7d7ad9ae00ed (diff) | |
| download | bcm5719-llvm-e0b2866147045ac2be59497a23438b783167c4e9.tar.gz bcm5719-llvm-e0b2866147045ac2be59497a23438b783167c4e9.zip | |
Implement template instantiation for using directives, which is dead simple.
Also, make the "don't know how to instantiate a particular kind of
declaration" diagnostic nicer, so we don't have to trap Clang in a
debugger to figure out what went wrong.
llvm-svn: 89050
| -rw-r--r-- | clang/lib/Sema/SemaTemplateInstantiateDecl.cpp | 24 | ||||
| -rw-r--r-- | clang/test/SemaTemplate/instantiate-using-decl.cpp | 3 |
2 files changed, 25 insertions, 2 deletions
diff --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp index 208352fb532..00ef407566f 100644 --- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp +++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -65,11 +65,17 @@ namespace { Decl *VisitTemplateTypeParmDecl(TemplateTypeParmDecl *D); Decl *VisitNonTypeTemplateParmDecl(NonTypeTemplateParmDecl *D); Decl *VisitTemplateTemplateParmDecl(TemplateTemplateParmDecl *D); + Decl *VisitUsingDirectiveDecl(UsingDirectiveDecl *D); Decl *VisitUnresolvedUsingDecl(UnresolvedUsingDecl *D); // Base case. FIXME: Remove once we can instantiate everything. - Decl *VisitDecl(Decl *) { - assert(false && "Template instantiation of unknown declaration kind!"); + Decl *VisitDecl(Decl *D) { + unsigned DiagID = SemaRef.getDiagnostics().getCustomDiagID( + Diagnostic::Error, + "cannot instantiate %0 yet"); + SemaRef.Diag(D->getLocation(), DiagID) + << D->getDeclKindName(); + return 0; } @@ -1005,6 +1011,20 @@ TemplateDeclInstantiator::VisitTemplateTemplateParmDecl( return Param; } +Decl *TemplateDeclInstantiator::VisitUsingDirectiveDecl(UsingDirectiveDecl *D) { + // Using directives are never dependent, so they require no explicit + + UsingDirectiveDecl *Inst + = UsingDirectiveDecl::Create(SemaRef.Context, Owner, D->getLocation(), + D->getNamespaceKeyLocation(), + D->getQualifierRange(), D->getQualifier(), + D->getIdentLocation(), + D->getNominatedNamespace(), + D->getCommonAncestor()); + Owner->addDecl(Inst); + return Inst; +} + Decl * TemplateDeclInstantiator::VisitUnresolvedUsingDecl(UnresolvedUsingDecl *D) { NestedNameSpecifier *NNS = diff --git a/clang/test/SemaTemplate/instantiate-using-decl.cpp b/clang/test/SemaTemplate/instantiate-using-decl.cpp index fd9010fa4bb..a1cf355c890 100644 --- a/clang/test/SemaTemplate/instantiate-using-decl.cpp +++ b/clang/test/SemaTemplate/instantiate-using-decl.cpp @@ -1,5 +1,7 @@ // RUN: clang-cc -fsyntax-only -verify %s +namespace N { } + template<typename T> struct A { void f(); @@ -10,6 +12,7 @@ struct B : A<T> { using A<T>::f; void g() { + using namespace N; f(); } }; |

