From 244bf110428646f38d77ae08f07e3802781bb665 Mon Sep 17 00:00:00 2001 From: "Stephan T. Lavavej" Date: Fri, 20 Oct 2023 14:40:22 -0700 Subject: [PATCH 1/5] Add a Standard mode check to `<__msvc_print.hpp>`. --- stl/inc/__msvc_print.hpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/stl/inc/__msvc_print.hpp b/stl/inc/__msvc_print.hpp index 5de74a0f268..79f5171d160 100644 --- a/stl/inc/__msvc_print.hpp +++ b/stl/inc/__msvc_print.hpp @@ -8,6 +8,11 @@ #include #if _STL_COMPILER_PREPROCESSOR +#ifndef __cpp_lib_concepts +#error The contents of are available only with C++20 or later, and the contents of \ +are available only with C++23 or later. (Also, you should not include this internal header.) +#endif // ^^^ !defined(__cpp_lib_concepts) ^^^ + #include #include From 4c24a200018da97d43a655ea4adc6fe7b323c66f Mon Sep 17 00:00:00 2001 From: "Stephan T. Lavavej" Date: Fri, 20 Oct 2023 14:40:44 -0700 Subject: [PATCH 2/5] Move Standard mode checks in `` as early as possible. `` was already doing this. --- stl/inc/xcharconv.h | 8 ++++---- stl/inc/xcharconv_ryu.h | 8 ++++---- stl/inc/xcharconv_ryu_tables.h | 4 ++-- stl/inc/xnode_handle.h | 3 ++- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/stl/inc/xcharconv.h b/stl/inc/xcharconv.h index cf352799eae..07f6c2f8752 100644 --- a/stl/inc/xcharconv.h +++ b/stl/inc/xcharconv.h @@ -8,14 +8,14 @@ #include #if _STL_COMPILER_PREPROCESSOR -#include -#include -#include - #if !_HAS_CXX17 #error The contents of are only available with C++17. (Also, you should not include this internal header.) #endif // !_HAS_CXX17 +#include +#include +#include + #pragma pack(push, _CRT_PACKING) #pragma warning(push, _STL_WARNING_LEVEL) #pragma warning(disable : _STL_DISABLED_WARNINGS) diff --git a/stl/inc/xcharconv_ryu.h b/stl/inc/xcharconv_ryu.h index fc29a3d4858..343a09226b7 100644 --- a/stl/inc/xcharconv_ryu.h +++ b/stl/inc/xcharconv_ryu.h @@ -37,6 +37,10 @@ #include #if _STL_COMPILER_PREPROCESSOR +#if !_HAS_CXX17 +#error The contents of are only available with C++17. (Also, you should not include this internal header.) +#endif // !_HAS_CXX17 + #include #include #include @@ -54,10 +58,6 @@ #include _STL_INTRIN_HEADER // for _umul128() and __shiftright128() #endif // ^^^ intrinsics available ^^^ -#if !_HAS_CXX17 -#error The contents of are only available with C++17. (Also, you should not include this internal header.) -#endif // !_HAS_CXX17 - #pragma pack(push, _CRT_PACKING) #pragma warning(push, _STL_WARNING_LEVEL) #pragma warning(disable : _STL_DISABLED_WARNINGS) diff --git a/stl/inc/xcharconv_ryu_tables.h b/stl/inc/xcharconv_ryu_tables.h index ef01dd9e581..a8d4e5a7b4e 100644 --- a/stl/inc/xcharconv_ryu_tables.h +++ b/stl/inc/xcharconv_ryu_tables.h @@ -37,12 +37,12 @@ #include #if _STL_COMPILER_PREPROCESSOR -#include - #if !_HAS_CXX17 #error The contents of are only available with C++17. (Also, you should not include this internal header.) #endif // !_HAS_CXX17 +#include + #pragma pack(push, _CRT_PACKING) #pragma warning(push, _STL_WARNING_LEVEL) #pragma warning(disable : _STL_DISABLED_WARNINGS) diff --git a/stl/inc/xnode_handle.h b/stl/inc/xnode_handle.h index f7f685b259e..2462a506e53 100644 --- a/stl/inc/xnode_handle.h +++ b/stl/inc/xnode_handle.h @@ -7,12 +7,13 @@ #define _XNODE_HANDLE_H #include #if _STL_COMPILER_PREPROCESSOR -#include #if !_HAS_CXX17 #error Node handles are only available with C++17. (Also, you should not include this internal header.) #endif // _HAS_CXX17 +#include + #pragma pack(push, _CRT_PACKING) #pragma warning(push, _STL_WARNING_LEVEL) #pragma warning(disable : _STL_DISABLED_WARNINGS) From dffa3d6821739a6ac8a3fe0b7bbfb03fb53028f6 Mon Sep 17 00:00:00 2001 From: "Stephan T. Lavavej" Date: Fri, 20 Oct 2023 16:12:11 -0700 Subject: [PATCH 3/5] `` should have guarded its includes with `__cpp_lib_print` instead of `_HAS_CXX23`. --- stl/inc/ostream | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stl/inc/ostream b/stl/inc/ostream index 1a679cf019b..de3b0a0feef 100644 --- a/stl/inc/ostream +++ b/stl/inc/ostream @@ -9,11 +9,11 @@ #if _STL_COMPILER_PREPROCESSOR #include -#if _HAS_CXX23 +#ifdef __cpp_lib_print #include <__msvc_filebuf.hpp> #include <__msvc_print.hpp> #include -#endif // _HAS_CXX23 +#endif // ^^^ defined(__cpp_lib_print) ^^^ #pragma pack(push, _CRT_PACKING) #pragma warning(push, _STL_WARNING_LEVEL) From c4ceaf0bf255d28513c337a8eedc548b4d2b1f85 Mon Sep 17 00:00:00 2001 From: "Stephan T. Lavavej" Date: Fri, 20 Oct 2023 16:58:13 -0700 Subject: [PATCH 4/5] Update how GH_001411_core_headers tests __msvc_print.hpp. --- tests/std/tests/GH_001411_core_headers/test.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/std/tests/GH_001411_core_headers/test.cpp b/tests/std/tests/GH_001411_core_headers/test.cpp index a3cbc49e9bf..1bf1d87f6c6 100644 --- a/tests/std/tests/GH_001411_core_headers/test.cpp +++ b/tests/std/tests/GH_001411_core_headers/test.cpp @@ -19,9 +19,9 @@ #include #endif // _HAS_CXX17 -#if _HAS_CXX23 +#ifdef __cpp_lib_concepts #include <__msvc_print.hpp> -#endif // _HAS_CXX23 +#endif // ^^^ defined(__cpp_lib_concepts) ^^^ // <__msvc_bit_utils.hpp> is included by and // <__msvc_iter_core.hpp> is included by From 40e37b5b7afd594a9a6c0cf96ab68cd9bf35ef3d Mon Sep 17 00:00:00 2001 From: "Stephan T. Lavavej" Date: Tue, 24 Oct 2023 13:09:41 -0700 Subject: [PATCH 5/5] Mention `` in a comment and only `` in the error. --- stl/inc/__msvc_print.hpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/stl/inc/__msvc_print.hpp b/stl/inc/__msvc_print.hpp index 79f5171d160..b1b3a249dfb 100644 --- a/stl/inc/__msvc_print.hpp +++ b/stl/inc/__msvc_print.hpp @@ -8,9 +8,8 @@ #include #if _STL_COMPILER_PREPROCESSOR -#ifndef __cpp_lib_concepts -#error The contents of are available only with C++20 or later, and the contents of \ -are available only with C++23 or later. (Also, you should not include this internal header.) +#ifndef __cpp_lib_concepts // note: includes this header in C++20 mode +#error The contents of are available only with C++23. (Also, you should not include this internal header.) #endif // ^^^ !defined(__cpp_lib_concepts) ^^^ #include