1 //===----------------------------------------------------------------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 #ifndef SUPPORT_MSVC_STDLIB_FORCE_INCLUDE_H
10 #define SUPPORT_MSVC_STDLIB_FORCE_INCLUDE_H
12 // This header is force-included when running the libc++ tests against the
13 // MSVC standard library.
15 #ifndef _LIBCXX_IN_DEVCRT
16 // Silence warnings about CRT machinery.
17 #define _CRT_SECURE_NO_WARNINGS 1
19 // Avoid assertion dialogs.
20 #define _CRT_SECURE_INVALID_PARAMETER(EXPR) ::abort()
21 #endif // _LIBCXX_IN_DEVCRT
26 #if defined(_LIBCPP_VERSION)
27 #error This header may not be used when targeting libc++
30 #ifndef _LIBCXX_IN_DEVCRT
31 struct AssertionDialogAvoider
{
32 AssertionDialogAvoider() {
33 _CrtSetReportMode(_CRT_ASSERT
, _CRTDBG_MODE_FILE
);
34 _CrtSetReportFile(_CRT_ASSERT
, _CRTDBG_FILE_STDERR
);
36 _CrtSetReportMode(_CRT_ERROR
, _CRTDBG_MODE_FILE
);
37 _CrtSetReportFile(_CRT_ERROR
, _CRTDBG_FILE_STDERR
);
41 const AssertionDialogAvoider assertion_dialog_avoider
{};
42 #endif // _LIBCXX_IN_DEVCRT
44 // MSVC frontend only configurations
45 #if !defined(__clang__)
46 // Simulate feature-test macros.
47 #define __has_feature(X) _MSVC_HAS_FEATURE_ ## X
48 #define _MSVC_HAS_FEATURE_cxx_exceptions 1
49 #define _MSVC_HAS_FEATURE_cxx_rtti 1
50 #define _MSVC_HAS_FEATURE_address_sanitizer 0
51 #define _MSVC_HAS_FEATURE_memory_sanitizer 0
52 #define _MSVC_HAS_FEATURE_thread_sanitizer 0
54 #define __has_attribute(X) _MSVC_HAS_ATTRIBUTE_ ## X
55 #define _MSVC_HAS_ATTRIBUTE_vector_size 0
57 // Silence compiler warnings.
58 #pragma warning(disable: 4180) // qualifier applied to function type has no meaning; ignored
59 #pragma warning(disable: 4324) // structure was padded due to alignment specifier
60 #pragma warning(disable: 4521) // multiple copy constructors specified
61 #pragma warning(disable: 4702) // unreachable code
62 #pragma warning(disable: 28251) // Inconsistent annotation for 'new': this instance has no annotations.
63 #endif // !defined(__clang__)
65 // MSVC doesn't have __int128_t.
66 #define _LIBCPP_HAS_NO_INT128
68 #ifndef _LIBCXX_IN_DEVCRT
69 // atomic_is_lock_free.pass.cpp needs this VS 2015 Update 2 fix.
70 #define _ENABLE_ATOMIC_ALIGNMENT_FIX
72 // Restore features that are removed in C++20.
73 #define _HAS_FEATURES_REMOVED_IN_CXX20 1
75 // Silence warnings about features that are deprecated in C++17 and C++20.
76 #define _SILENCE_ALL_CXX17_DEPRECATION_WARNINGS
77 #define _SILENCE_ALL_CXX20_DEPRECATION_WARNINGS
78 #endif // _LIBCXX_IN_DEVCRT
83 #define TEST_STD_VER 99
85 #define TEST_STD_VER 17
86 #else // !(_HAS_CXX20 || _HAS_CXX17)
87 #define TEST_STD_VER 14
90 #define _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST
93 #define _LIBCPP_SUPPRESS_DEPRECATED_PUSH \
94 _Pragma("GCC diagnostic push") \
95 _Pragma("GCC diagnostic ignored \"-Wdeprecated\"")
96 #define _LIBCPP_SUPPRESS_DEPRECATED_POP \
97 _Pragma("GCC diagnostic pop")
98 #else // ^^^ clang / MSVC vvv
99 #define _LIBCPP_SUPPRESS_DEPRECATED_PUSH \
100 __pragma(warning(push)) \
101 __pragma(warning(disable : 4996)) \
102 __pragma(warning(disable : 5215))
103 #define _LIBCPP_SUPPRESS_DEPRECATED_POP \
104 __pragma(warning(pop))
107 #endif // SUPPORT_MSVC_STDLIB_FORCE_INCLUDE_H