From 216c278982ea8dd76d5d7d1ad0dcb39d3c5226e3 Mon Sep 17 00:00:00 2001 From: Sean Hunt Date: Wed, 7 Apr 2010 23:11:06 +0000 Subject: [PATCH] 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100716 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Sema/SemaDeclCXX.cpp | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp index e8909d63b4..298ce066f7 100644 --- a/lib/Sema/SemaDeclCXX.cpp +++ b/lib/Sema/SemaDeclCXX.cpp @@ -5044,11 +5044,28 @@ bool Sema::CheckLiteralOperatorDeclaration(FunctionDecl *FnDecl) { bool Valid = false; - // FIXME: Check for the one valid template signature - // template type operator "" name(); - - if (FunctionDecl::param_iterator Param = FnDecl->param_begin()) { + // template 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(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 -- 2.40.0