[cfe-commits] [PATCH] Improved handling of 128-bit integer literals
Dmitri Gribenko
gribozavr at gmail.com
Fri Nov 30 11:01:20 PST 2012
On Fri, Nov 30, 2012 at 1:50 PM, Stephen Canon <scanon at apple.com> wrote:
> • fixed indentation
> • i32 and i64 will now have the correct size (instead of i32 being "long" even on LP64 platforms). We can't do this for i8 or i16 without more invasive changes, so those will wait for another patch.
> • MS literals get sign- or zero-extended as appropriate.
> • MS literal path is generally cleaner.
> • adopted hasInt128Type().
+ if (sizeof(__uint64_t) <= sizeof(int)) {
+ ASSERT_TRUE(PrintedStmtMSMatches(
+ "void A() { 1i64, -1i64, 1ui64; }",
+ "A", "1 , -1 , 1U"));
+ } else if (sizeof(__uint64_t) <= sizeof(long)) {
+ ASSERT_TRUE(PrintedStmtMSMatches(
+ "void A() { 1i64, -1i64, 1ui64; }",
+ "A", "1L , -1L , 1UL"));
+ } else {
+ ASSERT_TRUE(PrintedStmtMSMatches(
+ "void A() { 1i64, -1i64, 1ui64; }",
+ "A", "1LL , -1LL , 1ULL"));
+ }
This does not look portable. Why can't we fold sizeof(__uint64_t) to
8? And also, this assumes that clang will target the same platform as
host...
Dmitri
--
main(i,j){for(i=2;;i++){for(j=2;j<i;j++){if(!(i%j)){j=0;break;}}if
(j){printf("%d\n",i);}}} /*Dmitri Gribenko <gribozavr at gmail.com>*/
More information about the cfe-commits
mailing list