[cfe-commits] r123231 - in /cfe/trunk: lib/Sema/SemaExpr.cpp test/Sema/MicrosoftExtensions.cpp
Francois Pichet
pichet2000 at gmail.com
Tue Jan 11 04:23:00 PST 2011
Author: fpichet
Date: Tue Jan 11 06:23:00 2011
New Revision: 123231
URL: http://llvm.org/viewvc/llvm-project?rev=123231&view=rev
Log:
In Microsoft mode, force 64 bit hex integer constants to signed type if the LL or i64 suffix is used. This MSVC behavior.
For example:
void f(long long){ printf("long long"); }
void f(unsigned long long) { printf("unsigned long long"); }
int main() {
f(0xffffffffffffffffLL);
}
Will print "long long" using MSVC.
This patch also fixes 16 compile errors related to overloading issues when parsing the MSVC 2008 C++ standard lib.
Added:
cfe/trunk/test/Sema/MicrosoftExtensions.cpp
Modified:
cfe/trunk/lib/Sema/SemaExpr.cpp
Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=123231&r1=123230&r2=123231&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Tue Jan 11 06:23:00 2011
@@ -2497,7 +2497,8 @@
// Does it fit in a unsigned long long?
if (ResultVal.isIntN(LongLongSize)) {
// Does it fit in a signed long long?
- if (!Literal.isUnsigned && ResultVal[LongLongSize-1] == 0)
+ if (!Literal.isUnsigned && (ResultVal[LongLongSize-1] == 0 ||
+ (getLangOptions().Microsoft && Literal.isLongLong)))
Ty = Context.LongLongTy;
else if (AllowUnsigned)
Ty = Context.UnsignedLongLongTy;
Added: cfe/trunk/test/Sema/MicrosoftExtensions.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/MicrosoftExtensions.cpp?rev=123231&view=auto
==============================================================================
--- cfe/trunk/test/Sema/MicrosoftExtensions.cpp (added)
+++ cfe/trunk/test/Sema/MicrosoftExtensions.cpp Tue Jan 11 06:23:00 2011
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 %s -fsyntax-only -Wno-unused-value -Wmicrosoft -fms-extensions -verify
+
+
+void f(long long);
+void f(int);
+
+int main()
+{
+ // This is an ambiguous call in standard C++.
+ // This calls f(long long) in Microsoft mode because LL is always signed.
+ f(0xffffffffffffffffLL);
+ f(0xffffffffffffffffi64);
+}
More information about the cfe-commits
mailing list