[cfe-commits] r73263 - in /cfe/trunk: lib/Sema/SemaTemplateDeduction.cpp lib/Sema/SemaTemplateInstantiate.cpp www/cxx_status.html

Douglas Gregor dgregor at apple.com
Fri Jun 12 15:31:53 PDT 2009


Author: dgregor
Date: Fri Jun 12 17:31:52 2009
New Revision: 73263

URL: http://llvm.org/viewvc/llvm-project?rev=73263&view=rev
Log:
It looks like we've finished off matching of class template partial specializations; add comments and update the C++ status page

Modified:
    cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
    cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp
    cfe/trunk/www/cxx_status.html

Modified: cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp?rev=73263&r1=73262&r2=73263&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp Fri Jun 12 17:31:52 2009
@@ -618,12 +618,18 @@
   return Sema::TDK_Success;
 }
 
-
+/// \brief Perform template argument deduction to determine whether
+/// the given template arguments match the given class template
+/// partial specialization per C++ [temp.class.spec.match].
 Sema::TemplateDeductionResult
 Sema::DeduceTemplateArguments(ClassTemplatePartialSpecializationDecl *Partial,
                               const TemplateArgumentList &TemplateArgs,
                               TemplateDeductionInfo &Info) {
-  // Deduce the template arguments for the partial specialization
+  // C++ [temp.class.spec.match]p2:
+  //   A partial specialization matches a given actual template
+  //   argument list if the template arguments of the partial
+  //   specialization can be deduced from the actual template argument
+  //   list (14.8.2).
   llvm::SmallVector<TemplateArgument, 4> Deduced;
   Deduced.resize(Partial->getTemplateParameters()->size());
   if (TemplateDeductionResult Result

Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp?rev=73263&r1=73262&r2=73263&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp Fri Jun 12 17:31:52 2009
@@ -854,11 +854,14 @@
   const TemplateArgumentList *TemplateArgs 
     = &ClassTemplateSpec->getTemplateArgs();
 
-  // C++ [temp.class.spec]p7:
-  //   Partial specialization declarations themselves are not found by
-  //   name lookup. Rather, when the primary template name is used,
-  //   any previously declared partial specializations of the primary
-  //   template are also considered.
+  // C++ [temp.class.spec.match]p1:
+  //   When a class template is used in a context that requires an
+  //   instantiation of the class, it is necessary to determine
+  //   whether the instantiation is to be generated using the primary
+  //   template or one of the partial specializations. This is done by
+  //   matching the template arguments of the class template
+  //   specialization with the template argument lists of the partial
+  //   specializations.
   typedef std::pair<ClassTemplatePartialSpecializationDecl *,
                     TemplateArgumentList *> MatchResult;
   llvm::SmallVector<MatchResult, 4> Matched;
@@ -881,13 +884,28 @@
   }
 
   if (Matched.size() == 1) {
+    //   -- If exactly one matching specialization is found, the
+    //      instantiation is generated from that specialization.
     Pattern = Matched[0].first;
     TemplateArgs = Matched[0].second;
   } else if (Matched.size() > 1) {
+    //   -- If more than one matching specialization is found, the
+    //      partial order rules (14.5.4.2) are used to determine
+    //      whether one of the specializations is more specialized
+    //      than the others. If none of the specializations is more
+    //      specialized than all of the other matching
+    //      specializations, then the use of the class template is
+    //      ambiguous and the program is ill-formed.
     // FIXME: Implement partial ordering of class template partial
     // specializations.
     Diag(ClassTemplateSpec->getLocation(), 
          diag::unsup_template_partial_spec_ordering);
+  } else {
+    //   -- If no matches are found, the instantiation is generated
+    //      from the primary template.
+
+    // Since we initialized the pattern and template arguments from
+    // the primary template, there is nothing more we need to do here.
   }
 
   // Note that this is an instantiation.  

Modified: cfe/trunk/www/cxx_status.html
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/www/cxx_status.html?rev=73263&r1=73262&r2=73263&view=diff

==============================================================================
--- cfe/trunk/www/cxx_status.html (original)
+++ cfe/trunk/www/cxx_status.html Fri Jun 12 17:31:52 2009
@@ -1895,7 +1895,7 @@
   <td>      14.5.4.1 [temp.class.spec.match]</td>
   <td class="na" align="center">N/A</td>  
   <td class="na" align="center">N/A</td>
-  <td class="medium" align="center"></td>
+  <td class="complete" align="center"></td>
   <td class="na" align="center">N/A</td>
   <td></td>
 </tr>





More information about the cfe-commits mailing list