diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2012-03-04 09:41:16 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2012-03-04 09:41:16 +0000 |
commit | 72eebee0cb6a0bc09a20e95db19e0efad4b41beb (patch) | |
tree | a2bc72a105169b78de022d8f8925e5d348cd26f3 /clang/lib/Sema/SemaDeclCXX.cpp | |
parent | 420525ce3b93e43c5438c7d6f958084fcb6a02cc (diff) | |
download | bcm5719-llvm-72eebee0cb6a0bc09a20e95db19e0efad4b41beb.tar.gz bcm5719-llvm-72eebee0cb6a0bc09a20e95db19e0efad4b41beb.zip |
Add tests for [over.literal]. Fix a few bugs which were exposed by the tests.
llvm-svn: 151997
Diffstat (limited to 'clang/lib/Sema/SemaDeclCXX.cpp')
-rw-r--r-- | clang/lib/Sema/SemaDeclCXX.cpp | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp index 4f0e1609509..34648805f93 100644 --- a/clang/lib/Sema/SemaDeclCXX.cpp +++ b/clang/lib/Sema/SemaDeclCXX.cpp @@ -9297,12 +9297,17 @@ bool Sema::CheckLiteralOperatorDeclaration(FunctionDecl *FnDecl) { return true; } + if (FnDecl->isExternC()) { + Diag(FnDecl->getLocation(), diag::err_literal_operator_extern_c); + return true; + } + bool Valid = false; // 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()) { + if (FunctionTemplateDecl *TpDecl = FnDecl->getDescribedFunctionTemplate()) { + if (FnDecl->param_size() == 0) { // Must have only one template parameter TemplateParameterList *Params = TpDecl->getTemplateParameters(); if (Params->size() == 1) { @@ -9315,11 +9320,11 @@ bool Sema::CheckLiteralOperatorDeclaration(FunctionDecl *FnDecl) { Valid = true; } } - } else { + } else if (FnDecl->param_size()) { // Check the first parameter FunctionDecl::param_iterator Param = FnDecl->param_begin(); - QualType T = (*Param)->getType(); + QualType T = (*Param)->getType().getUnqualifiedType(); // unsigned long long int, long double, and any character type are allowed // as the only parameters. @@ -9339,7 +9344,7 @@ bool Sema::CheckLiteralOperatorDeclaration(FunctionDecl *FnDecl) { if (!PT) goto FinishedParams; T = PT->getPointeeType(); - if (!T.isConstQualified()) + if (!T.isConstQualified() || T.isVolatileQualified()) goto FinishedParams; T = T.getUnqualifiedType(); |