From b9719d39d3af8f53abcb733362ad5895211c52d6 Mon Sep 17 00:00:00 2001 From: "Stephan T. Lavavej" Date: Mon, 20 Mar 2023 14:47:54 -0700 Subject: [PATCH 1/2] P1467R9 Extended Floating-Point Types --- stl/CMakeLists.txt | 1 + stl/inc/__msvc_all_public_headers.hpp | 1 + stl/inc/header-units.json | 1 + stl/inc/stdfloat | 36 +++++++++++++++++++ stl/inc/yvals_core.h | 2 ++ stl/modules/std.ixx | 1 + .../include/test_header_units_and_modules.hpp | 7 ++++ .../importable_cxx_library_headers.jsonc | 1 + .../test.cpp | 1 + .../include_each_header_alone_matrix.lst | 1 + 10 files changed, 52 insertions(+) create mode 100644 stl/inc/stdfloat diff --git a/stl/CMakeLists.txt b/stl/CMakeLists.txt index 4bc93c646ca..267dad5c75b 100644 --- a/stl/CMakeLists.txt +++ b/stl/CMakeLists.txt @@ -198,6 +198,7 @@ set(HEADERS ${CMAKE_CURRENT_LIST_DIR}/inc/stack ${CMAKE_CURRENT_LIST_DIR}/inc/stacktrace ${CMAKE_CURRENT_LIST_DIR}/inc/stdexcept + ${CMAKE_CURRENT_LIST_DIR}/inc/stdfloat ${CMAKE_CURRENT_LIST_DIR}/inc/stop_token ${CMAKE_CURRENT_LIST_DIR}/inc/streambuf ${CMAKE_CURRENT_LIST_DIR}/inc/string diff --git a/stl/inc/__msvc_all_public_headers.hpp b/stl/inc/__msvc_all_public_headers.hpp index 1734fa07b26..6fcb666dda0 100644 --- a/stl/inc/__msvc_all_public_headers.hpp +++ b/stl/inc/__msvc_all_public_headers.hpp @@ -49,6 +49,7 @@ #include #include #include +#include #include #include #include diff --git a/stl/inc/header-units.json b/stl/inc/header-units.json index 612fae95022..dece3d654aa 100644 --- a/stl/inc/header-units.json +++ b/stl/inc/header-units.json @@ -104,6 +104,7 @@ "stack", "stacktrace", "stdexcept", + "stdfloat", "stop_token", "streambuf", "string", diff --git a/stl/inc/stdfloat b/stl/inc/stdfloat new file mode 100644 index 00000000000..f82ed8cc21d --- /dev/null +++ b/stl/inc/stdfloat @@ -0,0 +1,36 @@ +// stdfloat standard header (core) + +// Copyright (c) Microsoft Corporation. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#pragma once +#ifndef _STDFLOAT_ +#define _STDFLOAT_ +#include +#if _STL_COMPILER_PREPROCESSOR + +#if !_HAS_CXX23 +_EMIT_STL_WARNING(STL4038, "The contents of are available only with C++23 or later."); +#else // ^^^ !_HAS_CXX23 / _HAS_CXX23 vvv + +#pragma pack(push, _CRT_PACKING) +#pragma warning(push, _STL_WARNING_LEVEL) +#pragma warning(disable : _STL_DISABLED_WARNINGS) +_STL_DISABLE_CLANG_WARNINGS +#pragma push_macro("new") +#undef new + +// We don't support any optional extended floating-point types, but we do need to provide an empty `namespace std`. +// We don't need to `export` it for modules, as the other headers will implicitly do so (N4928 [module.interface]/2.1). +_STD_BEGIN +_STD_END + +#pragma pop_macro("new") +_STL_RESTORE_CLANG_WARNINGS +#pragma warning(pop) +#pragma pack(pop) + +#endif // ^^^ _HAS_CXX23 ^^^ + +#endif // _STL_COMPILER_PREPROCESSOR +#endif // _STDFLOAT_ diff --git a/stl/inc/yvals_core.h b/stl/inc/yvals_core.h index da3870dedf5..040d71abb26 100644 --- a/stl/inc/yvals_core.h +++ b/stl/inc/yvals_core.h @@ -319,6 +319,8 @@ // P1272R4 byteswap() // P1328R1 constexpr type_info::operator==() // P1425R4 Iterator Pair Constructors For stack And queue +// P1467R9 Extended Floating-Point Types +// (only the header; we don't support any optional extended floating-point types) // P1659R3 ranges::starts_with, ranges::ends_with // P1679R3 contains() For basic_string/basic_string_view // P1682R3 to_underlying() For Enumerations diff --git a/stl/modules/std.ixx b/stl/modules/std.ixx index dc43b5722e6..c3547d76445 100644 --- a/stl/modules/std.ixx +++ b/stl/modules/std.ixx @@ -100,6 +100,7 @@ export module std; #include #include #include +#include #include #include #include diff --git a/tests/std/include/test_header_units_and_modules.hpp b/tests/std/include/test_header_units_and_modules.hpp index 9b73391c185..d13529b58c6 100644 --- a/tests/std/include/test_header_units_and_modules.hpp +++ b/tests/std/include/test_header_units_and_modules.hpp @@ -772,6 +772,12 @@ void test_stdexcept() { assert(caught_puppies); } +void test_stdfloat() { + using namespace std; + puts("Testing ."); + // `namespace std` is available, so we're done. +} + void test_stop_token() { using namespace std; puts("Testing ."); @@ -1109,6 +1115,7 @@ void all_cpp_header_tests() { test_stack(); test_stacktrace(); test_stdexcept(); + test_stdfloat(); test_stop_token(); test_streambuf(); test_string(); diff --git a/tests/std/tests/P1502R1_standard_library_header_units/importable_cxx_library_headers.jsonc b/tests/std/tests/P1502R1_standard_library_header_units/importable_cxx_library_headers.jsonc index ad8b6c8ab9e..5dd239b739d 100644 --- a/tests/std/tests/P1502R1_standard_library_header_units/importable_cxx_library_headers.jsonc +++ b/tests/std/tests/P1502R1_standard_library_header_units/importable_cxx_library_headers.jsonc @@ -64,6 +64,7 @@ "stack", "stacktrace", "stdexcept", + "stdfloat", "stop_token", "streambuf", "string", diff --git a/tests/std/tests/P1502R1_standard_library_header_units/test.cpp b/tests/std/tests/P1502R1_standard_library_header_units/test.cpp index e9ec1a36cf0..ca6561d7cbc 100644 --- a/tests/std/tests/P1502R1_standard_library_header_units/test.cpp +++ b/tests/std/tests/P1502R1_standard_library_header_units/test.cpp @@ -70,6 +70,7 @@ import ; import ; import ; import ; +import ; import ; import ; import ; diff --git a/tests/std/tests/include_each_header_alone_matrix.lst b/tests/std/tests/include_each_header_alone_matrix.lst index e9fdcfa9c7e..363e8444f78 100644 --- a/tests/std/tests/include_each_header_alone_matrix.lst +++ b/tests/std/tests/include_each_header_alone_matrix.lst @@ -69,6 +69,7 @@ PM_CL="/DMEOW_HEADER=stack" PM_CL="/DMEOW_HEADER=stacktrace" PM_CL="/DMEOW_HEADER=stdatomic.h" PM_CL="/DMEOW_HEADER=stdexcept" +PM_CL="/DMEOW_HEADER=stdfloat" PM_CL="/DMEOW_HEADER=stop_token" PM_CL="/DMEOW_HEADER=streambuf" PM_CL="/DMEOW_HEADER=string" From 7506843ab524605dc3752c81450d4a0c7df54064 Mon Sep 17 00:00:00 2001 From: "Stephan T. Lavavej" Date: Tue, 21 Mar 2023 11:56:22 -0700 Subject: [PATCH 2/2] Test that complex is trivially copyable. --- tests/std/tests/Dev10_555491_complex_linker_errors/test.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/std/tests/Dev10_555491_complex_linker_errors/test.cpp b/tests/std/tests/Dev10_555491_complex_linker_errors/test.cpp index 4dbe0fed137..7c0efffbf09 100644 --- a/tests/std/tests/Dev10_555491_complex_linker_errors/test.cpp +++ b/tests/std/tests/Dev10_555491_complex_linker_errors/test.cpp @@ -292,4 +292,10 @@ int main() { assert((proj(-inf) == complex{inf, 0.0})); test_gh_2728(); + + // Also test N4928 [complex.numbers.general]/2: + // "Specializations of complex for cv-unqualified floating-point types are trivially-copyable literal types" + STATIC_ASSERT(is_trivially_copyable_v>); + STATIC_ASSERT(is_trivially_copyable_v>); + STATIC_ASSERT(is_trivially_copyable_v>); }