[libcxx-commits] [libcxx] [libc++] Do not forward-declare syncstream outside experimental (PR #82511)

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Thu Feb 29 07:53:44 PST 2024


https://github.com/ldionne updated https://github.com/llvm/llvm-project/pull/82511

>From eb443dc150b439587d46fa904cabad63733cec90 Mon Sep 17 00:00:00 2001
From: Louis Dionne <ldionne.2 at gmail.com>
Date: Wed, 21 Feb 2024 09:27:09 -0800
Subject: [PATCH 1/4] [libc++] Do not forward-declare syncstream outside
 experimental

We only define the classes in <syncstream> when experimental
library features are enabled, but we would forward-declare
them in <iosfwd> even when they are disabled. This led to
confusing error messages about being unable to instantiate
an undefined template.
---
 libcxx/include/iosfwd | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libcxx/include/iosfwd b/libcxx/include/iosfwd
index e28998d004156d..728700853fb331 100644
--- a/libcxx/include/iosfwd
+++ b/libcxx/include/iosfwd
@@ -143,7 +143,7 @@ typedef fpos<mbstate_t> u8streampos;
 typedef fpos<mbstate_t> u16streampos;
 typedef fpos<mbstate_t> u32streampos;
 
-#if _LIBCPP_STD_VER >= 20
+#if _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_SYNCSTREAM)
 
 template <class _CharT, class _Traits = char_traits<_CharT>, class _Allocator = allocator<_CharT>>
 class basic_syncbuf;
@@ -161,7 +161,7 @@ using osyncstream = basic_osyncstream<char>;
 using wosyncstream = basic_osyncstream<wchar_t>;
 #  endif
 
-#endif // _LIBCPP_STD_VER >=20
+#endif // _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_SYNCSTREAM)
 
 // Include other forward declarations here
 template <class _Tp, class _Alloc = allocator<_Tp> >

>From 59c8aef2b241453c4b0220133c06d1c34591f5ac Mon Sep 17 00:00:00 2001
From: Louis Dionne <ldionne.2 at gmail.com>
Date: Tue, 27 Feb 2024 17:34:21 -0500
Subject: [PATCH 2/4] Fix iosfwd module in non-experimental mode

---
 libcxx/modules/std/iosfwd.inc | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/libcxx/modules/std/iosfwd.inc b/libcxx/modules/std/iosfwd.inc
index 410fb6aefed801..44759efd150897 100644
--- a/libcxx/modules/std/iosfwd.inc
+++ b/libcxx/modules/std/iosfwd.inc
@@ -18,18 +18,22 @@ export namespace std {
   using std::u8streampos;
 #endif
 
+#ifndef _LIBCPP_HAS_NO_EXPERIMENTAL_SYNCSTREAM
   using std::basic_osyncstream;
   using std::basic_syncbuf;
+#endif
 
   using std::istreambuf_iterator;
   using std::ostreambuf_iterator;
 
+#ifndef _LIBCPP_HAS_NO_EXPERIMENTAL_SYNCSTREAM
   using std::osyncstream;
   using std::syncbuf;
 
-#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
   using std::wosyncstream;
   using std::wsyncbuf;
+# endif
 #endif
 
   using std::fpos;

>From b52ca7815c05bb2d24cca850501f993dd27e228d Mon Sep 17 00:00:00 2001
From: Louis Dionne <ldionne.2 at gmail.com>
Date: Wed, 28 Feb 2024 09:22:18 -0500
Subject: [PATCH 3/4] Format .inc file

---
 libcxx/modules/std/iosfwd.inc | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libcxx/modules/std/iosfwd.inc b/libcxx/modules/std/iosfwd.inc
index 44759efd150897..628e0149002b7c 100644
--- a/libcxx/modules/std/iosfwd.inc
+++ b/libcxx/modules/std/iosfwd.inc
@@ -30,10 +30,10 @@ export namespace std {
   using std::osyncstream;
   using std::syncbuf;
 
-# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+#  ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
   using std::wosyncstream;
   using std::wsyncbuf;
-# endif
+#  endif
 #endif
 
   using std::fpos;

>From aa9513506cffbe4b1476526e923509be54b45cd2 Mon Sep 17 00:00:00 2001
From: Louis Dionne <ldionne.2 at gmail.com>
Date: Thu, 29 Feb 2024 10:52:12 -0500
Subject: [PATCH 4/4] Add endif comment

---
 libcxx/modules/std/iosfwd.inc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libcxx/modules/std/iosfwd.inc b/libcxx/modules/std/iosfwd.inc
index 628e0149002b7c..090d990d061e5e 100644
--- a/libcxx/modules/std/iosfwd.inc
+++ b/libcxx/modules/std/iosfwd.inc
@@ -34,7 +34,7 @@ export namespace std {
   using std::wosyncstream;
   using std::wsyncbuf;
 #  endif
-#endif
+#endif // _LIBCPP_HAS_NO_EXPERIMENTAL_SYNCSTREAM
 
   using std::fpos;
 } // namespace std



More information about the libcxx-commits mailing list