diff options
| author | Douglas Gregor <dgregor@apple.com> | 2009-10-12 23:11:44 +0000 |
|---|---|---|
| committer | Douglas Gregor <dgregor@apple.com> | 2009-10-12 23:11:44 +0000 |
| commit | ef06ccf8d0aa401aef79102a1c5c1e1b4a4815a2 (patch) | |
| tree | b8f09a7f0a8a0d8af999cd7030538fad7e202474 | |
| parent | 0f58bec599eefcd81bd5c986939afb784af7ca98 (diff) | |
| download | bcm5719-llvm-ef06ccf8d0aa401aef79102a1c5c1e1b4a4815a2.tar.gz bcm5719-llvm-ef06ccf8d0aa401aef79102a1c5c1e1b4a4815a2.zip | |
When declaring a class template whose name is qualified, make sure
that the scope in which it is being declared is complete. Also, when
instantiating a member class template's ClassTemplateDecl, be sure to
delay type creation so that the resulting type is dependent. Ick.
llvm-svn: 83923
| -rw-r--r-- | clang/lib/Sema/SemaTemplate.cpp | 3 | ||||
| -rw-r--r-- | clang/lib/Sema/SemaTemplateInstantiateDecl.cpp | 8 | ||||
| -rw-r--r-- | clang/test/CXX/temp/temp.spec/temp.expl.spec/p18.cpp | 16 |
3 files changed, 25 insertions, 2 deletions
diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp index 8ca9089c5e3..9d39ddbe68f 100644 --- a/clang/lib/Sema/SemaTemplate.cpp +++ b/clang/lib/Sema/SemaTemplate.cpp @@ -574,6 +574,9 @@ Sema::CheckClassTemplate(Scope *S, unsigned TagSpec, TagUseKind TUK, DeclContext *SemanticContext; LookupResult Previous; if (SS.isNotEmpty() && !SS.isInvalid()) { + if (RequireCompleteDeclContext(SS)) + return true; + SemanticContext = computeDeclContext(SS, true); if (!SemanticContext) { // FIXME: Produce a reasonable diagnostic here diff --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp index 916e4432947..4fd2a734b1f 100644 --- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp +++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -390,7 +390,8 @@ Decl *TemplateDeclInstantiator::VisitClassTemplateDecl(ClassTemplateDecl *D) { CXXRecordDecl *RecordInst = CXXRecordDecl::Create(SemaRef.Context, Pattern->getTagKind(), Owner, Pattern->getLocation(), Pattern->getIdentifier(), - Pattern->getTagKeywordLoc(), /*PrevDecl=*/ NULL); + Pattern->getTagKeywordLoc(), /*PrevDecl=*/ NULL, + /*DelayTypeCreation=*/true); ClassTemplateDecl *Inst = ClassTemplateDecl::Create(SemaRef.Context, Owner, D->getLocation(), @@ -398,7 +399,10 @@ Decl *TemplateDeclInstantiator::VisitClassTemplateDecl(ClassTemplateDecl *D) { RecordInst->setDescribedClassTemplate(Inst); Inst->setAccess(D->getAccess()); Inst->setInstantiatedFromMemberTemplate(D); - + + // Trigger creation of the type for the instantiation. + SemaRef.Context.getTypeDeclType(RecordInst); + Owner->addDecl(Inst); return Inst; } diff --git a/clang/test/CXX/temp/temp.spec/temp.expl.spec/p18.cpp b/clang/test/CXX/temp/temp.spec/temp.expl.spec/p18.cpp new file mode 100644 index 00000000000..112444af954 --- /dev/null +++ b/clang/test/CXX/temp/temp.spec/temp.expl.spec/p18.cpp @@ -0,0 +1,16 @@ +// RUN: clang-cc -fsyntax-only -verify %s +template<class T1> class A { + template<class T2> class B { + template<class T3> void mf1(T3); + void mf2(); + }; +}; + +template<> template<class X> +class A<int>::B { }; + +template<> template<> template<class T> + void A<int>::B<double>::mf1(T t) { } + +template<class Y> template<> + void A<Y>::B<double>::mf2() { } // expected-error{{does not refer}} |

