On Fri, May 23, 2025 at 1:52 PM Jonathan Wakely <jwak...@redhat.com> wrote:
> On 23/05/25 10:03 +0100, Jonathan Wakely wrote: > >On 22/05/25 14:50 +0200, Tomasz Kamiński wrote: > >>From: Jonathan Wakely <jwak...@redhat.com> > >> > >>This papers implements C++26 std::indirect as specified > >>in P3019 with amendment to move assignment from LWG 4251. > >> > >> PR libstdc++/119152 > >> > >>libstdc++-v3/ChangeLog: > >> > >> * include/Makefile.am: Add new header. > >> * include/Makefile.in: Regenerate. > >> * include/bits/indirect.h: New file. > >> * include/bits/version.def (indirect): Define. > >> * include/bits/version.h: Regenerate. > >> * include/std/memory: Include new header. > >> * testsuite/std/memory/indirect/copy.cc > >> * testsuite/std/memory/indirect/copy_alloc.cc > >> * testsuite/std/memory/indirect/ctor.cc > >> * testsuite/std/memory/indirect/incomplete.cc > >> * testsuite/std/memory/indirect/invalid_neg.cc > >> * testsuite/std/memory/indirect/move.cc > >> * testsuite/std/memory/indirect/move_alloc.cc > >> * testsuite/std/memory/indirect/relops.cc > >> > >>Co-authored-by: Tomasz Kamiński <tkami...@redhat.com> > >>Signed-off-by: Tomasz Kamiński <tkami...@redhat.com> > >>--- > >>Changes in v2: > >>- Fixed typos in commit messages as pointed by Jakub > >>- Removed stray comment in indirect.h header as pointed out by Daniel > >> > >>libstdc++-v3/include/Makefile.am | 1 + > >>libstdc++-v3/include/Makefile.in | 1 + > >>libstdc++-v3/include/bits/indirect.h | 459 ++++++++++++++++++ > >>libstdc++-v3/include/bits/version.def | 9 + > >>libstdc++-v3/include/bits/version.h | 10 + > >>libstdc++-v3/include/std/memory | 5 + > >>.../testsuite/std/memory/indirect/copy.cc | 121 +++++ > >>.../std/memory/indirect/copy_alloc.cc | 228 +++++++++ > >>.../testsuite/std/memory/indirect/ctor.cc | 203 ++++++++ > >>.../std/memory/indirect/incomplete.cc | 38 ++ > >>.../std/memory/indirect/invalid_neg.cc | 28 ++ > >>.../testsuite/std/memory/indirect/move.cc | 144 ++++++ > >>.../std/memory/indirect/move_alloc.cc | 296 +++++++++++ > >>.../testsuite/std/memory/indirect/relops.cc | 82 ++++ > >>14 files changed, 1625 insertions(+) > >>create mode 100644 libstdc++-v3/include/bits/indirect.h > >>create mode 100644 libstdc++-v3/testsuite/std/memory/indirect/copy.cc > >>create mode 100644 > libstdc++-v3/testsuite/std/memory/indirect/copy_alloc.cc > >>create mode 100644 libstdc++-v3/testsuite/std/memory/indirect/ctor.cc > >>create mode 100644 > libstdc++-v3/testsuite/std/memory/indirect/incomplete.cc > >>create mode 100644 > libstdc++-v3/testsuite/std/memory/indirect/invalid_neg.cc > >>create mode 100644 libstdc++-v3/testsuite/std/memory/indirect/move.cc > >>create mode 100644 > libstdc++-v3/testsuite/std/memory/indirect/move_alloc.cc > >>create mode 100644 libstdc++-v3/testsuite/std/memory/indirect/relops.cc > >> > >>diff --git a/libstdc++-v3/include/Makefile.am > b/libstdc++-v3/include/Makefile.am > >>index 3e5b6c4142e..b67d470c27e 100644 > >>--- a/libstdc++-v3/include/Makefile.am > >>+++ b/libstdc++-v3/include/Makefile.am > >>@@ -210,6 +210,7 @@ bits_headers = \ > >> ${bits_srcdir}/gslice_array.h \ > >> ${bits_srcdir}/hashtable.h \ > >> ${bits_srcdir}/hashtable_policy.h \ > >>+ ${bits_srcdir}/indirect.h \ > >> ${bits_srcdir}/indirect_array.h \ > >> ${bits_srcdir}/ios_base.h \ > >> ${bits_srcdir}/istream.tcc \ > >>diff --git a/libstdc++-v3/include/Makefile.in > b/libstdc++-v3/include/Makefile.in > >>index 3531162b5f7..6f7f2be68fd 100644 > >>--- a/libstdc++-v3/include/Makefile.in > >>+++ b/libstdc++-v3/include/Makefile.in > >>@@ -563,6 +563,7 @@ bits_freestanding = \ > >>@GLIBCXX_HOSTED_TRUE@ ${bits_srcdir}/gslice_array.h \ > >>@GLIBCXX_HOSTED_TRUE@ ${bits_srcdir}/hashtable.h \ > >>@GLIBCXX_HOSTED_TRUE@ ${bits_srcdir}/hashtable_policy.h \ > >>+@GLIBCXX_HOSTED_TRUE@ ${bits_srcdir}/indirect.h \ > >>@GLIBCXX_HOSTED_TRUE@ ${bits_srcdir}/indirect_array.h \ > >>@GLIBCXX_HOSTED_TRUE@ ${bits_srcdir}/ios_base.h \ > >>@GLIBCXX_HOSTED_TRUE@ ${bits_srcdir}/istream.tcc \ > >>diff --git a/libstdc++-v3/include/bits/indirect.h > b/libstdc++-v3/include/bits/indirect.h > >>new file mode 100644 > >>index 00000000000..3fd9807a8fd > >>--- /dev/null > >>+++ b/libstdc++-v3/include/bits/indirect.h > >>@@ -0,0 +1,459 @@ > >>+// Vocabulary Types for Composite Class Design -*- C++ -*- > >>+ > >>+// Copyright The GNU Toolchain Authors. > >>+// > >>+// This file is part of the GNU ISO C++ Library. This library is free > >>+// software; you can redistribute it and/or modify it under the > >>+// terms of the GNU General Public License as published by the > >>+// Free Software Foundation; either version 3, or (at your option) > >>+// any later version. > >>+ > >>+// This library is distributed in the hope that it will be useful, > >>+// but WITHOUT ANY WARRANTY; without even the implied warranty of > >>+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > >>+// GNU General Public License for more details. > >>+ > >>+// Under Section 7 of GPL version 3, you are granted additional > >>+// permissions described in the GCC Runtime Library Exception, version > >>+// 3.1, as published by the Free Software Foundation. > >>+ > >>+// You should have received a copy of the GNU General Public License and > >>+// a copy of the GCC Runtime Library Exception along with this program; > >>+// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see > >>+// <http://www.gnu.org/licenses/>. > >>+ > >>+/** @file include/bits/indirect.h > >>+ * This is an internal header file, included by other library headers. > >>+ * Do not attempt to use it directly. @headername{memory} > >>+ */ > >>+ > >>+#ifndef _GLIBCXX_INDIRECT_H > >>+#define _GLIBCXX_INDIRECT_H 1 > >>+ > >>+#pragma GCC system_header > >>+ > >>+#include <bits/version.h> > >>+ > >>+#ifdef __glibcxx_indirect || __glibcxx_polymorphic // >= C++26 > > > >This needs to be #if defined(x) || defined(y) not #ifdef (my fault). > > Or just #if x || y > Just to confirm, the patch is still OK for trunk with this changed to: #if __glibcxx_indirect || __glibcxx_polymorphic // >= C++26 (And I think this is my fault).