1 //===----------------------------------------------------------------------===// 2 // 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 6 // 7 //===----------------------------------------------------------------------===// 8 9 #ifndef SUPPORT_MSVC_STDLIB_FORCE_INCLUDE_H 10 #define SUPPORT_MSVC_STDLIB_FORCE_INCLUDE_H 11 12 // This header is force-included when running the libc++ tests against the 13 // MSVC standard library. 14 15 #ifndef _LIBCXX_IN_DEVCRT 16 // Silence warnings about CRT machinery. 17 #define _CRT_SECURE_NO_WARNINGS 1 18 19 // Avoid assertion dialogs. 20 #define _CRT_SECURE_INVALID_PARAMETER(EXPR) ::abort() 21 #endif // _LIBCXX_IN_DEVCRT 22 23 #include <crtdbg.h> 24 #include <stdlib.h> 25 26 #if defined(_LIBCPP_VERSION) 27 #error This header may not be used when targeting libc++ 28 #endif 29 30 #ifndef _LIBCXX_IN_DEVCRT 31 struct AssertionDialogAvoider { AssertionDialogAvoiderAssertionDialogAvoider32 AssertionDialogAvoider() { 33 _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_FILE); 34 _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR); 35 36 _CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_FILE); 37 _CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDERR); 38 } 39 }; 40 41 const AssertionDialogAvoider assertion_dialog_avoider{}; 42 #endif // _LIBCXX_IN_DEVCRT 43 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 53 54 #define __has_attribute(X) _MSVC_HAS_ATTRIBUTE_ ## X 55 #define _MSVC_HAS_ATTRIBUTE_vector_size 0 56 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__) 64 65 // MSVC doesn't have __int128_t. 66 #define _LIBCPP_HAS_NO_INT128 67 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 71 72 // Restore features that are removed in C++20. 73 #define _HAS_FEATURES_REMOVED_IN_CXX20 1 74 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 79 80 #include <version> 81 82 #if _HAS_CXX20 83 #define TEST_STD_VER 99 84 #elif _HAS_CXX17 85 #define TEST_STD_VER 17 86 #else // !(_HAS_CXX20 || _HAS_CXX17) 87 #define TEST_STD_VER 14 88 #endif 89 90 #define _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST 91 92 #ifdef __clang__ 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)) 105 #endif // __clang__ 106 107 #endif // SUPPORT_MSVC_STDLIB_FORCE_INCLUDE_H 108