diff options
author | Douglas Gregor <dgregor@apple.com> | 2009-09-11 21:19:12 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2009-09-11 21:19:12 +0000 |
commit | 4aa04b155a3212c9599814d9d8d1468f9fb6cae9 (patch) | |
tree | 23e2f4cea904a819471da8a5692ad4f57e59099c /clang/lib/Sema/SemaTemplateInstantiate.cpp | |
parent | a6bce00934046d2a3688e476ce8510a292a8728b (diff) | |
download | bcm5719-llvm-4aa04b155a3212c9599814d9d8d1468f9fb6cae9.tar.gz bcm5719-llvm-4aa04b155a3212c9599814d9d8d1468f9fb6cae9.zip |
Slight improvement for extern templates, so that an explicit
instantiation definition can follow an explicit instantiation
declaration. This is as far as I want to go with extern templates now,
but they will still need quite a bit more work to get all of the C++0x
semantics right.
llvm-svn: 81573
Diffstat (limited to 'clang/lib/Sema/SemaTemplateInstantiate.cpp')
-rw-r--r-- | clang/lib/Sema/SemaTemplateInstantiate.cpp | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/clang/lib/Sema/SemaTemplateInstantiate.cpp b/clang/lib/Sema/SemaTemplateInstantiate.cpp index 6a5235229a8..adc8a94e51e 100644 --- a/clang/lib/Sema/SemaTemplateInstantiate.cpp +++ b/clang/lib/Sema/SemaTemplateInstantiate.cpp @@ -820,11 +820,28 @@ Sema::InstantiateClassTemplateSpecialization( ClassTemplateSpec = cast<ClassTemplateSpecializationDecl>( ClassTemplateSpec->getCanonicalDecl()); - // We can only instantiate something that hasn't already been - // instantiated or specialized. Fail without any diagnostics: our - // caller will provide an error message. - if (ClassTemplateSpec->getSpecializationKind() != TSK_Undeclared) + // Check whether we have already instantiated or specialized this class + // template specialization. + if (ClassTemplateSpec->getSpecializationKind() != TSK_Undeclared) { + if (ClassTemplateSpec->getSpecializationKind() == + TSK_ExplicitInstantiationDeclaration && + TSK == TSK_ExplicitInstantiationDefinition) { + // An explicit instantiation definition follows an explicit instantiation + // declaration (C++0x [temp.explicit]p10); go ahead and perform the + // explicit instantiation. + ClassTemplateSpec->setSpecializationKind(TSK); + InstantiateClassTemplateSpecializationMembers( + /*FIXME?*/ClassTemplateSpec->getPointOfInstantiation(), + ClassTemplateSpec, + TSK); + return false; + } + + // We can only instantiate something that hasn't already been + // instantiated or specialized. Fail without any diagnostics: our + // caller will provide an error message. return true; + } ClassTemplateDecl *Template = ClassTemplateSpec->getSpecializedTemplate(); CXXRecordDecl *Pattern = 0; |