[cfe-commits] [PATCH] Win64 (esp. mingw64) stuff

NAKAMURA Takumi geek4civic at gmail.com
Tue Jan 18 05:45:36 PST 2011


Good evening, Doug!

2011/1/18 Douglas Gregor <dgregor at apple.com>:
> I don't think we want this change in behavior. Previously, when sizeof(int) == sizeof(long), we would get 'int' rather than 'long', and we want to keep that. Please check sizeof(int) first, then sizeof(long), then sizeof(long long).

Thank you!

Sure, that makes sense. An improved patch is attached.
Checked on x86_64-centos5, mingw(x86-64 and i686), and msvc10.

...Takumi
-------------- next part --------------
From 776be409324aa76112271c2dfc6a57599831d0da Mon Sep 17 00:00:00 2001
From: NAKAMURA Takumi <geek4civic at gmail.com>
Date: Thu, 16 Dec 2010 01:35:29 +0900
Subject: [PATCH 1/9] lib/Sema/SemaExpr.cpp: __null should be LongLongTy on LLP64 Win64.

---
 lib/Sema/SemaExpr.cpp |   11 +++++++++--
 1 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index 45e0c33..16a20de 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -8581,10 +8581,17 @@ ExprResult Sema::ActOnGNUNullExpr(SourceLocation TokenLoc) {
   // The type of __null will be int or long, depending on the size of
   // pointers on the target.
   QualType Ty;
-  if (Context.Target.getPointerWidth(0) == Context.Target.getIntWidth())
+  unsigned pw = Context.Target.getPointerWidth(0);
+  if (pw == Context.Target.getIntWidth())
     Ty = Context.IntTy;
-  else
+  else if (pw == Context.Target.getLongWidth())
     Ty = Context.LongTy;
+  else if (pw == Context.Target.getLongLongWidth())
+    Ty = Context.LongLongTy;
+  else {
+    assert(!"I don't know size of pointer!");
+    Ty = Context.IntTy;
+  }
 
   return Owned(new (Context) GNUNullExpr(Ty, TokenLoc));
 }
-- 
1.7.1.GIT



More information about the cfe-commits mailing list