From 57b6f21c544b7d924922273ba274b1dce803a54c Mon Sep 17 00:00:00 2001 From: Michael Schellenberger Costa Date: Wed, 29 Jan 2020 10:17:33 +0100 Subject: [PATCH 1/7] [ostream] Add deleted charX_t overloads to operator<< --- stl/inc/ostream | 39 +++++++++++++++++++++++++++++++++++---- stl/inc/yvals_core.h | 3 ++- 2 files changed, 37 insertions(+), 5 deletions(-) diff --git a/stl/inc/ostream b/stl/inc/ostream index d335116daca..258ccd59c15 100644 --- a/stl/inc/ostream +++ b/stl/inc/ostream @@ -912,15 +912,46 @@ basic_ostream& operator<<( } #ifdef __cpp_char8_t // These deleted overloads are specified in P1423. +// don't insert a UTF-8 NTBS template -basic_ostream& operator<<( - basic_ostream&, const char8_t*) = delete; // don't insert a UTF-8 NTBS +basic_ostream& operator<<(basic_ostream&, const char8_t*) = delete; +template +basic_ostream& operator<<(basic_ostream&, const char8_t*) = delete; +// don't insert a UTF-8 code unit template -basic_ostream& operator<<( - basic_ostream&, char8_t) = delete; // don't insert a UTF-8 code unit +basic_ostream& operator<<(basic_ostream&, char8_t) = delete; +template +basic_ostream& operator<<(basic_ostream&, char8_t) = delete; #endif // __cpp_char8_t +#if _HAS_CXX20 +template +basic_ostream& operator<<(basic_ostream&, wchar_t) = delete; +template +basic_ostream& operator<<(basic_ostream&, char16_t) = delete; +template +basic_ostream& operator<<(basic_ostream&, char32_t) = delete; + +template +basic_ostream& operator<<(basic_ostream&, char16_t) = delete; +template +basic_ostream& operator<<(basic_ostream&, char32_t) = delete; + +template +basic_ostream& operator<<(basic_ostream&, const wchar_t*) = delete; +template +basic_ostream& operator<<(basic_ostream&, const char16_t*) = delete; +template +basic_ostream& operator<<(basic_ostream&, const char32_t*) = delete; + +template +basic_ostream& operator<<(basic_ostream&, const char16_t*) = delete; +template +basic_ostream& operator<<(basic_ostream&, const char32_t*) = delete; + +#endif // !_HAS_CXX20 + template struct _Can_stream_out : false_type {}; diff --git a/stl/inc/yvals_core.h b/stl/inc/yvals_core.h index 60be7ce8fc5..b9538bff9ab 100644 --- a/stl/inc/yvals_core.h +++ b/stl/inc/yvals_core.h @@ -59,6 +59,7 @@ // P0941R2 Feature-Test Macros // P0972R0 noexcept For zero(), min(), max() // P1164R1 Making create_directory() Intuitive +// P1423R3 char8_t Backward Compatibility Remediation // P1902R1 Missing Feature-Test Macros 2017-2019 // _HAS_CXX17 directly controls: @@ -1007,7 +1008,7 @@ #define __cpp_lib_bounded_array_traits 201902L #ifdef __cpp_char8_t -#define __cpp_lib_char8_t 201811L +#define __cpp_lib_char8_t 201907L #endif // __cpp_char8_t #if defined(__cpp_concepts) && __cpp_concepts > 201507L From c38a7acfacc1a319c7fd36ecab302771782ab214 Mon Sep 17 00:00:00 2001 From: Michael Schellenberger Costa Date: Thu, 30 Jan 2020 09:39:44 +0100 Subject: [PATCH 2/7] Update stl/inc/ostream Co-Authored-By: Casey Carter --- stl/inc/ostream | 1 - 1 file changed, 1 deletion(-) diff --git a/stl/inc/ostream b/stl/inc/ostream index 258ccd59c15..36e5315bb20 100644 --- a/stl/inc/ostream +++ b/stl/inc/ostream @@ -949,7 +949,6 @@ template basic_ostream& operator<<(basic_ostream&, const char16_t*) = delete; template basic_ostream& operator<<(basic_ostream&, const char32_t*) = delete; - #endif // !_HAS_CXX20 template From 23862470eec08d957a570ffd716a7d68b7d38575 Mon Sep 17 00:00:00 2001 From: Michael Schellenberger Costa Date: Thu, 30 Jan 2020 09:41:33 +0100 Subject: [PATCH 3/7] Mark it as controlled by CXX20 --- stl/inc/yvals_core.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stl/inc/yvals_core.h b/stl/inc/yvals_core.h index b9538bff9ab..c41dcbb7863 100644 --- a/stl/inc/yvals_core.h +++ b/stl/inc/yvals_core.h @@ -59,7 +59,6 @@ // P0941R2 Feature-Test Macros // P0972R0 noexcept For zero(), min(), max() // P1164R1 Making create_directory() Intuitive -// P1423R3 char8_t Backward Compatibility Remediation // P1902R1 Missing Feature-Test Macros 2017-2019 // _HAS_CXX17 directly controls: @@ -173,6 +172,7 @@ // P1227R2 Signed std::ssize(), Unsigned span::size() // P1357R1 is_bounded_array, is_unbounded_array // P1394R4 Range Constructor For span +// P1423R3 char8_t Backward Compatibility Remediation // P1456R1 Move-Only Views // P1612R1 Relocating endian To // P1645R1 constexpr For Algorithms From 469d6c33f47ca4d62b0b0703b3e2a098f7f496b7 Mon Sep 17 00:00:00 2001 From: Casey Carter Date: Thu, 30 Jan 2020 13:36:04 -0800 Subject: [PATCH 4/7] Skip libcxx tests that expect the pre-1423 value of __cpp_lib_char8_t --- tests/libcxx/skipped_tests.txt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/libcxx/skipped_tests.txt b/tests/libcxx/skipped_tests.txt index 06d1868ba22..d22aec74a0d 100644 --- a/tests/libcxx/skipped_tests.txt +++ b/tests/libcxx/skipped_tests.txt @@ -51,6 +51,13 @@ containers\unord\unord.set\insert_and_emplace_allocator_requirements.pass.cpp # See https://reviews.llvm.org/D73138 containers\views\span.sub\subspan.pass.cpp +# libcxx doesn't yet implement P1423R3, so it expects an "old" value for __cpp_lib_char8_t +language.support\support.limits\support.limits.general\filesystem.version.pass.cpp +language.support\support.limits\support.limits.general\istream.version.pass.cpp +language.support\support.limits\support.limits.general\limits.version.pass.cpp +language.support\support.limits\support.limits.general\locale.version.pass.cpp +language.support\support.limits\support.limits.general\ostream.version.pass.cpp + # *** INTERACTIONS WITH CONTEST / C1XX THAT UPSTREAM LIKELY WON'T FIX *** # Tracked by VSO-593630 " Enable libcxx filesystem tests" From 4f5c7ae6315d8e033b29903c59ff9162c6f9b01e Mon Sep 17 00:00:00 2001 From: Casey Carter Date: Thu, 30 Jan 2020 15:21:36 -0800 Subject: [PATCH 5/7] Add escape hatch _HAS_STREAM_INSERTIONS_REMOVED_BY_P1423 for non-`char8_t` changes --- stl/inc/ostream | 4 ++-- stl/inc/yvals_core.h | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/stl/inc/ostream b/stl/inc/ostream index 36e5315bb20..f533dbc3d0e 100644 --- a/stl/inc/ostream +++ b/stl/inc/ostream @@ -925,7 +925,7 @@ template basic_ostream& operator<<(basic_ostream&, char8_t) = delete; #endif // __cpp_char8_t -#if _HAS_CXX20 +#if _HAS_CXX20 && !_HAS_STREAM_INSERTIONS_REMOVED_BY_P1423 template basic_ostream& operator<<(basic_ostream&, wchar_t) = delete; template @@ -949,7 +949,7 @@ template basic_ostream& operator<<(basic_ostream&, const char16_t*) = delete; template basic_ostream& operator<<(basic_ostream&, const char32_t*) = delete; -#endif // !_HAS_CXX20 +#endif // _HAS_CXX20 && !_HAS_STREAM_INSERTIONS_REMOVED_BY_P1423 template struct _Can_stream_out : false_type {}; diff --git a/stl/inc/yvals_core.h b/stl/inc/yvals_core.h index c41dcbb7863..35ecccc0321 100644 --- a/stl/inc/yvals_core.h +++ b/stl/inc/yvals_core.h @@ -586,6 +586,12 @@ #endif // _M_FP_EXCEPT #endif // _STD_VECTORIZE_WITH_FLOAT_CONTROL +// P1423R3 char8_t Backward Compatibility Remediation +// Controls whether we allow the stream insertions this proposal forbids +#ifndef _HAS_STREAM_INSERTIONS_REMOVED_BY_P1423 +#define _HAS_STREAM_INSERTIONS_REMOVED_BY_P1423 0 +#endif // _HAS_STREAM_INSERTIONS_REMOVED_BY_P1423 + // P0174R2 Deprecating Vestigial Library Parts // P0521R0 Deprecating shared_ptr::unique() // Other C++17 deprecation warnings From 47c9372b0e6db8dc2f94e097d5f45638286a8161 Mon Sep 17 00:00:00 2001 From: Casey Carter Date: Fri, 31 Jan 2020 11:46:59 -0800 Subject: [PATCH 6/7] Change escape hatch name and default to !_HAS_CXX20 --- stl/inc/ostream | 4 ++-- stl/inc/yvals_core.h | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/stl/inc/ostream b/stl/inc/ostream index f533dbc3d0e..1c2daec56c8 100644 --- a/stl/inc/ostream +++ b/stl/inc/ostream @@ -925,7 +925,7 @@ template basic_ostream& operator<<(basic_ostream&, char8_t) = delete; #endif // __cpp_char8_t -#if _HAS_CXX20 && !_HAS_STREAM_INSERTIONS_REMOVED_BY_P1423 +#if !_HAS_STREAM_INSERTIONS_REMOVED_IN_CXX20 template basic_ostream& operator<<(basic_ostream&, wchar_t) = delete; template @@ -949,7 +949,7 @@ template basic_ostream& operator<<(basic_ostream&, const char16_t*) = delete; template basic_ostream& operator<<(basic_ostream&, const char32_t*) = delete; -#endif // _HAS_CXX20 && !_HAS_STREAM_INSERTIONS_REMOVED_BY_P1423 +#endif // !_HAS_STREAM_INSERTIONS_REMOVED_IN_CXX20 template struct _Can_stream_out : false_type {}; diff --git a/stl/inc/yvals_core.h b/stl/inc/yvals_core.h index 35ecccc0321..dd0e842da8c 100644 --- a/stl/inc/yvals_core.h +++ b/stl/inc/yvals_core.h @@ -588,9 +588,9 @@ // P1423R3 char8_t Backward Compatibility Remediation // Controls whether we allow the stream insertions this proposal forbids -#ifndef _HAS_STREAM_INSERTIONS_REMOVED_BY_P1423 -#define _HAS_STREAM_INSERTIONS_REMOVED_BY_P1423 0 -#endif // _HAS_STREAM_INSERTIONS_REMOVED_BY_P1423 +#ifndef _HAS_STREAM_INSERTIONS_REMOVED_IN_CXX20 +#define _HAS_STREAM_INSERTIONS_REMOVED_IN_CXX20 (!_HAS_CXX20) +#endif // _HAS_STREAM_INSERTIONS_REMOVED_IN_CXX20 // P0174R2 Deprecating Vestigial Library Parts // P0521R0 Deprecating shared_ptr::unique() From 53acdbfbc0424e265ad012140bbdca693db7d3ab Mon Sep 17 00:00:00 2001 From: Casey Carter Date: Fri, 31 Jan 2020 14:41:04 -0800 Subject: [PATCH 7/7] Narrow stream insertion of unsigned short should work with /Zc:wchar_t-; rename escape hatch --- stl/inc/ostream | 12 ++++++++---- stl/inc/yvals_core.h | 6 +++--- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/stl/inc/ostream b/stl/inc/ostream index 1c2daec56c8..c064fff6766 100644 --- a/stl/inc/ostream +++ b/stl/inc/ostream @@ -925,9 +925,15 @@ template basic_ostream& operator<<(basic_ostream&, char8_t) = delete; #endif // __cpp_char8_t -#if !_HAS_STREAM_INSERTIONS_REMOVED_IN_CXX20 +#if !_HAS_STREAM_INSERTION_OPERATORS_DELETED_IN_CXX20 +#ifdef _NATIVE_WCHAR_T_DEFINED template basic_ostream& operator<<(basic_ostream&, wchar_t) = delete; + +template +basic_ostream& operator<<(basic_ostream&, const wchar_t*) = delete; +#endif // _NATIVE_WCHAR_T_DEFINED + template basic_ostream& operator<<(basic_ostream&, char16_t) = delete; template @@ -938,8 +944,6 @@ basic_ostream& operator<<(basic_ostream&, ch template basic_ostream& operator<<(basic_ostream&, char32_t) = delete; -template -basic_ostream& operator<<(basic_ostream&, const wchar_t*) = delete; template basic_ostream& operator<<(basic_ostream&, const char16_t*) = delete; template @@ -949,7 +953,7 @@ template basic_ostream& operator<<(basic_ostream&, const char16_t*) = delete; template basic_ostream& operator<<(basic_ostream&, const char32_t*) = delete; -#endif // !_HAS_STREAM_INSERTIONS_REMOVED_IN_CXX20 +#endif // !_HAS_STREAM_INSERTION_OPERATORS_DELETED_IN_CXX20 template struct _Can_stream_out : false_type {}; diff --git a/stl/inc/yvals_core.h b/stl/inc/yvals_core.h index dd0e842da8c..017f515acef 100644 --- a/stl/inc/yvals_core.h +++ b/stl/inc/yvals_core.h @@ -588,9 +588,9 @@ // P1423R3 char8_t Backward Compatibility Remediation // Controls whether we allow the stream insertions this proposal forbids -#ifndef _HAS_STREAM_INSERTIONS_REMOVED_IN_CXX20 -#define _HAS_STREAM_INSERTIONS_REMOVED_IN_CXX20 (!_HAS_CXX20) -#endif // _HAS_STREAM_INSERTIONS_REMOVED_IN_CXX20 +#ifndef _HAS_STREAM_INSERTION_OPERATORS_DELETED_IN_CXX20 +#define _HAS_STREAM_INSERTION_OPERATORS_DELETED_IN_CXX20 (!_HAS_CXX20) +#endif // _HAS_STREAM_INSERTION_OPERATORS_DELETED_IN_CXX20 // P0174R2 Deprecating Vestigial Library Parts // P0521R0 Deprecating shared_ptr::unique()