]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++: Deprecate std::filesystem::u8path for C++20
authorJonathan Wakely <jwakely@redhat.com>
Wed, 18 Jan 2023 14:27:55 +0000 (14:27 +0000)
committerJonathan Wakely <jwakely@redhat.com>
Wed, 18 Jan 2023 21:47:58 +0000 (21:47 +0000)
P0482R6 deprecated these functions for C++20. There was a ballot comment
on the C++23 CD saying to un-deprecate it, but LEWG just rejected that,
so let's add attributes to deprecate them.

libstdc++-v3/ChangeLog:

* include/bits/fs_path.h (u8path): Add deprecated attribute.
* testsuite/27_io/filesystem/path/construct/90281.cc: Add
-Wno-deprecated-declarations for C++20 and later.
* testsuite/27_io/filesystem/path/factory/u8path-char8_t.cc:
Likewise.
* testsuite/27_io/filesystem/path/factory/u8path.cc: Likewise.
* testsuite/27_io/filesystem/path/native/string.cc: Likewise.
* testsuite/27_io/filesystem/path/factory/u8path-depr.cc: New test.

libstdc++-v3/include/bits/fs_path.h
libstdc++-v3/testsuite/27_io/filesystem/path/construct/90281.cc
libstdc++-v3/testsuite/27_io/filesystem/path/factory/u8path-char8_t.cc
libstdc++-v3/testsuite/27_io/filesystem/path/factory/u8path-depr.cc [new file with mode: 0644]
libstdc++-v3/testsuite/27_io/filesystem/path/factory/u8path.cc
libstdc++-v3/testsuite/27_io/filesystem/path/native/string.cc

index 5f18f2314d1f1faf9566f1b0ca0a6a8f0bd0c302..1cbfaaa542790d268307b913e14de579fd8f461e 100644 (file)
@@ -808,6 +808,7 @@ namespace __detail
           typename _Require = __detail::_Path2<_InputIterator>,
           typename _CharT
             = __detail::__value_type_is_char_or_char8_t<_InputIterator>>
+    _GLIBCXX20_DEPRECATED_SUGGEST("path(u8string(first, last))")
     inline path
     u8path(_InputIterator __first, _InputIterator __last)
     {
@@ -830,6 +831,7 @@ namespace __detail
   template<typename _Source,
           typename _Require = __detail::_Path<_Source>,
           typename _CharT = __detail::__value_type_is_char_or_char8_t<_Source>>
+    _GLIBCXX20_DEPRECATED_SUGGEST("path((const char8_t*)&*source)")
     inline path
     u8path(const _Source& __source)
     {
index 4b38646c0e0896f1afb3e9a528b3b11c8121f7b9..d26b5e15b298607d75e7587a9db89370678d066c 100644 (file)
@@ -16,6 +16,7 @@
 // <http://www.gnu.org/licenses/>.
 
 // { dg-do run { target c++17 } }
+// { dg-additional-options "-Wno-deprecated-declarations" { target c++20 } }
 
 #include <filesystem>
 #include <testsuite_hooks.h>
index ceedd5fbdc239b21fa6ba825a03c197a1816d885..eff95c18bdfb5d083718f658311d2cdf1bdb87e8 100644 (file)
@@ -17,6 +17,7 @@
 
 // { dg-options "-fchar8_t -Wno-stringop-overread" }
 // { dg-do run { target c++17 } }
+// { dg-additional-options "-Wno-deprecated-declarations" { target c++20 } }
 
 #include <filesystem>
 #include <string_view>
diff --git a/libstdc++-v3/testsuite/27_io/filesystem/path/factory/u8path-depr.cc b/libstdc++-v3/testsuite/27_io/filesystem/path/factory/u8path-depr.cc
new file mode 100644 (file)
index 0000000..de54668
--- /dev/null
@@ -0,0 +1,16 @@
+// { dg-options "-std=gnu++20" }
+// { dg-do compile { target c++20 } }
+
+#include <filesystem>
+
+namespace fs = std::filesystem;
+
+const char* s = "";
+auto p1 = fs::u8path(s); // { dg-warning "deprecated" }
+auto p2 = fs::u8path(s, s); // { dg-warning "deprecated" }
+
+#if __cpp_lib_char8_t
+const char8_t* u = u8"";
+auto p3 = fs::u8path(u); // { dg-warning "deprecated" }
+auto p4 = fs::u8path(u, u); // { dg-warning "deprecated" }
+#endif
index 726b3eaadd85b103558b6ebc2c6bca028b3fb61d..4c41fc28da9e2caff6e56be21c9ad92cb4be95dd 100644 (file)
@@ -16,6 +16,7 @@
 // <http://www.gnu.org/licenses/>.
 
 // { dg-do run { target c++17 } }
+// { dg-additional-options "-Wno-deprecated-declarations" { target c++20 } }
 
 #include <filesystem>
 #include <string_view>
index 8620c15fa8897cb3152721b905c73de4b09e3bc7..d5942c9beaac59ef6728d881c83ec68fd258dd36 100644 (file)
@@ -16,6 +16,7 @@
 // <http://www.gnu.org/licenses/>.
 
 // { dg-do run { target c++17 } }
+// { dg-additional-options "-Wno-deprecated-declarations" { target c++20 } }
 
 #include <filesystem>
 #include <string>