summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
authorAlexis Hunt <alercah@gmail.com>2010-04-07 23:11:06 +0000
committerAlexis Hunt <alercah@gmail.com>2010-04-07 23:11:06 +0000
commit7dd2617e9c84c232a250d31cb819524d48c4d29a (patch)
treee0f76751cb59608e3e39ba3aab37449f4c582247 /clang
parent4b1b4205eda2c3ef88bace485c851d2fe26a8976 (diff)
downloadbcm5719-llvm-7dd2617e9c84c232a250d31cb819524d48c4d29a.tar.gz
bcm5719-llvm-7dd2617e9c84c232a250d31cb819524d48c4d29a.zip
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. llvm-svn: 100716
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/Sema/SemaDeclCXX.cpp25
1 files changed, 21 insertions, 4 deletions
diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index e8909d63b41..298ce066f7c 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/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 <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
OpenPOWER on IntegriCloud