diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2012-03-09 08:00:36 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2012-03-09 08:00:36 +0000 |
commit | 36f5cfe4df32af6c5fe01228102512996f566f9d (patch) | |
tree | 28e2c2562f781f6dbe711d15a00af596b21b9c9b /include/clang | |
parent | 8a26fc15d4647da863f0cca73a203823b01da7e5 (diff) |
Support for raw and template forms of numeric user-defined literals,
and lots of tidying up.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152392 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang')
-rw-r--r-- | include/clang/Basic/DiagnosticCommonKinds.td | 4 | ||||
-rw-r--r-- | include/clang/Basic/DiagnosticSemaKinds.td | 8 | ||||
-rw-r--r-- | include/clang/Sema/Lookup.h | 5 | ||||
-rw-r--r-- | include/clang/Sema/Sema.h | 38 |
4 files changed, 46 insertions, 9 deletions
diff --git a/include/clang/Basic/DiagnosticCommonKinds.td b/include/clang/Basic/DiagnosticCommonKinds.td index c649cfcf7c..103fc00b40 100644 --- a/include/clang/Basic/DiagnosticCommonKinds.td +++ b/include/clang/Basic/DiagnosticCommonKinds.td @@ -43,6 +43,10 @@ def err_expected_colon_after_setter_name : Error< "must end with ':'">; def err_invalid_string_udl : Error< "string literal with user-defined suffix cannot be used here">; +def err_invalid_character_udl : Error< + "character literal with user-defined suffix cannot be used here">; +def err_invalid_numeric_udl : Error< + "numeric literal with user-defined suffix cannot be used here">; // Parse && Sema def ext_no_declarators : ExtWarn<"declaration does not declare anything">, diff --git a/include/clang/Basic/DiagnosticSemaKinds.td b/include/clang/Basic/DiagnosticSemaKinds.td index 0f5e7670ac..a5a597bdb9 100644 --- a/include/clang/Basic/DiagnosticSemaKinds.td +++ b/include/clang/Basic/DiagnosticSemaKinds.td @@ -2195,7 +2195,13 @@ def err_addr_ovl_not_func_ptrref : Error< "address of overloaded function %0 cannot be converted to type %1">; def err_addr_ovl_no_qualifier : Error< "can't form member pointer of type %0 without '&' and class name">; - + +// C++11 Literal Operators +def err_ovl_no_viable_literal_operator : Error< + "no matching literal operator for call to %0" + "%select{| with argument of type %2| with arguments of types %2 and %3}1" + "%select{| or 'const char *', and no matching literal operator template}4">; + // C++ Template Declarations def err_template_param_shadow : Error< "declaration of %0 shadows template parameter">; diff --git a/include/clang/Sema/Lookup.h b/include/clang/Sema/Lookup.h index e7a6f15c0e..d35711a361 100644 --- a/include/clang/Sema/Lookup.h +++ b/include/clang/Sema/Lookup.h @@ -550,6 +550,11 @@ public: return *I++; } + /// Restart the iteration. + void restart() { + I = Results.begin(); + } + /// Erase the last element returned from this iterator. void erase() { Results.Decls.erase(--I); diff --git a/include/clang/Sema/Sema.h b/include/clang/Sema/Sema.h index ae4485c856..86634d128c 100644 --- a/include/clang/Sema/Sema.h +++ b/include/clang/Sema/Sema.h @@ -1552,7 +1552,8 @@ public: void AddFunctionCandidates(const UnresolvedSetImpl &Functions, llvm::ArrayRef<Expr *> Args, OverloadCandidateSet& CandidateSet, - bool SuppressUserConversions = false); + bool SuppressUserConversions = false, + TemplateArgumentListInfo *ExplicitTemplateArgs = 0); void AddMethodCandidate(DeclAccessPair FoundDecl, QualType ObjectType, Expr::Classification ObjectClassification, @@ -1794,6 +1795,22 @@ public: ForRedeclaration }; + /// \brief The possible outcomes of name lookup for a literal operator. + enum LiteralOperatorLookupResult { + /// \brief The lookup resulted in an error. + LOLR_Error, + /// \brief The lookup found a single 'cooked' literal operator, which + /// expects a normal literal to be built and passed to it. + LOLR_Cooked, + /// \brief The lookup found a single 'raw' literal operator, which expects + /// a string literal containing the spelling of the literal token. + LOLR_Raw, + /// \brief The lookup found an overload set of literal operator templates, + /// which expect the characters of the spelling of the literal token to be + /// passed as a non-type template argument pack. + LOLR_Template + }; + SpecialMemberOverloadResult *LookupSpecialMember(CXXRecordDecl *D, CXXSpecialMember SM, bool ConstArg, @@ -1857,6 +1874,10 @@ public: unsigned ThisQuals); CXXDestructorDecl *LookupDestructor(CXXRecordDecl *Class); + LiteralOperatorLookupResult LookupLiteralOperator(Scope *S, LookupResult &R, + ArrayRef<QualType> ArgTys, + bool AllowRawAndTemplate); + void ArgumentDependentLookup(DeclarationName Name, bool Operator, SourceLocation Loc, llvm::ArrayRef<Expr *> Args, @@ -2545,15 +2566,16 @@ public: const DeclarationNameInfo &NameInfo, NamedDecl *D); - ExprResult BuildLiteralOperatorCall(IdentifierInfo *UDSuffix, - SourceLocation UDSuffixLoc, + ExprResult BuildLiteralOperatorCall(LookupResult &R, + DeclarationNameInfo &SuffixInfo, ArrayRef<Expr*> Args, - SourceLocation LitEndLoc); + SourceLocation LitEndLoc, + TemplateArgumentListInfo *ExplicitTemplateArgs = 0); ExprResult ActOnPredefinedExpr(SourceLocation Loc, tok::TokenKind Kind); ExprResult ActOnIntegerConstant(SourceLocation Loc, uint64_t Val); - ExprResult ActOnNumericConstant(const Token &Tok); - ExprResult ActOnCharacterConstant(const Token &Tok); + ExprResult ActOnNumericConstant(const Token &Tok, Scope *UDLScope = 0); + ExprResult ActOnCharacterConstant(const Token &Tok, Scope *UDLScope = 0); ExprResult ActOnParenExpr(SourceLocation L, SourceLocation R, Expr *E); ExprResult ActOnParenListExpr(SourceLocation L, SourceLocation R, @@ -2561,8 +2583,8 @@ public: /// ActOnStringLiteral - The specified tokens were lexed as pasted string /// fragments (e.g. "foo" "bar" L"baz"). - ExprResult ActOnStringLiteral(const Token *StringToks, - unsigned NumStringToks); + ExprResult ActOnStringLiteral(const Token *StringToks, unsigned NumStringToks, + Scope *UDLScope = 0); ExprResult ActOnGenericSelectionExpr(SourceLocation KeyLoc, SourceLocation DefaultLoc, |