diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2012-03-08 08:45:32 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2012-03-08 08:45:32 +0000 |
commit | b453ad3214d00acc51c9aa702c76c58354d84b84 (patch) | |
tree | fbf7b0f3c7bf20b921b60a43a544a87c8968cc05 /lib/Lex/LiteralSupport.cpp | |
parent | aae1d8bd6f2482e0bf13a29d5b0cb7639080974d (diff) | |
download | clang-b453ad3214d00acc51c9aa702c76c58354d84b84.tar.gz clang-b453ad3214d00acc51c9aa702c76c58354d84b84.tar.bz2 clang-b453ad3214d00acc51c9aa702c76c58354d84b84.tar.xz |
Add support for cooked forms of user-defined-integer-literal and
user-defined-floating-literal. Support for raw forms of these literals
to follow.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152302 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Lex/LiteralSupport.cpp')
-rw-r--r-- | lib/Lex/LiteralSupport.cpp | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/lib/Lex/LiteralSupport.cpp b/lib/Lex/LiteralSupport.cpp index e0bdc5f858..901d96d21a 100644 --- a/lib/Lex/LiteralSupport.cpp +++ b/lib/Lex/LiteralSupport.cpp @@ -333,6 +333,10 @@ static void EncodeUCNEscape(const char *&ThisTokBuf, const char *ThisTokEnd, /// decimal-constant integer-suffix /// octal-constant integer-suffix /// hexadecimal-constant integer-suffix +/// user-defiend-integer-literal: [C++11 lex.ext] +/// decimal-literal ud-suffix +/// octal-literal ud-suffix +/// hexadecimal-literal ud-suffix /// decimal-constant: /// nonzero-digit /// decimal-constant digit @@ -382,6 +386,7 @@ NumericLiteralParser(const char *begin, const char *end, s = DigitsBegin = begin; saw_exponent = false; saw_period = false; + saw_ud_suffix = false; isLong = false; isUnsigned = false; isLongLong = false; @@ -519,13 +524,20 @@ NumericLiteralParser(const char *begin, const char *end, isImaginary = true; continue; // Success. } - // If we reached here, there was an error. + // If we reached here, there was an error or a ud-suffix. break; } - // Report an error if there are any. if (s != ThisTokEnd) { - PP.Diag(PP.AdvanceToTokenCharacter(TokLoc, s-begin), + if (PP.getLangOptions().CPlusPlus0x && s == SuffixBegin && *s == '_') { + // We have a ud-suffix! By C++11 [lex.ext]p10, ud-suffixes not starting + // with an '_' are ill-formed. + saw_ud_suffix = true; + return; + } + + // Report an error if there are any. + PP.Diag(PP.AdvanceToTokenCharacter(TokLoc, SuffixBegin-begin), isFPConstant ? diag::err_invalid_suffix_float_constant : diag::err_invalid_suffix_integer_constant) << StringRef(SuffixBegin, ThisTokEnd-SuffixBegin); |