[clang] 3f643f1 - [clang-cl] Set _MSVC_LANG to 202002L with /std:c++20
Nico Weber via cfe-commits
cfe-commits at lists.llvm.org
Wed Dec 1 05:55:06 PST 2021
Author: Nico Weber
Date: 2021-12-01T08:54:41-05:00
New Revision: 3f643f166494826144bad05eaa3ae14508788df6
URL: https://github.com/llvm/llvm-project/commit/3f643f166494826144bad05eaa3ae14508788df6
DIFF: https://github.com/llvm/llvm-project/commit/3f643f166494826144bad05eaa3ae14508788df6.diff
LOG: [clang-cl] Set _MSVC_LANG to 202002L with /std:c++20
MSVC says this should be 202002L for /std:c++20, and of VS16.11
that's indeed the case (older versions warn that they don't
understand /std:c++20, and then cl.exe defaults to C++14 and
sets _MSVC_LANG to 201402 accordingly).
Differential Revision: https://reviews.llvm.org/D114867
Added:
Modified:
clang/lib/Basic/Targets/OSTargets.cpp
clang/test/Preprocessor/predefined-win-macros.c
Removed:
################################################################################
diff --git a/clang/lib/Basic/Targets/OSTargets.cpp b/clang/lib/Basic/Targets/OSTargets.cpp
index 4d9a462b51366..abf46fcb61a5d 100644
--- a/clang/lib/Basic/Targets/OSTargets.cpp
+++ b/clang/lib/Basic/Targets/OSTargets.cpp
@@ -182,7 +182,7 @@ static void addVisualCDefines(const LangOptions &Opts, MacroBuilder &Builder) {
if (Opts.isCompatibleWithMSVC(LangOptions::MSVC2015)) {
if (Opts.CPlusPlus20)
- Builder.defineMacro("_MSVC_LANG", "201705L");
+ Builder.defineMacro("_MSVC_LANG", "202002L");
else if (Opts.CPlusPlus17)
Builder.defineMacro("_MSVC_LANG", "201703L");
else if (Opts.CPlusPlus14)
diff --git a/clang/test/Preprocessor/predefined-win-macros.c b/clang/test/Preprocessor/predefined-win-macros.c
index 928ca6f4fa8d9..2ded133d271bc 100644
--- a/clang/test/Preprocessor/predefined-win-macros.c
+++ b/clang/test/Preprocessor/predefined-win-macros.c
@@ -45,9 +45,9 @@
// 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++2a -o - | FileCheck -match-full-lines %s --check-prefix=CHECK-MS-CPP2A
+// 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 201705L
+// CHECK-MS-CPP2A: #define _MSVC_LANG 202002L
// RUN: %clang_cc1 -triple i386-windows %s -E -dM -o - \
// RUN: | FileCheck -match-full-lines %s --check-prefix=CHECK-X86-WIN
More information about the cfe-commits
mailing list