[PATCH] D114952: [clang-cl] Define _MSVC_LANG for -std=c++2b
Nico Weber via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Dec 2 06:20:37 PST 2021
thakis created this revision.
thakis added a reviewer: hans.
thakis requested review of this revision.
This matches the value that msvc v19.29 VS16.11 uses for
_MSVC_LANG with /std:c++latest.
https://reviews.llvm.org/D114952
Files:
clang/lib/Basic/Targets/OSTargets.cpp
clang/test/Preprocessor/predefined-win-macros.c
Index: clang/test/Preprocessor/predefined-win-macros.c
===================================================================
--- clang/test/Preprocessor/predefined-win-macros.c
+++ clang/test/Preprocessor/predefined-win-macros.c
@@ -45,9 +45,14 @@
// CHECK-MS-NOT: GXX
// RUN: %clang_cc1 %s -x c++ -E -dM -triple i686-pc-win32 -fms-extensions -fms-compatibility \
-// RUN: -fms-compatibility-version=19.00 -std=c++20 -o - | FileCheck -match-full-lines %s --check-prefix=CHECK-MS-CPP2A
-// CHECK-MS-CPP2A: #define _MSC_VER 1900
-// CHECK-MS-CPP2A: #define _MSVC_LANG 202002L
+// RUN: -fms-compatibility-version=19.00 -std=c++20 -o - | FileCheck -match-full-lines %s --check-prefix=CHECK-MS-CPP20
+// CHECK-MS-CPP20: #define _MSC_VER 1900
+// CHECK-MS-CPP20: #define _MSVC_LANG 202002L
+
+// RUN: %clang_cc1 %s -x c++ -E -dM -triple i686-pc-win32 -fms-extensions -fms-compatibility \
+// RUN: -fms-compatibility-version=19.00 -std=c++2b -o - | FileCheck -match-full-lines %s --check-prefix=CHECK-MS-CPP2B
+// CHECK-MS-CPP2B: #define _MSC_VER 1900
+// CHECK-MS-CPP2B: #define _MSVC_LANG 202004L
// RUN: %clang_cc1 -triple i386-windows %s -E -dM -o - \
// RUN: | FileCheck -match-full-lines %s --check-prefix=CHECK-X86-WIN
Index: clang/lib/Basic/Targets/OSTargets.cpp
===================================================================
--- clang/lib/Basic/Targets/OSTargets.cpp
+++ clang/lib/Basic/Targets/OSTargets.cpp
@@ -181,7 +181,9 @@
Builder.defineMacro("_HAS_CHAR16_T_LANGUAGE_SUPPORT", Twine(1));
if (Opts.isCompatibleWithMSVC(LangOptions::MSVC2015)) {
- if (Opts.CPlusPlus20)
+ if (Opts.CPlusPlus2b)
+ Builder.defineMacro("_MSVC_LANG", "202004L");
+ else if (Opts.CPlusPlus20)
Builder.defineMacro("_MSVC_LANG", "202002L");
else if (Opts.CPlusPlus17)
Builder.defineMacro("_MSVC_LANG", "201703L");
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D114952.391303.patch
Type: text/x-patch
Size: 1882 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20211202/d5bc5059/attachment.bin>
More information about the cfe-commits
mailing list