From: David Majnemer Date: Tue, 28 Jun 2016 03:13:16 +0000 (+0000) Subject: [clang-cl] Define _MSVC_LANG X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e71aa188b2f2815be25a870c7a29dc1b8211cc2c;p=clang [clang-cl] Define _MSVC_LANG Recently, Microsoft added support for a flag, /std, which controls which version of the language rules MSVC should use. MSVC hasn't updated __cplusplus though. Instead, they added a new macro, _MSVC_LANG, which is defined in a similar fashion to __cplusplus. This is used to indicate which mode the compiler is in. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@273987 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Basic/Targets.cpp b/lib/Basic/Targets.cpp index c0e2290d38..440e291eef 100644 --- a/lib/Basic/Targets.cpp +++ b/lib/Basic/Targets.cpp @@ -734,6 +734,13 @@ protected: if (Opts.CPlusPlus11 && Opts.isCompatibleWithMSVC(LangOptions::MSVC2015)) Builder.defineMacro("_HAS_CHAR16_T_LANGUAGE_SUPPORT", Twine(1)); + + if (Opts.isCompatibleWithMSVC(LangOptions::MSVC2015)) { + if (Opts.CPlusPlus1z) + Builder.defineMacro("_MSVC_LANG", "201403L"); + else if (Opts.CPlusPlus14) + Builder.defineMacro("_MSVC_LANG", "201402L"); + } } if (Opts.MicrosoftExt) { diff --git a/test/Preprocessor/predefined-macros.c b/test/Preprocessor/predefined-macros.c index 53964061ce..7385cd2c93 100644 --- a/test/Preprocessor/predefined-macros.c +++ b/test/Preprocessor/predefined-macros.c @@ -1,10 +1,11 @@ // This test verifies that the correct macros are predefined. // -// RUN: %clang_cc1 %s -E -dM -triple i686-pc-win32 -fms-extensions -fms-compatibility \ -// RUN: -fms-compatibility-version=13.00 -o - | FileCheck -match-full-lines %s --check-prefix=CHECK-MS +// RUN: %clang_cc1 %s -x c++ -E -dM -triple i686-pc-win32 -fms-extensions -fms-compatibility \ +// RUN: -fms-compatibility-version=19.00 -std=c++1z -o - | FileCheck -match-full-lines %s --check-prefix=CHECK-MS // CHECK-MS: #define _INTEGRAL_MAX_BITS 64 // CHECK-MS: #define _MSC_EXTENSIONS 1 -// CHECK-MS: #define _MSC_VER 1300 +// CHECK-MS: #define _MSC_VER 1900 +// CHECK-MS: #define _MSVC_LANG 201403L // CHECK-MS: #define _M_IX86 600 // CHECK-MS: #define _M_IX86_FP 0 // CHECK-MS: #define _WIN32 1 @@ -13,11 +14,12 @@ // CHECK-MS-NOT: GNU // CHECK-MS-NOT: GXX // -// RUN: %clang_cc1 %s -E -dM -triple x86_64-pc-win32 -fms-extensions -fms-compatibility \ -// RUN: -fms-compatibility-version=13.00 -o - | FileCheck -match-full-lines %s --check-prefix=CHECK-MS64 +// RUN: %clang_cc1 %s -x c++ -E -dM -triple x86_64-pc-win32 -fms-extensions -fms-compatibility \ +// RUN: -fms-compatibility-version=19.00 -std=c++14 -o - | FileCheck -match-full-lines %s --check-prefix=CHECK-MS64 // CHECK-MS64: #define _INTEGRAL_MAX_BITS 64 // CHECK-MS64: #define _MSC_EXTENSIONS 1 -// CHECK-MS64: #define _MSC_VER 1300 +// CHECK-MS64: #define _MSC_VER 1900 +// CHECK-MS64: #define _MSVC_LANG 201402L // CHECK-MS64: #define _M_AMD64 100 // CHECK-MS64: #define _M_X64 100 // CHECK-MS64: #define _WIN64 1