]> granicus.if.org Git - clang/commitdiff
[MS] Update _MSVC_LANG values for C++17 and C++2a
authorReid Kleckner <rnk@google.com>
Mon, 23 Jul 2018 17:44:00 +0000 (17:44 +0000)
committerReid Kleckner <rnk@google.com>
Mon, 23 Jul 2018 17:44:00 +0000 (17:44 +0000)
Fixes PR38262

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

lib/Basic/Targets/OSTargets.h
test/Preprocessor/predefined-macros.c
test/Preprocessor/predefined-win-macros.c [new file with mode: 0644]

index cb7f089c0956ebb6810ea4f21258eb9337cd12d3..d0354784acf9b8679f75bbed0e6b3bb2240a1fdd 100644 (file)
@@ -617,8 +617,10 @@ protected:
         Builder.defineMacro("_HAS_CHAR16_T_LANGUAGE_SUPPORT", Twine(1));
 
       if (Opts.isCompatibleWithMSVC(LangOptions::MSVC2015)) {
-        if (Opts.CPlusPlus17)
-          Builder.defineMacro("_MSVC_LANG", "201403L");
+        if (Opts.CPlusPlus2a)
+          Builder.defineMacro("_MSVC_LANG", "201704L");
+        else if (Opts.CPlusPlus17)
+          Builder.defineMacro("_MSVC_LANG", "201703L");
         else if (Opts.CPlusPlus14)
           Builder.defineMacro("_MSVC_LANG", "201402L");
       }
index 87ad424ee9c71ae68218eee4b7b2bf4c76f8e449..9296b1cf5a50d7ca15a33b81bff2c87e97730b2e 100644 (file)
@@ -1,33 +1,5 @@
 // This test verifies that the correct macros are predefined.
 //
-// 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 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
-// CHECK-MS-NOT: #define __STRICT_ANSI__
-// CHECK-MS-NOT: GCC
-// CHECK-MS-NOT: GNU
-// CHECK-MS-NOT: GXX
-//
-// 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 1900
-// CHECK-MS64: #define _MSVC_LANG 201402L
-// CHECK-MS64: #define _M_AMD64 100
-// CHECK-MS64: #define _M_X64 100
-// CHECK-MS64: #define _WIN64 1
-// CHECK-MS64-NOT: #define __STRICT_ANSI__
-// CHECK-MS64-NOT: GCC
-// CHECK-MS64-NOT: GNU
-// CHECK-MS64-NOT: GXX
-//
 // RUN: %clang_cc1 %s -E -dM -triple i686-pc-win32 -fms-compatibility \
 // RUN:     -o - | FileCheck -match-full-lines %s --check-prefix=CHECK-MS-STDINT
 // CHECK-MS-STDINT:#define __INT16_MAX__ 32767
 // MSCOPE:#define __OPENCL_MEMORY_SCOPE_WORK_GROUP 1
 // MSCOPE:#define __OPENCL_MEMORY_SCOPE_WORK_ITEM 0
 
