]> granicus.if.org Git - clang/commitdiff
[MS] Move hex long long sign compat hack to -fms-compatibility
authorReid Kleckner <rnk@google.com>
Tue, 4 Oct 2016 15:57:49 +0000 (15:57 +0000)
committerReid Kleckner <rnk@google.com>
Tue, 4 Oct 2016 15:57:49 +0000 (15:57 +0000)
Treating large 0x*LL literals as signed instead of unsigned is not a
conforming language extension, so move it out of -fms-extensions.

Came up in PR30605

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@283227 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaExpr.cpp
test/SemaCXX/MicrosoftCompatibility.cpp
test/SemaCXX/MicrosoftExtensions.cpp

index 76d88c1d261fadbba7030c165e96352325ca4475..bf2ee03a0d5462be464fa7ca78c060bef39df703 100644 (file)
@@ -3518,7 +3518,7 @@ ExprResult Sema::ActOnNumericConstant(const Token &Tok, Scope *UDLScope) {
           // To be compatible with MSVC, hex integer literals ending with the
           // LL or i64 suffix are always signed in Microsoft mode.
           if (!Literal.isUnsigned && (ResultVal[LongLongSize-1] == 0 ||
-              (getLangOpts().MicrosoftExt && Literal.isLongLong)))
+              (getLangOpts().MSVCCompat && Literal.isLongLong)))
             Ty = Context.LongLongTy;
           else if (AllowUnsigned)
             Ty = Context.UnsignedLongLongTy;
index fe8e8f77accbeefd3f6dadfd2f71f0c045c15f2c..566086810885bb7169d011e88c498ef60c92010e 100644 (file)
@@ -242,3 +242,14 @@ namespace IntToNullPtrConv {
   template<int N> int *get_n() { return N; }   // expected-warning {{expression which evaluates to zero treated as a null pointer constant}}
   int *g_nullptr = get_n<0>();  // expected-note {{in instantiation of function template specialization}}
 }
+
+namespace signed_hex_i64 {
+void f(long long);
+void f(int);
+void g() {
+  // 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);
+}
+}
index e10deadf7c7f52c62609764efd0559bb823c9e24..e12dea1fb62032b0bd7aa96f38e3354bb9c5c2be 100644 (file)
@@ -158,19 +158,16 @@ void m1() {
 }
 
 
-
-
-
-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);
+namespace signed_hex_i64 {
+void f(long long); // expected-note {{candidate function}}
+void f(int); // expected-note {{candidate function}}
+void g() {
+  // This used to be controlled by -fms-extensions, but it is now under
+  // -fms-compatibility.
+  f(0xffffffffffffffffLL); // expected-error {{call to 'f' is ambiguous}}
   f(0xffffffffffffffffi64);
 }
+}
 
 // Enumeration types with a fixed underlying type.
 const int seventeen = 17;