<div dir="ltr">On Tue, Sep 24, 2013 at 2:23 PM, Gao, Yunzhong <span dir="ltr"><<a href="mailto:yunzhong_gao@playstation.sony.com" target="_blank">yunzhong_gao@playstation.sony.com</a>></span> wrote:<br><div class="gmail_extra">
<div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Hi Richard,<br>
I am seeing warnings like this:<br>
Lexer.cpp: In member function 'const char* clang::Lexer::LexUDSuffix(clang::Token&, const char*, bool)':<br>
Lexer.cpp:1662:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]<br>
I wonder if an explicit cast is needed?<br></blockquote><div><br></div><div>No, just a better type. Or a better compiler (this warning was trivially a false positive because the signed value was a positive constant expression). But fixed in r191336, thanks.</div>
<div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
- Gao.<br>
<div><div class="h5"><br>
<br>
> -----Original Message-----<br>
> From: <a href="mailto:cfe-commits-bounces@cs.uiuc.edu">cfe-commits-bounces@cs.uiuc.edu</a> [mailto:<a href="mailto:cfe-commits-">cfe-commits-</a><br>
> <a href="mailto:bounces@cs.uiuc.edu">bounces@cs.uiuc.edu</a>] On Behalf Of Richard Smith<br>
> Sent: Monday, September 23, 2013 9:06 PM<br>
> To: <a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
> Subject: r191274 - Handle standard libraries that miss out the space when<br>
> defining the standard<br>
><br>
> Author: rsmith<br>
> Date: Mon Sep 23 23:06:10 2013<br>
> New Revision: 191274<br>
><br>
> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=191274&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=191274&view=rev</a><br>
> Log:<br>
> Handle standard libraries that miss out the space when defining the standard<br>
> literal operators. Also, for now, allow the proposed C++1y "il", "i", and "if"<br>
> suffixes too. (Will revert the latter if LWG decides not to go ahead with that<br>
> change after all.)<br>
><br>
> Modified:<br>
> cfe/trunk/lib/Lex/Lexer.cpp<br>
> cfe/trunk/lib/Lex/LiteralSupport.cpp<br>
> cfe/trunk/test/SemaCXX/cxx1y-user-defined-literals.cpp<br>
><br>
> Modified: cfe/trunk/lib/Lex/Lexer.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-" target="_blank">http://llvm.org/viewvc/llvm-</a><br>
> project/cfe/trunk/lib/Lex/Lexer.cpp?rev=191274&r1=191273&r2=191274&vie<br>
> w=diff<br>
> ==========================================================<br>
> ====================<br>
> --- cfe/trunk/lib/Lex/Lexer.cpp (original)<br>
> +++ cfe/trunk/lib/Lex/Lexer.cpp Mon Sep 23 23:06:10 2013<br>
> @@ -29,6 +29,7 @@<br>
> #include "clang/Basic/SourceManager.h"<br>
> #include "clang/Lex/CodeCompletionHandler.h"<br>
> #include "clang/Lex/LexDiagnostic.h"<br>
> +#include "clang/Lex/LiteralSupport.h"<br>
> #include "clang/Lex/Preprocessor.h"<br>
> #include "llvm/ADT/STLExtras.h"<br>
> #include "llvm/ADT/StringExtras.h"<br>
> @@ -1638,12 +1639,33 @@ const char *Lexer::LexUDSuffix(Token &Re<br>
> bool IsUDSuffix = false;<br>
> if (C == '_')<br>
> IsUDSuffix = true;<br>
> - else if (IsStringLiteral && C == 's' && getLangOpts().CPlusPlus1y) {<br>
> - // In C++1y, "s" is a valid ud-suffix for a string literal.<br>
> - unsigned NextSize;<br>
> - if (!isIdentifierBody(getCharAndSizeNoWarn(CurPtr + Size, NextSize,<br>
> - getLangOpts())))<br>
> - IsUDSuffix = true;<br>
> + else if (IsStringLiteral && getLangOpts().CPlusPlus1y) {<br>
> + // In C++1y, we need to look ahead a few characters to see if this is a<br>
> + // valid suffix for a string literal or a numeric literal (this could be<br>
> + // the 'operator""if' defining a numeric literal operator).<br>
> + const int MaxStandardSuffixLength = 3;<br>
> + char Buffer[MaxStandardSuffixLength] = { C };<br>
> + unsigned Consumed = Size;<br>
> + unsigned Chars = 1;<br>
> + while (true) {<br>
> + unsigned NextSize;<br>
> + char Next = getCharAndSizeNoWarn(CurPtr + Consumed, NextSize,<br>
> + getLangOpts());<br>
> + if (!isIdentifierBody(Next)) {<br>
> + // End of suffix. Check whether this is on the whitelist.<br>
> + IsUDSuffix = (Chars == 1 && Buffer[0] == 's') ||<br>
> + NumericLiteralParser::isValidUDSuffix(<br>
> + getLangOpts(), StringRef(Buffer, Chars));<br>
> + break;<br>
> + }<br>
> +<br>
> + if (Chars == MaxStandardSuffixLength)<br>
> + // Too long: can't be a standard suffix.<br>
> + break;<br>
> +<br>
> + Buffer[Chars++] = Next;<br>
> + Consumed += NextSize;<br>
> + }<br>
> }<br>
><br>
> if (!IsUDSuffix) {<br>
><br>
> Modified: cfe/trunk/lib/Lex/LiteralSupport.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-" target="_blank">http://llvm.org/viewvc/llvm-</a><br>
> project/cfe/trunk/lib/Lex/LiteralSupport.cpp?rev=191274&r1=191273&r2=19<br>
> 1274&view=diff<br>
> ==========================================================<br>
> ====================<br>
> --- cfe/trunk/lib/Lex/LiteralSupport.cpp (original)<br>
> +++ cfe/trunk/lib/Lex/LiteralSupport.cpp Mon Sep 23 23:06:10 2013<br>
> @@ -604,6 +604,9 @@ NumericLiteralParser::NumericLiteralPars<br>
> break;<br>
> }<br>
> }<br>
> + // "i", "if", and "il" are user-defined suffixes in C++1y.<br>
> + if (PP.getLangOpts().CPlusPlus1y && *s == 'i')<br>
> + break;<br>
> // fall through.<br>
> case 'j':<br>
> case 'J':<br>
> @@ -665,9 +668,11 @@ bool NumericLiteralParser::isValidUDSuff<br>
> return false;<br>
><br>
> // In C++1y, "s", "h", "min", "ms", "us", and "ns" are used in the library.<br>
> + // Per tweaked N3660, "il", "i", and "if" are also used in the library.<br>
> return llvm::StringSwitch<bool>(Suffix)<br>
> .Cases("h", "min", "s", true)<br>
> .Cases("ms", "us", "ns", true)<br>
> + .Cases("il", "i", "if", true)<br>
> .Default(false);<br>
> }<br>
><br>
><br>
> Modified: cfe/trunk/test/SemaCXX/cxx1y-user-defined-literals.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/cxx1y-" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/cxx1y-</a><br>
> user-defined-literals.cpp?rev=191274&r1=191273&r2=191274&view=diff<br>
> ==========================================================<br>
> ====================<br>
> --- cfe/trunk/test/SemaCXX/cxx1y-user-defined-literals.cpp (original)<br>
> +++ cfe/trunk/test/SemaCXX/cxx1y-user-defined-literals.cpp Mon Sep 23<br>
</div></div>> +++ 23:06:10 2013<br>
<div class="im">> @@ -8,15 +8,23 @@ namespace std {<br>
> using size_t = decltype(sizeof(0));<br>
><br>
> struct duration {};<br>
> - duration operator"" ns(unsigned long long);<br>
> - duration operator"" us(unsigned long long);<br>
> - duration operator"" ms(unsigned long long);<br>
> - duration operator"" s(unsigned long long);<br>
> - duration operator"" min(unsigned long long);<br>
> - duration operator"" h(unsigned long long);<br>
</div>> + duration operator""ns(unsigned long long); duration<br>
> + operator""us(unsigned long long); duration operator""ms(unsigned long<br>
> + long); duration operator""s(unsigned long long); duration<br>
> + operator""min(unsigned long long); duration operator""h(unsigned long<br>
<div class="im">> + long);<br>
><br>
> struct string {};<br>
> - string operator"" s(const char*, size_t);<br>
> + string operator""s(const char*, size_t);<br>
> +<br>
</div>> + template<typename T> struct complex {}; complex<float><br>
> + operator""if(long double); complex<float> operator""if(unsigned long<br>
> + long); complex<double> operator""i(long double); complex<double><br>
> + operator""i(unsigned long long); complex<long double><br>
> + operator""il(long double); complex<long double> operator""il(unsigned<br>
<div class="im">> + long long);<br>
> }<br>
><br>
> #else<br>
> @@ -29,4 +37,8 @@ char error = 'x's; // expected-error {{i int _1z = 1z; //<br>
> expected-error {{invalid suffix}} int _1b = 1b; // expected-error {{invalid<br>
> digit}}<br>
><br>
</div>> +complex<float> cf1 = 1if, cf2 = 2.if, cf3 = 0x3if; complex<double> cd1<br>
> += 1i, cd2 = 2.i, cd3 = 0b0110101i; complex<long double> cld1 = 1il,<br>
> +cld2 = <a href="http://2.il" target="_blank">2.il</a>, cld3 = 0047il;<br>
<div class=""><div class="h5">> +<br>
> #endif<br>
><br>
><br>
> _______________________________________________<br>
> cfe-commits mailing list<br>
> <a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
<br>
</div></div></blockquote></div><br></div></div>