-// RUN: %clang_cc1 -triple i386-windows %s -E -dM -o - \
-// RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-X86-WIN
-
-// CHECK-X86-WIN-NOT: #define WIN32 1
-// CHECK-X86-WIN-NOT: #define WIN64 1
-// CHECK-X86-WIN-NOT: #define WINNT 1
-// CHECK-X86-WIN: #define _WIN32 1
-// CHECK-X86-WIN-NOT: #define _WIN64 1
-
-// RUN: %clang_cc1 -triple thumbv7-windows %s -E -dM -o - \
-// RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-ARM-WIN
-
-// CHECK-ARM-WIN-NOT: #define WIN32 1
-// CHECK-ARM-WIN-NOT: #define WIN64 1
-// CHECK-ARM-WIN-NOT: #define WINNT 1
-// CHECK-ARM-WIN: #define _WIN32 1
-// CHECK-ARM-WIN-NOT: #define _WIN64 1
-
-// RUN: %clang_cc1 -triple x86_64-windows %s -E -dM -o - \
-// RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-AMD64-WIN
-
-// CHECK-AMD64-WIN-NOT: #define WIN32 1
-// CHECK-AMD64-WIN-NOT: #define WIN64 1
-// CHECK-AMD64-WIN-NOT: #define WINNT 1
-// CHECK-AMD64-WIN: #define _WIN32 1
-// CHECK-AMD64-WIN: #define _WIN64 1
-
-// RUN: %clang_cc1 -triple aarch64-windows %s -E -dM -o - \
-// RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-ARM64-WIN
-
-// CHECK-ARM64-WIN-NOT: #define WIN32 1
-// CHECK-ARM64-WIN-NOT: #define WIN64 1
-// CHECK-ARM64-WIN-NOT: #define WINNT 1
-// CHECK-ARM64-WIN: #define _M_ARM64 1
-// CHECK-ARM64-WIN: #define _WIN32 1
-// CHECK-ARM64-WIN: #define _WIN64 1
-
-// RUN: %clang_cc1 -triple i686-windows-gnu %s -E -dM -o - \
-// RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-X86-MINGW
-
-// CHECK-X86-MINGW: #define WIN32 1
-// CHECK-X86-MINGW-NOT: #define WIN64 1
-// CHECK-X86-MINGW: #define WINNT 1
-// CHECK-X86-MINGW: #define _WIN32 1
-// CHECK-X86-MINGW-NOT: #define _WIN64 1
-
-// RUN: %clang_cc1 -triple thumbv7-windows-gnu %s -E -dM -o - \
-// RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-ARM-MINGW
-
-// CHECK-ARM-MINGW: #define WIN32 1
-// CHECK-ARM-MINGW-NOT: #define WIN64 1
-// CHECK-ARM-MINGW: #define WINNT 1
-// CHECK-ARM-MINGW: #define _WIN32 1
-// CHECK-ARM-MINGW-NOT: #define _WIN64 1
-
-// RUN: %clang_cc1 -triple x86_64-windows-gnu %s -E -dM -o - \
-// RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-AMD64-MINGW
-
-// CHECK-AMD64-MINGW: #define WIN32 1
-// CHECK-AMD64-MINGW: #define WIN64 1
-// CHECK-AMD64-MINGW: #define WINNT 1
-// CHECK-AMD64-MINGW: #define _WIN32 1
-// CHECK-AMD64-MINGW: #define _WIN64 1
-
-// RUN: %clang_cc1 -triple aarch64-windows-gnu %s -E -dM -o - \
-// RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-ARM64-MINGW
-
-// CHECK-ARM64-MINGW-NOT: #define _M_ARM64 1
-// CHECK-ARM64-MINGW: #define WIN32 1
-// CHECK-ARM64-MINGW: #define WIN64 1
-// CHECK-ARM64-MINGW: #define WINNT 1
-// CHECK-ARM64-MINGW: #define _WIN32 1
-// CHECK-ARM64-MINGW: #define _WIN64 1
-// CHECK-ARM64-MINGW: #define __aarch64__ 1
-
 // RUN: %clang_cc1 %s -E -dM -o - -x cl -triple spir-unknown-unknown \
 // RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-SPIR
 // CHECK-SPIR: #define __IMAGE_SUPPORT__ 1
