aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaTemplateInstantiate.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2009-09-11 21:19:12 +0000
committerDouglas Gregor <dgregor@apple.com>2009-09-11 21:19:12 +0000
commit52604ab71a74b8ec481255dfeea7dc9dba63b1a5 (patch)
tree55ff684e046cb16edcf0341bc87cf41b05fc780a /lib/Sema/SemaTemplateInstantiate.cpp
parentbbbcdd9cc06b6078939129330ecc9bda3310984d (diff)
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@81573 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaTemplateInstantiate.cpp')
-rw-r--r--lib/Sema/SemaTemplateInstantiate.cpp25
1 files changed, 21 insertions, 4 deletions
diff --git a/lib/Sema/SemaTemplateInstantiate.cpp b/lib/Sema/SemaTemplateInstantiate.cpp
index 6a5235229a..adc8a94e51 100644
--- a/lib/Sema/SemaTemplateInstantiate.cpp
+++ b/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;