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 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 { 32 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 // MSVC has quick_exit() and at_quick_exit(). 69 #define _LIBCPP_HAS_QUICK_EXIT 70 71 #ifndef _LIBCXX_IN_DEVCRT 72 // atomic_is_lock_free.pass.cpp needs this VS 2015 Update 2 fix. 73 #define _ENABLE_ATOMIC_ALIGNMENT_FIX 74 75 // Restore features that are removed in C++20. 76 #define _HAS_FEATURES_REMOVED_IN_CXX20 1 77 78 // Silence warnings about features that are deprecated in C++17 and C++20. 79 #define _SILENCE_ALL_CXX17_DEPRECATION_WARNINGS 80 #define _SILENCE_ALL_CXX20_DEPRECATION_WARNINGS 81 #endif // _LIBCXX_IN_DEVCRT 82 83 #include <version> 84 85 #if _HAS_CXX20 86 #define TEST_STD_VER 99 87 #elif _HAS_CXX17 88 #define TEST_STD_VER 17 89 #else // !(_HAS_CXX20 || _HAS_CXX17) 90 #define TEST_STD_VER 14 91 #endif 92 93 #define _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST 94 #define _LIBCPP_SUPPRESS_DEPRECATED_PUSH 95 #define _LIBCPP_SUPPRESS_DEPRECATED_POP 96 97 #endif // SUPPORT_MSVC_STDLIB_FORCE_INCLUDE_H 98