[PATCH] Partial specialization after class template instantiation.
Richard Smith
richard at metafoo.co.uk
Fri Oct 24 12:54:43 PDT 2014
================
Comment at: ../llvm/tools/clang/include/clang/Basic/DiagnosticSemaKinds.td:3395
@@ -3394,1 +3394,3 @@
"explicit specialization of %0 after instantiation">;
+def err_part_specialization_after_instantiation : Error<
+ "partial specialization of %0 after instantiation">;
----------------
Please use `partial_spec` or `partial_specialization` rather than `part_specialization`, like other diagnostics do.
================
Comment at: ../llvm/tools/clang/lib/Sema/SemaTemplate.cpp:6225
@@ +6224,3 @@
+ // unit in which such a use occurs; no diagnostic is required.
+ if (isPartialSpecialization) {
+ auto *ThisPartialSpec =
----------------
We don't need these checks for a redeclaration:
if (isPartialSpecialization && !PrevDecl) {
================
Comment at: ../llvm/tools/clang/lib/Sema/SemaTemplate.cpp:6227
@@ +6226,3 @@
+ auto *ThisPartialSpec =
+ static_cast<ClassTemplatePartialSpecializationDecl *>(Specialization);
+ for (const auto &S : ClassTemplate->specializations()) {
----------------
Use `cast`, not `static_cast`, here. (It'll assert if the type doesn't match.)
================
Comment at: ../llvm/tools/clang/lib/Sema/SemaTemplate.cpp:6232
@@ +6231,3 @@
+ S->hasDefinition() &&
+ !DeduceTemplateArguments(ThisPartialSpec, S->getTemplateArgs(), Info)) {
+ auto *InstantiatedFrom =
----------------
Hmm, what happens if we get an error outside of the immediate context during this deduction? Are we allowed to reject the program for that reason?
For instance:
template<typename T> struct X { typedef typename T::type type; };
template<typename T, typename U> struct A {};
A<int, int> Aint;
template<typename T> struct A<T, typename X<T>::type> {};
Do we provide a sufficiently useful template instantiation backtrace in this case?
http://reviews.llvm.org/D5744
More information about the cfe-commits
mailing list