PR libstdc++/91786 fix compilation error with Clang

Message ID 20191125190129.GA359982@redhat.com
State New
Headers show
Series
  • PR libstdc++/91786 fix compilation error with Clang
Related show

Commit Message

Jonathan Wakely Nov. 25, 2019, 7:01 p.m.
PR libstdc++/91786
	* include/bits/fs_path.h (filesystem_error): Move definition before
	the use in u8path.

Tested powerpc64le-linux, committed to trunk.
commit 48db2e15557a1e7bff8ce629c8e9979d0b6d0c29
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Fri Nov 22 00:29:05 2019 +0000

    PR libstdc++/91786 fix compilation error with Clang
    
            PR libstdc++/91786
            * include/bits/fs_path.h (filesystem_error): Move definition before
            the use in u8path.

Patch

diff --git a/libstdc++-v3/include/bits/fs_path.h b/libstdc++-v3/include/bits/fs_path.h
index e1083acf30f..031ec3d7c7f 100644
--- a/libstdc++-v3/include/bits/fs_path.h
+++ b/libstdc++-v3/include/bits/fs_path.h
@@ -622,59 +622,6 @@  _GLIBCXX_BEGIN_NAMESPACE_CXX11
 
   size_t hash_value(const path& __p) noexcept;
 
-  /// Create a path from a UTF-8-encoded sequence of char
-  template<typename _InputIterator>
-    inline auto
-    u8path(_InputIterator __first, _InputIterator __last)
-    -> decltype(filesystem::path(__first, __last, std::locale::classic()))
-    {
-#ifdef _GLIBCXX_FILESYSTEM_IS_WINDOWS
-      // XXX This assumes native wide encoding is UTF-16.
-      std::codecvt_utf8_utf16<path::value_type> __cvt;
-      path::string_type __tmp;
-      if constexpr (is_pointer_v<_InputIterator>)
-	{
-	  if (__str_codecvt_in_all(__first, __last, __tmp, __cvt))
-	    return path{ __tmp };
-	}
-      else
-	{
-	  const std::string __u8str{__first, __last};
-	  const char* const __ptr = __u8str.data();
-	  if (__str_codecvt_in_all(__ptr, __ptr + __u8str.size(), __tmp, __cvt))
-	    return path{ __tmp };
-	}
-      _GLIBCXX_THROW_OR_ABORT(filesystem_error(
-	    "Cannot convert character sequence",
-	    std::make_error_code(errc::illegal_byte_sequence)));
-#else
-      // This assumes native normal encoding is UTF-8.
-      return path{ __first, __last };
-#endif
-    }
-
-  /// Create a path from a UTF-8-encoded sequence of char
-  template<typename _Source>
-    inline auto
-    u8path(const _Source& __source)
-    -> decltype(filesystem::path(__source, std::locale::classic()))
-    {
-#ifdef _GLIBCXX_FILESYSTEM_IS_WINDOWS
-      if constexpr (is_convertible_v<const _Source&, std::string_view>)
-	{
-	  const std::string_view __s = __source;
-	  return filesystem::u8path(__s.data(), __s.data() + __s.size());
-	}
-      else
-	{
-	  std::string __s = path::_S_string_from_iter(__source);
-	  return filesystem::u8path(__s.data(), __s.data() + __s.size());
-	}
-#else
-      return path{ __source };
-#endif
-    }
-
   /// @}
 
   /// Exception type thrown by the Filesystem library
@@ -706,6 +653,65 @@  _GLIBCXX_BEGIN_NAMESPACE_CXX11
     std::__shared_ptr<const _Impl> _M_impl;
   };
 
+  /** Create a path from a UTF-8-encoded sequence of char
+   *
+   * @relates std::filesystem::path
+   */
+  template<typename _InputIterator>
+    inline auto
+    u8path(_InputIterator __first, _InputIterator __last)
+    -> decltype(filesystem::path(__first, __last, std::locale::classic()))
+    {
+#ifdef _GLIBCXX_FILESYSTEM_IS_WINDOWS
+      // XXX This assumes native wide encoding is UTF-16.
+      std::codecvt_utf8_utf16<path::value_type> __cvt;
+      path::string_type __tmp;
+      if constexpr (is_pointer_v<_InputIterator>)
+	{
+	  if (__str_codecvt_in_all(__first, __last, __tmp, __cvt))
+	    return path{ __tmp };
+	}
+      else
+	{
+	  const std::string __u8str{__first, __last};
+	  const char* const __ptr = __u8str.data();
+	  if (__str_codecvt_in_all(__ptr, __ptr + __u8str.size(), __tmp, __cvt))
+	    return path{ __tmp };
+	}
+      _GLIBCXX_THROW_OR_ABORT(filesystem_error(
+	    "Cannot convert character sequence",
+	    std::make_error_code(errc::illegal_byte_sequence)));
+#else
+      // This assumes native normal encoding is UTF-8.
+      return path{ __first, __last };
+#endif
+    }
+
+  /** Create a path from a UTF-8-encoded sequence of char
+   *
+   * @relates std::filesystem::path
+   */
+  template<typename _Source>
+    inline auto
+    u8path(const _Source& __source)
+    -> decltype(filesystem::path(__source, std::locale::classic()))
+    {
+#ifdef _GLIBCXX_FILESYSTEM_IS_WINDOWS
+      if constexpr (is_convertible_v<const _Source&, std::string_view>)
+	{
+	  const std::string_view __s = __source;
+	  return filesystem::u8path(__s.data(), __s.data() + __s.size());
+	}
+      else
+	{
+	  std::string __s = path::_S_string_from_iter(__source);
+	  return filesystem::u8path(__s.data(), __s.data() + __s.size());
+	}
+#else
+      return path{ __source };
+#endif
+    }
+
   /// @cond undocumented
 
   struct path::_Cmpt : path