[cfe-commits] r100716 - /cfe/trunk/lib/Sema/SemaDeclCXX.cpp

Sean Hunt rideau3 at gmail.com
Wed Apr 7 16:11:06 PDT 2010


Author: coppro
Date: Wed Apr  7 18:11:06 2010
New Revision: 100716

URL: http://llvm.org/viewvc/llvm-project?rev=100716&view=rev
Log:
Implement checking for template literal operator functions. This
code won't actually get used yet because we don't handle non-type
parameter packs, but when we do, this code should jump in and work.

Modified:
    cfe/trunk/lib/Sema/SemaDeclCXX.cpp

Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=100716&r1=100715&r2=100716&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Wed Apr  7 18:11:06 2010
@@ -5044,11 +5044,28 @@
 
   bool Valid = false;
 
-  // FIXME: Check for the one valid template signature
-  // template <char...> type operator "" name();
-
-  if (FunctionDecl::param_iterator Param = FnDecl->param_begin()) {
+  // template <char...> type operator "" name() is the only valid template
+  // signature, and the only valid signature with no parameters.
+  if (FnDecl->param_size() == 0) {
+    if (FunctionTemplateDecl *TpDecl = FnDecl->getDescribedFunctionTemplate()) {
+      // Must have only one template parameter
+      TemplateParameterList *Params = TpDecl->getTemplateParameters();
+      if (Params->size() == 1) {
+        NonTypeTemplateParmDecl *PmDecl =
+          cast<NonTypeTemplateParmDecl>(Params->getParam(0));
+
+        // The template parameter must be a char parameter pack.
+        // FIXME: This test will always fail because non-type parameter packs
+        //   have not been implemented.
+        if (PmDecl && PmDecl->isTemplateParameterPack() &&
+            Context.hasSameType(PmDecl->getType(), Context.CharTy))
+          Valid = true;
+      }
+    }
+  } else {
     // Check the first parameter
+    FunctionDecl::param_iterator Param = FnDecl->param_begin();
+
     QualType T = (*Param)->getType();
 
     // unsigned long long int, long double, and any character type are allowed





More information about the cfe-commits mailing list