diff --git a/test/Preprocessor/predefined-win-macros.c b/test/Preprocessor/predefined-win-macros.c
new file mode 100644 (file)
index 0000000..0979e34
--- /dev/null
@@ -0,0 +1,110 @@
+// This test verifies that the correct macros are predefined.
+//
+// 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 1900
+// CHECK-MS64: #define _MSVC_LANG 201402L
+// CHECK-MS64: #define _M_AMD64 100
+// CHECK-MS64: #define _M_X64 100
+// CHECK-MS64: #define _WIN64 1
+// CHECK-MS64-NOT: #define __STRICT_ANSI__
+// CHECK-MS64-NOT: GCC
+// CHECK-MS64-NOT: GNU
+// CHECK-MS64-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++17 -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 1900
+// CHECK-MS: #define _MSVC_LANG 201703L
+// CHECK-MS: #define _M_IX86 600
+// CHECK-MS: #define _M_IX86_FP 0
+// CHECK-MS: #define _WIN32 1
+// CHECK-MS-NOT: #define __STRICT_ANSI__
+// CHECK-MS-NOT: GCC
+// CHECK-MS-NOT: GNU
+// 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
+// CHECK-MS-CPP2A: #define _MSC_VER 1900
+// CHECK-MS-CPP2A: #define _MSVC_LANG 201704L
+
+// RUN: %clang_cc1 -triple i386-windows %s -E -dM -o - \
+// RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-X86-WIN
+
+// CHECK-X86-WIN-NOT: #define WIN32 1
+// CHECK-X86-WIN-NOT: #define WIN64 1
+// CHECK-X86-WIN-NOT: #define WINNT 1
+// CHECK-X86-WIN: #define _WIN32 1
+// CHECK-X86-WIN-NOT: #define _WIN64 1
+
+// RUN: %clang_cc1 -triple thumbv7-windows %s -E -dM -o - \
+// RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-ARM-WIN
+
+// CHECK-ARM-WIN-NOT: #define WIN32 1
+// CHECK-ARM-WIN-NOT: #define WIN64 1
+// CHECK-ARM-WIN-NOT: #define WINNT 1
+// CHECK-ARM-WIN: #define _WIN32 1
+// CHECK-ARM-WIN-NOT: #define _WIN64 1
+
+// RUN: %clang_cc1 -triple x86_64-windows %s -E -dM -o - \
+// RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-AMD64-WIN
+
+// CHECK-AMD64-WIN-NOT: #define WIN32 1
+// CHECK-AMD64-WIN-NOT: #define WIN64 1
+// CHECK-AMD64-WIN-NOT: #define WINNT 1
+// CHECK-AMD64-WIN: #define _WIN32 1
+// CHECK-AMD64-WIN: #define _WIN64 1
+
+// RUN: %clang_cc1 -triple aarch64-windows %s -E -dM -o - \
+// RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-ARM64-WIN
+
+// CHECK-ARM64-WIN-NOT: #define WIN32 1
+// CHECK-ARM64-WIN-NOT: #define WIN64 1
+// CHECK-ARM64-WIN-NOT: #define WINNT 1
+// CHECK-ARM64-WIN: #define _M_ARM64 1
+// CHECK-ARM64-WIN: #define _WIN32 1
+// CHECK-ARM64-WIN: #define _WIN64 1
+
+// RUN: %clang_cc1 -triple i686-windows-gnu %s -E -dM -o - \
+// RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-X86-MINGW
+
+// CHECK-X86-MINGW: #define WIN32 1
+// CHECK-X86-MINGW-NOT: #define WIN64 1
+// CHECK-X86-MINGW: #define WINNT 1
+// CHECK-X86-MINGW: #define _WIN32 1
+// CHECK-X86-MINGW-NOT: #define _WIN64 1
+
+// RUN: %clang_cc1 -triple thumbv7-windows-gnu %s -E -dM -o - \
+// RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-ARM-MINGW
+
+// CHECK-ARM-MINGW: #define WIN32 1
+// CHECK-ARM-MINGW-NOT: #define WIN64 1
+// CHECK-ARM-MINGW: #define WINNT 1
+// CHECK-ARM-MINGW: #define _WIN32 1
+// CHECK-ARM-MINGW-NOT: #define _WIN64 1
+
+// RUN: %clang_cc1 -triple x86_64-windows-gnu %s -E -dM -o - \
+// RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-AMD64-MINGW
+
+// CHECK-AMD64-MINGW: #define WIN32 1
+// CHECK-AMD64-MINGW: #define WIN64 1
+// CHECK-AMD64-MINGW: #define WINNT 1
+// CHECK-AMD64-MINGW: #define _WIN32 1
+// CHECK-AMD64-MINGW: #define _WIN64 1
+
+// RUN: %clang_cc1 -triple aarch64-windows-gnu %s -E -dM -o - \
+// RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-ARM64-MINGW
+
+// CHECK-ARM64-MINGW-NOT: #define _M_ARM64 1
+// CHECK-ARM64-MINGW: #define WIN32 1
+// CHECK-ARM64-MINGW: #define WIN64 1
+// CHECK-ARM64-MINGW: #define WINNT 1
+// CHECK-ARM64-MINGW: #define _WIN32 1
+// CHECK-ARM64-MINGW: #define _WIN64 1
+// CHECK-ARM64-MINGW: #define __aarch64__ 1
+