Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom Tromey <tromey@adacore.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tromey@adacore.com>,
	Simon Marchi <simon.marchi@efficios.com>
Subject: [PATCH v3 13/17] Change span-selftests.c for C++20
Date: Tue, 17 Nov 2026 15:10:09 -0700	[thread overview]
Message-ID: <20261117-span-part-1-v3-13-40b8b11d2d8c@adacore.com> (raw)
In-Reply-To: <20261117-span-part-1-v3-0-40b8b11d2d8c@adacore.com>

span-selftests.c has a number of tests that aren't valid for C++20
std::span.  This patch removes these.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31422
Approved-By: Simon Marchi <simon.marchi@efficios.com>
---
 gdb/unittests/span-selftests.c | 27 +++------------------------
 1 file changed, 3 insertions(+), 24 deletions(-)

diff --git a/gdb/unittests/span-selftests.c b/gdb/unittests/span-selftests.c
index eb192bd49fd..e478a5cfabf 100644
--- a/gdb/unittests/span-selftests.c
+++ b/gdb/unittests/span-selftests.c
@@ -364,21 +364,6 @@ check_iterator ()
   SELF_CHECK (sum == 2 + 4 + 6 + 8);
 }
 
-template<typename T>
-static void
-check_const_iterator ()
-{
-  T data[] = {1, 2, 3, 4};
-  gdb::span<T> view (data);
-
-  typename std::decay<T>::type sum = 0;
-  for (typename gdb::span<T>::const_iterator it = view.cbegin ();
-       it != view.cend (); it++)
-    sum += *it;
-
-  SELF_CHECK (sum == 1 + 2 + 3 + 4);
-}
-
 /* Entry point.  */
 
 static void
@@ -422,18 +407,14 @@ run_tests ()
 
     view = vec;
     SELF_CHECK (check_container_view (view, vec));
-    view = std::move (vec);
-    SELF_CHECK (check_container_view (view, vec));
 
     view = array;
     SELF_CHECK (check_container_view (view, array));
-    view = std::move (array);
-    SELF_CHECK (check_container_view (view, array));
 
     gdb_byte elem = 0;
-    view = elem;
+    view = gdb::make_span (&elem, 1);
     SELF_CHECK (check_elem_view (view, elem));
-    view = std::move (elem);
+    view = std::move (gdb::make_span (&elem, 1));
     SELF_CHECK (check_elem_view (view, elem));
   }
 
@@ -506,8 +487,6 @@ run_tests ()
   check_range_for<gdb_byte> ();
   check_range_for<const gdb_byte> ();
   check_iterator<gdb_byte> ();
-  check_const_iterator<gdb_byte> ();
-  check_const_iterator<const gdb_byte> ();
 
   /* Check that the right ctor overloads are taken when the element is
      a container.  */
@@ -519,7 +498,7 @@ run_tests ()
     SELF_CHECK (view_array.size () == 3);
 
     Vec elem;
-    gdb::span<Vec> view_elem = elem;
+    gdb::span<Vec> view_elem = gdb::make_span (&elem, 1);
     SELF_CHECK (view_elem.size () == 1);
   }
 

-- 
2.56.0


  parent reply	other threads:[~2026-11-17 22:11 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-17 22:09 [PATCH v3 00/17] Rename gdb::array_view to gdb::span Tom Tromey
2026-11-17 22:09 ` [PATCH v3 01/17] Rename array_view files Tom Tromey
2026-11-17 22:09 ` [PATCH v3 02/17] Rename gdb::array_view to gdb::span Tom Tromey
2026-11-17 22:09 ` [PATCH v3 03/17] Rename gdb::make_array_view to gdb::make_span Tom Tromey
2026-11-17 22:10 ` [PATCH v3 04/17] Rename gdb_argv::as_array_view Tom Tromey
2026-11-17 22:10 ` [PATCH v3 05/17] Remove operator== and operator!= from gdb::span Tom Tromey
2026-11-17 22:10 ` [PATCH v3 06/17] Rename span::slice to span::subspan Tom Tromey
2026-11-17 22:10 ` [PATCH v3 07/17] Qualify calls to gdb::copy Tom Tromey
2026-11-17 22:10 ` [PATCH v3 08/17] Add single-argument overloads of process_options et al Tom Tromey
2026-11-17 22:10 ` [PATCH v3 09/17] Remove span from cli-option.c:build_help_option Tom Tromey
2026-11-17 22:10 ` [PATCH v3 10/17] Don't use the single-argument gdb::span constructor Tom Tromey
2026-11-17 22:10 ` [PATCH v3 11/17] Don't turn rvalue reference into a span Tom Tromey
2026-11-17 22:10 ` [PATCH v3 12/17] gdb/unittests: use one static_assert per check in span-selftests.c Tom Tromey
2026-11-17 22:10 ` Tom Tromey [this message]
2026-11-17 22:10 ` [PATCH v3 14/17] Make gdb::span conform more closely to C++20 Tom Tromey
2026-11-17 22:10 ` [PATCH v3 15/17] Allow the use of C++20 std::ranges in gdbsupport/ranges.h Tom Tromey
2026-11-17 22:10 ` [PATCH v3 16/17] Allow the use of C++20 std::span in gdbsupport/span.h Tom Tromey
2026-11-17 22:10 ` [PATCH v3 17/17] Move gdb::ranges::equal to gdbsupport/ranges.h Tom Tromey
2026-11-18 15:04 ` [PATCH v3 00/17] Rename gdb::array_view to gdb::span Tom Tromey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261117-span-part-1-v3-13-40b8b11d2d8c@adacore.com \
    --to=tromey@adacore.com \
    --cc=gdb-patches@sourceware.org \
    --cc=simon.marchi@efficios.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox