[PATCH] D99663: [clang-cl] [Sema] Do not prefer integral conversion over floating-to-integral for MS compatibility 19.28 and higher.
Marek Kurdej via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Apr 1 23:58:31 PDT 2021
This revision was automatically updated to reflect the committed changes.
Closed by commit rG2ec7f639c49f: [clang-cl] [Sema] Do not prefer integral conversion over floating-to-integral… (authored by curdeius).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D99663/new/
https://reviews.llvm.org/D99663
Files:
clang/include/clang/Basic/LangOptions.h
clang/lib/Sema/SemaOverload.cpp
clang/test/SemaCXX/MicrosoftCompatibility.cpp
Index: clang/test/SemaCXX/MicrosoftCompatibility.cpp
===================================================================
--- clang/test/SemaCXX/MicrosoftCompatibility.cpp
+++ clang/test/SemaCXX/MicrosoftCompatibility.cpp
@@ -1,3 +1,5 @@
+// RUN: %clang_cc1 %s -triple i686-pc-win32 -fsyntax-only -std=c++11 -Wmicrosoft -verify -fms-compatibility -fexceptions -fcxx-exceptions -fms-compatibility-version=19.28
+// RUN: %clang_cc1 %s -triple i686-pc-win32 -fsyntax-only -std=c++11 -Wmicrosoft -verify -fms-compatibility -fexceptions -fcxx-exceptions -fms-compatibility-version=19.27
// RUN: %clang_cc1 %s -triple i686-pc-win32 -fsyntax-only -std=c++11 -Wmicrosoft -verify -fms-compatibility -fexceptions -fcxx-exceptions -fms-compatibility-version=19.00
// RUN: %clang_cc1 %s -triple i686-pc-win32 -fsyntax-only -std=c++11 -Wmicrosoft -verify -fms-compatibility -fexceptions -fcxx-exceptions -fms-compatibility-version=18.00
@@ -28,12 +30,20 @@
void f(float a);
void f(int a);
+#if _MSC_VER >= 1928
+// expected-note at -3 2 {{candidate function}}
+// expected-note at -3 2 {{candidate function}}
+#endif
void test()
{
long a = 0;
f((long)0);
- f(a);
+ f(a);
+#if _MSC_VER >= 1928
+// expected-error at -3 {{call to 'f' is ambiguous}}
+// expected-error at -3 {{call to 'f' is ambiguous}}
+#endif
}
}
Index: clang/lib/Sema/SemaOverload.cpp
===================================================================
--- clang/lib/Sema/SemaOverload.cpp
+++ clang/lib/Sema/SemaOverload.cpp
@@ -4106,7 +4106,7 @@
}
}
- // In Microsoft mode, prefer an integral conversion to a
+ // In Microsoft mode (below 19.28), prefer an integral conversion to a
// floating-to-integral conversion if the integral conversion
// is between types of the same size.
// For example:
@@ -4118,7 +4118,9 @@
// }
// Here, MSVC will call f(int) instead of generating a compile error
// as clang will do in standard mode.
- if (S.getLangOpts().MSVCCompat && SCS1.Second == ICK_Integral_Conversion &&
+ if (S.getLangOpts().MSVCCompat &&
+ !S.getLangOpts().isCompatibleWithMSVC(LangOptions::MSVC2019_8) &&
+ SCS1.Second == ICK_Integral_Conversion &&
SCS2.Second == ICK_Floating_Integral &&
S.Context.getTypeSize(SCS1.getFromType()) ==
S.Context.getTypeSize(SCS1.getToType(2)))
Index: clang/include/clang/Basic/LangOptions.h
===================================================================
--- clang/include/clang/Basic/LangOptions.h
+++ clang/include/clang/Basic/LangOptions.h
@@ -124,6 +124,7 @@
MSVC2017_5 = 1912,
MSVC2017_7 = 1914,
MSVC2019 = 1920,
+ MSVC2019_8 = 1928,
};
enum SYCLMajorVersion {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D99663.334907.patch
Type: text/x-patch
Size: 2675 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210402/dba51c70/attachment.bin>
More information about the cfe-commits
mailing list