[cfe-commits] [REVIEW] Literal operator semantic improvements
Douglas Gregor
dgregor at apple.com
Tue Jan 12 17:10:43 PST 2010
On Jan 7, 2010, at 12:53 AM, Sean Hunt wrote:
> This patch actually gets CXX literal operator names into the
> DeclarationNameTable (oops), and also adds semantic analysis of the
> literal operator's signature.
A couple of comments:
+/// CheckLiteralOperatorDeclaration - Check whether the declaration
+/// of this literal operator function is well-formed. If so, returns
+/// false; otherwise, emits appropriate diagnostics and returns true.
+bool Sema::CheckLiteralOperatorDeclaration(FunctionDecl *FnDecl) {
+ DeclContext *DC = FnDecl->getDeclContext();
+ if (!isa<NamespaceDecl>(DC) && !isa<TranslationUnitDecl>(DC)) {
+ Diag(FnDecl->getLocation(),
diag::err_literal_operator_outside_namespace)
+ << FnDecl->getDeclName();
+ return true;
+ }
Can a literal operator be declared in a linkage-specification, e.g.,
extern "C++" {
void operator "" good (char16_t);
}
?
This code would reject that.
+ // The second and final parameter must be an std::size_t
+ if (Context.hasSameType((*Param)->getType(), Context.getSizeType
()) &&
+ ++Param == FnDecl->param_end())
+ Valid = true;
It can probably be a const-qualified std::size_t, right? We allow this
for, e.g., operator new's size_t parameter.
Everything else seems reasonable. Please go ahead and commit once
those issues above are resolved.
- Doug
More information about the cfe-commits
mailing list