public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 00/11] GDB: Require C++17
@ 2023-10-13 14:44 Lancelot Six
  2023-10-13 14:44 ` [PATCH 01/11] gdb/ax_cxx_compile_stdcxx.m4: upgrade Lancelot Six
                   ` (11 more replies)
  0 siblings, 12 replies; 39+ messages in thread
From: Lancelot Six @ 2023-10-13 14:44 UTC (permalink / raw)
  To: gdb-patches; +Cc: Lancelot Six

Hi all,

This series is a followup of the discussions from last Cauldron and Tom's
RFC patch[1] regarding requiring C++17 in GDB.  It seems that the
overall sentiment is positive for such move, so here is a proper series.

The first patch in the series is a preparatory step to improve
configure's C++ dialect detection, importing recent changes from
upstream autoconf to our locally maintained ax_cxx_compile_stdcxx.m4.

Patch #2 is almost identical to what Tom sent[1], except that the
regenerated configure scripts profit from patch #1.

Patch #3 to #9 removes some locally maintained equivalent of features
now available in C++17 standard library (std::make_unique,
std::optional, std::string_view, stt::invoke_result).

Finally, some places in GDB used to use some custom implementations
depending on the current compiler's C++ version.  Patch #10 and #11
remove the pre-C++17 branches (and the need for conditional
compilation).

Given that the patches can be big, I am not sure they will all make it
through the mailing list.  I have also pushed them under the
`users/lsix/try-require-c++17` branch (there might be minor differences
between the patch and the branch as I fix typos in the commit messages).

I have tested this series on x86_64 GNU/Linux (Ubuntu-22.04) and have
seen no regression.  The try-bots did not report any issue either.

I expect no user visible change after this series.

As usual, all feedbacks are welcome.

All the best,
Lancelot.

[1] https://sourceware.org/pipermail/gdb-patches/2023-October/202987.html

Lancelot Six (11):
  gdb/ax_cxx_compile_stdcxx.m4: upgrade
  gdb/gdbsupport/gdbserver: Require c++17
  gdb: Use C++17's std::make_unique instead of gdb::make_unique
  gdb: Replace gdb::optional with std::optional
  gdbsupport: remove gdb::optional
  gdb: Use std::string_view instead of gdb::string_view
  gdb: Remove uses of gdb::to_string (const std::string_view &)
  gdbsupport: Remove gdb::string_view
  gdbsupport: Replace gdb::invoke_result with std::invoke_result
  gdb/disasm.h: Mark callbacks noexcept unconditionally
  gdb: Use initializers in lambda captures unconditionally

 gdb/Makefile.in                               |    2 -
 gdb/NEWS                                      |    3 +
 gdb/aarch64-linux-tdep.c                      |   10 +-
 gdb/ada-lang.c                                |   34 +-
 gdb/ada-lex.l                                 |    2 +-
 gdb/ada-valprint.c                            |    4 +-
 gdb/addrmap.c                                 |    3 +-
 gdb/amd-dbgapi-target.c                       |    4 +-
 gdb/amdgpu-tdep.c                             |   68 +-
 gdb/annotate.c                                |    2 +-
 gdb/arm-fbsd-tdep.c                           |    6 +-
 gdb/arm-fbsd-tdep.h                           |    2 +-
 gdb/arm-linux-tdep.c                          |    2 +-
 gdb/arm-tdep.c                                |    4 +-
 gdb/auto-load.c                               |    2 +-
 gdb/auxv.c                                    |   10 +-
 gdb/auxv.h                                    |    4 +-
 gdb/avr-tdep.c                                |    2 +-
 gdb/ax_cxx_compile_stdcxx.m4                  |  126 +-
 gdb/break-catch-load.c                        |    3 +-
 gdb/breakpoint.c                              |   19 +-
 gdb/buildsym.c                                |    2 +-
 gdb/cli/cli-cmds.c                            |    6 +-
 gdb/cli/cli-cmds.h                            |    4 +-
 gdb/cli/cli-decode.c                          |    4 +-
 gdb/cli/cli-decode.h                          |    2 +-
 gdb/cli/cli-option.c                          |   14 +-
 gdb/cli/cli-option.h                          |    2 +-
 gdb/cli/cli-script.c                          |    4 +-
 gdb/command.h                                 |    2 +-
 gdb/compile/compile-c-support.c               |    3 +-
 gdb/compile/compile.c                         |    4 +-
 gdb/config.in                                 |    4 +-
 gdb/configure                                 | 1994 +++++++++++++++--
 gdb/configure.ac                              |    4 +-
 gdb/cp-name-parser.y                          |    3 +-
 gdb/cp-support.c                              |   11 +-
 gdb/darwin-nat.c                              |    2 +-
 gdb/dbxread.c                                 |   18 +-
 gdb/debuginfod-support.c                      |   19 +-
 gdb/disasm.c                                  |   14 +-
 gdb/disasm.h                                  |   29 +-
 gdb/dwarf2/attribute.h                        |    2 +-
 gdb/dwarf2/cooked-index.c                     |   13 +-
 gdb/dwarf2/cooked-index.h                     |    2 +-
 gdb/dwarf2/cu.h                               |    8 +-
 gdb/dwarf2/die.h                              |    4 +-
 gdb/dwarf2/frame.c                            |    3 +-
 gdb/dwarf2/index-cache.h                      |    2 +-
 gdb/dwarf2/index-common.c                     |    2 +-
 gdb/dwarf2/index-common.h                     |    2 +-
 gdb/dwarf2/index-write.c                      |    4 +-
 gdb/dwarf2/line-header.c                      |    4 +-
 gdb/dwarf2/macro.c                            |    4 +-
 gdb/dwarf2/macro.h                            |    2 +-
 gdb/dwarf2/read-debug-names.c                 |    3 +-
 gdb/dwarf2/read-gdb-index.c                   |    7 +-
 gdb/dwarf2/read.c                             |   31 +-
 gdb/dwarf2/read.h                             |    2 +-
 gdb/elfread.c                                 |    8 +-
 gdb/eval.c                                    |    2 +-
 gdb/event-top.c                               |    2 +-
 gdb/exceptions.c                              |    4 +-
 gdb/extension-priv.h                          |    6 +-
 gdb/extension.c                               |   12 +-
 gdb/extension.h                               |    8 +-
 gdb/f-lang.c                                  |    2 +-
 gdb/fbsd-nat.c                                |    6 +-
 gdb/fbsd-nat.h                                |    4 +-
 gdb/fbsd-tdep.c                               |    8 +-
 gdb/gdb_bfd.c                                 |    2 +-
 gdb/gdbthread.h                               |    8 +-
 gdb/gdbtypes.c                                |   21 +-
 gdb/gdbtypes.h                                |    8 +-
 gdb/guile/scm-ports.c                         |    4 +-
 gdb/ia64-tdep.c                               |    4 +-
 gdb/inf-child.c                               |    2 +-
 gdb/inf-child.h                               |    2 +-
 gdb/infcmd.c                                  |    4 +-
 gdb/inferior.c                                |    4 +-
 gdb/inferior.h                                |    2 +-
 gdb/inflow.c                                  |    4 +-
 gdb/infrun.c                                  |   12 +-
 gdb/interps.c                                 |    2 +-
 gdb/interps.h                                 |    4 +-
 gdb/jit.c                                     |    2 +-
 gdb/language.c                                |    2 +-
 gdb/linux-nat.c                               |    4 +-
 gdb/linux-nat.h                               |    2 +-
 gdb/linux-tdep.c                              |   26 +-
 gdb/linux-tdep.h                              |    4 +-
 gdb/linux-thread-db.c                         |    2 +-
 gdb/main.c                                    |    4 +-
 gdb/mdebugread.c                              |   18 +-
 gdb/mi/mi-cmd-stack.c                         |    4 +-
 gdb/mi/mi-cmd-var.c                           |    2 +-
 gdb/mi/mi-cmds.c                              |    2 +-
 gdb/mi/mi-cmds.h                              |    8 +-
 gdb/mi/mi-interp.c                            |    2 +-
 gdb/mi/mi-interp.h                            |    2 +-
 gdb/mi/mi-main.c                              |   15 +-
 gdb/mi/mi-out.c                               |    7 +-
 gdb/minsyms.c                                 |    4 +-
 gdb/minsyms.h                                 |    2 +-
 gdb/nat/linux-btrace.c                        |    5 +-
 gdb/nat/linux-osdata.c                        |    8 +-
 gdb/nat/windows-nat.c                         |    6 +-
 gdb/nat/windows-nat.h                         |    4 +-
 gdb/observable.h                              |    2 +-
 gdb/osdata.c                                  |    2 +-
 gdb/parse.c                                   |    4 +-
 gdb/ppc-linux-nat.c                           |    4 +-
 gdb/ppc-linux-tdep.c                          |    2 +-
 gdb/ppc-tdep.h                                |    2 +-
 gdb/printcmd.c                                |    6 +-
 gdb/probe.c                                   |   22 +-
 gdb/procfs.c                                  |    2 +-
 gdb/psymtab.c                                 |    4 +-
 gdb/psymtab.h                                 |    6 +-
 gdb/python/py-disasm.c                        |   22 +-
 gdb/python/py-framefilter.c                   |   10 +-
 gdb/python/py-inferior.c                      |    2 +-
 gdb/python/py-mi.c                            |    5 +-
 gdb/python/py-utils.c                         |    4 +-
 gdb/python/py-varobj.c                        |    3 +-
 gdb/python/python-internal.h                  |    4 +-
 gdb/python/python.c                           |    8 +-
 gdb/ravenscar-thread.c                        |    4 +-
 gdb/record-btrace.c                           |    8 +-
 gdb/regcache.c                                |    4 +-
 gdb/remote.c                                  |   16 +-
 gdb/riscv-tdep.c                              |    2 +-
 gdb/s390-linux-tdep.c                         |    2 +-
 gdb/skip.c                                    |    4 +-
 gdb/solib-aix.c                               |   14 +-
 gdb/solib-dsbt.c                              |    2 +-
 gdb/solib-rocm.c                              |   28 +-
 gdb/solib-svr4.c                              |   16 +-
 gdb/solib-target.c                            |    2 +-
 gdb/source-cache.c                            |    2 +-
 gdb/split-name.c                              |    4 +-
 gdb/split-name.h                              |    4 +-
 gdb/stabsread.c                               |    2 +-
 gdb/stack.c                                   |   16 +-
 gdb/stack.h                                   |    2 +-
 gdb/symfile.c                                 |    2 +-
 gdb/symtab.c                                  |   38 +-
 gdb/symtab.h                                  |   38 +-
 gdb/target.c                                  |   16 +-
 gdb/target.h                                  |   10 +-
 gdb/thread.c                                  |   14 +-
 gdb/tracefile-tfile.c                         |    2 +-
 gdb/tracepoint.c                              |    2 +-
 gdb/tui/tui-disasm.c                          |    2 +-
 gdb/tui/tui-io.c                              |    2 +-
 gdb/tui/tui-layout.c                          |    2 +-
 gdb/tui/tui-win.c                             |    6 +-
 gdb/ui-out.c                                  |    4 +-
 gdb/unittests/basic_string_view/capacity/1.cc |  172 --
 .../basic_string_view/capacity/empty_neg.cc   |   28 -
 .../basic_string_view/cons/char/1.cc          |   67 -
 .../basic_string_view/cons/char/2.cc          |   46 -
 .../basic_string_view/cons/char/3.cc          |   39 -
 .../basic_string_view/cons/wchar_t/1.cc       |   68 -
 .../basic_string_view/cons/wchar_t/2.cc       |   45 -
 .../basic_string_view/cons/wchar_t/3.cc       |   38 -
 .../element_access/char/1.cc                  |   70 -
 .../element_access/char/2.cc                  |   30 -
 .../element_access/char/empty.cc              |   39 -
 .../element_access/char/front_back.cc         |   43 -
 .../element_access/wchar_t/1.cc               |   71 -
 .../element_access/wchar_t/2.cc               |   32 -
 .../element_access/wchar_t/empty.cc           |   38 -
 .../element_access/wchar_t/front_back.cc      |   42 -
 gdb/unittests/basic_string_view/include.cc    |   25 -
 .../basic_string_view/inserters/char/1.cc     |   65 -
 .../basic_string_view/inserters/char/2.cc     |   91 -
 .../basic_string_view/inserters/char/3.cc     |   54 -
 .../inserters/pod/10081-out.cc                |   75 -
 .../basic_string_view/inserters/wchar_t/1.cc  |   70 -
 .../basic_string_view/inserters/wchar_t/2.cc  |   91 -
 .../basic_string_view/inserters/wchar_t/3.cc  |   53 -
 .../basic_string_view/literals/types.cc       |   45 -
 .../basic_string_view/literals/values.cc      |   72 -
 .../modifiers/remove_prefix/char/1.cc         |   66 -
 .../modifiers/remove_prefix/wchar_t/1.cc      |   61 -
 .../modifiers/remove_suffix/char/1.cc         |   66 -
 .../modifiers/remove_suffix/wchar_t/1.cc      |   61 -
 .../modifiers/swap/char/1.cc                  |   36 -
 .../modifiers/swap/wchar_t/1.cc               |   35 -
 .../operations/compare/char/1.cc              |  132 --
 .../operations/compare/char/13650.cc          |   50 -
 .../operations/compare/char/2.cc              |   30 -
 .../operations/compare/char/70483.cc          |   89 -
 .../operations/compare/wchar_t/1.cc           |  133 --
 .../operations/compare/wchar_t/13650.cc       |   49 -
 .../operations/compare/wchar_t/2.cc           |   30 -
 .../operations/copy/char/1.cc                 |   46 -
 .../operations/copy/wchar_t/1.cc              |   46 -
 .../operations/data/char/1.cc                 |   44 -
 .../operations/data/wchar_t/1.cc              |   43 -
 .../operations/find/char/1.cc                 |  168 --
 .../operations/find/char/2.cc                 |  166 --
 .../operations/find/char/3.cc                 |  166 --
 .../operations/find/char/4.cc                 |   45 -
 .../operations/find/wchar_t/1.cc              |  163 --
 .../operations/find/wchar_t/2.cc              |  161 --
 .../operations/find/wchar_t/3.cc              |  161 --
 .../operations/find/wchar_t/4.cc              |   44 -
 .../operations/rfind/char/1.cc                |   95 -
 .../operations/rfind/char/2.cc                |   53 -
 .../operations/rfind/char/3.cc                |   68 -
 .../operations/rfind/wchar_t/1.cc             |   94 -
 .../operations/rfind/wchar_t/2.cc             |   52 -
 .../operations/rfind/wchar_t/3.cc             |   66 -
 .../operations/string_conversion/1.cc         |   51 -
 .../operations/substr/char/1.cc               |   79 -
 .../operations/substr/wchar_t/1.cc            |   79 -
 .../basic_string_view/operators/char/2.cc     |  373 ---
 .../basic_string_view/operators/wchar_t/2.cc  |  367 ---
 .../basic_string_view/range_access/char/1.cc  |   47 -
 .../range_access/wchar_t/1.cc                 |   47 -
 .../requirements/explicit_instantiation/1.cc  |   26 -
 .../explicit_instantiation/char/1.cc          |   23 -
 .../explicit_instantiation/char16_t/1.cc      |   24 -
 .../explicit_instantiation/char32_t/1.cc      |   24 -
 .../explicit_instantiation/wchar_t/1.cc       |   23 -
 .../requirements/typedefs.cc                  |   47 -
 gdb/unittests/basic_string_view/typedefs.cc   |   36 -
 gdb/unittests/basic_string_view/types/1.cc    |   43 -
 gdb/unittests/optional-selftests.c            |   95 -
 gdb/unittests/optional/assignment/1.cc        |  196 --
 gdb/unittests/optional/assignment/2.cc        |  194 --
 gdb/unittests/optional/assignment/3.cc        |  157 --
 gdb/unittests/optional/assignment/4.cc        |  157 --
 gdb/unittests/optional/assignment/5.cc        |   81 -
 gdb/unittests/optional/assignment/6.cc        |   91 -
 gdb/unittests/optional/assignment/7.cc        |   30 -
 gdb/unittests/optional/cons/copy.cc           |  127 --
 gdb/unittests/optional/cons/default.cc        |   59 -
 gdb/unittests/optional/cons/move.cc           |  125 --
 gdb/unittests/optional/cons/value.cc          |  295 ---
 gdb/unittests/optional/in_place.cc            |   66 -
 gdb/unittests/optional/observers/1.cc         |   32 -
 gdb/unittests/optional/observers/2.cc         |   36 -
 gdb/unittests/parallel-for-selftests.c        |    5 +-
 gdb/unittests/string_view-selftests.c         |  193 --
 gdb/utils.c                                   |    6 +-
 gdb/valarith.c                                |    4 +-
 gdb/valops.c                                  |    6 +-
 gdb/value.c                                   |    2 +-
 gdb/value.h                                   |    4 +-
 gdb/varobj.c                                  |    3 +-
 gdb/windows-nat.c                             |   10 +-
 gdb/xcoffread.c                               |   18 +-
 gdb/xml-support.c                             |    4 +-
 gdb/xml-support.h                             |    6 +-
 gdb/xml-syscall.c                             |    2 +-
 gdb/xml-tdesc.c                               |   12 +-
 gdb/xml-tdesc.h                               |    4 +-
 gdbserver/config.in                           |    4 +-
 gdbserver/configure                           | 1980 ++++++++++++++--
 gdbserver/configure.ac                        |    4 +-
 gdbserver/linux-aarch64-low.cc                |    4 +-
 gdbserver/regcache.cc                         |    4 +-
 gdbserver/regcache.h                          |    2 +-
 gdbserver/win32-low.cc                        |    2 +-
 gdbsupport/Makefile.in                        |    2 +-
 gdbsupport/common-debug.h                     |    4 +-
 gdbsupport/common-utils.h                     |    8 +-
 gdbsupport/config.in                          |    4 +-
 gdbsupport/configure                          | 1980 ++++++++++++++--
 gdbsupport/configure.ac                       |    4 +-
 gdbsupport/event-loop.cc                      |    6 +-
 gdbsupport/filestuff.cc                       |    2 +-
 gdbsupport/filestuff.h                        |    2 +-
 gdbsupport/filtered-iterator.h                |    4 +-
 gdbsupport/format.h                           |    4 +-
 gdbsupport/forward-scope-exit.h               |    6 +-
 gdbsupport/function-view.h                    |    4 +-
 gdbsupport/gdb_optional.h                     |  233 --
 gdbsupport/gdb_string_view.h                  |  566 -----
 gdbsupport/gdb_string_view.tcc                |  219 --
 gdbsupport/gdb_unique_ptr.h                   |   13 -
 gdbsupport/invoke-result.h                    |   37 -
 gdbsupport/parallel-for.h                     |    9 +-
 gdbsupport/range-chain.h                      |    2 +-
 gdbsupport/safe-iterator.h                    |    4 +-
 gdbsupport/scoped_ignore_sigttou.h            |    2 +-
 gdbsupport/thread-pool.cc                     |    2 +-
 gdbsupport/thread-pool.h                      |    4 +-
 291 files changed, 5968 insertions(+), 9706 deletions(-)
 delete mode 100644 gdb/unittests/basic_string_view/capacity/1.cc
 delete mode 100644 gdb/unittests/basic_string_view/capacity/empty_neg.cc
 delete mode 100644 gdb/unittests/basic_string_view/cons/char/1.cc
 delete mode 100644 gdb/unittests/basic_string_view/cons/char/2.cc
 delete mode 100644 gdb/unittests/basic_string_view/cons/char/3.cc
 delete mode 100644 gdb/unittests/basic_string_view/cons/wchar_t/1.cc
 delete mode 100644 gdb/unittests/basic_string_view/cons/wchar_t/2.cc
 delete mode 100644 gdb/unittests/basic_string_view/cons/wchar_t/3.cc
 delete mode 100644 gdb/unittests/basic_string_view/element_access/char/1.cc
 delete mode 100644 gdb/unittests/basic_string_view/element_access/char/2.cc
 delete mode 100644 gdb/unittests/basic_string_view/element_access/char/empty.cc
 delete mode 100644 gdb/unittests/basic_string_view/element_access/char/front_back.cc
 delete mode 100644 gdb/unittests/basic_string_view/element_access/wchar_t/1.cc
 delete mode 100644 gdb/unittests/basic_string_view/element_access/wchar_t/2.cc
 delete mode 100644 gdb/unittests/basic_string_view/element_access/wchar_t/empty.cc
 delete mode 100644 gdb/unittests/basic_string_view/element_access/wchar_t/front_back.cc
 delete mode 100644 gdb/unittests/basic_string_view/include.cc
 delete mode 100644 gdb/unittests/basic_string_view/inserters/char/1.cc
 delete mode 100644 gdb/unittests/basic_string_view/inserters/char/2.cc
 delete mode 100644 gdb/unittests/basic_string_view/inserters/char/3.cc
 delete mode 100644 gdb/unittests/basic_string_view/inserters/pod/10081-out.cc
 delete mode 100644 gdb/unittests/basic_string_view/inserters/wchar_t/1.cc
 delete mode 100644 gdb/unittests/basic_string_view/inserters/wchar_t/2.cc
 delete mode 100644 gdb/unittests/basic_string_view/inserters/wchar_t/3.cc
 delete mode 100644 gdb/unittests/basic_string_view/literals/types.cc
 delete mode 100644 gdb/unittests/basic_string_view/literals/values.cc
 delete mode 100644 gdb/unittests/basic_string_view/modifiers/remove_prefix/char/1.cc
 delete mode 100644 gdb/unittests/basic_string_view/modifiers/remove_prefix/wchar_t/1.cc
 delete mode 100644 gdb/unittests/basic_string_view/modifiers/remove_suffix/char/1.cc
 delete mode 100644 gdb/unittests/basic_string_view/modifiers/remove_suffix/wchar_t/1.cc
 delete mode 100644 gdb/unittests/basic_string_view/modifiers/swap/char/1.cc
 delete mode 100644 gdb/unittests/basic_string_view/modifiers/swap/wchar_t/1.cc
 delete mode 100644 gdb/unittests/basic_string_view/operations/compare/char/1.cc
 delete mode 100644 gdb/unittests/basic_string_view/operations/compare/char/13650.cc
 delete mode 100644 gdb/unittests/basic_string_view/operations/compare/char/2.cc
 delete mode 100644 gdb/unittests/basic_string_view/operations/compare/char/70483.cc
 delete mode 100644 gdb/unittests/basic_string_view/operations/compare/wchar_t/1.cc
 delete mode 100644 gdb/unittests/basic_string_view/operations/compare/wchar_t/13650.cc
 delete mode 100644 gdb/unittests/basic_string_view/operations/compare/wchar_t/2.cc
 delete mode 100644 gdb/unittests/basic_string_view/operations/copy/char/1.cc
 delete mode 100644 gdb/unittests/basic_string_view/operations/copy/wchar_t/1.cc
 delete mode 100644 gdb/unittests/basic_string_view/operations/data/char/1.cc
 delete mode 100644 gdb/unittests/basic_string_view/operations/data/wchar_t/1.cc
 delete mode 100644 gdb/unittests/basic_string_view/operations/find/char/1.cc
 delete mode 100644 gdb/unittests/basic_string_view/operations/find/char/2.cc
 delete mode 100644 gdb/unittests/basic_string_view/operations/find/char/3.cc
 delete mode 100644 gdb/unittests/basic_string_view/operations/find/char/4.cc
 delete mode 100644 gdb/unittests/basic_string_view/operations/find/wchar_t/1.cc
 delete mode 100644 gdb/unittests/basic_string_view/operations/find/wchar_t/2.cc
 delete mode 100644 gdb/unittests/basic_string_view/operations/find/wchar_t/3.cc
 delete mode 100644 gdb/unittests/basic_string_view/operations/find/wchar_t/4.cc
 delete mode 100644 gdb/unittests/basic_string_view/operations/rfind/char/1.cc
 delete mode 100644 gdb/unittests/basic_string_view/operations/rfind/char/2.cc
 delete mode 100644 gdb/unittests/basic_string_view/operations/rfind/char/3.cc
 delete mode 100644 gdb/unittests/basic_string_view/operations/rfind/wchar_t/1.cc
 delete mode 100644 gdb/unittests/basic_string_view/operations/rfind/wchar_t/2.cc
 delete mode 100644 gdb/unittests/basic_string_view/operations/rfind/wchar_t/3.cc
 delete mode 100644 gdb/unittests/basic_string_view/operations/string_conversion/1.cc
 delete mode 100644 gdb/unittests/basic_string_view/operations/substr/char/1.cc
 delete mode 100644 gdb/unittests/basic_string_view/operations/substr/wchar_t/1.cc
 delete mode 100644 gdb/unittests/basic_string_view/operators/char/2.cc
 delete mode 100644 gdb/unittests/basic_string_view/operators/wchar_t/2.cc
 delete mode 100644 gdb/unittests/basic_string_view/range_access/char/1.cc
 delete mode 100644 gdb/unittests/basic_string_view/range_access/wchar_t/1.cc
 delete mode 100644 gdb/unittests/basic_string_view/requirements/explicit_instantiation/1.cc
 delete mode 100644 gdb/unittests/basic_string_view/requirements/explicit_instantiation/char/1.cc
 delete mode 100644 gdb/unittests/basic_string_view/requirements/explicit_instantiation/char16_t/1.cc
 delete mode 100644 gdb/unittests/basic_string_view/requirements/explicit_instantiation/char32_t/1.cc
 delete mode 100644 gdb/unittests/basic_string_view/requirements/explicit_instantiation/wchar_t/1.cc
 delete mode 100644 gdb/unittests/basic_string_view/requirements/typedefs.cc
 delete mode 100644 gdb/unittests/basic_string_view/typedefs.cc
 delete mode 100644 gdb/unittests/basic_string_view/types/1.cc
 delete mode 100644 gdb/unittests/optional-selftests.c
 delete mode 100644 gdb/unittests/optional/assignment/1.cc
 delete mode 100644 gdb/unittests/optional/assignment/2.cc
 delete mode 100644 gdb/unittests/optional/assignment/3.cc
 delete mode 100644 gdb/unittests/optional/assignment/4.cc
 delete mode 100644 gdb/unittests/optional/assignment/5.cc
 delete mode 100644 gdb/unittests/optional/assignment/6.cc
 delete mode 100644 gdb/unittests/optional/assignment/7.cc
 delete mode 100644 gdb/unittests/optional/cons/copy.cc
 delete mode 100644 gdb/unittests/optional/cons/default.cc
 delete mode 100644 gdb/unittests/optional/cons/move.cc
 delete mode 100644 gdb/unittests/optional/cons/value.cc
 delete mode 100644 gdb/unittests/optional/in_place.cc
 delete mode 100644 gdb/unittests/optional/observers/1.cc
 delete mode 100644 gdb/unittests/optional/observers/2.cc
 delete mode 100644 gdb/unittests/string_view-selftests.c
 delete mode 100644 gdbsupport/gdb_optional.h
 delete mode 100644 gdbsupport/gdb_string_view.h
 delete mode 100644 gdbsupport/gdb_string_view.tcc
 delete mode 100644 gdbsupport/invoke-result.h


base-commit: 9326300e4d3dbe943380b30766ed474d98df07ba
-- 
2.34.1


^ permalink raw reply	[flat|nested] 39+ messages in thread

* [PATCH 01/11] gdb/ax_cxx_compile_stdcxx.m4: upgrade
  2023-10-13 14:44 [PATCH 00/11] GDB: Require C++17 Lancelot Six
@ 2023-10-13 14:44 ` Lancelot Six
  2023-10-13 14:44 ` [PATCH 02/11] gdb/gdbsupport/gdbserver: Require c++17 Lancelot Six
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 39+ messages in thread
From: Lancelot Six @ 2023-10-13 14:44 UTC (permalink / raw)
  To: gdb-patches; +Cc: Lancelot Six

This patch upgrades gdb/ax_cxx_compile_stdcxx.m4 to follow changes
available in [1] and regenerates the configure script.

[1] https://www.gnu.org/software/autoconf-archive/ax_cxx_compile_stdcxx.html

Change-Id: I5b16adc65c9e48a13ad65202d58ab7a9d487214e
---
 gdb/ax_cxx_compile_stdcxx.m4 | 126 +++++++++++++++++++++++------------
 gdb/configure                |  44 +++++++++---
 gdbserver/configure          |  44 +++++++++---
 gdbsupport/configure         |  44 +++++++++---
 4 files changed, 184 insertions(+), 74 deletions(-)

diff --git a/gdb/ax_cxx_compile_stdcxx.m4 b/gdb/ax_cxx_compile_stdcxx.m4
index 68ff8a553f0..b0432599489 100644
--- a/gdb/ax_cxx_compile_stdcxx.m4
+++ b/gdb/ax_cxx_compile_stdcxx.m4
@@ -19,13 +19,13 @@
 #
 #   Check for baseline language coverage in the compiler for the specified
 #   version of the C++ standard.  If necessary, add switches to CXX and
-#   CXXCPP to enable support.  VERSION may be '11' (for the C++11 standard)
-#   or '14' (for the C++14 standard).
+#   CXXCPP to enable support.  VERSION may be '11', '14', '17', or '20' for
+#   the respective C++ standard version.
 #
 #   The second argument, if specified, indicates whether you insist on an
 #   extended mode (e.g. -std=gnu++11) or a strict conformance mode (e.g.
 #   -std=c++11).  If neither is specified, you get whatever works, with
-#   preference for an extended mode.
+#   preference for no added switch, and then for an extended mode.
 #
 #   The third argument, if specified 'mandatory' or if left unspecified,
 #   indicates that baseline support for the specified C++ standard is
@@ -42,14 +42,17 @@
 #   Copyright (c) 2014, 2015 Google Inc.; contributed by Alexey Sokolov <sokolov@google.com>
 #   Copyright (c) 2015 Paul Norman <penorman@mac.com>
 #   Copyright (c) 2015 Moritz Klammler <moritz@klammler.eu>
-#   Copyright (c) 2016 Krzesimir Nowak <qdlacz@gmail.com>
+#   Copyright (c) 2016, 2018 Krzesimir Nowak <qdlacz@gmail.com>
+#   Copyright (c) 2019 Enji Cooper <yaneurabeya@gmail.com>
+#   Copyright (c) 2020 Jason Merrill <jason@redhat.com>
+#   Copyright (c) 2021 Jörn Heusipp <osmanx@problemloesungsmaschine.de>
 #
 #   Copying and distribution of this file, with or without modification, are
 #   permitted in any medium without royalty provided the copyright notice
 #   and this notice are preserved.  This file is offered as-is, without any
 #   warranty.
 
-#serial 8
+#serial 18
 
 dnl  This macro is based on the code from the AX_CXX_COMPILE_STDCXX_11 macro
 dnl  (serial version number 13).
@@ -58,6 +61,7 @@ AC_DEFUN([AX_CXX_COMPILE_STDCXX], [dnl
   m4_if([$1], [11], [ax_cxx_compile_alternatives="11 0x"],
         [$1], [14], [ax_cxx_compile_alternatives="14 1y"],
         [$1], [17], [ax_cxx_compile_alternatives="17 1z"],
+        [$1], [20], [ax_cxx_compile_alternatives="20"],
         [m4_fatal([invalid first argument `$1' to AX_CXX_COMPILE_STDCXX])])dnl
   m4_if([$2], [], [],
         [$2], [ext], [],
@@ -70,14 +74,16 @@ AC_DEFUN([AX_CXX_COMPILE_STDCXX], [dnl
   AC_LANG_PUSH([C++])dnl
   CXX_DIALECT=""
   ac_success=no
-  AC_CACHE_CHECK(whether $CXX supports C++$1 features by default,
-  ax_cv_cxx_compile_cxx$1,
-  [AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_testbody_$1])],
-    [ax_cv_cxx_compile_cxx$1=yes],
-    [ax_cv_cxx_compile_cxx$1=no])])
-  if test x$ax_cv_cxx_compile_cxx$1 = xyes; then
-    ac_success=yes
-  fi
+
+  m4_if([$2], [], [dnl
+    AC_CACHE_CHECK(whether $CXX supports C++$1 features by default,
+		   ax_cv_cxx_compile_cxx$1,
+      [AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_testbody_$1])],
+        [ax_cv_cxx_compile_cxx$1=yes],
+        [ax_cv_cxx_compile_cxx$1=no])])
+    if test x$ax_cv_cxx_compile_cxx$1 = xyes; then
+      ac_success=yes
+    fi])
 
   m4_if([$2], [noext], [], [dnl
   if test x$ac_success = xno; then
@@ -109,9 +115,18 @@ AC_DEFUN([AX_CXX_COMPILE_STDCXX], [dnl
     dnl HP's aCC needs +std=c++11 according to:
     dnl http://h21007.www2.hp.com/portal/download/files/unprot/aCxx/PDF_Release_Notes/769149-001.pdf
     dnl Cray's crayCC needs "-h std=c++11"
+    dnl MSVC needs -std:c++NN for C++17 and later (default is C++14)
     for alternative in ${ax_cxx_compile_alternatives}; do
-      for switch in -std=c++${alternative} +std=c++${alternative} "-h std=c++${alternative}"; do
-        cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx$1_$switch])
+      for switch in -std=c++${alternative} +std=c++${alternative} "-h std=c++${alternative}" MSVC; do
+        if test x"$switch" = xMSVC; then
+          dnl AS_TR_SH maps both `:` and `=` to `_` so -std:c++17 would collide
+          dnl with -std=c++17.  We suffix the cache variable name with _MSVC to
+          dnl avoid this.
+          switch=-std:c++${alternative}
+          cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx$1_${switch}_MSVC])
+        else
+          cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx$1_$switch])
+        fi
         AC_CACHE_CHECK(whether $CXX supports C++$1 features with $switch,
                        $cachevar,
           [ac_save_CXX="$CXX"
@@ -160,7 +175,6 @@ m4_define([_AX_CXX_COMPILE_STDCXX_testbody_11],
   _AX_CXX_COMPILE_STDCXX_testbody_new_in_11
 )
 
-
 dnl  Test body for checking C++14 support
 
 m4_define([_AX_CXX_COMPILE_STDCXX_testbody_14],
@@ -168,12 +182,24 @@ m4_define([_AX_CXX_COMPILE_STDCXX_testbody_14],
   _AX_CXX_COMPILE_STDCXX_testbody_new_in_14
 )
 
+dnl  Test body for checking C++17 support
+
 m4_define([_AX_CXX_COMPILE_STDCXX_testbody_17],
   _AX_CXX_COMPILE_STDCXX_testbody_new_in_11
   _AX_CXX_COMPILE_STDCXX_testbody_new_in_14
   _AX_CXX_COMPILE_STDCXX_testbody_new_in_17
 )
 
+dnl  Test body for checking C++20 support
+
+m4_define([_AX_CXX_COMPILE_STDCXX_testbody_20],
+  _AX_CXX_COMPILE_STDCXX_testbody_new_in_11
+  _AX_CXX_COMPILE_STDCXX_testbody_new_in_14
+  _AX_CXX_COMPILE_STDCXX_testbody_new_in_17
+  _AX_CXX_COMPILE_STDCXX_testbody_new_in_20
+)
+
+
 dnl  Tests for new features in C++11
 
 m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_11], [[
@@ -185,7 +211,11 @@ m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_11], [[
 
 #error "This is not a C++ compiler"
 
-#elif __cplusplus < 201103L
+// MSVC always sets __cplusplus to 199711L in older versions; newer versions
+// only set it correctly if /Zc:__cplusplus is specified as well as a
+// /std:c++NN switch:
+// https://devblogs.microsoft.com/cppblog/msvc-now-correctly-reports-__cplusplus/
+#elif __cplusplus < 201103L && !defined _MSC_VER
 
 #error "This is not a C++11 compiler"
 
@@ -210,11 +240,13 @@ namespace cxx11
 
     struct Base
     {
+      virtual ~Base() {}
       virtual void f() {}
     };
 
     struct Derived : public Base
     {
+      virtual ~Derived() override {}
       virtual void f() override {}
     };
 
@@ -474,7 +506,7 @@ m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_14], [[
 
 #error "This is not a C++ compiler"
 
-#elif __cplusplus < 201402L
+#elif __cplusplus < 201402L && !defined _MSC_VER
 
 #error "This is not a C++14 compiler"
 
@@ -598,20 +630,12 @@ m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_17], [[
 
 #error "This is not a C++ compiler"
 
-#elif __cplusplus <= 201402L
+#elif __cplusplus < 201703L && !defined _MSC_VER
 
 #error "This is not a C++17 compiler"
 
 #else
 
-#if defined(__clang__)
-  #define REALLY_CLANG
-#else
-  #if defined(__GNUC__)
-    #define REALLY_GCC
-  #endif
-#endif
-
 #include <initializer_list>
 #include <utility>
 #include <type_traits>
@@ -619,16 +643,12 @@ m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_17], [[
 namespace cxx17
 {
 
-#if !defined(REALLY_CLANG)
   namespace test_constexpr_lambdas
   {
 
-    // TODO: test it with clang++ from git
-
     constexpr int foo = [](){return 42;}();
 
   }
-#endif // !defined(REALLY_CLANG)
 
   namespace test::nested_namespace::definitions
   {
@@ -863,12 +883,9 @@ namespace cxx17
 
   }
 
-#if !defined(REALLY_CLANG)
   namespace test_template_argument_deduction_for_class_templates
   {
 
-    // TODO: test it with clang++ from git
-
     template <typename T1, typename T2>
     struct pair
     {
@@ -887,7 +904,6 @@ namespace cxx17
     }
 
   }
-#endif // !defined(REALLY_CLANG)
 
   namespace test_non_type_auto_template_parameters
   {
@@ -901,12 +917,9 @@ namespace cxx17
 
   }
 
-#if !defined(REALLY_CLANG)
   namespace test_structured_bindings
   {
 
-    // TODO: test it with clang++ from git
-
     int arr[2] = { 1, 2 };
     std::pair<int, int> pr = { 1, 2 };
 
@@ -938,14 +951,10 @@ namespace cxx17
     const auto [ x3, y3 ] = f3();
 
   }
-#endif // !defined(REALLY_CLANG)
 
-#if !defined(REALLY_CLANG)
   namespace test_exception_spec_type_system
   {
 
-    // TODO: test it with clang++ from git
-
     struct Good {};
     struct Bad {};
 
@@ -963,7 +972,6 @@ namespace cxx17
     static_assert (std::is_same_v<Good, decltype(f(g1, g2))>);
 
   }
-#endif // !defined(REALLY_CLANG)
 
   namespace test_inline_variables
   {
@@ -988,6 +996,36 @@ namespace cxx17
 
 }  // namespace cxx17
 
-#endif  // __cplusplus <= 201402L
+#endif  // __cplusplus < 201703L && !defined _MSC_VER
+
+]])
+
+
+dnl  Tests for new features in C++20
+
+m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_20], [[
+
+#ifndef __cplusplus
+
+#error "This is not a C++ compiler"
+
+#elif __cplusplus < 202002L && !defined _MSC_VER
+
+#error "This is not a C++20 compiler"
+
+#else
+
+#include <version>
+
+namespace cxx20
+{
+
+// As C++20 supports feature test macros in the standard, there is no
+// immediate need to actually test for feature availability on the
+// Autoconf side.
+
+}  // namespace cxx20
+
+#endif  // __cplusplus < 202002L && !defined _MSC_VER
 
 ]])
diff --git a/gdb/configure b/gdb/configure
index 5361bf42952..408d8a50423 100755
--- a/gdb/configure
+++ b/gdb/configure
@@ -16501,7 +16501,8 @@ ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ex
 ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
   CXX_DIALECT=""
   ac_success=no
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++11 features by default" >&5
+
+      { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++11 features by default" >&5
 $as_echo_n "checking whether $CXX supports C++11 features by default... " >&6; }
 if ${ax_cv_cxx_compile_cxx11+:} false; then :
   $as_echo_n "(cached) " >&6
@@ -16517,7 +16518,11 @@ else
 
 #error "This is not a C++ compiler"
 
-#elif __cplusplus < 201103L
+// MSVC always sets __cplusplus to 199711L in older versions; newer versions
+// only set it correctly if /Zc:__cplusplus is specified as well as a
+// /std:c++NN switch:
+// https://devblogs.microsoft.com/cppblog/msvc-now-correctly-reports-__cplusplus/
+#elif __cplusplus < 201103L && !defined _MSC_VER
 
 #error "This is not a C++11 compiler"
 
@@ -16542,11 +16547,13 @@ namespace cxx11
 
     struct Base
     {
+      virtual ~Base() {}
       virtual void f() {}
     };
 
     struct Derived : public Base
     {
+      virtual ~Derived() override {}
       virtual void f() override {}
     };
 
@@ -16804,9 +16811,9 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_cxx_compile_cxx11" >&5
 $as_echo "$ax_cv_cxx_compile_cxx11" >&6; }
-  if test x$ax_cv_cxx_compile_cxx11 = xyes; then
-    ac_success=yes
-  fi
+    if test x$ax_cv_cxx_compile_cxx11 = xyes; then
+      ac_success=yes
+    fi
 
     if test x$ac_success = xno; then
     for alternative in ${ax_cxx_compile_alternatives}; do
@@ -16830,7 +16837,11 @@ else
 
 #error "This is not a C++ compiler"
 
-#elif __cplusplus < 201103L
+// MSVC always sets __cplusplus to 199711L in older versions; newer versions
+// only set it correctly if /Zc:__cplusplus is specified as well as a
+// /std:c++NN switch:
+// https://devblogs.microsoft.com/cppblog/msvc-now-correctly-reports-__cplusplus/
+#elif __cplusplus < 201103L && !defined _MSC_VER
 
 #error "This is not a C++11 compiler"
 
@@ -16855,11 +16866,13 @@ namespace cxx11
 
     struct Base
     {
+      virtual ~Base() {}
       virtual void f() {}
     };
 
     struct Derived : public Base
     {
+      virtual ~Derived() override {}
       virtual void f() override {}
     };
 
@@ -17132,9 +17145,14 @@ $as_echo "$ac_res" >&6; }
   fi
 
     if test x$ac_success = xno; then
-                for alternative in ${ax_cxx_compile_alternatives}; do
-      for switch in -std=c++${alternative} +std=c++${alternative} "-h std=c++${alternative}"; do
-        cachevar=`$as_echo "ax_cv_cxx_compile_cxx11_$switch" | $as_tr_sh`
+                    for alternative in ${ax_cxx_compile_alternatives}; do
+      for switch in -std=c++${alternative} +std=c++${alternative} "-h std=c++${alternative}" MSVC; do
+        if test x"$switch" = xMSVC; then
+                                        switch=-std:c++${alternative}
+          cachevar=`$as_echo "ax_cv_cxx_compile_cxx11_${switch}_MSVC" | $as_tr_sh`
+        else
+          cachevar=`$as_echo "ax_cv_cxx_compile_cxx11_$switch" | $as_tr_sh`
+        fi
         { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++11 features with $switch" >&5
 $as_echo_n "checking whether $CXX supports C++11 features with $switch... " >&6; }
 if eval \${$cachevar+:} false; then :
@@ -17153,7 +17171,11 @@ else
 
 #error "This is not a C++ compiler"
 
-#elif __cplusplus < 201103L
+// MSVC always sets __cplusplus to 199711L in older versions; newer versions
+// only set it correctly if /Zc:__cplusplus is specified as well as a
+// /std:c++NN switch:
+// https://devblogs.microsoft.com/cppblog/msvc-now-correctly-reports-__cplusplus/
+#elif __cplusplus < 201103L && !defined _MSC_VER
 
 #error "This is not a C++11 compiler"
 
@@ -17178,11 +17200,13 @@ namespace cxx11
 
     struct Base
     {
+      virtual ~Base() {}
       virtual void f() {}
     };
 
     struct Derived : public Base
     {
+      virtual ~Derived() override {}
       virtual void f() override {}
     };
 
diff --git a/gdbserver/configure b/gdbserver/configure
index 202043202cd..a49598fb682 100755
--- a/gdbserver/configure
+++ b/gdbserver/configure
@@ -5018,7 +5018,8 @@ ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ex
 ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
   CXX_DIALECT=""
   ac_success=no
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++11 features by default" >&5
+
+      { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++11 features by default" >&5
 $as_echo_n "checking whether $CXX supports C++11 features by default... " >&6; }
 if ${ax_cv_cxx_compile_cxx11+:} false; then :
   $as_echo_n "(cached) " >&6
@@ -5034,7 +5035,11 @@ else
 
 #error "This is not a C++ compiler"
 
-#elif __cplusplus < 201103L
+// MSVC always sets __cplusplus to 199711L in older versions; newer versions
+// only set it correctly if /Zc:__cplusplus is specified as well as a
+// /std:c++NN switch:
+// https://devblogs.microsoft.com/cppblog/msvc-now-correctly-reports-__cplusplus/
+#elif __cplusplus < 201103L && !defined _MSC_VER
 
 #error "This is not a C++11 compiler"
 
@@ -5059,11 +5064,13 @@ namespace cxx11
 
     struct Base
     {
+      virtual ~Base() {}
       virtual void f() {}
     };
 
     struct Derived : public Base
     {
+      virtual ~Derived() override {}
       virtual void f() override {}
     };
 
@@ -5321,9 +5328,9 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_cxx_compile_cxx11" >&5
 $as_echo "$ax_cv_cxx_compile_cxx11" >&6; }
-  if test x$ax_cv_cxx_compile_cxx11 = xyes; then
-    ac_success=yes
-  fi
+    if test x$ax_cv_cxx_compile_cxx11 = xyes; then
+      ac_success=yes
+    fi
 
     if test x$ac_success = xno; then
     for alternative in ${ax_cxx_compile_alternatives}; do
@@ -5347,7 +5354,11 @@ else
 
 #error "This is not a C++ compiler"
 
-#elif __cplusplus < 201103L
+// MSVC always sets __cplusplus to 199711L in older versions; newer versions
+// only set it correctly if /Zc:__cplusplus is specified as well as a
+// /std:c++NN switch:
+// https://devblogs.microsoft.com/cppblog/msvc-now-correctly-reports-__cplusplus/
+#elif __cplusplus < 201103L && !defined _MSC_VER
 
 #error "This is not a C++11 compiler"
 
@@ -5372,11 +5383,13 @@ namespace cxx11
 
     struct Base
     {
+      virtual ~Base() {}
       virtual void f() {}
     };
 
     struct Derived : public Base
     {
+      virtual ~Derived() override {}
       virtual void f() override {}
     };
 
@@ -5649,9 +5662,14 @@ $as_echo "$ac_res" >&6; }
   fi
 
     if test x$ac_success = xno; then
-                for alternative in ${ax_cxx_compile_alternatives}; do
-      for switch in -std=c++${alternative} +std=c++${alternative} "-h std=c++${alternative}"; do
-        cachevar=`$as_echo "ax_cv_cxx_compile_cxx11_$switch" | $as_tr_sh`
+                    for alternative in ${ax_cxx_compile_alternatives}; do
+      for switch in -std=c++${alternative} +std=c++${alternative} "-h std=c++${alternative}" MSVC; do
+        if test x"$switch" = xMSVC; then
+                                        switch=-std:c++${alternative}
+          cachevar=`$as_echo "ax_cv_cxx_compile_cxx11_${switch}_MSVC" | $as_tr_sh`
+        else
+          cachevar=`$as_echo "ax_cv_cxx_compile_cxx11_$switch" | $as_tr_sh`
+        fi
         { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++11 features with $switch" >&5
 $as_echo_n "checking whether $CXX supports C++11 features with $switch... " >&6; }
 if eval \${$cachevar+:} false; then :
@@ -5670,7 +5688,11 @@ else
 
 #error "This is not a C++ compiler"
 
-#elif __cplusplus < 201103L
+// MSVC always sets __cplusplus to 199711L in older versions; newer versions
+// only set it correctly if /Zc:__cplusplus is specified as well as a
+// /std:c++NN switch:
+// https://devblogs.microsoft.com/cppblog/msvc-now-correctly-reports-__cplusplus/
+#elif __cplusplus < 201103L && !defined _MSC_VER
 
 #error "This is not a C++11 compiler"
 
@@ -5695,11 +5717,13 @@ namespace cxx11
 
     struct Base
     {
+      virtual ~Base() {}
       virtual void f() {}
     };
 
     struct Derived : public Base
     {
+      virtual ~Derived() override {}
       virtual void f() override {}
     };
 
diff --git a/gdbsupport/configure b/gdbsupport/configure
index 2c15e9df840..6d2a4309d7e 100755
--- a/gdbsupport/configure
+++ b/gdbsupport/configure
@@ -5916,7 +5916,8 @@ ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ex
 ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
   CXX_DIALECT=""
   ac_success=no
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++11 features by default" >&5
+
+      { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++11 features by default" >&5
 $as_echo_n "checking whether $CXX supports C++11 features by default... " >&6; }
 if ${ax_cv_cxx_compile_cxx11+:} false; then :
   $as_echo_n "(cached) " >&6
@@ -5932,7 +5933,11 @@ else
 
 #error "This is not a C++ compiler"
 
-#elif __cplusplus < 201103L
+// MSVC always sets __cplusplus to 199711L in older versions; newer versions
+// only set it correctly if /Zc:__cplusplus is specified as well as a
+// /std:c++NN switch:
+// https://devblogs.microsoft.com/cppblog/msvc-now-correctly-reports-__cplusplus/
+#elif __cplusplus < 201103L && !defined _MSC_VER
 
 #error "This is not a C++11 compiler"
 
@@ -5957,11 +5962,13 @@ namespace cxx11
 
     struct Base
     {
+      virtual ~Base() {}
       virtual void f() {}
     };
 
     struct Derived : public Base
     {
+      virtual ~Derived() override {}
       virtual void f() override {}
     };
 
@@ -6219,9 +6226,9 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_cxx_compile_cxx11" >&5
 $as_echo "$ax_cv_cxx_compile_cxx11" >&6; }
-  if test x$ax_cv_cxx_compile_cxx11 = xyes; then
-    ac_success=yes
-  fi
+    if test x$ax_cv_cxx_compile_cxx11 = xyes; then
+      ac_success=yes
+    fi
 
     if test x$ac_success = xno; then
     for alternative in ${ax_cxx_compile_alternatives}; do
@@ -6245,7 +6252,11 @@ else
 
 #error "This is not a C++ compiler"
 
-#elif __cplusplus < 201103L
+// MSVC always sets __cplusplus to 199711L in older versions; newer versions
+// only set it correctly if /Zc:__cplusplus is specified as well as a
+// /std:c++NN switch:
+// https://devblogs.microsoft.com/cppblog/msvc-now-correctly-reports-__cplusplus/
+#elif __cplusplus < 201103L && !defined _MSC_VER
 
 #error "This is not a C++11 compiler"
 
@@ -6270,11 +6281,13 @@ namespace cxx11
 
     struct Base
     {
+      virtual ~Base() {}
       virtual void f() {}
     };
 
     struct Derived : public Base
     {
+      virtual ~Derived() override {}
       virtual void f() override {}
     };
 
@@ -6547,9 +6560,14 @@ $as_echo "$ac_res" >&6; }
   fi
 
     if test x$ac_success = xno; then
-                for alternative in ${ax_cxx_compile_alternatives}; do
-      for switch in -std=c++${alternative} +std=c++${alternative} "-h std=c++${alternative}"; do
-        cachevar=`$as_echo "ax_cv_cxx_compile_cxx11_$switch" | $as_tr_sh`
+                    for alternative in ${ax_cxx_compile_alternatives}; do
+      for switch in -std=c++${alternative} +std=c++${alternative} "-h std=c++${alternative}" MSVC; do
+        if test x"$switch" = xMSVC; then
+                                        switch=-std:c++${alternative}
+          cachevar=`$as_echo "ax_cv_cxx_compile_cxx11_${switch}_MSVC" | $as_tr_sh`
+        else
+          cachevar=`$as_echo "ax_cv_cxx_compile_cxx11_$switch" | $as_tr_sh`
+        fi
         { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++11 features with $switch" >&5
 $as_echo_n "checking whether $CXX supports C++11 features with $switch... " >&6; }
 if eval \${$cachevar+:} false; then :
@@ -6568,7 +6586,11 @@ else
 
 #error "This is not a C++ compiler"
 
-#elif __cplusplus < 201103L
+// MSVC always sets __cplusplus to 199711L in older versions; newer versions
+// only set it correctly if /Zc:__cplusplus is specified as well as a
+// /std:c++NN switch:
+// https://devblogs.microsoft.com/cppblog/msvc-now-correctly-reports-__cplusplus/
+#elif __cplusplus < 201103L && !defined _MSC_VER
 
 #error "This is not a C++11 compiler"
 
@@ -6593,11 +6615,13 @@ namespace cxx11
 
     struct Base
     {
+      virtual ~Base() {}
       virtual void f() {}
     };
 
     struct Derived : public Base
     {
+      virtual ~Derived() override {}
       virtual void f() override {}
     };
 
-- 
2.34.1


^ permalink raw reply	[flat|nested] 39+ messages in thread

* [PATCH 02/11] gdb/gdbsupport/gdbserver: Require c++17
  2023-10-13 14:44 [PATCH 00/11] GDB: Require C++17 Lancelot Six
  2023-10-13 14:44 ` [PATCH 01/11] gdb/ax_cxx_compile_stdcxx.m4: upgrade Lancelot Six
@ 2023-10-13 14:44 ` Lancelot Six
  2023-10-13 15:21   ` Eli Zaretskii
  2023-10-16 21:50   ` Pedro Alves
  2023-10-13 14:44 ` [PATCH 03/11] gdb: Use C++17's std::make_unique instead of gdb::make_unique Lancelot Six
                   ` (9 subsequent siblings)
  11 siblings, 2 replies; 39+ messages in thread
From: Lancelot Six @ 2023-10-13 14:44 UTC (permalink / raw)
  To: gdb-patches; +Cc: Lancelot Six

This patch proposes to require a C++17 compiler to build gdb /
gdbsupport / gdbserver.  Before this patch, GDB required a C++11
compiler.

The general policy regarding bumping C++ language requirement in GDB (as
stated in [1]) is:

    Our general policy is to wait until the oldest compiler that
    supports C++NN is at least 3 years old.

    Rationale: We want to ensure reasonably widespread compiler
    availability, to lower barrier of entry to GDB contributions, and to
    make it easy for users to easily build new GDB on currently
    supported stable distributions themselves. 3 years should be
    sufficient for latest stable releases of distributions to include a
    compiler for the standard, and/or for new compilers to appear as
    easily installable optional packages. Requiring everyone to build a
    compiler first before building GDB, which would happen if we
    required a too-new compiler, would cause too much inconvenience.

    See the policy proposal and discussion
    [here](https://sourceware.org/ml/gdb-patches/2016-10/msg00616.html).

The first GCC release which with full C++17 support is GCC-9[2],
released in 2019[3], which is over 4 years ago.  Clang has had C++17
support since Clang-5[4] released in 2018[5].

A discussions with many distros showed that a C++17-able compiler is
always available, meaning that this no hard requirement preventing us to
require it going forward.

[1] https://sourceware.org/gdb/wiki/Internals%20GDB-C-Coding-Standards#When_is_GDB_going_to_start_requiring_C.2B-.2B-NN_.3F
[2] https://gcc.gnu.org/projects/cxx-status.html#cxx17
[3] https://gcc.gnu.org/gcc-9/
[4] https://clang.llvm.org/cxx_status.html
[5] https://releases.llvm.org/

Change-Id: Id596f5db17ea346e8a978668825787b3a9a443fd
---
 gdb/NEWS                |    3 +
 gdb/config.in           |    4 +-
 gdb/configure           | 1970 ++++++++++++++++++++++++++++++++++-----
 gdb/configure.ac        |    4 +-
 gdbserver/config.in     |    4 +-
 gdbserver/configure     | 1970 ++++++++++++++++++++++++++++++++++-----
 gdbserver/configure.ac  |    4 +-
 gdbsupport/Makefile.in  |    2 +-
 gdbsupport/config.in    |    4 +-
 gdbsupport/configure    | 1970 ++++++++++++++++++++++++++++++++++-----
 gdbsupport/configure.ac |    4 +-
 11 files changed, 5212 insertions(+), 727 deletions(-)

diff --git a/gdb/NEWS b/gdb/NEWS
index 81264c0cfb3..8ab2e4c593a 100644
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -3,6 +3,9 @@
 
 *** Changes since GDB 14
 
+* Building GDB and GDBserver now requires a C++17 compiler.
+  For example, GCC 9 or later.
+
 * GDB index now contains information about the main function. This speeds up
   startup when it is being used for some large binaries.
 
diff --git a/gdb/config.in b/gdb/config.in
index e17245156d8..f8926fe4404 100644
--- a/gdb/config.in
+++ b/gdb/config.in
@@ -99,8 +99,8 @@
 /* Define to 1 if you have the <curses.h> header file. */
 #undef HAVE_CURSES_H
 
-/* define if the compiler supports basic C++11 syntax */
-#undef HAVE_CXX11
+/* define if the compiler supports basic C++17 syntax */
+#undef HAVE_CXX17
 
 /* Define to 1 if you have the declaration of `ADDR_NO_RANDOMIZE', and to 0 if
    you don't. */
diff --git a/gdb/configure b/gdb/configure
index 408d8a50423..0878481e354 100755
--- a/gdb/configure
+++ b/gdb/configure
@@ -803,7 +803,7 @@ CCDEPMODE
 DEPDIR
 am__leading_dot
 CXX_DIALECT
-HAVE_CXX11
+HAVE_CXX17
 CXXCPP
 OTOOL64
 OTOOL
@@ -16491,9 +16491,9 @@ exec 5>>config.log
 $lt_cl_success || as_fn_exit 1
 
 
-# We require a C++11 compiler.  Check if one is available, and if
+# We require a C++17 compiler.  Check if one is available, and if
 # necessary, set CXX_DIALECT to some -std=xxx switch.
-  ax_cxx_compile_alternatives="11 0x"    ax_cxx_compile_cxx11_required=true
+  ax_cxx_compile_alternatives="17 1z"    ax_cxx_compile_cxx17_required=true
   ac_ext=cpp
 ac_cpp='$CXXCPP $CPPFLAGS'
 ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
@@ -16502,9 +16502,9 @@ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
   CXX_DIALECT=""
   ac_success=no
 
-      { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++11 features by default" >&5
-$as_echo_n "checking whether $CXX supports C++11 features by default... " >&6; }
-if ${ax_cv_cxx_compile_cxx11+:} false; then :
+      { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++17 features by default" >&5
+$as_echo_n "checking whether $CXX supports C++17 features by default... " >&6; }
+if ${ax_cv_cxx_compile_cxx17+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
@@ -16801,32 +16801,1362 @@ namespace cxx11
 
 
 
+
+// If the compiler admits that it is not ready for C++14, why torture it?
+// Hopefully, this will speed up the test.
+
+#ifndef __cplusplus
+
+#error "This is not a C++ compiler"
+
+#elif __cplusplus < 201402L && !defined _MSC_VER
+
+#error "This is not a C++14 compiler"
+
+#else
+
+namespace cxx14
+{
+
+  namespace test_polymorphic_lambdas
+  {
+
+    int
+    test()
+    {
+      const auto lambda = [](auto&&... args){
+        const auto istiny = [](auto x){
+          return (sizeof(x) == 1UL) ? 1 : 0;
+        };
+        const int aretiny[] = { istiny(args)... };
+        return aretiny[0];
+      };
+      return lambda(1, 1L, 1.0f, '1');
+    }
+
+  }
+
+  namespace test_binary_literals
+  {
+
+    constexpr auto ivii = 0b0000000000101010;
+    static_assert(ivii == 42, "wrong value");
+
+  }
+
+  namespace test_generalized_constexpr
+  {
+
+    template < typename CharT >
+    constexpr unsigned long
+    strlen_c(const CharT *const s) noexcept
+    {
+      auto length = 0UL;
+      for (auto p = s; *p; ++p)
+        ++length;
+      return length;
+    }
+
+    static_assert(strlen_c("") == 0UL, "");
+    static_assert(strlen_c("x") == 1UL, "");
+    static_assert(strlen_c("test") == 4UL, "");
+    static_assert(strlen_c("another\0test") == 7UL, "");
+
+  }
+
+  namespace test_lambda_init_capture
+  {
+
+    int
+    test()
+    {
+      auto x = 0;
+      const auto lambda1 = [a = x](int b){ return a + b; };
+      const auto lambda2 = [a = lambda1(x)](){ return a; };
+      return lambda2();
+    }
+
+  }
+
+  namespace test_digit_separators
+  {
+
+    constexpr auto ten_million = 100'000'000;
+    static_assert(ten_million == 100000000, "");
+
+  }
+
+  namespace test_return_type_deduction
+  {
+
+    auto f(int& x) { return x; }
+    decltype(auto) g(int& x) { return x; }
+
+    template < typename T1, typename T2 >
+    struct is_same
+    {
+      static constexpr auto value = false;
+    };
+
+    template < typename T >
+    struct is_same<T, T>
+    {
+      static constexpr auto value = true;
+    };
+
+    int
+    test()
+    {
+      auto x = 0;
+      static_assert(is_same<int, decltype(f(x))>::value, "");
+      static_assert(is_same<int&, decltype(g(x))>::value, "");
+      return x;
+    }
+
+  }
+
+}  // namespace cxx14
+
+#endif  // __cplusplus >= 201402L
+
+
+
+
+// If the compiler admits that it is not ready for C++17, why torture it?
+// Hopefully, this will speed up the test.
+
+#ifndef __cplusplus
+
+#error "This is not a C++ compiler"
+
+#elif __cplusplus < 201703L && !defined _MSC_VER
+
+#error "This is not a C++17 compiler"
+
+#else
+
+#include <initializer_list>
+#include <utility>
+#include <type_traits>
+
+namespace cxx17
+{
+
+  namespace test_constexpr_lambdas
+  {
+
+    constexpr int foo = [](){return 42;}();
+
+  }
+
+  namespace test::nested_namespace::definitions
+  {
+
+  }
+
+  namespace test_fold_expression
+  {
+
+    template<typename... Args>
+    int multiply(Args... args)
+    {
+      return (args * ... * 1);
+    }
+
+    template<typename... Args>
+    bool all(Args... args)
+    {
+      return (args && ...);
+    }
+
+  }
+
+  namespace test_extended_static_assert
+  {
+
+    static_assert (true);
+
+  }
+
+  namespace test_auto_brace_init_list
+  {
+
+    auto foo = {5};
+    auto bar {5};
+
+    static_assert(std::is_same<std::initializer_list<int>, decltype(foo)>::value);
+    static_assert(std::is_same<int, decltype(bar)>::value);
+  }
+
+  namespace test_typename_in_template_template_parameter
+  {
+
+    template<template<typename> typename X> struct D;
+
+  }
+
+  namespace test_fallthrough_nodiscard_maybe_unused_attributes
+  {
+
+    int f1()
+    {
+      return 42;
+    }
+
+    [[nodiscard]] int f2()
+    {
+      [[maybe_unused]] auto unused = f1();
+
+      switch (f1())
+      {
+      case 17:
+        f1();
+        [[fallthrough]];
+      case 42:
+        f1();
+      }
+      return f1();
+    }
+
+  }
+
+  namespace test_extended_aggregate_initialization
+  {
+
+    struct base1
+    {
+      int b1, b2 = 42;
+    };
+
+    struct base2
+    {
+      base2() {
+        b3 = 42;
+      }
+      int b3;
+    };
+
+    struct derived : base1, base2
+    {
+        int d;
+    };
+
+    derived d1 {{1, 2}, {}, 4};  // full initialization
+    derived d2 {{}, {}, 4};      // value-initialized bases
+
+  }
+
+  namespace test_general_range_based_for_loop
+  {
+
+    struct iter
+    {
+      int i;
+
+      int& operator* ()
+      {
+        return i;
+      }
+
+      const int& operator* () const
+      {
+        return i;
+      }
+
+      iter& operator++()
+      {
+        ++i;
+        return *this;
+      }
+    };
+
+    struct sentinel
+    {
+      int i;
+    };
+
+    bool operator== (const iter& i, const sentinel& s)
+    {
+      return i.i == s.i;
+    }
+
+    bool operator!= (const iter& i, const sentinel& s)
+    {
+      return !(i == s);
+    }
+
+    struct range
+    {
+      iter begin() const
+      {
+        return {0};
+      }
+
+      sentinel end() const
+      {
+        return {5};
+      }
+    };
+
+    void f()
+    {
+      range r {};
+
+      for (auto i : r)
+      {
+        [[maybe_unused]] auto v = i;
+      }
+    }
+
+  }
+
+  namespace test_lambda_capture_asterisk_this_by_value
+  {
+
+    struct t
+    {
+      int i;
+      int foo()
+      {
+        return [*this]()
+        {
+          return i;
+        }();
+      }
+    };
+
+  }
+
+  namespace test_enum_class_construction
+  {
+
+    enum class byte : unsigned char
+    {};
+
+    byte foo {42};
+
+  }
+
+  namespace test_constexpr_if
+  {
+
+    template <bool cond>
+    int f ()
+    {
+      if constexpr(cond)
+      {
+        return 13;
+      }
+      else
+      {
+        return 42;
+      }
+    }
+
+  }
+
+  namespace test_selection_statement_with_initializer
+  {
+
+    int f()
+    {
+      return 13;
+    }
+
+    int f2()
+    {
+      if (auto i = f(); i > 0)
+      {
+        return 3;
+      }
+
+      switch (auto i = f(); i + 4)
+      {
+      case 17:
+        return 2;
+
+      default:
+        return 1;
+      }
+    }
+
+  }
+
+  namespace test_template_argument_deduction_for_class_templates
+  {
+
+    template <typename T1, typename T2>
+    struct pair
+    {
+      pair (T1 p1, T2 p2)
+        : m1 {p1},
+          m2 {p2}
+      {}
+
+      T1 m1;
+      T2 m2;
+    };
+
+    void f()
+    {
+      [[maybe_unused]] auto p = pair{13, 42u};
+    }
+
+  }
+
+  namespace test_non_type_auto_template_parameters
+  {
+
+    template <auto n>
+    struct B
+    {};
+
+    B<5> b1;
+    B<'a'> b2;
+
+  }
+
+  namespace test_structured_bindings
+  {
+
+    int arr[2] = { 1, 2 };
+    std::pair<int, int> pr = { 1, 2 };
+
+    auto f1() -> int(&)[2]
+    {
+      return arr;
+    }
+
+    auto f2() -> std::pair<int, int>&
+    {
+      return pr;
+    }
+
+    struct S
+    {
+      int x1 : 2;
+      volatile double y1;
+    };
+
+    S f3()
+    {
+      return {};
+    }
+
+    auto [ x1, y1 ] = f1();
+    auto& [ xr1, yr1 ] = f1();
+    auto [ x2, y2 ] = f2();
+    auto& [ xr2, yr2 ] = f2();
+    const auto [ x3, y3 ] = f3();
+
+  }
+
+  namespace test_exception_spec_type_system
+  {
+
+    struct Good {};
+    struct Bad {};
+
+    void g1() noexcept;
+    void g2();
+
+    template<typename T>
+    Bad
+    f(T*, T*);
+
+    template<typename T1, typename T2>
+    Good
+    f(T1*, T2*);
+
+    static_assert (std::is_same_v<Good, decltype(f(g1, g2))>);
+
+  }
+
+  namespace test_inline_variables
+  {
+
+    template<class T> void f(T)
+    {}
+
+    template<class T> inline T g(T)
+    {
+      return T{};
+    }
+
+    template<> inline void f<>(int)
+    {}
+
+    template<> int g<>(int)
+    {
+      return 5;
+    }
+
+  }
+
+}  // namespace cxx17
+
+#endif  // __cplusplus < 201703L && !defined _MSC_VER
+
+
+
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
+  ax_cv_cxx_compile_cxx17=yes
+else
+  ax_cv_cxx_compile_cxx17=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_cxx_compile_cxx17" >&5
+$as_echo "$ax_cv_cxx_compile_cxx17" >&6; }
+    if test x$ax_cv_cxx_compile_cxx17 = xyes; then
+      ac_success=yes
+    fi
+
+    if test x$ac_success = xno; then
+    for alternative in ${ax_cxx_compile_alternatives}; do
+      switch="-std=gnu++${alternative}"
+      cachevar=`$as_echo "ax_cv_cxx_compile_cxx17_$switch" | $as_tr_sh`
+      { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++17 features with $switch" >&5
+$as_echo_n "checking whether $CXX supports C++17 features with $switch... " >&6; }
+if eval \${$cachevar+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_save_CXX="$CXX"
+         CXX="$CXX $switch"
+         cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+
+// If the compiler admits that it is not ready for C++11, why torture it?
+// Hopefully, this will speed up the test.
+
+#ifndef __cplusplus
+
+#error "This is not a C++ compiler"
+
+// MSVC always sets __cplusplus to 199711L in older versions; newer versions
+// only set it correctly if /Zc:__cplusplus is specified as well as a
+// /std:c++NN switch:
+// https://devblogs.microsoft.com/cppblog/msvc-now-correctly-reports-__cplusplus/
+#elif __cplusplus < 201103L && !defined _MSC_VER
+
+#error "This is not a C++11 compiler"
+
+#else
+
+namespace cxx11
+{
+
+  namespace test_static_assert
+  {
+
+    template <typename T>
+    struct check
+    {
+      static_assert(sizeof(int) <= sizeof(T), "not big enough");
+    };
+
+  }
+
+  namespace test_final_override
+  {
+
+    struct Base
+    {
+      virtual ~Base() {}
+      virtual void f() {}
+    };
+
+    struct Derived : public Base
+    {
+      virtual ~Derived() override {}
+      virtual void f() override {}
+    };
+
+  }
+
+  namespace test_double_right_angle_brackets
+  {
+
+    template < typename T >
+    struct check {};
+
+    typedef check<void> single_type;
+    typedef check<check<void>> double_type;
+    typedef check<check<check<void>>> triple_type;
+    typedef check<check<check<check<void>>>> quadruple_type;
+
+  }
+
+  namespace test_decltype
+  {
+
+    int
+    f()
+    {
+      int a = 1;
+      decltype(a) b = 2;
+      return a + b;
+    }
+
+  }
+
+  namespace test_type_deduction
+  {
+
+    template < typename T1, typename T2 >
+    struct is_same
+    {
+      static const bool value = false;
+    };
+
+    template < typename T >
+    struct is_same<T, T>
+    {
+      static const bool value = true;
+    };
+
+    template < typename T1, typename T2 >
+    auto
+    add(T1 a1, T2 a2) -> decltype(a1 + a2)
+    {
+      return a1 + a2;
+    }
+
+    int
+    test(const int c, volatile int v)
+    {
+      static_assert(is_same<int, decltype(0)>::value == true, "");
+      static_assert(is_same<int, decltype(c)>::value == false, "");
+      static_assert(is_same<int, decltype(v)>::value == false, "");
+      auto ac = c;
+      auto av = v;
+      auto sumi = ac + av + 'x';
+      auto sumf = ac + av + 1.0;
+      static_assert(is_same<int, decltype(ac)>::value == true, "");
+      static_assert(is_same<int, decltype(av)>::value == true, "");
+      static_assert(is_same<int, decltype(sumi)>::value == true, "");
+      static_assert(is_same<int, decltype(sumf)>::value == false, "");
+      static_assert(is_same<int, decltype(add(c, v))>::value == true, "");
+      return (sumf > 0.0) ? sumi : add(c, v);
+    }
+
+  }
+
+  namespace test_noexcept
+  {
+
+    int f() { return 0; }
+    int g() noexcept { return 0; }
+
+    static_assert(noexcept(f()) == false, "");
+    static_assert(noexcept(g()) == true, "");
+
+  }
+
+  namespace test_constexpr
+  {
+
+    template < typename CharT >
+    unsigned long constexpr
+    strlen_c_r(const CharT *const s, const unsigned long acc) noexcept
+    {
+      return *s ? strlen_c_r(s + 1, acc + 1) : acc;
+    }
+
+    template < typename CharT >
+    unsigned long constexpr
+    strlen_c(const CharT *const s) noexcept
+    {
+      return strlen_c_r(s, 0UL);
+    }
+
+    static_assert(strlen_c("") == 0UL, "");
+    static_assert(strlen_c("1") == 1UL, "");
+    static_assert(strlen_c("example") == 7UL, "");
+    static_assert(strlen_c("another\0example") == 7UL, "");
+
+  }
+
+  namespace test_rvalue_references
+  {
+
+    template < int N >
+    struct answer
+    {
+      static constexpr int value = N;
+    };
+
+    answer<1> f(int&)       { return answer<1>(); }
+    answer<2> f(const int&) { return answer<2>(); }
+    answer<3> f(int&&)      { return answer<3>(); }
+
+    void
+    test()
+    {
+      int i = 0;
+      const int c = 0;
+      static_assert(decltype(f(i))::value == 1, "");
+      static_assert(decltype(f(c))::value == 2, "");
+      static_assert(decltype(f(0))::value == 3, "");
+    }
+
+  }
+
+  namespace test_uniform_initialization
+  {
+
+    struct test
+    {
+      static const int zero {};
+      static const int one {1};
+    };
+
+    static_assert(test::zero == 0, "");
+    static_assert(test::one == 1, "");
+
+  }
+
+  namespace test_lambdas
+  {
+
+    void
+    test1()
+    {
+      auto lambda1 = [](){};
+      auto lambda2 = lambda1;
+      lambda1();
+      lambda2();
+    }
+
+    int
+    test2()
+    {
+      auto a = [](int i, int j){ return i + j; }(1, 2);
+      auto b = []() -> int { return '0'; }();
+      auto c = [=](){ return a + b; }();
+      auto d = [&](){ return c; }();
+      auto e = [a, &b](int x) mutable {
+        const auto identity = [](int y){ return y; };
+        for (auto i = 0; i < a; ++i)
+          a += b--;
+        return x + identity(a + b);
+      }(0);
+      return a + b + c + d + e;
+    }
+
+    int
+    test3()
+    {
+      const auto nullary = [](){ return 0; };
+      const auto unary = [](int x){ return x; };
+      using nullary_t = decltype(nullary);
+      using unary_t = decltype(unary);
+      const auto higher1st = [](nullary_t f){ return f(); };
+      const auto higher2nd = [unary](nullary_t f1){
+        return [unary, f1](unary_t f2){ return f2(unary(f1())); };
+      };
+      return higher1st(nullary) + higher2nd(nullary)(unary);
+    }
+
+  }
+
+  namespace test_variadic_templates
+  {
+
+    template <int...>
+    struct sum;
+
+    template <int N0, int... N1toN>
+    struct sum<N0, N1toN...>
+    {
+      static constexpr auto value = N0 + sum<N1toN...>::value;
+    };
+
+    template <>
+    struct sum<>
+    {
+      static constexpr auto value = 0;
+    };
+
+    static_assert(sum<>::value == 0, "");
+    static_assert(sum<1>::value == 1, "");
+    static_assert(sum<23>::value == 23, "");
+    static_assert(sum<1, 2>::value == 3, "");
+    static_assert(sum<5, 5, 11>::value == 21, "");
+    static_assert(sum<2, 3, 5, 7, 11, 13>::value == 41, "");
+
+  }
+
+  // http://stackoverflow.com/questions/13728184/template-aliases-and-sfinae
+  // Clang 3.1 fails with headers of libstd++ 4.8.3 when using std::function
+  // because of this.
+  namespace test_template_alias_sfinae
+  {
+
+    struct foo {};
+
+    template<typename T>
+    using member = typename T::member_type;
+
+    template<typename T>
+    void func(...) {}
+
+    template<typename T>
+    void func(member<T>*) {}
+
+    void test();
+
+    void test() { func<foo>(0); }
+
+  }
+
+}  // namespace cxx11
+
+#endif  // __cplusplus >= 201103L
+
+
+
+
+// If the compiler admits that it is not ready for C++14, why torture it?
+// Hopefully, this will speed up the test.
+
+#ifndef __cplusplus
+
+#error "This is not a C++ compiler"
+
+#elif __cplusplus < 201402L && !defined _MSC_VER
+
+#error "This is not a C++14 compiler"
+
+#else
+
+namespace cxx14
+{
+
+  namespace test_polymorphic_lambdas
+  {
+
+    int
+    test()
+    {
+      const auto lambda = [](auto&&... args){
+        const auto istiny = [](auto x){
+          return (sizeof(x) == 1UL) ? 1 : 0;
+        };
+        const int aretiny[] = { istiny(args)... };
+        return aretiny[0];
+      };
+      return lambda(1, 1L, 1.0f, '1');
+    }
+
+  }
+
+  namespace test_binary_literals
+  {
+
+    constexpr auto ivii = 0b0000000000101010;
+    static_assert(ivii == 42, "wrong value");
+
+  }
+
+  namespace test_generalized_constexpr
+  {
+
+    template < typename CharT >
+    constexpr unsigned long
+    strlen_c(const CharT *const s) noexcept
+    {
+      auto length = 0UL;
+      for (auto p = s; *p; ++p)
+        ++length;
+      return length;
+    }
+
+    static_assert(strlen_c("") == 0UL, "");
+    static_assert(strlen_c("x") == 1UL, "");
+    static_assert(strlen_c("test") == 4UL, "");
+    static_assert(strlen_c("another\0test") == 7UL, "");
+
+  }
+
+  namespace test_lambda_init_capture
+  {
+
+    int
+    test()
+    {
+      auto x = 0;
+      const auto lambda1 = [a = x](int b){ return a + b; };
+      const auto lambda2 = [a = lambda1(x)](){ return a; };
+      return lambda2();
+    }
+
+  }
+
+  namespace test_digit_separators
+  {
+
+    constexpr auto ten_million = 100'000'000;
+    static_assert(ten_million == 100000000, "");
+
+  }
+
+  namespace test_return_type_deduction
+  {
+
+    auto f(int& x) { return x; }
+    decltype(auto) g(int& x) { return x; }
+
+    template < typename T1, typename T2 >
+    struct is_same
+    {
+      static constexpr auto value = false;
+    };
+
+    template < typename T >
+    struct is_same<T, T>
+    {
+      static constexpr auto value = true;
+    };
+
+    int
+    test()
+    {
+      auto x = 0;
+      static_assert(is_same<int, decltype(f(x))>::value, "");
+      static_assert(is_same<int&, decltype(g(x))>::value, "");
+      return x;
+    }
+
+  }
+
+}  // namespace cxx14
+
+#endif  // __cplusplus >= 201402L
+
+
+
+
+// If the compiler admits that it is not ready for C++17, why torture it?
+// Hopefully, this will speed up the test.
+
+#ifndef __cplusplus
+
+#error "This is not a C++ compiler"
+
+#elif __cplusplus < 201703L && !defined _MSC_VER
+
+#error "This is not a C++17 compiler"
+
+#else
+
+#include <initializer_list>
+#include <utility>
+#include <type_traits>
+
+namespace cxx17
+{
+
+  namespace test_constexpr_lambdas
+  {
+
+    constexpr int foo = [](){return 42;}();
+
+  }
+
+  namespace test::nested_namespace::definitions
+  {
+
+  }
+
+  namespace test_fold_expression
+  {
+
+    template<typename... Args>
+    int multiply(Args... args)
+    {
+      return (args * ... * 1);
+    }
+
+    template<typename... Args>
+    bool all(Args... args)
+    {
+      return (args && ...);
+    }
+
+  }
+
+  namespace test_extended_static_assert
+  {
+
+    static_assert (true);
+
+  }
+
+  namespace test_auto_brace_init_list
+  {
+
+    auto foo = {5};
+    auto bar {5};
+
+    static_assert(std::is_same<std::initializer_list<int>, decltype(foo)>::value);
+    static_assert(std::is_same<int, decltype(bar)>::value);
+  }
+
+  namespace test_typename_in_template_template_parameter
+  {
+
+    template<template<typename> typename X> struct D;
+
+  }
+
+  namespace test_fallthrough_nodiscard_maybe_unused_attributes
+  {
+
+    int f1()
+    {
+      return 42;
+    }
+
+    [[nodiscard]] int f2()
+    {
+      [[maybe_unused]] auto unused = f1();
+
+      switch (f1())
+      {
+      case 17:
+        f1();
+        [[fallthrough]];
+      case 42:
+        f1();
+      }
+      return f1();
+    }
+
+  }
+
+  namespace test_extended_aggregate_initialization
+  {
+
+    struct base1
+    {
+      int b1, b2 = 42;
+    };
+
+    struct base2
+    {
+      base2() {
+        b3 = 42;
+      }
+      int b3;
+    };
+
+    struct derived : base1, base2
+    {
+        int d;
+    };
+
+    derived d1 {{1, 2}, {}, 4};  // full initialization
+    derived d2 {{}, {}, 4};      // value-initialized bases
+
+  }
+
+  namespace test_general_range_based_for_loop
+  {
+
+    struct iter
+    {
+      int i;
+
+      int& operator* ()
+      {
+        return i;
+      }
+
+      const int& operator* () const
+      {
+        return i;
+      }
+
+      iter& operator++()
+      {
+        ++i;
+        return *this;
+      }
+    };
+
+    struct sentinel
+    {
+      int i;
+    };
+
+    bool operator== (const iter& i, const sentinel& s)
+    {
+      return i.i == s.i;
+    }
+
+    bool operator!= (const iter& i, const sentinel& s)
+    {
+      return !(i == s);
+    }
+
+    struct range
+    {
+      iter begin() const
+      {
+        return {0};
+      }
+
+      sentinel end() const
+      {
+        return {5};
+      }
+    };
+
+    void f()
+    {
+      range r {};
+
+      for (auto i : r)
+      {
+        [[maybe_unused]] auto v = i;
+      }
+    }
+
+  }
+
+  namespace test_lambda_capture_asterisk_this_by_value
+  {
+
+    struct t
+    {
+      int i;
+      int foo()
+      {
+        return [*this]()
+        {
+          return i;
+        }();
+      }
+    };
+
+  }
+
+  namespace test_enum_class_construction
+  {
+
+    enum class byte : unsigned char
+    {};
+
+    byte foo {42};
+
+  }
+
+  namespace test_constexpr_if
+  {
+
+    template <bool cond>
+    int f ()
+    {
+      if constexpr(cond)
+      {
+        return 13;
+      }
+      else
+      {
+        return 42;
+      }
+    }
+
+  }
+
+  namespace test_selection_statement_with_initializer
+  {
+
+    int f()
+    {
+      return 13;
+    }
+
+    int f2()
+    {
+      if (auto i = f(); i > 0)
+      {
+        return 3;
+      }
+
+      switch (auto i = f(); i + 4)
+      {
+      case 17:
+        return 2;
+
+      default:
+        return 1;
+      }
+    }
+
+  }
+
+  namespace test_template_argument_deduction_for_class_templates
+  {
+
+    template <typename T1, typename T2>
+    struct pair
+    {
+      pair (T1 p1, T2 p2)
+        : m1 {p1},
+          m2 {p2}
+      {}
+
+      T1 m1;
+      T2 m2;
+    };
+
+    void f()
+    {
+      [[maybe_unused]] auto p = pair{13, 42u};
+    }
+
+  }
+
+  namespace test_non_type_auto_template_parameters
+  {
+
+    template <auto n>
+    struct B
+    {};
+
+    B<5> b1;
+    B<'a'> b2;
+
+  }
+
+  namespace test_structured_bindings
+  {
+
+    int arr[2] = { 1, 2 };
+    std::pair<int, int> pr = { 1, 2 };
+
+    auto f1() -> int(&)[2]
+    {
+      return arr;
+    }
+
+    auto f2() -> std::pair<int, int>&
+    {
+      return pr;
+    }
+
+    struct S
+    {
+      int x1 : 2;
+      volatile double y1;
+    };
+
+    S f3()
+    {
+      return {};
+    }
+
+    auto [ x1, y1 ] = f1();
+    auto& [ xr1, yr1 ] = f1();
+    auto [ x2, y2 ] = f2();
+    auto& [ xr2, yr2 ] = f2();
+    const auto [ x3, y3 ] = f3();
+
+  }
+
+  namespace test_exception_spec_type_system
+  {
+
+    struct Good {};
+    struct Bad {};
+
+    void g1() noexcept;
+    void g2();
+
+    template<typename T>
+    Bad
+    f(T*, T*);
+
+    template<typename T1, typename T2>
+    Good
+    f(T1*, T2*);
+
+    static_assert (std::is_same_v<Good, decltype(f(g1, g2))>);
+
+  }
+
+  namespace test_inline_variables
+  {
+
+    template<class T> void f(T)
+    {}
+
+    template<class T> inline T g(T)
+    {
+      return T{};
+    }
+
+    template<> inline void f<>(int)
+    {}
+
+    template<> int g<>(int)
+    {
+      return 5;
+    }
+
+  }
+
+}  // namespace cxx17
+
+#endif  // __cplusplus < 201703L && !defined _MSC_VER
+
+
+
 _ACEOF
 if ac_fn_cxx_try_compile "$LINENO"; then :
-  ax_cv_cxx_compile_cxx11=yes
+  eval $cachevar=yes
 else
-  ax_cv_cxx_compile_cxx11=no
+  eval $cachevar=no
 fi
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+         CXX="$ac_save_CXX"
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_cxx_compile_cxx11" >&5
-$as_echo "$ax_cv_cxx_compile_cxx11" >&6; }
-    if test x$ax_cv_cxx_compile_cxx11 = xyes; then
-      ac_success=yes
-    fi
+eval ac_res=\$$cachevar
+	       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+      if eval test x\$$cachevar = xyes; then
+        CXX_DIALECT="$switch"
+        CXX="$CXX $switch"
+        if test -n "$CXXCPP" ; then
+          CXXCPP="$CXXCPP $switch"
+        fi
+        ac_success=yes
+        break
+      fi
+    done
+  fi
 
     if test x$ac_success = xno; then
-    for alternative in ${ax_cxx_compile_alternatives}; do
-      switch="-std=gnu++${alternative}"
-      cachevar=`$as_echo "ax_cv_cxx_compile_cxx11_$switch" | $as_tr_sh`
-      { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++11 features with $switch" >&5
-$as_echo_n "checking whether $CXX supports C++11 features with $switch... " >&6; }
+                    for alternative in ${ax_cxx_compile_alternatives}; do
+      for switch in -std=c++${alternative} +std=c++${alternative} "-h std=c++${alternative}" MSVC; do
+        if test x"$switch" = xMSVC; then
+                                        switch=-std:c++${alternative}
+          cachevar=`$as_echo "ax_cv_cxx_compile_cxx17_${switch}_MSVC" | $as_tr_sh`
+        else
+          cachevar=`$as_echo "ax_cv_cxx_compile_cxx17_$switch" | $as_tr_sh`
+        fi
+        { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++17 features with $switch" >&5
+$as_echo_n "checking whether $CXX supports C++17 features with $switch... " >&6; }
 if eval \${$cachevar+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   ac_save_CXX="$CXX"
-         CXX="$CXX $switch"
-         cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+           CXX="$CXX $switch"
+           cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
 
@@ -17120,337 +18450,501 @@ namespace cxx11
 
 
 
-_ACEOF
-if ac_fn_cxx_try_compile "$LINENO"; then :
-  eval $cachevar=yes
-else
-  eval $cachevar=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-         CXX="$ac_save_CXX"
-fi
-eval ac_res=\$$cachevar
-	       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
-$as_echo "$ac_res" >&6; }
-      if eval test x\$$cachevar = xyes; then
-        CXX_DIALECT="$switch"
-        CXX="$CXX $switch"
-        if test -n "$CXXCPP" ; then
-          CXXCPP="$CXXCPP $switch"
-        fi
-        ac_success=yes
-        break
-      fi
-    done
-  fi
 
-    if test x$ac_success = xno; then
-                    for alternative in ${ax_cxx_compile_alternatives}; do
-      for switch in -std=c++${alternative} +std=c++${alternative} "-h std=c++${alternative}" MSVC; do
-        if test x"$switch" = xMSVC; then
-                                        switch=-std:c++${alternative}
-          cachevar=`$as_echo "ax_cv_cxx_compile_cxx11_${switch}_MSVC" | $as_tr_sh`
-        else
-          cachevar=`$as_echo "ax_cv_cxx_compile_cxx11_$switch" | $as_tr_sh`
-        fi
-        { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++11 features with $switch" >&5
-$as_echo_n "checking whether $CXX supports C++11 features with $switch... " >&6; }
-if eval \${$cachevar+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_save_CXX="$CXX"
-           CXX="$CXX $switch"
-           cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
+// If the compiler admits that it is not ready for C++14, why torture it?
+// Hopefully, this will speed up the test.
+
+#ifndef __cplusplus
+
+#error "This is not a C++ compiler"
+
+#elif __cplusplus < 201402L && !defined _MSC_VER
+
+#error "This is not a C++14 compiler"
+
+#else
+
+namespace cxx14
+{
+
+  namespace test_polymorphic_lambdas
+  {
+
+    int
+    test()
+    {
+      const auto lambda = [](auto&&... args){
+        const auto istiny = [](auto x){
+          return (sizeof(x) == 1UL) ? 1 : 0;
+        };
+        const int aretiny[] = { istiny(args)... };
+        return aretiny[0];
+      };
+      return lambda(1, 1L, 1.0f, '1');
+    }
+
+  }
+
+  namespace test_binary_literals
+  {
+
+    constexpr auto ivii = 0b0000000000101010;
+    static_assert(ivii == 42, "wrong value");
+
+  }
+
+  namespace test_generalized_constexpr
+  {
+
+    template < typename CharT >
+    constexpr unsigned long
+    strlen_c(const CharT *const s) noexcept
+    {
+      auto length = 0UL;
+      for (auto p = s; *p; ++p)
+        ++length;
+      return length;
+    }
+
+    static_assert(strlen_c("") == 0UL, "");
+    static_assert(strlen_c("x") == 1UL, "");
+    static_assert(strlen_c("test") == 4UL, "");
+    static_assert(strlen_c("another\0test") == 7UL, "");
+
+  }
+
+  namespace test_lambda_init_capture
+  {
+
+    int
+    test()
+    {
+      auto x = 0;
+      const auto lambda1 = [a = x](int b){ return a + b; };
+      const auto lambda2 = [a = lambda1(x)](){ return a; };
+      return lambda2();
+    }
+
+  }
+
+  namespace test_digit_separators
+  {
+
+    constexpr auto ten_million = 100'000'000;
+    static_assert(ten_million == 100000000, "");
+
+  }
+
+  namespace test_return_type_deduction
+  {
+
+    auto f(int& x) { return x; }
+    decltype(auto) g(int& x) { return x; }
+
+    template < typename T1, typename T2 >
+    struct is_same
+    {
+      static constexpr auto value = false;
+    };
+
+    template < typename T >
+    struct is_same<T, T>
+    {
+      static constexpr auto value = true;
+    };
+
+    int
+    test()
+    {
+      auto x = 0;
+      static_assert(is_same<int, decltype(f(x))>::value, "");
+      static_assert(is_same<int&, decltype(g(x))>::value, "");
+      return x;
+    }
+
+  }
+
+}  // namespace cxx14
+
+#endif  // __cplusplus >= 201402L
+
+
 
 
-// If the compiler admits that it is not ready for C++11, why torture it?
+// If the compiler admits that it is not ready for C++17, why torture it?
 // Hopefully, this will speed up the test.
 
 #ifndef __cplusplus
 
 #error "This is not a C++ compiler"
 
-// MSVC always sets __cplusplus to 199711L in older versions; newer versions
-// only set it correctly if /Zc:__cplusplus is specified as well as a
-// /std:c++NN switch:
-// https://devblogs.microsoft.com/cppblog/msvc-now-correctly-reports-__cplusplus/
-#elif __cplusplus < 201103L && !defined _MSC_VER
+#elif __cplusplus < 201703L && !defined _MSC_VER
 
-#error "This is not a C++11 compiler"
+#error "This is not a C++17 compiler"
 
 #else
 
-namespace cxx11
+#include <initializer_list>
+#include <utility>
+#include <type_traits>
+
+namespace cxx17
 {
 
-  namespace test_static_assert
+  namespace test_constexpr_lambdas
   {
 
-    template <typename T>
-    struct check
-    {
-      static_assert(sizeof(int) <= sizeof(T), "not big enough");
-    };
+    constexpr int foo = [](){return 42;}();
 
   }
 
-  namespace test_final_override
+  namespace test::nested_namespace::definitions
   {
 
-    struct Base
+  }
+
+  namespace test_fold_expression
+  {
+
+    template<typename... Args>
+    int multiply(Args... args)
     {
-      virtual ~Base() {}
-      virtual void f() {}
-    };
+      return (args * ... * 1);
+    }
 
-    struct Derived : public Base
+    template<typename... Args>
+    bool all(Args... args)
     {
-      virtual ~Derived() override {}
-      virtual void f() override {}
-    };
+      return (args && ...);
+    }
 
   }
 
-  namespace test_double_right_angle_brackets
+  namespace test_extended_static_assert
   {
 
-    template < typename T >
-    struct check {};
+    static_assert (true);
 
-    typedef check<void> single_type;
-    typedef check<check<void>> double_type;
-    typedef check<check<check<void>>> triple_type;
-    typedef check<check<check<check<void>>>> quadruple_type;
+  }
+
+  namespace test_auto_brace_init_list
+  {
 
+    auto foo = {5};
+    auto bar {5};
+
+    static_assert(std::is_same<std::initializer_list<int>, decltype(foo)>::value);
+    static_assert(std::is_same<int, decltype(bar)>::value);
   }
 
-  namespace test_decltype
+  namespace test_typename_in_template_template_parameter
   {
 
-    int
-    f()
+    template<template<typename> typename X> struct D;
+
+  }
+
+  namespace test_fallthrough_nodiscard_maybe_unused_attributes
+  {
+
+    int f1()
     {
-      int a = 1;
-      decltype(a) b = 2;
-      return a + b;
+      return 42;
+    }
+
+    [[nodiscard]] int f2()
+    {
+      [[maybe_unused]] auto unused = f1();
+
+      switch (f1())
+      {
+      case 17:
+        f1();
+        [[fallthrough]];
+      case 42:
+        f1();
+      }
+      return f1();
     }
 
   }
 
-  namespace test_type_deduction
+  namespace test_extended_aggregate_initialization
   {
 
-    template < typename T1, typename T2 >
-    struct is_same
+    struct base1
     {
-      static const bool value = false;
+      int b1, b2 = 42;
     };
 
-    template < typename T >
-    struct is_same<T, T>
+    struct base2
     {
-      static const bool value = true;
+      base2() {
+        b3 = 42;
+      }
+      int b3;
     };
 
-    template < typename T1, typename T2 >
-    auto
-    add(T1 a1, T2 a2) -> decltype(a1 + a2)
+    struct derived : base1, base2
     {
-      return a1 + a2;
-    }
+        int d;
+    };
 
-    int
-    test(const int c, volatile int v)
-    {
-      static_assert(is_same<int, decltype(0)>::value == true, "");
-      static_assert(is_same<int, decltype(c)>::value == false, "");
-      static_assert(is_same<int, decltype(v)>::value == false, "");
-      auto ac = c;
-      auto av = v;
-      auto sumi = ac + av + 'x';
-      auto sumf = ac + av + 1.0;
-      static_assert(is_same<int, decltype(ac)>::value == true, "");
-      static_assert(is_same<int, decltype(av)>::value == true, "");
-      static_assert(is_same<int, decltype(sumi)>::value == true, "");
-      static_assert(is_same<int, decltype(sumf)>::value == false, "");
-      static_assert(is_same<int, decltype(add(c, v))>::value == true, "");
-      return (sumf > 0.0) ? sumi : add(c, v);
-    }
+    derived d1 {{1, 2}, {}, 4};  // full initialization
+    derived d2 {{}, {}, 4};      // value-initialized bases
 
   }
 
-  namespace test_noexcept
+  namespace test_general_range_based_for_loop
   {
 
-    int f() { return 0; }
-    int g() noexcept { return 0; }
+    struct iter
+    {
+      int i;
 
-    static_assert(noexcept(f()) == false, "");
-    static_assert(noexcept(g()) == true, "");
+      int& operator* ()
+      {
+        return i;
+      }
 
-  }
+      const int& operator* () const
+      {
+        return i;
+      }
 
-  namespace test_constexpr
-  {
+      iter& operator++()
+      {
+        ++i;
+        return *this;
+      }
+    };
 
-    template < typename CharT >
-    unsigned long constexpr
-    strlen_c_r(const CharT *const s, const unsigned long acc) noexcept
+    struct sentinel
     {
-      return *s ? strlen_c_r(s + 1, acc + 1) : acc;
+      int i;
+    };
+
+    bool operator== (const iter& i, const sentinel& s)
+    {
+      return i.i == s.i;
     }
 
-    template < typename CharT >
-    unsigned long constexpr
-    strlen_c(const CharT *const s) noexcept
+    bool operator!= (const iter& i, const sentinel& s)
     {
-      return strlen_c_r(s, 0UL);
+      return !(i == s);
     }
 
-    static_assert(strlen_c("") == 0UL, "");
-    static_assert(strlen_c("1") == 1UL, "");
-    static_assert(strlen_c("example") == 7UL, "");
-    static_assert(strlen_c("another\0example") == 7UL, "");
+    struct range
+    {
+      iter begin() const
+      {
+        return {0};
+      }
+
+      sentinel end() const
+      {
+        return {5};
+      }
+    };
+
+    void f()
+    {
+      range r {};
+
+      for (auto i : r)
+      {
+        [[maybe_unused]] auto v = i;
+      }
+    }
 
   }
 
-  namespace test_rvalue_references
+  namespace test_lambda_capture_asterisk_this_by_value
   {
 
-    template < int N >
-    struct answer
+    struct t
     {
-      static constexpr int value = N;
+      int i;
+      int foo()
+      {
+        return [*this]()
+        {
+          return i;
+        }();
+      }
     };
 
-    answer<1> f(int&)       { return answer<1>(); }
-    answer<2> f(const int&) { return answer<2>(); }
-    answer<3> f(int&&)      { return answer<3>(); }
+  }
 
-    void
-    test()
-    {
-      int i = 0;
-      const int c = 0;
-      static_assert(decltype(f(i))::value == 1, "");
-      static_assert(decltype(f(c))::value == 2, "");
-      static_assert(decltype(f(0))::value == 3, "");
-    }
+  namespace test_enum_class_construction
+  {
+
+    enum class byte : unsigned char
+    {};
+
+    byte foo {42};
 
   }
 
-  namespace test_uniform_initialization
+  namespace test_constexpr_if
   {
 
-    struct test
+    template <bool cond>
+    int f ()
     {
-      static const int zero {};
-      static const int one {1};
-    };
-
-    static_assert(test::zero == 0, "");
-    static_assert(test::one == 1, "");
+      if constexpr(cond)
+      {
+        return 13;
+      }
+      else
+      {
+        return 42;
+      }
+    }
 
   }
 
-  namespace test_lambdas
+  namespace test_selection_statement_with_initializer
   {
 
-    void
-    test1()
+    int f()
     {
-      auto lambda1 = [](){};
-      auto lambda2 = lambda1;
-      lambda1();
-      lambda2();
+      return 13;
     }
 
-    int
-    test2()
+    int f2()
     {
-      auto a = [](int i, int j){ return i + j; }(1, 2);
-      auto b = []() -> int { return '0'; }();
-      auto c = [=](){ return a + b; }();
-      auto d = [&](){ return c; }();
-      auto e = [a, &b](int x) mutable {
-        const auto identity = [](int y){ return y; };
-        for (auto i = 0; i < a; ++i)
-          a += b--;
-        return x + identity(a + b);
-      }(0);
-      return a + b + c + d + e;
+      if (auto i = f(); i > 0)
+      {
+        return 3;
+      }
+
+      switch (auto i = f(); i + 4)
+      {
+      case 17:
+        return 2;
+
+      default:
+        return 1;
+      }
     }
 
-    int
-    test3()
+  }
+
+  namespace test_template_argument_deduction_for_class_templates
+  {
+
+    template <typename T1, typename T2>
+    struct pair
     {
-      const auto nullary = [](){ return 0; };
-      const auto unary = [](int x){ return x; };
-      using nullary_t = decltype(nullary);
-      using unary_t = decltype(unary);
-      const auto higher1st = [](nullary_t f){ return f(); };
-      const auto higher2nd = [unary](nullary_t f1){
-        return [unary, f1](unary_t f2){ return f2(unary(f1())); };
-      };
-      return higher1st(nullary) + higher2nd(nullary)(unary);
+      pair (T1 p1, T2 p2)
+        : m1 {p1},
+          m2 {p2}
+      {}
+
+      T1 m1;
+      T2 m2;
+    };
+
+    void f()
+    {
+      [[maybe_unused]] auto p = pair{13, 42u};
     }
 
   }
 
-  namespace test_variadic_templates
+  namespace test_non_type_auto_template_parameters
   {
 
-    template <int...>
-    struct sum;
+    template <auto n>
+    struct B
+    {};
 
-    template <int N0, int... N1toN>
-    struct sum<N0, N1toN...>
+    B<5> b1;
+    B<'a'> b2;
+
+  }
+
+  namespace test_structured_bindings
+  {
+
+    int arr[2] = { 1, 2 };
+    std::pair<int, int> pr = { 1, 2 };
+
+    auto f1() -> int(&)[2]
     {
-      static constexpr auto value = N0 + sum<N1toN...>::value;
-    };
+      return arr;
+    }
 
-    template <>
-    struct sum<>
+    auto f2() -> std::pair<int, int>&
     {
-      static constexpr auto value = 0;
+      return pr;
+    }
+
+    struct S
+    {
+      int x1 : 2;
+      volatile double y1;
     };
 
-    static_assert(sum<>::value == 0, "");
-    static_assert(sum<1>::value == 1, "");
-    static_assert(sum<23>::value == 23, "");
-    static_assert(sum<1, 2>::value == 3, "");
-    static_assert(sum<5, 5, 11>::value == 21, "");
-    static_assert(sum<2, 3, 5, 7, 11, 13>::value == 41, "");
+    S f3()
+    {
+      return {};
+    }
+
+    auto [ x1, y1 ] = f1();
+    auto& [ xr1, yr1 ] = f1();
+    auto [ x2, y2 ] = f2();
+    auto& [ xr2, yr2 ] = f2();
+    const auto [ x3, y3 ] = f3();
 
   }
 
-  // http://stackoverflow.com/questions/13728184/template-aliases-and-sfinae
-  // Clang 3.1 fails with headers of libstd++ 4.8.3 when using std::function
-  // because of this.
-  namespace test_template_alias_sfinae
+  namespace test_exception_spec_type_system
   {
 
-    struct foo {};
+    struct Good {};
+    struct Bad {};
 
-    template<typename T>
-    using member = typename T::member_type;
+    void g1() noexcept;
+    void g2();
 
     template<typename T>
-    void func(...) {}
+    Bad
+    f(T*, T*);
 
-    template<typename T>
-    void func(member<T>*) {}
+    template<typename T1, typename T2>
+    Good
+    f(T1*, T2*);
 
-    void test();
+    static_assert (std::is_same_v<Good, decltype(f(g1, g2))>);
 
-    void test() { func<foo>(0); }
+  }
+
+  namespace test_inline_variables
+  {
+
+    template<class T> void f(T)
+    {}
+
+    template<class T> inline T g(T)
+    {
+      return T{};
+    }
+
+    template<> inline void f<>(int)
+    {}
+
+    template<> int g<>(int)
+    {
+      return 5;
+    }
 
   }
 
-}  // namespace cxx11
+}  // namespace cxx17
 
-#endif  // __cplusplus >= 201103L
+#endif  // __cplusplus < 201703L && !defined _MSC_VER
 
 
 
@@ -17487,19 +18981,19 @@ ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
 ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
 ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
-  if test x$ax_cxx_compile_cxx11_required = xtrue; then
+  if test x$ax_cxx_compile_cxx17_required = xtrue; then
     if test x$ac_success = xno; then
-      as_fn_error $? "*** A compiler with support for C++11 language features is required." "$LINENO" 5
+      as_fn_error $? "*** A compiler with support for C++17 language features is required." "$LINENO" 5
     fi
   fi
   if test x$ac_success = xno; then
-    HAVE_CXX11=0
-    { $as_echo "$as_me:${as_lineno-$LINENO}: No compiler with C++11 support was found" >&5
-$as_echo "$as_me: No compiler with C++11 support was found" >&6;}
+    HAVE_CXX17=0
+    { $as_echo "$as_me:${as_lineno-$LINENO}: No compiler with C++17 support was found" >&5
+$as_echo "$as_me: No compiler with C++17 support was found" >&6;}
   else
-    HAVE_CXX11=1
+    HAVE_CXX17=1
 
-$as_echo "#define HAVE_CXX11 1" >>confdefs.h
+$as_echo "#define HAVE_CXX17 1" >>confdefs.h
 
   fi
 
diff --git a/gdb/configure.ac b/gdb/configure.ac
index 3912b77b27f..43e5067e6ff 100644
--- a/gdb/configure.ac
+++ b/gdb/configure.ac
@@ -53,9 +53,9 @@ LT_INIT
 # link tests in the configure script.
 LT_OUTPUT
 
-# We require a C++11 compiler.  Check if one is available, and if
+# We require a C++17 compiler.  Check if one is available, and if
 # necessary, set CXX_DIALECT to some -std=xxx switch.
-AX_CXX_COMPILE_STDCXX(11, , mandatory)
+AX_CXX_COMPILE_STDCXX(17, , mandatory)
 
 # Dependency checking.
 ZW_CREATE_DEPDIR
diff --git a/gdbserver/config.in b/gdbserver/config.in
index 63876afcf85..ab507aa6f6a 100644
--- a/gdbserver/config.in
+++ b/gdbserver/config.in
@@ -28,8 +28,8 @@
 /* Define to 1 if you have the <arpa/inet.h> header file. */
 #undef HAVE_ARPA_INET_H
 
-/* define if the compiler supports basic C++11 syntax */
-#undef HAVE_CXX11
+/* define if the compiler supports basic C++17 syntax */
+#undef HAVE_CXX17
 
 /* Define to 1 if you have the declaration of `ADDR_NO_RANDOMIZE', and to 0 if
    you don't. */
diff --git a/gdbserver/configure b/gdbserver/configure
index a49598fb682..c6b8d7803c4 100755
--- a/gdbserver/configure
+++ b/gdbserver/configure
@@ -669,7 +669,7 @@ ax_pthread_config
 SED
 ALLOCA
 CXX_DIALECT
-HAVE_CXX11
+HAVE_CXX17
 RANLIB
 AR
 INSTALL_DATA
@@ -5007,10 +5007,10 @@ ac_script='s/[\\$]/&&/g;s/;s,x,x,$//'
 program_transform_name=`$as_echo "$program_transform_name" | sed "$ac_script"`
 
 
-# We require a C++11 compiler.  Check if one is available, and if
+# We require a C++17 compiler.  Check if one is available, and if
 # necessary, set CXX_DIALECT to some -std=xxx switch.
 
-  ax_cxx_compile_alternatives="11 0x"    ax_cxx_compile_cxx11_required=true
+  ax_cxx_compile_alternatives="17 1z"    ax_cxx_compile_cxx17_required=true
   ac_ext=cpp
 ac_cpp='$CXXCPP $CPPFLAGS'
 ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
@@ -5019,9 +5019,9 @@ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
   CXX_DIALECT=""
   ac_success=no
 
-      { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++11 features by default" >&5
-$as_echo_n "checking whether $CXX supports C++11 features by default... " >&6; }
-if ${ax_cv_cxx_compile_cxx11+:} false; then :
+      { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++17 features by default" >&5
+$as_echo_n "checking whether $CXX supports C++17 features by default... " >&6; }
+if ${ax_cv_cxx_compile_cxx17+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
@@ -5318,32 +5318,1362 @@ namespace cxx11
 
 
 
+
+// If the compiler admits that it is not ready for C++14, why torture it?
+// Hopefully, this will speed up the test.
+
+#ifndef __cplusplus
+
+#error "This is not a C++ compiler"
+
+#elif __cplusplus < 201402L && !defined _MSC_VER
+
+#error "This is not a C++14 compiler"
+
+#else
+
+namespace cxx14
+{
+
+  namespace test_polymorphic_lambdas
+  {
+
+    int
+    test()
+    {
+      const auto lambda = [](auto&&... args){
+        const auto istiny = [](auto x){
+          return (sizeof(x) == 1UL) ? 1 : 0;
+        };
+        const int aretiny[] = { istiny(args)... };
+        return aretiny[0];
+      };
+      return lambda(1, 1L, 1.0f, '1');
+    }
+
+  }
+
+  namespace test_binary_literals
+  {
+
+    constexpr auto ivii = 0b0000000000101010;
+    static_assert(ivii == 42, "wrong value");
+
+  }
+
+  namespace test_generalized_constexpr
+  {
+
+    template < typename CharT >
+    constexpr unsigned long
+    strlen_c(const CharT *const s) noexcept
+    {
+      auto length = 0UL;
+      for (auto p = s; *p; ++p)
+        ++length;
+      return length;
+    }
+
+    static_assert(strlen_c("") == 0UL, "");
+    static_assert(strlen_c("x") == 1UL, "");
+    static_assert(strlen_c("test") == 4UL, "");
+    static_assert(strlen_c("another\0test") == 7UL, "");
+
+  }
+
+  namespace test_lambda_init_capture
+  {
+
+    int
+    test()
+    {
+      auto x = 0;
+      const auto lambda1 = [a = x](int b){ return a + b; };
+      const auto lambda2 = [a = lambda1(x)](){ return a; };
+      return lambda2();
+    }
+
+  }
+
+  namespace test_digit_separators
+  {
+
+    constexpr auto ten_million = 100'000'000;
+    static_assert(ten_million == 100000000, "");
+
+  }
+
+  namespace test_return_type_deduction
+  {
+
+    auto f(int& x) { return x; }
+    decltype(auto) g(int& x) { return x; }
+
+    template < typename T1, typename T2 >
+    struct is_same
+    {
+      static constexpr auto value = false;
+    };
+
+    template < typename T >
+    struct is_same<T, T>
+    {
+      static constexpr auto value = true;
+    };
+
+    int
+    test()
+    {
+      auto x = 0;
+      static_assert(is_same<int, decltype(f(x))>::value, "");
+      static_assert(is_same<int&, decltype(g(x))>::value, "");
+      return x;
+    }
+
+  }
+
+}  // namespace cxx14
+
+#endif  // __cplusplus >= 201402L
+
+
+
+
+// If the compiler admits that it is not ready for C++17, why torture it?
+// Hopefully, this will speed up the test.
+
+#ifndef __cplusplus
+
+#error "This is not a C++ compiler"
+
+#elif __cplusplus < 201703L && !defined _MSC_VER
+
+#error "This is not a C++17 compiler"
+
+#else
+
+#include <initializer_list>
+#include <utility>
+#include <type_traits>
+
+namespace cxx17
+{
+
+  namespace test_constexpr_lambdas
+  {
+
+    constexpr int foo = [](){return 42;}();
+
+  }
+
+  namespace test::nested_namespace::definitions
+  {
+
+  }
+
+  namespace test_fold_expression
+  {
+
+    template<typename... Args>
+    int multiply(Args... args)
+    {
+      return (args * ... * 1);
+    }
+
+    template<typename... Args>
+    bool all(Args... args)
+    {
+      return (args && ...);
+    }
+
+  }
+
+  namespace test_extended_static_assert
+  {
+
+    static_assert (true);
+
+  }
+
+  namespace test_auto_brace_init_list
+  {
+
+    auto foo = {5};
+    auto bar {5};
+
+    static_assert(std::is_same<std::initializer_list<int>, decltype(foo)>::value);
+    static_assert(std::is_same<int, decltype(bar)>::value);
+  }
+
+  namespace test_typename_in_template_template_parameter
+  {
+
+    template<template<typename> typename X> struct D;
+
+  }
+
+  namespace test_fallthrough_nodiscard_maybe_unused_attributes
+  {
+
+    int f1()
+    {
+      return 42;
+    }
+
+    [[nodiscard]] int f2()
+    {
+      [[maybe_unused]] auto unused = f1();
+
+      switch (f1())
+      {
+      case 17:
+        f1();
+        [[fallthrough]];
+      case 42:
+        f1();
+      }
+      return f1();
+    }
+
+  }
+
+  namespace test_extended_aggregate_initialization
+  {
+
+    struct base1
+    {
+      int b1, b2 = 42;
+    };
+
+    struct base2
+    {
+      base2() {
+        b3 = 42;
+      }
+      int b3;
+    };
+
+    struct derived : base1, base2
+    {
+        int d;
+    };
+
+    derived d1 {{1, 2}, {}, 4};  // full initialization
+    derived d2 {{}, {}, 4};      // value-initialized bases
+
+  }
+
+  namespace test_general_range_based_for_loop
+  {
+
+    struct iter
+    {
+      int i;
+
+      int& operator* ()
+      {
+        return i;
+      }
+
+      const int& operator* () const
+      {
+        return i;
+      }
+
+      iter& operator++()
+      {
+        ++i;
+        return *this;
+      }
+    };
+
+    struct sentinel
+    {
+      int i;
+    };
+
+    bool operator== (const iter& i, const sentinel& s)
+    {
+      return i.i == s.i;
+    }
+
+    bool operator!= (const iter& i, const sentinel& s)
+    {
+      return !(i == s);
+    }
+
+    struct range
+    {
+      iter begin() const
+      {
+        return {0};
+      }
+
+      sentinel end() const
+      {
+        return {5};
+      }
+    };
+
+    void f()
+    {
+      range r {};
+
+      for (auto i : r)
+      {
+        [[maybe_unused]] auto v = i;
+      }
+    }
+
+  }
+
+  namespace test_lambda_capture_asterisk_this_by_value
+  {
+
+    struct t
+    {
+      int i;
+      int foo()
+      {
+        return [*this]()
+        {
+          return i;
+        }();
+      }
+    };
+
+  }
+
+  namespace test_enum_class_construction
+  {
+
+    enum class byte : unsigned char
+    {};
+
+    byte foo {42};
+
+  }
+
+  namespace test_constexpr_if
+  {
+
+    template <bool cond>
+    int f ()
+    {
+      if constexpr(cond)
+      {
+        return 13;
+      }
+      else
+      {
+        return 42;
+      }
+    }
+
+  }
+
+  namespace test_selection_statement_with_initializer
+  {
+
+    int f()
+    {
+      return 13;
+    }
+
+    int f2()
+    {
+      if (auto i = f(); i > 0)
+      {
+        return 3;
+      }
+
+      switch (auto i = f(); i + 4)
+      {
+      case 17:
+        return 2;
+
+      default:
+        return 1;
+      }
+    }
+
+  }
+
+  namespace test_template_argument_deduction_for_class_templates
+  {
+
+    template <typename T1, typename T2>
+    struct pair
+    {
+      pair (T1 p1, T2 p2)
+        : m1 {p1},
+          m2 {p2}
+      {}
+
+      T1 m1;
+      T2 m2;
+    };
+
+    void f()
+    {
+      [[maybe_unused]] auto p = pair{13, 42u};
+    }
+
+  }
+
+  namespace test_non_type_auto_template_parameters
+  {
+
+    template <auto n>
+    struct B
+    {};
+
+    B<5> b1;
+    B<'a'> b2;
+
+  }
+
+  namespace test_structured_bindings
+  {
+
+    int arr[2] = { 1, 2 };
+    std::pair<int, int> pr = { 1, 2 };
+
+    auto f1() -> int(&)[2]
+    {
+      return arr;
+    }
+
+    auto f2() -> std::pair<int, int>&
+    {
+      return pr;
+    }
+
+    struct S
+    {
+      int x1 : 2;
+      volatile double y1;
+    };
+
+    S f3()
+    {
+      return {};
+    }
+
+    auto [ x1, y1 ] = f1();
+    auto& [ xr1, yr1 ] = f1();
+    auto [ x2, y2 ] = f2();
+    auto& [ xr2, yr2 ] = f2();
+    const auto [ x3, y3 ] = f3();
+
+  }
+
+  namespace test_exception_spec_type_system
+  {
+
+    struct Good {};
+    struct Bad {};
+
+    void g1() noexcept;
+    void g2();
+
+    template<typename T>
+    Bad
+    f(T*, T*);
+
+    template<typename T1, typename T2>
+    Good
+    f(T1*, T2*);
+
+    static_assert (std::is_same_v<Good, decltype(f(g1, g2))>);
+
+  }
+
+  namespace test_inline_variables
+  {
+
+    template<class T> void f(T)
+    {}
+
+    template<class T> inline T g(T)
+    {
+      return T{};
+    }
+
+    template<> inline void f<>(int)
+    {}
+
+    template<> int g<>(int)
+    {
+      return 5;
+    }
+
+  }
+
+}  // namespace cxx17
+
+#endif  // __cplusplus < 201703L && !defined _MSC_VER
+
+
+
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
+  ax_cv_cxx_compile_cxx17=yes
+else
+  ax_cv_cxx_compile_cxx17=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_cxx_compile_cxx17" >&5
+$as_echo "$ax_cv_cxx_compile_cxx17" >&6; }
+    if test x$ax_cv_cxx_compile_cxx17 = xyes; then
+      ac_success=yes
+    fi
+
+    if test x$ac_success = xno; then
+    for alternative in ${ax_cxx_compile_alternatives}; do
+      switch="-std=gnu++${alternative}"
+      cachevar=`$as_echo "ax_cv_cxx_compile_cxx17_$switch" | $as_tr_sh`
+      { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++17 features with $switch" >&5
+$as_echo_n "checking whether $CXX supports C++17 features with $switch... " >&6; }
+if eval \${$cachevar+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_save_CXX="$CXX"
+         CXX="$CXX $switch"
+         cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+
+// If the compiler admits that it is not ready for C++11, why torture it?
+// Hopefully, this will speed up the test.
+
+#ifndef __cplusplus
+
+#error "This is not a C++ compiler"
+
+// MSVC always sets __cplusplus to 199711L in older versions; newer versions
+// only set it correctly if /Zc:__cplusplus is specified as well as a
+// /std:c++NN switch:
+// https://devblogs.microsoft.com/cppblog/msvc-now-correctly-reports-__cplusplus/
+#elif __cplusplus < 201103L && !defined _MSC_VER
+
+#error "This is not a C++11 compiler"
+
+#else
+
+namespace cxx11
+{
+
+  namespace test_static_assert
+  {
+
+    template <typename T>
+    struct check
+    {
+      static_assert(sizeof(int) <= sizeof(T), "not big enough");
+    };
+
+  }
+
+  namespace test_final_override
+  {
+
+    struct Base
+    {
+      virtual ~Base() {}
+      virtual void f() {}
+    };
+
+    struct Derived : public Base
+    {
+      virtual ~Derived() override {}
+      virtual void f() override {}
+    };
+
+  }
+
+  namespace test_double_right_angle_brackets
+  {
+
+    template < typename T >
+    struct check {};
+
+    typedef check<void> single_type;
+    typedef check<check<void>> double_type;
+    typedef check<check<check<void>>> triple_type;
+    typedef check<check<check<check<void>>>> quadruple_type;
+
+  }
+
+  namespace test_decltype
+  {
+
+    int
+    f()
+    {
+      int a = 1;
+      decltype(a) b = 2;
+      return a + b;
+    }
+
+  }
+
+  namespace test_type_deduction
+  {
+
+    template < typename T1, typename T2 >
+    struct is_same
+    {
+      static const bool value = false;
+    };
+
+    template < typename T >
+    struct is_same<T, T>
+    {
+      static const bool value = true;
+    };
+
+    template < typename T1, typename T2 >
+    auto
+    add(T1 a1, T2 a2) -> decltype(a1 + a2)
+    {
+      return a1 + a2;
+    }
+
+    int
+    test(const int c, volatile int v)
+    {
+      static_assert(is_same<int, decltype(0)>::value == true, "");
+      static_assert(is_same<int, decltype(c)>::value == false, "");
+      static_assert(is_same<int, decltype(v)>::value == false, "");
+      auto ac = c;
+      auto av = v;
+      auto sumi = ac + av + 'x';
+      auto sumf = ac + av + 1.0;
+      static_assert(is_same<int, decltype(ac)>::value == true, "");
+      static_assert(is_same<int, decltype(av)>::value == true, "");
+      static_assert(is_same<int, decltype(sumi)>::value == true, "");
+      static_assert(is_same<int, decltype(sumf)>::value == false, "");
+      static_assert(is_same<int, decltype(add(c, v))>::value == true, "");
+      return (sumf > 0.0) ? sumi : add(c, v);
+    }
+
+  }
+
+  namespace test_noexcept
+  {
+
+    int f() { return 0; }
+    int g() noexcept { return 0; }
+
+    static_assert(noexcept(f()) == false, "");
+    static_assert(noexcept(g()) == true, "");
+
+  }
+
+  namespace test_constexpr
+  {
+
+    template < typename CharT >
+    unsigned long constexpr
+    strlen_c_r(const CharT *const s, const unsigned long acc) noexcept
+    {
+      return *s ? strlen_c_r(s + 1, acc + 1) : acc;
+    }
+
+    template < typename CharT >
+    unsigned long constexpr
+    strlen_c(const CharT *const s) noexcept
+    {
+      return strlen_c_r(s, 0UL);
+    }
+
+    static_assert(strlen_c("") == 0UL, "");
+    static_assert(strlen_c("1") == 1UL, "");
+    static_assert(strlen_c("example") == 7UL, "");
+    static_assert(strlen_c("another\0example") == 7UL, "");
+
+  }
+
+  namespace test_rvalue_references
+  {
+
+    template < int N >
+    struct answer
+    {
+      static constexpr int value = N;
+    };
+
+    answer<1> f(int&)       { return answer<1>(); }
+    answer<2> f(const int&) { return answer<2>(); }
+    answer<3> f(int&&)      { return answer<3>(); }
+
+    void
+    test()
+    {
+      int i = 0;
+      const int c = 0;
+      static_assert(decltype(f(i))::value == 1, "");
+      static_assert(decltype(f(c))::value == 2, "");
+      static_assert(decltype(f(0))::value == 3, "");
+    }
+
+  }
+
+  namespace test_uniform_initialization
+  {
+
+    struct test
+    {
+      static const int zero {};
+      static const int one {1};
+    };
+
+    static_assert(test::zero == 0, "");
+    static_assert(test::one == 1, "");
+
+  }
+
+  namespace test_lambdas
+  {
+
+    void
+    test1()
+    {
+      auto lambda1 = [](){};
+      auto lambda2 = lambda1;
+      lambda1();
+      lambda2();
+    }
+
+    int
+    test2()
+    {
+      auto a = [](int i, int j){ return i + j; }(1, 2);
+      auto b = []() -> int { return '0'; }();
+      auto c = [=](){ return a + b; }();
+      auto d = [&](){ return c; }();
+      auto e = [a, &b](int x) mutable {
+        const auto identity = [](int y){ return y; };
+        for (auto i = 0; i < a; ++i)
+          a += b--;
+        return x + identity(a + b);
+      }(0);
+      return a + b + c + d + e;
+    }
+
+    int
+    test3()
+    {
+      const auto nullary = [](){ return 0; };
+      const auto unary = [](int x){ return x; };
+      using nullary_t = decltype(nullary);
+      using unary_t = decltype(unary);
+      const auto higher1st = [](nullary_t f){ return f(); };
+      const auto higher2nd = [unary](nullary_t f1){
+        return [unary, f1](unary_t f2){ return f2(unary(f1())); };
+      };
+      return higher1st(nullary) + higher2nd(nullary)(unary);
+    }
+
+  }
+
+  namespace test_variadic_templates
+  {
+
+    template <int...>
+    struct sum;
+
+    template <int N0, int... N1toN>
+    struct sum<N0, N1toN...>
+    {
+      static constexpr auto value = N0 + sum<N1toN...>::value;
+    };
+
+    template <>
+    struct sum<>
+    {
+      static constexpr auto value = 0;
+    };
+
+    static_assert(sum<>::value == 0, "");
+    static_assert(sum<1>::value == 1, "");
+    static_assert(sum<23>::value == 23, "");
+    static_assert(sum<1, 2>::value == 3, "");
+    static_assert(sum<5, 5, 11>::value == 21, "");
+    static_assert(sum<2, 3, 5, 7, 11, 13>::value == 41, "");
+
+  }
+
+  // http://stackoverflow.com/questions/13728184/template-aliases-and-sfinae
+  // Clang 3.1 fails with headers of libstd++ 4.8.3 when using std::function
+  // because of this.
+  namespace test_template_alias_sfinae
+  {
+
+    struct foo {};
+
+    template<typename T>
+    using member = typename T::member_type;
+
+    template<typename T>
+    void func(...) {}
+
+    template<typename T>
+    void func(member<T>*) {}
+
+    void test();
+
+    void test() { func<foo>(0); }
+
+  }
+
+}  // namespace cxx11
+
+#endif  // __cplusplus >= 201103L
+
+
+
+
+// If the compiler admits that it is not ready for C++14, why torture it?
+// Hopefully, this will speed up the test.
+
+#ifndef __cplusplus
+
+#error "This is not a C++ compiler"
+
+#elif __cplusplus < 201402L && !defined _MSC_VER
+
+#error "This is not a C++14 compiler"
+
+#else
+
+namespace cxx14
+{
+
+  namespace test_polymorphic_lambdas
+  {
+
+    int
+    test()
+    {
+      const auto lambda = [](auto&&... args){
+        const auto istiny = [](auto x){
+          return (sizeof(x) == 1UL) ? 1 : 0;
+        };
+        const int aretiny[] = { istiny(args)... };
+        return aretiny[0];
+      };
+      return lambda(1, 1L, 1.0f, '1');
+    }
+
+  }
+
+  namespace test_binary_literals
+  {
+
+    constexpr auto ivii = 0b0000000000101010;
+    static_assert(ivii == 42, "wrong value");
+
+  }
+
+  namespace test_generalized_constexpr
+  {
+
+    template < typename CharT >
+    constexpr unsigned long
+    strlen_c(const CharT *const s) noexcept
+    {
+      auto length = 0UL;
+      for (auto p = s; *p; ++p)
+        ++length;
+      return length;
+    }
+
+    static_assert(strlen_c("") == 0UL, "");
+    static_assert(strlen_c("x") == 1UL, "");
+    static_assert(strlen_c("test") == 4UL, "");
+    static_assert(strlen_c("another\0test") == 7UL, "");
+
+  }
+
+  namespace test_lambda_init_capture
+  {
+
+    int
+    test()
+    {
+      auto x = 0;
+      const auto lambda1 = [a = x](int b){ return a + b; };
+      const auto lambda2 = [a = lambda1(x)](){ return a; };
+      return lambda2();
+    }
+
+  }
+
+  namespace test_digit_separators
+  {
+
+    constexpr auto ten_million = 100'000'000;
+    static_assert(ten_million == 100000000, "");
+
+  }
+
+  namespace test_return_type_deduction
+  {
+
+    auto f(int& x) { return x; }
+    decltype(auto) g(int& x) { return x; }
+
+    template < typename T1, typename T2 >
+    struct is_same
+    {
+      static constexpr auto value = false;
+    };
+
+    template < typename T >
+    struct is_same<T, T>
+    {
+      static constexpr auto value = true;
+    };
+
+    int
+    test()
+    {
+      auto x = 0;
+      static_assert(is_same<int, decltype(f(x))>::value, "");
+      static_assert(is_same<int&, decltype(g(x))>::value, "");
+      return x;
+    }
+
+  }
+
+}  // namespace cxx14
+
+#endif  // __cplusplus >= 201402L
+
+
+
+
+// If the compiler admits that it is not ready for C++17, why torture it?
+// Hopefully, this will speed up the test.
+
+#ifndef __cplusplus
+
+#error "This is not a C++ compiler"
+
+#elif __cplusplus < 201703L && !defined _MSC_VER
+
+#error "This is not a C++17 compiler"
+
+#else
+
+#include <initializer_list>
+#include <utility>
+#include <type_traits>
+
+namespace cxx17
+{
+
+  namespace test_constexpr_lambdas
+  {
+
+    constexpr int foo = [](){return 42;}();
+
+  }
+
+  namespace test::nested_namespace::definitions
+  {
+
+  }
+
+  namespace test_fold_expression
+  {
+
+    template<typename... Args>
+    int multiply(Args... args)
+    {
+      return (args * ... * 1);
+    }
+
+    template<typename... Args>
+    bool all(Args... args)
+    {
+      return (args && ...);
+    }
+
+  }
+
+  namespace test_extended_static_assert
+  {
+
+    static_assert (true);
+
+  }
+
+  namespace test_auto_brace_init_list
+  {
+
+    auto foo = {5};
+    auto bar {5};
+
+    static_assert(std::is_same<std::initializer_list<int>, decltype(foo)>::value);
+    static_assert(std::is_same<int, decltype(bar)>::value);
+  }
+
+  namespace test_typename_in_template_template_parameter
+  {
+
+    template<template<typename> typename X> struct D;
+
+  }
+
+  namespace test_fallthrough_nodiscard_maybe_unused_attributes
+  {
+
+    int f1()
+    {
+      return 42;
+    }
+
+    [[nodiscard]] int f2()
+    {
+      [[maybe_unused]] auto unused = f1();
+
+      switch (f1())
+      {
+      case 17:
+        f1();
+        [[fallthrough]];
+      case 42:
+        f1();
+      }
+      return f1();
+    }
+
+  }
+
+  namespace test_extended_aggregate_initialization
+  {
+
+    struct base1
+    {
+      int b1, b2 = 42;
+    };
+
+    struct base2
+    {
+      base2() {
+        b3 = 42;
+      }
+      int b3;
+    };
+
+    struct derived : base1, base2
+    {
+        int d;
+    };
+
+    derived d1 {{1, 2}, {}, 4};  // full initialization
+    derived d2 {{}, {}, 4};      // value-initialized bases
+
+  }
+
+  namespace test_general_range_based_for_loop
+  {
+
+    struct iter
+    {
+      int i;
+
+      int& operator* ()
+      {
+        return i;
+      }
+
+      const int& operator* () const
+      {
+        return i;
+      }
+
+      iter& operator++()
+      {
+        ++i;
+        return *this;
+      }
+    };
+
+    struct sentinel
+    {
+      int i;
+    };
+
+    bool operator== (const iter& i, const sentinel& s)
+    {
+      return i.i == s.i;
+    }
+
+    bool operator!= (const iter& i, const sentinel& s)
+    {
+      return !(i == s);
+    }
+
+    struct range
+    {
+      iter begin() const
+      {
+        return {0};
+      }
+
+      sentinel end() const
+      {
+        return {5};
+      }
+    };
+
+    void f()
+    {
+      range r {};
+
+      for (auto i : r)
+      {
+        [[maybe_unused]] auto v = i;
+      }
+    }
+
+  }
+
+  namespace test_lambda_capture_asterisk_this_by_value
+  {
+
+    struct t
+    {
+      int i;
+      int foo()
+      {
+        return [*this]()
+        {
+          return i;
+        }();
+      }
+    };
+
+  }
+
+  namespace test_enum_class_construction
+  {
+
+    enum class byte : unsigned char
+    {};
+
+    byte foo {42};
+
+  }
+
+  namespace test_constexpr_if
+  {
+
+    template <bool cond>
+    int f ()
+    {
+      if constexpr(cond)
+      {
+        return 13;
+      }
+      else
+      {
+        return 42;
+      }
+    }
+
+  }
+
+  namespace test_selection_statement_with_initializer
+  {
+
+    int f()
+    {
+      return 13;
+    }
+
+    int f2()
+    {
+      if (auto i = f(); i > 0)
+      {
+        return 3;
+      }
+
+      switch (auto i = f(); i + 4)
+      {
+      case 17:
+        return 2;
+
+      default:
+        return 1;
+      }
+    }
+
+  }
+
+  namespace test_template_argument_deduction_for_class_templates
+  {
+
+    template <typename T1, typename T2>
+    struct pair
+    {
+      pair (T1 p1, T2 p2)
+        : m1 {p1},
+          m2 {p2}
+      {}
+
+      T1 m1;
+      T2 m2;
+    };
+
+    void f()
+    {
+      [[maybe_unused]] auto p = pair{13, 42u};
+    }
+
+  }
+
+  namespace test_non_type_auto_template_parameters
+  {
+
+    template <auto n>
+    struct B
+    {};
+
+    B<5> b1;
+    B<'a'> b2;
+
+  }
+
+  namespace test_structured_bindings
+  {
+
+    int arr[2] = { 1, 2 };
+    std::pair<int, int> pr = { 1, 2 };
+
+    auto f1() -> int(&)[2]
+    {
+      return arr;
+    }
+
+    auto f2() -> std::pair<int, int>&
+    {
+      return pr;
+    }
+
+    struct S
+    {
+      int x1 : 2;
+      volatile double y1;
+    };
+
+    S f3()
+    {
+      return {};
+    }
+
+    auto [ x1, y1 ] = f1();
+    auto& [ xr1, yr1 ] = f1();
+    auto [ x2, y2 ] = f2();
+    auto& [ xr2, yr2 ] = f2();
+    const auto [ x3, y3 ] = f3();
+
+  }
+
+  namespace test_exception_spec_type_system
+  {
+
+    struct Good {};
+    struct Bad {};
+
+    void g1() noexcept;
+    void g2();
+
+    template<typename T>
+    Bad
+    f(T*, T*);
+
+    template<typename T1, typename T2>
+    Good
+    f(T1*, T2*);
+
+    static_assert (std::is_same_v<Good, decltype(f(g1, g2))>);
+
+  }
+
+  namespace test_inline_variables
+  {
+
+    template<class T> void f(T)
+    {}
+
+    template<class T> inline T g(T)
+    {
+      return T{};
+    }
+
+    template<> inline void f<>(int)
+    {}
+
+    template<> int g<>(int)
+    {
+      return 5;
+    }
+
+  }
+
+}  // namespace cxx17
+
+#endif  // __cplusplus < 201703L && !defined _MSC_VER
+
+
+
 _ACEOF
 if ac_fn_cxx_try_compile "$LINENO"; then :
-  ax_cv_cxx_compile_cxx11=yes
+  eval $cachevar=yes
 else
-  ax_cv_cxx_compile_cxx11=no
+  eval $cachevar=no
 fi
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+         CXX="$ac_save_CXX"
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_cxx_compile_cxx11" >&5
-$as_echo "$ax_cv_cxx_compile_cxx11" >&6; }
-    if test x$ax_cv_cxx_compile_cxx11 = xyes; then
-      ac_success=yes
-    fi
+eval ac_res=\$$cachevar
+	       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+      if eval test x\$$cachevar = xyes; then
+        CXX_DIALECT="$switch"
+        CXX="$CXX $switch"
+        if test -n "$CXXCPP" ; then
+          CXXCPP="$CXXCPP $switch"
+        fi
+        ac_success=yes
+        break
+      fi
+    done
+  fi
 
     if test x$ac_success = xno; then
-    for alternative in ${ax_cxx_compile_alternatives}; do
-      switch="-std=gnu++${alternative}"
-      cachevar=`$as_echo "ax_cv_cxx_compile_cxx11_$switch" | $as_tr_sh`
-      { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++11 features with $switch" >&5
-$as_echo_n "checking whether $CXX supports C++11 features with $switch... " >&6; }
+                    for alternative in ${ax_cxx_compile_alternatives}; do
+      for switch in -std=c++${alternative} +std=c++${alternative} "-h std=c++${alternative}" MSVC; do
+        if test x"$switch" = xMSVC; then
+                                        switch=-std:c++${alternative}
+          cachevar=`$as_echo "ax_cv_cxx_compile_cxx17_${switch}_MSVC" | $as_tr_sh`
+        else
+          cachevar=`$as_echo "ax_cv_cxx_compile_cxx17_$switch" | $as_tr_sh`
+        fi
+        { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++17 features with $switch" >&5
+$as_echo_n "checking whether $CXX supports C++17 features with $switch... " >&6; }
 if eval \${$cachevar+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   ac_save_CXX="$CXX"
-         CXX="$CXX $switch"
-         cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+           CXX="$CXX $switch"
+           cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
 
@@ -5637,337 +6967,501 @@ namespace cxx11
 
 
 
-_ACEOF
-if ac_fn_cxx_try_compile "$LINENO"; then :
-  eval $cachevar=yes
-else
-  eval $cachevar=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-         CXX="$ac_save_CXX"
-fi
-eval ac_res=\$$cachevar
-	       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
-$as_echo "$ac_res" >&6; }
-      if eval test x\$$cachevar = xyes; then
-        CXX_DIALECT="$switch"
-        CXX="$CXX $switch"
-        if test -n "$CXXCPP" ; then
-          CXXCPP="$CXXCPP $switch"
-        fi
-        ac_success=yes
-        break
-      fi
-    done
-  fi
 
-    if test x$ac_success = xno; then
-                    for alternative in ${ax_cxx_compile_alternatives}; do
-      for switch in -std=c++${alternative} +std=c++${alternative} "-h std=c++${alternative}" MSVC; do
-        if test x"$switch" = xMSVC; then
-                                        switch=-std:c++${alternative}
-          cachevar=`$as_echo "ax_cv_cxx_compile_cxx11_${switch}_MSVC" | $as_tr_sh`
-        else
-          cachevar=`$as_echo "ax_cv_cxx_compile_cxx11_$switch" | $as_tr_sh`
-        fi
-        { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++11 features with $switch" >&5
-$as_echo_n "checking whether $CXX supports C++11 features with $switch... " >&6; }
-if eval \${$cachevar+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_save_CXX="$CXX"
-           CXX="$CXX $switch"
-           cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
+// If the compiler admits that it is not ready for C++14, why torture it?
+// Hopefully, this will speed up the test.
+
+#ifndef __cplusplus
+
+#error "This is not a C++ compiler"
+
+#elif __cplusplus < 201402L && !defined _MSC_VER
+
+#error "This is not a C++14 compiler"
+
+#else
+
+namespace cxx14
+{
+
+  namespace test_polymorphic_lambdas
+  {
+
+    int
+    test()
+    {
+      const auto lambda = [](auto&&... args){
+        const auto istiny = [](auto x){
+          return (sizeof(x) == 1UL) ? 1 : 0;
+        };
+        const int aretiny[] = { istiny(args)... };
+        return aretiny[0];
+      };
+      return lambda(1, 1L, 1.0f, '1');
+    }
+
+  }
+
+  namespace test_binary_literals
+  {
+
+    constexpr auto ivii = 0b0000000000101010;
+    static_assert(ivii == 42, "wrong value");
+
+  }
+
+  namespace test_generalized_constexpr
+  {
+
+    template < typename CharT >
+    constexpr unsigned long
+    strlen_c(const CharT *const s) noexcept
+    {
+      auto length = 0UL;
+      for (auto p = s; *p; ++p)
+        ++length;
+      return length;
+    }
+
+    static_assert(strlen_c("") == 0UL, "");
+    static_assert(strlen_c("x") == 1UL, "");
+    static_assert(strlen_c("test") == 4UL, "");
+    static_assert(strlen_c("another\0test") == 7UL, "");
+
+  }
+
+  namespace test_lambda_init_capture
+  {
+
+    int
+    test()
+    {
+      auto x = 0;
+      const auto lambda1 = [a = x](int b){ return a + b; };
+      const auto lambda2 = [a = lambda1(x)](){ return a; };
+      return lambda2();
+    }
+
+  }
+
+  namespace test_digit_separators
+  {
+
+    constexpr auto ten_million = 100'000'000;
+    static_assert(ten_million == 100000000, "");
+
+  }
+
+  namespace test_return_type_deduction
+  {
+
+    auto f(int& x) { return x; }
+    decltype(auto) g(int& x) { return x; }
+
+    template < typename T1, typename T2 >
+    struct is_same
+    {
+      static constexpr auto value = false;
+    };
+
+    template < typename T >
+    struct is_same<T, T>
+    {
+      static constexpr auto value = true;
+    };
+
+    int
+    test()
+    {
+      auto x = 0;
+      static_assert(is_same<int, decltype(f(x))>::value, "");
+      static_assert(is_same<int&, decltype(g(x))>::value, "");
+      return x;
+    }
+
+  }
 
+}  // namespace cxx14
 
-// If the compiler admits that it is not ready for C++11, why torture it?
+#endif  // __cplusplus >= 201402L
+
+
+
+
+// If the compiler admits that it is not ready for C++17, why torture it?
 // Hopefully, this will speed up the test.
 
 #ifndef __cplusplus
 
 #error "This is not a C++ compiler"
 
-// MSVC always sets __cplusplus to 199711L in older versions; newer versions
-// only set it correctly if /Zc:__cplusplus is specified as well as a
-// /std:c++NN switch:
-// https://devblogs.microsoft.com/cppblog/msvc-now-correctly-reports-__cplusplus/
-#elif __cplusplus < 201103L && !defined _MSC_VER
+#elif __cplusplus < 201703L && !defined _MSC_VER
 
-#error "This is not a C++11 compiler"
+#error "This is not a C++17 compiler"
 
 #else
 
-namespace cxx11
+#include <initializer_list>
+#include <utility>
+#include <type_traits>
+
+namespace cxx17
 {
 
-  namespace test_static_assert
+  namespace test_constexpr_lambdas
   {
 
-    template <typename T>
-    struct check
-    {
-      static_assert(sizeof(int) <= sizeof(T), "not big enough");
-    };
+    constexpr int foo = [](){return 42;}();
 
   }
 
-  namespace test_final_override
+  namespace test::nested_namespace::definitions
   {
 
-    struct Base
+  }
+
+  namespace test_fold_expression
+  {
+
+    template<typename... Args>
+    int multiply(Args... args)
     {
-      virtual ~Base() {}
-      virtual void f() {}
-    };
+      return (args * ... * 1);
+    }
 
-    struct Derived : public Base
+    template<typename... Args>
+    bool all(Args... args)
     {
-      virtual ~Derived() override {}
-      virtual void f() override {}
-    };
+      return (args && ...);
+    }
 
   }
 
-  namespace test_double_right_angle_brackets
+  namespace test_extended_static_assert
   {
 
-    template < typename T >
-    struct check {};
+    static_assert (true);
 
-    typedef check<void> single_type;
-    typedef check<check<void>> double_type;
-    typedef check<check<check<void>>> triple_type;
-    typedef check<check<check<check<void>>>> quadruple_type;
+  }
+
+  namespace test_auto_brace_init_list
+  {
 
+    auto foo = {5};
+    auto bar {5};
+
+    static_assert(std::is_same<std::initializer_list<int>, decltype(foo)>::value);
+    static_assert(std::is_same<int, decltype(bar)>::value);
   }
 
-  namespace test_decltype
+  namespace test_typename_in_template_template_parameter
   {
 
-    int
-    f()
+    template<template<typename> typename X> struct D;
+
+  }
+
+  namespace test_fallthrough_nodiscard_maybe_unused_attributes
+  {
+
+    int f1()
     {
-      int a = 1;
-      decltype(a) b = 2;
-      return a + b;
+      return 42;
+    }
+
+    [[nodiscard]] int f2()
+    {
+      [[maybe_unused]] auto unused = f1();
+
+      switch (f1())
+      {
+      case 17:
+        f1();
+        [[fallthrough]];
+      case 42:
+        f1();
+      }
+      return f1();
     }
 
   }
 
-  namespace test_type_deduction
+  namespace test_extended_aggregate_initialization
   {
 
-    template < typename T1, typename T2 >
-    struct is_same
+    struct base1
     {
-      static const bool value = false;
+      int b1, b2 = 42;
     };
 
-    template < typename T >
-    struct is_same<T, T>
+    struct base2
     {
-      static const bool value = true;
+      base2() {
+        b3 = 42;
+      }
+      int b3;
     };
 
-    template < typename T1, typename T2 >
-    auto
-    add(T1 a1, T2 a2) -> decltype(a1 + a2)
+    struct derived : base1, base2
     {
-      return a1 + a2;
+        int d;
+    };
+
+    derived d1 {{1, 2}, {}, 4};  // full initialization
+    derived d2 {{}, {}, 4};      // value-initialized bases
+
+  }
+
+  namespace test_general_range_based_for_loop
+  {
+
+    struct iter
+    {
+      int i;
+
+      int& operator* ()
+      {
+        return i;
+      }
+
+      const int& operator* () const
+      {
+        return i;
+      }
+
+      iter& operator++()
+      {
+        ++i;
+        return *this;
+      }
+    };
+
+    struct sentinel
+    {
+      int i;
+    };
+
+    bool operator== (const iter& i, const sentinel& s)
+    {
+      return i.i == s.i;
     }
 
-    int
-    test(const int c, volatile int v)
+    bool operator!= (const iter& i, const sentinel& s)
     {
-      static_assert(is_same<int, decltype(0)>::value == true, "");
-      static_assert(is_same<int, decltype(c)>::value == false, "");
-      static_assert(is_same<int, decltype(v)>::value == false, "");
-      auto ac = c;
-      auto av = v;
-      auto sumi = ac + av + 'x';
-      auto sumf = ac + av + 1.0;
-      static_assert(is_same<int, decltype(ac)>::value == true, "");
-      static_assert(is_same<int, decltype(av)>::value == true, "");
-      static_assert(is_same<int, decltype(sumi)>::value == true, "");
-      static_assert(is_same<int, decltype(sumf)>::value == false, "");
-      static_assert(is_same<int, decltype(add(c, v))>::value == true, "");
-      return (sumf > 0.0) ? sumi : add(c, v);
+      return !(i == s);
+    }
+
+    struct range
+    {
+      iter begin() const
+      {
+        return {0};
+      }
+
+      sentinel end() const
+      {
+        return {5};
+      }
+    };
+
+    void f()
+    {
+      range r {};
+
+      for (auto i : r)
+      {
+        [[maybe_unused]] auto v = i;
+      }
     }
 
   }
 
-  namespace test_noexcept
+  namespace test_lambda_capture_asterisk_this_by_value
   {
 
-    int f() { return 0; }
-    int g() noexcept { return 0; }
+    struct t
+    {
+      int i;
+      int foo()
+      {
+        return [*this]()
+        {
+          return i;
+        }();
+      }
+    };
 
-    static_assert(noexcept(f()) == false, "");
-    static_assert(noexcept(g()) == true, "");
+  }
+
+  namespace test_enum_class_construction
+  {
+
+    enum class byte : unsigned char
+    {};
+
+    byte foo {42};
 
   }
 
-  namespace test_constexpr
+  namespace test_constexpr_if
   {
 
-    template < typename CharT >
-    unsigned long constexpr
-    strlen_c_r(const CharT *const s, const unsigned long acc) noexcept
+    template <bool cond>
+    int f ()
     {
-      return *s ? strlen_c_r(s + 1, acc + 1) : acc;
+      if constexpr(cond)
+      {
+        return 13;
+      }
+      else
+      {
+        return 42;
+      }
     }
 
-    template < typename CharT >
-    unsigned long constexpr
-    strlen_c(const CharT *const s) noexcept
+  }
+
+  namespace test_selection_statement_with_initializer
+  {
+
+    int f()
     {
-      return strlen_c_r(s, 0UL);
+      return 13;
     }
 
-    static_assert(strlen_c("") == 0UL, "");
-    static_assert(strlen_c("1") == 1UL, "");
-    static_assert(strlen_c("example") == 7UL, "");
-    static_assert(strlen_c("another\0example") == 7UL, "");
+    int f2()
+    {
+      if (auto i = f(); i > 0)
+      {
+        return 3;
+      }
+
+      switch (auto i = f(); i + 4)
+      {
+      case 17:
+        return 2;
+
+      default:
+        return 1;
+      }
+    }
 
   }
 
-  namespace test_rvalue_references
+  namespace test_template_argument_deduction_for_class_templates
   {
 
-    template < int N >
-    struct answer
+    template <typename T1, typename T2>
+    struct pair
     {
-      static constexpr int value = N;
-    };
+      pair (T1 p1, T2 p2)
+        : m1 {p1},
+          m2 {p2}
+      {}
 
-    answer<1> f(int&)       { return answer<1>(); }
-    answer<2> f(const int&) { return answer<2>(); }
-    answer<3> f(int&&)      { return answer<3>(); }
+      T1 m1;
+      T2 m2;
+    };
 
-    void
-    test()
+    void f()
     {
-      int i = 0;
-      const int c = 0;
-      static_assert(decltype(f(i))::value == 1, "");
-      static_assert(decltype(f(c))::value == 2, "");
-      static_assert(decltype(f(0))::value == 3, "");
+      [[maybe_unused]] auto p = pair{13, 42u};
     }
 
   }
 
-  namespace test_uniform_initialization
+  namespace test_non_type_auto_template_parameters
   {
 
-    struct test
-    {
-      static const int zero {};
-      static const int one {1};
-    };
+    template <auto n>
+    struct B
+    {};
 
-    static_assert(test::zero == 0, "");
-    static_assert(test::one == 1, "");
+    B<5> b1;
+    B<'a'> b2;
 
   }
 
-  namespace test_lambdas
+  namespace test_structured_bindings
   {
 
-    void
-    test1()
+    int arr[2] = { 1, 2 };
+    std::pair<int, int> pr = { 1, 2 };
+
+    auto f1() -> int(&)[2]
     {
-      auto lambda1 = [](){};
-      auto lambda2 = lambda1;
-      lambda1();
-      lambda2();
+      return arr;
     }
 
-    int
-    test2()
+    auto f2() -> std::pair<int, int>&
     {
-      auto a = [](int i, int j){ return i + j; }(1, 2);
-      auto b = []() -> int { return '0'; }();
-      auto c = [=](){ return a + b; }();
-      auto d = [&](){ return c; }();
-      auto e = [a, &b](int x) mutable {
-        const auto identity = [](int y){ return y; };
-        for (auto i = 0; i < a; ++i)
-          a += b--;
-        return x + identity(a + b);
-      }(0);
-      return a + b + c + d + e;
+      return pr;
     }
 
-    int
-    test3()
+    struct S
     {
-      const auto nullary = [](){ return 0; };
-      const auto unary = [](int x){ return x; };
-      using nullary_t = decltype(nullary);
-      using unary_t = decltype(unary);
-      const auto higher1st = [](nullary_t f){ return f(); };
-      const auto higher2nd = [unary](nullary_t f1){
-        return [unary, f1](unary_t f2){ return f2(unary(f1())); };
-      };
-      return higher1st(nullary) + higher2nd(nullary)(unary);
+      int x1 : 2;
+      volatile double y1;
+    };
+
+    S f3()
+    {
+      return {};
     }
 
+    auto [ x1, y1 ] = f1();
+    auto& [ xr1, yr1 ] = f1();
+    auto [ x2, y2 ] = f2();
+    auto& [ xr2, yr2 ] = f2();
+    const auto [ x3, y3 ] = f3();
+
   }
 
-  namespace test_variadic_templates
+  namespace test_exception_spec_type_system
   {
 
-    template <int...>
-    struct sum;
+    struct Good {};
+    struct Bad {};
 
-    template <int N0, int... N1toN>
-    struct sum<N0, N1toN...>
-    {
-      static constexpr auto value = N0 + sum<N1toN...>::value;
-    };
+    void g1() noexcept;
+    void g2();
 
-    template <>
-    struct sum<>
-    {
-      static constexpr auto value = 0;
-    };
+    template<typename T>
+    Bad
+    f(T*, T*);
 
-    static_assert(sum<>::value == 0, "");
-    static_assert(sum<1>::value == 1, "");
-    static_assert(sum<23>::value == 23, "");
-    static_assert(sum<1, 2>::value == 3, "");
-    static_assert(sum<5, 5, 11>::value == 21, "");
-    static_assert(sum<2, 3, 5, 7, 11, 13>::value == 41, "");
+    template<typename T1, typename T2>
+    Good
+    f(T1*, T2*);
+
+    static_assert (std::is_same_v<Good, decltype(f(g1, g2))>);
 
   }
 
-  // http://stackoverflow.com/questions/13728184/template-aliases-and-sfinae
-  // Clang 3.1 fails with headers of libstd++ 4.8.3 when using std::function
-  // because of this.
-  namespace test_template_alias_sfinae
+  namespace test_inline_variables
   {
 
-    struct foo {};
-
-    template<typename T>
-    using member = typename T::member_type;
-
-    template<typename T>
-    void func(...) {}
+    template<class T> void f(T)
+    {}
 
-    template<typename T>
-    void func(member<T>*) {}
+    template<class T> inline T g(T)
+    {
+      return T{};
+    }
 
-    void test();
+    template<> inline void f<>(int)
+    {}
 
-    void test() { func<foo>(0); }
+    template<> int g<>(int)
+    {
+      return 5;
+    }
 
   }
 
-}  // namespace cxx11
+}  // namespace cxx17
 
-#endif  // __cplusplus >= 201103L
+#endif  // __cplusplus < 201703L && !defined _MSC_VER
 
 
 
@@ -6004,19 +7498,19 @@ ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
 ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
 ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
-  if test x$ax_cxx_compile_cxx11_required = xtrue; then
+  if test x$ax_cxx_compile_cxx17_required = xtrue; then
     if test x$ac_success = xno; then
-      as_fn_error $? "*** A compiler with support for C++11 language features is required." "$LINENO" 5
+      as_fn_error $? "*** A compiler with support for C++17 language features is required." "$LINENO" 5
     fi
   fi
   if test x$ac_success = xno; then
-    HAVE_CXX11=0
-    { $as_echo "$as_me:${as_lineno-$LINENO}: No compiler with C++11 support was found" >&5
-$as_echo "$as_me: No compiler with C++11 support was found" >&6;}
+    HAVE_CXX17=0
+    { $as_echo "$as_me:${as_lineno-$LINENO}: No compiler with C++17 support was found" >&5
+$as_echo "$as_me: No compiler with C++17 support was found" >&6;}
   else
-    HAVE_CXX11=1
+    HAVE_CXX17=1
 
-$as_echo "#define HAVE_CXX11 1" >>confdefs.h
+$as_echo "#define HAVE_CXX17 1" >>confdefs.h
 
   fi
 
diff --git a/gdbserver/configure.ac b/gdbserver/configure.ac
index 12bc0090d67..2609a11e6f6 100644
--- a/gdbserver/configure.ac
+++ b/gdbserver/configure.ac
@@ -46,9 +46,9 @@ AC_PROG_RANLIB
 
 AC_ARG_PROGRAM
 
-# We require a C++11 compiler.  Check if one is available, and if
+# We require a C++17 compiler.  Check if one is available, and if
 # necessary, set CXX_DIALECT to some -std=xxx switch.
-AX_CXX_COMPILE_STDCXX(11, , mandatory)
+AX_CXX_COMPILE_STDCXX(17, , mandatory)
 
 AC_HEADER_STDC
 
diff --git a/gdbsupport/Makefile.in b/gdbsupport/Makefile.in
index 07cb78fc4c7..50a5a55e19d 100644
--- a/gdbsupport/Makefile.in
+++ b/gdbsupport/Makefile.in
@@ -252,7 +252,7 @@ EXEEXT = @EXEEXT@
 GENCAT = @GENCAT@
 GMSGFMT = @GMSGFMT@
 GREP = @GREP@
-HAVE_CXX11 = @HAVE_CXX11@
+HAVE_CXX17 = @HAVE_CXX17@
 HAVE_LIBIPT = @HAVE_LIBIPT@
 HAVE_LIBXXHASH = @HAVE_LIBXXHASH@
 INCINTL = @INCINTL@
diff --git a/gdbsupport/config.in b/gdbsupport/config.in
index 2cdc1fbde61..1cef12634bd 100644
--- a/gdbsupport/config.in
+++ b/gdbsupport/config.in
@@ -28,8 +28,8 @@
    */
 #undef HAVE_ALLOCA_H
 
-/* define if the compiler supports basic C++11 syntax */
-#undef HAVE_CXX11
+/* define if the compiler supports basic C++17 syntax */
+#undef HAVE_CXX17
 
 /* Define to 1 if you have the declaration of `ADDR_NO_RANDOMIZE', and to 0 if
    you don't. */
diff --git a/gdbsupport/configure b/gdbsupport/configure
index 6d2a4309d7e..0ef3d25a10b 100755
--- a/gdbsupport/configure
+++ b/gdbsupport/configure
@@ -656,7 +656,7 @@ LIBINTL_DEP
 LIBINTL
 USE_NLS
 CXX_DIALECT
-HAVE_CXX11
+HAVE_CXX17
 LARGEFILE_CPPFLAGS
 EGREP
 GREP
@@ -5905,10 +5905,10 @@ fi
 
 
 
-# We require a C++11 compiler.  Check if one is available, and if
+# We require a C++17 compiler.  Check if one is available, and if
 # necessary, set CXX_DIALECT to some -std=xxx switch.
 
-  ax_cxx_compile_alternatives="11 0x"    ax_cxx_compile_cxx11_required=true
+  ax_cxx_compile_alternatives="17 1z"    ax_cxx_compile_cxx17_required=true
   ac_ext=cpp
 ac_cpp='$CXXCPP $CPPFLAGS'
 ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
@@ -5917,9 +5917,9 @@ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
   CXX_DIALECT=""
   ac_success=no
 
-      { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++11 features by default" >&5
-$as_echo_n "checking whether $CXX supports C++11 features by default... " >&6; }
-if ${ax_cv_cxx_compile_cxx11+:} false; then :
+      { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++17 features by default" >&5
+$as_echo_n "checking whether $CXX supports C++17 features by default... " >&6; }
+if ${ax_cv_cxx_compile_cxx17+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
@@ -6216,32 +6216,1362 @@ namespace cxx11
 
 
 
+
+// If the compiler admits that it is not ready for C++14, why torture it?
+// Hopefully, this will speed up the test.
+
+#ifndef __cplusplus
+
+#error "This is not a C++ compiler"
+
+#elif __cplusplus < 201402L && !defined _MSC_VER
+
+#error "This is not a C++14 compiler"
+
+#else
+
+namespace cxx14
+{
+
+  namespace test_polymorphic_lambdas
+  {
+
+    int
+    test()
+    {
+      const auto lambda = [](auto&&... args){
+        const auto istiny = [](auto x){
+          return (sizeof(x) == 1UL) ? 1 : 0;
+        };
+        const int aretiny[] = { istiny(args)... };
+        return aretiny[0];
+      };
+      return lambda(1, 1L, 1.0f, '1');
+    }
+
+  }
+
+  namespace test_binary_literals
+  {
+
+    constexpr auto ivii = 0b0000000000101010;
+    static_assert(ivii == 42, "wrong value");
+
+  }
+
+  namespace test_generalized_constexpr
+  {
+
+    template < typename CharT >
+    constexpr unsigned long
+    strlen_c(const CharT *const s) noexcept
+    {
+      auto length = 0UL;
+      for (auto p = s; *p; ++p)
+        ++length;
+      return length;
+    }
+
+    static_assert(strlen_c("") == 0UL, "");
+    static_assert(strlen_c("x") == 1UL, "");
+    static_assert(strlen_c("test") == 4UL, "");
+    static_assert(strlen_c("another\0test") == 7UL, "");
+
+  }
+
+  namespace test_lambda_init_capture
+  {
+
+    int
+    test()
+    {
+      auto x = 0;
+      const auto lambda1 = [a = x](int b){ return a + b; };
+      const auto lambda2 = [a = lambda1(x)](){ return a; };
+      return lambda2();
+    }
+
+  }
+
+  namespace test_digit_separators
+  {
+
+    constexpr auto ten_million = 100'000'000;
+    static_assert(ten_million == 100000000, "");
+
+  }
+
+  namespace test_return_type_deduction
+  {
+
+    auto f(int& x) { return x; }
+    decltype(auto) g(int& x) { return x; }
+
+    template < typename T1, typename T2 >
+    struct is_same
+    {
+      static constexpr auto value = false;
+    };
+
+    template < typename T >
+    struct is_same<T, T>
+    {
+      static constexpr auto value = true;
+    };
+
+    int
+    test()
+    {
+      auto x = 0;
+      static_assert(is_same<int, decltype(f(x))>::value, "");
+      static_assert(is_same<int&, decltype(g(x))>::value, "");
+      return x;
+    }
+
+  }
+
+}  // namespace cxx14
+
+#endif  // __cplusplus >= 201402L
+
+
+
+
+// If the compiler admits that it is not ready for C++17, why torture it?
+// Hopefully, this will speed up the test.
+
+#ifndef __cplusplus
+
+#error "This is not a C++ compiler"
+
+#elif __cplusplus < 201703L && !defined _MSC_VER
+
+#error "This is not a C++17 compiler"
+
+#else
+
+#include <initializer_list>
+#include <utility>
+#include <type_traits>
+
+namespace cxx17
+{
+
+  namespace test_constexpr_lambdas
+  {
+
+    constexpr int foo = [](){return 42;}();
+
+  }
+
+  namespace test::nested_namespace::definitions
+  {
+
+  }
+
+  namespace test_fold_expression
+  {
+
+    template<typename... Args>
+    int multiply(Args... args)
+    {
+      return (args * ... * 1);
+    }
+
+    template<typename... Args>
+    bool all(Args... args)
+    {
+      return (args && ...);
+    }
+
+  }
+
+  namespace test_extended_static_assert
+  {
+
+    static_assert (true);
+
+  }
+
+  namespace test_auto_brace_init_list
+  {
+
+    auto foo = {5};
+    auto bar {5};
+
+    static_assert(std::is_same<std::initializer_list<int>, decltype(foo)>::value);
+    static_assert(std::is_same<int, decltype(bar)>::value);
+  }
+
+  namespace test_typename_in_template_template_parameter
+  {
+
+    template<template<typename> typename X> struct D;
+
+  }
+
+  namespace test_fallthrough_nodiscard_maybe_unused_attributes
+  {
+
+    int f1()
+    {
+      return 42;
+    }
+
+    [[nodiscard]] int f2()
+    {
+      [[maybe_unused]] auto unused = f1();
+
+      switch (f1())
+      {
+      case 17:
+        f1();
+        [[fallthrough]];
+      case 42:
+        f1();
+      }
+      return f1();
+    }
+
+  }
+
+  namespace test_extended_aggregate_initialization
+  {
+
+    struct base1
+    {
+      int b1, b2 = 42;
+    };
+
+    struct base2
+    {
+      base2() {
+        b3 = 42;
+      }
+      int b3;
+    };
+
+    struct derived : base1, base2
+    {
+        int d;
+    };
+
+    derived d1 {{1, 2}, {}, 4};  // full initialization
+    derived d2 {{}, {}, 4};      // value-initialized bases
+
+  }
+
+  namespace test_general_range_based_for_loop
+  {
+
+    struct iter
+    {
+      int i;
+
+      int& operator* ()
+      {
+        return i;
+      }
+
+      const int& operator* () const
+      {
+        return i;
+      }
+
+      iter& operator++()
+      {
+        ++i;
+        return *this;
+      }
+    };
+
+    struct sentinel
+    {
+      int i;
+    };
+
+    bool operator== (const iter& i, const sentinel& s)
+    {
+      return i.i == s.i;
+    }
+
+    bool operator!= (const iter& i, const sentinel& s)
+    {
+      return !(i == s);
+    }
+
+    struct range
+    {
+      iter begin() const
+      {
+        return {0};
+      }
+
+      sentinel end() const
+      {
+        return {5};
+      }
+    };
+
+    void f()
+    {
+      range r {};
+
+      for (auto i : r)
+      {
+        [[maybe_unused]] auto v = i;
+      }
+    }
+
+  }
+
+  namespace test_lambda_capture_asterisk_this_by_value
+  {
+
+    struct t
+    {
+      int i;
+      int foo()
+      {
+        return [*this]()
+        {
+          return i;
+        }();
+      }
+    };
+
+  }
+
+  namespace test_enum_class_construction
+  {
+
+    enum class byte : unsigned char
+    {};
+
+    byte foo {42};
+
+  }
+
+  namespace test_constexpr_if
+  {
+
+    template <bool cond>
+    int f ()
+    {
+      if constexpr(cond)
+      {
+        return 13;
+      }
+      else
+      {
+        return 42;
+      }
+    }
+
+  }
+
+  namespace test_selection_statement_with_initializer
+  {
+
+    int f()
+    {
+      return 13;
+    }
+
+    int f2()
+    {
+      if (auto i = f(); i > 0)
+      {
+        return 3;
+      }
+
+      switch (auto i = f(); i + 4)
+      {
+      case 17:
+        return 2;
+
+      default:
+        return 1;
+      }
+    }
+
+  }
+
+  namespace test_template_argument_deduction_for_class_templates
+  {
+
+    template <typename T1, typename T2>
+    struct pair
+    {
+      pair (T1 p1, T2 p2)
+        : m1 {p1},
+          m2 {p2}
+      {}
+
+      T1 m1;
+      T2 m2;
+    };
+
+    void f()
+    {
+      [[maybe_unused]] auto p = pair{13, 42u};
+    }
+
+  }
+
+  namespace test_non_type_auto_template_parameters
+  {
+
+    template <auto n>
+    struct B
+    {};
+
+    B<5> b1;
+    B<'a'> b2;
+
+  }
+
+  namespace test_structured_bindings
+  {
+
+    int arr[2] = { 1, 2 };
+    std::pair<int, int> pr = { 1, 2 };
+
+    auto f1() -> int(&)[2]
+    {
+      return arr;
+    }
+
+    auto f2() -> std::pair<int, int>&
+    {
+      return pr;
+    }
+
+    struct S
+    {
+      int x1 : 2;
+      volatile double y1;
+    };
+
+    S f3()
+    {
+      return {};
+    }
+
+    auto [ x1, y1 ] = f1();
+    auto& [ xr1, yr1 ] = f1();
+    auto [ x2, y2 ] = f2();
+    auto& [ xr2, yr2 ] = f2();
+    const auto [ x3, y3 ] = f3();
+
+  }
+
+  namespace test_exception_spec_type_system
+  {
+
+    struct Good {};
+    struct Bad {};
+
+    void g1() noexcept;
+    void g2();
+
+    template<typename T>
+    Bad
+    f(T*, T*);
+
+    template<typename T1, typename T2>
+    Good
+    f(T1*, T2*);
+
+    static_assert (std::is_same_v<Good, decltype(f(g1, g2))>);
+
+  }
+
+  namespace test_inline_variables
+  {
+
+    template<class T> void f(T)
+    {}
+
+    template<class T> inline T g(T)
+    {
+      return T{};
+    }
+
+    template<> inline void f<>(int)
+    {}
+
+    template<> int g<>(int)
+    {
+      return 5;
+    }
+
+  }
+
+}  // namespace cxx17
+
+#endif  // __cplusplus < 201703L && !defined _MSC_VER
+
+
+
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
+  ax_cv_cxx_compile_cxx17=yes
+else
+  ax_cv_cxx_compile_cxx17=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_cxx_compile_cxx17" >&5
+$as_echo "$ax_cv_cxx_compile_cxx17" >&6; }
+    if test x$ax_cv_cxx_compile_cxx17 = xyes; then
+      ac_success=yes
+    fi
+
+    if test x$ac_success = xno; then
+    for alternative in ${ax_cxx_compile_alternatives}; do
+      switch="-std=gnu++${alternative}"
+      cachevar=`$as_echo "ax_cv_cxx_compile_cxx17_$switch" | $as_tr_sh`
+      { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++17 features with $switch" >&5
+$as_echo_n "checking whether $CXX supports C++17 features with $switch... " >&6; }
+if eval \${$cachevar+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_save_CXX="$CXX"
+         CXX="$CXX $switch"
+         cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+
+// If the compiler admits that it is not ready for C++11, why torture it?
+// Hopefully, this will speed up the test.
+
+#ifndef __cplusplus
+
+#error "This is not a C++ compiler"
+
+// MSVC always sets __cplusplus to 199711L in older versions; newer versions
+// only set it correctly if /Zc:__cplusplus is specified as well as a
+// /std:c++NN switch:
+// https://devblogs.microsoft.com/cppblog/msvc-now-correctly-reports-__cplusplus/
+#elif __cplusplus < 201103L && !defined _MSC_VER
+
+#error "This is not a C++11 compiler"
+
+#else
+
+namespace cxx11
+{
+
+  namespace test_static_assert
+  {
+
+    template <typename T>
+    struct check
+    {
+      static_assert(sizeof(int) <= sizeof(T), "not big enough");
+    };
+
+  }
+
+  namespace test_final_override
+  {
+
+    struct Base
+    {
+      virtual ~Base() {}
+      virtual void f() {}
+    };
+
+    struct Derived : public Base
+    {
+      virtual ~Derived() override {}
+      virtual void f() override {}
+    };
+
+  }
+
+  namespace test_double_right_angle_brackets
+  {
+
+    template < typename T >
+    struct check {};
+
+    typedef check<void> single_type;
+    typedef check<check<void>> double_type;
+    typedef check<check<check<void>>> triple_type;
+    typedef check<check<check<check<void>>>> quadruple_type;
+
+  }
+
+  namespace test_decltype
+  {
+
+    int
+    f()
+    {
+      int a = 1;
+      decltype(a) b = 2;
+      return a + b;
+    }
+
+  }
+
+  namespace test_type_deduction
+  {
+
+    template < typename T1, typename T2 >
+    struct is_same
+    {
+      static const bool value = false;
+    };
+
+    template < typename T >
+    struct is_same<T, T>
+    {
+      static const bool value = true;
+    };
+
+    template < typename T1, typename T2 >
+    auto
+    add(T1 a1, T2 a2) -> decltype(a1 + a2)
+    {
+      return a1 + a2;
+    }
+
+    int
+    test(const int c, volatile int v)
+    {
+      static_assert(is_same<int, decltype(0)>::value == true, "");
+      static_assert(is_same<int, decltype(c)>::value == false, "");
+      static_assert(is_same<int, decltype(v)>::value == false, "");
+      auto ac = c;
+      auto av = v;
+      auto sumi = ac + av + 'x';
+      auto sumf = ac + av + 1.0;
+      static_assert(is_same<int, decltype(ac)>::value == true, "");
+      static_assert(is_same<int, decltype(av)>::value == true, "");
+      static_assert(is_same<int, decltype(sumi)>::value == true, "");
+      static_assert(is_same<int, decltype(sumf)>::value == false, "");
+      static_assert(is_same<int, decltype(add(c, v))>::value == true, "");
+      return (sumf > 0.0) ? sumi : add(c, v);
+    }
+
+  }
+
+  namespace test_noexcept
+  {
+
+    int f() { return 0; }
+    int g() noexcept { return 0; }
+
+    static_assert(noexcept(f()) == false, "");
+    static_assert(noexcept(g()) == true, "");
+
+  }
+
+  namespace test_constexpr
+  {
+
+    template < typename CharT >
+    unsigned long constexpr
+    strlen_c_r(const CharT *const s, const unsigned long acc) noexcept
+    {
+      return *s ? strlen_c_r(s + 1, acc + 1) : acc;
+    }
+
+    template < typename CharT >
+    unsigned long constexpr
+    strlen_c(const CharT *const s) noexcept
+    {
+      return strlen_c_r(s, 0UL);
+    }
+
+    static_assert(strlen_c("") == 0UL, "");
+    static_assert(strlen_c("1") == 1UL, "");
+    static_assert(strlen_c("example") == 7UL, "");
+    static_assert(strlen_c("another\0example") == 7UL, "");
+
+  }
+
+  namespace test_rvalue_references
+  {
+
+    template < int N >
+    struct answer
+    {
+      static constexpr int value = N;
+    };
+
+    answer<1> f(int&)       { return answer<1>(); }
+    answer<2> f(const int&) { return answer<2>(); }
+    answer<3> f(int&&)      { return answer<3>(); }
+
+    void
+    test()
+    {
+      int i = 0;
+      const int c = 0;
+      static_assert(decltype(f(i))::value == 1, "");
+      static_assert(decltype(f(c))::value == 2, "");
+      static_assert(decltype(f(0))::value == 3, "");
+    }
+
+  }
+
+  namespace test_uniform_initialization
+  {
+
+    struct test
+    {
+      static const int zero {};
+      static const int one {1};
+    };
+
+    static_assert(test::zero == 0, "");
+    static_assert(test::one == 1, "");
+
+  }
+
+  namespace test_lambdas
+  {
+
+    void
+    test1()
+    {
+      auto lambda1 = [](){};
+      auto lambda2 = lambda1;
+      lambda1();
+      lambda2();
+    }
+
+    int
+    test2()
+    {
+      auto a = [](int i, int j){ return i + j; }(1, 2);
+      auto b = []() -> int { return '0'; }();
+      auto c = [=](){ return a + b; }();
+      auto d = [&](){ return c; }();
+      auto e = [a, &b](int x) mutable {
+        const auto identity = [](int y){ return y; };
+        for (auto i = 0; i < a; ++i)
+          a += b--;
+        return x + identity(a + b);
+      }(0);
+      return a + b + c + d + e;
+    }
+
+    int
+    test3()
+    {
+      const auto nullary = [](){ return 0; };
+      const auto unary = [](int x){ return x; };
+      using nullary_t = decltype(nullary);
+      using unary_t = decltype(unary);
+      const auto higher1st = [](nullary_t f){ return f(); };
+      const auto higher2nd = [unary](nullary_t f1){
+        return [unary, f1](unary_t f2){ return f2(unary(f1())); };
+      };
+      return higher1st(nullary) + higher2nd(nullary)(unary);
+    }
+
+  }
+
+  namespace test_variadic_templates
+  {
+
+    template <int...>
+    struct sum;
+
+    template <int N0, int... N1toN>
+    struct sum<N0, N1toN...>
+    {
+      static constexpr auto value = N0 + sum<N1toN...>::value;
+    };
+
+    template <>
+    struct sum<>
+    {
+      static constexpr auto value = 0;
+    };
+
+    static_assert(sum<>::value == 0, "");
+    static_assert(sum<1>::value == 1, "");
+    static_assert(sum<23>::value == 23, "");
+    static_assert(sum<1, 2>::value == 3, "");
+    static_assert(sum<5, 5, 11>::value == 21, "");
+    static_assert(sum<2, 3, 5, 7, 11, 13>::value == 41, "");
+
+  }
+
+  // http://stackoverflow.com/questions/13728184/template-aliases-and-sfinae
+  // Clang 3.1 fails with headers of libstd++ 4.8.3 when using std::function
+  // because of this.
+  namespace test_template_alias_sfinae
+  {
+
+    struct foo {};
+
+    template<typename T>
+    using member = typename T::member_type;
+
+    template<typename T>
+    void func(...) {}
+
+    template<typename T>
+    void func(member<T>*) {}
+
+    void test();
+
+    void test() { func<foo>(0); }
+
+  }
+
+}  // namespace cxx11
+
+#endif  // __cplusplus >= 201103L
+
+
+
+
+// If the compiler admits that it is not ready for C++14, why torture it?
+// Hopefully, this will speed up the test.
+
+#ifndef __cplusplus
+
+#error "This is not a C++ compiler"
+
+#elif __cplusplus < 201402L && !defined _MSC_VER
+
+#error "This is not a C++14 compiler"
+
+#else
+
+namespace cxx14
+{
+
+  namespace test_polymorphic_lambdas
+  {
+
+    int
+    test()
+    {
+      const auto lambda = [](auto&&... args){
+        const auto istiny = [](auto x){
+          return (sizeof(x) == 1UL) ? 1 : 0;
+        };
+        const int aretiny[] = { istiny(args)... };
+        return aretiny[0];
+      };
+      return lambda(1, 1L, 1.0f, '1');
+    }
+
+  }
+
+  namespace test_binary_literals
+  {
+
+    constexpr auto ivii = 0b0000000000101010;
+    static_assert(ivii == 42, "wrong value");
+
+  }
+
+  namespace test_generalized_constexpr
+  {
+
+    template < typename CharT >
+    constexpr unsigned long
+    strlen_c(const CharT *const s) noexcept
+    {
+      auto length = 0UL;
+      for (auto p = s; *p; ++p)
+        ++length;
+      return length;
+    }
+
+    static_assert(strlen_c("") == 0UL, "");
+    static_assert(strlen_c("x") == 1UL, "");
+    static_assert(strlen_c("test") == 4UL, "");
+    static_assert(strlen_c("another\0test") == 7UL, "");
+
+  }
+
+  namespace test_lambda_init_capture
+  {
+
+    int
+    test()
+    {
+      auto x = 0;
+      const auto lambda1 = [a = x](int b){ return a + b; };
+      const auto lambda2 = [a = lambda1(x)](){ return a; };
+      return lambda2();
+    }
+
+  }
+
+  namespace test_digit_separators
+  {
+
+    constexpr auto ten_million = 100'000'000;
+    static_assert(ten_million == 100000000, "");
+
+  }
+
+  namespace test_return_type_deduction
+  {
+
+    auto f(int& x) { return x; }
+    decltype(auto) g(int& x) { return x; }
+
+    template < typename T1, typename T2 >
+    struct is_same
+    {
+      static constexpr auto value = false;
+    };
+
+    template < typename T >
+    struct is_same<T, T>
+    {
+      static constexpr auto value = true;
+    };
+
+    int
+    test()
+    {
+      auto x = 0;
+      static_assert(is_same<int, decltype(f(x))>::value, "");
+      static_assert(is_same<int&, decltype(g(x))>::value, "");
+      return x;
+    }
+
+  }
+
+}  // namespace cxx14
+
+#endif  // __cplusplus >= 201402L
+
+
+
+
+// If the compiler admits that it is not ready for C++17, why torture it?
+// Hopefully, this will speed up the test.
+
+#ifndef __cplusplus
+
+#error "This is not a C++ compiler"
+
+#elif __cplusplus < 201703L && !defined _MSC_VER
+
+#error "This is not a C++17 compiler"
+
+#else
+
+#include <initializer_list>
+#include <utility>
+#include <type_traits>
+
+namespace cxx17
+{
+
+  namespace test_constexpr_lambdas
+  {
+
+    constexpr int foo = [](){return 42;}();
+
+  }
+
+  namespace test::nested_namespace::definitions
+  {
+
+  }
+
+  namespace test_fold_expression
+  {
+
+    template<typename... Args>
+    int multiply(Args... args)
+    {
+      return (args * ... * 1);
+    }
+
+    template<typename... Args>
+    bool all(Args... args)
+    {
+      return (args && ...);
+    }
+
+  }
+
+  namespace test_extended_static_assert
+  {
+
+    static_assert (true);
+
+  }
+
+  namespace test_auto_brace_init_list
+  {
+
+    auto foo = {5};
+    auto bar {5};
+
+    static_assert(std::is_same<std::initializer_list<int>, decltype(foo)>::value);
+    static_assert(std::is_same<int, decltype(bar)>::value);
+  }
+
+  namespace test_typename_in_template_template_parameter
+  {
+
+    template<template<typename> typename X> struct D;
+
+  }
+
+  namespace test_fallthrough_nodiscard_maybe_unused_attributes
+  {
+
+    int f1()
+    {
+      return 42;
+    }
+
+    [[nodiscard]] int f2()
+    {
+      [[maybe_unused]] auto unused = f1();
+
+      switch (f1())
+      {
+      case 17:
+        f1();
+        [[fallthrough]];
+      case 42:
+        f1();
+      }
+      return f1();
+    }
+
+  }
+
+  namespace test_extended_aggregate_initialization
+  {
+
+    struct base1
+    {
+      int b1, b2 = 42;
+    };
+
+    struct base2
+    {
+      base2() {
+        b3 = 42;
+      }
+      int b3;
+    };
+
+    struct derived : base1, base2
+    {
+        int d;
+    };
+
+    derived d1 {{1, 2}, {}, 4};  // full initialization
+    derived d2 {{}, {}, 4};      // value-initialized bases
+
+  }
+
+  namespace test_general_range_based_for_loop
+  {
+
+    struct iter
+    {
+      int i;
+
+      int& operator* ()
+      {
+        return i;
+      }
+
+      const int& operator* () const
+      {
+        return i;
+      }
+
+      iter& operator++()
+      {
+        ++i;
+        return *this;
+      }
+    };
+
+    struct sentinel
+    {
+      int i;
+    };
+
+    bool operator== (const iter& i, const sentinel& s)
+    {
+      return i.i == s.i;
+    }
+
+    bool operator!= (const iter& i, const sentinel& s)
+    {
+      return !(i == s);
+    }
+
+    struct range
+    {
+      iter begin() const
+      {
+        return {0};
+      }
+
+      sentinel end() const
+      {
+        return {5};
+      }
+    };
+
+    void f()
+    {
+      range r {};
+
+      for (auto i : r)
+      {
+        [[maybe_unused]] auto v = i;
+      }
+    }
+
+  }
+
+  namespace test_lambda_capture_asterisk_this_by_value
+  {
+
+    struct t
+    {
+      int i;
+      int foo()
+      {
+        return [*this]()
+        {
+          return i;
+        }();
+      }
+    };
+
+  }
+
+  namespace test_enum_class_construction
+  {
+
+    enum class byte : unsigned char
+    {};
+
+    byte foo {42};
+
+  }
+
+  namespace test_constexpr_if
+  {
+
+    template <bool cond>
+    int f ()
+    {
+      if constexpr(cond)
+      {
+        return 13;
+      }
+      else
+      {
+        return 42;
+      }
+    }
+
+  }
+
+  namespace test_selection_statement_with_initializer
+  {
+
+    int f()
+    {
+      return 13;
+    }
+
+    int f2()
+    {
+      if (auto i = f(); i > 0)
+      {
+        return 3;
+      }
+
+      switch (auto i = f(); i + 4)
+      {
+      case 17:
+        return 2;
+
+      default:
+        return 1;
+      }
+    }
+
+  }
+
+  namespace test_template_argument_deduction_for_class_templates
+  {
+
+    template <typename T1, typename T2>
+    struct pair
+    {
+      pair (T1 p1, T2 p2)
+        : m1 {p1},
+          m2 {p2}
+      {}
+
+      T1 m1;
+      T2 m2;
+    };
+
+    void f()
+    {
+      [[maybe_unused]] auto p = pair{13, 42u};
+    }
+
+  }
+
+  namespace test_non_type_auto_template_parameters
+  {
+
+    template <auto n>
+    struct B
+    {};
+
+    B<5> b1;
+    B<'a'> b2;
+
+  }
+
+  namespace test_structured_bindings
+  {
+
+    int arr[2] = { 1, 2 };
+    std::pair<int, int> pr = { 1, 2 };
+
+    auto f1() -> int(&)[2]
+    {
+      return arr;
+    }
+
+    auto f2() -> std::pair<int, int>&
+    {
+      return pr;
+    }
+
+    struct S
+    {
+      int x1 : 2;
+      volatile double y1;
+    };
+
+    S f3()
+    {
+      return {};
+    }
+
+    auto [ x1, y1 ] = f1();
+    auto& [ xr1, yr1 ] = f1();
+    auto [ x2, y2 ] = f2();
+    auto& [ xr2, yr2 ] = f2();
+    const auto [ x3, y3 ] = f3();
+
+  }
+
+  namespace test_exception_spec_type_system
+  {
+
+    struct Good {};
+    struct Bad {};
+
+    void g1() noexcept;
+    void g2();
+
+    template<typename T>
+    Bad
+    f(T*, T*);
+
+    template<typename T1, typename T2>
+    Good
+    f(T1*, T2*);
+
+    static_assert (std::is_same_v<Good, decltype(f(g1, g2))>);
+
+  }
+
+  namespace test_inline_variables
+  {
+
+    template<class T> void f(T)
+    {}
+
+    template<class T> inline T g(T)
+    {
+      return T{};
+    }
+
+    template<> inline void f<>(int)
+    {}
+
+    template<> int g<>(int)
+    {
+      return 5;
+    }
+
+  }
+
+}  // namespace cxx17
+
+#endif  // __cplusplus < 201703L && !defined _MSC_VER
+
+
+
 _ACEOF
 if ac_fn_cxx_try_compile "$LINENO"; then :
-  ax_cv_cxx_compile_cxx11=yes
+  eval $cachevar=yes
 else
-  ax_cv_cxx_compile_cxx11=no
+  eval $cachevar=no
 fi
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+         CXX="$ac_save_CXX"
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_cxx_compile_cxx11" >&5
-$as_echo "$ax_cv_cxx_compile_cxx11" >&6; }
-    if test x$ax_cv_cxx_compile_cxx11 = xyes; then
-      ac_success=yes
-    fi
+eval ac_res=\$$cachevar
+	       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+      if eval test x\$$cachevar = xyes; then
+        CXX_DIALECT="$switch"
+        CXX="$CXX $switch"
+        if test -n "$CXXCPP" ; then
+          CXXCPP="$CXXCPP $switch"
+        fi
+        ac_success=yes
+        break
+      fi
+    done
+  fi
 
     if test x$ac_success = xno; then
-    for alternative in ${ax_cxx_compile_alternatives}; do
-      switch="-std=gnu++${alternative}"
-      cachevar=`$as_echo "ax_cv_cxx_compile_cxx11_$switch" | $as_tr_sh`
-      { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++11 features with $switch" >&5
-$as_echo_n "checking whether $CXX supports C++11 features with $switch... " >&6; }
+                    for alternative in ${ax_cxx_compile_alternatives}; do
+      for switch in -std=c++${alternative} +std=c++${alternative} "-h std=c++${alternative}" MSVC; do
+        if test x"$switch" = xMSVC; then
+                                        switch=-std:c++${alternative}
+          cachevar=`$as_echo "ax_cv_cxx_compile_cxx17_${switch}_MSVC" | $as_tr_sh`
+        else
+          cachevar=`$as_echo "ax_cv_cxx_compile_cxx17_$switch" | $as_tr_sh`
+        fi
+        { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++17 features with $switch" >&5
+$as_echo_n "checking whether $CXX supports C++17 features with $switch... " >&6; }
 if eval \${$cachevar+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   ac_save_CXX="$CXX"
-         CXX="$CXX $switch"
-         cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+           CXX="$CXX $switch"
+           cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
 
@@ -6535,337 +7865,501 @@ namespace cxx11
 
 
 
-_ACEOF
-if ac_fn_cxx_try_compile "$LINENO"; then :
-  eval $cachevar=yes
-else
-  eval $cachevar=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-         CXX="$ac_save_CXX"
-fi
-eval ac_res=\$$cachevar
-	       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
-$as_echo "$ac_res" >&6; }
-      if eval test x\$$cachevar = xyes; then
-        CXX_DIALECT="$switch"
-        CXX="$CXX $switch"
-        if test -n "$CXXCPP" ; then
-          CXXCPP="$CXXCPP $switch"
-        fi
-        ac_success=yes
-        break
-      fi
-    done
-  fi
 
-    if test x$ac_success = xno; then
-                    for alternative in ${ax_cxx_compile_alternatives}; do
-      for switch in -std=c++${alternative} +std=c++${alternative} "-h std=c++${alternative}" MSVC; do
-        if test x"$switch" = xMSVC; then
-                                        switch=-std:c++${alternative}
-          cachevar=`$as_echo "ax_cv_cxx_compile_cxx11_${switch}_MSVC" | $as_tr_sh`
-        else
-          cachevar=`$as_echo "ax_cv_cxx_compile_cxx11_$switch" | $as_tr_sh`
-        fi
-        { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++11 features with $switch" >&5
-$as_echo_n "checking whether $CXX supports C++11 features with $switch... " >&6; }
-if eval \${$cachevar+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_save_CXX="$CXX"
-           CXX="$CXX $switch"
-           cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
+// If the compiler admits that it is not ready for C++14, why torture it?
+// Hopefully, this will speed up the test.
+
+#ifndef __cplusplus
+
+#error "This is not a C++ compiler"
+
+#elif __cplusplus < 201402L && !defined _MSC_VER
+
+#error "This is not a C++14 compiler"
+
+#else
+
+namespace cxx14
+{
+
+  namespace test_polymorphic_lambdas
+  {
+
+    int
+    test()
+    {
+      const auto lambda = [](auto&&... args){
+        const auto istiny = [](auto x){
+          return (sizeof(x) == 1UL) ? 1 : 0;
+        };
+        const int aretiny[] = { istiny(args)... };
+        return aretiny[0];
+      };
+      return lambda(1, 1L, 1.0f, '1');
+    }
+
+  }
+
+  namespace test_binary_literals
+  {
+
+    constexpr auto ivii = 0b0000000000101010;
+    static_assert(ivii == 42, "wrong value");
+
+  }
+
+  namespace test_generalized_constexpr
+  {
+
+    template < typename CharT >
+    constexpr unsigned long
+    strlen_c(const CharT *const s) noexcept
+    {
+      auto length = 0UL;
+      for (auto p = s; *p; ++p)
+        ++length;
+      return length;
+    }
+
+    static_assert(strlen_c("") == 0UL, "");
+    static_assert(strlen_c("x") == 1UL, "");
+    static_assert(strlen_c("test") == 4UL, "");
+    static_assert(strlen_c("another\0test") == 7UL, "");
+
+  }
+
+  namespace test_lambda_init_capture
+  {
+
+    int
+    test()
+    {
+      auto x = 0;
+      const auto lambda1 = [a = x](int b){ return a + b; };
+      const auto lambda2 = [a = lambda1(x)](){ return a; };
+      return lambda2();
+    }
+
+  }
+
+  namespace test_digit_separators
+  {
+
+    constexpr auto ten_million = 100'000'000;
+    static_assert(ten_million == 100000000, "");
+
+  }
+
+  namespace test_return_type_deduction
+  {
+
+    auto f(int& x) { return x; }
+    decltype(auto) g(int& x) { return x; }
+
+    template < typename T1, typename T2 >
+    struct is_same
+    {
+      static constexpr auto value = false;
+    };
+
+    template < typename T >
+    struct is_same<T, T>
+    {
+      static constexpr auto value = true;
+    };
+
+    int
+    test()
+    {
+      auto x = 0;
+      static_assert(is_same<int, decltype(f(x))>::value, "");
+      static_assert(is_same<int&, decltype(g(x))>::value, "");
+      return x;
+    }
+
+  }
 
+}  // namespace cxx14
 
-// If the compiler admits that it is not ready for C++11, why torture it?
+#endif  // __cplusplus >= 201402L
+
+
+
+
+// If the compiler admits that it is not ready for C++17, why torture it?
 // Hopefully, this will speed up the test.
 
 #ifndef __cplusplus
 
 #error "This is not a C++ compiler"
 
-// MSVC always sets __cplusplus to 199711L in older versions; newer versions
-// only set it correctly if /Zc:__cplusplus is specified as well as a
-// /std:c++NN switch:
-// https://devblogs.microsoft.com/cppblog/msvc-now-correctly-reports-__cplusplus/
-#elif __cplusplus < 201103L && !defined _MSC_VER
+#elif __cplusplus < 201703L && !defined _MSC_VER
 
-#error "This is not a C++11 compiler"
+#error "This is not a C++17 compiler"
 
 #else
 
-namespace cxx11
+#include <initializer_list>
+#include <utility>
+#include <type_traits>
+
+namespace cxx17
 {
 
-  namespace test_static_assert
+  namespace test_constexpr_lambdas
   {
 
-    template <typename T>
-    struct check
-    {
-      static_assert(sizeof(int) <= sizeof(T), "not big enough");
-    };
+    constexpr int foo = [](){return 42;}();
 
   }
 
-  namespace test_final_override
+  namespace test::nested_namespace::definitions
   {
 
-    struct Base
+  }
+
+  namespace test_fold_expression
+  {
+
+    template<typename... Args>
+    int multiply(Args... args)
     {
-      virtual ~Base() {}
-      virtual void f() {}
-    };
+      return (args * ... * 1);
+    }
 
-    struct Derived : public Base
+    template<typename... Args>
+    bool all(Args... args)
     {
-      virtual ~Derived() override {}
-      virtual void f() override {}
-    };
+      return (args && ...);
+    }
 
   }
 
-  namespace test_double_right_angle_brackets
+  namespace test_extended_static_assert
   {
 
-    template < typename T >
-    struct check {};
+    static_assert (true);
 
-    typedef check<void> single_type;
-    typedef check<check<void>> double_type;
-    typedef check<check<check<void>>> triple_type;
-    typedef check<check<check<check<void>>>> quadruple_type;
+  }
+
+  namespace test_auto_brace_init_list
+  {
 
+    auto foo = {5};
+    auto bar {5};
+
+    static_assert(std::is_same<std::initializer_list<int>, decltype(foo)>::value);
+    static_assert(std::is_same<int, decltype(bar)>::value);
   }
 
-  namespace test_decltype
+  namespace test_typename_in_template_template_parameter
   {
 
-    int
-    f()
+    template<template<typename> typename X> struct D;
+
+  }
+
+  namespace test_fallthrough_nodiscard_maybe_unused_attributes
+  {
+
+    int f1()
     {
-      int a = 1;
-      decltype(a) b = 2;
-      return a + b;
+      return 42;
+    }
+
+    [[nodiscard]] int f2()
+    {
+      [[maybe_unused]] auto unused = f1();
+
+      switch (f1())
+      {
+      case 17:
+        f1();
+        [[fallthrough]];
+      case 42:
+        f1();
+      }
+      return f1();
     }
 
   }
 
-  namespace test_type_deduction
+  namespace test_extended_aggregate_initialization
   {
 
-    template < typename T1, typename T2 >
-    struct is_same
+    struct base1
     {
-      static const bool value = false;
+      int b1, b2 = 42;
     };
 
-    template < typename T >
-    struct is_same<T, T>
+    struct base2
     {
-      static const bool value = true;
+      base2() {
+        b3 = 42;
+      }
+      int b3;
     };
 
-    template < typename T1, typename T2 >
-    auto
-    add(T1 a1, T2 a2) -> decltype(a1 + a2)
+    struct derived : base1, base2
     {
-      return a1 + a2;
+        int d;
+    };
+
+    derived d1 {{1, 2}, {}, 4};  // full initialization
+    derived d2 {{}, {}, 4};      // value-initialized bases
+
+  }
+
+  namespace test_general_range_based_for_loop
+  {
+
+    struct iter
+    {
+      int i;
+
+      int& operator* ()
+      {
+        return i;
+      }
+
+      const int& operator* () const
+      {
+        return i;
+      }
+
+      iter& operator++()
+      {
+        ++i;
+        return *this;
+      }
+    };
+
+    struct sentinel
+    {
+      int i;
+    };
+
+    bool operator== (const iter& i, const sentinel& s)
+    {
+      return i.i == s.i;
     }
 
-    int
-    test(const int c, volatile int v)
+    bool operator!= (const iter& i, const sentinel& s)
     {
-      static_assert(is_same<int, decltype(0)>::value == true, "");
-      static_assert(is_same<int, decltype(c)>::value == false, "");
-      static_assert(is_same<int, decltype(v)>::value == false, "");
-      auto ac = c;
-      auto av = v;
-      auto sumi = ac + av + 'x';
-      auto sumf = ac + av + 1.0;
-      static_assert(is_same<int, decltype(ac)>::value == true, "");
-      static_assert(is_same<int, decltype(av)>::value == true, "");
-      static_assert(is_same<int, decltype(sumi)>::value == true, "");
-      static_assert(is_same<int, decltype(sumf)>::value == false, "");
-      static_assert(is_same<int, decltype(add(c, v))>::value == true, "");
-      return (sumf > 0.0) ? sumi : add(c, v);
+      return !(i == s);
+    }
+
+    struct range
+    {
+      iter begin() const
+      {
+        return {0};
+      }
+
+      sentinel end() const
+      {
+        return {5};
+      }
+    };
+
+    void f()
+    {
+      range r {};
+
+      for (auto i : r)
+      {
+        [[maybe_unused]] auto v = i;
+      }
     }
 
   }
 
-  namespace test_noexcept
+  namespace test_lambda_capture_asterisk_this_by_value
   {
 
-    int f() { return 0; }
-    int g() noexcept { return 0; }
+    struct t
+    {
+      int i;
+      int foo()
+      {
+        return [*this]()
+        {
+          return i;
+        }();
+      }
+    };
 
-    static_assert(noexcept(f()) == false, "");
-    static_assert(noexcept(g()) == true, "");
+  }
+
+  namespace test_enum_class_construction
+  {
+
+    enum class byte : unsigned char
+    {};
+
+    byte foo {42};
 
   }
 
-  namespace test_constexpr
+  namespace test_constexpr_if
   {
 
-    template < typename CharT >
-    unsigned long constexpr
-    strlen_c_r(const CharT *const s, const unsigned long acc) noexcept
+    template <bool cond>
+    int f ()
     {
-      return *s ? strlen_c_r(s + 1, acc + 1) : acc;
+      if constexpr(cond)
+      {
+        return 13;
+      }
+      else
+      {
+        return 42;
+      }
     }
 
-    template < typename CharT >
-    unsigned long constexpr
-    strlen_c(const CharT *const s) noexcept
+  }
+
+  namespace test_selection_statement_with_initializer
+  {
+
+    int f()
     {
-      return strlen_c_r(s, 0UL);
+      return 13;
     }
 
-    static_assert(strlen_c("") == 0UL, "");
-    static_assert(strlen_c("1") == 1UL, "");
-    static_assert(strlen_c("example") == 7UL, "");
-    static_assert(strlen_c("another\0example") == 7UL, "");
+    int f2()
+    {
+      if (auto i = f(); i > 0)
+      {
+        return 3;
+      }
+
+      switch (auto i = f(); i + 4)
+      {
+      case 17:
+        return 2;
+
+      default:
+        return 1;
+      }
+    }
 
   }
 
-  namespace test_rvalue_references
+  namespace test_template_argument_deduction_for_class_templates
   {
 
-    template < int N >
-    struct answer
+    template <typename T1, typename T2>
+    struct pair
     {
-      static constexpr int value = N;
-    };
+      pair (T1 p1, T2 p2)
+        : m1 {p1},
+          m2 {p2}
+      {}
 
-    answer<1> f(int&)       { return answer<1>(); }
-    answer<2> f(const int&) { return answer<2>(); }
-    answer<3> f(int&&)      { return answer<3>(); }
+      T1 m1;
+      T2 m2;
+    };
 
-    void
-    test()
+    void f()
     {
-      int i = 0;
-      const int c = 0;
-      static_assert(decltype(f(i))::value == 1, "");
-      static_assert(decltype(f(c))::value == 2, "");
-      static_assert(decltype(f(0))::value == 3, "");
+      [[maybe_unused]] auto p = pair{13, 42u};
     }
 
   }
 
-  namespace test_uniform_initialization
+  namespace test_non_type_auto_template_parameters
   {
 
-    struct test
-    {
-      static const int zero {};
-      static const int one {1};
-    };
+    template <auto n>
+    struct B
+    {};
 
-    static_assert(test::zero == 0, "");
-    static_assert(test::one == 1, "");
+    B<5> b1;
+    B<'a'> b2;
 
   }
 
-  namespace test_lambdas
+  namespace test_structured_bindings
   {
 
-    void
-    test1()
+    int arr[2] = { 1, 2 };
+    std::pair<int, int> pr = { 1, 2 };
+
+    auto f1() -> int(&)[2]
     {
-      auto lambda1 = [](){};
-      auto lambda2 = lambda1;
-      lambda1();
-      lambda2();
+      return arr;
     }
 
-    int
-    test2()
+    auto f2() -> std::pair<int, int>&
     {
-      auto a = [](int i, int j){ return i + j; }(1, 2);
-      auto b = []() -> int { return '0'; }();
-      auto c = [=](){ return a + b; }();
-      auto d = [&](){ return c; }();
-      auto e = [a, &b](int x) mutable {
-        const auto identity = [](int y){ return y; };
-        for (auto i = 0; i < a; ++i)
-          a += b--;
-        return x + identity(a + b);
-      }(0);
-      return a + b + c + d + e;
+      return pr;
     }
 
-    int
-    test3()
+    struct S
     {
-      const auto nullary = [](){ return 0; };
-      const auto unary = [](int x){ return x; };
-      using nullary_t = decltype(nullary);
-      using unary_t = decltype(unary);
-      const auto higher1st = [](nullary_t f){ return f(); };
-      const auto higher2nd = [unary](nullary_t f1){
-        return [unary, f1](unary_t f2){ return f2(unary(f1())); };
-      };
-      return higher1st(nullary) + higher2nd(nullary)(unary);
+      int x1 : 2;
+      volatile double y1;
+    };
+
+    S f3()
+    {
+      return {};
     }
 
+    auto [ x1, y1 ] = f1();
+    auto& [ xr1, yr1 ] = f1();
+    auto [ x2, y2 ] = f2();
+    auto& [ xr2, yr2 ] = f2();
+    const auto [ x3, y3 ] = f3();
+
   }
 
-  namespace test_variadic_templates
+  namespace test_exception_spec_type_system
   {
 
-    template <int...>
-    struct sum;
+    struct Good {};
+    struct Bad {};
 
-    template <int N0, int... N1toN>
-    struct sum<N0, N1toN...>
-    {
-      static constexpr auto value = N0 + sum<N1toN...>::value;
-    };
+    void g1() noexcept;
+    void g2();
 
-    template <>
-    struct sum<>
-    {
-      static constexpr auto value = 0;
-    };
+    template<typename T>
+    Bad
+    f(T*, T*);
 
-    static_assert(sum<>::value == 0, "");
-    static_assert(sum<1>::value == 1, "");
-    static_assert(sum<23>::value == 23, "");
-    static_assert(sum<1, 2>::value == 3, "");
-    static_assert(sum<5, 5, 11>::value == 21, "");
-    static_assert(sum<2, 3, 5, 7, 11, 13>::value == 41, "");
+    template<typename T1, typename T2>
+    Good
+    f(T1*, T2*);
+
+    static_assert (std::is_same_v<Good, decltype(f(g1, g2))>);
 
   }
 
-  // http://stackoverflow.com/questions/13728184/template-aliases-and-sfinae
-  // Clang 3.1 fails with headers of libstd++ 4.8.3 when using std::function
-  // because of this.
-  namespace test_template_alias_sfinae
+  namespace test_inline_variables
   {
 
-    struct foo {};
-
-    template<typename T>
-    using member = typename T::member_type;
-
-    template<typename T>
-    void func(...) {}
+    template<class T> void f(T)
+    {}
 
-    template<typename T>
-    void func(member<T>*) {}
+    template<class T> inline T g(T)
+    {
+      return T{};
+    }
 
-    void test();
+    template<> inline void f<>(int)
+    {}
 
-    void test() { func<foo>(0); }
+    template<> int g<>(int)
+    {
+      return 5;
+    }
 
   }
 
-}  // namespace cxx11
+}  // namespace cxx17
 
-#endif  // __cplusplus >= 201103L
+#endif  // __cplusplus < 201703L && !defined _MSC_VER
 
 
 
@@ -6902,19 +8396,19 @@ ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
 ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
 ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
-  if test x$ax_cxx_compile_cxx11_required = xtrue; then
+  if test x$ax_cxx_compile_cxx17_required = xtrue; then
     if test x$ac_success = xno; then
-      as_fn_error $? "*** A compiler with support for C++11 language features is required." "$LINENO" 5
+      as_fn_error $? "*** A compiler with support for C++17 language features is required." "$LINENO" 5
     fi
   fi
   if test x$ac_success = xno; then
-    HAVE_CXX11=0
-    { $as_echo "$as_me:${as_lineno-$LINENO}: No compiler with C++11 support was found" >&5
-$as_echo "$as_me: No compiler with C++11 support was found" >&6;}
+    HAVE_CXX17=0
+    { $as_echo "$as_me:${as_lineno-$LINENO}: No compiler with C++17 support was found" >&5
+$as_echo "$as_me: No compiler with C++17 support was found" >&6;}
   else
-    HAVE_CXX11=1
+    HAVE_CXX17=1
 
-$as_echo "#define HAVE_CXX11 1" >>confdefs.h
+$as_echo "#define HAVE_CXX17 1" >>confdefs.h
 
   fi
 
diff --git a/gdbsupport/configure.ac b/gdbsupport/configure.ac
index 2cb382bd4ec..a0986fab9cd 100644
--- a/gdbsupport/configure.ac
+++ b/gdbsupport/configure.ac
@@ -41,9 +41,9 @@ AC_PROG_RANLIB
 AC_USE_SYSTEM_EXTENSIONS
 ACX_LARGEFILE
 
-# We require a C++11 compiler.  Check if one is available, and if
+# We require a C++17 compiler.  Check if one is available, and if
 # necessary, set CXX_DIALECT to some -std=xxx switch.
-AX_CXX_COMPILE_STDCXX(11, , mandatory)
+AX_CXX_COMPILE_STDCXX(17, , mandatory)
 
 dnl Set up for gettext.
 ZW_GNU_GETTEXT_SISTER_DIR
-- 
2.34.1


^ permalink raw reply	[flat|nested] 39+ messages in thread

* [PATCH 03/11] gdb: Use C++17's std::make_unique instead of gdb::make_unique
  2023-10-13 14:44 [PATCH 00/11] GDB: Require C++17 Lancelot Six
  2023-10-13 14:44 ` [PATCH 01/11] gdb/ax_cxx_compile_stdcxx.m4: upgrade Lancelot Six
  2023-10-13 14:44 ` [PATCH 02/11] gdb/gdbsupport/gdbserver: Require c++17 Lancelot Six
@ 2023-10-13 14:44 ` Lancelot Six
  2023-10-16 19:14   ` Tom Tromey
  2023-10-13 14:44 ` [PATCH 04/11] gdb: Replace gdb::optional with std::optional Lancelot Six
                   ` (8 subsequent siblings)
  11 siblings, 1 reply; 39+ messages in thread
From: Lancelot Six @ 2023-10-13 14:44 UTC (permalink / raw)
  To: gdb-patches; +Cc: Lancelot Six

gdb::make_unique is a wrapper around std::make_unique when compiled with
C++17.  Now that C++17 is required, use std::make_unique directly in the
codebase, and remove gdb::make_unique.

Change-Id: I80b615e46e4b7c097f09d78e579a9bdce00254ab
---
 gdb/addrmap.c                          |  3 ++-
 gdb/break-catch-load.c                 |  3 ++-
 gdb/compile/compile-c-support.c        |  3 ++-
 gdb/cp-name-parser.y                   |  3 ++-
 gdb/cp-support.c                       |  3 ++-
 gdb/dwarf2/frame.c                     |  3 ++-
 gdb/dwarf2/read-debug-names.c          |  3 ++-
 gdb/dwarf2/read-gdb-index.c            |  3 ++-
 gdb/dwarf2/read.c                      |  3 ++-
 gdb/gdb_bfd.c                          |  2 +-
 gdb/gdbtypes.c                         |  3 ++-
 gdb/mi/mi-main.c                       |  3 ++-
 gdb/mi/mi-out.c                        |  7 ++++---
 gdb/nat/linux-btrace.c                 |  5 +++--
 gdb/python/py-mi.c                     |  3 ++-
 gdb/python/py-varobj.c                 |  3 ++-
 gdb/ui-out.c                           |  4 ++--
 gdb/unittests/parallel-for-selftests.c |  5 +++--
 gdb/varobj.c                           |  3 ++-
 gdbsupport/gdb_unique_ptr.h            | 13 -------------
 20 files changed, 41 insertions(+), 37 deletions(-)

diff --git a/gdb/addrmap.c b/gdb/addrmap.c
index d16775d49d4..757947abaf4 100644
--- a/gdb/addrmap.c
+++ b/gdb/addrmap.c
@@ -21,6 +21,7 @@
 #include "gdbsupport/gdb_obstack.h"
 #include "addrmap.h"
 #include "gdbsupport/selftest.h"
+#include <memory>
 
 /* Make sure splay trees can actually hold the values we want to
    store in them.  */
@@ -428,7 +429,7 @@ test_addrmap ()
 
   /* Create mutable addrmap.  */
   auto_obstack temp_obstack;
-  auto map = gdb::make_unique<struct addrmap_mutable> ();
+  auto map = std::make_unique<struct addrmap_mutable> ();
   SELF_CHECK (map != nullptr);
 
   /* Check initial state.  */
diff --git a/gdb/break-catch-load.c b/gdb/break-catch-load.c
index 94d8b420d32..cac914d3fac 100644
--- a/gdb/break-catch-load.c
+++ b/gdb/break-catch-load.c
@@ -28,6 +28,7 @@
 #include "solist.h"
 #include "target.h"
 #include "valprint.h"
+#include <memory>
 
 /* An instance of this type is used to represent an solib catchpoint.
    A breakpoint is really of this type iff its ops pointer points to
@@ -230,7 +231,7 @@ add_solib_catchpoint (const char *arg, bool is_load, bool is_temp, bool enabled)
   if (*arg == '\0')
     arg = nullptr;
 
-  auto c = gdb::make_unique<solib_catchpoint> (gdbarch, is_temp, nullptr,
+  auto c = std::make_unique<solib_catchpoint> (gdbarch, is_temp, nullptr,
 					       is_load, arg);
 
   c->enable_state = enabled ? bp_enabled : bp_disabled;
diff --git a/gdb/compile/compile-c-support.c b/gdb/compile/compile-c-support.c
index 53b7285b366..20a7bb4e0d4 100644
--- a/gdb/compile/compile-c-support.c
+++ b/gdb/compile/compile-c-support.c
@@ -30,6 +30,7 @@
 #include "gdbsupport/gdb-dlfcn.h"
 #include "gdbsupport/preprocessor.h"
 #include "gdbarch.h"
+#include <memory>
 
 /* See compile-internal.h.  */
 
@@ -118,7 +119,7 @@ get_compile_context (const char *fe_libcc, const char *fe_context,
     error (_("The loaded version of GCC does not support the required version "
 	     "of the API."));
 
-  return gdb::make_unique<INSTTYPE> (context);
+  return std::make_unique<INSTTYPE> (context);
 }
 
 /* A C-language implementation of get_compile_context.  */
diff --git a/gdb/cp-name-parser.y b/gdb/cp-name-parser.y
index 324166a03ff..061882363be 100644
--- a/gdb/cp-name-parser.y
+++ b/gdb/cp-name-parser.y
@@ -45,6 +45,7 @@
 #include "cp-support.h"
 #include "c-support.h"
 #include "parser-defs.h"
+#include <memory>
 
 #define GDB_YY_REMAP_PREFIX cpname
 #include "yy-remap.h"
@@ -2038,7 +2039,7 @@ cp_demangled_name_to_comp (const char *demangled_name,
 
   state.demangle_info = allocate_info ();
 
-  auto result = gdb::make_unique<demangle_parse_info> ();
+  auto result = std::make_unique<demangle_parse_info> ();
   result->info = state.demangle_info;
 
   if (yyparse (&state))
diff --git a/gdb/cp-support.c b/gdb/cp-support.c
index e02e859b99a..579f09303c8 100644
--- a/gdb/cp-support.c
+++ b/gdb/cp-support.c
@@ -44,6 +44,7 @@
 #include "run-on-main-thread.h"
 #include "typeprint.h"
 #include "inferior.h"
+#include <memory>
 
 #define d_left(dc) (dc)->u.s_binary.left
 #define d_right(dc) (dc)->u.s_binary.right
@@ -675,7 +676,7 @@ mangled_name_to_comp (const char *mangled_name, int options,
 					      options, memory);
       if (ret)
 	{
-	  auto info = gdb::make_unique<demangle_parse_info> ();
+	  auto info = std::make_unique<demangle_parse_info> ();
 	  info->tree = ret;
 	  *demangled_p = NULL;
 	  return info;
diff --git a/gdb/dwarf2/frame.c b/gdb/dwarf2/frame.c
index abc8d613482..6f52a1abe0e 100644
--- a/gdb/dwarf2/frame.c
+++ b/gdb/dwarf2/frame.c
@@ -49,6 +49,7 @@
 #include <unordered_map>
 
 #include <algorithm>
+#include <memory>
 
 struct comp_unit;
 
@@ -2126,7 +2127,7 @@ dwarf2_build_frame_info (struct objfile *objfile)
   struct gdbarch *gdbarch = objfile->arch ();
 
   /* Build a minimal decoding of the DWARF2 compilation unit.  */
-  auto unit = gdb::make_unique<comp_unit> (objfile);
+  auto unit = std::make_unique<comp_unit> (objfile);
 
   if (objfile->separate_debug_objfile_backlink == NULL)
     {
diff --git a/gdb/dwarf2/read-debug-names.c b/gdb/dwarf2/read-debug-names.c
index 2e5067efb3d..535028b1597 100644
--- a/gdb/dwarf2/read-debug-names.c
+++ b/gdb/dwarf2/read-debug-names.c
@@ -26,6 +26,7 @@
 #include "mapped-index.h"
 #include "read.h"
 #include "stringify.h"
+#include <memory>
 
 /* A description of the mapped .debug_names.
    Uninitialized map has CU_COUNT 0.  */
@@ -462,7 +463,7 @@ create_cus_from_debug_names (dwarf2_per_bfd *per_bfd,
 bool
 dwarf2_read_debug_names (dwarf2_per_objfile *per_objfile)
 {
-  auto map = gdb::make_unique<mapped_debug_names> ();
+  auto map = std::make_unique<mapped_debug_names> ();
   mapped_debug_names dwz_map;
   struct objfile *objfile = per_objfile->objfile;
   dwarf2_per_bfd *per_bfd = per_objfile->per_bfd;
diff --git a/gdb/dwarf2/read-gdb-index.c b/gdb/dwarf2/read-gdb-index.c
index b96eaa96e23..da3bf0633fc 100644
--- a/gdb/dwarf2/read-gdb-index.c
+++ b/gdb/dwarf2/read-gdb-index.c
@@ -27,6 +27,7 @@
 #include "gdbsupport/gdb-checked-static-cast.h"
 #include "mapped-index.h"
 #include "read.h"
+#include <memory>
 
 /* When true, do not reject deprecated .gdb_index sections.  */
 static bool use_deprecated_index_sections = false;
@@ -828,7 +829,7 @@ dwarf2_read_gdb_index
   if (main_index_contents.empty ())
     return 0;
 
-  auto map = gdb::make_unique<mapped_gdb_index> ();
+  auto map = std::make_unique<mapped_gdb_index> ();
   if (!read_gdb_index_from_buffer (objfile_name (objfile),
 				   use_deprecated_index_sections,
 				   main_index_contents, map.get (), &cu_list,
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index d4aec19d31d..5bbf208ed5a 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -95,6 +95,7 @@
 #include "split-name.h"
 #include "gdbsupport/parallel-for.h"
 #include "gdbsupport/thread-pool.h"
+#include <memory>
 
 /* When == 1, print basic high level tracing messages.
    When > 1, be more verbose.
@@ -4535,7 +4536,7 @@ allocate_type_unit_groups_table ()
 static std::unique_ptr<type_unit_group>
 create_type_unit_group (struct dwarf2_cu *cu, sect_offset line_offset_struct)
 {
-  auto tu_group = gdb::make_unique<type_unit_group> ();
+  auto tu_group = std::make_unique<type_unit_group> ();
 
   tu_group->hash.dwo_unit = cu->dwo_unit;
   tu_group->hash.line_sect_off = line_offset_struct;
diff --git a/gdb/gdb_bfd.c b/gdb/gdb_bfd.c
index 217753cf914..fc0c5bab6ed 100644
--- a/gdb/gdb_bfd.c
+++ b/gdb/gdb_bfd.c
@@ -302,7 +302,7 @@ gdb_bfd_open_from_target_memory (CORE_ADDR addr, ULONGEST size,
 				 const char *target)
 {
   std::unique_ptr<target_buffer> buffer
-    = gdb::make_unique<target_buffer> (addr, size);
+    = std::make_unique<target_buffer> (addr, size);
 
   return gdb_bfd_openr_iovec (buffer->filename (), target,
 			      [&] (bfd *nbfd)
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index 7011fddd695..534b7a2bfa2 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -45,6 +45,7 @@
 #include "gmp-utils.h"
 #include "rust-lang.h"
 #include "ada-lang.h"
+#include <memory>
 
 /* The value of an invalid conversion badness.  */
 #define INVALID_CONVERSION 100
@@ -5833,7 +5834,7 @@ static const struct registry<objfile>::key<fixed_point_type_storage>
 void
 allocate_fixed_point_type_info (struct type *type)
 {
-  auto up = gdb::make_unique<fixed_point_type_info> ();
+  auto up = std::make_unique<fixed_point_type_info> ();
   fixed_point_type_info *info;
 
   if (type->is_objfile_owned ())
diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c
index 944c9116731..d750371f917 100644
--- a/gdb/mi/mi-main.c
+++ b/gdb/mi/mi-main.c
@@ -63,6 +63,7 @@
 #include <algorithm>
 #include <set>
 #include <map>
+#include <memory>
 
 enum
   {
@@ -1933,7 +1934,7 @@ mi_execute_command (const char *cmd, int from_tty)
     = gdb::checked_static_cast<mi_interp *> (command_interp ());
   try
     {
-      command = gdb::make_unique<mi_parse> (cmd, &token);
+      command = std::make_unique<mi_parse> (cmd, &token);
     }
   catch (const gdb_exception &exception)
     {
diff --git a/gdb/mi/mi-out.c b/gdb/mi/mi-out.c
index bbd21287b28..95f8069674c 100644
--- a/gdb/mi/mi-out.c
+++ b/gdb/mi/mi-out.c
@@ -23,6 +23,7 @@
 #include "mi-out.h"
 
 #include <vector>
+#include <memory>
 
 #include "interps.h"
 #include "ui-out.h"
@@ -340,13 +341,13 @@ std::unique_ptr<mi_ui_out>
 mi_out_new (const char *mi_version)
 {
   if (streq (mi_version, INTERP_MI4) ||  streq (mi_version, INTERP_MI))
-    return gdb::make_unique<mi_ui_out> (4);
+    return std::make_unique<mi_ui_out> (4);
 
   if (streq (mi_version, INTERP_MI3))
-    return gdb::make_unique<mi_ui_out> (3);
+    return std::make_unique<mi_ui_out> (3);
 
   if (streq (mi_version, INTERP_MI2))
-    return gdb::make_unique<mi_ui_out> (2);
+    return std::make_unique<mi_ui_out> (2);
 
   return nullptr;
 }
diff --git a/gdb/nat/linux-btrace.c b/gdb/nat/linux-btrace.c
index 3c217daa488..aa02f193399 100644
--- a/gdb/nat/linux-btrace.c
+++ b/gdb/nat/linux-btrace.c
@@ -27,6 +27,7 @@
 #include "gdbsupport/filestuff.h"
 #include "gdbsupport/scoped_fd.h"
 #include "gdbsupport/scoped_mmap.h"
+#include <memory>
 
 #include <inttypes.h>
 
@@ -468,7 +469,7 @@ linux_enable_bts (ptid_t ptid, const struct btrace_config_bts *conf)
     error (_("BTS support has been disabled for the target cpu."));
 
   std::unique_ptr<linux_btrace_target_info> tinfo
-    { gdb::make_unique<linux_btrace_target_info> (ptid) };
+    { std::make_unique<linux_btrace_target_info> (ptid) };
 
   tinfo->conf.format = BTRACE_FORMAT_BTS;
 
@@ -617,7 +618,7 @@ linux_enable_pt (ptid_t ptid, const struct btrace_config_pt *conf)
     pid = ptid.pid ();
 
   std::unique_ptr<linux_btrace_target_info> tinfo
-    { gdb::make_unique<linux_btrace_target_info> (ptid) };
+    { std::make_unique<linux_btrace_target_info> (ptid) };
 
   tinfo->conf.format = BTRACE_FORMAT_PT;
 
diff --git a/gdb/python/py-mi.c b/gdb/python/py-mi.c
index a7b4f4fa3cf..a43fac98c43 100644
--- a/gdb/python/py-mi.c
+++ b/gdb/python/py-mi.c
@@ -27,6 +27,7 @@
 #include "mi/mi-parse.h"
 #include "mi/mi-console.h"
 #include "mi/mi-interp.h"
+#include <memory>
 
 /* A ui_out subclass that creates a Python object based on the data
    that is passed in.  */
@@ -290,7 +291,7 @@ gdbpy_execute_mi_command (PyObject *self, PyObject *args, PyObject *kw)
   try
     {
       scoped_restore save_uiout = make_scoped_restore (&current_uiout, &uiout);
-      auto parser = gdb::make_unique<mi_parse> (std::move (mi_command),
+      auto parser = std::make_unique<mi_parse> (std::move (mi_command),
 						std::move (arg_strings));
       mi_execute_command (parser.get ());
     }
diff --git a/gdb/python/py-varobj.c b/gdb/python/py-varobj.c
index 98603cec009..f72f1400d1d 100644
--- a/gdb/python/py-varobj.c
+++ b/gdb/python/py-varobj.c
@@ -18,6 +18,7 @@
 #include "varobj.h"
 #include "varobj-iter.h"
 #include "valprint.h"
+#include <memory>
 
 /* A dynamic varobj iterator "class" for python pretty-printed
    varobjs.  This inherits struct varobj_iter.  */
@@ -170,5 +171,5 @@ py_varobj_get_iterator (struct varobj *var, PyObject *printer,
       error (_("Could not get children iterator"));
     }
 
-  return gdb::make_unique<py_varobj_iter> (var, std::move (iter), opts);
+  return std::make_unique<py_varobj_iter> (var, std::move (iter), opts);
 }
diff --git a/gdb/ui-out.c b/gdb/ui-out.c
index defa8f9dfa4..e8653c6c127 100644
--- a/gdb/ui-out.c
+++ b/gdb/ui-out.c
@@ -236,7 +236,7 @@ void ui_out_table::append_header (int width, ui_align alignment,
     internal_error (_("table header must be specified after table_begin and "
 		      "before table_body."));
 
-  auto header = gdb::make_unique<ui_out_hdr> (m_headers.size () + 1,
+  auto header = std::make_unique<ui_out_hdr> (m_headers.size () + 1,
 					      width, alignment,
 					      col_name, col_hdr);
 
@@ -328,7 +328,7 @@ ui_out::current_level () const
 void
 ui_out::push_level (ui_out_type type)
 {
-  auto level = gdb::make_unique<ui_out_level> (type);
+  auto level = std::make_unique<ui_out_level> (type);
 
   m_levels.push_back (std::move (level));
 }
diff --git a/gdb/unittests/parallel-for-selftests.c b/gdb/unittests/parallel-for-selftests.c
index 1ad7eaa701c..5e2f8b5f735 100644
--- a/gdb/unittests/parallel-for-selftests.c
+++ b/gdb/unittests/parallel-for-selftests.c
@@ -27,6 +27,7 @@
 #include "defs.h"
 #include "gdbsupport/selftest.h"
 #include "gdbsupport/parallel-for.h"
+#include <memory>
 
 #if CXX_STD_THREAD
 
@@ -160,7 +161,7 @@ TEST (int n_threads)
 	      {
 		if (start == end)
 		  any_empty_tasks = true;
-		return gdb::make_unique<int> (end - start);
+		return std::make_unique<int> (end - start);
 	      });
   SELF_CHECK (!any_empty_tasks);
   SELF_CHECK (std::all_of (intresults.begin (),
@@ -178,7 +179,7 @@ TEST (int n_threads)
 	      {
 		if (start == end)
 		  any_empty_tasks = true;
-		return gdb::make_unique<int> (end - start);
+		return std::make_unique<int> (end - start);
 	      },
 	    task_size_one);
   SELF_CHECK (!any_empty_tasks);
diff --git a/gdb/varobj.c b/gdb/varobj.c
index a4fcbffc311..5d1ae343fca 100644
--- a/gdb/varobj.c
+++ b/gdb/varobj.c
@@ -33,6 +33,7 @@
 #include "gdbarch.h"
 #include <algorithm>
 #include "observable.h"
+#include <memory>
 
 #if HAVE_PYTHON
 #include "python/python.h"
@@ -259,7 +260,7 @@ varobj_create (const char *objname,
 	       const char *expression, CORE_ADDR frame, enum varobj_type type)
 {
   /* Fill out a varobj structure for the (root) variable being constructed.  */
-  auto var = gdb::make_unique<varobj> (new varobj_root);
+  auto var = std::make_unique<varobj> (new varobj_root);
 
   if (expression != NULL)
     {
diff --git a/gdbsupport/gdb_unique_ptr.h b/gdbsupport/gdb_unique_ptr.h
index 2b6c0ce3d53..3bef6ff34d6 100644
--- a/gdbsupport/gdb_unique_ptr.h
+++ b/gdbsupport/gdb_unique_ptr.h
@@ -56,19 +56,6 @@ struct noop_deleter
   void operator() (T *ptr) const { }
 };
 
-/* Create simple std::unique_ptr<T> objects.  */
-
-template<typename T, typename... Arg>
-std::unique_ptr<T>
-make_unique (Arg &&...args)
-{
-#if __cplusplus >= 201402L
-  return std::make_unique<T> (std::forward<Arg> (args)...);
-#else
-  return std::unique_ptr<T> (new T (std::forward<Arg> (args)...));
-#endif /* __cplusplus < 201402L */
-}
-
 } /* namespace gdb */
 
 /* Dup STR and return a unique_xmalloc_ptr for the result.  */
-- 
2.34.1


^ permalink raw reply	[flat|nested] 39+ messages in thread

* [PATCH 04/11] gdb: Replace gdb::optional with std::optional
  2023-10-13 14:44 [PATCH 00/11] GDB: Require C++17 Lancelot Six
                   ` (2 preceding siblings ...)
  2023-10-13 14:44 ` [PATCH 03/11] gdb: Use C++17's std::make_unique instead of gdb::make_unique Lancelot Six
@ 2023-10-13 14:44 ` Lancelot Six
  2023-10-13 14:44 ` [PATCH 05/11] gdbsupport: remove gdb::optional Lancelot Six
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 39+ messages in thread
From: Lancelot Six @ 2023-10-13 14:44 UTC (permalink / raw)
  To: gdb-patches; +Cc: Lancelot Six

Since GDB now requires C++17, we don't need the internally maintained
gdb::optional implementation.  This patch does the following replacing:
  - gdb::optional -> std::optional
  - gdb::in_place -> std::in_place
  - #include "gdbsupport/gdb_optional.h" -> #include <optional>

This change has mostly been done automatically.  One exception is
gdbsupport/thread-pool.* which did not use the gdb:: prefix as it
already lives in the gdb namespace.

Change-Id: I19a92fa03e89637bab136c72e34fd351524f65e9
---
 gdb/aarch64-linux-tdep.c           | 10 +++++-----
 gdb/ada-lang.c                     |  6 +++---
 gdb/ada-lex.l                      |  2 +-
 gdb/ada-valprint.c                 |  4 ++--
 gdb/amd-dbgapi-target.c            |  4 ++--
 gdb/annotate.c                     |  2 +-
 gdb/arm-fbsd-tdep.c                |  6 +++---
 gdb/arm-fbsd-tdep.h                |  2 +-
 gdb/arm-linux-tdep.c               |  2 +-
 gdb/arm-tdep.c                     |  4 ++--
 gdb/auto-load.c                    |  2 +-
 gdb/auxv.c                         | 10 +++++-----
 gdb/auxv.h                         |  4 ++--
 gdb/avr-tdep.c                     |  2 +-
 gdb/breakpoint.c                   | 19 ++++++++++---------
 gdb/buildsym.c                     |  2 +-
 gdb/cli/cli-cmds.c                 |  6 +++---
 gdb/cli/cli-cmds.h                 |  4 ++--
 gdb/cli/cli-decode.c               |  4 ++--
 gdb/cli/cli-decode.h               |  2 +-
 gdb/cli/cli-option.c               | 14 +++++++-------
 gdb/cli/cli-option.h               |  2 +-
 gdb/command.h                      |  2 +-
 gdb/compile/compile.c              |  4 ++--
 gdb/darwin-nat.c                   |  2 +-
 gdb/debuginfod-support.c           | 10 +++++-----
 gdb/disasm.c                       | 14 +++++++-------
 gdb/disasm.h                       |  2 +-
 gdb/dwarf2/attribute.h             |  2 +-
 gdb/dwarf2/cu.h                    |  8 ++++----
 gdb/dwarf2/die.h                   |  4 ++--
 gdb/dwarf2/index-cache.h           |  2 +-
 gdb/dwarf2/index-write.c           |  4 ++--
 gdb/dwarf2/line-header.c           |  4 ++--
 gdb/dwarf2/macro.c                 |  4 ++--
 gdb/dwarf2/macro.h                 |  2 +-
 gdb/dwarf2/read-gdb-index.c        |  4 ++--
 gdb/dwarf2/read.c                  | 24 ++++++++++++------------
 gdb/dwarf2/read.h                  |  2 +-
 gdb/eval.c                         |  2 +-
 gdb/event-top.c                    |  2 +-
 gdb/exceptions.c                   |  4 ++--
 gdb/extension-priv.h               |  6 +++---
 gdb/extension.c                    | 12 ++++++------
 gdb/extension.h                    |  8 ++++----
 gdb/f-lang.c                       |  2 +-
 gdb/fbsd-nat.c                     |  6 +++---
 gdb/fbsd-nat.h                     |  4 ++--
 gdb/fbsd-tdep.c                    |  8 ++++----
 gdb/gdbthread.h                    |  8 ++++----
 gdb/gdbtypes.c                     | 18 +++++++++---------
 gdb/gdbtypes.h                     |  8 ++++----
 gdb/guile/scm-ports.c              |  4 ++--
 gdb/ia64-tdep.c                    |  4 ++--
 gdb/inf-child.c                    |  2 +-
 gdb/inf-child.h                    |  2 +-
 gdb/infcmd.c                       |  4 ++--
 gdb/inferior.c                     |  4 ++--
 gdb/inferior.h                     |  2 +-
 gdb/inflow.c                       |  4 ++--
 gdb/infrun.c                       | 12 ++++++------
 gdb/interps.c                      |  2 +-
 gdb/interps.h                      |  4 ++--
 gdb/jit.c                          |  2 +-
 gdb/linux-nat.c                    |  4 ++--
 gdb/linux-nat.h                    |  2 +-
 gdb/linux-tdep.c                   | 18 +++++++++---------
 gdb/linux-tdep.h                   |  4 ++--
 gdb/linux-thread-db.c              |  2 +-
 gdb/main.c                         |  4 ++--
 gdb/mi/mi-cmd-stack.c              |  4 ++--
 gdb/mi/mi-cmd-var.c                |  2 +-
 gdb/mi/mi-cmds.c                   |  2 +-
 gdb/mi/mi-cmds.h                   |  8 ++++----
 gdb/mi/mi-interp.c                 |  2 +-
 gdb/mi/mi-interp.h                 |  2 +-
 gdb/mi/mi-main.c                   | 12 ++++++------
 gdb/nat/linux-osdata.c             |  8 ++++----
 gdb/nat/windows-nat.c              |  6 +++---
 gdb/nat/windows-nat.h              |  4 ++--
 gdb/observable.h                   |  2 +-
 gdb/osdata.c                       |  2 +-
 gdb/parse.c                        |  4 ++--
 gdb/ppc-linux-nat.c                |  4 ++--
 gdb/ppc-linux-tdep.c               |  2 +-
 gdb/ppc-tdep.h                     |  2 +-
 gdb/printcmd.c                     |  6 +++---
 gdb/probe.c                        | 22 +++++++++++-----------
 gdb/procfs.c                       |  2 +-
 gdb/psymtab.c                      |  2 +-
 gdb/psymtab.h                      |  2 +-
 gdb/python/py-disasm.c             | 22 +++++++++++-----------
 gdb/python/py-framefilter.c        | 10 +++++-----
 gdb/python/py-inferior.c           |  2 +-
 gdb/python/py-mi.c                 |  2 +-
 gdb/python/py-utils.c              |  4 ++--
 gdb/python/python-internal.h       |  4 ++--
 gdb/python/python.c                |  8 ++++----
 gdb/ravenscar-thread.c             |  4 ++--
 gdb/record-btrace.c                |  8 ++++----
 gdb/regcache.c                     |  4 ++--
 gdb/remote.c                       | 16 ++++++++--------
 gdb/riscv-tdep.c                   |  2 +-
 gdb/s390-linux-tdep.c              |  2 +-
 gdb/skip.c                         |  4 ++--
 gdb/solib-aix.c                    | 14 +++++++-------
 gdb/solib-dsbt.c                   |  2 +-
 gdb/solib-svr4.c                   | 16 ++++++++--------
 gdb/solib-target.c                 |  2 +-
 gdb/source-cache.c                 |  2 +-
 gdb/stack.c                        | 16 ++++++++--------
 gdb/stack.h                        |  2 +-
 gdb/symfile.c                      |  2 +-
 gdb/symtab.c                       | 24 ++++++++++++------------
 gdb/symtab.h                       | 24 ++++++++++++------------
 gdb/target.c                       | 16 ++++++++--------
 gdb/target.h                       | 10 +++++-----
 gdb/thread.c                       | 14 +++++++-------
 gdb/tracefile-tfile.c              |  2 +-
 gdb/tracepoint.c                   |  2 +-
 gdb/tui/tui-disasm.c               |  2 +-
 gdb/tui/tui-layout.c               |  2 +-
 gdb/unittests/optional-selftests.c |  4 ++--
 gdb/utils.c                        |  6 +++---
 gdb/valarith.c                     |  4 ++--
 gdb/valops.c                       |  6 +++---
 gdb/value.c                        |  2 +-
 gdb/value.h                        |  4 ++--
 gdb/windows-nat.c                  | 10 +++++-----
 gdb/xml-support.c                  |  4 ++--
 gdb/xml-support.h                  |  6 +++---
 gdb/xml-syscall.c                  |  2 +-
 gdb/xml-tdesc.c                    | 12 ++++++------
 gdb/xml-tdesc.h                    |  4 ++--
 gdbserver/linux-aarch64-low.cc     |  4 ++--
 gdbserver/regcache.cc              |  4 ++--
 gdbserver/regcache.h               |  2 +-
 gdbserver/win32-low.cc             |  2 +-
 gdbsupport/common-debug.h          |  4 ++--
 gdbsupport/event-loop.cc           |  6 +++---
 gdbsupport/filestuff.cc            |  2 +-
 gdbsupport/filestuff.h             |  2 +-
 gdbsupport/forward-scope-exit.h    |  6 +++---
 gdbsupport/range-chain.h           |  2 +-
 gdbsupport/scoped_ignore_sigttou.h |  2 +-
 gdbsupport/thread-pool.cc          |  2 +-
 gdbsupport/thread-pool.h           |  4 ++--
 147 files changed, 413 insertions(+), 412 deletions(-)

diff --git a/gdb/aarch64-linux-tdep.c b/gdb/aarch64-linux-tdep.c
index f1fcce9b9eb..cd99b33fed2 100644
--- a/gdb/aarch64-linux-tdep.c
+++ b/gdb/aarch64-linux-tdep.c
@@ -1609,7 +1609,7 @@ static const struct target_desc *
 aarch64_linux_core_read_description (struct gdbarch *gdbarch,
 				     struct target_ops *target, bfd *abfd)
 {
-  gdb::optional<gdb::byte_vector> auxv = target_read_auxv_raw (target);
+  std::optional<gdb::byte_vector> auxv = target_read_auxv_raw (target);
   CORE_ADDR hwcap = linux_get_hwcap (auxv, target, gdbarch);
   CORE_ADDR hwcap2 = linux_get_hwcap2 (auxv, target, gdbarch);
 
@@ -2427,7 +2427,7 @@ aarch64_linux_gcc_target_options (struct gdbarch *gdbarch)
 
    Return the allocation tag if successful and nullopt otherwise.  */
 
-static gdb::optional<CORE_ADDR>
+static std::optional<CORE_ADDR>
 aarch64_mte_get_atag (CORE_ADDR address)
 {
   gdb::byte_vector tags;
@@ -2481,7 +2481,7 @@ aarch64_linux_memtag_matches_p (struct gdbarch *gdbarch,
   CORE_ADDR addr = value_as_address (address);
 
   /* Fetch the allocation tag for ADDRESS.  */
-  gdb::optional<CORE_ADDR> atag
+  std::optional<CORE_ADDR> atag
     = aarch64_mte_get_atag (gdbarch_remove_non_address_bits (gdbarch, addr));
 
   if (!atag.has_value ())
@@ -2579,7 +2579,7 @@ aarch64_linux_get_memtag (struct gdbarch *gdbarch, struct value *address,
 
       /* Remove the top byte.  */
       addr = gdbarch_remove_non_address_bits (gdbarch, addr);
-      gdb::optional<CORE_ADDR> atag = aarch64_mte_get_atag (addr);
+      std::optional<CORE_ADDR> atag = aarch64_mte_get_atag (addr);
 
       if (!atag.has_value ())
 	return nullptr;
@@ -2651,7 +2651,7 @@ aarch64_linux_report_signal_info (struct gdbarch *gdbarch,
       uiout->field_core_addr ("fault-addr", gdbarch, fault_addr);
       uiout->text ("\n");
 
-      gdb::optional<CORE_ADDR> atag
+      std::optional<CORE_ADDR> atag
 	= aarch64_mte_get_atag (gdbarch_remove_non_address_bits (gdbarch,
 								 fault_addr));
       gdb_byte ltag = aarch64_mte_get_ltag (fault_addr);
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 9bb649e901d..58c70160d31 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -3098,7 +3098,7 @@ ada_value_slice_from_ptr (struct value *array_ptr, struct type *type,
 			       type0->dyn_prop (DYN_PROP_BYTE_STRIDE),
 			       type0->field (0).bitsize ());
   int base_low =  ada_discrete_type_low_bound (type0->index_type ());
-  gdb::optional<LONGEST> base_low_pos, low_pos;
+  std::optional<LONGEST> base_low_pos, low_pos;
   CORE_ADDR base;
 
   low_pos = discrete_position (base_index_type, low);
@@ -3132,7 +3132,7 @@ ada_value_slice (struct value *array, int low, int high)
 			      (alloc, type->target_type (), index_type,
 			       type->dyn_prop (DYN_PROP_BYTE_STRIDE),
 			       type->field (0).bitsize ());
-  gdb::optional<LONGEST> low_pos, high_pos;
+  std::optional<LONGEST> low_pos, high_pos;
 
 
   low_pos = discrete_position (base_index_type, low);
@@ -8792,7 +8792,7 @@ pos_atr (struct value *arg)
   if (!discrete_type_p (type))
     error (_("'POS only defined on discrete types"));
 
-  gdb::optional<LONGEST> result = discrete_position (type, value_as_long (val));
+  std::optional<LONGEST> result = discrete_position (type, value_as_long (val));
   if (!result.has_value ())
     error (_("enumeration value is invalid: can't find 'POS"));
 
diff --git a/gdb/ada-lex.l b/gdb/ada-lex.l
index 0547b704eaf..0576f361a42 100644
--- a/gdb/ada-lex.l
+++ b/gdb/ada-lex.l
@@ -713,7 +713,7 @@ processAttribute (const char *str)
     if (strcasecmp (str, item.name) == 0)
       return item.code;
 
-  gdb::optional<int> found;
+  std::optional<int> found;
   for (const auto &item : attributes)
     if (subseqMatch (str, item.name))
       {
diff --git a/gdb/ada-valprint.c b/gdb/ada-valprint.c
index b32f1e506d1..f1c4e8b0b70 100644
--- a/gdb/ada-valprint.c
+++ b/gdb/ada-valprint.c
@@ -385,7 +385,7 @@ ada_print_scalar (struct type *type, LONGEST val, struct ui_file *stream)
 
     case TYPE_CODE_ENUM:
       {
-	gdb::optional<LONGEST> posn = discrete_position (type, val);
+	std::optional<LONGEST> posn = discrete_position (type, val);
 	if (posn.has_value ())
 	  fputs_styled (ada_enum_name (type->field (*posn).name ()),
 			variable_name_style.style (), stream);
@@ -827,7 +827,7 @@ ada_val_print_enum (struct value *value, struct ui_file *stream, int recurse,
   int offset_aligned = ada_aligned_value_addr (type, valaddr) - valaddr;
 
   val = unpack_long (type, valaddr + offset_aligned);
-  gdb::optional<LONGEST> posn = discrete_position (type, val);
+  std::optional<LONGEST> posn = discrete_position (type, val);
   if (posn.has_value ())
     {
       const char *name = ada_enum_name (type->field (*posn).name ());
diff --git a/gdb/amd-dbgapi-target.c b/gdb/amd-dbgapi-target.c
index 22c81262876..a19d6d0fc95 100644
--- a/gdb/amd-dbgapi-target.c
+++ b/gdb/amd-dbgapi-target.c
@@ -528,7 +528,7 @@ amd_dbgapi_target::xfer_partial (enum target_object object, const char *annex,
 			       ULONGEST offset, ULONGEST requested_len,
 			       ULONGEST *xfered_len)
 {
-  gdb::optional<scoped_restore_current_thread> maybe_restore_thread;
+  std::optional<scoped_restore_current_thread> maybe_restore_thread;
 
   if (!ptid_is_gpu (inferior_ptid))
     return beneath ()->xfer_partial (object, annex, readbuf, writebuf, offset,
@@ -1901,7 +1901,7 @@ static void
 amd_dbgapi_log_message_callback (amd_dbgapi_log_level_t level,
 				 const char *message)
 {
-  gdb::optional<target_terminal::scoped_restore_terminal_state> tstate;
+  std::optional<target_terminal::scoped_restore_terminal_state> tstate;
 
   if (target_supports_terminal_ours ())
     {
diff --git a/gdb/annotate.c b/gdb/annotate.c
index 8385429042d..f3ead9e3ce2 100644
--- a/gdb/annotate.c
+++ b/gdb/annotate.c
@@ -233,7 +233,7 @@ annotate_thread_changed (void)
 
 static void
 annotate_thread_exited (thread_info *t,
-			gdb::optional<ULONGEST> exit_code,
+			std::optional<ULONGEST> exit_code,
 			bool /* silent */)
 {
   if (annotation_level > 1)
diff --git a/gdb/arm-fbsd-tdep.c b/gdb/arm-fbsd-tdep.c
index b6aa42a4fd0..03264f744a2 100644
--- a/gdb/arm-fbsd-tdep.c
+++ b/gdb/arm-fbsd-tdep.c
@@ -215,7 +215,7 @@ arm_fbsd_iterate_over_regset_sections (struct gdbarch *gdbarch,
 /* See arm-fbsd-tdep.h.  */
 
 const struct target_desc *
-arm_fbsd_read_description_auxv (const gdb::optional<gdb::byte_vector> &auxv,
+arm_fbsd_read_description_auxv (const std::optional<gdb::byte_vector> &auxv,
 				target_ops *target, gdbarch *gdbarch, bool tls)
 {
   CORE_ADDR arm_hwcap = 0;
@@ -244,7 +244,7 @@ arm_fbsd_read_description_auxv (const gdb::optional<gdb::byte_vector> &auxv,
 const struct target_desc *
 arm_fbsd_read_description_auxv (bool tls)
 {
-  const gdb::optional<gdb::byte_vector> &auxv = target_read_auxv ();
+  const std::optional<gdb::byte_vector> &auxv = target_read_auxv ();
   return arm_fbsd_read_description_auxv (auxv,
 					 current_inferior ()->top_target (),
 					 current_inferior ()->arch (),
@@ -260,7 +260,7 @@ arm_fbsd_core_read_description (struct gdbarch *gdbarch,
 {
   asection *tls = bfd_get_section_by_name (abfd, ".reg-aarch-tls");
 
-  gdb::optional<gdb::byte_vector> auxv = target_read_auxv_raw (target);
+  std::optional<gdb::byte_vector> auxv = target_read_auxv_raw (target);
   return arm_fbsd_read_description_auxv (auxv, target, gdbarch, tls != nullptr);
 }
 
diff --git a/gdb/arm-fbsd-tdep.h b/gdb/arm-fbsd-tdep.h
index 3478e4b6860..7eb1850c1a7 100644
--- a/gdb/arm-fbsd-tdep.h
+++ b/gdb/arm-fbsd-tdep.h
@@ -47,7 +47,7 @@ extern const struct regset arm_fbsd_tls_regset;
    AUXV.  */
 
 extern const struct target_desc *
-  arm_fbsd_read_description_auxv (const gdb::optional<gdb::byte_vector> &auxv,
+  arm_fbsd_read_description_auxv (const std::optional<gdb::byte_vector> &auxv,
 				  target_ops *target, gdbarch *gdbarch,
 				  bool tls);
 
diff --git a/gdb/arm-linux-tdep.c b/gdb/arm-linux-tdep.c
index dfa816990ff..4c0f7816d61 100644
--- a/gdb/arm-linux-tdep.c
+++ b/gdb/arm-linux-tdep.c
@@ -732,7 +732,7 @@ arm_linux_core_read_description (struct gdbarch *gdbarch,
 				 struct target_ops *target,
 				 bfd *abfd)
 {
-  gdb::optional<gdb::byte_vector> auxv = target_read_auxv_raw (target);
+  std::optional<gdb::byte_vector> auxv = target_read_auxv_raw (target);
   CORE_ADDR arm_hwcap = linux_get_hwcap (auxv, target, gdbarch);
 
   if (arm_hwcap & HWCAP_VFP)
diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c
index a0ad1fb7a82..58c550af183 100644
--- a/gdb/arm-tdep.c
+++ b/gdb/arm-tdep.c
@@ -302,7 +302,7 @@ struct arm_prologue_cache
   int framereg;
 
   /* True if the return address is signed, false otherwise.  */
-  gdb::optional<bool> ra_signed_state;
+  std::optional<bool> ra_signed_state;
 
   /* Saved register offsets.  */
   trad_frame_saved_reg *saved_regs;
@@ -1035,7 +1035,7 @@ thumb_analyze_prologue (struct gdbarch *gdbarch,
   while (start < limit)
     {
       unsigned short insn;
-      gdb::optional<bool> ra_signed_state;
+      std::optional<bool> ra_signed_state;
 
       insn = read_code_unsigned_integer (start, 2, byte_order_for_code);
 
diff --git a/gdb/auto-load.c b/gdb/auto-load.c
index 8bbe6696dcc..daea75b7437 100644
--- a/gdb/auto-load.c
+++ b/gdb/auto-load.c
@@ -914,7 +914,7 @@ source_script_file (struct auto_load_pspace_info *pspace_info,
       return;
     }
 
-  gdb::optional<open_script> opened = find_and_open_script (file,
+  std::optional<open_script> opened = find_and_open_script (file,
 							    1 /*search_path*/);
 
   if (opened)
diff --git a/gdb/auxv.c b/gdb/auxv.c
index 61acd48fc98..994d97c1a2c 100644
--- a/gdb/auxv.c
+++ b/gdb/auxv.c
@@ -331,7 +331,7 @@ parse_auxv (target_ops *ops, gdbarch *gdbarch, const gdb_byte **readptr,
     overhead of transfering data from a remote target to the local host.  */
 struct auxv_info
 {
-  gdb::optional<gdb::byte_vector> data;
+  std::optional<gdb::byte_vector> data;
 };
 
 /* Per-inferior data key for auxv.  */
@@ -357,7 +357,7 @@ auxv_all_objfiles_removed (program_space *pspace)
 
 /* See auxv.h.  */
 
-const gdb::optional<gdb::byte_vector> &
+const std::optional<gdb::byte_vector> &
 target_read_auxv ()
 {
   inferior *inf = current_inferior ();
@@ -374,7 +374,7 @@ target_read_auxv ()
 
 /* See auxv.h.  */
 
-gdb::optional<gdb::byte_vector>
+std::optional<gdb::byte_vector>
 target_read_auxv_raw (target_ops *ops)
 {
   return target_read_alloc (ops, TARGET_OBJECT_AUXV, NULL);
@@ -413,7 +413,7 @@ target_auxv_search (const gdb::byte_vector &auxv, target_ops *ops,
 int
 target_auxv_search (CORE_ADDR match, CORE_ADDR *valp)
 {
-  const gdb::optional<gdb::byte_vector> &auxv = target_read_auxv ();
+  const std::optional<gdb::byte_vector> &auxv = target_read_auxv ();
 
   if (!auxv.has_value ())
     return -1;
@@ -572,7 +572,7 @@ fprint_target_auxv (struct ui_file *file)
   gdbarch *gdbarch = current_inferior ()->arch ();
   CORE_ADDR type, val;
   int ents = 0;
-  const gdb::optional<gdb::byte_vector> &auxv = target_read_auxv ();
+  const std::optional<gdb::byte_vector> &auxv = target_read_auxv ();
 
   if (!auxv.has_value ())
     return -1;
diff --git a/gdb/auxv.h b/gdb/auxv.h
index a920f7a5da8..10f31dc84e8 100644
--- a/gdb/auxv.h
+++ b/gdb/auxv.h
@@ -48,11 +48,11 @@ extern int svr4_auxv_parse (struct gdbarch *gdbarch, const gdb_byte **readptr,
 
 /* Read auxv data from the current inferior's target stack.  */
 
-extern const gdb::optional<gdb::byte_vector> &target_read_auxv ();
+extern const std::optional<gdb::byte_vector> &target_read_auxv ();
 
 /* Read auxv data from OPS.  */
 
-extern gdb::optional<gdb::byte_vector> target_read_auxv_raw (target_ops *ops);
+extern std::optional<gdb::byte_vector> target_read_auxv_raw (target_ops *ops);
 
 /* Search AUXV for an entry with a_type matching MATCH.
 
diff --git a/gdb/avr-tdep.c b/gdb/avr-tdep.c
index 92aec3b510f..598d740883c 100644
--- a/gdb/avr-tdep.c
+++ b/gdb/avr-tdep.c
@@ -1566,7 +1566,7 @@ avr_io_reg_read_command (const char *args, int from_tty)
   unsigned int val;
 
   /* Find out how many io registers the target has.  */
-  gdb::optional<gdb::byte_vector> buf
+  std::optional<gdb::byte_vector> buf
     = target_read_alloc (current_inferior ()->top_target (),
 			 TARGET_OBJECT_AVR, "avr.io_reg");
 
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index 2edcbf6d490..1cc2dfbe66e 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -82,7 +82,7 @@
 #include <algorithm>
 #include "progspace-and-thread.h"
 #include "gdbsupport/array-view.h"
-#include "gdbsupport/gdb_optional.h"
+#include <optional>
 #include "gdbsupport/common-utils.h"
 
 /* Prototypes for local functions.  */
@@ -2067,7 +2067,7 @@ update_watchpoint (struct watchpoint *b, bool reparse)
   if (b->disposition == disp_del_at_next_stop)
     return;
 
-  gdb::optional<scoped_restore_selected_frame> restore_frame;
+  std::optional<scoped_restore_selected_frame> restore_frame;
 
   /* Determine if the watchpoint is within scope.  */
   if (b->exp_valid_block == NULL)
@@ -3365,7 +3365,7 @@ remove_breakpoints (void)
 
 static void
 remove_threaded_breakpoints (thread_info *tp,
-			     gdb::optional<ULONGEST> /* exit_code */,
+			     std::optional<ULONGEST> /* exit_code */,
 			     int /* silent */)
 {
   for (breakpoint &b : all_breakpoints_safe ())
@@ -6780,8 +6780,8 @@ print_one_breakpoint_location (struct breakpoint *b,
 	(uiout->test_flags (fix_breakpoint_script_output)
 	 || fix_breakpoint_script_output_globally);
 
-      gdb::optional<ui_out_emit_tuple> tuple_emitter;
-      gdb::optional<ui_out_emit_list> list_emitter;
+      std::optional<ui_out_emit_tuple> tuple_emitter;
+      std::optional<ui_out_emit_list> list_emitter;
 
       if (use_fixed_output)
 	list_emitter.emplace (uiout, "script");
@@ -6854,7 +6854,8 @@ print_one_breakpoint (breakpoint *b, const bp_location **last_loc, int allflag)
     = (uiout->test_flags (fix_multi_location_breakpoint_output)
        || fix_multi_location_breakpoint_output_globally);
 
-  gdb::optional<ui_out_emit_tuple> bkpt_tuple_emitter (gdb::in_place, uiout, "bkpt");
+  std::optional<ui_out_emit_tuple> bkpt_tuple_emitter (std::in_place, uiout,
+						       "bkpt");
   bool printed = print_one_breakpoint_location (b, NULL, 0, last_loc,
 						allflag, false);
 
@@ -6889,7 +6890,7 @@ print_one_breakpoint (breakpoint *b, const bp_location **last_loc, int allflag)
 		      || !b->first_loc ().enabled
 		      || b->first_loc ().disabled_by_cond))))
 	{
-	  gdb::optional<ui_out_emit_list> locations_list;
+	  std::optional<ui_out_emit_list> locations_list;
 
 	  /* For MI version <= 2, keep the behavior where GDB outputs an invalid
 	     MI record.  For later versions, place breakpoint locations in a
@@ -9954,7 +9955,7 @@ watchpoint::print_it (const bpstat *bs) const
 
   string_file stb;
 
-  gdb::optional<ui_out_emit_tuple> tuple_emitter;
+  std::optional<ui_out_emit_tuple> tuple_emitter;
   switch (this->type)
     {
     case bp_watchpoint:
@@ -10932,7 +10933,7 @@ until_break_command (const char *arg, int from_tty, int anywhere)
 
   std::vector<breakpoint_up> breakpoints;
 
-  gdb::optional<delete_longjmp_breakpoint_cleanup> lj_deleter;
+  std::optional<delete_longjmp_breakpoint_cleanup> lj_deleter;
 
   if (frame_id_p (caller_frame_id))
     {
diff --git a/gdb/buildsym.c b/gdb/buildsym.c
index b982afea3d2..32d60cc22d4 100644
--- a/gdb/buildsym.c
+++ b/gdb/buildsym.c
@@ -643,7 +643,7 @@ buildsym_compunit::record_line (struct subfile *subfile, int line,
      anyway.  */
   if (line == 0)
     {
-      gdb::optional<int> last_line;
+      std::optional<int> last_line;
 
       while (!subfile->line_vector_entries.empty ())
 	{
diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c
index 8cadd637151..49952eaca6a 100644
--- a/gdb/cli/cli-cmds.c
+++ b/gdb/cli/cli-cmds.c
@@ -655,12 +655,12 @@ show_script_ext_mode (struct ui_file *file, int from_tty,
    If SEARCH_PATH is non-zero, and the file isn't found in cwd,
    search for it in the source search path.  */
 
-gdb::optional<open_script>
+std::optional<open_script>
 find_and_open_script (const char *script_file, int search_path)
 {
   int fd;
   openp_flags search_flags = OPF_TRY_CWD_FIRST | OPF_RETURN_REALPATH;
-  gdb::optional<open_script> opened;
+  std::optional<open_script> opened;
 
   gdb::unique_xmalloc_ptr<char> file (tilde_expand (script_file));
 
@@ -742,7 +742,7 @@ source_script_with_search (const char *file, int from_tty, int search_path)
   if (file == NULL || *file == 0)
     error (_("source command requires file name of file to source."));
 
-  gdb::optional<open_script> opened = find_and_open_script (file, search_path);
+  std::optional<open_script> opened = find_and_open_script (file, search_path);
   if (!opened)
     {
       /* The script wasn't found, or was otherwise inaccessible.
diff --git a/gdb/cli/cli-cmds.h b/gdb/cli/cli-cmds.h
index 429574426ac..a2579dc25f2 100644
--- a/gdb/cli/cli-cmds.h
+++ b/gdb/cli/cli-cmds.h
@@ -18,7 +18,7 @@
 #define CLI_CLI_CMDS_H
 
 #include "gdbsupport/filestuff.h"
-#include "gdbsupport/gdb_optional.h"
+#include <optional>
 #include "completer.h"
 
 /* Chain containing all defined commands.  */
@@ -179,7 +179,7 @@ struct open_script
   }
 };
 
-extern gdb::optional<open_script>
+extern std::optional<open_script>
     find_and_open_script (const char *file, int search_path);
 
 /* Command tracing state.  */
diff --git a/gdb/cli/cli-decode.c b/gdb/cli/cli-decode.c
index 0bbe96b5334..940cd6a2c8e 100644
--- a/gdb/cli/cli-decode.c
+++ b/gdb/cli/cli-decode.c
@@ -24,7 +24,7 @@
 #include "cli/cli-cmds.h"
 #include "cli/cli-decode.h"
 #include "cli/cli-style.h"
-#include "gdbsupport/gdb_optional.h"
+#include <optional>
 
 /* Prototypes for local functions.  */
 
@@ -2727,7 +2727,7 @@ cmd_func (struct cmd_list_element *cmd, const char *args, int from_tty)
 {
   if (!cmd->is_command_class_help ())
     {
-      gdb::optional<scoped_restore_tmpl<bool>> restore_suppress;
+      std::optional<scoped_restore_tmpl<bool>> restore_suppress;
 
       if (cmd->suppress_notification != NULL)
 	restore_suppress.emplace (cmd->suppress_notification, true);
diff --git a/gdb/cli/cli-decode.h b/gdb/cli/cli-decode.h
index 8fe9325c2da..14d9c29b464 100644
--- a/gdb/cli/cli-decode.h
+++ b/gdb/cli/cli-decode.h
@@ -233,7 +233,7 @@ struct cmd_list_element
   void (*destroyer) (struct cmd_list_element *self, void *context) = nullptr;
 
   /* Setting affected by "set" and "show".  Not used if type is not_set_cmd.  */
-  gdb::optional<setting> var;
+  std::optional<setting> var;
 
   /* Pointer to NULL terminated list of enumerated values (like
      argv).  */
diff --git a/gdb/cli/cli-option.c b/gdb/cli/cli-option.c
index 9b303b1304e..d2d489b7219 100644
--- a/gdb/cli/cli-option.c
+++ b/gdb/cli/cli-option.c
@@ -58,11 +58,11 @@ struct option_def_and_value
   void *ctx;
 
   /* The option's value, if any.  */
-  gdb::optional<option_value> value;
+  std::optional<option_value> value;
 
   /* Constructor.  */
   option_def_and_value (const option_def &option_, void *ctx_,
-			gdb::optional<option_value> &&value_ = {})
+			std::optional<option_value> &&value_ = {})
     : option (option_),
       ctx (ctx_),
       value (std::move (value_))
@@ -99,7 +99,7 @@ struct option_def_and_value
      allocated on the heap, so we must clear the pointer in the
      source, to avoid a double free.  */
   static void clear_value (const option_def &option,
-			   gdb::optional<option_value> &value)
+			   std::optional<option_value> &value)
   {
     if (value.has_value ())
       {
@@ -109,7 +109,7 @@ struct option_def_and_value
   }
 };
 
-static void save_option_value_in_ctx (gdb::optional<option_def_and_value> &ov);
+static void save_option_value_in_ctx (std::optional<option_def_and_value> &ov);
 
 /* Info passed around when handling completion.  */
 struct parse_option_completion_info
@@ -177,7 +177,7 @@ complete_on_all_options (completion_tracker &tracker,
 /* Parse ARGS, guided by OPTIONS_GROUP.  HAVE_DELIMITER is true if the
    whole ARGS line included the "--" options-terminator delimiter.  */
 
-static gdb::optional<option_def_and_value>
+static std::optional<option_def_and_value>
 parse_option (gdb::array_view<const option_def_group> options_group,
 	      process_options_mode mode,
 	      bool have_delimiter,
@@ -496,7 +496,7 @@ complete_options (completion_tracker &tracker,
 	    }
 	  else if (**args == '-')
 	    {
-	      gdb::optional<option_def_and_value> ov
+	      std::optional<option_def_and_value> ov
 		= parse_option (options_group, mode, have_delimiter,
 				args, &completion_info);
 	      if (!ov && !tracker.have_completions ())
@@ -589,7 +589,7 @@ complete_options (completion_tracker &tracker,
 /* Save the parsed value in the option's context.  */
 
 static void
-save_option_value_in_ctx (gdb::optional<option_def_and_value> &ov)
+save_option_value_in_ctx (std::optional<option_def_and_value> &ov)
 {
   switch (ov->option.type)
     {
diff --git a/gdb/cli/cli-option.h b/gdb/cli/cli-option.h
index 7b015b89f47..4c62227f31c 100644
--- a/gdb/cli/cli-option.h
+++ b/gdb/cli/cli-option.h
@@ -20,7 +20,7 @@
 #ifndef CLI_OPTION_H
 #define CLI_OPTION_H 1
 
-#include "gdbsupport/gdb_optional.h"
+#include <optional>
 #include "gdbsupport/array-view.h"
 #include "completer.h"
 #include <string>
diff --git a/gdb/command.h b/gdb/command.h
index 467bb283cdc..1ab953b996b 100644
--- a/gdb/command.h
+++ b/gdb/command.h
@@ -126,7 +126,7 @@ struct literal_def
   LONGEST use;
 
   /* An optional number accepted that stands for the literal.  */
-  gdb::optional<LONGEST> val;
+  std::optional<LONGEST> val;
 };
 
 /* Return true if a setting of type VAR_TYPE is backed with type T.
diff --git a/gdb/compile/compile.c b/gdb/compile/compile.c
index a93c9404660..be1bcca47b4 100644
--- a/gdb/compile/compile.c
+++ b/gdb/compile/compile.c
@@ -40,7 +40,7 @@
 #include "osabi.h"
 #include "gdbsupport/gdb_wait.h"
 #include "valprint.h"
-#include "gdbsupport/gdb_optional.h"
+#include <optional>
 #include "gdbsupport/gdb_unlinker.h"
 #include "gdbsupport/pathstuff.h"
 #include "gdbsupport/scoped_ignore_signal.h"
@@ -768,7 +768,7 @@ compile_to_object (struct command_line *cmd, const char *cmd_string,
 
   compile_file_names fnames = get_new_file_names ();
 
-  gdb::optional<gdb::unlinker> source_remover;
+  std::optional<gdb::unlinker> source_remover;
 
   {
     gdb_file_up src = gdb_fopen_cloexec (fnames.source_file (), "w");
diff --git a/gdb/darwin-nat.c b/gdb/darwin-nat.c
index 588e9e2a345..af0a360d8ca 100644
--- a/gdb/darwin-nat.c
+++ b/gdb/darwin-nat.c
@@ -1967,7 +1967,7 @@ darwin_nat_target::create_inferior (const char *exec_file,
 				    const std::string &allargs,
 				    char **env, int from_tty)
 {
-  gdb::optional<scoped_restore_tmpl<bool>> restore_startup_with_shell;
+  std::optional<scoped_restore_tmpl<bool>> restore_startup_with_shell;
   darwin_nat_target *the_target = this;
 
   if (startup_with_shell && may_have_sip ())
diff --git a/gdb/debuginfod-support.c b/gdb/debuginfod-support.c
index 902af405cc6..1ebd98ca705 100644
--- a/gdb/debuginfod-support.c
+++ b/gdb/debuginfod-support.c
@@ -21,7 +21,7 @@
 #include <errno.h>
 #include "gdbsupport/scoped_fd.h"
 #include "debuginfod-support.h"
-#include "gdbsupport/gdb_optional.h"
+#include <optional>
 #include "cli/cli-cmds.h"
 #include "cli/cli-style.h"
 #include "cli-out.h"
@@ -320,7 +320,7 @@ debuginfod_source_query (const unsigned char *build_id,
 
   char *dname = nullptr;
   scoped_fd fd;
-  gdb::optional<target_terminal::scoped_restore_terminal_state> term_state;
+  std::optional<target_terminal::scoped_restore_terminal_state> term_state;
 
   {
     user_data data ("source file", srcpath);
@@ -366,7 +366,7 @@ debuginfod_debuginfo_query (const unsigned char *build_id,
 
   char *dname = nullptr;
   scoped_fd fd;
-  gdb::optional<target_terminal::scoped_restore_terminal_state> term_state;
+  std::optional<target_terminal::scoped_restore_terminal_state> term_state;
 
   {
     user_data data ("separate debug info for", filename);
@@ -409,7 +409,7 @@ debuginfod_exec_query (const unsigned char *build_id,
 
   char *dname = nullptr;
   scoped_fd fd;
-  gdb::optional<target_terminal::scoped_restore_terminal_state> term_state;
+  std::optional<target_terminal::scoped_restore_terminal_state> term_state;
 
   {
     user_data data ("executable for", filename);
@@ -458,7 +458,7 @@ debuginfod_section_query (const unsigned char *build_id,
   char *dname = nullptr;
   std::string desc = std::string ("section ") + section_name + " for";
   scoped_fd fd;
-  gdb::optional<target_terminal::scoped_restore_terminal_state> term_state;
+  std::optional<target_terminal::scoped_restore_terminal_state> term_state;
 
   {
     user_data data (desc.c_str (), filename);
diff --git a/gdb/disasm.c b/gdb/disasm.c
index 2e866f6865e..82b7e990ff9 100644
--- a/gdb/disasm.c
+++ b/gdb/disasm.c
@@ -29,7 +29,7 @@
 #include "source.h"
 #include "gdbsupport/gdb-safe-ctype.h"
 #include <algorithm>
-#include "gdbsupport/gdb_optional.h"
+#include <optional>
 #include "valprint.h"
 #include "cli/cli-style.h"
 #include "objfiles.h"
@@ -653,8 +653,8 @@ do_mixed_source_and_assembly_deprecated
 
   ui_out_emit_list asm_insns_list (uiout, "asm_insns");
 
-  gdb::optional<ui_out_emit_tuple> outer_tuple_emitter;
-  gdb::optional<ui_out_emit_list> inner_list_emitter;
+  std::optional<ui_out_emit_tuple> outer_tuple_emitter;
+  std::optional<ui_out_emit_list> inner_list_emitter;
 
   for (i = 0; i < newlines; i++)
     {
@@ -810,8 +810,8 @@ do_mixed_source_and_assembly (struct gdbarch *gdbarch,
 
   ui_out_emit_list asm_insns_emitter (uiout, "asm_insns");
 
-  gdb::optional<ui_out_emit_tuple> tuple_emitter;
-  gdb::optional<ui_out_emit_list> list_emitter;
+  std::optional<ui_out_emit_tuple> tuple_emitter;
+  std::optional<ui_out_emit_list> list_emitter;
 
   last_symtab = NULL;
   last_line = 0;
@@ -1093,7 +1093,7 @@ gdb_print_insn_1 (struct gdbarch *gdbarch, CORE_ADDR vma,
 		  struct disassemble_info *info)
 {
   /* Call into the extension languages to do the disassembly.  */
-  gdb::optional<int> length = ext_lang_print_insn (gdbarch, vma, info);
+  std::optional<int> length = ext_lang_print_insn (gdbarch, vma, info);
   if (length.has_value ())
     return *length;
 
@@ -1125,7 +1125,7 @@ gdb_disassembler::print_insn (CORE_ADDR memaddr,
      this output.  */
   if (length > 0 && use_ext_lang_for_styling ())
     {
-      gdb::optional<std::string> ext_contents;
+      std::optional<std::string> ext_contents;
       ext_contents = ext_lang_colorize_disasm (m_buffer.string (), arch ());
       if (ext_contents.has_value ())
 	m_buffer = std::move (*ext_contents);
diff --git a/gdb/disasm.h b/gdb/disasm.h
index dbc63e52ed2..5596bd62a10 100644
--- a/gdb/disasm.h
+++ b/gdb/disasm.h
@@ -275,7 +275,7 @@ struct gdb_disassembler : public gdb_printing_disassembler,
      negative value (which indicates an error), then, if this variable has
      a value, we report a memory error to the user, otherwise, we report a
      non-memory error.  */
-  gdb::optional<CORE_ADDR> m_err_memaddr;
+  std::optional<CORE_ADDR> m_err_memaddr;
 
   /* The stream to which disassembler output will be written.  */
   ui_file *m_dest;
diff --git a/gdb/dwarf2/attribute.h b/gdb/dwarf2/attribute.h
index 4cfdaa1e355..fdb579a368a 100644
--- a/gdb/dwarf2/attribute.h
+++ b/gdb/dwarf2/attribute.h
@@ -29,7 +29,7 @@
 
 #include "dwarf2.h"
 #include "dwarf2/types.h"
-#include "gdbsupport/gdb_optional.h"
+#include <optional>
 
 /* Blocks are a bunch of untyped bytes.  */
 struct dwarf_block
diff --git a/gdb/dwarf2/cu.h b/gdb/dwarf2/cu.h
index 0c15d8b02db..d57f3683a9a 100644
--- a/gdb/dwarf2/cu.h
+++ b/gdb/dwarf2/cu.h
@@ -22,7 +22,7 @@
 
 #include "buildsym.h"
 #include "dwarf2/comp-unit-head.h"
-#include "gdbsupport/gdb_optional.h"
+#include <optional>
 #include "language.h"
 
 /* Type used for delaying computation of method physnames.
@@ -101,7 +101,7 @@ struct dwarf2_cu
   struct comp_unit_head header;
 
   /* Base address of this compilation unit.  */
-  gdb::optional<unrelocated_addr> base_address;
+  std::optional<unrelocated_addr> base_address;
 
   /* The language we are debugging.  */
   const struct language_defn *language_defn = nullptr;
@@ -189,7 +189,7 @@ struct dwarf2_cu
 
   /* The DW_AT_addr_base (DW_AT_GNU_addr_base) attribute if present.
      Note this value comes from the Fission stub CU/TU's DIE.  */
-  gdb::optional<ULONGEST> addr_base;
+  std::optional<ULONGEST> addr_base;
 
   /* The DW_AT_GNU_ranges_base attribute, if present.
 
@@ -242,7 +242,7 @@ struct dwarf2_cu
      files, the value is implicitly zero.  For DWARF 5 version DWO files, the
      value is often implicit and is the size of the header of
      .debug_str_offsets section (8 or 4, depending on the address size).  */
-  gdb::optional<ULONGEST> str_offsets_base;
+  std::optional<ULONGEST> str_offsets_base;
 
   /* Mark used when releasing cached dies.  */
   bool m_mark : 1;
diff --git a/gdb/dwarf2/die.h b/gdb/dwarf2/die.h
index cdee46996d6..c7040776b07 100644
--- a/gdb/dwarf2/die.h
+++ b/gdb/dwarf2/die.h
@@ -59,7 +59,7 @@ struct die_info
   /* Return the address base of the compile unit, which, if exists, is
      stored either at the attribute DW_AT_GNU_addr_base, or
      DW_AT_addr_base.  */
-  gdb::optional<ULONGEST> addr_base ()
+  std::optional<ULONGEST> addr_base ()
   {
     for (unsigned i = 0; i < num_attrs; ++i)
       if (attrs[i].name == DW_AT_addr_base
@@ -73,7 +73,7 @@ struct die_info
 	  complaint (_("address base attribute (offset %s) as wrong form"),
 		     sect_offset_str (sect_off));
 	}
-    return gdb::optional<ULONGEST> ();
+    return std::optional<ULONGEST> ();
   }
 
   /* Return the base address of the compile unit into the .debug_ranges section,
diff --git a/gdb/dwarf2/index-cache.h b/gdb/dwarf2/index-cache.h
index cfa45435fbd..023fc86fc89 100644
--- a/gdb/dwarf2/index-cache.h
+++ b/gdb/dwarf2/index-cache.h
@@ -52,7 +52,7 @@ struct index_cache_store_context
   std::string build_id_str;
 
   /* Captured value of dwz build id.  */
-  gdb::optional<std::string> dwz_build_id_str;
+  std::optional<std::string> dwz_build_id_str;
 };
 
 /* Class to manage the access to the DWARF index cache.  */
diff --git a/gdb/dwarf2/index-write.c b/gdb/dwarf2/index-write.c
index 6ea4217fb22..a6d770c9ee5 100644
--- a/gdb/dwarf2/index-write.c
+++ b/gdb/dwarf2/index-write.c
@@ -1473,7 +1473,7 @@ struct index_wip_file
      FILENAME_TEMP is unlinked, because on MS-Windows one cannot
      delete a file that is still open.  So, we wrap the unlinker in an
      optional and emplace it once we know the file name.  */
-  gdb::optional<gdb::unlinker> unlink_file;
+  std::optional<gdb::unlinker> unlink_file;
 
   gdb_file_up out_file;
 };
@@ -1496,7 +1496,7 @@ write_dwarf_index (dwarf2_per_bfd *per_bfd, const char *dir,
 			      ? INDEX5_SUFFIX : INDEX4_SUFFIX);
 
   index_wip_file objfile_index_wip (dir, basename, index_suffix);
-  gdb::optional<index_wip_file> dwz_index_wip;
+  std::optional<index_wip_file> dwz_index_wip;
 
   if (dwz_basename != NULL)
       dwz_index_wip.emplace (dir, dwz_basename, index_suffix);
diff --git a/gdb/dwarf2/line-header.c b/gdb/dwarf2/line-header.c
index d072a91bac9..ddaf7e4a527 100644
--- a/gdb/dwarf2/line-header.c
+++ b/gdb/dwarf2/line-header.c
@@ -160,8 +160,8 @@ read_formatted_entries (dwarf2_per_objfile *per_objfile, bfd *abfd,
 	  ULONGEST form  = read_unsigned_leb128 (abfd, format, &bytes_read);
 	  format += bytes_read;
 
-	  gdb::optional<const char *> string;
-	  gdb::optional<unsigned int> uint;
+	  std::optional<const char *> string;
+	  std::optional<unsigned int> uint;
 
 	  switch (form)
 	    {
diff --git a/gdb/dwarf2/macro.c b/gdb/dwarf2/macro.c
index 78cce2d69eb..2e88e670216 100644
--- a/gdb/dwarf2/macro.c
+++ b/gdb/dwarf2/macro.c
@@ -444,7 +444,7 @@ dwarf_decode_macro_bytes (dwarf2_per_objfile *per_objfile,
 			  unsigned int offset_size,
 			  struct dwarf2_section_info *str_section,
 			  struct dwarf2_section_info *str_offsets_section,
-			  gdb::optional<ULONGEST> str_offsets_base,
+			  std::optional<ULONGEST> str_offsets_base,
 			  htab_t include_hash, struct dwarf2_cu *cu)
 {
   struct objfile *objfile = per_objfile->objfile;
@@ -805,7 +805,7 @@ dwarf_decode_macros (dwarf2_per_objfile *per_objfile,
 		     const struct line_header *lh, unsigned int offset_size,
 		     unsigned int offset, struct dwarf2_section_info *str_section,
 		     struct dwarf2_section_info *str_offsets_section,
-		     gdb::optional<ULONGEST> str_offsets_base,
+		     std::optional<ULONGEST> str_offsets_base,
 		     int section_is_gnu, struct dwarf2_cu *cu)
 {
   bfd *abfd;
diff --git a/gdb/dwarf2/macro.h b/gdb/dwarf2/macro.h
index d92994fef16..7daf147033a 100644
--- a/gdb/dwarf2/macro.h
+++ b/gdb/dwarf2/macro.h
@@ -30,7 +30,7 @@ extern void dwarf_decode_macros (dwarf2_per_objfile *per_objfile,
 				 unsigned int offset,
 				 dwarf2_section_info *str_section,
 				 dwarf2_section_info *str_offsets_section,
-				 gdb::optional<ULONGEST> str_offsets_base,
+				 std::optional<ULONGEST> str_offsets_base,
 				 int section_is_gnu, struct dwarf2_cu *cu);
 
 #endif /* GDB_DWARF2_MACRO_H */
diff --git a/gdb/dwarf2/read-gdb-index.c b/gdb/dwarf2/read-gdb-index.c
index da3bf0633fc..dd011900d2b 100644
--- a/gdb/dwarf2/read-gdb-index.c
+++ b/gdb/dwarf2/read-gdb-index.c
@@ -182,7 +182,7 @@ struct dw2_symtab_iterator
   dwarf2_per_objfile *per_objfile;
   /* If set, only look for symbols that match that block.  Valid values are
      GLOBAL_BLOCK and STATIC_BLOCK.  */
-  gdb::optional<block_enum> block_index;
+  std::optional<block_enum> block_index;
   /* The kind of symbol we're looking for.  */
   domain_enum domain;
   /* The list of CUs from the index entry of the symbol,
@@ -204,7 +204,7 @@ struct dw2_symtab_iterator
 static void
 dw2_symtab_iter_init (struct dw2_symtab_iterator *iter,
 		      dwarf2_per_objfile *per_objfile,
-		      gdb::optional<block_enum> block_index,
+		      std::optional<block_enum> block_index,
 		      domain_enum domain, offset_type namei,
 		      mapped_gdb_index &index)
 {
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 5bbf208ed5a..e40353975c1 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -77,7 +77,7 @@
 #include "build-id.h"
 #include "namespace.h"
 #include "gdbsupport/function-view.h"
-#include "gdbsupport/gdb_optional.h"
+#include <optional>
 #include "gdbsupport/underlying.h"
 #include "gdbsupport/hash_enum.h"
 #include "filename-seen-cache.h"
@@ -4080,7 +4080,7 @@ read_cutu_die_from_dwo (dwarf2_cu *cu,
 /* Return the signature of the compile unit, if found. In DWARF 4 and before,
    the signature is in the DW_AT_GNU_dwo_id attribute. In DWARF 5 and later, the
    signature is part of the header.  */
-static gdb::optional<ULONGEST>
+static std::optional<ULONGEST>
 lookup_dwo_id (struct dwarf2_cu *cu, struct die_info* comp_unit_die)
 {
   if (cu->header.version >= 5)
@@ -4088,7 +4088,7 @@ lookup_dwo_id (struct dwarf2_cu *cu, struct die_info* comp_unit_die)
   struct attribute *attr;
   attr = dwarf2_attr (comp_unit_die, DW_AT_GNU_dwo_id, cu);
   if (attr == nullptr || !attr->form_is_unsigned ())
-    return gdb::optional<ULONGEST> ();
+    return std::optional<ULONGEST> ();
   return attr->as_unsigned ();
 }
 
@@ -4121,7 +4121,7 @@ lookup_dwo_unit (dwarf2_cu *cu, die_info *comp_unit_die, const char *dwo_name)
     dwo_unit = lookup_dwo_type_unit (cu, dwo_name, comp_dir);
   else
     {
-      gdb::optional<ULONGEST> signature = lookup_dwo_id (cu, comp_unit_die);
+      std::optional<ULONGEST> signature = lookup_dwo_id (cu, comp_unit_die);
 
       if (!signature.has_value ())
 	error (_("Dwarf Error: missing dwo_id for dwo_name %s"
@@ -7981,7 +7981,7 @@ create_dwo_cu_reader (const struct die_reader_specs *reader,
   sect_offset sect_off = cu->per_cu->sect_off;
   struct dwarf2_section_info *section = cu->per_cu->section;
 
-  gdb::optional<ULONGEST> signature = lookup_dwo_id (cu, comp_unit_die);
+  std::optional<ULONGEST> signature = lookup_dwo_id (cu, comp_unit_die);
   if (!signature.has_value ())
     {
       complaint (_("Dwarf Error: debug entry at offset %s is missing"
@@ -10785,7 +10785,7 @@ dwarf2_rnglists_process (unsigned offset, struct dwarf2_cu *cu,
   struct objfile *objfile = per_objfile->objfile;
   bfd *obfd = objfile->obfd.get ();
   /* Base address selection entry.  */
-  gdb::optional<unrelocated_addr> base;
+  std::optional<unrelocated_addr> base;
   const gdb_byte *buffer;
   bool overflow = false;
   ULONGEST addr_index;
@@ -10991,7 +10991,7 @@ dwarf2_ranges_process (unsigned offset, struct dwarf2_cu *cu, dwarf_tag tag,
   unsigned int addr_size = cu_header->addr_size;
   CORE_ADDR mask = ~(~(CORE_ADDR)1 << (addr_size * 8 - 1));
   /* Base address selection entry.  */
-  gdb::optional<unrelocated_addr> base;
+  std::optional<unrelocated_addr> base;
   unsigned int dummy;
   const gdb_byte *buffer;
 
@@ -16187,8 +16187,8 @@ cooked_indexer::scan_attributes (dwarf2_per_cu_data *scanning_per_cu,
   bool is_declaration = false;
   sect_offset origin_offset {};
 
-  gdb::optional<unrelocated_addr> low_pc;
-  gdb::optional<unrelocated_addr> high_pc;
+  std::optional<unrelocated_addr> low_pc;
+  std::optional<unrelocated_addr> high_pc;
   bool high_pc_relative = false;
 
   for (int i = 0; i < abbrev->num_attrs; ++i)
@@ -17565,7 +17565,7 @@ dwarf2_per_objfile::read_line_string (const gdb_byte *buf,
 
 static unrelocated_addr
 read_addr_index_1 (dwarf2_per_objfile *per_objfile, unsigned int addr_index,
-		   gdb::optional<ULONGEST> addr_base, int addr_size)
+		   std::optional<ULONGEST> addr_base, int addr_size)
 {
   struct objfile *objfile = per_objfile->objfile;
   bfd *abfd = objfile->obfd.get ();
@@ -17618,7 +17618,7 @@ dwarf2_read_addr_index (dwarf2_per_cu_data *per_cu,
 			unsigned int addr_index)
 {
   struct dwarf2_cu *cu = per_objfile->get_cu (per_cu);
-  gdb::optional<ULONGEST> addr_base;
+  std::optional<ULONGEST> addr_base;
   int addr_size;
 
   /* We need addr_base and addr_size.
@@ -21389,7 +21389,7 @@ dwarf_decode_macros (struct dwarf2_cu *cu, unsigned int offset,
 
   struct dwarf2_section_info *str_offsets_section;
   struct dwarf2_section_info *str_section;
-  gdb::optional<ULONGEST> str_offsets_base;
+  std::optional<ULONGEST> str_offsets_base;
 
   if (cu->dwo_unit != nullptr)
     {
diff --git a/gdb/dwarf2/read.h b/gdb/dwarf2/read.h
index 1d9432c5c11..0cbe2bb3e69 100644
--- a/gdb/dwarf2/read.h
+++ b/gdb/dwarf2/read.h
@@ -747,7 +747,7 @@ struct dwarf2_per_objfile
   dwarf2_cu *sym_cu = nullptr;
 
   /* CUs that are queued to be read.  */
-  gdb::optional<std::queue<dwarf2_queue_item>> queue;
+  std::optional<std::queue<dwarf2_queue_item>> queue;
 
 private:
   /* Hold the corresponding compunit_symtab for each CU or TU.  This
diff --git a/gdb/eval.c b/gdb/eval.c
index b859e825925..3358b0d8d32 100644
--- a/gdb/eval.c
+++ b/gdb/eval.c
@@ -102,7 +102,7 @@ expression::uses_objfile (struct objfile *objfile) const
 struct value *
 expression::evaluate (struct type *expect_type, enum noside noside)
 {
-  gdb::optional<enable_thread_stack_temporaries> stack_temporaries;
+  std::optional<enable_thread_stack_temporaries> stack_temporaries;
   if (target_has_execution () && inferior_ptid != null_ptid
       && language_defn->la_language == language_cplus
       && !thread_stack_temporaries_enabled_p (inferior_thread ()))
diff --git a/gdb/event-top.c b/gdb/event-top.c
index 3d6fa896a9c..ee78768f8a6 100644
--- a/gdb/event-top.c
+++ b/gdb/event-top.c
@@ -692,7 +692,7 @@ void
 gdb_rl_deprep_term_function (void)
 {
 #ifdef RL_STATE_EOF
-  gdb::optional<scoped_restore_tmpl<int>> restore_eof_found;
+  std::optional<scoped_restore_tmpl<int>> restore_eof_found;
 
   if (RL_ISSTATE (RL_STATE_EOF))
     {
diff --git a/gdb/exceptions.c b/gdb/exceptions.c
index 2ba5a9c9fad..61fe74f648c 100644
--- a/gdb/exceptions.c
+++ b/gdb/exceptions.c
@@ -27,7 +27,7 @@
 #include "serial.h"
 #include "gdbthread.h"
 #include "ui.h"
-#include "gdbsupport/gdb_optional.h"
+#include <optional>
 
 static void
 print_flush (void)
@@ -38,7 +38,7 @@ print_flush (void)
   if (deprecated_error_begin_hook)
     deprecated_error_begin_hook ();
 
-  gdb::optional<target_terminal::scoped_restore_terminal_state> term_state;
+  std::optional<target_terminal::scoped_restore_terminal_state> term_state;
   if (target_supports_terminal_ours ())
     {
       term_state.emplace ();
diff --git a/gdb/extension-priv.h b/gdb/extension-priv.h
index 3442302a0be..7b74b46ee7c 100644
--- a/gdb/extension-priv.h
+++ b/gdb/extension-priv.h
@@ -256,13 +256,13 @@ struct extension_language_ops
      CONTENTS is the contents of the file.  This should either return
      colorized (using ANSI terminal escapes) version of the contents,
      or an empty option.  */
-  gdb::optional<std::string> (*colorize) (const std::string &name,
+  std::optional<std::string> (*colorize) (const std::string &name,
 					  const std::string &contents);
 
   /* Colorize a single line of disassembler output, CONTENT.  This should
      either return colorized (using ANSI terminal escapes) version of the
      contents, or an empty optional.  */
-  gdb::optional<std::string> (*colorize_disasm) (const std::string &content,
+  std::optional<std::string> (*colorize_disasm) (const std::string &content,
 						 gdbarch *gdbarch);
 
   /* Print a single instruction from ADDRESS in architecture GDBARCH.  INFO
@@ -276,7 +276,7 @@ struct extension_language_ops
      If no instruction can be disassembled then return an empty value and
      other extension languages will get a chance to perform the
      disassembly.  */
-  gdb::optional<int> (*print_insn) (struct gdbarch *gdbarch,
+  std::optional<int> (*print_insn) (struct gdbarch *gdbarch,
 				    CORE_ADDR address,
 				    struct disassemble_info *info);
 };
diff --git a/gdb/extension.c b/gdb/extension.c
index 65f3bab32a7..0fbba5fc8fc 100644
--- a/gdb/extension.c
+++ b/gdb/extension.c
@@ -939,10 +939,10 @@ xmethod_worker::get_result_type (value *object, gdb::array_view<value *> args)
 
 /* See extension.h.  */
 
-gdb::optional<std::string>
+std::optional<std::string>
 ext_lang_colorize (const std::string &filename, const std::string &contents)
 {
-  gdb::optional<std::string> result;
+  std::optional<std::string> result;
 
   for (const struct extension_language_defn *extlang : extension_languages)
     {
@@ -959,10 +959,10 @@ ext_lang_colorize (const std::string &filename, const std::string &contents)
 
 /* See extension.h.  */
 
-gdb::optional<std::string>
+std::optional<std::string>
 ext_lang_colorize_disasm (const std::string &content, gdbarch *gdbarch)
 {
-  gdb::optional<std::string> result;
+  std::optional<std::string> result;
 
   for (const struct extension_language_defn *extlang : extension_languages)
     {
@@ -979,7 +979,7 @@ ext_lang_colorize_disasm (const std::string &content, gdbarch *gdbarch)
 
 /* See extension.h.  */
 
-gdb::optional<int>
+std::optional<int>
 ext_lang_print_insn (struct gdbarch *gdbarch, CORE_ADDR address,
 		     struct disassemble_info *info)
 {
@@ -988,7 +988,7 @@ ext_lang_print_insn (struct gdbarch *gdbarch, CORE_ADDR address,
       if (extlang->ops == nullptr
 	  || extlang->ops->print_insn == nullptr)
 	continue;
-      gdb::optional<int> length
+      std::optional<int> length
 	= extlang->ops->print_insn (gdbarch, address, info);
       if (length.has_value ())
 	return length;
diff --git a/gdb/extension.h b/gdb/extension.h
index 28f9e3bc028..bfdd9d51deb 100644
--- a/gdb/extension.h
+++ b/gdb/extension.h
@@ -22,7 +22,7 @@
 
 #include "mi/mi-cmds.h"
 #include "gdbsupport/array-view.h"
-#include "gdbsupport/gdb_optional.h"
+#include <optional>
 
 struct breakpoint;
 struct command_line;
@@ -316,7 +316,7 @@ extern void get_matching_xmethod_workers
    either a colorized (using ANSI terminal escapes) version of the
    source code, or an empty value if colorizing could not be done.  */
 
-extern gdb::optional<std::string> ext_lang_colorize
+extern std::optional<std::string> ext_lang_colorize
   (const std::string &filename, const std::string &contents);
 
 /* Try to colorize a single line of disassembler output, CONTENT for
@@ -324,7 +324,7 @@ extern gdb::optional<std::string> ext_lang_colorize
    escapes) version of CONTENT, or an empty value if colorizing could not
    be done.  */
 
-extern gdb::optional<std::string> ext_lang_colorize_disasm
+extern std::optional<std::string> ext_lang_colorize_disasm
   (const std::string &content, gdbarch *gdbarch);
 
 /* Calls extension_language_ops::print_insn for each extension language,
@@ -334,7 +334,7 @@ extern gdb::optional<std::string> ext_lang_colorize_disasm
    All arguments are forwarded to extension_language_ops::print_insn, see
    that function for a full description.  */
 
-extern gdb::optional<int> ext_lang_print_insn
+extern std::optional<int> ext_lang_print_insn
   (struct gdbarch *gdbarch, CORE_ADDR address, struct disassemble_info *info);
 
 #if GDB_SELF_TEST
diff --git a/gdb/f-lang.c b/gdb/f-lang.c
index fc0614e5761..ebcca7adea3 100644
--- a/gdb/f-lang.c
+++ b/gdb/f-lang.c
@@ -306,7 +306,7 @@ class fortran_array_repacker_base_impl
 
   /* Set and reset to handle removing intermediate values from the
      value chain.  */
-  gdb::optional<scoped_value_mark> m_mark;
+  std::optional<scoped_value_mark> m_mark;
 };
 
 /* A class used by FORTRAN_VALUE_SUBARRAY when repacking Fortran array
diff --git a/gdb/fbsd-nat.c b/gdb/fbsd-nat.c
index 0e0d0cdf621..211b83f555a 100644
--- a/gdb/fbsd-nat.c
+++ b/gdb/fbsd-nat.c
@@ -99,7 +99,7 @@ fbsd_nat_target::have_pending_event (ptid_t filter)
 
 /* See fbsd-nat.h.  */
 
-gdb::optional<fbsd_nat_target::pending_event>
+std::optional<fbsd_nat_target::pending_event>
 fbsd_nat_target::take_pending_event (ptid_t filter)
 {
   for (auto it = m_pending_events.begin (); it != m_pending_events.end (); it++)
@@ -1663,7 +1663,7 @@ fbsd_nat_target::wait (ptid_t ptid, struct target_waitstatus *ourstatus,
 			 target_options_to_string (target_options).c_str ());
 
   /* If there is a valid pending event, return it.  */
-  gdb::optional<pending_event> event = take_pending_event (ptid);
+  std::optional<pending_event> event = take_pending_event (ptid);
   if (event.has_value ())
     {
       /* Stop any other inferiors currently running.  */
@@ -1899,7 +1899,7 @@ fbsd_nat_target::detach_fork_children (inferior *inf)
 
   while (1)
     {
-      gdb::optional<pending_event> event = take_pending_event (ptid);
+      std::optional<pending_event> event = take_pending_event (ptid);
       if (!event.has_value ())
 	break;
 
diff --git a/gdb/fbsd-nat.h b/gdb/fbsd-nat.h
index 7016cc0242a..8118408bf47 100644
--- a/gdb/fbsd-nat.h
+++ b/gdb/fbsd-nat.h
@@ -20,7 +20,7 @@
 #ifndef FBSD_NAT_H
 #define FBSD_NAT_H
 
-#include "gdbsupport/gdb_optional.h"
+#include <optional>
 #include "inf-ptrace.h"
 #include "regcache.h"
 #include "regset.h"
@@ -262,7 +262,7 @@ class fbsd_nat_target : public inf_ptrace_target
      FILTER.  If there is a matching event, the event is removed from
      the pending list and returned.  */
 
-  gdb::optional<pending_event> take_pending_event (ptid_t filter);
+  std::optional<pending_event> take_pending_event (ptid_t filter);
 
   /* List of pending events.  */
 
diff --git a/gdb/fbsd-tdep.c b/gdb/fbsd-tdep.c
index d166d785736..4ac33697082 100644
--- a/gdb/fbsd-tdep.c
+++ b/gdb/fbsd-tdep.c
@@ -650,10 +650,10 @@ find_signalled_thread (struct thread_info *info, void *data)
    the data is prefixed with a 32-bit integer size to match the format
    used in FreeBSD NT_PROCSTAT_* notes.  */
 
-static gdb::optional<gdb::byte_vector>
+static std::optional<gdb::byte_vector>
 fbsd_make_note_desc (enum target_object object, uint32_t structsize)
 {
-  gdb::optional<gdb::byte_vector> buf =
+  std::optional<gdb::byte_vector> buf =
     target_read_alloc (current_inferior ()->top_target (), object, NULL);
   if (!buf || buf->empty ())
     return {};
@@ -735,7 +735,7 @@ fbsd_make_corefile_notes (struct gdbarch *gdbarch, bfd *obfd, int *note_size)
 
   /* Auxiliary vector.  */
   uint32_t structsize = gdbarch_ptr_bit (gdbarch) / 4; /* Elf_Auxinfo  */
-  gdb::optional<gdb::byte_vector> note_desc =
+  std::optional<gdb::byte_vector> note_desc =
     fbsd_make_note_desc (TARGET_OBJECT_AUXV, structsize);
   if (note_desc && !note_desc->empty ())
     {
@@ -2340,7 +2340,7 @@ fbsd_vdso_range (struct gdbarch *gdbarch, struct mem_range *range)
   else
     {
       /* Fetch the list of address space entries from the running target. */
-      gdb::optional<gdb::byte_vector> buf =
+      std::optional<gdb::byte_vector> buf =
 	target_read_alloc (current_inferior ()->top_target (),
 			   TARGET_OBJECT_FREEBSD_VMMAP, nullptr);
       if (!buf || buf->empty ())
diff --git a/gdb/gdbthread.h b/gdb/gdbthread.h
index 48f32bb3a0b..403aed7c838 100644
--- a/gdb/gdbthread.h
+++ b/gdb/gdbthread.h
@@ -210,10 +210,10 @@ struct thread_suspend_state
 
      - If the thread is running, then this field has its value removed by
        calling stop_pc.reset() (see thread_info::set_executing()).
-       Attempting to read a gdb::optional with no value is undefined
+       Attempting to read a std::optional with no value is undefined
        behaviour and will trigger an assertion error when _GLIBCXX_DEBUG is
        defined, which should make error easier to track down.  */
-  gdb::optional<CORE_ADDR> stop_pc;
+  std::optional<CORE_ADDR> stop_pc;
 };
 
 /* Base class for target-specific thread data.  */
@@ -645,7 +645,7 @@ extern void delete_thread_silent (struct thread_info *thread);
    available.  If SILENT, then don't inform the CLI about the
    exit.  */
 extern void set_thread_exited (thread_info *tp,
-			       gdb::optional<ULONGEST> exit_code = {},
+			       std::optional<ULONGEST> exit_code = {},
 			       bool silent = false);
 
 /* Delete a step_resume_breakpoint from the thread database.  */
@@ -1042,7 +1042,7 @@ extern bool switch_to_thread_if_alive (thread_info *thr);
    exception if !FLAGS.SILENT and !FLAGS.CONT and CMD fails.  */
 
 extern void thread_try_catch_cmd (thread_info *thr,
-				  gdb::optional<int> ada_task,
+				  std::optional<int> ada_task,
 				  const char *cmd, int from_tty,
 				  const qcs_flags &flags);
 
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index 534b7a2bfa2..284793c055d 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -1046,7 +1046,7 @@ has_static_range (const struct range_bounds *bounds)
 
 /* See gdbtypes.h.  */
 
-gdb::optional<LONGEST>
+std::optional<LONGEST>
 get_discrete_low_bound (struct type *type)
 {
   type = check_typedef (type);
@@ -1062,7 +1062,7 @@ get_discrete_low_bound (struct type *type)
 
 	if (type->target_type ()->code () == TYPE_CODE_ENUM)
 	  {
-	    gdb::optional<LONGEST> low_pos
+	    std::optional<LONGEST> low_pos
 	      = discrete_position (type->target_type (), low);
 
 	    if (low_pos.has_value ())
@@ -1113,7 +1113,7 @@ get_discrete_low_bound (struct type *type)
 
 /* See gdbtypes.h.  */
 
-gdb::optional<LONGEST>
+std::optional<LONGEST>
 get_discrete_high_bound (struct type *type)
 {
   type = check_typedef (type);
@@ -1129,7 +1129,7 @@ get_discrete_high_bound (struct type *type)
 
 	if (type->target_type ()->code () == TYPE_CODE_ENUM)
 	  {
-	    gdb::optional<LONGEST> high_pos
+	    std::optional<LONGEST> high_pos
 	      = discrete_position (type->target_type (), high);
 
 	    if (high_pos.has_value ())
@@ -1192,11 +1192,11 @@ get_discrete_high_bound (struct type *type)
 bool
 get_discrete_bounds (struct type *type, LONGEST *lowp, LONGEST *highp)
 {
-  gdb::optional<LONGEST> low = get_discrete_low_bound (type);
+  std::optional<LONGEST> low = get_discrete_low_bound (type);
   if (!low.has_value ())
     return false;
 
-  gdb::optional<LONGEST> high = get_discrete_high_bound (type);
+  std::optional<LONGEST> high = get_discrete_high_bound (type);
   if (!high.has_value ())
     return false;
 
@@ -1244,7 +1244,7 @@ get_array_bounds (struct type *type, LONGEST *low_bound, LONGEST *high_bound)
    in which case the value of POS is unmodified.
 */
 
-gdb::optional<LONGEST>
+std::optional<LONGEST>
 discrete_position (struct type *type, LONGEST val)
 {
   if (type->code () == TYPE_CODE_RANGE)
@@ -2535,7 +2535,7 @@ compute_variant_fields_inner (struct type *type,
 			      std::vector<bool> &flags)
 {
   /* Evaluate the discriminant.  */
-  gdb::optional<ULONGEST> discr_value;
+  std::optional<ULONGEST> discr_value;
   if (part.discriminant_index != -1)
     {
       int idx = part.discriminant_index;
@@ -2758,7 +2758,7 @@ resolve_dynamic_type_internal (struct type *type,
   if (!is_dynamic_type_internal (real_type, top_level))
     return type;
 
-  gdb::optional<CORE_ADDR> type_length;
+  std::optional<CORE_ADDR> type_length;
   prop = TYPE_DYNAMIC_LENGTH (type);
   if (prop != NULL
       && dwarf2_evaluate_property (prop, frame, addr_stack, &value))
diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h
index 505c8ba12b5..d5bd6d2d2d7 100644
--- a/gdb/gdbtypes.h
+++ b/gdb/gdbtypes.h
@@ -47,7 +47,7 @@
 #include "hashtab.h"
 #include "gdbsupport/array-view.h"
 #include "gdbsupport/gdb-hashtab.h"
-#include "gdbsupport/gdb_optional.h"
+#include <optional>
 #include "gdbsupport/offset-type.h"
 #include "gdbsupport/enum-flags.h"
 #include "gdbsupport/underlying.h"
@@ -2663,11 +2663,11 @@ extern bool get_discrete_bounds (struct type *type, LONGEST *lowp,
 
 /* If TYPE's low bound is a known constant, return it, else return nullopt.  */
 
-extern gdb::optional<LONGEST> get_discrete_low_bound (struct type *type);
+extern std::optional<LONGEST> get_discrete_low_bound (struct type *type);
 
 /* If TYPE's high bound is a known constant, return it, else return nullopt.  */
 
-extern gdb::optional<LONGEST> get_discrete_high_bound (struct type *type);
+extern std::optional<LONGEST> get_discrete_high_bound (struct type *type);
 
 /* Assuming TYPE is a simple, non-empty array type, compute its upper
    and lower bound.  Save the low bound into LOW_BOUND if not NULL.
@@ -2679,7 +2679,7 @@ extern gdb::optional<LONGEST> get_discrete_high_bound (struct type *type);
 extern bool get_array_bounds (struct type *type, LONGEST *low_bound,
 			      LONGEST *high_bound);
 
-extern gdb::optional<LONGEST> discrete_position (struct type *type,
+extern std::optional<LONGEST> discrete_position (struct type *type,
 						 LONGEST val);
 
 extern int class_types_same_p (const struct type *, const struct type *);
diff --git a/gdb/guile/scm-ports.c b/gdb/guile/scm-ports.c
index a27ea8b3c80..ceca60b37e5 100644
--- a/gdb/guile/scm-ports.c
+++ b/gdb/guile/scm-ports.c
@@ -26,7 +26,7 @@
 #include "ui.h"
 #include "target.h"
 #include "guile-internal.h"
-#include "gdbsupport/gdb_optional.h"
+#include <optional>
 
 #ifdef HAVE_POLL
 #if defined (HAVE_POLL_H)
@@ -602,7 +602,7 @@ ioscm_with_output_to_port_worker (SCM port, SCM thunk, enum oport oport,
 						  ? &gdb_stderr : &gdb_stdout);
 
   {
-    gdb::optional<ui_out_redirect_pop> redirect_popper;
+    std::optional<ui_out_redirect_pop> redirect_popper;
     if (oport == GDB_STDERR)
       gdb_stderr = port_file.get ();
     else
diff --git a/gdb/ia64-tdep.c b/gdb/ia64-tdep.c
index cdd5553cf5d..6d537c4c8d3 100644
--- a/gdb/ia64-tdep.c
+++ b/gdb/ia64-tdep.c
@@ -69,7 +69,7 @@ struct ia64_table_entry
   };
 
 static struct ia64_table_entry *ktab = NULL;
-static gdb::optional<gdb::byte_vector> ktab_buf;
+static std::optional<gdb::byte_vector> ktab_buf;
 
 #endif
 
@@ -2648,7 +2648,7 @@ ia64_access_mem (unw_addr_space_t as,
 }
 
 /* Call low-level function to access the kernel unwind table.  */
-static gdb::optional<gdb::byte_vector>
+static std::optional<gdb::byte_vector>
 getunwind_table ()
 {
   /* FIXME drow/2005-09-10: This code used to call
diff --git a/gdb/inf-child.c b/gdb/inf-child.c
index 25afdb2202e..4eeb68be8f0 100644
--- a/gdb/inf-child.c
+++ b/gdb/inf-child.c
@@ -352,7 +352,7 @@ inf_child_target::fileio_unlink (struct inferior *inf, const char *filename,
 
 /* Implementation of to_fileio_readlink.  */
 
-gdb::optional<std::string>
+std::optional<std::string>
 inf_child_target::fileio_readlink (struct inferior *inf, const char *filename,
 				   fileio_error *target_errno)
 {
diff --git a/gdb/inf-child.h b/gdb/inf-child.h
index 017e8e35680..4aeb3898028 100644
--- a/gdb/inf-child.h
+++ b/gdb/inf-child.h
@@ -85,7 +85,7 @@ class inf_child_target
   int fileio_unlink (struct inferior *inf,
 		     const char *filename,
 		     fileio_error *target_errno) override;
-  gdb::optional<std::string> fileio_readlink (struct inferior *inf,
+  std::optional<std::string> fileio_readlink (struct inferior *inf,
 					      const char *filename,
 					      fileio_error *target_errno) override;
   bool use_agent (bool use) override;
diff --git a/gdb/infcmd.c b/gdb/infcmd.c
index cf8cd527955..3901a1aae66 100644
--- a/gdb/infcmd.c
+++ b/gdb/infcmd.c
@@ -52,7 +52,7 @@
 #include "ui.h"
 #include "interps.h"
 #include "skip.h"
-#include "gdbsupport/gdb_optional.h"
+#include <optional>
 #include "source.h"
 #include "cli/cli-style.h"
 #include "dwarf2/loc.h"
@@ -2790,7 +2790,7 @@ notice_new_inferior (thread_info *thr, bool leave_running, int from_tty)
   enum attach_post_wait_mode mode
     = leave_running ? ATTACH_POST_WAIT_RESUME : ATTACH_POST_WAIT_NOTHING;
 
-  gdb::optional<scoped_restore_current_thread> restore_thread;
+  std::optional<scoped_restore_current_thread> restore_thread;
 
   if (inferior_ptid != null_ptid)
     restore_thread.emplace ();
diff --git a/gdb/inferior.c b/gdb/inferior.c
index efe57cceae3..c9575e17749 100644
--- a/gdb/inferior.c
+++ b/gdb/inferior.c
@@ -731,10 +731,10 @@ switch_to_inferior_no_thread (inferior *inf)
 
 /* See regcache.h.  */
 
-gdb::optional<scoped_restore_current_thread>
+std::optional<scoped_restore_current_thread>
 maybe_switch_inferior (inferior *inf)
 {
-  gdb::optional<scoped_restore_current_thread> maybe_restore_thread;
+  std::optional<scoped_restore_current_thread> maybe_restore_thread;
   if (inf != current_inferior ())
     {
       maybe_restore_thread.emplace ();
diff --git a/gdb/inferior.h b/gdb/inferior.h
index 33eff7a9141..f8f9395aec4 100644
--- a/gdb/inferior.h
+++ b/gdb/inferior.h
@@ -340,7 +340,7 @@ extern void switch_to_inferior_no_thread (inferior *inf);
 
    If the current inferior was changed, return an RAII object that will
    restore the original current context.  */
-extern gdb::optional<scoped_restore_current_thread> maybe_switch_inferior
+extern std::optional<scoped_restore_current_thread> maybe_switch_inferior
   (inferior *inf);
 
 /* Info about an inferior's target description.  There's one of these
diff --git a/gdb/inflow.c b/gdb/inflow.c
index 095c5f03672..749f620739d 100644
--- a/gdb/inflow.c
+++ b/gdb/inflow.c
@@ -113,9 +113,9 @@ static struct terminal_info *get_inflow_inferior_data (struct inferior *);
    we save our handlers in these two variables and set SIGINT and SIGQUIT
    to SIG_IGN.  */
 
-static gdb::optional<sighandler_t> sigint_ours;
+static std::optional<sighandler_t> sigint_ours;
 #ifdef SIGQUIT
-static gdb::optional<sighandler_t> sigquit_ours;
+static std::optional<sighandler_t> sigquit_ours;
 #endif
 
 /* The name of the tty (from the `tty' command) that we're giving to
diff --git a/gdb/infrun.c b/gdb/infrun.c
index 4fde96800fb..0fe9fd0c6dc 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -62,7 +62,7 @@
 #include "thread-fsm.h"
 #include "gdbsupport/enum-flags.h"
 #include "progspace-and-thread.h"
-#include "gdbsupport/gdb_optional.h"
+#include <optional>
 #include "arch-utils.h"
 #include "gdbsupport/scope-exit.h"
 #include "gdbsupport/forward-scope-exit.h"
@@ -711,7 +711,7 @@ holding the child stopped.  Try \"set detach-on-fork\" or \
     {
       /* If FOLLOW_CHILD, we leave CHILD_INF as the current inferior
 	 (do not restore the parent as the current inferior).  */
-      gdb::optional<scoped_restore_current_thread> maybe_restore;
+      std::optional<scoped_restore_current_thread> maybe_restore;
 
       if (!follow_child && !sched_multi)
 	maybe_restore.emplace ();
@@ -4399,7 +4399,7 @@ fetch_inferior_event ()
        debugging.  If we're looking at traceframes while the target is
        running, we're going to need to get back to that mode after
        handling the event.  */
-    gdb::optional<scoped_restore_current_traceframe> maybe_restore_traceframe;
+    std::optional<scoped_restore_current_traceframe> maybe_restore_traceframe;
     if (non_stop)
       {
 	maybe_restore_traceframe.emplace ();
@@ -4772,7 +4772,7 @@ adjust_pc_after_break (struct thread_info *thread,
       || (target_is_non_stop_p ()
 	  && moribund_breakpoint_here_p (aspace, breakpoint_pc)))
     {
-      gdb::optional<scoped_restore_tmpl<int>> restore_operation_disable;
+      std::optional<scoped_restore_tmpl<int>> restore_operation_disable;
 
       if (record_full_is_used ())
 	restore_operation_disable.emplace
@@ -6722,7 +6722,7 @@ handle_signal_stop (struct execution_control_state *ecs)
 	  decr_pc = gdbarch_decr_pc_after_break (gdbarch);
 	  if (decr_pc != 0)
 	    {
-	      gdb::optional<scoped_restore_tmpl<int>>
+	      std::optional<scoped_restore_tmpl<int>>
 		restore_operation_disable;
 
 	      if (record_full_is_used ())
@@ -8930,7 +8930,7 @@ normal_stop ()
   else if (last.kind () != TARGET_WAITKIND_NO_RESUMED)
     finish_ptid = inferior_ptid;
 
-  gdb::optional<scoped_finish_thread_state> maybe_finish_thread_state;
+  std::optional<scoped_finish_thread_state> maybe_finish_thread_state;
   if (finish_ptid != null_ptid)
     {
       maybe_finish_thread_state.emplace
diff --git a/gdb/interps.c b/gdb/interps.c
index f91b2b62c1b..5f2a484a032 100644
--- a/gdb/interps.c
+++ b/gdb/interps.c
@@ -430,7 +430,7 @@ interps_notify_new_thread (thread_info *t)
 
 void
 interps_notify_thread_exited (thread_info *t,
-			      gdb::optional<ULONGEST> exit_code,
+			      std::optional<ULONGEST> exit_code,
 			      int silent)
 {
   interps_notify (&interp::on_thread_exited, t, exit_code, silent);
diff --git a/gdb/interps.h b/gdb/interps.h
index 287df2c8c81..986110b9b6a 100644
--- a/gdb/interps.h
+++ b/gdb/interps.h
@@ -123,7 +123,7 @@ class interp : public intrusive_list_node<interp>
 
   /* Notify the interpreter that thread T has exited.  */
   virtual void on_thread_exited (thread_info *,
-				 gdb::optional<ULONGEST> exit_code,
+				 std::optional<ULONGEST> exit_code,
 				 int silent) {}
 
   /* Notify the interpreter that inferior INF was added.  */
@@ -292,7 +292,7 @@ extern void interps_notify_new_thread (thread_info *t);
 
 /* Notify all interpreters that thread T has exited.  */
 extern void interps_notify_thread_exited (thread_info *t,
-					  gdb::optional<ULONGEST> exit_code,
+					  std::optional<ULONGEST> exit_code,
 					  int silent);
 
 /* Notify all interpreters that inferior INF was added.  */
diff --git a/gdb/jit.c b/gdb/jit.c
index 9e8325ab803..0e3a4285bdd 100644
--- a/gdb/jit.c
+++ b/gdb/jit.c
@@ -76,7 +76,7 @@ maint_info_jit_cmd (const char *args, int from_tty)
   inferior *inf = current_inferior ();
   bool printed_header = false;
 
-  gdb::optional<ui_out_emit_table> table_emitter;
+  std::optional<ui_out_emit_table> table_emitter;
 
   /* Print a line for each JIT-ed objfile.  */
   for (objfile *obj : inf->pspace->objfiles ())
diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c
index 9148dda4aad..42991c71266 100644
--- a/gdb/linux-nat.c
+++ b/gdb/linux-nat.c
@@ -4003,7 +4003,7 @@ linux_proc_xfer_memory_partial (int pid, gdb_byte *readbuf,
 static bool
 proc_mem_file_is_writable ()
 {
-  static gdb::optional<bool> writable;
+  static std::optional<bool> writable;
 
   if (writable.has_value ())
     return *writable;
@@ -4424,7 +4424,7 @@ linux_nat_target::fileio_open (struct inferior *inf, const char *filename,
 
 /* Implementation of to_fileio_readlink.  */
 
-gdb::optional<std::string>
+std::optional<std::string>
 linux_nat_target::fileio_readlink (struct inferior *inf, const char *filename,
 				   fileio_error *target_errno)
 {
diff --git a/gdb/linux-nat.h b/gdb/linux-nat.h
index 770fe924427..e9c3a1a7436 100644
--- a/gdb/linux-nat.h
+++ b/gdb/linux-nat.h
@@ -103,7 +103,7 @@ class linux_nat_target : public inf_ptrace_target
 		   int flags, int mode, int warn_if_slow,
 		   fileio_error *target_errno) override;
 
-  gdb::optional<std::string>
+  std::optional<std::string>
     fileio_readlink (struct inferior *inf,
 		     const char *filename,
 		     fileio_error *target_errno) override;
diff --git a/gdb/linux-tdep.c b/gdb/linux-tdep.c
index f7b8a594097..6dcc56cd562 100644
--- a/gdb/linux-tdep.c
+++ b/gdb/linux-tdep.c
@@ -38,7 +38,7 @@
 #include "gdbcmd.h"
 #include "gdbsupport/gdb_regex.h"
 #include "gdbsupport/enum-flags.h"
-#include "gdbsupport/gdb_optional.h"
+#include <optional>
 #include "gcore.h"
 #include "gcore-elf.h"
 #include "solib-svr4.h"
@@ -229,7 +229,7 @@ struct linux_info
   int vsyscall_range_p = 0;
 
   /* Inferior's displaced step buffers.  */
-  gdb::optional<displaced_step_buffers> disp_step_bufs;
+  std::optional<displaced_step_buffers> disp_step_bufs;
 };
 
 /* Per-inferior data key.  */
@@ -589,7 +589,7 @@ struct mapping_regexes
 static int
 mapping_is_anonymous_p (const char *filename)
 {
-  static gdb::optional<mapping_regexes> regexes;
+  static std::optional<mapping_regexes> regexes;
   static int init_regex_p = 0;
 
   if (!init_regex_p)
@@ -873,7 +873,7 @@ linux_info_proc (struct gdbarch *gdbarch, const char *args,
   if (cwd_f)
     {
       xsnprintf (filename, sizeof filename, "/proc/%ld/cwd", pid);
-      gdb::optional<std::string> contents
+      std::optional<std::string> contents
 	= target_fileio_readlink (NULL, filename, &target_errno);
       if (contents.has_value ())
 	gdb_printf ("cwd = '%s'\n", contents->c_str ());
@@ -883,7 +883,7 @@ linux_info_proc (struct gdbarch *gdbarch, const char *args,
   if (exe_f)
     {
       xsnprintf (filename, sizeof filename, "/proc/%ld/exe", pid);
-      gdb::optional<std::string> contents
+      std::optional<std::string> contents
 	= target_fileio_readlink (NULL, filename, &target_errno);
       if (contents.has_value ())
 	gdb_printf ("exe = '%s'\n", contents->c_str ());
@@ -2108,7 +2108,7 @@ linux_make_corefile_notes (struct gdbarch *gdbarch, bfd *obfd, int *note_size)
     return NULL;
 
   /* Auxillary vector.  */
-  gdb::optional<gdb::byte_vector> auxv =
+  std::optional<gdb::byte_vector> auxv =
     target_read_alloc (current_inferior ()->top_target (),
 		       TARGET_OBJECT_AUXV, NULL);
   if (auxv && !auxv->empty ())
@@ -2675,7 +2675,7 @@ linux_displaced_step_restore_all_in_ptid (inferior *parent_inf, ptid_t ptid)
 /* Helper for linux_get_hwcap and linux_get_hwcap2.  */
 
 static CORE_ADDR
-linux_get_hwcap_helper (const gdb::optional<gdb::byte_vector> &auxv,
+linux_get_hwcap_helper (const std::optional<gdb::byte_vector> &auxv,
 			target_ops *target, gdbarch *gdbarch, CORE_ADDR match)
 {
   CORE_ADDR field;
@@ -2688,7 +2688,7 @@ linux_get_hwcap_helper (const gdb::optional<gdb::byte_vector> &auxv,
 /* See linux-tdep.h.  */
 
 CORE_ADDR
-linux_get_hwcap (const gdb::optional<gdb::byte_vector> &auxv,
+linux_get_hwcap (const std::optional<gdb::byte_vector> &auxv,
 		 target_ops *target, gdbarch *gdbarch)
 {
   return linux_get_hwcap_helper (auxv, target, gdbarch, AT_HWCAP);
@@ -2707,7 +2707,7 @@ linux_get_hwcap ()
 /* See linux-tdep.h.  */
 
 CORE_ADDR
-linux_get_hwcap2 (const gdb::optional<gdb::byte_vector> &auxv,
+linux_get_hwcap2 (const std::optional<gdb::byte_vector> &auxv,
 		  target_ops *target, gdbarch *gdbarch)
 {
   return linux_get_hwcap_helper (auxv, target, gdbarch, AT_HWCAP2);
diff --git a/gdb/linux-tdep.h b/gdb/linux-tdep.h
index e09a6ef32b1..819b221e599 100644
--- a/gdb/linux-tdep.h
+++ b/gdb/linux-tdep.h
@@ -94,7 +94,7 @@ extern int linux_is_uclinux (void);
    parse auxv entries.
 
    On error, 0 is returned.  */
-extern CORE_ADDR linux_get_hwcap (const gdb::optional<gdb::byte_vector> &auxv,
+extern CORE_ADDR linux_get_hwcap (const std::optional<gdb::byte_vector> &auxv,
 				  struct target_ops *target, gdbarch *gdbarch);
 
 /* Same as the above, but obtain all the inputs from the current inferior.  */
@@ -105,7 +105,7 @@ extern CORE_ADDR linux_get_hwcap ();
    parse auxv entries.
 
    On error, 0 is returned.  */
-extern CORE_ADDR linux_get_hwcap2 (const gdb::optional<gdb::byte_vector> &auxv,
+extern CORE_ADDR linux_get_hwcap2 (const std::optional<gdb::byte_vector> &auxv,
 				   struct target_ops *target, gdbarch *gdbarch);
 
 /* Same as the above, but obtain all the inputs from the current inferior.  */
diff --git a/gdb/linux-thread-db.c b/gdb/linux-thread-db.c
index cef78f599be..c2ec422b7f3 100644
--- a/gdb/linux-thread-db.c
+++ b/gdb/linux-thread-db.c
@@ -312,7 +312,7 @@ struct thread_db_thread_info : public private_thread_info
   /* Cached thread state.  */
   td_thrhandle_t th {};
   thread_t tid {};
-  gdb::optional<gdb::byte_vector> thread_handle;
+  std::optional<gdb::byte_vector> thread_handle;
 };
 
 static thread_db_thread_info *
diff --git a/gdb/main.c b/gdb/main.c
index 2da39f89a90..486c1ffe071 100644
--- a/gdb/main.c
+++ b/gdb/main.c
@@ -361,7 +361,7 @@ get_init_files (std::vector<std::string> *system_gdbinit,
 {
   /* Cache the file lookup object so we only actually search for the files
      once.  */
-  static gdb::optional<gdb_initfile_finder> init_files;
+  static std::optional<gdb_initfile_finder> init_files;
   if (!init_files.has_value ())
     init_files.emplace (GDBINIT, SYSTEM_GDBINIT, SYSTEM_GDBINIT_RELOCATABLE,
 			SYSTEM_GDBINIT_DIR, SYSTEM_GDBINIT_DIR_RELOCATABLE,
@@ -381,7 +381,7 @@ get_earlyinit_files (std::string *home_gdbearlyinit)
 {
   /* Cache the file lookup object so we only actually search for the files
      once.  */
-  static gdb::optional<gdb_initfile_finder> init_files;
+  static std::optional<gdb_initfile_finder> init_files;
   if (!init_files.has_value ())
     init_files.emplace (GDBEARLYINIT, nullptr, false, nullptr, false, false);
 
diff --git a/gdb/mi/mi-cmd-stack.c b/gdb/mi/mi-cmd-stack.c
index e473be7d465..6982338751a 100644
--- a/gdb/mi/mi-cmd-stack.c
+++ b/gdb/mi/mi-cmd-stack.c
@@ -34,7 +34,7 @@
 #include "extension.h"
 #include <ctype.h>
 #include "mi-parse.h"
-#include "gdbsupport/gdb_optional.h"
+#include <optional>
 #include "gdbsupport/gdb-safe-ctype.h"
 #include "inferior.h"
 #include "observable.h"
@@ -515,7 +515,7 @@ list_arg_or_local (const struct frame_arg *arg, enum what_to_list what,
 					     arg->val->type ()->length ()))))
     return;
 
-  gdb::optional<ui_out_emit_tuple> tuple_emitter;
+  std::optional<ui_out_emit_tuple> tuple_emitter;
   if (values != PRINT_NO_VALUES || what == all)
     tuple_emitter.emplace (uiout, nullptr);
 
diff --git a/gdb/mi/mi-cmd-var.c b/gdb/mi/mi-cmd-var.c
index 8b4dd6d0c96..87c54c8c95d 100644
--- a/gdb/mi/mi-cmd-var.c
+++ b/gdb/mi/mi-cmd-var.c
@@ -30,7 +30,7 @@
 #include "mi-getopt.h"
 #include "gdbthread.h"
 #include "mi-parse.h"
-#include "gdbsupport/gdb_optional.h"
+#include <optional>
 #include "inferior.h"
 
 static void varobj_update_one (struct varobj *var,
diff --git a/gdb/mi/mi-cmds.c b/gdb/mi/mi-cmds.c
index 5ea31fc98d1..dbee2d010ea 100644
--- a/gdb/mi/mi-cmds.c
+++ b/gdb/mi/mi-cmds.c
@@ -183,7 +183,7 @@ mi_command::mi_command (const char *name, int *suppress_notification)
 
 /* See mi-cmds.h.  */
 
-gdb::optional<scoped_restore_tmpl<int>>
+std::optional<scoped_restore_tmpl<int>>
 mi_command::do_suppress_notification () const
 {
   if (m_suppress_notification != nullptr)
diff --git a/gdb/mi/mi-cmds.h b/gdb/mi/mi-cmds.h
index e67c486a997..f99c24313b9 100644
--- a/gdb/mi/mi-cmds.h
+++ b/gdb/mi/mi-cmds.h
@@ -23,7 +23,7 @@
 #define MI_MI_CMDS_H
 
 #include "gdbsupport/function-view.h"
-#include "gdbsupport/gdb_optional.h"
+#include <optional>
 #include "mi/mi-main.h"
 
 enum print_values {
@@ -180,12 +180,12 @@ struct mi_command
 
   /* If this command was created with a suppress notifications pointer,
      then this function will set the suppress flag and return a
-     gdb::optional with its value set to an object that will restore the
+     std::optional with its value set to an object that will restore the
      previous value of the suppress notifications flag.
 
      If this command was created without a suppress notifications points,
-     then this function returns an empty gdb::optional.  */
-  gdb::optional<scoped_restore_tmpl<int>> do_suppress_notification () const;
+     then this function returns an empty std::optional.  */
+  std::optional<scoped_restore_tmpl<int>> do_suppress_notification () const;
 
 private:
 
diff --git a/gdb/mi/mi-interp.c b/gdb/mi/mi-interp.c
index 0d3c8235c2c..a0e41006c56 100644
--- a/gdb/mi/mi-interp.c
+++ b/gdb/mi/mi-interp.c
@@ -278,7 +278,7 @@ mi_interp::on_new_thread (thread_info *t)
 
 void
 mi_interp::on_thread_exited (thread_info *t,
-			     gdb::optional<ULONGEST> /* exit_code */,
+			     std::optional<ULONGEST> /* exit_code */,
 			     int /* silent */)
 {
   target_terminal::scoped_restore_terminal_state term_state;
diff --git a/gdb/mi/mi-interp.h b/gdb/mi/mi-interp.h
index f9af61f0a57..353c0c6d593 100644
--- a/gdb/mi/mi-interp.h
+++ b/gdb/mi/mi-interp.h
@@ -51,7 +51,7 @@ class mi_interp final : public interp
   void on_command_error () override;
   void on_user_selected_context_changed (user_selected_what selection) override;
   void on_new_thread (thread_info *t) override;
-  void on_thread_exited (thread_info *t, gdb::optional<ULONGEST> exit_code,
+  void on_thread_exited (thread_info *t, std::optional<ULONGEST> exit_code,
 			 int silent) override;
   void on_inferior_added (inferior *inf) override;
   void on_inferior_appeared (inferior *inf) override;
diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c
index d750371f917..3fa36fc77ed 100644
--- a/gdb/mi/mi-main.c
+++ b/gdb/mi/mi-main.c
@@ -52,7 +52,7 @@
 #include "extension.h"
 #include "gdbcmd.h"
 #include "observable.h"
-#include "gdbsupport/gdb_optional.h"
+#include <optional>
 #include "gdbsupport/byte-vector.h"
 
 #include <ctype.h>
@@ -2097,7 +2097,7 @@ mi_cmd_execute (struct mi_parse *parse)
 
   user_selected_context current_user_selected_context;
 
-  gdb::optional<scoped_restore_current_thread> thread_saver;
+  std::optional<scoped_restore_current_thread> thread_saver;
   if (parse->thread != -1)
     {
       thread_info *tp = find_thread_global_id (parse->thread);
@@ -2114,7 +2114,7 @@ mi_cmd_execute (struct mi_parse *parse)
       switch_to_thread (tp);
     }
 
-  gdb::optional<scoped_restore_selected_frame> frame_saver;
+  std::optional<scoped_restore_selected_frame> frame_saver;
   if (parse->frame != -1)
     {
       frame_info_ptr fid;
@@ -2132,7 +2132,7 @@ mi_cmd_execute (struct mi_parse *parse)
 	error (_("Invalid frame id: %d"), frame);
     }
 
-  gdb::optional<scoped_restore_current_language> lang_saver;
+  std::optional<scoped_restore_current_language> lang_saver;
   if (parse->language != language_unknown)
     {
       lang_saver.emplace ();
@@ -2143,7 +2143,7 @@ mi_cmd_execute (struct mi_parse *parse)
 
   gdb_assert (parse->cmd != nullptr);
 
-  gdb::optional<scoped_restore_tmpl<int>> restore_suppress_notification
+  std::optional<scoped_restore_tmpl<int>> restore_suppress_notification
     = parse->cmd->do_suppress_notification ();
 
   parse->cmd->invoke (parse);
@@ -2514,7 +2514,7 @@ print_variable_or_computed (const char *expression, enum print_values values)
   else
     val = expr->evaluate ();
 
-  gdb::optional<ui_out_emit_tuple> tuple_emitter;
+  std::optional<ui_out_emit_tuple> tuple_emitter;
   if (values != PRINT_NO_VALUES)
     tuple_emitter.emplace (uiout, nullptr);
   uiout->field_string ("name", expression);
diff --git a/gdb/nat/linux-osdata.c b/gdb/nat/linux-osdata.c
index 103b7ab26cd..e85384660d4 100644
--- a/gdb/nat/linux-osdata.c
+++ b/gdb/nat/linux-osdata.c
@@ -66,7 +66,7 @@ linux_common_core_of_thread (ptid_t ptid)
   sprintf (filename, "/proc/%lld/task/%lld/stat",
 	   (PID_T) ptid.pid (), (PID_T) ptid.lwp ());
 
-  gdb::optional<std::string> content = read_text_file_to_string (filename);
+  std::optional<std::string> content = read_text_file_to_string (filename);
   if (!content.has_value ())
     return -1;
 
@@ -257,10 +257,10 @@ get_cores_used_by_process (PID_T pid, int *cores, const int num_cores)
 
 /* get_core_array_size helper that uses /sys/devices/system/cpu/possible.  */
 
-static gdb::optional<size_t>
+static std::optional<size_t>
 get_core_array_size_using_sys_possible ()
 {
-  gdb::optional<std::string> possible
+  std::optional<std::string> possible
     = read_text_file_to_string ("/sys/devices/system/cpu/possible");
 
   if (!possible.has_value ())
@@ -310,7 +310,7 @@ get_core_array_size ()
      we are in a container that has access to a subset of the host's cores.
      It will return a size that considers all the CPU cores available to the
      host.  If that fails for some reason, fall back to sysconf.  */
-  gdb::optional<size_t> count = get_core_array_size_using_sys_possible ();
+  std::optional<size_t> count = get_core_array_size_using_sys_possible ();
   if (count.has_value ())
     return *count;
 
diff --git a/gdb/nat/windows-nat.c b/gdb/nat/windows-nat.c
index 8028494de20..bf4c4387886 100644
--- a/gdb/nat/windows-nat.c
+++ b/gdb/nat/windows-nat.c
@@ -698,10 +698,10 @@ windows_process_info::matching_pending_stop (bool debug_events)
 
 /* See nat/windows-nat.h.  */
 
-gdb::optional<pending_stop>
+std::optional<pending_stop>
 windows_process_info::fetch_pending_stop (bool debug_events)
 {
-  gdb::optional<pending_stop> result;
+  std::optional<pending_stop> result;
   for (auto iter = pending_stops.begin ();
        iter != pending_stops.end ();
        ++iter)
@@ -818,7 +818,7 @@ create_process_wrapper (FUNC *do_create_process, const CHAR *image,
 	  InitializeProcThreadAttributeList (info_ex.lpAttributeList,
 					     1, 0, &size);
 
-	  gdb::optional<BOOL> return_value;
+	  std::optional<BOOL> return_value;
 	  DWORD attr_flags = relocate_aslr_flags;
 	  if (!UpdateProcThreadAttribute (info_ex.lpAttributeList, 0,
 					  mitigation_policy,
diff --git a/gdb/nat/windows-nat.h b/gdb/nat/windows-nat.h
index e3ea7dbb525..0dc37b29705 100644
--- a/gdb/nat/windows-nat.h
+++ b/gdb/nat/windows-nat.h
@@ -23,7 +23,7 @@
 #include <psapi.h>
 #include <vector>
 
-#include "gdbsupport/gdb_optional.h"
+#include <optional>
 #include "target/waitstatus.h"
 
 #define STATUS_WX86_BREAKPOINT 0x4000001F
@@ -246,7 +246,7 @@ struct windows_process_info
      remove it from the list of pending stops, set 'current_event', and
      return it.  Otherwise, return an empty optional.  */
 
-  gdb::optional<pending_stop> fetch_pending_stop (bool debug_events);
+  std::optional<pending_stop> fetch_pending_stop (bool debug_events);
 
   const char *pid_to_exec_file (int);
 
diff --git a/gdb/observable.h b/gdb/observable.h
index acb05e9b535..5cf2d159096 100644
--- a/gdb/observable.h
+++ b/gdb/observable.h
@@ -124,7 +124,7 @@ extern observable<struct thread_info */* t */> new_thread;
    removing the thread from its tables without wanting to notify the
    CLI about it.  */
 extern observable<thread_info */* t */,
-		  gdb::optional<ULONGEST> /* exit_code */,
+		  std::optional<ULONGEST> /* exit_code */,
 		  bool /* silent */> thread_exit;
 
 /* An explicit stop request was issued to PTID.  If PTID equals
diff --git a/gdb/osdata.c b/gdb/osdata.c
index 21b8eb01f6b..cb1e950df5c 100644
--- a/gdb/osdata.c
+++ b/gdb/osdata.c
@@ -162,7 +162,7 @@ std::unique_ptr<osdata>
 get_osdata (const char *type)
 {
   std::unique_ptr<osdata> osdata;
-  gdb::optional<gdb::char_vector> xml = target_get_osdata (type);
+  std::optional<gdb::char_vector> xml = target_get_osdata (type);
 
   if (xml)
     {
diff --git a/gdb/parse.c b/gdb/parse.c
index c69b53addff..b57d112fafd 100644
--- a/gdb/parse.c
+++ b/gdb/parse.c
@@ -49,7 +49,7 @@
 #include "objfiles.h"
 #include "user-regs.h"
 #include <algorithm>
-#include "gdbsupport/gdb_optional.h"
+#include <optional>
 #include "c-exp.h"
 
 static unsigned int expressiondebug = 0;
@@ -471,7 +471,7 @@ parse_expression (const char *string, innermost_block_tracker *tracker,
 expression_up
 parse_expression_with_language (const char *string, enum language lang)
 {
-  gdb::optional<scoped_restore_current_language> lang_saver;
+  std::optional<scoped_restore_current_language> lang_saver;
   if (current_language->la_language != lang)
     {
       lang_saver.emplace ();
diff --git a/gdb/ppc-linux-nat.c b/gdb/ppc-linux-nat.c
index a0205119f00..f34de9cb666 100644
--- a/gdb/ppc-linux-nat.c
+++ b/gdb/ppc-linux-nat.c
@@ -464,7 +464,7 @@ class ppc_linux_dreg_interface
     };
 
   /* The interface option.  Initialized if has_value () returns true.  */
-  gdb::optional<enum debug_reg_interface> m_interface;
+  std::optional<enum debug_reg_interface> m_interface;
 
   /* The info returned by the kernel with PPC_PTRACE_GETHWDBGINFO.  Only
      valid if we determined that the interface is HWDEBUG.  */
@@ -485,7 +485,7 @@ struct ppc_linux_process_info
   /* The watchpoint value that GDB requested for this process.
 
      Only used when the interface is DEBUGREG.  */
-  gdb::optional<long> requested_wp_val;
+  std::optional<long> requested_wp_val;
 };
 
 struct ppc_linux_nat_target final : public linux_nat_target
diff --git a/gdb/ppc-linux-tdep.c b/gdb/ppc-linux-tdep.c
index 7c75bb5693d..c8f138f3b3e 100644
--- a/gdb/ppc-linux-tdep.c
+++ b/gdb/ppc-linux-tdep.c
@@ -1609,7 +1609,7 @@ ppc_linux_core_read_description (struct gdbarch *gdbarch,
   if (vsx)
     features.vsx = true;
 
-  gdb::optional<gdb::byte_vector> auxv = target_read_auxv_raw (target);
+  std::optional<gdb::byte_vector> auxv = target_read_auxv_raw (target);
   CORE_ADDR hwcap = linux_get_hwcap (auxv, target, gdbarch);
 
   features.isa205 = ppc_linux_has_isa205 (hwcap);
diff --git a/gdb/ppc-tdep.h b/gdb/ppc-tdep.h
index ddeb810f35b..b24154998ec 100644
--- a/gdb/ppc-tdep.h
+++ b/gdb/ppc-tdep.h
@@ -447,7 +447,7 @@ struct ppc_inferior_data
   /* This is an optional in case we add more fields to ppc_inferior_data, we
      don't want it instantiated as soon as we get the ppc_inferior_data for an
      inferior.  */
-  gdb::optional<displaced_step_buffers> disp_step_buf;
+  std::optional<displaced_step_buffers> disp_step_buf;
 };
 
 extern ppc_inferior_data * get_ppc_per_inferior (inferior *inf);
diff --git a/gdb/printcmd.c b/gdb/printcmd.c
index 5e9c8a5b222..5afbc565cf7 100644
--- a/gdb/printcmd.c
+++ b/gdb/printcmd.c
@@ -52,7 +52,7 @@
 #include "gdbsupport/format.h"
 #include "source.h"
 #include "gdbsupport/byte-vector.h"
-#include "gdbsupport/gdb_optional.h"
+#include <optional>
 #include "gdbsupport/gdb-safe-ctype.h"
 #include "gdbsupport/rsp-low.h"
 #include "inferior.h"
@@ -435,7 +435,7 @@ print_scalar_formatted (const gdb_byte *valaddr, struct type *type,
   /* Some cases below will unpack the value again.  In the biased
      range case, we want to avoid this, so we store the unpacked value
      here for possible use later.  */
-  gdb::optional<LONGEST> val_long;
+  std::optional<LONGEST> val_long;
   if ((is_fixed_point_type (type)
        && (options->format == 'o'
 	   || options->format == 'x'
@@ -2521,7 +2521,7 @@ printf_wide_c_string (struct ui_file *stream, const char *format,
   struct type *wctype = lookup_typename (current_language,
 					 "wchar_t", NULL, 0);
   int wcwidth = wctype->length ();
-  gdb::optional<gdb::byte_vector> tem_str;
+  std::optional<gdb::byte_vector> tem_str;
 
   if (value->lval () == lval_internalvar
       && c_is_string_type_p (value->type ()))
diff --git a/gdb/probe.c b/gdb/probe.c
index 13e95bcfb20..d9079be4d62 100644
--- a/gdb/probe.c
+++ b/gdb/probe.c
@@ -36,7 +36,7 @@
 #include "location.h"
 #include <ctype.h>
 #include <algorithm>
-#include "gdbsupport/gdb_optional.h"
+#include <optional>
 
 /* Class that implements the static probe methods for "any" probe.  */
 
@@ -280,7 +280,7 @@ collect_probes (const std::string &objname, const std::string &provider,
 		const std::string &probe_name, const static_probe_ops *spops)
 {
   std::vector<bound_probe> result;
-  gdb::optional<compiled_regex> obj_pat, prov_pat, probe_pat;
+  std::optional<compiled_regex> obj_pat, prov_pat, probe_pat;
 
   if (!provider.empty ())
     prov_pat.emplace (provider.c_str (), REG_NOSUB,
@@ -683,9 +683,9 @@ disable_probes_command (const char *arg, int from_tty)
 static bool ignore_probes_p = false;
 static bool ignore_probes_idx = 0;
 static bool ignore_probes_verbose_p;
-static gdb::optional<compiled_regex> ignore_probes_prov_pat[2];
-static gdb::optional<compiled_regex> ignore_probes_name_pat[2];
-static gdb::optional<compiled_regex> ignore_probes_obj_pat[2];
+static std::optional<compiled_regex> ignore_probes_prov_pat[2];
+static std::optional<compiled_regex> ignore_probes_name_pat[2];
+static std::optional<compiled_regex> ignore_probes_obj_pat[2];
 
 /* See comments in probe.h.  */
 
@@ -696,11 +696,11 @@ ignore_probe_p (const char *provider, const char *name,
   if (!ignore_probes_p)
     return false;
 
-  gdb::optional<compiled_regex> &re_prov
+  std::optional<compiled_regex> &re_prov
     = ignore_probes_prov_pat[ignore_probes_idx];
-  gdb::optional<compiled_regex> &re_name
+  std::optional<compiled_regex> &re_name
     = ignore_probes_name_pat[ignore_probes_idx];
-  gdb::optional<compiled_regex> &re_obj
+  std::optional<compiled_regex> &re_obj
     = ignore_probes_obj_pat[ignore_probes_idx];
 
   bool res
@@ -755,11 +755,11 @@ ignore_probes_command (const char *arg, int from_tty)
   /* Parse the regular expressions, making sure that the old regular
      expressions are still valid if an exception is throw.  */
   int new_ignore_probes_idx = 1 - ignore_probes_idx;
-  gdb::optional<compiled_regex> &re_prov
+  std::optional<compiled_regex> &re_prov
     = ignore_probes_prov_pat[new_ignore_probes_idx];
-  gdb::optional<compiled_regex> &re_name
+  std::optional<compiled_regex> &re_name
     = ignore_probes_name_pat[new_ignore_probes_idx];
-  gdb::optional<compiled_regex> &re_obj
+  std::optional<compiled_regex> &re_obj
     = ignore_probes_obj_pat[new_ignore_probes_idx];
   re_prov.reset ();
   re_name.reset ();
diff --git a/gdb/procfs.c b/gdb/procfs.c
index 0e8a08f99d3..f8b88bf8754 100644
--- a/gdb/procfs.c
+++ b/gdb/procfs.c
@@ -3615,7 +3615,7 @@ procfs_target::make_corefile_notes (bfd *obfd, int *note_size)
   proc_iterate_over_threads (pi, procfs_corefile_thread_callback,
 			     &thread_args);
 
-  gdb::optional<gdb::byte_vector> auxv =
+  std::optional<gdb::byte_vector> auxv =
     target_read_alloc (current_inferior ()->top_target (),
 		       TARGET_OBJECT_AUXV, NULL);
   if (auxv && !auxv->empty ())
diff --git a/gdb/psymtab.c b/gdb/psymtab.c
index 41ecf31424b..484d4eaa651 100644
--- a/gdb/psymtab.c
+++ b/gdb/psymtab.c
@@ -1025,7 +1025,7 @@ psymbol_functions::expand_symtabs_matching
   for (partial_symtab *ps : partial_symbols (objfile))
     ps->searched_flag = PST_NOT_SEARCHED;
 
-  gdb::optional<lookup_name_info> psym_lookup_name;
+  std::optional<lookup_name_info> psym_lookup_name;
   if (lookup_name != nullptr)
     psym_lookup_name = lookup_name->make_ignore_params ();
 
diff --git a/gdb/psymtab.h b/gdb/psymtab.h
index 41337d0db89..4bafc6e998e 100644
--- a/gdb/psymtab.h
+++ b/gdb/psymtab.h
@@ -131,7 +131,7 @@ class psymtab_storage
   /* The obstack where allocations are made.  This is lazily allocated
      so that we don't waste memory when there are no psymtabs.  */
 
-  gdb::optional<auto_obstack> m_obstack;
+  std::optional<auto_obstack> m_obstack;
 };
 
 /* A partial_symbol records the name, domain, and address class of
diff --git a/gdb/python/py-disasm.c b/gdb/python/py-disasm.c
index 6f0fed137e6..7a13b81a0c2 100644
--- a/gdb/python/py-disasm.c
+++ b/gdb/python/py-disasm.c
@@ -176,7 +176,7 @@ struct gdbpy_disassembler : public gdb_disassemble_info
   /* Return a reference to an optional that contains the address at which a
      memory error occurred.  The optional will only have a value if a
      memory error actually occurred.  */
-  const gdb::optional<CORE_ADDR> &memory_error_address () const
+  const std::optional<CORE_ADDR> &memory_error_address () const
   { return m_memory_error_address; }
 
   /* Return the content of the disassembler as a string.  The contents are
@@ -221,7 +221,7 @@ struct gdbpy_disassembler : public gdb_disassemble_info
 
   /* When the user indicates that a memory error has occurred then the
      address of the memory error is stored in here.  */
-  gdb::optional<CORE_ADDR> m_memory_error_address;
+  std::optional<CORE_ADDR> m_memory_error_address;
 
   /* When the user calls the builtin_disassemble function, if they pass a
      memory source object then a pointer to the object is placed in here,
@@ -245,7 +245,7 @@ struct gdbpy_disassembler : public gdb_disassemble_info
 
   /* Store a single exception.  This is used to pass Python exceptions back
      from ::memory_read to disasmpy_builtin_disassemble.  */
-  gdb::optional<gdbpy_err_fetch> m_stored_exception;
+  std::optional<gdbpy_err_fetch> m_stored_exception;
 };
 
 /* Return true if OBJ is still valid, otherwise, return false.  A valid OBJ
@@ -1215,7 +1215,7 @@ struct scoped_disasm_info_object
 
 /* See python-internal.h.  */
 
-gdb::optional<int>
+std::optional<int>
 gdbpy_print_insn (struct gdbarch *gdbarch, CORE_ADDR memaddr,
 		  disassemble_info *info)
 {
@@ -1294,7 +1294,7 @@ gdbpy_print_insn (struct gdbarch *gdbarch, CORE_ADDR memaddr,
 	    addr = disasm_info->address;
 
 	  info->memory_error_func (-1, addr, info);
-	  return gdb::optional<int> (-1);
+	  return std::optional<int> (-1);
 	}
       else if (PyErr_ExceptionMatches (gdbpy_gdberror_exc))
 	{
@@ -1302,12 +1302,12 @@ gdbpy_print_insn (struct gdbarch *gdbarch, CORE_ADDR memaddr,
 	  gdb::unique_xmalloc_ptr<char> msg = err.to_string ();
 
 	  info->fprintf_func (info->stream, "%s", msg.get ());
-	  return gdb::optional<int> (-1);
+	  return std::optional<int> (-1);
 	}
       else
 	{
 	  gdbpy_print_stack ();
-	  return gdb::optional<int> (-1);
+	  return std::optional<int> (-1);
 	}
 
     }
@@ -1326,7 +1326,7 @@ gdbpy_print_insn (struct gdbarch *gdbarch, CORE_ADDR memaddr,
       PyErr_SetString (PyExc_TypeError,
 		       _("Result is not a DisassemblerResult."));
       gdbpy_print_stack ();
-      return gdb::optional<int> (-1);
+      return std::optional<int> (-1);
     }
 
   /* The result from the Python disassembler has the correct type.  Convert
@@ -1345,7 +1345,7 @@ gdbpy_print_insn (struct gdbarch *gdbarch, CORE_ADDR memaddr,
 	(PyExc_ValueError,
 	 _("Invalid length attribute: length must be greater than 0."));
       gdbpy_print_stack ();
-      return gdb::optional<int> (-1);
+      return std::optional<int> (-1);
     }
   if (length > max_insn_length)
     {
@@ -1354,7 +1354,7 @@ gdbpy_print_insn (struct gdbarch *gdbarch, CORE_ADDR memaddr,
 	 _("Invalid length attribute: length %d greater than architecture maximum of %d"),
 	 length, max_insn_length);
       gdbpy_print_stack ();
-      return gdb::optional<int> (-1);
+      return std::optional<int> (-1);
     }
 
   /* It is impossible to create a DisassemblerResult object with an empty
@@ -1390,7 +1390,7 @@ gdbpy_print_insn (struct gdbarch *gdbarch, CORE_ADDR memaddr,
 	}
     }
 
-  return gdb::optional<int> (length);
+  return std::optional<int> (length);
 }
 
 /* The tp_dealloc callback for the DisassemblerResult type.  Takes care of
diff --git a/gdb/python/py-framefilter.c b/gdb/python/py-framefilter.c
index e555dc3d879..dc7e47d70f0 100644
--- a/gdb/python/py-framefilter.c
+++ b/gdb/python/py-framefilter.c
@@ -32,7 +32,7 @@
 #include "demangle.h"
 #include "mi/mi-cmds.h"
 #include "python-internal.h"
-#include "gdbsupport/gdb_optional.h"
+#include <optional>
 #include "cli/cli-style.h"
 
 enum mi_print_types
@@ -322,7 +322,7 @@ py_print_single_arg (struct ui_out *out,
   else
     val = fv;
 
-  gdb::optional<ui_out_emit_tuple> maybe_tuple;
+  std::optional<ui_out_emit_tuple> maybe_tuple;
 
   /*  MI has varying rules for tuples, but generally if there is only
       one element in each item in the list, do not start a tuple.  The
@@ -562,7 +562,7 @@ enumerate_locals (PyObject *iter,
       struct symbol *sym;
       const struct block *sym_block;
       int local_indent = 8 + (8 * indent);
-      gdb::optional<ui_out_emit_tuple> tuple;
+      std::optional<ui_out_emit_tuple> tuple;
 
       gdbpy_ref<> item (PyIter_Next (iter));
       if (item == NULL)
@@ -773,7 +773,7 @@ py_print_frame (PyObject *filter, frame_filter_flags flags,
   get_user_print_options (&opts);
   if (print_frame_info)
     {
-      gdb::optional<enum print_what> user_frame_info_print_what;
+      std::optional<enum print_what> user_frame_info_print_what;
 
       get_user_print_what_frame_info (&user_frame_info_print_what);
       if (!out->is_mi_like_p () && user_frame_info_print_what.has_value ())
@@ -808,7 +808,7 @@ py_print_frame (PyObject *filter, frame_filter_flags flags,
       return EXT_LANG_BT_OK;
     }
 
-  gdb::optional<ui_out_emit_tuple> tuple;
+  std::optional<ui_out_emit_tuple> tuple;
 
   /* -stack-list-locals does not require a
      wrapping frame attribute.  */
diff --git a/gdb/python/py-inferior.c b/gdb/python/py-inferior.c
index c0bd6a69895..ed153d668ac 100644
--- a/gdb/python/py-inferior.c
+++ b/gdb/python/py-inferior.c
@@ -364,7 +364,7 @@ add_thread_object (struct thread_info *tp)
 
 static void
 delete_thread_object (thread_info *tp,
-		      gdb::optional<ULONGEST> /* exit_code */,
+		      std::optional<ULONGEST> /* exit_code */,
 		      bool /* silent */)
 {
   if (!gdb_python_initialized)
diff --git a/gdb/python/py-mi.c b/gdb/python/py-mi.c
index a43fac98c43..c338636b3c1 100644
--- a/gdb/python/py-mi.c
+++ b/gdb/python/py-mi.c
@@ -146,7 +146,7 @@ class py_ui_out : public ui_out
 
   /* If an error occurred, this holds the exception information for
      use by the 'release' method.  */
-  gdb::optional<gdbpy_err_fetch> m_error;
+  std::optional<gdbpy_err_fetch> m_error;
 
   /* Return a reference to the object under construction.  */
   object_desc &current ()
diff --git a/gdb/python/py-utils.c b/gdb/python/py-utils.c
index 15520849f15..f1ca9ea0a5d 100644
--- a/gdb/python/py-utils.c
+++ b/gdb/python/py-utils.c
@@ -469,12 +469,12 @@ gdbpy_fix_doc_string_indentation (gdb::unique_xmalloc_ptr<char> doc)
      (user left a single stray space at the start of an otherwise blank
      line), we don't consider lines without content when updating the
      MIN_WHITESPACE value.  */
-  gdb::optional<int> min_whitespace;
+  std::optional<int> min_whitespace;
 
   /* The index into WS_INFO at which the processing of DOC can be
      considered "all done", that is, after this point there are no further
      lines with useful content and we should just stop.  */
-  gdb::optional<size_t> all_done_idx;
+  std::optional<size_t> all_done_idx;
 
   /* White-space information for each line in DOC.  */
   std::vector<line_whitespace> ws_info;
diff --git a/gdb/python/python-internal.h b/gdb/python/python-internal.h
index 847bed84dfe..86eb5436f2a 100644
--- a/gdb/python/python-internal.h
+++ b/gdb/python/python-internal.h
@@ -732,7 +732,7 @@ class gdbpy_enter
 
   /* An optional is used here because we don't want to call
      PyErr_Fetch too early.  */
-  gdb::optional<gdbpy_err_fetch> m_error;
+  std::optional<gdbpy_err_fetch> m_error;
 };
 
 /* Like gdbpy_enter, but takes a varobj.  This is a subclass just to
@@ -953,7 +953,7 @@ extern gdb::unique_xmalloc_ptr<char> gdbpy_fix_doc_string_indentation
 
    If no instruction can be disassembled then return an empty value.  */
 
-extern gdb::optional<int> gdbpy_print_insn (struct gdbarch *gdbarch,
+extern std::optional<int> gdbpy_print_insn (struct gdbarch *gdbarch,
 					    CORE_ADDR address,
 					    disassemble_info *info);
 
diff --git a/gdb/python/python.c b/gdb/python/python.c
index d3dea088c3b..5fc883745db 100644
--- a/gdb/python/python.c
+++ b/gdb/python/python.c
@@ -121,9 +121,9 @@ static void gdbpy_set_quit_flag (const struct extension_language_defn *);
 static int gdbpy_check_quit_flag (const struct extension_language_defn *);
 static enum ext_lang_rc gdbpy_before_prompt_hook
   (const struct extension_language_defn *, const char *current_gdb_prompt);
-static gdb::optional<std::string> gdbpy_colorize
+static std::optional<std::string> gdbpy_colorize
   (const std::string &filename, const std::string &contents);
-static gdb::optional<std::string> gdbpy_colorize_disasm
+static std::optional<std::string> gdbpy_colorize_disasm
   (const std::string &content, gdbarch *gdbarch);
 
 /* The interface between gdb proper and loading of python scripts.  */
@@ -1191,7 +1191,7 @@ gdbpy_before_prompt_hook (const struct extension_language_defn *extlang,
 
 /* This is the extension_language_ops.colorize "method".  */
 
-static gdb::optional<std::string>
+static std::optional<std::string>
 gdbpy_colorize (const std::string &filename, const std::string &contents)
 {
   if (!gdb_python_initialized)
@@ -1268,7 +1268,7 @@ gdbpy_colorize (const std::string &filename, const std::string &contents)
 
 /* This is the extension_language_ops.colorize_disasm "method".  */
 
-static gdb::optional<std::string>
+static std::optional<std::string>
 gdbpy_colorize_disasm (const std::string &content, gdbarch *gdbarch)
 {
   if (!gdb_python_initialized)
diff --git a/gdb/ravenscar-thread.c b/gdb/ravenscar-thread.c
index 3558cfd3875..f147b66b3c6 100644
--- a/gdb/ravenscar-thread.c
+++ b/gdb/ravenscar-thread.c
@@ -685,7 +685,7 @@ ravenscar_thread_target::fetch_registers (struct regcache *regcache,
       struct gdbarch *gdbarch = regcache->arch ();
       bool is_active = task_is_currently_active (ptid);
       struct ravenscar_arch_ops *arch_ops = gdbarch_ravenscar_ops (gdbarch);
-      gdb::optional<fpu_state> fp_state;
+      std::optional<fpu_state> fp_state;
 
       int low_reg = regnum == -1 ? 0 : regnum;
       int high_reg = regnum == -1 ? gdbarch_num_regs (gdbarch) : regnum + 1;
@@ -731,7 +731,7 @@ ravenscar_thread_target::store_registers (struct regcache *regcache,
       struct gdbarch *gdbarch = regcache->arch ();
       bool is_active = task_is_currently_active (ptid);
       struct ravenscar_arch_ops *arch_ops = gdbarch_ravenscar_ops (gdbarch);
-      gdb::optional<fpu_state> fp_state;
+      std::optional<fpu_state> fp_state;
 
       int low_reg = regnum == -1 ? 0 : regnum;
       int high_reg = regnum == -1 ? gdbarch_num_regs (gdbarch) : regnum + 1;
diff --git a/gdb/record-btrace.c b/gdb/record-btrace.c
index abab79f3132..7a7d7617bc9 100644
--- a/gdb/record-btrace.c
+++ b/gdb/record-btrace.c
@@ -758,8 +758,8 @@ btrace_find_line_range (CORE_ADDR pc)
 
 static void
 btrace_print_lines (struct btrace_line_range lines, struct ui_out *uiout,
-		    gdb::optional<ui_out_emit_tuple> *src_and_asm_tuple,
-		    gdb::optional<ui_out_emit_list> *asm_list,
+		    std::optional<ui_out_emit_tuple> *src_and_asm_tuple,
+		    std::optional<ui_out_emit_list> *asm_list,
 		    gdb_disassembly_flags flags)
 {
   print_source_lines_flags psl_flags;
@@ -798,8 +798,8 @@ btrace_insn_history (struct ui_out *uiout,
 
   ui_out_emit_list list_emitter (uiout, "asm_insns");
 
-  gdb::optional<ui_out_emit_tuple> src_and_asm_tuple;
-  gdb::optional<ui_out_emit_list> asm_list;
+  std::optional<ui_out_emit_tuple> src_and_asm_tuple;
+  std::optional<ui_out_emit_list> asm_list;
 
   gdb_pretty_print_disassembler disasm (gdbarch, uiout);
 
diff --git a/gdb/regcache.c b/gdb/regcache.c
index 5acac2b8e47..c2802183fbe 100644
--- a/gdb/regcache.c
+++ b/gdb/regcache.c
@@ -596,7 +596,7 @@ regcache::raw_update (int regnum)
 
   if (get_register_status (regnum) == REG_UNKNOWN)
     {
-      gdb::optional<scoped_restore_current_thread> maybe_restore_thread
+      std::optional<scoped_restore_current_thread> maybe_restore_thread
 	= maybe_switch_inferior (m_inf_for_target_calls);
 
       target_fetch_registers (this, regnum);
@@ -850,7 +850,7 @@ regcache::raw_write (int regnum, const gdb_byte *buf)
 		  m_descr->sizeof_register[regnum]) == 0))
     return;
 
-  gdb::optional<scoped_restore_current_thread> maybe_restore_thread
+  std::optional<scoped_restore_current_thread> maybe_restore_thread
     = maybe_switch_inferior (m_inf_for_target_calls);
 
   target_prepare_to_store (this);
diff --git a/gdb/remote.c b/gdb/remote.c
index 961061e02a9..b405cb6abf7 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -915,7 +915,7 @@ class remote_target : public process_stratum_target
 		     const char *filename,
 		     fileio_error *target_errno) override;
 
-  gdb::optional<std::string>
+  std::optional<std::string>
     fileio_readlink (struct inferior *inf,
 		     const char *filename,
 		     fileio_error *target_errno) override;
@@ -4074,7 +4074,7 @@ remote_target::remote_get_threads_with_qxfer (threads_listing_context *context)
 #if defined(HAVE_LIBEXPAT)
   if (m_features.packet_support (PACKET_qXfer_threads) == PACKET_ENABLE)
     {
-      gdb::optional<gdb::char_vector> xml
+      std::optional<gdb::char_vector> xml
 	= target_read_stralloc (this, TARGET_OBJECT_THREADS, NULL);
 
       if (xml && (*xml)[0] != '\0')
@@ -11767,7 +11767,7 @@ std::vector<mem_region>
 remote_target::memory_map ()
 {
   std::vector<mem_region> result;
-  gdb::optional<gdb::char_vector> text
+  std::optional<gdb::char_vector> text
     = target_read_stralloc (current_inferior ()->top_target (),
 			    TARGET_OBJECT_MEMORY_MAP, NULL);
 
@@ -12732,7 +12732,7 @@ remote_target::fileio_unlink (struct inferior *inf, const char *filename,
 
 /* Implementation of to_fileio_readlink.  */
 
-gdb::optional<std::string>
+std::optional<std::string>
 remote_target::fileio_readlink (struct inferior *inf, const char *filename,
 				fileio_error *remote_errno)
 {
@@ -13999,7 +13999,7 @@ remote_target::set_circular_trace_buffer (int val)
 traceframe_info_up
 remote_target::traceframe_info ()
 {
-  gdb::optional<gdb::char_vector> text
+  std::optional<gdb::char_vector> text
     = target_read_stralloc (current_inferior ()->top_target (),
 			    TARGET_OBJECT_TRACEFRAME_INFO,
 			    NULL);
@@ -14540,7 +14540,7 @@ btrace_read_config (thread_info *tp, btrace_config *conf)
   scoped_restore_current_thread restore_thread;
   switch_to_thread (tp);
 
-  gdb::optional<gdb::char_vector> xml
+  std::optional<gdb::char_vector> xml
     = target_read_stralloc (current_inferior ()->top_target (),
 			    TARGET_OBJECT_BTRACE_CONF, "");
   if (xml)
@@ -14740,7 +14740,7 @@ remote_target::read_btrace (struct btrace_data *btrace,
 		      (unsigned int) type);
     }
 
-  gdb::optional<gdb::char_vector> xml
+  std::optional<gdb::char_vector> xml
     = target_read_stralloc (current_inferior ()->top_target (),
 			    TARGET_OBJECT_BTRACE, annex);
   if (!xml)
@@ -14780,7 +14780,7 @@ remote_target::load (const char *name, int from_tty)
 const char *
 remote_target::pid_to_exec_file (int pid)
 {
-  static gdb::optional<gdb::char_vector> filename;
+  static std::optional<gdb::char_vector> filename;
   char *annex = NULL;
 
   if (m_features.packet_support (PACKET_qXfer_exec_file) != PACKET_ENABLE)
diff --git a/gdb/riscv-tdep.c b/gdb/riscv-tdep.c
index 3a2891c2c92..3725be44276 100644
--- a/gdb/riscv-tdep.c
+++ b/gdb/riscv-tdep.c
@@ -1676,7 +1676,7 @@ class riscv_insn
      passed, is the value to place in rs1, otherwise rd is duplicated into
      rs1.  */
   void decode_ci_type_insn (enum opcode opcode, ULONGEST ival,
-			    gdb::optional<int> rs1_regnum = {})
+			    std::optional<int> rs1_regnum = {})
   {
     m_opcode = opcode;
     m_rd = decode_register_index (ival, OP_SH_CRS1S);
diff --git a/gdb/s390-linux-tdep.c b/gdb/s390-linux-tdep.c
index 414238a4db2..ae45ec6b5df 100644
--- a/gdb/s390-linux-tdep.c
+++ b/gdb/s390-linux-tdep.c
@@ -332,7 +332,7 @@ s390_core_read_description (struct gdbarch *gdbarch,
 			    struct target_ops *target, bfd *abfd)
 {
   asection *section = bfd_get_section_by_name (abfd, ".reg");
-  gdb::optional<gdb::byte_vector> auxv = target_read_auxv_raw (target);
+  std::optional<gdb::byte_vector> auxv = target_read_auxv_raw (target);
   CORE_ADDR hwcap = linux_get_hwcap (auxv, target, gdbarch);
   bool high_gprs, v1, v2, te, vx, gs;
 
diff --git a/gdb/skip.c b/gdb/skip.c
index 28902a6d326..465978ff9cc 100644
--- a/gdb/skip.c
+++ b/gdb/skip.c
@@ -34,7 +34,7 @@
 #include "filenames.h"
 #include "fnmatch.h"
 #include "gdbsupport/gdb_regex.h"
-#include "gdbsupport/gdb_optional.h"
+#include <optional>
 #include <list>
 #include "cli/cli-style.h"
 #include "gdbsupport/buildargv.h"
@@ -113,7 +113,7 @@ class skiplist_entry
   std::string m_function;
 
   /* If this is a function regexp, the compiled form.  */
-  gdb::optional<compiled_regex> m_compiled_function_regexp;
+  std::optional<compiled_regex> m_compiled_function_regexp;
 
   /* Enabled/disabled state.  */
   bool m_enabled = true;
diff --git a/gdb/solib-aix.c b/gdb/solib-aix.c
index fd6b1e7a454..320e1bf2034 100644
--- a/gdb/solib-aix.c
+++ b/gdb/solib-aix.c
@@ -65,7 +65,7 @@ struct solib_aix_inferior_data
      the same principles applied to shared libraries also apply
      to the main executable.  So it's simpler to keep it as part
      of this list.  */
-  gdb::optional<std::vector<lm_info_aix>> library_list;
+  std::optional<std::vector<lm_info_aix>> library_list;
 };
 
 /* Key to our per-inferior data.  */
@@ -91,7 +91,7 @@ get_solib_aix_inferior_data (struct inferior *inf)
 
 /* Dummy implementation if XML support is not compiled in.  */
 
-static gdb::optional<std::vector<lm_info_aix>>
+static std::optional<std::vector<lm_info_aix>>
 solib_aix_parse_libraries (const char *library)
 {
   static int have_warned;
@@ -201,7 +201,7 @@ static const struct gdb_xml_element library_list_elements[] =
 
    Return an empty option if the parsing failed.  */
 
-static gdb::optional<std::vector<lm_info_aix>>
+static std::optional<std::vector<lm_info_aix>>
 solib_aix_parse_libraries (const char *library)
 {
   std::vector<lm_info_aix> result;
@@ -225,7 +225,7 @@ solib_aix_parse_libraries (const char *library)
    is not NULL, then print a warning including WARNING_MSG and
    a description of the error.  */
 
-static gdb::optional<std::vector<lm_info_aix>> &
+static std::optional<std::vector<lm_info_aix>> &
 solib_aix_get_library_list (struct inferior *inf, const char *warning_msg)
 {
   struct solib_aix_inferior_data *data;
@@ -235,7 +235,7 @@ solib_aix_get_library_list (struct inferior *inf, const char *warning_msg)
   if (data->library_list.has_value ())
     return data->library_list;
 
-  gdb::optional<gdb::char_vector> library_document
+  std::optional<gdb::char_vector> library_document
     = target_read_stralloc (current_inferior ()->top_target (),
 			    TARGET_OBJECT_LIBRARIES_AIX,
 			    NULL);
@@ -442,7 +442,7 @@ solib_aix_solib_create_inferior_hook (int from_tty)
 
   /* We need to relocate the main executable...  */
 
-  gdb::optional<std::vector<lm_info_aix>> &library_list
+  std::optional<std::vector<lm_info_aix>> &library_list
     = solib_aix_get_library_list (current_inferior (), warning_msg);
   if (!library_list.has_value ())
     return;  /* Warning already printed.  */
@@ -472,7 +472,7 @@ solib_aix_current_sos (void)
   struct so_list *start = NULL, *last = NULL;
   int ix;
 
-  gdb::optional<std::vector<lm_info_aix>> &library_list
+  std::optional<std::vector<lm_info_aix>> &library_list
     = solib_aix_get_library_list (current_inferior (), NULL);
   if (!library_list.has_value ())
     return NULL;
diff --git a/gdb/solib-dsbt.c b/gdb/solib-dsbt.c
index c29b2b81b11..7b0adc1137e 100644
--- a/gdb/solib-dsbt.c
+++ b/gdb/solib-dsbt.c
@@ -281,7 +281,7 @@ static void
 dsbt_get_initial_loadmaps (void)
 {
   struct dsbt_info *info = get_dsbt_info ();
-  gdb::optional<gdb::byte_vector> buf
+  std::optional<gdb::byte_vector> buf
     = target_read_alloc (current_inferior ()->top_target (),
 			 TARGET_OBJECT_FDPIC, "exec");
 
diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c
index 7bc6ca45c37..2d7e9453827 100644
--- a/gdb/solib-svr4.c
+++ b/gdb/solib-svr4.c
@@ -453,7 +453,7 @@ static int match_main (const char *);
    architecture size (32-bit or 64-bit) is returned to *P_ARCH_SIZE.  Likewise,
    the base address of the section is returned in *BASE_ADDR.  */
 
-static gdb::optional<gdb::byte_vector>
+static std::optional<gdb::byte_vector>
 read_program_header (int type, int *p_arch_size, CORE_ADDR *base_addr)
 {
   bfd_endian byte_order = gdbarch_byte_order (current_inferior ()->arch ());
@@ -586,7 +586,7 @@ read_program_header (int type, int *p_arch_size, CORE_ADDR *base_addr)
 
 
 /* Return program interpreter string.  */
-static gdb::optional<gdb::byte_vector>
+static std::optional<gdb::byte_vector>
 find_program_interpreter (void)
 {
   /* If we have a current exec_bfd, use its section table.  */
@@ -631,7 +631,7 @@ scan_dyntag_auxv (const int desired_dyntag, CORE_ADDR *ptr,
   CORE_ADDR base_addr;
 
   /* Read in .dynamic section.  */
-  gdb::optional<gdb::byte_vector> ph_data
+  std::optional<gdb::byte_vector> ph_data
     = read_program_header (PT_DYNAMIC, &arch_size, &base_addr);
   if (!ph_data)
     return 0;
@@ -1219,7 +1219,7 @@ svr4_current_sos_via_xfer_libraries (struct svr4_library_list *list,
   gdb_assert (annex == NULL || target_augmented_libraries_svr4_read ());
 
   /* Fetch the list of shared libraries.  */
-  gdb::optional<gdb::char_vector> svr4_library_document
+  std::optional<gdb::char_vector> svr4_library_document
     = target_read_stralloc (current_inferior ()->top_target (),
 			    TARGET_OBJECT_LIBRARIES_SVR4,
 			    annex);
@@ -2426,7 +2426,7 @@ enable_break (struct svr4_info *info, int from_tty)
 
   /* Find the program interpreter; if not found, warn the user and drop
      into the old breakpoint at symbol code.  */
-  gdb::optional<gdb::byte_vector> interp_name_holder
+  std::optional<gdb::byte_vector> interp_name_holder
     = find_program_interpreter ();
   if (interp_name_holder)
     {
@@ -2637,7 +2637,7 @@ enable_break (struct svr4_info *info, int from_tty)
 
 /* Read the ELF program headers from ABFD.  */
 
-static gdb::optional<gdb::byte_vector>
+static std::optional<gdb::byte_vector>
 read_program_headers_from_bfd (bfd *abfd)
 {
   Elf_Internal_Ehdr *ehdr = elf_elfheader (abfd);
@@ -2750,9 +2750,9 @@ svr4_exec_displacement (CORE_ADDR *displacementp)
 	 really do not match.  */
       int arch_size;
 
-      gdb::optional<gdb::byte_vector> phdrs_target
+      std::optional<gdb::byte_vector> phdrs_target
 	= read_program_header (-1, &arch_size, NULL);
-      gdb::optional<gdb::byte_vector> phdrs_binary
+      std::optional<gdb::byte_vector> phdrs_binary
 	= read_program_headers_from_bfd (current_program_space->exec_bfd ());
       if (phdrs_target && phdrs_binary)
 	{
diff --git a/gdb/solib-target.c b/gdb/solib-target.c
index ca9478f2ec3..fe766544211 100644
--- a/gdb/solib-target.c
+++ b/gdb/solib-target.c
@@ -233,7 +233,7 @@ solib_target_current_sos (void)
   struct so_list *new_solib, *start = NULL, *last = NULL;
 
   /* Fetch the list of shared libraries.  */
-  gdb::optional<gdb::char_vector> library_document
+  std::optional<gdb::char_vector> library_document
     = target_read_stralloc (current_inferior ()->top_target (),
 			    TARGET_OBJECT_LIBRARIES, NULL);
   if (!library_document)
diff --git a/gdb/source-cache.c b/gdb/source-cache.c
index 77b357cb42b..0d80bfc99d0 100644
--- a/gdb/source-cache.c
+++ b/gdb/source-cache.c
@@ -269,7 +269,7 @@ source_cache::ensure (struct symtab *s)
       if (!already_styled)
 #endif /* HAVE_SOURCE_HIGHLIGHT */
 	{
-	  gdb::optional<std::string> ext_contents;
+	  std::optional<std::string> ext_contents;
 	  ext_contents = ext_lang_colorize (fullname, contents);
 	  if (ext_contents.has_value ())
 	    contents = std::move (*ext_contents);
diff --git a/gdb/stack.c b/gdb/stack.c
index 0b35d62f82f..efb36d0ea4f 100644
--- a/gdb/stack.c
+++ b/gdb/stack.c
@@ -97,7 +97,7 @@ static const char *const print_frame_info_choices[] =
 
 /* print_frame_info_print_what[i] maps a choice to the corresponding
    print_what enum.  */
-static const gdb::optional<enum print_what> print_frame_info_print_what[] =
+static const std::optional<enum print_what> print_frame_info_print_what[] =
   {{}, /* Empty value for "auto".  */
    SRC_LINE, LOCATION, SRC_AND_LOC, LOC_AND_ADDRESS, SHORT_LOCATION};
 
@@ -973,7 +973,7 @@ do_gdb_disassembly (struct gdbarch *gdbarch,
    Value not present indicates to the caller to use default values
    specific to the command being executed.  */
 
-static gdb::optional<enum print_what>
+static std::optional<enum print_what>
 print_frame_info_to_print_what (const char *print_frame_info)
 {
   for (int i = 0; print_frame_info_choices[i] != NULL; i++)
@@ -1004,7 +1004,7 @@ print_pc (struct ui_out *uiout, struct gdbarch *gdbarch, frame_info_ptr frame,
 /* See stack.h.  */
 
 void
-get_user_print_what_frame_info (gdb::optional<enum print_what> *what)
+get_user_print_what_frame_info (std::optional<enum print_what> *what)
 {
   *what
     = print_frame_info_to_print_what
@@ -2261,8 +2261,8 @@ iterate_over_block_local_vars (const struct block *block,
 
 struct print_variable_and_value_data
 {
-  gdb::optional<compiled_regex> preg;
-  gdb::optional<compiled_regex> treg;
+  std::optional<compiled_regex> preg;
+  std::optional<compiled_regex> treg;
   struct frame_id frame_id;
   int num_tabs;
   struct ui_file *stream;
@@ -2307,7 +2307,7 @@ print_variable_and_value_data::operator() (const char *print_name,
    If REGEXP is NULL, it results in an empty regular expression.  */
 
 static void
-prepare_reg (const char *regexp, gdb::optional<compiled_regex> *reg)
+prepare_reg (const char *regexp, std::optional<compiled_regex> *reg)
 {
   if (regexp != NULL)
     {
@@ -2503,8 +2503,8 @@ print_frame_arg_vars (frame_info_ptr frame,
   struct print_variable_and_value_data cb_data;
   struct symbol *func;
   CORE_ADDR pc;
-  gdb::optional<compiled_regex> preg;
-  gdb::optional<compiled_regex> treg;
+  std::optional<compiled_regex> preg;
+  std::optional<compiled_regex> treg;
 
   if (!get_frame_pc_if_available (frame, &pc))
     {
diff --git a/gdb/stack.h b/gdb/stack.h
index 1b0c2b342a4..a64abaf52b5 100644
--- a/gdb/stack.h
+++ b/gdb/stack.h
@@ -38,7 +38,7 @@ void iterate_over_block_local_vars (const struct block *block,
    information to print, otherwise the printing function should print
    the relevant information.  */
 
-void get_user_print_what_frame_info (gdb::optional<enum print_what> *what);
+void get_user_print_what_frame_info (std::optional<enum print_what> *what);
 
 /* Return true if we should display the address in addition to the location,
    because we are in the middle of a statement.  */
diff --git a/gdb/symfile.c b/gdb/symfile.c
index 5eb1638b781..a6236804b08 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -913,7 +913,7 @@ syms_from_objfile_1 (struct objfile *objfile,
 
   /* Make sure that partially constructed symbol tables will be cleaned up
      if an error occurs during symbol reading.  */
-  gdb::optional<clear_symtab_users_cleanup> defer_clear_users;
+  std::optional<clear_symtab_users_cleanup> defer_clear_users;
 
   objfile_up objfile_holder (objfile);
 
diff --git a/gdb/symtab.c b/gdb/symtab.c
index 46547f8b0ae..7f67159b516 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -66,7 +66,7 @@
 #include "parser-defs.h"
 #include "completer.h"
 #include "progspace-and-thread.h"
-#include "gdbsupport/gdb_optional.h"
+#include <optional>
 #include "filename-seen-cache.h"
 #include "arch-utils.h"
 #include <algorithm>
@@ -943,7 +943,7 @@ void
 general_symbol_info::compute_and_set_names (gdb::string_view linkage_name,
 					    bool copy_name,
 					    objfile_per_bfd_storage *per_bfd,
-					    gdb::optional<hashval_t> hash)
+					    std::optional<hashval_t> hash)
 {
   struct demangled_name_entry **slot;
 
@@ -3714,7 +3714,7 @@ skip_prologue_using_lineinfo (CORE_ADDR func_addr, struct symtab *symtab)
    the function starting at FUNC_ADDR which has prologue_end set to true if
    such entry exist, otherwise return an empty optional.  */
 
-static gdb::optional<CORE_ADDR>
+static std::optional<CORE_ADDR>
 skip_prologue_using_linetable (CORE_ADDR func_addr)
 {
   CORE_ADDR start_pc, end_pc;
@@ -3838,7 +3838,7 @@ skip_prologue_sal (struct symtab_and_line *sal)
 	 be placed to skip the prologue.  */
       if (!ignore_prologue_end_flag && skip)
 	{
-	  gdb::optional<CORE_ADDR> linetable_pc
+	  std::optional<CORE_ADDR> linetable_pc
 	    = skip_prologue_using_linetable (pc);
 	  if (linetable_pc)
 	    {
@@ -4450,8 +4450,8 @@ info_sources_worker (struct ui_out *uiout,
   output_source_filename_data data (uiout, filter);
 
   ui_out_emit_list results_emitter (uiout, "files");
-  gdb::optional<ui_out_emit_tuple> output_tuple;
-  gdb::optional<ui_out_emit_list> sources_list;
+  std::optional<ui_out_emit_tuple> output_tuple;
+  std::optional<ui_out_emit_list> sources_list;
 
   gdb_assert (group_by_objfile || uiout->is_mi_like_p ());
 
@@ -4652,7 +4652,7 @@ global_symbol_searcher::is_suitable_msymbol
 
 bool
 global_symbol_searcher::expand_symtabs
-	(objfile *objfile, const gdb::optional<compiled_regex> &preg) const
+	(objfile *objfile, const std::optional<compiled_regex> &preg) const
 {
   enum search_domain kind = m_kind;
   bool found_msymbol = false;
@@ -4734,8 +4734,8 @@ global_symbol_searcher::expand_symtabs
 bool
 global_symbol_searcher::add_matching_symbols
 	(objfile *objfile,
-	 const gdb::optional<compiled_regex> &preg,
-	 const gdb::optional<compiled_regex> &treg,
+	 const std::optional<compiled_regex> &preg,
+	 const std::optional<compiled_regex> &treg,
 	 std::set<symbol_search> *result_set) const
 {
   enum search_domain kind = m_kind;
@@ -4813,7 +4813,7 @@ global_symbol_searcher::add_matching_symbols
 
 bool
 global_symbol_searcher::add_matching_msymbols
-	(objfile *objfile, const gdb::optional<compiled_regex> &preg,
+	(objfile *objfile, const std::optional<compiled_regex> &preg,
 	 std::vector<symbol_search> *results) const
 {
   enum search_domain kind = m_kind;
@@ -4860,8 +4860,8 @@ global_symbol_searcher::add_matching_msymbols
 std::vector<symbol_search>
 global_symbol_searcher::search () const
 {
-  gdb::optional<compiled_regex> preg;
-  gdb::optional<compiled_regex> treg;
+  std::optional<compiled_regex> preg;
+  std::optional<compiled_regex> treg;
 
   gdb_assert (m_kind != ALL_DOMAIN);
 
diff --git a/gdb/symtab.h b/gdb/symtab.h
index 365743384e1..d61d5bb7815 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -30,7 +30,7 @@
 #include "gdbsupport/gdb_regex.h"
 #include "gdbsupport/enum-flags.h"
 #include "gdbsupport/function-view.h"
-#include "gdbsupport/gdb_optional.h"
+#include <optional>
 #include "gdbsupport/gdb_string_view.h"
 #include "gdbsupport/next-iterator.h"
 #include "gdbsupport/iterator-range.h"
@@ -364,10 +364,10 @@ class lookup_name_info final
      around by const reference (see intro), and they're conceptually
      "cache" that can always be reconstructed from the non-mutable
      fields.  */
-  mutable gdb::optional<ada_lookup_name_info> m_ada;
-  mutable gdb::optional<demangle_for_lookup_info> m_cplus;
-  mutable gdb::optional<demangle_for_lookup_info> m_d;
-  mutable gdb::optional<demangle_for_lookup_info> m_go;
+  mutable std::optional<ada_lookup_name_info> m_ada;
+  mutable std::optional<demangle_for_lookup_info> m_cplus;
+  mutable std::optional<demangle_for_lookup_info> m_d;
+  mutable std::optional<demangle_for_lookup_info> m_go;
 
   /* The demangled hashes.  Stored in an array with one entry for each
      possible language.  The second array records whether we've
@@ -511,8 +511,8 @@ struct general_symbol_info
      copy_name must be set to true.  */
   void compute_and_set_names (gdb::string_view linkage_name, bool copy_name,
 			      struct objfile_per_bfd_storage *per_bfd,
-			      gdb::optional<hashval_t> hash
-				= gdb::optional<hashval_t> ());
+			      std::optional<hashval_t> hash
+				= std::optional<hashval_t> ());
 
   CORE_ADDR value_address () const
   {
@@ -2601,7 +2601,7 @@ class global_symbol_searcher
      true if any msymbols were seen that we should later consider adding to
      the results list.  */
   bool expand_symtabs (objfile *objfile,
-		       const gdb::optional<compiled_regex> &preg) const;
+		       const std::optional<compiled_regex> &preg) const;
 
   /* Add symbols from symtabs in OBJFILE that match PREG, and TREG, and are
      of type M_KIND, to the results set RESULTS_SET.  Return false if we
@@ -2610,8 +2610,8 @@ class global_symbol_searcher
      Returning true does not indicate that any results were added, just
      that we didn't _not_ add a result due to reaching MAX_SEARCH_RESULTS.  */
   bool add_matching_symbols (objfile *objfile,
-			     const gdb::optional<compiled_regex> &preg,
-			     const gdb::optional<compiled_regex> &treg,
+			     const std::optional<compiled_regex> &preg,
+			     const std::optional<compiled_regex> &treg,
 			     std::set<symbol_search> *result_set) const;
 
   /* Add msymbols from OBJFILE that match PREG and M_KIND, to the results
@@ -2621,7 +2621,7 @@ class global_symbol_searcher
      does not indicate that any results were added, just that we didn't
      _not_ add a result due to reaching MAX_SEARCH_RESULTS.  */
   bool add_matching_msymbols (objfile *objfile,
-			      const gdb::optional<compiled_regex> &preg,
+			      const std::optional<compiled_regex> &preg,
 			      std::vector<symbol_search> *results) const;
 
   /* Return true if MSYMBOL is of type KIND.  */
@@ -2910,7 +2910,7 @@ struct info_sources_filter
 
   /* A compiled version of M_REGEXP.  This object is only given a value if
      M_REGEXP is not nullptr and is not the empty string.  */
-  gdb::optional<compiled_regex> m_c_regexp;
+  std::optional<compiled_regex> m_c_regexp;
 };
 
 /* Perform the core of the 'info sources' command.
diff --git a/gdb/target.c b/gdb/target.c
index 6853c143231..73df178e69d 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -2264,7 +2264,7 @@ target_write (struct target_ops *ops,
    for details.  */
 
 template <typename T>
-gdb::optional<gdb::def_vector<T>>
+std::optional<gdb::def_vector<T>>
 target_read_alloc_1 (struct target_ops *ops, enum target_object object,
 		     const char *annex)
 {
@@ -2313,7 +2313,7 @@ target_read_alloc_1 (struct target_ops *ops, enum target_object object,
 
 /* See target.h  */
 
-gdb::optional<gdb::byte_vector>
+std::optional<gdb::byte_vector>
 target_read_alloc (struct target_ops *ops, enum target_object object,
 		   const char *annex)
 {
@@ -2322,11 +2322,11 @@ target_read_alloc (struct target_ops *ops, enum target_object object,
 
 /* See target.h.  */
 
-gdb::optional<gdb::char_vector>
+std::optional<gdb::char_vector>
 target_read_stralloc (struct target_ops *ops, enum target_object object,
 		      const char *annex)
 {
-  gdb::optional<gdb::char_vector> buf
+  std::optional<gdb::char_vector> buf
     = target_read_alloc_1<char> (ops, object, annex);
 
   if (!buf)
@@ -3008,7 +3008,7 @@ target_supports_multi_process (void)
 
 /* See target.h.  */
 
-gdb::optional<gdb::char_vector>
+std::optional<gdb::char_vector>
 target_get_osdata (const char *type)
 {
   struct target_ops *t;
@@ -3250,7 +3250,7 @@ target_ops::fileio_unlink (struct inferior *inf, const char *filename,
   return -1;
 }
 
-gdb::optional<std::string>
+std::optional<std::string>
 target_ops::fileio_readlink (struct inferior *inf, const char *filename,
 			     fileio_error *target_errno)
 {
@@ -3421,13 +3421,13 @@ target_fileio_unlink (struct inferior *inf, const char *filename,
 
 /* See target.h.  */
 
-gdb::optional<std::string>
+std::optional<std::string>
 target_fileio_readlink (struct inferior *inf, const char *filename,
 			fileio_error *target_errno)
 {
   for (target_ops *t = default_fileio_target (); t != NULL; t = t->beneath ())
     {
-      gdb::optional<std::string> ret
+      std::optional<std::string> ret
 	= t->fileio_readlink (inf, filename, target_errno);
 
       if (!ret.has_value () && *target_errno == FILEIO_ENOSYS)
diff --git a/gdb/target.h b/gdb/target.h
index 446c0a9fdbf..1d7926bb962 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -345,7 +345,7 @@ LONGEST target_write_with_progress (struct target_ops *ops,
    size is known in advance.  Don't try to read TARGET_OBJECT_MEMORY
    through this function.  */
 
-extern gdb::optional<gdb::byte_vector> target_read_alloc
+extern std::optional<gdb::byte_vector> target_read_alloc
     (struct target_ops *ops, enum target_object object, const char *annex);
 
 /* Read OBJECT/ANNEX using OPS.  The result is a NUL-terminated character vector
@@ -355,7 +355,7 @@ extern gdb::optional<gdb::byte_vector> target_read_alloc
    the returned vector is guaranteed to have at least one element.  A warning is
    issued if the result contains any embedded NUL bytes.  */
 
-extern gdb::optional<gdb::char_vector> target_read_stralloc
+extern std::optional<gdb::char_vector> target_read_stralloc
     (struct target_ops *ops, enum target_object object, const char *annex);
 
 /* See target_ops->to_xfer_partial.  */
@@ -994,7 +994,7 @@ struct target_ops
        seen by the debugger (GDB or, for remote targets, the remote
        stub).  Return a string, or an empty optional if an error
        occurs (and set *TARGET_ERRNO).  */
-    virtual gdb::optional<std::string> fileio_readlink (struct inferior *inf,
+    virtual std::optional<std::string> fileio_readlink (struct inferior *inf,
 							const char *filename,
 							fileio_error *target_errno);
 
@@ -2199,7 +2199,7 @@ extern int target_fileio_unlink (struct inferior *inf,
    by the debugger (GDB or, for remote targets, the remote stub).
    Return a null-terminated string allocated via xmalloc, or NULL if
    an error occurs (and set *TARGET_ERRNO).  */
-extern gdb::optional<std::string> target_fileio_readlink
+extern std::optional<std::string> target_fileio_readlink
     (struct inferior *inf, const char *filename, fileio_error *target_errno);
 
 /* Read target file FILENAME, in the filesystem as seen by INF.  If
@@ -2462,7 +2462,7 @@ struct target_ops *find_target_at (enum strata stratum);
 /* Read OS data object of type TYPE from the target, and return it in XML
    format.  The return value follows the same rules as target_read_stralloc.  */
 
-extern gdb::optional<gdb::char_vector> target_get_osdata (const char *type);
+extern std::optional<gdb::char_vector> target_get_osdata (const char *type);
 
 /* Stuff that should be shared among the various remote targets.  */
 
diff --git a/gdb/thread.c b/gdb/thread.c
index c8145da59bc..f97f2768fb2 100644
--- a/gdb/thread.c
+++ b/gdb/thread.c
@@ -46,7 +46,7 @@
 #include "thread-fsm.h"
 #include "tid-parse.h"
 #include <algorithm>
-#include "gdbsupport/gdb_optional.h"
+#include <optional>
 #include "inline-frame.h"
 #include "stack.h"
 #include "interps.h"
@@ -194,7 +194,7 @@ clear_thread_inferior_resources (struct thread_info *tp)
 /* Notify interpreters and observers that thread T has exited.  */
 
 static void
-notify_thread_exited (thread_info *t, gdb::optional<ULONGEST> exit_code,
+notify_thread_exited (thread_info *t, std::optional<ULONGEST> exit_code,
 		      int silent)
 {
   if (!silent && print_thread_events)
@@ -215,7 +215,7 @@ notify_thread_exited (thread_info *t, gdb::optional<ULONGEST> exit_code,
 /* See gdbthread.h.  */
 
 void
-set_thread_exited (thread_info *tp, gdb::optional<ULONGEST> exit_code,
+set_thread_exited (thread_info *tp, std::optional<ULONGEST> exit_code,
 		   bool silent)
 {
   /* Dead threads don't need to step-over.  Remove from chain.  */
@@ -486,7 +486,7 @@ global_thread_step_over_chain_remove (struct thread_info *tp)
 /* Helper for the different delete_thread variants.  */
 
 static void
-delete_thread_1 (thread_info *thr, gdb::optional<ULONGEST> exit_code,
+delete_thread_1 (thread_info *thr, std::optional<ULONGEST> exit_code,
 		 bool silent)
 {
   gdb_assert (thr != nullptr);
@@ -1089,8 +1089,8 @@ print_thread_info_1 (struct ui_out *uiout, const char *requested_threads,
     /* For backward compatibility, we make a list for MI.  A table is
        preferable for the CLI, though, because it shows table
        headers.  */
-    gdb::optional<ui_out_emit_list> list_emitter;
-    gdb::optional<ui_out_emit_table> table_emitter;
+    std::optional<ui_out_emit_list> list_emitter;
+    std::optional<ui_out_emit_table> table_emitter;
 
     /* We'll be switching threads temporarily below.  */
     scoped_restore_current_thread restore_thread;
@@ -1520,7 +1520,7 @@ tp_array_compar_descending (const thread_info_ref &a, const thread_info_ref &b)
 /* See gdbthread.h.  */
 
 void
-thread_try_catch_cmd (thread_info *thr, gdb::optional<int> ada_task,
+thread_try_catch_cmd (thread_info *thr, std::optional<int> ada_task,
 		      const char *cmd, int from_tty,
 		      const qcs_flags &flags)
 {
diff --git a/gdb/tracefile-tfile.c b/gdb/tracefile-tfile.c
index b698b4004cc..a710246d7ad 100644
--- a/gdb/tracefile-tfile.c
+++ b/gdb/tracefile-tfile.c
@@ -305,7 +305,7 @@ tfile_write_tdesc (struct trace_file_writer *self)
   struct tfile_trace_file_writer *writer
     = (struct tfile_trace_file_writer *) self;
 
-  gdb::optional<std::string> tdesc
+  std::optional<std::string> tdesc
     = target_fetch_description_xml (current_inferior ()->top_target ());
 
   if (!tdesc)
diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c
index 2c548688570..b1b31ad378c 100644
--- a/gdb/tracepoint.c
+++ b/gdb/tracepoint.c
@@ -3732,7 +3732,7 @@ sdata_make_value (struct gdbarch *gdbarch, struct internalvar *var,
 		  void *ignore)
 {
   /* We need to read the whole object before we know its size.  */
-  gdb::optional<gdb::byte_vector> buf
+  std::optional<gdb::byte_vector> buf
     = target_read_alloc (current_inferior ()->top_target (),
 			 TARGET_OBJECT_STATIC_TRACE_DATA,
 			 NULL);
diff --git a/gdb/tui/tui-disasm.c b/gdb/tui/tui-disasm.c
index c1ed491c558..ebd8bf0e2d1 100644
--- a/gdb/tui/tui-disasm.c
+++ b/gdb/tui/tui-disasm.c
@@ -234,7 +234,7 @@ tui_find_disassembly_address (struct gdbarch *gdbarch, CORE_ADDR pc, int from)
 	 promising starting point then we record it in this structure.  If
 	 the next address we try is not a suitable starting point then we
 	 will fall back to the address held here.  */
-      gdb::optional<CORE_ADDR> possible_new_low;
+      std::optional<CORE_ADDR> possible_new_low;
 
       /* The previous value of NEW_LOW so we know if the new value is
 	 different or not.  */
diff --git a/gdb/tui/tui-layout.c b/gdb/tui/tui-layout.c
index 159445dc520..b932649b3ac 100644
--- a/gdb/tui/tui-layout.c
+++ b/gdb/tui/tui-layout.c
@@ -819,7 +819,7 @@ tui_layout_split::apply (int x_, int y_, int width_, int height_,
   };
 
   /* This is given a value only if we fix the size of the cmd window.  */
-  gdb::optional<old_size_info> old_cmd_info;
+  std::optional<old_size_info> old_cmd_info;
 
   std::vector<size_info> info (m_splits.size ());
 
diff --git a/gdb/unittests/optional-selftests.c b/gdb/unittests/optional-selftests.c
index 8a727c02159..51135b8b98c 100644
--- a/gdb/unittests/optional-selftests.c
+++ b/gdb/unittests/optional-selftests.c
@@ -31,7 +31,7 @@
 #define VERIFY SELF_CHECK
 
 /* Used to disable testing features not supported by
-   gdb::optional.  */
+   std::optional.  */
 #define GDB_OPTIONAL
 
 namespace selftests {
@@ -41,7 +41,7 @@ namespace optional {
    copied over from libstdc++'s testsuite.  To preserve the structure
    and help with comparison with the original tests, the file names
    have been preserved, and only minimal modification was done to have
-   them compile against gdb::optional instead of std::optional:
+   them compile against std::optional instead of std::optional:
 
      - std::optional->gdb:optional, etc.
      - ATTRIBUTE_UNUSED in a few places
diff --git a/gdb/utils.c b/gdb/utils.c
index a191d26a007..94a7cafa65b 100644
--- a/gdb/utils.c
+++ b/gdb/utils.c
@@ -68,7 +68,7 @@
 #include "gdbsupport/gdb_regex.h"
 #include "gdbsupport/job-control.h"
 #include "gdbsupport/selftest.h"
-#include "gdbsupport/gdb_optional.h"
+#include <optional>
 #include "cp-support.h"
 #include <algorithm>
 #include "gdbsupport/pathstuff.h"
@@ -143,7 +143,7 @@ vwarning (const char *string, va_list args)
     (*deprecated_warning_hook) (string, args);
   else
     {
-      gdb::optional<target_terminal::scoped_restore_terminal_state> term_state;
+      std::optional<target_terminal::scoped_restore_terminal_state> term_state;
       if (target_supports_terminal_ours ())
 	{
 	  term_state.emplace ();
@@ -375,7 +375,7 @@ internal_vproblem (struct internal_problem *problem,
     }
 
   /* Try to get the message out and at the start of a new line.  */
-  gdb::optional<target_terminal::scoped_restore_terminal_state> term_state;
+  std::optional<target_terminal::scoped_restore_terminal_state> term_state;
   if (target_supports_terminal_ours ())
     {
       term_state.emplace ();
diff --git a/gdb/valarith.c b/gdb/valarith.c
index f3acf98c98b..6cf56302aee 100644
--- a/gdb/valarith.c
+++ b/gdb/valarith.c
@@ -150,14 +150,14 @@ value_subscript (struct value *array, LONGEST index)
       || tarray->code () == TYPE_CODE_STRING)
     {
       struct type *range_type = tarray->index_type ();
-      gdb::optional<LONGEST> lowerbound = get_discrete_low_bound (range_type);
+      std::optional<LONGEST> lowerbound = get_discrete_low_bound (range_type);
       if (!lowerbound.has_value ())
 	lowerbound = 0;
 
       if (array->lval () != lval_memory)
 	return value_subscripted_rvalue (array, index, *lowerbound);
 
-      gdb::optional<LONGEST> upperbound
+      std::optional<LONGEST> upperbound
 	= get_discrete_high_bound (range_type);
 
       if (!upperbound.has_value ())
diff --git a/gdb/valops.c b/gdb/valops.c
index 70851cd40b4..a8760ccf3e4 100644
--- a/gdb/valops.c
+++ b/gdb/valops.c
@@ -52,7 +52,7 @@ static struct value *search_struct_field (const char *, struct value *,
 					  struct type *, int);
 
 static struct value *search_struct_method (const char *, struct value **,
-					   gdb::optional<gdb::array_view<value *>>,
+					   std::optional<gdb::array_view<value *>>,
 					   LONGEST, int *, struct type *);
 
 static int find_oload_champ_namespace (gdb::array_view<value *> args,
@@ -2196,7 +2196,7 @@ search_struct_field (const char *name, struct value *arg1,
 
 static struct value *
 search_struct_method (const char *name, struct value **arg1p,
-		      gdb::optional<gdb::array_view<value *>> args,
+		      std::optional<gdb::array_view<value *>> args,
 		      LONGEST offset, int *static_memfuncp,
 		      struct type *type)
 {
@@ -2332,7 +2332,7 @@ search_struct_method (const char *name, struct value **arg1p,
 
 struct value *
 value_struct_elt (struct value **argp,
-		  gdb::optional<gdb::array_view<value *>> args,
+		  std::optional<gdb::array_view<value *>> args,
 		  const char *name, int *static_memfuncp, const char *err)
 {
   struct type *t;
diff --git a/gdb/value.c b/gdb/value.c
index 17b7c53d052..7067ae94df0 100644
--- a/gdb/value.c
+++ b/gdb/value.c
@@ -826,7 +826,7 @@ exceeds_max_value_size (ULONGEST length)
 /* When this has a value, it is used to limit the number of array elements
    of an array that are loaded into memory when an array value is made
    non-lazy.  */
-static gdb::optional<int> array_length_limiting_element_count;
+static std::optional<int> array_length_limiting_element_count;
 
 /* See value.h.  */
 scoped_array_length_limiting::scoped_array_length_limiting (int elements)
diff --git a/gdb/value.h b/gdb/value.h
index e4912717684..6d91e8eee7a 100644
--- a/gdb/value.h
+++ b/gdb/value.h
@@ -1269,7 +1269,7 @@ extern struct value *value_neg (struct value *arg1);
 extern struct value *value_complement (struct value *arg1);
 
 extern struct value *value_struct_elt (struct value **argp,
-				       gdb::optional<gdb::array_view <value *>> args,
+				       std::optional<gdb::array_view <value *>> args,
 				       const char *name, int *static_memfuncp,
 				       const char *err);
 
@@ -1635,7 +1635,7 @@ struct scoped_array_length_limiting
 
 private:
   /* Used to hold the previous array value element limit.  */
-  gdb::optional<int> m_old_value;
+  std::optional<int> m_old_value;
 };
 
 #endif /* !defined (VALUE_H) */
diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c
index b446afd72d8..e4d50d081c9 100644
--- a/gdb/windows-nat.c
+++ b/gdb/windows-nat.c
@@ -1335,7 +1335,7 @@ windows_nat_target::windows_continue (DWORD continue_status, int id,
 	th->suspend ();
       }
 
-  gdb::optional<unsigned> err;
+  std::optional<unsigned> err;
   do_synchronously ([&] ()
     {
       if (!continue_last_debug_event (continue_status, debug_events))
@@ -1561,7 +1561,7 @@ windows_nat_target::get_windows_debug_event
   /* If there is a relevant pending stop, report it now.  See the
      comment by the definition of "pending_stops" for details on why
      this is needed.  */
-  gdb::optional<pending_stop> stop
+  std::optional<pending_stop> stop
     = windows_process.fetch_pending_stop (debug_events);
   if (stop.has_value ())
     {
@@ -2024,7 +2024,7 @@ windows_nat_target::attach (const char *args, int from_tty)
   windows_init_thread_list ();
   windows_process.saw_create = 0;
 
-  gdb::optional<unsigned> err;
+  std::optional<unsigned> err;
   do_synchronously ([&] ()
     {
       BOOL ok = DebugActiveProcess (pid);
@@ -2074,7 +2074,7 @@ windows_nat_target::detach (inferior *inf, int from_tty)
 {
   windows_continue (DBG_CONTINUE, -1, 0, true);
 
-  gdb::optional<unsigned> err;
+  std::optional<unsigned> err;
   do_synchronously ([&] ()
     {
       if (!DebugActiveProcessStop (windows_process.current_event.dwProcessId))
@@ -2533,7 +2533,7 @@ windows_nat_target::create_inferior (const char *exec_file,
 #endif	/* !__CYGWIN__ */
   const char *allargs = origallargs.c_str ();
   PROCESS_INFORMATION pi;
-  gdb::optional<unsigned> ret;
+  std::optional<unsigned> ret;
   DWORD flags = 0;
   const std::string &inferior_tty = current_inferior ()->tty ();
 
diff --git a/gdb/xml-support.c b/gdb/xml-support.c
index 0c98dc7e6b4..2d231b6f4bb 100644
--- a/gdb/xml-support.c
+++ b/gdb/xml-support.c
@@ -785,7 +785,7 @@ xinclude_start_include (struct gdb_xml_parser *parser,
     gdb_xml_error (parser, _("Maximum XInclude depth (%d) exceeded"),
 		   MAX_XINCLUDE_DEPTH);
 
-  gdb::optional<gdb::char_vector> text = data->fetcher (href);
+  std::optional<gdb::char_vector> text = data->fetcher (href);
   if (!text)
     gdb_xml_error (parser, _("Could not load XML document \"%s\""), href);
 
@@ -960,7 +960,7 @@ show_debug_xml (struct ui_file *file, int from_tty,
   gdb_printf (file, _("XML debugging is %s.\n"), value);
 }
 
-gdb::optional<gdb::char_vector>
+std::optional<gdb::char_vector>
 xml_fetch_content_from_file (const char *filename, const char *dirname)
 {
   gdb_file_up file;
diff --git a/gdb/xml-support.h b/gdb/xml-support.h
index 1f9ac68b745..8388276df25 100644
--- a/gdb/xml-support.h
+++ b/gdb/xml-support.h
@@ -24,7 +24,7 @@
 #include "gdbsupport/gdb_obstack.h"
 #include "gdbsupport/xml-utils.h"
 #include "gdbsupport/byte-vector.h"
-#include "gdbsupport/gdb_optional.h"
+#include <optional>
 #include "gdbsupport/function-view.h"
 
 struct gdb_xml_parser;
@@ -49,7 +49,7 @@ LONGEST xml_builtin_xfer_partial (const char *filename,
 
 /* Callback to fetch a new XML file, based on the provided HREF.  */
 
-using xml_fetch_another = gdb::function_view<gdb::optional<gdb::char_vector>
+using xml_fetch_another = gdb::function_view<std::optional<gdb::char_vector>
 					     (const char * /* href */)>;
 
 /* Append the expansion of TEXT after processing <xi:include> tags in
@@ -230,7 +230,7 @@ ULONGEST gdb_xml_parse_ulongest (struct gdb_xml_parser *parser,
    the text.  If something goes wrong, return an uninstantiated optional
    and warn.  */
 
-extern gdb::optional<gdb::char_vector> xml_fetch_content_from_file
+extern std::optional<gdb::char_vector> xml_fetch_content_from_file
     (const char *filename, const char *dirname);
 
 #endif
diff --git a/gdb/xml-syscall.c b/gdb/xml-syscall.c
index da1211ef8e9..cfb54347431 100644
--- a/gdb/xml-syscall.c
+++ b/gdb/xml-syscall.c
@@ -314,7 +314,7 @@ syscall_parse_xml (const char *document, xml_fetch_another fetcher)
 static struct syscalls_info *
 xml_init_syscalls_info (const char *filename)
 {
-  gdb::optional<gdb::char_vector> full_file
+  std::optional<gdb::char_vector> full_file
     = xml_fetch_content_from_file (filename,
 				   const_cast<char *>(gdb_datadir.c_str ()));
   if (!full_file)
diff --git a/gdb/xml-tdesc.c b/gdb/xml-tdesc.c
index a8b0b0566c7..daf123af69d 100644
--- a/gdb/xml-tdesc.c
+++ b/gdb/xml-tdesc.c
@@ -663,7 +663,7 @@ tdesc_parse_xml (const char *document, xml_fetch_another fetcher)
 const struct target_desc *
 file_read_description_xml (const char *filename)
 {
-  gdb::optional<gdb::char_vector> tdesc_str
+  std::optional<gdb::char_vector> tdesc_str
     = xml_fetch_content_from_file (filename, NULL);
   if (!tdesc_str)
     {
@@ -687,7 +687,7 @@ file_read_description_xml (const char *filename)
    is "target.xml".  Other calls may be performed for the DTD or
    for <xi:include>.  */
 
-static gdb::optional<gdb::char_vector>
+static std::optional<gdb::char_vector>
 fetch_available_features_from_target (const char *name, target_ops *ops)
 {
   /* Read this object as a string.  This ensures that a NUL
@@ -704,7 +704,7 @@ fetch_available_features_from_target (const char *name, target_ops *ops)
 const struct target_desc *
 target_read_description_xml (struct target_ops *ops)
 {
-  gdb::optional<gdb::char_vector> tdesc_str
+  std::optional<gdb::char_vector> tdesc_str
     = fetch_available_features_from_target ("target.xml", ops);
   if (!tdesc_str)
     return NULL;
@@ -721,7 +721,7 @@ target_read_description_xml (struct target_ops *ops)
    includes, but not parsing it.  Used to dump whole tdesc
    as a single XML file.  */
 
-gdb::optional<std::string>
+std::optional<std::string>
 target_fetch_description_xml (struct target_ops *ops)
 {
 #if !defined(HAVE_LIBEXPAT)
@@ -736,7 +736,7 @@ target_fetch_description_xml (struct target_ops *ops)
 
   return {};
 #else
-  gdb::optional<gdb::char_vector>
+  std::optional<gdb::char_vector>
     tdesc_str = fetch_available_features_from_target ("target.xml", ops);
   if (!tdesc_str)
     return {};
@@ -765,6 +765,6 @@ string_read_description_xml (const char *xml)
   return tdesc_parse_xml (xml, [] (const char *href)
     {
       error (_("xincludes are unsupported with this method"));
-      return gdb::optional<gdb::char_vector> ();
+      return std::optional<gdb::char_vector> ();
     });
 }
diff --git a/gdb/xml-tdesc.h b/gdb/xml-tdesc.h
index 0fbfc7e043e..0ffca92ed7a 100644
--- a/gdb/xml-tdesc.h
+++ b/gdb/xml-tdesc.h
@@ -22,7 +22,7 @@
 #ifndef XML_TDESC_H
 #define XML_TDESC_H
 
-#include "gdbsupport/gdb_optional.h"
+#include <optional>
 #include <string>
 
 struct target_ops;
@@ -42,7 +42,7 @@ const struct target_desc *target_read_description_xml (struct target_ops *);
    but not parsing it.  Used to dump whole tdesc as a single XML file.
    Returns the description on success, and a disengaged optional
    otherwise.  */
-gdb::optional<std::string> target_fetch_description_xml (target_ops *ops);
+std::optional<std::string> target_fetch_description_xml (target_ops *ops);
 
 /* Take an xml string, parse it, and return the parsed description.  Does not
    handle a string containing includes.  */
diff --git a/gdbserver/linux-aarch64-low.cc b/gdbserver/linux-aarch64-low.cc
index fcbe7bb64d7..70454652720 100644
--- a/gdbserver/linux-aarch64-low.cc
+++ b/gdbserver/linux-aarch64-low.cc
@@ -299,7 +299,7 @@ aarch64_fill_tlsregset (struct regcache *regcache, void *buf)
   collect_register (regcache, tls_regnum, tls_buf);
 
   /* Read TPIDR2, if it exists.  */
-  gdb::optional<int> regnum = find_regno_no_throw (regcache->tdesc, "tpidr2");
+  std::optional<int> regnum = find_regno_no_throw (regcache->tdesc, "tpidr2");
 
   if (regnum.has_value ())
     collect_register (regcache, *regnum, tls_buf + sizeof (uint64_t));
@@ -316,7 +316,7 @@ aarch64_store_tlsregset (struct regcache *regcache, const void *buf)
   supply_register (regcache, tls_regnum, tls_buf);
 
   /* Write TPIDR2, if it exists.  */
-  gdb::optional<int> regnum = find_regno_no_throw (regcache->tdesc, "tpidr2");
+  std::optional<int> regnum = find_regno_no_throw (regcache->tdesc, "tpidr2");
 
   if (regnum.has_value ())
     supply_register (regcache, *regnum, tls_buf + sizeof (uint64_t));
diff --git a/gdbserver/regcache.cc b/gdbserver/regcache.cc
index 0b1141662ac..2e75a948a19 100644
--- a/gdbserver/regcache.cc
+++ b/gdbserver/regcache.cc
@@ -249,7 +249,7 @@ registers_from_string (struct regcache *regcache, char *buf)
 
 /* See regcache.h */
 
-gdb::optional<int>
+std::optional<int>
 find_regno_no_throw (const struct target_desc *tdesc, const char *name)
 {
   for (int i = 0; i < tdesc->reg_defs.size (); ++i)
@@ -263,7 +263,7 @@ find_regno_no_throw (const struct target_desc *tdesc, const char *name)
 int
 find_regno (const struct target_desc *tdesc, const char *name)
 {
-  gdb::optional<int> regnum = find_regno_no_throw (tdesc, name);
+  std::optional<int> regnum = find_regno_no_throw (tdesc, name);
 
   if (regnum.has_value ())
     return *regnum;
diff --git a/gdbserver/regcache.h b/gdbserver/regcache.h
index 7248bcf5808..4700c03f104 100644
--- a/gdbserver/regcache.h
+++ b/gdbserver/regcache.h
@@ -112,7 +112,7 @@ int register_size (const struct target_desc *tdesc, int n);
 
 /* No throw version of find_regno.  If NAME is not a known register, return
    an empty value.  */
-gdb::optional<int> find_regno_no_throw (const struct target_desc *tdesc,
+std::optional<int> find_regno_no_throw (const struct target_desc *tdesc,
 					const char *name);
 
 int find_regno (const struct target_desc *tdesc, const char *name);
diff --git a/gdbserver/win32-low.cc b/gdbserver/win32-low.cc
index 3246957ec44..3842c80daff 100644
--- a/gdbserver/win32-low.cc
+++ b/gdbserver/win32-low.cc
@@ -1019,7 +1019,7 @@ get_child_debug_event (DWORD *continue_status,
 
   windows_process.attaching = 0;
   {
-    gdb::optional<pending_stop> stop
+    std::optional<pending_stop> stop
       = windows_process.fetch_pending_stop (debug_threads);
     if (stop.has_value ())
       {
diff --git a/gdbsupport/common-debug.h b/gdbsupport/common-debug.h
index 33b15a005f1..8908669696c 100644
--- a/gdbsupport/common-debug.h
+++ b/gdbsupport/common-debug.h
@@ -20,7 +20,7 @@
 #ifndef COMMON_COMMON_DEBUG_H
 #define COMMON_COMMON_DEBUG_H
 
-#include "gdbsupport/gdb_optional.h"
+#include <optional>
 #include "gdbsupport/preprocessor.h"
 
 #include <stdarg.h>
@@ -200,7 +200,7 @@ struct scoped_debug_start_end
   const char *m_end_prefix;
 
   /* The result of formatting the format string in the constructor.  */
-  gdb::optional<std::string> m_msg;
+  std::optional<std::string> m_msg;
 
   /* True is a non-nullptr format was passed to the constructor.  */
   bool m_with_format;
diff --git a/gdbsupport/event-loop.cc b/gdbsupport/event-loop.cc
index 52e7fd2223f..031c2ff500f 100644
--- a/gdbsupport/event-loop.cc
+++ b/gdbsupport/event-loop.cc
@@ -33,7 +33,7 @@
 #include <sys/types.h>
 #include "gdbsupport/gdb_sys_time.h"
 #include "gdbsupport/gdb_select.h"
-#include "gdbsupport/gdb_optional.h"
+#include <optional>
 #include "gdbsupport/scope-exit.h"
 
 /* See event-loop.h.  */
@@ -246,7 +246,7 @@ gdb_do_one_event (int mstimeout)
      When the timeout is reached, events are not monitored again:
      they already have been checked in the loop above. */
 
-  gdb::optional<int> timer_id;
+  std::optional<int> timer_id;
 
   SCOPE_EXIT 
     {
@@ -258,7 +258,7 @@ gdb_do_one_event (int mstimeout)
     timer_id = create_timer (mstimeout,
 			     [] (gdb_client_data arg)
 			     {
-			       ((gdb::optional<int> *) arg)->reset ();
+			       ((std::optional<int> *) arg)->reset ();
 			     },
 			     &timer_id);
   return gdb_wait_for_event (1);
diff --git a/gdbsupport/filestuff.cc b/gdbsupport/filestuff.cc
index 9e61fea1195..334bae88dce 100644
--- a/gdbsupport/filestuff.cc
+++ b/gdbsupport/filestuff.cc
@@ -504,7 +504,7 @@ mkdir_recursive (const char *dir)
 
 /* See gdbsupport/filestuff.h.  */
 
-gdb::optional<std::string>
+std::optional<std::string>
 read_text_file_to_string (const char *path)
 {
   gdb_file_up file = gdb_fopen_cloexec (path, "r");
diff --git a/gdbsupport/filestuff.h b/gdbsupport/filestuff.h
index 48bef51f259..206b51e50e9 100644
--- a/gdbsupport/filestuff.h
+++ b/gdbsupport/filestuff.h
@@ -131,6 +131,6 @@ extern bool mkdir_recursive (const char *dir);
 
 /* Read the entire content of file PATH into an std::string.  */
 
-extern gdb::optional<std::string> read_text_file_to_string (const char *path);
+extern std::optional<std::string> read_text_file_to_string (const char *path);
 
 #endif /* COMMON_FILESTUFF_H */
diff --git a/gdbsupport/forward-scope-exit.h b/gdbsupport/forward-scope-exit.h
index bf591ddf170..0552e1132f0 100644
--- a/gdbsupport/forward-scope-exit.h
+++ b/gdbsupport/forward-scope-exit.h
@@ -52,9 +52,9 @@
       obj.release ();  // Optional cancel if needed.
 
    forward_scope_exit is also handy when you would need to wrap a
-   scope_exit in a gdb::optional:
+   scope_exit in a std::optional:
 
-      gdb::optional<longjmp_breakpoint_cleanup> cleanup;
+      std::optional<longjmp_breakpoint_cleanup> cleanup;
       if (some condition)
 	cleanup.emplace (thread);
       ...
@@ -62,7 +62,7 @@
 	cleanup->release ();
 
    since with scope exit, you would have to know the scope_exit's
-   callable template type when you create the gdb::optional:
+   callable template type when you create the std::optional:
 
      gdb:optional<scope_exit<what goes here?>>
 
diff --git a/gdbsupport/range-chain.h b/gdbsupport/range-chain.h
index 01d6cf0e4fc..3cebce014ad 100644
--- a/gdbsupport/range-chain.h
+++ b/gdbsupport/range-chain.h
@@ -90,7 +90,7 @@ struct range_chain
     /* The current iterator into one of the vector ranges.  If no
        value then this (outer) iterator is at the end of the overall
        range.  */
-    gdb::optional<typename Range::iterator> m_current;
+    std::optional<typename Range::iterator> m_current;
     /* Vector of ranges.  */
     const std::vector<Range> &m_ranges;
   };
diff --git a/gdbsupport/scoped_ignore_sigttou.h b/gdbsupport/scoped_ignore_sigttou.h
index a3f8361512a..558fb7f0a29 100644
--- a/gdbsupport/scoped_ignore_sigttou.h
+++ b/gdbsupport/scoped_ignore_sigttou.h
@@ -26,7 +26,7 @@
 #ifdef SIGTTOU
 
 /* Simple wrapper that allows lazy initialization / destruction of T.
-   Slightly more efficient than gdb::optional, because it doesn't
+   Slightly more efficient than std::optional, because it doesn't
    carry storage to track whether the object has been initialized.  */
 template<typename T>
 class lazy_init
diff --git a/gdbsupport/thread-pool.cc b/gdbsupport/thread-pool.cc
index 1c871ed378f..bbe043dc0a3 100644
--- a/gdbsupport/thread-pool.cc
+++ b/gdbsupport/thread-pool.cc
@@ -225,7 +225,7 @@ thread_pool::thread_function ()
 
   while (true)
     {
-      optional<task_t> t;
+      std::optional<task_t> t;
 
       {
 	/* We want to hold the lock while examining the task list, but
diff --git a/gdbsupport/thread-pool.h b/gdbsupport/thread-pool.h
index cb8696e1fa4..d5e1dc7fce1 100644
--- a/gdbsupport/thread-pool.h
+++ b/gdbsupport/thread-pool.h
@@ -30,7 +30,7 @@
 #include <condition_variable>
 #include <future>
 #endif
-#include "gdbsupport/gdb_optional.h"
+#include <optional>
 
 namespace gdb
 {
@@ -198,7 +198,7 @@ class thread_pool
      to represent a task.  If the optional is empty, then this means
      that the receiving thread should terminate.  If the optional is
      non-empty, then it is an actual task to evaluate.  */
-  std::queue<optional<task_t>> m_tasks;
+  std::queue<std::optional<task_t>> m_tasks;
 
   /* A condition variable and mutex that are used for communication
      between the main thread and the worker threads.  */
-- 
2.34.1


^ permalink raw reply	[flat|nested] 39+ messages in thread

* [PATCH 05/11] gdbsupport: remove gdb::optional
  2023-10-13 14:44 [PATCH 00/11] GDB: Require C++17 Lancelot Six
                   ` (3 preceding siblings ...)
  2023-10-13 14:44 ` [PATCH 04/11] gdb: Replace gdb::optional with std::optional Lancelot Six
@ 2023-10-13 14:44 ` Lancelot Six
  2023-10-13 14:44 ` [PATCH 06/11] gdb: Use std::string_view instead of gdb::string_view Lancelot Six
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 39+ messages in thread
From: Lancelot Six @ 2023-10-13 14:44 UTC (permalink / raw)
  To: gdb-patches; +Cc: Lancelot Six

The previous patch migrated all the uses of gdb::optional to use
std::optional instead,  so gdb::optional can be removed entirely
as well as the self-tests which came with it.

Change-Id: I96ecd67b850b01be10ef00eb85a78ac647d5adc7
---
 gdb/Makefile.in                        |   1 -
 gdb/unittests/optional-selftests.c     |  95 --------
 gdb/unittests/optional/assignment/1.cc | 196 ----------------
 gdb/unittests/optional/assignment/2.cc | 194 ----------------
 gdb/unittests/optional/assignment/3.cc | 157 -------------
 gdb/unittests/optional/assignment/4.cc | 157 -------------
 gdb/unittests/optional/assignment/5.cc |  81 -------
 gdb/unittests/optional/assignment/6.cc |  91 --------
 gdb/unittests/optional/assignment/7.cc |  30 ---
 gdb/unittests/optional/cons/copy.cc    | 127 -----------
 gdb/unittests/optional/cons/default.cc |  59 -----
 gdb/unittests/optional/cons/move.cc    | 125 -----------
 gdb/unittests/optional/cons/value.cc   | 295 -------------------------
 gdb/unittests/optional/in_place.cc     |  66 ------
 gdb/unittests/optional/observers/1.cc  |  32 ---
 gdb/unittests/optional/observers/2.cc  |  36 ---
 gdbsupport/gdb_optional.h              | 233 -------------------
 17 files changed, 1975 deletions(-)
 delete mode 100644 gdb/unittests/optional-selftests.c
 delete mode 100644 gdb/unittests/optional/assignment/1.cc
 delete mode 100644 gdb/unittests/optional/assignment/2.cc
 delete mode 100644 gdb/unittests/optional/assignment/3.cc
 delete mode 100644 gdb/unittests/optional/assignment/4.cc
 delete mode 100644 gdb/unittests/optional/assignment/5.cc
 delete mode 100644 gdb/unittests/optional/assignment/6.cc
 delete mode 100644 gdb/unittests/optional/assignment/7.cc
 delete mode 100644 gdb/unittests/optional/cons/copy.cc
 delete mode 100644 gdb/unittests/optional/cons/default.cc
 delete mode 100644 gdb/unittests/optional/cons/move.cc
 delete mode 100644 gdb/unittests/optional/cons/value.cc
 delete mode 100644 gdb/unittests/optional/in_place.cc
 delete mode 100644 gdb/unittests/optional/observers/1.cc
 delete mode 100644 gdb/unittests/optional/observers/2.cc
 delete mode 100644 gdbsupport/gdb_optional.h

diff --git a/gdb/Makefile.in b/gdb/Makefile.in
index 9c0a0bff2cd..413ce1ea68a 100644
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -469,7 +469,6 @@ SELFTESTS_SRCS = \
 	unittests/memrange-selftests.c \
 	unittests/offset-type-selftests.c \
 	unittests/observable-selftests.c \
-	unittests/optional-selftests.c \
 	unittests/packed-selftests.c \
 	unittests/parallel-for-selftests.c \
 	unittests/parse-connection-spec-selftests.c \
diff --git a/gdb/unittests/optional-selftests.c b/gdb/unittests/optional-selftests.c
deleted file mode 100644
index 51135b8b98c..00000000000
--- a/gdb/unittests/optional-selftests.c
+++ /dev/null
@@ -1,95 +0,0 @@
-/* Self tests for optional for GDB, the GNU debugger.
-
-   Copyright (C) 2017-2023 Free Software Foundation, Inc.
-
-   This file is part of GDB.
-
-   This program 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 of the License, or
-   (at your option) any later version.
-
-   This program 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.
-
-   You should have received a copy of the GNU General Public License
-   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
-
-#include "defs.h"
-#include "gdbsupport/selftest.h"
-#include "gdbsupport/gdb_optional.h"
-
-/* Used by the included .cc files below.  Included here because the
-   included test files are wrapped in a namespace.  */
-#include <vector>
-#include <string>
-#include <memory>
-
-/* libstdc++'s testsuite uses VERIFY.  */
-#define VERIFY SELF_CHECK
-
-/* Used to disable testing features not supported by
-   std::optional.  */
-#define GDB_OPTIONAL
-
-namespace selftests {
-namespace optional {
-
-/* The actual tests live in separate files, which were originally
-   copied over from libstdc++'s testsuite.  To preserve the structure
-   and help with comparison with the original tests, the file names
-   have been preserved, and only minimal modification was done to have
-   them compile against std::optional instead of std::optional:
-
-     - std::optional->gdb:optional, etc.
-     - ATTRIBUTE_UNUSED in a few places
-     - wrap each file in a namespace so they can all be compiled as a
-       single unit.
-     - libstdc++'s license and formatting style was preserved.
-*/
-
-#include "optional/assignment/1.cc"
-#include "optional/assignment/2.cc"
-#include "optional/assignment/3.cc"
-#include "optional/assignment/4.cc"
-#include "optional/assignment/5.cc"
-#include "optional/assignment/6.cc"
-#include "optional/assignment/7.cc"
-#include "optional/cons/copy.cc"
-#include "optional/cons/default.cc"
-#include "optional/cons/move.cc"
-#include "optional/cons/value.cc"
-#include "optional/in_place.cc"
-#include "optional/observers/1.cc"
-#include "optional/observers/2.cc"
-
-static void
-run_tests ()
-{
-  assign_1::test ();
-  assign_2::test ();
-  assign_3::test ();
-  assign_4::test ();
-  assign_5::test ();
-  assign_6::test ();
-  assign_7::test ();
-  cons_copy::test ();
-  cons_default::test ();
-  cons_move::test ();
-  cons_value::test ();
-  in_place::test ();
-  observers_1::test ();
-  observers_2::test ();
-}
-
-} /* namespace optional */
-} /* namespace selftests */
-
-void _initialize_optional_selftests ();
-void
-_initialize_optional_selftests ()
-{
-  selftests::register_test ("optional", selftests::optional::run_tests);
-}
diff --git a/gdb/unittests/optional/assignment/1.cc b/gdb/unittests/optional/assignment/1.cc
deleted file mode 100644
index 6a68f7d4002..00000000000
--- a/gdb/unittests/optional/assignment/1.cc
+++ /dev/null
@@ -1,196 +0,0 @@
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-namespace assign_1 {
-
-struct exception {};
-
-static int counter = 0;
-
-struct mixin_counter
-{
-  mixin_counter() { ++counter; }
-  mixin_counter(mixin_counter const&) { ++counter; }
-  ~mixin_counter() { --counter; }
-};
-
-struct value_type : private mixin_counter
-{
-  enum state_type
-  {
-    zero,
-    moved_from,
-    throwing_construction,
-    throwing_copy,
-    throwing_copy_assignment,
-    throwing_move,
-    throwing_move_assignment,
-    threw,
-  };
-
-  value_type() = default;
-
-  explicit value_type(state_type state_)
-  : state(state_)
-  {
-    throw_if(throwing_construction);
-  }
-
-  value_type(value_type const& other)
-  : state(other.state)
-  {
-    throw_if(throwing_copy);
-  }
-
-  value_type&
-  operator=(value_type const& other)
-  {
-    state = other.state;
-    throw_if(throwing_copy_assignment);
-    return *this;
-  }
-
-  value_type(value_type&& other)
-  : state(other.state)
-  {
-    other.state = moved_from;
-    throw_if(throwing_move);
-  }
-
-  value_type&
-  operator=(value_type&& other)
-  {
-    state = other.state;
-    other.state = moved_from;
-    throw_if(throwing_move_assignment);
-    return *this;
-  }
-
-  void throw_if(state_type match)
-  {
-    if(state == match)
-    {
-      state = threw;
-      throw exception {};
-    }
-  }
-
-  state_type state = zero;
-};
-
-static void
-test ()
-{
-  using O = gdb::optional<value_type>;
-  using S = value_type::state_type;
-  auto const make = [](S s = S::zero) { return O { gdb::in_place, s }; };
-
-  enum outcome_type { nothrow, caught, bad_catch };
-
-  // Check copy/move assignment for disengaged optional
-
-  // From disengaged optional
-  {
-    O o;
-    VERIFY( !o );
-    O p;
-    o = p;
-    VERIFY( !o );
-    VERIFY( !p );
-  }
-
-  {
-    O o;
-    VERIFY( !o );
-    O p;
-    o = std::move(p);
-    VERIFY( !o );
-    VERIFY( !p );
-  }
-
-#ifndef GDB_OPTIONAL
-  {
-    O o;
-    VERIFY( !o );
-    o = {};
-    VERIFY( !o );
-  }
-#endif
-
-  // From engaged optional
-  {
-    O o;
-    VERIFY( !o );
-    O p = make(S::throwing_copy_assignment);
-    o = p;
-    VERIFY( o && o->state == S::throwing_copy_assignment );
-    VERIFY( p && p->state == S::throwing_copy_assignment );
-  }
-
-  {
-    O o;
-    VERIFY( !o );
-    O p = make(S::throwing_move_assignment);
-    o = std::move(p);
-    VERIFY( o && o->state == S::throwing_move_assignment );
-    VERIFY( p && p->state == S::moved_from );
-  }
-
-  {
-    outcome_type outcome {};
-    O o;
-    VERIFY( !o );
-    O p = make(S::throwing_copy);
-
-    try
-    {
-      o = p;
-    }
-    catch(exception const&)
-    { outcome = caught; }
-    catch(...)
-    { outcome = bad_catch; }
-
-    VERIFY( outcome == caught );
-    VERIFY( !o );
-    VERIFY( p && p->state == S::throwing_copy );
-  }
-
-  {
-    outcome_type outcome {};
-    O o;
-    VERIFY( !o );
-    O p = make(S::throwing_move);
-
-    try
-    {
-      o = std::move(p);
-    }
-    catch(exception const&)
-    { outcome = caught; }
-    catch(...)
-    { outcome = bad_catch; }
-
-    VERIFY( outcome == caught );
-    VERIFY( !o );
-    VERIFY( p && p->state == S::moved_from );
-  }
-
-  VERIFY( counter == 0 );
-}
-
-} // namespace assign_1
diff --git a/gdb/unittests/optional/assignment/2.cc b/gdb/unittests/optional/assignment/2.cc
deleted file mode 100644
index 2e63a491920..00000000000
--- a/gdb/unittests/optional/assignment/2.cc
+++ /dev/null
@@ -1,194 +0,0 @@
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-namespace assign_2 {
-
-struct exception {};
-
-static int counter = 0;
-
-struct mixin_counter
-{
-  mixin_counter() { ++counter; }
-  mixin_counter(mixin_counter const&) { ++counter; }
-  ~mixin_counter() { --counter; }
-};
-
-struct value_type : private mixin_counter
-{
-  enum state_type
-  {
-    zero,
-    moved_from,
-    throwing_construction,
-    throwing_copy,
-    throwing_copy_assignment,
-    throwing_move,
-    throwing_move_assignment,
-    threw,
-  };
-
-  value_type() = default;
-
-  explicit value_type(state_type state_)
-  : state(state_)
-  {
-    throw_if(throwing_construction);
-  }
-
-  value_type(value_type const& other)
-  : state(other.state)
-  {
-    throw_if(throwing_copy);
-  }
-
-  value_type&
-  operator=(value_type const& other)
-  {
-    state = other.state;
-    throw_if(throwing_copy_assignment);
-    return *this;
-  }
-
-  value_type(value_type&& other)
-  : state(other.state)
-  {
-    other.state = moved_from;
-    throw_if(throwing_move);
-  }
-
-  value_type&
-  operator=(value_type&& other)
-  {
-    state = other.state;
-    other.state = moved_from;
-    throw_if(throwing_move_assignment);
-    return *this;
-  }
-
-  void throw_if(state_type match)
-  {
-    if(state == match)
-    {
-      state = threw;
-      throw exception {};
-    }
-  }
-
-  state_type state = zero;
-};
-
-static void
-test ()
-{
-  using O = gdb::optional<value_type>;
-  using S = value_type::state_type;
-  auto const make = [](S s = S::zero) { return O { gdb::in_place, s }; };
-
-  enum outcome_type { nothrow, caught, bad_catch };
-
-  // Check copy/move assignment for engaged optional
-
-  // From disengaged optional
-  {
-    O o = make(S::zero);
-    VERIFY( o );
-    O p;
-    o = p;
-    VERIFY( !o );
-    VERIFY( !p );
-  }
-
-  {
-    O o = make(S::zero);
-    VERIFY( o );
-    O p;
-    o = std::move(p);
-    VERIFY( !o );
-    VERIFY( !p );
-  }
-
-#ifndef GDB_OPTIONAL
-  {
-    O o = make(S::zero);
-    VERIFY( o );
-    o = {};
-    VERIFY( !o );
-  }
-#endif
-
-  // From engaged optional
-  {
-    O o = make(S::zero);
-    VERIFY( o );
-    O p = make(S::throwing_copy);
-    o = p;
-    VERIFY( o && o->state == S::throwing_copy);
-    VERIFY( p && p->state == S::throwing_copy);
-  }
-
-  {
-    O o = make(S::zero);
-    VERIFY( o );
-    O p = make(S::throwing_move);
-    o = std::move(p);
-    VERIFY( o && o->state == S::throwing_move);
-    VERIFY( p && p->state == S::moved_from);
-  }
-
-  {
-    ATTRIBUTE_UNUSED outcome_type outcome {};
-    O o = make(S::zero);
-    VERIFY( o );
-    O p = make(S::throwing_copy_assignment);
-
-    try
-    {
-      o = p;
-    }
-    catch(exception const&)
-    { outcome = caught; }
-    catch(...)
-    { outcome = bad_catch; }
-
-    VERIFY( o && o->state == S::threw);
-    VERIFY( p && p->state == S::throwing_copy_assignment);
-  }
-
-  {
-    ATTRIBUTE_UNUSED outcome_type outcome {};
-    O o = make(S::zero);
-    VERIFY( o );
-    O p = make(S::throwing_move_assignment);
-
-    try
-    {
-      o = std::move(p);
-    }
-    catch(exception const&)
-    { outcome = caught; }
-    catch(...)
-    { outcome = bad_catch; }
-
-    VERIFY( o && o->state == S::threw);
-    VERIFY( p && p->state == S::moved_from);
-  }
-
-  VERIFY( counter == 0 );
-}
-
-} // namespace assign_2
diff --git a/gdb/unittests/optional/assignment/3.cc b/gdb/unittests/optional/assignment/3.cc
deleted file mode 100644
index a1d0934fe79..00000000000
--- a/gdb/unittests/optional/assignment/3.cc
+++ /dev/null
@@ -1,157 +0,0 @@
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-namespace assign_3 {
-
-struct exception {};
-
-static int counter = 0;
-
-struct mixin_counter
-{
-  mixin_counter() { ++counter; }
-  mixin_counter(mixin_counter const&) { ++counter; }
-  ~mixin_counter() { --counter; }
-};
-
-struct value_type : private mixin_counter
-{
-  enum state_type
-  {
-    zero,
-    moved_from,
-    throwing_construction,
-    throwing_copy,
-    throwing_copy_assignment,
-    throwing_move,
-    throwing_move_assignment,
-    threw,
-  };
-
-  value_type() = default;
-
-  explicit value_type(state_type state_)
-  : state(state_)
-  {
-    throw_if(throwing_construction);
-  }
-
-  value_type(value_type const& other)
-  : state(other.state)
-  {
-    throw_if(throwing_copy);
-  }
-
-  value_type&
-  operator=(value_type const& other)
-  {
-    state = other.state;
-    throw_if(throwing_copy_assignment);
-    return *this;
-  }
-
-  value_type(value_type&& other)
-  : state(other.state)
-  {
-    other.state = moved_from;
-    throw_if(throwing_move);
-  }
-
-  value_type&
-  operator=(value_type&& other)
-  {
-    state = other.state;
-    other.state = moved_from;
-    throw_if(throwing_move_assignment);
-    return *this;
-  }
-
-  void throw_if(state_type match)
-  {
-    if(state == match)
-    {
-      state = threw;
-      throw exception {};
-    }
-  }
-
-  state_type state = zero;
-};
-
-static void
-test ()
-{
-  using O = gdb::optional<value_type>;
-  using S = value_type::state_type;
-  auto const make = [](S s = S::zero) { return value_type { s }; };
-
-  enum outcome_type { nothrow, caught, bad_catch };
-
-  // Check value assignment for disengaged optional
-
-  {
-    O o;
-    value_type v = make(S::throwing_copy_assignment);
-    o = v;
-    VERIFY( o && o->state == S::throwing_copy_assignment );
-  }
-
-  {
-    O o;
-    value_type v = make(S::throwing_move_assignment);
-    o = std::move(v);
-    VERIFY( o && o->state == S::throwing_move_assignment );
-  }
-
-  {
-    ATTRIBUTE_UNUSED outcome_type outcome {};
-    O o;
-    value_type v = make(S::throwing_copy);
-
-    try
-    {
-      o = v;
-    }
-    catch(exception const&)
-    { outcome = caught; }
-    catch(...)
-    { outcome = bad_catch; }
-
-    VERIFY( !o );
-  }
-
-  {
-    ATTRIBUTE_UNUSED outcome_type outcome {};
-    O o;
-    value_type v = make(S::throwing_move);
-
-    try
-    {
-      o = std::move(v);
-    }
-    catch(exception const&)
-    { outcome = caught; }
-    catch(...)
-    { outcome = bad_catch; }
-
-    VERIFY( !o );
-  }
-
-  VERIFY( counter == 0 );
-}
-
-} // namespace assign_3
diff --git a/gdb/unittests/optional/assignment/4.cc b/gdb/unittests/optional/assignment/4.cc
deleted file mode 100644
index 2ad5978a5b4..00000000000
--- a/gdb/unittests/optional/assignment/4.cc
+++ /dev/null
@@ -1,157 +0,0 @@
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-namespace assign_4 {
-
-struct exception {};
-
-static int counter = 0;
-
-struct mixin_counter
-{
-  mixin_counter() { ++counter; }
-  mixin_counter(mixin_counter const&) { ++counter; }
-  ~mixin_counter() { --counter; }
-};
-
-struct value_type : private mixin_counter
-{
-  enum state_type
-  {
-    zero,
-    moved_from,
-    throwing_construction,
-    throwing_copy,
-    throwing_copy_assignment,
-    throwing_move,
-    throwing_move_assignment,
-    threw,
-  };
-
-  value_type() = default;
-
-  explicit value_type(state_type state_)
-  : state(state_)
-  {
-    throw_if(throwing_construction);
-  }
-
-  value_type(value_type const& other)
-  : state(other.state)
-  {
-    throw_if(throwing_copy);
-  }
-
-  value_type&
-  operator=(value_type const& other)
-  {
-    state = other.state;
-    throw_if(throwing_copy_assignment);
-    return *this;
-  }
-
-  value_type(value_type&& other)
-  : state(other.state)
-  {
-    other.state = moved_from;
-    throw_if(throwing_move);
-  }
-
-  value_type&
-  operator=(value_type&& other)
-  {
-    state = other.state;
-    other.state = moved_from;
-    throw_if(throwing_move_assignment);
-    return *this;
-  }
-
-  void throw_if(state_type match)
-  {
-    if(state == match)
-    {
-      state = threw;
-      throw exception {};
-    }
-  }
-
-  state_type state = zero;
-};
-
-static void
-test ()
-{
-  using O = gdb::optional<value_type>;
-  using S = value_type::state_type;
-  auto const make = [](S s = S::zero) { return value_type { s }; };
-
-  enum outcome_type { nothrow, caught, bad_catch };
-
-  // Check value assignment for engaged optional
-
-  {
-    O o = make();
-    value_type v = make(S::throwing_copy);
-    o = v;
-    VERIFY( o && o->state == S::throwing_copy);
-  }
-
-  {
-    O o = make();
-    value_type v = make(S::throwing_move);
-    o = std::move(v);
-    VERIFY( o && o->state == S::throwing_move);
-  }
-
-  {
-    ATTRIBUTE_UNUSED outcome_type outcome {};
-    O o = make();
-    value_type v = make(S::throwing_copy_assignment);
-
-    try
-    {
-      o = v;
-    }
-    catch(exception const&)
-    { outcome = caught; }
-    catch(...)
-    { outcome = bad_catch; }
-
-    VERIFY( o && o->state == S::threw );
-  }
-
-  {
-    ATTRIBUTE_UNUSED outcome_type outcome {};
-    O o = make();
-    value_type v = make(S::throwing_move_assignment);
-
-    try
-    {
-      o = std::move(v);
-    }
-    catch(exception const&)
-    { outcome = caught; }
-    catch(...)
-    { outcome = bad_catch; }
-
-    VERIFY( o && o->state == S::threw );
-  }
-
-  VERIFY( counter == 0 );
-}
-
-} // namespace assign_4
diff --git a/gdb/unittests/optional/assignment/5.cc b/gdb/unittests/optional/assignment/5.cc
deleted file mode 100644
index 85016a27bfa..00000000000
--- a/gdb/unittests/optional/assignment/5.cc
+++ /dev/null
@@ -1,81 +0,0 @@
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-namespace assign_5 {
-
-static int counter = 0;
-
-struct mixin_counter
-{
-  mixin_counter() { ++counter; }
-  mixin_counter(mixin_counter const&) { ++counter; }
-  ~mixin_counter() { --counter; }
-};
-
-struct value_type : private mixin_counter { };
-
-static void
-test ()
-{
-  using O = gdb::optional<value_type>;
-
-  // Check std::nullopt_t and 'default' (= {}) assignment
-
-#ifndef GDB_OPTIONAL
-  {
-    O o;
-    o = std::nullopt;
-    VERIFY( !o );
-  }
-#endif
-
-#ifndef GDB_OPTIONAL
-  {
-    O o { gdb::in_place };
-    o = std::nullopt;
-    VERIFY( !o );
-  }
-#endif
-
-#ifndef GDB_OPTIONAL
-  {
-    O o;
-    o = {};
-    VERIFY( !o );
-  }
-#endif
-
-#ifndef GDB_OPTIONAL
-  {
-    O o { gdb::in_place };
-    o = {};
-    VERIFY( !o );
-  }
-#endif
-  {
-    gdb::optional<std::vector<int>> ovi{{1, 2, 3}};
-    VERIFY(ovi->size() == 3);
-    VERIFY((*ovi)[0] == 1 && (*ovi)[1] == 2 && (*ovi)[2] == 3);
-    ovi = {4, 5, 6, 7};
-    VERIFY(ovi->size() == 4);
-    VERIFY((*ovi)[0] == 4 && (*ovi)[1] == 5 &&
-	   (*ovi)[2] == 6 && (*ovi)[3] == 7);
-  }
-  VERIFY( counter == 0 );
-}
-
-} // namespace assign_5
diff --git a/gdb/unittests/optional/assignment/6.cc b/gdb/unittests/optional/assignment/6.cc
deleted file mode 100644
index d0ea95fa556..00000000000
--- a/gdb/unittests/optional/assignment/6.cc
+++ /dev/null
@@ -1,91 +0,0 @@
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-namespace assign_6 {
-
-static int counter = 0;
-
-struct mixin_counter
-{
-  mixin_counter() { ++counter; }
-  mixin_counter(mixin_counter const&) { ++counter; }
-  ~mixin_counter() { --counter; }
-};
-
-struct value_type : private mixin_counter
-{
-  value_type() = default;
-  value_type(int) : state(1) { }
-  value_type(std::initializer_list<char>, const char*) : state(2) { }
-  int state = 0;
-};
-
-static void
-test ()
-{
-  using O = gdb::optional<value_type>;
-
-  // Check emplace
-
-  {
-    O o;
-    o.emplace();
-    VERIFY( o && o->state == 0 );
-  }
-  {
-    O o { gdb::in_place, 0 };
-    o.emplace();
-    VERIFY( o && o->state == 0 );
-  }
-
-  {
-    O o;
-    o.emplace(0);
-    VERIFY( o && o->state == 1 );
-  }
-  {
-    O o { gdb::in_place };
-    o.emplace(0);
-    VERIFY( o && o->state == 1 );
-  }
-
-#ifndef GDB_OPTIONAL
-  {
-    O o;
-    o.emplace({ 'a' }, "");
-    VERIFY( o && o->state == 2 );
-  }
-  {
-    O o { gdb::in_place };
-    o.emplace({ 'a' }, "");
-    VERIFY( o && o->state == 2 );
-  }
-#endif
-  {
-    O o;
-    VERIFY(&o.emplace(0) == &*o);
-#ifndef GDB_OPTIONAL
-    VERIFY(&o.emplace({ 'a' }, "") == &*o);
-#endif
-  }
-
-  static_assert( !std::is_constructible<O, std::initializer_list<int>, int>(), "" );
-
-  VERIFY( counter == 0 );
-}
-
-} // namespace assign_6
diff --git a/gdb/unittests/optional/assignment/7.cc b/gdb/unittests/optional/assignment/7.cc
deleted file mode 100644
index a9bd181e317..00000000000
--- a/gdb/unittests/optional/assignment/7.cc
+++ /dev/null
@@ -1,30 +0,0 @@
-// Copyright (C) 2016-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-namespace assign_7 {
-
-static void
-test ()
-{
-  gdb::optional<int> o{666};
-  VERIFY(o && *o == 666);
-  o.reset();
-  VERIFY(!o);
-  static_assert(noexcept(std::declval<gdb::optional<int>>().reset()), "");
-}
-
-} // namespace assign_7
diff --git a/gdb/unittests/optional/cons/copy.cc b/gdb/unittests/optional/cons/copy.cc
deleted file mode 100644
index 87a08f9a52b..00000000000
--- a/gdb/unittests/optional/cons/copy.cc
+++ /dev/null
@@ -1,127 +0,0 @@
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-namespace cons_copy {
-
-struct tracker
-{
-  tracker(int value) : value(value) { ++count; }
-  ~tracker() { --count; }
-
-  tracker(tracker const& other) : value(other.value) { ++count; }
-  tracker(tracker&& other) : value(other.value)
-  {
-    other.value = -1;
-    ++count;
-  }
-
-  tracker& operator=(tracker const&) = default;
-  tracker& operator=(tracker&&) = default;
-
-  int value;
-
-  static int count;
-};
-
-int tracker::count = 0;
-
-struct exception { };
-
-struct throwing_copy
-{
-  throwing_copy() = default;
-  throwing_copy(throwing_copy const&) { throw exception {}; }
-};
-
-static void
-test ()
-{
-  // [20.5.4.1] Constructors
-
-  {
-    gdb::optional<long> o;
-    auto copy = o;
-    VERIFY( !copy );
-    VERIFY( !o );
-  }
-
-  {
-    const long val = 0x1234ABCD;
-    gdb::optional<long> o { gdb::in_place, val};
-    auto copy = o;
-    VERIFY( copy );
-    VERIFY( *copy == val );
-#ifndef GDB_OPTIONAL
-    VERIFY( o && o == val );
-#endif
-  }
-
-  {
-    gdb::optional<tracker> o;
-    auto copy = o;
-    VERIFY( !copy );
-    VERIFY( tracker::count == 0 );
-    VERIFY( !o );
-  }
-
-  {
-    gdb::optional<tracker> o { gdb::in_place, 333 };
-    auto copy = o;
-    VERIFY( copy );
-    VERIFY( copy->value == 333 );
-    VERIFY( tracker::count == 2 );
-    VERIFY( o && o->value == 333 );
-  }
-
-  enum outcome { nothrow, caught, bad_catch };
-
-  {
-    outcome result = nothrow;
-    gdb::optional<throwing_copy> o;
-
-    try
-    {
-      auto copy = o;
-    }
-    catch(exception const&)
-    { result = caught; }
-    catch(...)
-    { result = bad_catch; }
-
-    VERIFY( result == nothrow );
-  }
-
-  {
-    outcome result = nothrow;
-    gdb::optional<throwing_copy> o { gdb::in_place };
-
-    try
-    {
-      auto copy = o;
-    }
-    catch(exception const&)
-    { result = caught; }
-    catch(...)
-    { result = bad_catch; }
-
-    VERIFY( result == caught );
-  }
-
-  VERIFY( tracker::count == 0 );
-}
-
-} // namespace cons_copy
diff --git a/gdb/unittests/optional/cons/default.cc b/gdb/unittests/optional/cons/default.cc
deleted file mode 100644
index 6ed99c3b9e5..00000000000
--- a/gdb/unittests/optional/cons/default.cc
+++ /dev/null
@@ -1,59 +0,0 @@
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-namespace cons_default {
-
-struct tracker
-{
-  tracker() { ++count; }
-  ~tracker() { --count; }
-
-  tracker(tracker const&) { ++count; }
-  tracker(tracker&&) { ++count; }
-
-  tracker& operator=(tracker const&) = default;
-  tracker& operator=(tracker&&) = default;
-
-  static int count;
-};
-
-int tracker::count = 0;
-
-static void
-test ()
-{
-  // [20.5.4.1] Constructors
-
-  {
-    gdb::optional<tracker> o;
-    VERIFY( !o );
-  }
-
-  {
-    gdb::optional<tracker> o {};
-    VERIFY( !o );
-  }
-
-  {
-    gdb::optional<tracker> o = {};
-    VERIFY( !o );
-  }
-
-  VERIFY( tracker::count == 0 );
-}
-
-} // namespace cons_default
diff --git a/gdb/unittests/optional/cons/move.cc b/gdb/unittests/optional/cons/move.cc
deleted file mode 100644
index 398784ae7ec..00000000000
--- a/gdb/unittests/optional/cons/move.cc
+++ /dev/null
@@ -1,125 +0,0 @@
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-namespace cons_move {
-
-struct tracker
-{
-  tracker(int value) : value(value) { ++count; }
-  ~tracker() { --count; }
-
-  tracker(tracker const& other) : value(other.value) { ++count; }
-  tracker(tracker&& other) : value(other.value)
-  {
-    other.value = -1;
-    ++count;
-  }
-
-  tracker& operator=(tracker const&) = default;
-  tracker& operator=(tracker&&) = default;
-
-  int value;
-
-  static int count;
-};
-
-int tracker::count = 0;
-
-struct exception { };
-
-struct throwing_move
-{
-  throwing_move() = default;
-  throwing_move(throwing_move const&) { throw exception {}; }
-};
-
-static void
-test ()
-{
-  // [20.5.4.1] Constructors
-
-  {
-    gdb::optional<long> o;
-    auto moved_to = std::move(o);
-    VERIFY( !moved_to );
-    VERIFY( !o );
-  }
-
-  {
-    const long val = 0x1234ABCD;
-    gdb::optional<long> o { gdb::in_place, val};
-    auto moved_to = std::move(o);
-    VERIFY( moved_to );
-    VERIFY( *moved_to == val );
-    VERIFY( o && *o == val );
-  }
-
-  {
-    gdb::optional<tracker> o;
-    auto moved_to = std::move(o);
-    VERIFY( !moved_to );
-    VERIFY( tracker::count == 0 );
-    VERIFY( !o );
-  }
-
-  {
-    gdb::optional<tracker> o { gdb::in_place, 333 };
-    auto moved_to = std::move(o);
-    VERIFY( moved_to );
-    VERIFY( moved_to->value == 333 );
-    VERIFY( tracker::count == 2 );
-    VERIFY( o && o->value == -1 );
-  }
-
-  enum outcome { nothrow, caught, bad_catch };
-
-  {
-    outcome result = nothrow;
-    gdb::optional<throwing_move> o;
-
-    try
-    {
-      auto moved_to = std::move(o);
-    }
-    catch(exception const&)
-    { result = caught; }
-    catch(...)
-    { result = bad_catch; }
-
-    VERIFY( result == nothrow );
-  }
-
-  {
-    outcome result = nothrow;
-    gdb::optional<throwing_move> o { gdb::in_place };
-
-    try
-    {
-      auto moved_to = std::move(o);
-    }
-    catch(exception const&)
-    { result = caught; }
-    catch(...)
-    { result = bad_catch; }
-
-    VERIFY( result == caught );
-  }
-
-  VERIFY( tracker::count == 0 );
-}
-
-} // namespace cons_move
diff --git a/gdb/unittests/optional/cons/value.cc b/gdb/unittests/optional/cons/value.cc
deleted file mode 100644
index 7d4fd91cfe6..00000000000
--- a/gdb/unittests/optional/cons/value.cc
+++ /dev/null
@@ -1,295 +0,0 @@
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-namespace cons_value {
-
-struct tracker
-{
-  tracker(int value) : value(value) { ++count; }
-  ~tracker() { --count; }
-
-  tracker(tracker const& other) : value(other.value) { ++count; }
-  tracker(tracker&& other) : value(other.value)
-  {
-    other.value = -1;
-    ++count;
-  }
-
-  tracker& operator=(tracker const&) = default;
-  tracker& operator=(tracker&&) = default;
-
-  int value;
-
-  static int count;
-};
-
-int tracker::count = 0;
-
-struct exception { };
-
-struct throwing_construction
-{
-  explicit throwing_construction(bool propagate) : propagate(propagate) { }
-
-  throwing_construction(throwing_construction const& other)
-  : propagate(other.propagate)
-  {
-    if(propagate)
-      throw exception {};
-  }
-
-  bool propagate;
-};
-
-static void
-test ()
-{
-  // [20.5.4.1] Constructors
-
-  {
-    auto i = 0x1234ABCD;
-    gdb::optional<long> o { i };
-    VERIFY( o );
-    VERIFY( *o == 0x1234ABCD );
-    VERIFY( i == 0x1234ABCD );
-  }
-
-  {
-    auto i = 0x1234ABCD;
-    gdb::optional<long> o = i;
-    VERIFY( o );
-    VERIFY( *o == 0x1234ABCD );
-    VERIFY( i == 0x1234ABCD );
-  }
-
-  {
-    auto i = 0x1234ABCD;
-    gdb::optional<long> o = { i };
-    VERIFY( o );
-    VERIFY( *o == 0x1234ABCD );
-    VERIFY( i == 0x1234ABCD );
-  }
-
-  {
-    auto i = 0x1234ABCD;
-    gdb::optional<long> o { std::move(i) };
-    VERIFY( o );
-    VERIFY( *o == 0x1234ABCD );
-    VERIFY( i == 0x1234ABCD );
-  }
-
-  {
-    auto i = 0x1234ABCD;
-    gdb::optional<long> o = std::move(i);
-    VERIFY( o );
-    VERIFY( *o == 0x1234ABCD );
-    VERIFY( i == 0x1234ABCD );
-  }
-
-  {
-    auto i = 0x1234ABCD;
-    gdb::optional<long> o = { std::move(i) };
-    VERIFY( o );
-    VERIFY( *o == 0x1234ABCD );
-    VERIFY( i == 0x1234ABCD );
-  }
-
-#ifndef GDB_OPTIONAL
-  {
-    std::vector<int> v = { 0, 1, 2, 3, 4, 5 };
-    gdb::optional<std::vector<int>> o { v };
-    VERIFY( !v.empty() );
-    VERIFY( o->size() == 6 );
-  }
-#endif
-
-  {
-    std::vector<int> v = { 0, 1, 2, 3, 4, 5 };
-    gdb::optional<std::vector<int>> o = v;
-    VERIFY( !v.empty() );
-    VERIFY( o->size() == 6 );
-  }
-
-  {
-    std::vector<int> v = { 0, 1, 2, 3, 4, 5 };
-    gdb::optional<std::vector<int>> o { v };
-    VERIFY( !v.empty() );
-    VERIFY( o->size() == 6 );
-  }
-
-  {
-    std::vector<int> v = { 0, 1, 2, 3, 4, 5 };
-    gdb::optional<std::vector<int>> o { std::move(v) };
-    VERIFY( v.empty() );
-    VERIFY( o->size() == 6 );
-  }
-
-  {
-    std::vector<int> v = { 0, 1, 2, 3, 4, 5 };
-    gdb::optional<std::vector<int>> o = std::move(v);
-    VERIFY( v.empty() );
-    VERIFY( o->size() == 6 );
-  }
-
-  {
-    std::vector<int> v = { 0, 1, 2, 3, 4, 5 };
-    gdb::optional<std::vector<int>> o { std::move(v) };
-    VERIFY( v.empty() );
-    VERIFY( o->size() == 6 );
-  }
-
-  {
-    tracker t { 333 };
-    gdb::optional<tracker> o = t;
-    VERIFY( o->value == 333 );
-    VERIFY( tracker::count == 2 );
-    VERIFY( t.value == 333 );
-  }
-
-  {
-    tracker t { 333 };
-    gdb::optional<tracker> o = std::move(t);
-    VERIFY( o->value == 333 );
-    VERIFY( tracker::count == 2 );
-    VERIFY( t.value == -1 );
-  }
-
-  enum outcome { nothrow, caught, bad_catch };
-
-  {
-    outcome result = nothrow;
-    throwing_construction t { false };
-
-    try
-    {
-      gdb::optional<throwing_construction> o { t };
-    }
-    catch(exception const&)
-    { result = caught; }
-    catch(...)
-    { result = bad_catch; }
-
-    VERIFY( result == nothrow );
-  }
-
-  {
-    outcome result = nothrow;
-    throwing_construction t { true };
-
-    try
-    {
-      gdb::optional<throwing_construction> o { t };
-    }
-    catch(exception const&)
-    { result = caught; }
-    catch(...)
-    { result = bad_catch; }
-
-    VERIFY( result == caught );
-  }
-
-  {
-    outcome result = nothrow;
-    throwing_construction t { false };
-
-    try
-    {
-      gdb::optional<throwing_construction> o { std::move(t) };
-    }
-    catch(exception const&)
-    { result = caught; }
-    catch(...)
-    { result = bad_catch; }
-
-    VERIFY( result == nothrow );
-  }
-
-  {
-    outcome result = nothrow;
-    throwing_construction t { true };
-
-    try
-    {
-      gdb::optional<throwing_construction> o { std::move(t) };
-    }
-    catch(exception const&)
-    { result = caught; }
-    catch(...)
-    { result = bad_catch; }
-
-    VERIFY( result == caught );
-  }
-
-  {
-#ifndef GDB_OPTIONAL
-    gdb::optional<std::string> os = "foo";
-#endif
-    struct X
-    {
-      explicit X(int) {}
-      X& operator=(int) {return *this;}
-    };
-#ifndef GDB_OPTIONAL
-    gdb::optional<X> ox{42};
-#endif
-    gdb::optional<int> oi{42};
-#ifndef GDB_OPTIONAL
-    gdb::optional<X> ox2{oi};
-#endif
-    gdb::optional<std::string> os2;
-    os2 = "foo";
-#ifndef GDB_OPTIONAL
-    gdb::optional<X> ox3;
-    ox3 = 42;
-    gdb::optional<X> ox4;
-    ox4 = oi;
-#endif
-  }
-  {
-    // no converting construction.
-#ifndef GDB_OPTIONAL
-    gdb::optional<int> oi = gdb::optional<short>();
-    VERIFY(!bool(oi));
-    gdb::optional<std::string> os = gdb::optional<const char*>();
-    VERIFY(!bool(os));
-#endif
-    gdb::optional<gdb::optional<int>> ooi = gdb::optional<int>();
-    VERIFY(bool(ooi));
-    ooi = gdb::optional<int>();
-    VERIFY(bool(ooi));
-    ooi = gdb::optional<int>(42);
-    VERIFY(bool(ooi));
-    VERIFY(bool(*ooi));
-#ifndef GDB_OPTIONAL
-    gdb::optional<gdb::optional<int>> ooi2 = gdb::optional<short>();
-    VERIFY(bool(ooi2));
-    ooi2 = gdb::optional<short>();
-    VERIFY(bool(ooi2));
-    ooi2 = gdb::optional<short>(6);
-    VERIFY(bool(ooi2));
-    VERIFY(bool(*ooi2));
-    gdb::optional<gdb::optional<int>> ooi3 = gdb::optional<int>(42);
-    VERIFY(bool(ooi3));
-    VERIFY(bool(*ooi3));
-    gdb::optional<gdb::optional<int>> ooi4 = gdb::optional<short>(6);
-    VERIFY(bool(ooi4));
-    VERIFY(bool(*ooi4));
-#endif
-  }
-}
-
-} // namespace cons_value
diff --git a/gdb/unittests/optional/in_place.cc b/gdb/unittests/optional/in_place.cc
deleted file mode 100644
index 067f975a0d3..00000000000
--- a/gdb/unittests/optional/in_place.cc
+++ /dev/null
@@ -1,66 +0,0 @@
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-namespace in_place {
-
-static void
-test ()
-{
-  // [20.5.5] In-place construction
-  {
-    gdb::optional<int> o { gdb::in_place };
-    VERIFY( o );
-    VERIFY( *o == int() );
-
-#ifndef GDB_OPTIONAL
-    static_assert( !std::is_convertible<gdb::in_place_t, gdb::optional<int>>(), "" );
-#endif
-  }
-
-  {
-    gdb::optional<int> o { gdb::in_place, 42 };
-    VERIFY( o );
-    VERIFY( *o == 42 );
-  }
-
-  {
-    gdb::optional<std::vector<int>> o { gdb::in_place, 18, 4 };
-    VERIFY( o );
-    VERIFY( o->size() == 18 );
-    VERIFY( (*o)[17] == 4 );
-  }
-
-#ifndef GDB_OPTIONAL
-  {
-    gdb::optional<std::vector<int>> o { gdb::in_place, { 18, 4 } };
-    VERIFY( o );
-    VERIFY( o->size() == 2 );
-    VERIFY( (*o)[0] == 18 );
-  }
-#endif
-
-#ifndef GDB_OPTIONAL
-  {
-    gdb::optional<std::vector<int>> o { gdb::in_place, { 18, 4 }, std::allocator<int> {} };
-    VERIFY( o );
-    VERIFY( o->size() == 2 );
-    VERIFY( (*o)[0] == 18 );
-  }
-#endif
-}
-
-} // namespace in_place
diff --git a/gdb/unittests/optional/observers/1.cc b/gdb/unittests/optional/observers/1.cc
deleted file mode 100644
index 20f4176adf1..00000000000
--- a/gdb/unittests/optional/observers/1.cc
+++ /dev/null
@@ -1,32 +0,0 @@
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-namespace observers_1 {
-
-struct value_type
-{
-  int i;
-};
-
-static void
-test ()
-{
-  gdb::optional<value_type> o { value_type { 51 } };
-  VERIFY( (*o).i == 51 );
-}
-
-} // namespace observers_1
diff --git a/gdb/unittests/optional/observers/2.cc b/gdb/unittests/optional/observers/2.cc
deleted file mode 100644
index 0ad09ab5011..00000000000
--- a/gdb/unittests/optional/observers/2.cc
+++ /dev/null
@@ -1,36 +0,0 @@
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-namespace observers_2 {
-
-struct value_type
-{
-  int i;
-};
-
-void* operator&(const value_type&) = delete;
-
-static void
-test ()
-{
-  gdb::optional<value_type> o { value_type { 51 } };
-  VERIFY( o->i == 51 );
-  VERIFY( o->i == (*o).i );
-  VERIFY( &o->i == &(*o).i );
-}
-
-} // namespace observers_2
diff --git a/gdbsupport/gdb_optional.h b/gdbsupport/gdb_optional.h
deleted file mode 100644
index 9b7b7b2f7f4..00000000000
--- a/gdbsupport/gdb_optional.h
+++ /dev/null
@@ -1,233 +0,0 @@
-/* An optional object.
-
-   Copyright (C) 2017-2023 Free Software Foundation, Inc.
-
-   This file is part of GDB.
-
-   This program 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 of the License, or
-   (at your option) any later version.
-
-   This program 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.
-
-   You should have received a copy of the GNU General Public License
-   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
-
-#ifndef COMMON_GDB_OPTIONAL_H
-#define COMMON_GDB_OPTIONAL_H
-
-#include "gdbsupport/traits.h"
-
-namespace gdb
-{
-
-struct in_place_t
-{
-  explicit in_place_t () = default;
-};
-
-constexpr gdb::in_place_t in_place {};
-
-/* This class attempts to be a compatible subset of std::optional,
-   which is slated to be available in C++17.  This class optionally
-   holds an object of some type -- by default it is constructed not
-   holding an object, but later the object can be "emplaced".  This is
-   similar to using std::unique_ptr, but in-object allocation is
-   guaranteed.
-
-   Unlike std::optional, we currently only support copy/move
-   construction/assignment of an optional<T> from either exactly
-   optional<T> or T.  I.e., we don't support copy/move
-   construction/assignment from optional<U> or U, when U is a type
-   convertible to T.  Making that work depending on the definitions of
-   T and U is somewhat complicated, and currently the users of this
-   class don't need it.  */
-
-template<typename T>
-class optional
-{
-public:
-
-  constexpr optional ()
-    : m_dummy ()
-  {}
-
-  template<typename... Args>
-  constexpr optional (in_place_t, Args &&... args)
-    : m_item (std::forward<Args> (args)...),
-      m_instantiated (true)
-  {}
-
-  ~optional ()
-  { this->reset (); }
-
-  /* Copy and move constructors.  */
-
-  optional (const optional &other)
-  {
-    if (other.m_instantiated)
-      this->emplace (other.get ());
-  }
-
-  optional (optional &&other)
-    noexcept(std::is_nothrow_move_constructible<T> ())
-  {
-    if (other.m_instantiated)
-      this->emplace (std::move (other.get ()));
-  }
-
-  constexpr optional (const T &other)
-    : m_item (other),
-      m_instantiated (true)
-  {}
-
-  constexpr optional (T &&other)
-    noexcept (std::is_nothrow_move_constructible<T> ())
-    : m_item (std::move (other)),
-      m_instantiated (true)
-  {}
-
-  /* Assignment operators.  */
-
-  optional &
-  operator= (const optional &other)
-  {
-    if (m_instantiated && other.m_instantiated)
-      this->get () = other.get ();
-    else
-      {
-	if (other.m_instantiated)
-	  this->emplace (other.get ());
-	else
-	  this->reset ();
-      }
-
-    return *this;
-  }
-
-  optional &
-  operator= (optional &&other)
-    noexcept (And<std::is_nothrow_move_constructible<T>,
-	      std::is_nothrow_move_assignable<T>> ())
-  {
-    if (m_instantiated && other.m_instantiated)
-      this->get () = std::move (other.get ());
-    else
-      {
-	if (other.m_instantiated)
-	  this->emplace (std::move (other.get ()));
-	else
-	  this->reset ();
-      }
-    return *this;
-  }
-
-  optional &
-  operator= (const T &other)
-  {
-    if (m_instantiated)
-      this->get () = other;
-    else
-      this->emplace (other);
-    return *this;
-  }
-
-  optional &
-  operator= (T &&other)
-    noexcept (And<std::is_nothrow_move_constructible<T>,
-	      std::is_nothrow_move_assignable<T>> ())
-  {
-    if (m_instantiated)
-      this->get () = std::move (other);
-    else
-      this->emplace (std::move (other));
-    return *this;
-  }
-
-  template<typename... Args>
-  T &emplace (Args &&... args)
-  {
-    this->reset ();
-    new (&m_item) T (std::forward<Args>(args)...);
-    m_instantiated = true;
-    return this->get ();
-  }
-
-  /* Observers.  */
-  constexpr const T *operator-> () const
-  { return std::addressof (this->get ()); }
-
-  T *operator-> ()
-  { return std::addressof (this->get ()); }
-
-  constexpr const T &operator* () const &
-  { return this->get (); }
-
-  T &operator* () &
-  { return this->get (); }
-
-  T &&operator* () &&
-  { return std::move (this->get ()); }
-
-  constexpr const T &&operator* () const &&
-  { return std::move (this->get ()); }
-
-  constexpr explicit operator bool () const noexcept
-  { return m_instantiated; }
-
-  constexpr bool has_value () const noexcept
-  { return m_instantiated; }
-
-  /* 'reset' is a 'safe' operation with no precondition.  */
-  void reset () noexcept
-  {
-    if (m_instantiated)
-      this->destroy ();
-  }
-
-private:
-
-  /* Destroy the object.  */
-  void destroy ()
-  {
-    gdb_assert (m_instantiated);
-    m_instantiated = false;
-    m_item.~T ();
-  }
-
-  /* The get operations have m_instantiated as a precondition.  */
-  T &get () noexcept
-  {
-#if defined(_GLIBCXX_DEBUG) && __cplusplus >= 201402L
-    gdb_assert (this->has_value ());
-#endif
-    return m_item;
-  }
-  constexpr const T &get () const noexcept
-  {
-#if defined(_GLIBCXX_DEBUG) && __cplusplus >= 201402L
-    gdb_assert (this->has_value ());
-#endif
-    return m_item;
-  }
-
-  /* The object.  */
-  union
-  {
-    struct { } m_dummy;
-    T m_item;
-    volatile char dont_use; /* Silences -Wmaybe-uninitialized warning, see
-			       PR gcc/80635.  */
-  };
-
-  /* True if the object was ever emplaced.  */
-  bool m_instantiated = false;
-};
-
-}
-
-#endif /* COMMON_GDB_OPTIONAL_H */
-- 
2.34.1


^ permalink raw reply	[flat|nested] 39+ messages in thread

* [PATCH 06/11] gdb: Use std::string_view instead of gdb::string_view
  2023-10-13 14:44 [PATCH 00/11] GDB: Require C++17 Lancelot Six
                   ` (4 preceding siblings ...)
  2023-10-13 14:44 ` [PATCH 05/11] gdbsupport: remove gdb::optional Lancelot Six
@ 2023-10-13 14:44 ` Lancelot Six
  2023-10-14 21:50   ` Tom Tromey
  2023-10-13 14:44 ` [PATCH 07/11] gdb: Remove uses of gdb::to_string (const std::string_view &) Lancelot Six
                   ` (5 subsequent siblings)
  11 siblings, 1 reply; 39+ messages in thread
From: Lancelot Six @ 2023-10-13 14:44 UTC (permalink / raw)
  To: gdb-patches; +Cc: Lancelot Six

Given that GDB now requires a C++17, replace all uses of
gdb::string_view with std::string_view.

This change has mostly been done automatically:
- gdb::string_view -> std::string_view
- #include "gdbsupport/gdb_string_view.h" -> #include <string_view>

The implementation and tests of gdb::string_view are unchanged, they will
be removed in a following patch.

Change-Id: Ibb806a7e9c79eb16a55c87c6e41ad396fecf0207
---
 gdb/ada-lang.c               |  8 +++---
 gdb/amdgpu-tdep.c            | 50 ++++++++++++++++++------------------
 gdb/cli/cli-script.c         |  4 +--
 gdb/dbxread.c                | 18 ++++++-------
 gdb/debuginfod-support.c     |  6 ++---
 gdb/dwarf2/cooked-index.c    |  6 ++---
 gdb/dwarf2/cooked-index.h    |  2 +-
 gdb/dwarf2/index-common.c    |  2 +-
 gdb/dwarf2/index-common.h    |  2 +-
 gdb/dwarf2/read.c            |  2 +-
 gdb/elfread.c                |  8 +++---
 gdb/language.c               |  2 +-
 gdb/linux-tdep.c             |  8 +++---
 gdb/mdebugread.c             | 18 ++++++-------
 gdb/minsyms.c                |  4 +--
 gdb/minsyms.h                |  2 +-
 gdb/psymtab.c                |  2 +-
 gdb/psymtab.h                |  4 +--
 gdb/solib-rocm.c             | 20 +++++++--------
 gdb/split-name.c             |  4 +--
 gdb/split-name.h             |  4 +--
 gdb/stabsread.c              |  2 +-
 gdb/symtab.c                 | 14 +++++-----
 gdb/symtab.h                 | 14 +++++-----
 gdb/tui/tui-io.c             |  2 +-
 gdb/tui/tui-win.c            |  6 ++---
 gdb/xcoffread.c              | 18 ++++++-------
 gdbsupport/common-utils.h    |  8 +++---
 gdbsupport/format.h          |  4 +--
 gdbsupport/gdb_string_view.h |  2 +-
 30 files changed, 123 insertions(+), 123 deletions(-)

diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 58c70160d31..3e394619399 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -1035,7 +1035,7 @@ find_case_fold_entry (uint32_t c)
    rather than emitting a warning.  Result good to next call.  */
 
 static const char *
-ada_fold_name (gdb::string_view name, bool throw_on_error = false)
+ada_fold_name (std::string_view name, bool throw_on_error = false)
 {
   static std::string fold_storage;
 
@@ -13250,7 +13250,7 @@ do_exact_match (const char *symbol_search_name,
 
 ada_lookup_name_info::ada_lookup_name_info (const lookup_name_info &lookup_name)
 {
-  gdb::string_view user_name = lookup_name.name ();
+  std::string_view user_name = lookup_name.name ();
 
   if (!user_name.empty () && user_name[0] == '<')
     {
@@ -13269,7 +13269,7 @@ ada_lookup_name_info::ada_lookup_name_info (const lookup_name_info &lookup_name)
     {
       m_verbatim_p = false;
 
-      m_encoded_p = user_name.find ("__") != gdb::string_view::npos;
+      m_encoded_p = user_name.find ("__") != std::string_view::npos;
 
       if (!m_encoded_p)
 	{
@@ -13326,7 +13326,7 @@ literal_symbol_name_matcher (const char *symbol_search_name,
 			     const lookup_name_info &lookup_name,
 			     completion_match_result *comp_match_res)
 {
-  gdb::string_view name_view = lookup_name.name ();
+  std::string_view name_view = lookup_name.name ();
 
   if (lookup_name.completion_mode ()
       ? (strncmp (symbol_search_name, name_view.data (),
diff --git a/gdb/amdgpu-tdep.c b/gdb/amdgpu-tdep.c
index 3a521a43977..48dc8db6bcc 100644
--- a/gdb/amdgpu-tdep.c
+++ b/gdb/amdgpu-tdep.c
@@ -237,7 +237,7 @@ struct amd_dbgapi_register_type_flags : public amd_dbgapi_register_type
   using container_type = std::vector<field>;
   using const_iterator_type = container_type::const_iterator;
 
-  amd_dbgapi_register_type_flags (unsigned int bit_size, gdb::string_view name)
+  amd_dbgapi_register_type_flags (unsigned int bit_size, std::string_view name)
     : amd_dbgapi_register_type (kind::FLAGS,
 				make_lookup_name (bit_size, name)),
       m_bit_size (bit_size),
@@ -270,7 +270,7 @@ struct amd_dbgapi_register_type_flags : public amd_dbgapi_register_type
   const std::string &name () const
   { return m_name; }
 
-  static std::string make_lookup_name (int bits, gdb::string_view name)
+  static std::string make_lookup_name (int bits, std::string_view name)
   {
     std::string res = string_printf ("flags%d_t ", bits);
     res.append (name.data (), name.size ());
@@ -297,7 +297,7 @@ struct amd_dbgapi_register_type_enum : public amd_dbgapi_register_type
   using container_type = std::vector<enumerator>;
   using const_iterator_type = container_type::const_iterator;
 
-  amd_dbgapi_register_type_enum (gdb::string_view name)
+  amd_dbgapi_register_type_enum (std::string_view name)
     : amd_dbgapi_register_type (kind::ENUM, make_lookup_name (name)),
       m_name (name.data (), name.length ())
   {}
@@ -326,7 +326,7 @@ struct amd_dbgapi_register_type_enum : public amd_dbgapi_register_type
   const std::string &name () const
   { return m_name; }
 
-  static std::string make_lookup_name (gdb::string_view name)
+  static std::string make_lookup_name (std::string_view name)
   {
     std::string res = "enum ";
     res.append (name.data (), name.length ());
@@ -349,7 +349,7 @@ using amd_dbgapi_register_type_map
 /* Parse S as a ULONGEST, raise an error on overflow.  */
 
 static ULONGEST
-try_strtoulst (gdb::string_view s)
+try_strtoulst (std::string_view s)
 {
   errno = 0;
   ULONGEST value = strtoulst (s.data (), nullptr, 0);
@@ -365,7 +365,7 @@ try_strtoulst (gdb::string_view s)
 #define WSOPT "[ \t]*"
 
 static const amd_dbgapi_register_type &
-parse_amd_dbgapi_register_type (gdb::string_view type_name,
+parse_amd_dbgapi_register_type (std::string_view type_name,
 				amd_dbgapi_register_type_map &type_map);
 
 
@@ -373,7 +373,7 @@ parse_amd_dbgapi_register_type (gdb::string_view type_name,
 
 static void
 parse_amd_dbgapi_register_type_enum_fields
-  (amd_dbgapi_register_type_enum &enum_type, gdb::string_view fields)
+  (amd_dbgapi_register_type_enum &enum_type, std::string_view fields)
 {
   compiled_regex regex (/* name */
 			"^(" IDENTIFIER ")"
@@ -394,8 +394,8 @@ parse_amd_dbgapi_register_type_enum_fields
       auto sv_from_match = [fields] (const regmatch_t &m)
 	{ return fields.substr (m.rm_so, m.rm_eo - m.rm_so); };
 
-      gdb::string_view name = sv_from_match (matches[1]);
-      gdb::string_view value_str = sv_from_match (matches[2]);
+      std::string_view name = sv_from_match (matches[1]);
+      std::string_view value_str = sv_from_match (matches[2]);
       ULONGEST value = try_strtoulst (value_str);
 
       if (value > std::numeric_limits<uint32_t>::max ())
@@ -412,7 +412,7 @@ parse_amd_dbgapi_register_type_enum_fields
 static void
 parse_amd_dbgapi_register_type_flags_fields
   (amd_dbgapi_register_type_flags &flags_type,
-   int bits, gdb::string_view name, gdb::string_view fields,
+   int bits, std::string_view name, std::string_view fields,
    amd_dbgapi_register_type_map &type_map)
 {
   gdb_assert (bits == 32 || bits == 64);
@@ -439,9 +439,9 @@ parse_amd_dbgapi_register_type_flags_fields
       auto sv_from_match = [fields] (const regmatch_t &m)
 	{ return fields.substr (m.rm_so, m.rm_eo - m.rm_so); };
 
-      gdb::string_view field_type_str = sv_from_match (matches[1]);
-      gdb::string_view field_name = sv_from_match (matches[3]);
-      gdb::string_view pos_begin_str = sv_from_match (matches[4]);
+      std::string_view field_type_str = sv_from_match (matches[1]);
+      std::string_view field_name = sv_from_match (matches[3]);
+      std::string_view pos_begin_str = sv_from_match (matches[4]);
       ULONGEST pos_begin = try_strtoulst (pos_begin_str);
 
       if (field_type_str == "bool")
@@ -452,7 +452,7 @@ parse_amd_dbgapi_register_type_flags_fields
 	  if (matches[5].rm_so == -1)
 	    error (_("Missing end bit position"));
 
-	  gdb::string_view pos_end_str = sv_from_match (matches[5]);
+	  std::string_view pos_end_str = sv_from_match (matches[5]);
 	  ULONGEST pos_end = try_strtoulst (pos_end_str.substr (1));
 	  const amd_dbgapi_register_type &field_type
 	    = parse_amd_dbgapi_register_type (field_type_str, type_map);
@@ -467,7 +467,7 @@ parse_amd_dbgapi_register_type_flags_fields
 /* parse_amd_dbgapi_register_type helper for scalars.  */
 
 static const amd_dbgapi_register_type &
-parse_amd_dbgapi_register_type_scalar (gdb::string_view name,
+parse_amd_dbgapi_register_type_scalar (std::string_view name,
 				       amd_dbgapi_register_type_map &type_map)
 {
   std::string name_str = gdb::to_string (name);
@@ -513,24 +513,24 @@ parse_amd_dbgapi_register_type_scalar (gdb::string_view name,
    details about the format.  */
 
 static const amd_dbgapi_register_type &
-parse_amd_dbgapi_register_type (gdb::string_view type_str,
+parse_amd_dbgapi_register_type (std::string_view type_str,
 				amd_dbgapi_register_type_map &type_map)
 {
   size_t pos_open_bracket = type_str.find_last_of ('[');
   auto sv_from_match = [type_str] (const regmatch_t &m)
     { return type_str.substr (m.rm_so, m.rm_eo - m.rm_so); };
 
-  if (pos_open_bracket != gdb::string_view::npos)
+  if (pos_open_bracket != std::string_view::npos)
     {
       /* Vector types.  */
-      gdb::string_view element_type_str
+      std::string_view element_type_str
 	= type_str.substr (0, pos_open_bracket);
       const amd_dbgapi_register_type &element_type
 	= parse_amd_dbgapi_register_type (element_type_str, type_map);
 
       size_t pos_close_bracket = type_str.find_last_of (']');
-      gdb_assert (pos_close_bracket != gdb::string_view::npos);
-      gdb::string_view count_str_view
+      gdb_assert (pos_close_bracket != std::string_view::npos);
+      std::string_view count_str_view
 	= type_str.substr (pos_open_bracket + 1,
 			    pos_close_bracket - pos_open_bracket);
       std::string count_str = gdb::to_string (count_str_view);
@@ -567,9 +567,9 @@ parse_amd_dbgapi_register_type (gdb::string_view type_str,
       if (res == REG_NOMATCH)
 	error (_("Failed to parse flags type string"));
 
-      gdb::string_view flags_keyword = sv_from_match (matches[1]);
+      std::string_view flags_keyword = sv_from_match (matches[1]);
       unsigned int bit_size = flags_keyword == "flags32_t" ? 32 : 64;
-      gdb::string_view name = sv_from_match (matches[2]);
+      std::string_view name = sv_from_match (matches[2]);
       std::string lookup_name
 	= amd_dbgapi_register_type_flags::make_lookup_name (bit_size, name);
       auto existing_type_it = type_map.find (lookup_name);
@@ -596,7 +596,7 @@ parse_amd_dbgapi_register_type (gdb::string_view type_str,
 
 	  amd_dbgapi_register_type_flags_up flags_type
 	    (new amd_dbgapi_register_type_flags (bit_size, name));
-	  gdb::string_view fields_without_braces = sv_from_match (matches[4]);
+	  std::string_view fields_without_braces = sv_from_match (matches[4]);
 
 	  parse_amd_dbgapi_register_type_flags_fields
 	    (*flags_type, bit_size, name, fields_without_braces, type_map);
@@ -620,7 +620,7 @@ parse_amd_dbgapi_register_type (gdb::string_view type_str,
       if (res == REG_NOMATCH)
 	error (_("Failed to parse flags type string"));
 
-      gdb::string_view name = sv_from_match (matches[1]);
+      std::string_view name = sv_from_match (matches[1]);
 
       std::string lookup_name
 	= amd_dbgapi_register_type_enum::make_lookup_name (name);
@@ -648,7 +648,7 @@ parse_amd_dbgapi_register_type (gdb::string_view type_str,
 
 	  amd_dbgapi_register_type_enum_up enum_type
 	    (new amd_dbgapi_register_type_enum (name));
-	  gdb::string_view fields_without_braces = sv_from_match (matches[3]);
+	  std::string_view fields_without_braces = sv_from_match (matches[3]);
 
 	  parse_amd_dbgapi_register_type_enum_fields
 	    (*enum_type, fields_without_braces);
diff --git a/gdb/cli/cli-script.c b/gdb/cli/cli-script.c
index 8ec5689ebcf..b355a6dc81e 100644
--- a/gdb/cli/cli-script.c
+++ b/gdb/cli/cli-script.c
@@ -35,7 +35,7 @@
 #include "extension.h"
 #include "interps.h"
 #include "compile/compile.h"
-#include "gdbsupport/gdb_string_view.h"
+#include <string_view>
 #include "python/python.h"
 #include "guile/guile.h"
 
@@ -103,7 +103,7 @@ class user_args
   std::string m_command_line;
 
   /* The arguments.  Each element points inside M_COMMAND_LINE.  */
-  std::vector<gdb::string_view> m_args;
+  std::vector<std::string_view> m_args;
 };
 
 /* The stack of arguments passed to user defined functions.  We need a
diff --git a/gdb/dbxread.c b/gdb/dbxread.c
index 3afafa77fb4..b92193bdadd 100644
--- a/gdb/dbxread.c
+++ b/gdb/dbxread.c
@@ -1483,7 +1483,7 @@ read_dbx_symtab (minimal_symbol_reader &reader,
 	    {
 	    case 'S':
 	      if (pst != nullptr)
-		pst->add_psymbol (gdb::string_view (sym_name, sym_len), true,
+		pst->add_psymbol (std::string_view (sym_name, sym_len), true,
 				  VAR_DOMAIN, LOC_STATIC,
 				  data_sect_index,
 				  psymbol_placement::STATIC,
@@ -1500,7 +1500,7 @@ read_dbx_symtab (minimal_symbol_reader &reader,
 	      /* The addresses in these entries are reported to be
 		 wrong.  See the code that reads 'G's for symtabs.  */
 	      if (pst != nullptr)
-		pst->add_psymbol (gdb::string_view (sym_name, sym_len), true,
+		pst->add_psymbol (std::string_view (sym_name, sym_len), true,
 				  VAR_DOMAIN, LOC_STATIC,
 				  data_sect_index,
 				  psymbol_placement::GLOBAL,
@@ -1525,7 +1525,7 @@ read_dbx_symtab (minimal_symbol_reader &reader,
 		      && namestring[0] != ' '))
 		{
 		  if (pst != nullptr)
-		    pst->add_psymbol (gdb::string_view (sym_name, sym_len),
+		    pst->add_psymbol (std::string_view (sym_name, sym_len),
 				      true, STRUCT_DOMAIN, LOC_TYPEDEF, -1,
 				      psymbol_placement::STATIC,
 				      unrelocated_addr (0),
@@ -1540,7 +1540,7 @@ read_dbx_symtab (minimal_symbol_reader &reader,
 		    {
 		      /* Also a typedef with the same name.  */
 		      if (pst != nullptr)
-			pst->add_psymbol (gdb::string_view (sym_name, sym_len),
+			pst->add_psymbol (std::string_view (sym_name, sym_len),
 					  true, VAR_DOMAIN, LOC_TYPEDEF, -1,
 					  psymbol_placement::STATIC,
 					  unrelocated_addr (0),
@@ -1559,7 +1559,7 @@ read_dbx_symtab (minimal_symbol_reader &reader,
 	      if (p != namestring)	/* a name is there, not just :T...  */
 		{
 		  if (pst != nullptr)
-		    pst->add_psymbol (gdb::string_view (sym_name, sym_len),
+		    pst->add_psymbol (std::string_view (sym_name, sym_len),
 				      true, VAR_DOMAIN, LOC_TYPEDEF, -1,
 				      psymbol_placement::STATIC,
 				      unrelocated_addr (0),
@@ -1627,7 +1627,7 @@ read_dbx_symtab (minimal_symbol_reader &reader,
 		      /* Note that the value doesn't matter for
 			 enum constants in psymtabs, just in symtabs.  */
 		      if (pst != nullptr)
-			pst->add_psymbol (gdb::string_view (p, q - p), true,
+			pst->add_psymbol (std::string_view (p, q - p), true,
 					  VAR_DOMAIN, LOC_CONST, -1,
 					  psymbol_placement::STATIC,
 					  unrelocated_addr (0),
@@ -1652,7 +1652,7 @@ read_dbx_symtab (minimal_symbol_reader &reader,
 	    case 'c':
 	      /* Constant, e.g. from "const" in Pascal.  */
 	      if (pst != nullptr)
-		pst->add_psymbol (gdb::string_view (sym_name, sym_len), true,
+		pst->add_psymbol (std::string_view (sym_name, sym_len), true,
 				  VAR_DOMAIN, LOC_CONST, -1,
 				  psymbol_placement::STATIC,
 				  unrelocated_addr (0),
@@ -1712,7 +1712,7 @@ read_dbx_symtab (minimal_symbol_reader &reader,
 		  textlow_not_set = 0;
 		}
 	      if (pst != nullptr)
-		pst->add_psymbol (gdb::string_view (sym_name, sym_len), true,
+		pst->add_psymbol (std::string_view (sym_name, sym_len), true,
 				  VAR_DOMAIN, LOC_BLOCK,
 				  SECT_OFF_TEXT (objfile),
 				  psymbol_placement::STATIC,
@@ -1771,7 +1771,7 @@ read_dbx_symtab (minimal_symbol_reader &reader,
 		  textlow_not_set = 0;
 		}
 	      if (pst != nullptr)
-		pst->add_psymbol (gdb::string_view (sym_name, sym_len), true,
+		pst->add_psymbol (std::string_view (sym_name, sym_len), true,
 				  VAR_DOMAIN, LOC_BLOCK,
 				  SECT_OFF_TEXT (objfile),
 				  psymbol_placement::GLOBAL,
diff --git a/gdb/debuginfod-support.c b/gdb/debuginfod-support.c
index 1ebd98ca705..0e202ff5d96 100644
--- a/gdb/debuginfod-support.c
+++ b/gdb/debuginfod-support.c
@@ -246,11 +246,11 @@ debuginfod_is_enabled ()
       gdb_printf (_("\nThis GDB supports auto-downloading debuginfo " \
 		    "from the following URLs:\n"));
 
-      gdb::string_view url_view (urls);
+      std::string_view url_view (urls);
       while (true)
 	{
 	  size_t off = url_view.find_first_not_of (' ');
-	  if (off == gdb::string_view::npos)
+	  if (off == std::string_view::npos)
 	    break;
 	  url_view = url_view.substr (off);
 	  /* g++ 11.2.1 on s390x, g++ 11.3.1 on ppc64le and g++ 11 on
@@ -266,7 +266,7 @@ debuginfod_is_enabled ()
 	     styled_string (file_name_style.style (),
 			    gdb::to_string (url_view.substr (0,
 							     off)).c_str ()));
-	  if (off == gdb::string_view::npos)
+	  if (off == std::string_view::npos)
 	    break;
 	  url_view = url_view.substr (off);
 	}
diff --git a/gdb/dwarf2/cooked-index.c b/gdb/dwarf2/cooked-index.c
index 58ea541a5c9..7c4af3a1681 100644
--- a/gdb/dwarf2/cooked-index.c
+++ b/gdb/dwarf2/cooked-index.c
@@ -266,9 +266,9 @@ cooked_index_shard::handle_gnat_encoded_entry (cooked_index_entry *entry,
   std::string canonical = ada_decode (entry->name, false, false);
   if (canonical.empty ())
     return {};
-  std::vector<gdb::string_view> names = split_name (canonical.c_str (),
+  std::vector<std::string_view> names = split_name (canonical.c_str (),
 						    split_style::DOT_STYLE);
-  gdb::string_view tail = names.back ();
+  std::string_view tail = names.back ();
   names.pop_back ();
 
   const cooked_index_entry *parent = nullptr;
@@ -333,7 +333,7 @@ cooked_index_shard::do_finalize ()
   auto eq_entry = [] (const void *a, const void *b) -> int
     {
       const cooked_index_entry *ae = (const cooked_index_entry *) a;
-      const gdb::string_view *sv = (const gdb::string_view *) b;
+      const std::string_view *sv = (const std::string_view *) b;
       return (strlen (ae->canonical) == sv->length ()
 	      && strncasecmp (ae->canonical, sv->data (), sv->length ()) == 0);
     };
diff --git a/gdb/dwarf2/cooked-index.h b/gdb/dwarf2/cooked-index.h
index 5aacb321c91..5675ea68bb8 100644
--- a/gdb/dwarf2/cooked-index.h
+++ b/gdb/dwarf2/cooked-index.h
@@ -25,7 +25,7 @@
 #include "symtab.h"
 #include "hashtab.h"
 #include "dwarf2/index-common.h"
-#include "gdbsupport/gdb_string_view.h"
+#include <string_view>
 #include "quick-symbol.h"
 #include "gdbsupport/gdb_obstack.h"
 #include "addrmap.h"
diff --git a/gdb/dwarf2/index-common.c b/gdb/dwarf2/index-common.c
index 07330a86da1..04b04f93a61 100644
--- a/gdb/dwarf2/index-common.c
+++ b/gdb/dwarf2/index-common.c
@@ -58,7 +58,7 @@ dwarf5_djb_hash (const char *str_)
 /* See dwarf-index-common.h.  */
 
 uint32_t
-dwarf5_djb_hash (gdb::string_view str)
+dwarf5_djb_hash (std::string_view str)
 {
   /* Note: tolower here ignores UTF-8, which isn't fully compliant.
      See http://dwarfstd.org/ShowIssue.php?issue=161027.1.  */
diff --git a/gdb/dwarf2/index-common.h b/gdb/dwarf2/index-common.h
index 23e814a240b..79d3a59220e 100644
--- a/gdb/dwarf2/index-common.h
+++ b/gdb/dwarf2/index-common.h
@@ -54,6 +54,6 @@ uint32_t dwarf5_djb_hash (const char *str_);
 
 /* Symbol name hashing function as specified by DWARF-5.  */
 
-uint32_t dwarf5_djb_hash (gdb::string_view str_);
+uint32_t dwarf5_djb_hash (std::string_view str_);
 
 #endif /* DWARF_INDEX_COMMON_H */
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index e40353975c1..1846f7160cc 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -16884,7 +16884,7 @@ cooked_index_functions::expand_symtabs_matching
 
   for (enum language lang : unique_styles)
     {
-      std::vector<gdb::string_view> name_vec
+      std::vector<std::string_view> name_vec
 	= lookup_name_without_params.split_name (lang);
       std::string last_name = gdb::to_string (name_vec.back ());
 
diff --git a/gdb/elfread.c b/gdb/elfread.c
index 7900dfbc388..e153dfcedd3 100644
--- a/gdb/elfread.c
+++ b/gdb/elfread.c
@@ -46,7 +46,7 @@
 #include "auxv.h"
 #include "mdebugread.h"
 #include "ctfread.h"
-#include "gdbsupport/gdb_string_view.h"
+#include <string_view>
 #include "gdbsupport/scoped_fd.h"
 #include "debuginfod-support.h"
 #include "dwarf2/public.h"
@@ -197,7 +197,7 @@ elf_locate_sections (asection *sectp, struct elfinfo *ei)
 
 static struct minimal_symbol *
 record_minimal_symbol (minimal_symbol_reader &reader,
-		       gdb::string_view name, bool copy_name,
+		       std::string_view name, bool copy_name,
 		       unrelocated_addr address,
 		       enum minimal_symbol_type ms_type,
 		       asection *bfd_section, struct objfile *objfile)
@@ -505,7 +505,7 @@ elf_symtab_read (minimal_symbol_reader &reader,
 		  && !is_plt
 		  && (elf_sym->version & VERSYM_HIDDEN) == 0)
 		record_minimal_symbol (reader,
-				       gdb::string_view (sym->name, len),
+				       std::string_view (sym->name, len),
 				       true, unrelocated_addr (symaddr),
 				       ms_type, sym->section, objfile);
 	      else if (is_plt)
@@ -519,7 +519,7 @@ elf_symtab_read (minimal_symbol_reader &reader,
 		      struct minimal_symbol *mtramp;
 
 		      mtramp = record_minimal_symbol
-			(reader, gdb::string_view (sym->name, len), true,
+			(reader, std::string_view (sym->name, len), true,
 			 unrelocated_addr (symaddr),
 			 mst_solib_trampoline, sym->section, objfile);
 		      if (mtramp)
diff --git a/gdb/language.c b/gdb/language.c
index c768971be42..cfd4a621e6b 100644
--- a/gdb/language.c
+++ b/gdb/language.c
@@ -641,7 +641,7 @@ default_symbol_name_matcher (const char *symbol_search_name,
 			     const lookup_name_info &lookup_name,
 			     completion_match_result *comp_match_res)
 {
-  gdb::string_view name = lookup_name.name ();
+  std::string_view name = lookup_name.name ();
   completion_match_for_lcd *match_for_lcd
     = (comp_match_res != NULL ? &comp_match_res->match_for_lcd : NULL);
   strncmp_iw_mode mode = (lookup_name.completion_mode ()
diff --git a/gdb/linux-tdep.c b/gdb/linux-tdep.c
index 6dcc56cd562..c71f5a6dcd3 100644
--- a/gdb/linux-tdep.c
+++ b/gdb/linux-tdep.c
@@ -457,13 +457,13 @@ struct mapping
 {
   ULONGEST addr;
   ULONGEST endaddr;
-  gdb::string_view permissions;
+  std::string_view permissions;
   ULONGEST offset;
-  gdb::string_view device;
+  std::string_view device;
   ULONGEST inode;
 
   /* This field is guaranteed to be NULL-terminated, hence it is not a
-     gdb::string_view.  */
+     std::string_view.  */
   const char *filename;
 };
 
@@ -1384,7 +1384,7 @@ parse_smaps_data (const char *data,
 
       /* Decode permissions.  */
       auto has_perm = [&m] (char c)
-	{ return m.permissions.find (c) != gdb::string_view::npos; };
+	{ return m.permissions.find (c) != std::string_view::npos; };
       read = has_perm ('r');
       write = has_perm ('w');
       exec = has_perm ('x');
diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c
index cd6638224e7..fc731605991 100644
--- a/gdb/mdebugread.c
+++ b/gdb/mdebugread.c
@@ -3050,7 +3050,7 @@ parse_partial_symbols (minimal_symbol_reader &reader,
 		    switch (p[1])
 		      {
 		      case 'S':
-			pst->add_psymbol (gdb::string_view (namestring,
+			pst->add_psymbol (std::string_view (namestring,
 							    p - namestring),
 					  true, VAR_DOMAIN, LOC_STATIC,
 					  SECT_OFF_DATA (objfile),
@@ -3063,7 +3063,7 @@ parse_partial_symbols (minimal_symbol_reader &reader,
 			/* The addresses in these entries are reported
 			   to be wrong.  See the code that reads 'G's
 			   for symtabs.  */
-			pst->add_psymbol (gdb::string_view (namestring,
+			pst->add_psymbol (std::string_view (namestring,
 							    p - namestring),
 					  true, VAR_DOMAIN, LOC_STATIC,
 					  SECT_OFF_DATA (objfile),
@@ -3085,7 +3085,7 @@ parse_partial_symbols (minimal_symbol_reader &reader,
 				&& namestring[0] != ' '))
 			  {
 			    pst->add_psymbol
-			      (gdb::string_view (namestring, p - namestring),
+			      (std::string_view (namestring, p - namestring),
 			       true, STRUCT_DOMAIN, LOC_TYPEDEF, -1,
 			       psymbol_placement::STATIC,
 			       unrelocated_addr (0),
@@ -3095,7 +3095,7 @@ parse_partial_symbols (minimal_symbol_reader &reader,
 			      {
 				/* Also a typedef with the same name.  */
 				pst->add_psymbol
-				  (gdb::string_view (namestring,
+				  (std::string_view (namestring,
 						     p - namestring),
 				   true, VAR_DOMAIN, LOC_TYPEDEF, -1,
 				   psymbol_placement::STATIC,
@@ -3111,7 +3111,7 @@ parse_partial_symbols (minimal_symbol_reader &reader,
 						   just :T...  */
 			  {
 			    pst->add_psymbol
-			      (gdb::string_view (namestring,
+			      (std::string_view (namestring,
 						 p - namestring),
 			       true, VAR_DOMAIN, LOC_TYPEDEF, -1,
 			       psymbol_placement::STATIC,
@@ -3178,7 +3178,7 @@ parse_partial_symbols (minimal_symbol_reader &reader,
 				/* Note that the value doesn't matter for
 				   enum constants in psymtabs, just in
 				   symtabs.  */
-				pst->add_psymbol (gdb::string_view (p,
+				pst->add_psymbol (std::string_view (p,
 								    q - p),
 						  true, VAR_DOMAIN,
 						  LOC_CONST, -1,
@@ -3199,7 +3199,7 @@ parse_partial_symbols (minimal_symbol_reader &reader,
 			continue;
 		      case 'c':
 			/* Constant, e.g. from "const" in Pascal.  */
-			pst->add_psymbol (gdb::string_view (namestring,
+			pst->add_psymbol (std::string_view (namestring,
 							    p - namestring),
 					  true, VAR_DOMAIN, LOC_CONST, -1,
 					  psymbol_placement::STATIC,
@@ -3215,7 +3215,7 @@ parse_partial_symbols (minimal_symbol_reader &reader,
 			    function_outside_compilation_unit_complaint
 			      (copy.c_str ());
 			  }
-			pst->add_psymbol (gdb::string_view (namestring,
+			pst->add_psymbol (std::string_view (namestring,
 							    p - namestring),
 					  true, VAR_DOMAIN, LOC_BLOCK,
 					  SECT_OFF_TEXT (objfile),
@@ -3236,7 +3236,7 @@ parse_partial_symbols (minimal_symbol_reader &reader,
 			    function_outside_compilation_unit_complaint
 			      (copy.c_str ());
 			  }
-			pst->add_psymbol (gdb::string_view (namestring,
+			pst->add_psymbol (std::string_view (namestring,
 							    p - namestring),
 					  true, VAR_DOMAIN, LOC_BLOCK,
 					  SECT_OFF_TEXT (objfile),
diff --git a/gdb/minsyms.c b/gdb/minsyms.c
index 1d778822858..72e500be959 100644
--- a/gdb/minsyms.c
+++ b/gdb/minsyms.c
@@ -1170,7 +1170,7 @@ mst_str (minimal_symbol_type t)
 /* See minsyms.h.  */
 
 struct minimal_symbol *
-minimal_symbol_reader::record_full (gdb::string_view name,
+minimal_symbol_reader::record_full (std::string_view name,
 				    bool copy_name, unrelocated_addr address,
 				    enum minimal_symbol_type ms_type,
 				    int section)
@@ -1510,7 +1510,7 @@ minimal_symbol_reader::install ()
 	       {
 		 size_t idx = msym - msymbols;
 		 msym->compute_and_set_names
-		   (gdb::string_view (msym->linkage_name (),
+		   (std::string_view (msym->linkage_name (),
 				      hash_values[idx].name_length),
 		    false,
 		    m_objfile->per_bfd,
diff --git a/gdb/minsyms.h b/gdb/minsyms.h
index f3a2474c796..ee415c4db41 100644
--- a/gdb/minsyms.h
+++ b/gdb/minsyms.h
@@ -118,7 +118,7 @@ class minimal_symbol_reader
      SECTION - the symbol's section
   */
 
-  struct minimal_symbol *record_full (gdb::string_view name,
+  struct minimal_symbol *record_full (std::string_view name,
 				      bool copy_name,
 				      unrelocated_addr address,
 				      enum minimal_symbol_type ms_type,
diff --git a/gdb/psymtab.c b/gdb/psymtab.c
index 484d4eaa651..d4cd5810c20 100644
--- a/gdb/psymtab.c
+++ b/gdb/psymtab.c
@@ -1208,7 +1208,7 @@ partial_symtab::add_psymbol (const partial_symbol &psymbol,
 /* See psymtab.h.  */
 
 void
-partial_symtab::add_psymbol (gdb::string_view name, bool copy_name,
+partial_symtab::add_psymbol (std::string_view name, bool copy_name,
 			     domain_enum domain,
 			     enum address_class theclass,
 			     short section,
diff --git a/gdb/psymtab.h b/gdb/psymtab.h
index 4bafc6e998e..005a63cbba8 100644
--- a/gdb/psymtab.h
+++ b/gdb/psymtab.h
@@ -21,7 +21,7 @@
 #define PSYMTAB_H
 
 #include "objfiles.h"
-#include "gdbsupport/gdb_string_view.h"
+#include <string_view>
 #include "gdbsupport/gdb_obstack.h"
 #include "symfile.h"
 #include "gdbsupport/next-iterator.h"
@@ -346,7 +346,7 @@ struct partial_symtab
      LANGUAGE is the language from which the symbol originates.  This will
      influence, amongst other things, how the symbol name is demangled. */
 
-  void add_psymbol (gdb::string_view name,
+  void add_psymbol (std::string_view name,
 		    bool copy_name, domain_enum domain,
 		    enum address_class theclass,
 		    short section,
diff --git a/gdb/solib-rocm.c b/gdb/solib-rocm.c
index b24d0e8fb23..27cefb9604b 100644
--- a/gdb/solib-rocm.c
+++ b/gdb/solib-rocm.c
@@ -451,8 +451,8 @@ rocm_code_object_stream_memory::read (bfd *, void *buf, file_ptr size,
 static gdb_bfd_iovec_base *
 rocm_bfd_iovec_open (bfd *abfd, inferior *inferior)
 {
-  gdb::string_view uri (bfd_get_filename (abfd));
-  gdb::string_view protocol_delim = "://";
+  std::string_view uri (bfd_get_filename (abfd));
+  std::string_view protocol_delim = "://";
   size_t protocol_end = uri.find (protocol_delim);
   std::string protocol = gdb::to_string (uri.substr (0, protocol_end));
   protocol_end += protocol_delim.length ();
@@ -460,7 +460,7 @@ rocm_bfd_iovec_open (bfd *abfd, inferior *inferior)
   std::transform (protocol.begin (), protocol.end (), protocol.begin (),
 		  [] (unsigned char c) { return std::tolower (c); });
 
-  gdb::string_view path;
+  std::string_view path;
   size_t path_end = uri.find_first_of ("#?", protocol_end);
   if (path_end != std::string::npos)
     path = uri.substr (protocol_end, path_end++ - protocol_end);
@@ -476,7 +476,7 @@ rocm_bfd_iovec_open (bfd *abfd, inferior *inferior)
 	&& std::isxdigit (path[i + 1])
 	&& std::isxdigit (path[i + 2]))
       {
-	gdb::string_view hex_digits = path.substr (i + 1, 2);
+	std::string_view hex_digits = path.substr (i + 1, 2);
 	decoded_path += std::stoi (gdb::to_string (hex_digits), 0, 16);
 	i += 2;
       }
@@ -484,7 +484,7 @@ rocm_bfd_iovec_open (bfd *abfd, inferior *inferior)
       decoded_path += path[i];
 
   /* Tokenize the query/fragment.  */
-  std::vector<gdb::string_view> tokens;
+  std::vector<std::string_view> tokens;
   size_t pos, last = path_end;
   while ((pos = uri.find ('&', last)) != std::string::npos)
     {
@@ -496,15 +496,15 @@ rocm_bfd_iovec_open (bfd *abfd, inferior *inferior)
     tokens.emplace_back (uri.substr (last));
 
   /* Create a tag-value map from the tokenized query/fragment.  */
-  std::unordered_map<gdb::string_view, gdb::string_view,
+  std::unordered_map<std::string_view, std::string_view,
 		     gdb::string_view_hash> params;
-  for (gdb::string_view token : tokens)
+  for (std::string_view token : tokens)
     {
       size_t delim = token.find ('=');
       if (delim != std::string::npos)
 	{
-	  gdb::string_view tag = token.substr (0, delim);
-	  gdb::string_view val = token.substr (delim + 1);
+	  std::string_view tag = token.substr (0, delim);
+	  std::string_view val = token.substr (delim + 1);
 	  params.emplace (tag, val);
 	}
     }
@@ -514,7 +514,7 @@ rocm_bfd_iovec_open (bfd *abfd, inferior *inferior)
       ULONGEST offset = 0;
       ULONGEST size = 0;
 
-      auto try_strtoulst = [] (gdb::string_view v)
+      auto try_strtoulst = [] (std::string_view v)
 	{
 	  errno = 0;
 	  ULONGEST value = strtoulst (v.data (), nullptr, 0);
diff --git a/gdb/split-name.c b/gdb/split-name.c
index 0253b3cf675..0805cb82700 100644
--- a/gdb/split-name.c
+++ b/gdb/split-name.c
@@ -23,10 +23,10 @@
 
 /* See split-name.h.  */
 
-std::vector<gdb::string_view>
+std::vector<std::string_view>
 split_name (const char *name, split_style style)
 {
-  std::vector<gdb::string_view> result;
+  std::vector<std::string_view> result;
   unsigned int previous_len = 0;
 
   switch (style)
diff --git a/gdb/split-name.h b/gdb/split-name.h
index 7648cf9b900..ad2862e222d 100644
--- a/gdb/split-name.h
+++ b/gdb/split-name.h
@@ -20,7 +20,7 @@
 #ifndef GDB_SPLIT_NAME_H
 #define GDB_SPLIT_NAME_H
 
-#include "gdbsupport/gdb_string_view.h"
+#include <string_view>
 
 /* The available styles of name splitting.  */
 
@@ -40,7 +40,7 @@ enum class split_style
 /* Split NAME into components at module boundaries.  STYLE indicates
    which style of splitting to use.  */
 
-extern std::vector<gdb::string_view> split_name (const char *name,
+extern std::vector<std::string_view> split_name (const char *name,
 						 split_style style);
 
 #endif /* GDB_SPLIT_NAME_H */
diff --git a/gdb/stabsread.c b/gdb/stabsread.c
index 7402a26a401..4011475f7ac 100644
--- a/gdb/stabsread.c
+++ b/gdb/stabsread.c
@@ -748,7 +748,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
       if (new_name != nullptr)
 	sym->compute_and_set_names (new_name.get (), true, objfile->per_bfd);
       else
-	sym->compute_and_set_names (gdb::string_view (string, p - string), true,
+	sym->compute_and_set_names (std::string_view (string, p - string), true,
 				    objfile->per_bfd);
 
       if (sym->language () == language_cplus)
diff --git a/gdb/symtab.c b/gdb/symtab.c
index 7f67159b516..408f8041bf0 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -70,7 +70,7 @@
 #include "filename-seen-cache.h"
 #include "arch-utils.h"
 #include <algorithm>
-#include "gdbsupport/gdb_string_view.h"
+#include <string_view>
 #include "gdbsupport/pathstuff.h"
 #include "gdbsupport/common-utils.h"
 
@@ -828,10 +828,10 @@ general_symbol_info::set_language (enum language language,
 /* Objects of this type are stored in the demangled name hash table.  */
 struct demangled_name_entry
 {
-  demangled_name_entry (gdb::string_view mangled_name)
+  demangled_name_entry (std::string_view mangled_name)
     : mangled (mangled_name) {}
 
-  gdb::string_view mangled;
+  std::string_view mangled;
   enum language language;
   gdb::unique_xmalloc_ptr<char> demangled;
 };
@@ -940,7 +940,7 @@ symbol_find_demangled_name (struct general_symbol_info *gsymbol,
    so the pointer can be discarded after calling this function.  */
 
 void
-general_symbol_info::compute_and_set_names (gdb::string_view linkage_name,
+general_symbol_info::compute_and_set_names (std::string_view linkage_name,
 					    bool copy_name,
 					    objfile_per_bfd_storage *per_bfd,
 					    std::optional<hashval_t> hash)
@@ -991,14 +991,14 @@ general_symbol_info::compute_and_set_names (gdb::string_view linkage_name,
       /* A 0-terminated copy of the linkage name.  Callers must set COPY_NAME
 	 to true if the string might not be nullterminated.  We have to make
 	 this copy because demangling needs a nullterminated string.  */
-      gdb::string_view linkage_name_copy;
+      std::string_view linkage_name_copy;
       if (copy_name)
 	{
 	  char *alloc_name = (char *) alloca (linkage_name.length () + 1);
 	  memcpy (alloc_name, linkage_name.data (), linkage_name.length ());
 	  alloc_name[linkage_name.length ()] = '\0';
 
-	  linkage_name_copy = gdb::string_view (alloc_name,
+	  linkage_name_copy = std::string_view (alloc_name,
 						linkage_name.length ());
 	}
       else
@@ -1038,7 +1038,7 @@ general_symbol_info::compute_and_set_names (gdb::string_view linkage_name,
 	  memcpy (mangled_ptr, linkage_name.data (), linkage_name.length ());
 	  mangled_ptr [linkage_name.length ()] = '\0';
 	  new (*slot) demangled_name_entry
-	    (gdb::string_view (mangled_ptr, linkage_name.length ()));
+	    (std::string_view (mangled_ptr, linkage_name.length ()));
 	}
       (*slot)->demangled = std::move (demangled_name);
       (*slot)->language = language ();
diff --git a/gdb/symtab.h b/gdb/symtab.h
index d61d5bb7815..52fd9e23e6c 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -31,7 +31,7 @@
 #include "gdbsupport/enum-flags.h"
 #include "gdbsupport/function-view.h"
 #include <optional>
-#include "gdbsupport/gdb_string_view.h"
+#include <string_view>
 #include "gdbsupport/next-iterator.h"
 #include "gdbsupport/iterator-range.h"
 #include "completer.h"
@@ -126,11 +126,11 @@ class ada_lookup_name_info final
 
   /* A wrapper for ::split_name that handles some Ada-specific
      peculiarities.  */
-  std::vector<gdb::string_view> split_name () const
+  std::vector<std::string_view> split_name () const
   {
     if (m_verbatim_p || m_standard_p)
       {
-	std::vector<gdb::string_view> result;
+	std::vector<std::string_view> result;
 	if (m_standard_p)
 	  result.emplace_back ("standard");
 	result.emplace_back (m_encoded_name);
@@ -238,7 +238,7 @@ class lookup_name_info final
   /* Getters.  See description of each corresponding field.  */
   symbol_name_match_type match_type () const { return m_match_type; }
   bool completion_mode () const { return m_completion_mode; }
-  gdb::string_view name () const { return m_name; }
+  std::string_view name () const { return m_name; }
   const bool ignore_parameters () const { return m_ignore_parameters; }
 
   /* Like the "name" method but guarantees that the returned string is
@@ -292,7 +292,7 @@ class lookup_name_info final
 
   /* A wrapper for ::split_name (see split-name.h) that splits this
      name, and that handles any language-specific peculiarities.  */  
-  std::vector<gdb::string_view> split_name (language lang) const
+  std::vector<std::string_view> split_name (language lang) const
   {
     if (lang == language_ada)
       return ada ().split_name ();
@@ -356,7 +356,7 @@ class lookup_name_info final
   symbol_name_match_type m_match_type;
   bool m_completion_mode;
   bool m_ignore_parameters;
-  gdb::string_view m_name;
+  std::string_view m_name;
 
   /* Language-specific info.  These fields are filled lazily the first
      time a lookup is done in the corresponding language.  They're
@@ -509,7 +509,7 @@ struct general_symbol_info
   /* Set the linkage and natural names of a symbol, by demangling
      the linkage name.  If linkage_name may not be nullterminated,
      copy_name must be set to true.  */
-  void compute_and_set_names (gdb::string_view linkage_name, bool copy_name,
+  void compute_and_set_names (std::string_view linkage_name, bool copy_name,
 			      struct objfile_per_bfd_storage *per_bfd,
 			      std::optional<hashval_t> hash
 				= std::optional<hashval_t> ());
diff --git a/gdb/tui/tui-io.c b/gdb/tui/tui-io.c
index b8954af36e2..83218dc4797 100644
--- a/gdb/tui/tui-io.c
+++ b/gdb/tui/tui-io.c
@@ -1197,7 +1197,7 @@ tui_getc_1 (FILE *fp)
 	 Compare keyname instead.  */
       if (ch >= KEY_MAX)
 	{
-	  auto name = gdb::string_view (keyname (ch));
+	  auto name = std::string_view (keyname (ch));
 
 	  /* The following sequences are hardcoded in readline as
 	     well.  */
diff --git a/gdb/tui/tui-win.c b/gdb/tui/tui-win.c
index a0a123340e3..9219c1f0184 100644
--- a/gdb/tui/tui-win.c
+++ b/gdb/tui/tui-win.c
@@ -54,7 +54,7 @@
 #include "gdb_curses.h"
 #include <ctype.h>
 #include "readline/readline.h"
-#include "gdbsupport/gdb_string_view.h"
+#include <string_view>
 
 #include <signal.h>
 
@@ -663,7 +663,7 @@ tui_scroll_right_command (const char *arg, int from_tty)
 
 /* Answer the window represented by name.  */
 static struct tui_win_info *
-tui_partial_win_by_name (gdb::string_view name)
+tui_partial_win_by_name (std::string_view name)
 {
   struct tui_win_info *best = nullptr;
 
@@ -935,7 +935,7 @@ tui_set_win_size (const char *arg, bool set_width_p)
   buf_ptr = skip_to_space (buf_ptr);
 
   /* Validate the window name.  */
-  gdb::string_view wname (buf, buf_ptr - buf);
+  std::string_view wname (buf, buf_ptr - buf);
   win_info = tui_partial_win_by_name (wname);
 
   if (win_info == NULL)
diff --git a/gdb/xcoffread.c b/gdb/xcoffread.c
index e6ecf2a6de5..829fc1f09c7 100644
--- a/gdb/xcoffread.c
+++ b/gdb/xcoffread.c
@@ -2500,7 +2500,7 @@ scan_xcoff_symtab (minimal_symbol_reader &reader,
 	    switch (p[1])
 	      {
 	      case 'S':
-		pst->add_psymbol (gdb::string_view (namestring,
+		pst->add_psymbol (std::string_view (namestring,
 						    p - namestring),
 				  true, VAR_DOMAIN, LOC_STATIC,
 				  SECT_OFF_DATA (objfile),
@@ -2513,7 +2513,7 @@ scan_xcoff_symtab (minimal_symbol_reader &reader,
 	      case 'G':
 		/* The addresses in these entries are reported to be
 		   wrong.  See the code that reads 'G's for symtabs.  */
-		pst->add_psymbol (gdb::string_view (namestring,
+		pst->add_psymbol (std::string_view (namestring,
 						    p - namestring),
 				  true, VAR_DOMAIN, LOC_STATIC,
 				  SECT_OFF_DATA (objfile),
@@ -2534,7 +2534,7 @@ scan_xcoff_symtab (minimal_symbol_reader &reader,
 		    || (p == namestring + 1
 			&& namestring[0] != ' '))
 		  {
-		    pst->add_psymbol (gdb::string_view (namestring,
+		    pst->add_psymbol (std::string_view (namestring,
 							p - namestring),
 				      true, STRUCT_DOMAIN, LOC_TYPEDEF, -1,
 				      psymbol_placement::STATIC,
@@ -2544,7 +2544,7 @@ scan_xcoff_symtab (minimal_symbol_reader &reader,
 		    if (p[2] == 't')
 		      {
 			/* Also a typedef with the same name.  */
-			pst->add_psymbol (gdb::string_view (namestring,
+			pst->add_psymbol (std::string_view (namestring,
 							    p - namestring),
 					  true, VAR_DOMAIN, LOC_TYPEDEF, -1,
 					  psymbol_placement::STATIC,
@@ -2559,7 +2559,7 @@ scan_xcoff_symtab (minimal_symbol_reader &reader,
 	      case 't':
 		if (p != namestring)	/* a name is there, not just :T...  */
 		  {
-		    pst->add_psymbol (gdb::string_view (namestring,
+		    pst->add_psymbol (std::string_view (namestring,
 							p - namestring),
 				      true, VAR_DOMAIN, LOC_TYPEDEF, -1,
 				      psymbol_placement::STATIC,
@@ -2624,7 +2624,7 @@ scan_xcoff_symtab (minimal_symbol_reader &reader,
 			  ;
 			/* Note that the value doesn't matter for
 			   enum constants in psymtabs, just in symtabs.  */
-			pst->add_psymbol (gdb::string_view (p, q - p), true,
+			pst->add_psymbol (std::string_view (p, q - p), true,
 					  VAR_DOMAIN, LOC_CONST, -1,
 					  psymbol_placement::STATIC,
 					  unrelocated_addr (0),
@@ -2644,7 +2644,7 @@ scan_xcoff_symtab (minimal_symbol_reader &reader,
 
 	      case 'c':
 		/* Constant, e.g. from "const" in Pascal.  */
-		pst->add_psymbol (gdb::string_view (namestring,
+		pst->add_psymbol (std::string_view (namestring,
 						    p - namestring),
 				  true, VAR_DOMAIN, LOC_CONST, -1,
 				  psymbol_placement::STATIC,
@@ -2659,7 +2659,7 @@ scan_xcoff_symtab (minimal_symbol_reader &reader,
 		    std::string name (namestring, (p - namestring));
 		    function_outside_compilation_unit_complaint (name.c_str ());
 		  }
-		pst->add_psymbol (gdb::string_view (namestring,
+		pst->add_psymbol (std::string_view (namestring,
 						    p - namestring),
 				  true, VAR_DOMAIN, LOC_BLOCK,
 				  SECT_OFF_TEXT (objfile),
@@ -2686,7 +2686,7 @@ scan_xcoff_symtab (minimal_symbol_reader &reader,
 		if (startswith (namestring, "@FIX"))
 		  continue;
 
-		pst->add_psymbol (gdb::string_view (namestring,
+		pst->add_psymbol (std::string_view (namestring,
 						    p - namestring),
 				  true, VAR_DOMAIN, LOC_BLOCK,
 				  SECT_OFF_TEXT (objfile),
diff --git a/gdbsupport/common-utils.h b/gdbsupport/common-utils.h
index 4ceb44d88b8..1efc5bbf459 100644
--- a/gdbsupport/common-utils.h
+++ b/gdbsupport/common-utils.h
@@ -26,7 +26,7 @@
 #include "gdbsupport/gdb_unique_ptr.h"
 #include "gdbsupport/array-view.h"
 #include "poison.h"
-#include "gdb_string_view.h"
+#include <string_view>
 
 #if defined HAVE_LIBXXHASH
 #  include <xxhash.h>
@@ -94,7 +94,7 @@ extern const char *safe_strerror (int);
    true if the start of STRING matches PATTERN, false otherwise.  */
 
 static inline bool
-startswith (gdb::string_view string, gdb::string_view pattern)
+startswith (std::string_view string, std::string_view pattern)
 {
   return (string.length () >= pattern.length ()
 	  && strncmp (string.data (), pattern.data (), pattern.length ()) == 0);
@@ -228,7 +228,7 @@ fast_hash (const void *ptr, size_t len, unsigned int start_value = 0)
 namespace gdb
 {
 
-/* Hash type for gdb::string_view.
+/* Hash type for std::string_view.
 
    Even after we switch to C++17 and dump our string_view implementation, we
    might want to keep this hash implementation if it's faster than std::hash
@@ -236,7 +236,7 @@ namespace gdb
 
 struct string_view_hash
 {
-  std::size_t operator() (gdb::string_view view) const
+  std::size_t operator() (std::string_view view) const
   {  return fast_hash (view.data (), view.length ()); }
 };
 
diff --git a/gdbsupport/format.h b/gdbsupport/format.h
index 2af34ab9450..5330bbe361e 100644
--- a/gdbsupport/format.h
+++ b/gdbsupport/format.h
@@ -20,7 +20,7 @@
 #ifndef COMMON_FORMAT_H
 #define COMMON_FORMAT_H
 
-#include "gdbsupport/gdb_string_view.h"
+#include <string_view>
 
 #if defined(__MINGW32__) && !defined(PRINTF_HAS_LONG_LONG)
 # define USE_PRINTF_I64 1
@@ -61,7 +61,7 @@ struct format_piece
   bool operator== (const format_piece &other) const
   {
     return (this->argclass == other.argclass
-	    && gdb::string_view (this->string) == other.string);
+	    && std::string_view (this->string) == other.string);
   }
 
   const char *string;
diff --git a/gdbsupport/gdb_string_view.h b/gdbsupport/gdb_string_view.h
index 26a3a9f0910..cf7af623327 100644
--- a/gdbsupport/gdb_string_view.h
+++ b/gdbsupport/gdb_string_view.h
@@ -556,7 +556,7 @@ namespace gdb {
 namespace gdb {
 
 static inline std::string
-to_string(const gdb::string_view &view)
+to_string(const std::string_view &view)
 {
   return { view.data (), view.size () };
 }
-- 
2.34.1


^ permalink raw reply	[flat|nested] 39+ messages in thread

* [PATCH 07/11] gdb: Remove uses of gdb::to_string (const std::string_view &)
  2023-10-13 14:44 [PATCH 00/11] GDB: Require C++17 Lancelot Six
                   ` (5 preceding siblings ...)
  2023-10-13 14:44 ` [PATCH 06/11] gdb: Use std::string_view instead of gdb::string_view Lancelot Six
@ 2023-10-13 14:44 ` Lancelot Six
  2023-10-13 14:44 ` [PATCH 08/11] gdbsupport: Remove gdb::string_view Lancelot Six
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 39+ messages in thread
From: Lancelot Six @ 2023-10-13 14:44 UTC (permalink / raw)
  To: gdb-patches; +Cc: Lancelot Six

This patch removes all uses of to_string(const std::string_view&) and
use the std::string ctor or implicit conversion from std::string_view to
std::string instead.

A later patch will remove this gdb::to_string while removing
gdbsupport/gdb_string_view.h.

Change-Id: I877cde557a0727be7b0435107e3c7a2aac165895
---
 gdb/ada-lang.c           | 20 +++++++++-----------
 gdb/amdgpu-tdep.c        | 18 +++++++++---------
 gdb/debuginfod-support.c |  3 +--
 gdb/dwarf2/read.c        |  2 +-
 gdb/solib-rocm.c         |  8 ++++----
 5 files changed, 24 insertions(+), 27 deletions(-)

diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 3e394619399..ff7222c7eed 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -1040,7 +1040,7 @@ ada_fold_name (std::string_view name, bool throw_on_error = false)
   static std::string fold_storage;
 
   if (!name.empty () && name[0] == '\'')
-    fold_storage = gdb::to_string (name.substr (1, name.size () - 2));
+    fold_storage = name.substr (1, name.size () - 2);
   else
     {
       /* Why convert to UTF-32 and implement our own case-folding,
@@ -1081,12 +1081,12 @@ ada_fold_name (std::string_view name, bool throw_on_error = false)
 	      warned = true;
 	      warning (_("could not convert '%s' from the host encoding (%s) to UTF-32.\n"
 			 "This normally should not happen, please file a bug report."),
-		       gdb::to_string (name).c_str (), host_charset ());
+		       std::string (name).c_str (), host_charset ());
 	    }
 
 	  /* We don't try to recover from errors; just return the
 	     original string.  */
-	  fold_storage = gdb::to_string (name);
+	  fold_storage = name;
 	  return fold_storage.c_str ();
 	}
 
@@ -1135,12 +1135,12 @@ ada_fold_name (std::string_view name, bool throw_on_error = false)
 	      warned = true;
 	      warning (_("could not convert the lower-cased variant of '%s'\n"
 			 "from UTF-32 to the host encoding (%s)."),
-		       gdb::to_string (name).c_str (), host_charset ());
+		       std::string (name).c_str (), host_charset ());
 	    }
 
 	  /* We don't try to recover from errors; just return the
 	     original string.  */
-	  fold_storage = gdb::to_string (name);
+	  fold_storage = name;
 	}
     }
 
@@ -13255,11 +13255,9 @@ ada_lookup_name_info::ada_lookup_name_info (const lookup_name_info &lookup_name)
   if (!user_name.empty () && user_name[0] == '<')
     {
       if (user_name.back () == '>')
-	m_encoded_name
-	  = gdb::to_string (user_name.substr (1, user_name.size () - 2));
+	m_encoded_name = user_name.substr (1, user_name.size () - 2);
       else
-	m_encoded_name
-	  = gdb::to_string (user_name.substr (1, user_name.size () - 1));
+	m_encoded_name = user_name.substr (1, user_name.size () - 1);
       m_encoded_p = true;
       m_verbatim_p = true;
       m_wild_match_p = false;
@@ -13276,10 +13274,10 @@ ada_lookup_name_info::ada_lookup_name_info (const lookup_name_info &lookup_name)
 	  const char *folded = ada_fold_name (user_name);
 	  m_encoded_name = ada_encode_1 (folded, false);
 	  if (m_encoded_name.empty ())
-	    m_encoded_name = gdb::to_string (user_name);
+	    m_encoded_name = user_name;
 	}
       else
-	m_encoded_name = gdb::to_string (user_name);
+	m_encoded_name = user_name;
 
       /* Handle the 'package Standard' special case.  See description
 	 of m_standard_p.  */
diff --git a/gdb/amdgpu-tdep.c b/gdb/amdgpu-tdep.c
index 48dc8db6bcc..15f32885b07 100644
--- a/gdb/amdgpu-tdep.c
+++ b/gdb/amdgpu-tdep.c
@@ -401,7 +401,7 @@ parse_amd_dbgapi_register_type_enum_fields
       if (value > std::numeric_limits<uint32_t>::max ())
 	enum_type.set_bit_size (64);
 
-      enum_type.add_enumerator (gdb::to_string (name), value);
+      enum_type.add_enumerator (std::string (name), value);
 
       fields = fields.substr (matches[0].rm_eo);
     }
@@ -445,7 +445,7 @@ parse_amd_dbgapi_register_type_flags_fields
       ULONGEST pos_begin = try_strtoulst (pos_begin_str);
 
       if (field_type_str == "bool")
-	flags_type.add_field (gdb::to_string (field_name), pos_begin, pos_begin,
+	flags_type.add_field (std::string (field_name), pos_begin, pos_begin,
 			      nullptr);
       else
 	{
@@ -456,7 +456,7 @@ parse_amd_dbgapi_register_type_flags_fields
 	  ULONGEST pos_end = try_strtoulst (pos_end_str.substr (1));
 	  const amd_dbgapi_register_type &field_type
 	    = parse_amd_dbgapi_register_type (field_type_str, type_map);
-	  flags_type.add_field (gdb::to_string (field_name), pos_begin, pos_end,
+	  flags_type.add_field (std::string (field_name), pos_begin, pos_end,
 				&field_type);
 	}
 
@@ -470,7 +470,7 @@ static const amd_dbgapi_register_type &
 parse_amd_dbgapi_register_type_scalar (std::string_view name,
 				       amd_dbgapi_register_type_map &type_map)
 {
-  std::string name_str = gdb::to_string (name);
+  std::string name_str (name);
   auto it = type_map.find (name_str);
   if (it != type_map.end ())
     {
@@ -533,7 +533,7 @@ parse_amd_dbgapi_register_type (std::string_view type_str,
       std::string_view count_str_view
 	= type_str.substr (pos_open_bracket + 1,
 			    pos_close_bracket - pos_open_bracket);
-      std::string count_str = gdb::to_string (count_str_view);
+      std::string count_str (count_str_view);
       unsigned int count = std::stoul (count_str);
 
       std::string lookup_name
@@ -579,7 +579,7 @@ parse_amd_dbgapi_register_type (std::string_view type_str,
 	  /* No braces, lookup existing type.  */
 	  if (existing_type_it == type_map.end ())
 	    error (_("reference to unknown type %s."),
-		   gdb::to_string (name).c_str ());
+		   std::string (name).c_str ());
 
 	  if (existing_type_it->second->kind ()
 	      != amd_dbgapi_register_type::kind::FLAGS)
@@ -592,7 +592,7 @@ parse_amd_dbgapi_register_type (std::string_view type_str,
 	  /* With braces, it's a definition.  */
 	  if (existing_type_it != type_map.end ())
 	    error (_("re-definition of type %s."),
-		   gdb::to_string (name).c_str ());
+		   std::string (name).c_str ());
 
 	  amd_dbgapi_register_type_flags_up flags_type
 	    (new amd_dbgapi_register_type_flags (bit_size, name));
@@ -631,7 +631,7 @@ parse_amd_dbgapi_register_type (std::string_view type_str,
 	  /* No braces, lookup existing type.  */
 	  if (existing_type_it == type_map.end ())
 	    error (_("reference to unknown type %s"),
-		   gdb::to_string (name).c_str ());
+		   std::string (name).c_str ());
 
 	  if (existing_type_it->second->kind ()
 	      != amd_dbgapi_register_type::kind::ENUM)
@@ -644,7 +644,7 @@ parse_amd_dbgapi_register_type (std::string_view type_str,
 	  /* With braces, it's a definition.  */
 	  if (existing_type_it != type_map.end ())
 	    error (_("re-definition of type %s"),
-		   gdb::to_string (name).c_str ());
+		   std::string (name).c_str ());
 
 	  amd_dbgapi_register_type_enum_up enum_type
 	    (new amd_dbgapi_register_type_enum (name));
diff --git a/gdb/debuginfod-support.c b/gdb/debuginfod-support.c
index 0e202ff5d96..eb88c406ad6 100644
--- a/gdb/debuginfod-support.c
+++ b/gdb/debuginfod-support.c
@@ -264,8 +264,7 @@ debuginfod_is_enabled ()
 	  gdb_printf
 	    (_("  <%ps>\n"),
 	     styled_string (file_name_style.style (),
-			    gdb::to_string (url_view.substr (0,
-							     off)).c_str ()));
+			    std::string (url_view.substr (0, off)).c_str ()));
 	  if (off == std::string_view::npos)
 	    break;
 	  url_view = url_view.substr (off);
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 1846f7160cc..0973fb6fe13 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -16886,7 +16886,7 @@ cooked_index_functions::expand_symtabs_matching
     {
       std::vector<std::string_view> name_vec
 	= lookup_name_without_params.split_name (lang);
-      std::string last_name = gdb::to_string (name_vec.back ());
+      std::string last_name (name_vec.back ());
 
       for (const cooked_index_entry *entry : table->find (last_name,
 							  completing))
diff --git a/gdb/solib-rocm.c b/gdb/solib-rocm.c
index 27cefb9604b..c39b5b8bdeb 100644
--- a/gdb/solib-rocm.c
+++ b/gdb/solib-rocm.c
@@ -454,7 +454,7 @@ rocm_bfd_iovec_open (bfd *abfd, inferior *inferior)
   std::string_view uri (bfd_get_filename (abfd));
   std::string_view protocol_delim = "://";
   size_t protocol_end = uri.find (protocol_delim);
-  std::string protocol = gdb::to_string (uri.substr (0, protocol_end));
+  std::string protocol (uri.substr (0, protocol_end));
   protocol_end += protocol_delim.length ();
 
   std::transform (protocol.begin (), protocol.end (), protocol.begin (),
@@ -477,7 +477,7 @@ rocm_bfd_iovec_open (bfd *abfd, inferior *inferior)
 	&& std::isxdigit (path[i + 2]))
       {
 	std::string_view hex_digits = path.substr (i + 1, 2);
-	decoded_path += std::stoi (gdb::to_string (hex_digits), 0, 16);
+	decoded_path += std::stoi (std::string (hex_digits), 0, 16);
 	i += 2;
       }
     else
@@ -563,7 +563,7 @@ rocm_bfd_iovec_open (bfd *abfd, inferior *inferior)
 	  if (pid != inferior->pid)
 	    {
 	      warning (_("`%s': code object is from another inferior"),
-		       gdb::to_string (uri).c_str ());
+		       std::string (uri).c_str ());
 	      bfd_set_error (bfd_error_bad_value);
 	      return nullptr;
 	    }
@@ -580,7 +580,7 @@ rocm_bfd_iovec_open (bfd *abfd, inferior *inferior)
 	}
 
       warning (_("`%s': protocol not supported: %s"),
-	       gdb::to_string (uri).c_str (), protocol.c_str ());
+	       std::string (uri).c_str (), protocol.c_str ());
       bfd_set_error (bfd_error_bad_value);
       return nullptr;
     }
-- 
2.34.1


^ permalink raw reply	[flat|nested] 39+ messages in thread

* [PATCH 08/11] gdbsupport: Remove gdb::string_view
  2023-10-13 14:44 [PATCH 00/11] GDB: Require C++17 Lancelot Six
                   ` (6 preceding siblings ...)
  2023-10-13 14:44 ` [PATCH 07/11] gdb: Remove uses of gdb::to_string (const std::string_view &) Lancelot Six
@ 2023-10-13 14:44 ` Lancelot Six
  2023-10-16 19:38   ` Tom Tromey
  2023-10-13 14:44 ` [PATCH 09/11] gdbsupport: Replace gdb::invoke_result with std::invoke_result Lancelot Six
                   ` (3 subsequent siblings)
  11 siblings, 1 reply; 39+ messages in thread
From: Lancelot Six @ 2023-10-13 14:44 UTC (permalink / raw)
  To: gdb-patches; +Cc: Lancelot Six

Now that all places using gdb::string_view have been updated to use
std::string_view, this patch drops the gdb::string_view implementation
and the tests which came with it.

Change-Id: Idf5479b09e0ac536917b3f0e13aca48424b90df0
---
 gdb/Makefile.in                               |   1 -
 gdb/unittests/basic_string_view/capacity/1.cc | 172 ------
 .../basic_string_view/capacity/empty_neg.cc   |  28 -
 .../basic_string_view/cons/char/1.cc          |  67 ---
 .../basic_string_view/cons/char/2.cc          |  46 --
 .../basic_string_view/cons/char/3.cc          |  39 --
 .../basic_string_view/cons/wchar_t/1.cc       |  68 ---
 .../basic_string_view/cons/wchar_t/2.cc       |  45 --
 .../basic_string_view/cons/wchar_t/3.cc       |  38 --
 .../element_access/char/1.cc                  |  70 ---
 .../element_access/char/2.cc                  |  30 -
 .../element_access/char/empty.cc              |  39 --
 .../element_access/char/front_back.cc         |  43 --
 .../element_access/wchar_t/1.cc               |  71 ---
 .../element_access/wchar_t/2.cc               |  32 -
 .../element_access/wchar_t/empty.cc           |  38 --
 .../element_access/wchar_t/front_back.cc      |  42 --
 gdb/unittests/basic_string_view/include.cc    |  25 -
 .../basic_string_view/inserters/char/1.cc     |  65 --
 .../basic_string_view/inserters/char/2.cc     |  91 ---
 .../basic_string_view/inserters/char/3.cc     |  54 --
 .../inserters/pod/10081-out.cc                |  75 ---
 .../basic_string_view/inserters/wchar_t/1.cc  |  70 ---
 .../basic_string_view/inserters/wchar_t/2.cc  |  91 ---
 .../basic_string_view/inserters/wchar_t/3.cc  |  53 --
 .../basic_string_view/literals/types.cc       |  45 --
 .../basic_string_view/literals/values.cc      |  72 ---
 .../modifiers/remove_prefix/char/1.cc         |  66 --
 .../modifiers/remove_prefix/wchar_t/1.cc      |  61 --
 .../modifiers/remove_suffix/char/1.cc         |  66 --
 .../modifiers/remove_suffix/wchar_t/1.cc      |  61 --
 .../modifiers/swap/char/1.cc                  |  36 --
 .../modifiers/swap/wchar_t/1.cc               |  35 --
 .../operations/compare/char/1.cc              | 132 ----
 .../operations/compare/char/13650.cc          |  50 --
 .../operations/compare/char/2.cc              |  30 -
 .../operations/compare/char/70483.cc          |  89 ---
 .../operations/compare/wchar_t/1.cc           | 133 ----
 .../operations/compare/wchar_t/13650.cc       |  49 --
 .../operations/compare/wchar_t/2.cc           |  30 -
 .../operations/copy/char/1.cc                 |  46 --
 .../operations/copy/wchar_t/1.cc              |  46 --
 .../operations/data/char/1.cc                 |  44 --
 .../operations/data/wchar_t/1.cc              |  43 --
 .../operations/find/char/1.cc                 | 168 ------
 .../operations/find/char/2.cc                 | 166 -----
 .../operations/find/char/3.cc                 | 166 -----
 .../operations/find/char/4.cc                 |  45 --
 .../operations/find/wchar_t/1.cc              | 163 -----
 .../operations/find/wchar_t/2.cc              | 161 -----
 .../operations/find/wchar_t/3.cc              | 161 -----
 .../operations/find/wchar_t/4.cc              |  44 --
 .../operations/rfind/char/1.cc                |  95 ---
 .../operations/rfind/char/2.cc                |  53 --
 .../operations/rfind/char/3.cc                |  68 ---
 .../operations/rfind/wchar_t/1.cc             |  94 ---
 .../operations/rfind/wchar_t/2.cc             |  52 --
 .../operations/rfind/wchar_t/3.cc             |  66 --
 .../operations/string_conversion/1.cc         |  51 --
 .../operations/substr/char/1.cc               |  79 ---
 .../operations/substr/wchar_t/1.cc            |  79 ---
 .../basic_string_view/operators/char/2.cc     | 373 ------------
 .../basic_string_view/operators/wchar_t/2.cc  | 367 ------------
 .../basic_string_view/range_access/char/1.cc  |  47 --
 .../range_access/wchar_t/1.cc                 |  47 --
 .../requirements/explicit_instantiation/1.cc  |  26 -
 .../explicit_instantiation/char/1.cc          |  23 -
 .../explicit_instantiation/char16_t/1.cc      |  24 -
 .../explicit_instantiation/char32_t/1.cc      |  24 -
 .../explicit_instantiation/wchar_t/1.cc       |  23 -
 .../requirements/typedefs.cc                  |  47 --
 gdb/unittests/basic_string_view/typedefs.cc   |  36 --
 gdb/unittests/basic_string_view/types/1.cc    |  43 --
 gdb/unittests/string_view-selftests.c         | 193 ------
 gdbsupport/gdb_string_view.h                  | 566 ------------------
 gdbsupport/gdb_string_view.tcc                | 219 -------
 76 files changed, 6296 deletions(-)
 delete mode 100644 gdb/unittests/basic_string_view/capacity/1.cc
 delete mode 100644 gdb/unittests/basic_string_view/capacity/empty_neg.cc
 delete mode 100644 gdb/unittests/basic_string_view/cons/char/1.cc
 delete mode 100644 gdb/unittests/basic_string_view/cons/char/2.cc
 delete mode 100644 gdb/unittests/basic_string_view/cons/char/3.cc
 delete mode 100644 gdb/unittests/basic_string_view/cons/wchar_t/1.cc
 delete mode 100644 gdb/unittests/basic_string_view/cons/wchar_t/2.cc
 delete mode 100644 gdb/unittests/basic_string_view/cons/wchar_t/3.cc
 delete mode 100644 gdb/unittests/basic_string_view/element_access/char/1.cc
 delete mode 100644 gdb/unittests/basic_string_view/element_access/char/2.cc
 delete mode 100644 gdb/unittests/basic_string_view/element_access/char/empty.cc
 delete mode 100644 gdb/unittests/basic_string_view/element_access/char/front_back.cc
 delete mode 100644 gdb/unittests/basic_string_view/element_access/wchar_t/1.cc
 delete mode 100644 gdb/unittests/basic_string_view/element_access/wchar_t/2.cc
 delete mode 100644 gdb/unittests/basic_string_view/element_access/wchar_t/empty.cc
 delete mode 100644 gdb/unittests/basic_string_view/element_access/wchar_t/front_back.cc
 delete mode 100644 gdb/unittests/basic_string_view/include.cc
 delete mode 100644 gdb/unittests/basic_string_view/inserters/char/1.cc
 delete mode 100644 gdb/unittests/basic_string_view/inserters/char/2.cc
 delete mode 100644 gdb/unittests/basic_string_view/inserters/char/3.cc
 delete mode 100644 gdb/unittests/basic_string_view/inserters/pod/10081-out.cc
 delete mode 100644 gdb/unittests/basic_string_view/inserters/wchar_t/1.cc
 delete mode 100644 gdb/unittests/basic_string_view/inserters/wchar_t/2.cc
 delete mode 100644 gdb/unittests/basic_string_view/inserters/wchar_t/3.cc
 delete mode 100644 gdb/unittests/basic_string_view/literals/types.cc
 delete mode 100644 gdb/unittests/basic_string_view/literals/values.cc
 delete mode 100644 gdb/unittests/basic_string_view/modifiers/remove_prefix/char/1.cc
 delete mode 100644 gdb/unittests/basic_string_view/modifiers/remove_prefix/wchar_t/1.cc
 delete mode 100644 gdb/unittests/basic_string_view/modifiers/remove_suffix/char/1.cc
 delete mode 100644 gdb/unittests/basic_string_view/modifiers/remove_suffix/wchar_t/1.cc
 delete mode 100644 gdb/unittests/basic_string_view/modifiers/swap/char/1.cc
 delete mode 100644 gdb/unittests/basic_string_view/modifiers/swap/wchar_t/1.cc
 delete mode 100644 gdb/unittests/basic_string_view/operations/compare/char/1.cc
 delete mode 100644 gdb/unittests/basic_string_view/operations/compare/char/13650.cc
 delete mode 100644 gdb/unittests/basic_string_view/operations/compare/char/2.cc
 delete mode 100644 gdb/unittests/basic_string_view/operations/compare/char/70483.cc
 delete mode 100644 gdb/unittests/basic_string_view/operations/compare/wchar_t/1.cc
 delete mode 100644 gdb/unittests/basic_string_view/operations/compare/wchar_t/13650.cc
 delete mode 100644 gdb/unittests/basic_string_view/operations/compare/wchar_t/2.cc
 delete mode 100644 gdb/unittests/basic_string_view/operations/copy/char/1.cc
 delete mode 100644 gdb/unittests/basic_string_view/operations/copy/wchar_t/1.cc
 delete mode 100644 gdb/unittests/basic_string_view/operations/data/char/1.cc
 delete mode 100644 gdb/unittests/basic_string_view/operations/data/wchar_t/1.cc
 delete mode 100644 gdb/unittests/basic_string_view/operations/find/char/1.cc
 delete mode 100644 gdb/unittests/basic_string_view/operations/find/char/2.cc
 delete mode 100644 gdb/unittests/basic_string_view/operations/find/char/3.cc
 delete mode 100644 gdb/unittests/basic_string_view/operations/find/char/4.cc
 delete mode 100644 gdb/unittests/basic_string_view/operations/find/wchar_t/1.cc
 delete mode 100644 gdb/unittests/basic_string_view/operations/find/wchar_t/2.cc
 delete mode 100644 gdb/unittests/basic_string_view/operations/find/wchar_t/3.cc
 delete mode 100644 gdb/unittests/basic_string_view/operations/find/wchar_t/4.cc
 delete mode 100644 gdb/unittests/basic_string_view/operations/rfind/char/1.cc
 delete mode 100644 gdb/unittests/basic_string_view/operations/rfind/char/2.cc
 delete mode 100644 gdb/unittests/basic_string_view/operations/rfind/char/3.cc
 delete mode 100644 gdb/unittests/basic_string_view/operations/rfind/wchar_t/1.cc
 delete mode 100644 gdb/unittests/basic_string_view/operations/rfind/wchar_t/2.cc
 delete mode 100644 gdb/unittests/basic_string_view/operations/rfind/wchar_t/3.cc
 delete mode 100644 gdb/unittests/basic_string_view/operations/string_conversion/1.cc
 delete mode 100644 gdb/unittests/basic_string_view/operations/substr/char/1.cc
 delete mode 100644 gdb/unittests/basic_string_view/operations/substr/wchar_t/1.cc
 delete mode 100644 gdb/unittests/basic_string_view/operators/char/2.cc
 delete mode 100644 gdb/unittests/basic_string_view/operators/wchar_t/2.cc
 delete mode 100644 gdb/unittests/basic_string_view/range_access/char/1.cc
 delete mode 100644 gdb/unittests/basic_string_view/range_access/wchar_t/1.cc
 delete mode 100644 gdb/unittests/basic_string_view/requirements/explicit_instantiation/1.cc
 delete mode 100644 gdb/unittests/basic_string_view/requirements/explicit_instantiation/char/1.cc
 delete mode 100644 gdb/unittests/basic_string_view/requirements/explicit_instantiation/char16_t/1.cc
 delete mode 100644 gdb/unittests/basic_string_view/requirements/explicit_instantiation/char32_t/1.cc
 delete mode 100644 gdb/unittests/basic_string_view/requirements/explicit_instantiation/wchar_t/1.cc
 delete mode 100644 gdb/unittests/basic_string_view/requirements/typedefs.cc
 delete mode 100644 gdb/unittests/basic_string_view/typedefs.cc
 delete mode 100644 gdb/unittests/basic_string_view/types/1.cc
 delete mode 100644 gdb/unittests/string_view-selftests.c
 delete mode 100644 gdbsupport/gdb_string_view.h
 delete mode 100644 gdbsupport/gdb_string_view.tcc

diff --git a/gdb/Makefile.in b/gdb/Makefile.in
index 413ce1ea68a..1266686134d 100644
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -482,7 +482,6 @@ SELFTESTS_SRCS = \
 	unittests/scoped_mmap-selftests.c \
 	unittests/scoped_restore-selftests.c \
 	unittests/search-memory-selftests.c \
-	unittests/string_view-selftests.c \
 	unittests/style-selftests.c \
 	unittests/tracepoint-selftests.c \
 	unittests/tui-selftests.c \
diff --git a/gdb/unittests/basic_string_view/capacity/1.cc b/gdb/unittests/basic_string_view/capacity/1.cc
deleted file mode 100644
index 12470a98279..00000000000
--- a/gdb/unittests/basic_string_view/capacity/1.cc
+++ /dev/null
@@ -1,172 +0,0 @@
-// { dg-options "-std=gnu++17" }
-
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-// string_view size, length
-
-namespace capacity_1 {
-
-template<typename T>
-  struct A { };
-
-template<typename T>
-  bool
-  operator==(const A<T>&, const A<T>&) { return true; }
-
-template<typename T>
-  bool
-  operator<(const A<T>&, const A<T>&) { return true; }
-
-struct B { };
-
-} // namespace capacity_1
-} // namespace string_view
-} // namespace selftests
-
-// char_traits specialization
-namespace std
-{
-  template<>
-    struct char_traits<selftests::string_view::capacity_1::A<
-	selftests::string_view::capacity_1::B> >
-    {
-      typedef selftests::string_view::capacity_1::A<
-	  selftests::string_view::capacity_1::B> char_type;
-      // Unsigned as wint_t in unsigned.
-      typedef unsigned long  	int_type;
-      typedef streampos 	pos_type;
-      typedef streamoff 	off_type;
-      typedef mbstate_t 	state_type;
-      
-      static void 
-      assign(char_type& __c1, const char_type& __c2)
-      { __c1 = __c2; }
-
-      static bool 
-      eq(const char_type& __c1, const char_type& __c2)
-      { return __c1 == __c2; }
-
-      static bool 
-      lt(const char_type& __c1, const char_type& __c2)
-      { return __c1 < __c2; }
-
-      static int 
-      compare(const char_type* __s1, const char_type* __s2, size_t __n)
-      { 
-	for (size_t __i = 0; __i < __n; ++__i)
-	  if (!eq(__s1[__i], __s2[__i]))
-	    return lt(__s1[__i], __s2[__i]) ? -1 : 1;
-	return 0; 
-      }
-
-      static size_t
-      length(const char_type* __s)
-      { 
-	const char_type* __p = __s; 
-	while (__p) 
-	  ++__p; 
-	return (__p - __s); 
-      }
-
-      static const char_type* 
-      find(const char_type* __s, size_t __n, const char_type& __a)
-      { 
-	for (const char_type* __p = __s; size_t(__p - __s) < __n; ++__p)
-	  if (*__p == __a) return __p;
-	return 0;
-      }
-
-      static char_type* 
-      move(char_type* __s1, const char_type* __s2, size_t __n)
-      { return (char_type*) memmove(__s1, __s2, __n * sizeof(char_type)); }
-
-      static char_type* 
-      copy(char_type* __s1, const char_type* __s2, size_t __n)
-      { return (char_type*) memcpy(__s1, __s2, __n * sizeof(char_type)); }
-
-      static char_type* 
-      assign(char_type* __s, size_t __n, char_type __a)
-      { 
-	for (char_type* __p = __s; __p < __s + __n; ++__p) 
-	  assign(*__p, __a);
-        return __s; 
-      }
-
-      static char_type 
-      to_char_type(const int_type&)
-      { return char_type(); }
-
-      static int_type 
-      to_int_type(const char_type&) { return int_type(); }
-
-      static bool 
-      eq_int_type(const int_type& __c1, const int_type& __c2)
-      { return __c1 == __c2; }
-
-      static int_type 
-      eof() { return static_cast<int_type>(-1); }
-
-      static int_type 
-      not_eof(const int_type& __c)
-      { return eq_int_type(__c, eof()) ? int_type(0) : __c; }
-    };
-} // namespace std
-
-namespace selftests {
-namespace string_view {
-namespace capacity_1 {
-
-static void
-test01 ()
-{
-  gdb::basic_string_view<A<B>> str02;
-  typedef gdb::basic_string_view< A<B> >::size_type size_type_o;
-  size_type_o sz03;
-  size_type_o sz04;
-
-  // non-POD types: size, length, max_size, empty()
-  bool b01 = str02.empty();  
-  VERIFY( b01 == true );
-  sz03 = str02.size();
-  sz04 = str02.length();
-  VERIFY( sz03 == sz04 );
-  str02.data();
-  sz03 = str02.size();
-  sz04 = str02.length();
-  VERIFY( sz03 == sz04 );
-
-  sz03 = str02.max_size();  
-  VERIFY( sz03 >= sz04 );
-
-  sz03 = str02.size();
-  str02 = {};
-  b01 = str02.empty(); 
-  VERIFY( b01 == true );
-  sz04 = str02.size();  
-  VERIFY( sz03 >= sz04 );
-}
-
-static int
-main()
-{
-  test01();
-
-  return 0;
-}
-
-} // namespace capacity_1
diff --git a/gdb/unittests/basic_string_view/capacity/empty_neg.cc b/gdb/unittests/basic_string_view/capacity/empty_neg.cc
deleted file mode 100644
index 4cb1beac5a6..00000000000
--- a/gdb/unittests/basic_string_view/capacity/empty_neg.cc
+++ /dev/null
@@ -1,28 +0,0 @@
-// Copyright (C) 2017-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-// { dg-options "-std=gnu++17" }
-// { dg-do compile { target c++17 } }
-
-#include <string_view>
-
-void
-test01()
-{
-  std::string_view s;
-  s.empty();  // { dg-warning "ignoring return value" }
-}
diff --git a/gdb/unittests/basic_string_view/cons/char/1.cc b/gdb/unittests/basic_string_view/cons/char/1.cc
deleted file mode 100644
index b27f999e429..00000000000
--- a/gdb/unittests/basic_string_view/cons/char/1.cc
+++ /dev/null
@@ -1,67 +0,0 @@
-// { dg-options "-std=gnu++17" }
-
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-// basic_string_view constructors.
-
-namespace cons_1 {
-
-static void
-test01 ()
-{
-  typedef gdb::string_view::size_type csize_type;
-
-  // basic_string_view()
-  const gdb::string_view str00{};
-  VERIFY( str00.length() == 0 );
-  VERIFY( str00.data() == nullptr );
-
-  // basic_string_view(const char*)
-  const char str_lit01[] = "rodeo beach, marin";
-  const gdb::string_view str01{str_lit01};
-  VERIFY( str01.length() == 18 );
-  VERIFY( str01.data() == str_lit01 );
-  const gdb::string_view str02{"baker beach, san francisco"};
-  VERIFY( str02.length() == 26 );
-
-  // basic_string_view(const string_view&)
-  gdb::string_view str04{str01};
-  VERIFY( str04.length() == str01.length() );
-  VERIFY( str04.data() == str01.data() );
-
-  // basic_string_view(const char* s)
-  csize_type len_lit01 = strlen(str_lit01);
-  gdb::string_view str05{str_lit01, len_lit01};
-  VERIFY( str05.length() == len_lit01 );
-  VERIFY( str05.data() == str_lit01 );
-
-  // basic_string_view(basic_string& s)
-  std::string istr07(10, 'z');
-  gdb::string_view str07{istr07};
-  VERIFY( str07.length() == 10 );
-}
-
-static int
-main ()
-{ 
-  test01();
-
-  return 0;
-}
-
-} // namespace cons_1
diff --git a/gdb/unittests/basic_string_view/cons/char/2.cc b/gdb/unittests/basic_string_view/cons/char/2.cc
deleted file mode 100644
index 22a7916c9e3..00000000000
--- a/gdb/unittests/basic_string_view/cons/char/2.cc
+++ /dev/null
@@ -1,46 +0,0 @@
-// { dg-options "-std=gnu++17" }
-
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-// basic_string_view constructors.
-
-namespace cons_2 {
-
-static void
-test03 ()
-{
-  const char* with_nulls = "This contains \0 a zero byte.";
-
-  // These are tests to see how basic_string_view handles data with NUL
-  // bytes.  Obviously basic_string_view(char*) will halt at the first one, but
-  // nothing else should.
-  gdb::string_view s1(with_nulls, 28);
-  VERIFY( s1.size() == 28 );
-  gdb::string_view s2(s1);
-  VERIFY( s2.size() == 28 );
-}
-
-static int
-main ()
-{ 
-  test03();
-
-  return 0;
-}
-
-} // namespace cons_2
diff --git a/gdb/unittests/basic_string_view/cons/char/3.cc b/gdb/unittests/basic_string_view/cons/char/3.cc
deleted file mode 100644
index ab98b0b70a4..00000000000
--- a/gdb/unittests/basic_string_view/cons/char/3.cc
+++ /dev/null
@@ -1,39 +0,0 @@
-// { dg-options "-std=gnu++17" }
-
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-// basic_string_view constructors.
-
-namespace cons_3 {
-
-static void
-test05 ()
-{
-  char const * s = 0;
-  gdb::string_view zero_length_built_with_NULL(s, 0);
-}
-
-static int
-main ()
-{ 
-  test05();
-
-  return 0;
-}
-
-} // namespace cons_3
diff --git a/gdb/unittests/basic_string_view/cons/wchar_t/1.cc b/gdb/unittests/basic_string_view/cons/wchar_t/1.cc
deleted file mode 100644
index 8a1599c5b81..00000000000
--- a/gdb/unittests/basic_string_view/cons/wchar_t/1.cc
+++ /dev/null
@@ -1,68 +0,0 @@
-// { dg-options "-std=gnu++17" }
-
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-// basic_string_view constructors.
-
-#include <string_view>
-#include <string>
-#include <cwchar>
-#include <testsuite_hooks.h>
-
-void
-test01()
-{
-  typedef std::wstring_view::size_type csize_type;
-
-  // basic_string_view()
-  const std::wstring_view str00{};
-  VERIFY( str00.length() == 0 );
-  VERIFY( str00.data() == nullptr );
-
-  // basic_string_view(const char*)
-  const wchar_t str_lit01[] = L"rodeo beach, marin";
-  const std::wstring_view str01{str_lit01};
-  VERIFY( str01.length() == 18 );
-  VERIFY( str01.data() == str_lit01 );
-  const std::wstring_view str02{L"baker beach, san francisco"};
-  VERIFY( str02.length() == 26 );
-
-  // basic_string_view(const string_view&)
-  std::wstring_view str04{str01};
-  VERIFY( str04.length() == str01.length() );
-  VERIFY( str04.data() == str01.data() );
-
-  // basic_string_view(const char* s)
-  csize_type len_lit01 = wcslen(str_lit01);
-  std::wstring_view str05{str_lit01, len_lit01};
-  VERIFY( str05.length() == len_lit01 );
-  VERIFY( str05.data() == str_lit01 );
-
-  // basic_string_view(basic_string& s)
-  std::wstring istr07(10, L'z');
-  std::wstring_view str07{istr07};
-  VERIFY( str07.length() == 10 );
-}
-
-int
-main()
-{ 
-  test01();
-
-  return 0;
-}
diff --git a/gdb/unittests/basic_string_view/cons/wchar_t/2.cc b/gdb/unittests/basic_string_view/cons/wchar_t/2.cc
deleted file mode 100644
index 54a7fe509bb..00000000000
--- a/gdb/unittests/basic_string_view/cons/wchar_t/2.cc
+++ /dev/null
@@ -1,45 +0,0 @@
-// { dg-options "-std=gnu++17" }
-
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-// basic_string_view constructors.
-
-#include <string_view>
-#include <testsuite_hooks.h>
-
-void
-test03()
-{
-  const wchar_t* with_nulls = L"This contains \0 a zero byte.";
-
-  // These are tests to see how basic_string_view handles data with NUL
-  // bytes.  Obviously basic_string_view(char*) will halt at the first one, but
-  // nothing else should.
-  std::wstring_view s1 (with_nulls, 28);
-  VERIFY( s1.size() == 28 );
-  std::wstring_view s2 (s1);
-  VERIFY( s2.size() == 28 );
-}
-
-int
-main()
-{ 
-  test03();
-
-  return 0;
-}
diff --git a/gdb/unittests/basic_string_view/cons/wchar_t/3.cc b/gdb/unittests/basic_string_view/cons/wchar_t/3.cc
deleted file mode 100644
index 540683f5421..00000000000
--- a/gdb/unittests/basic_string_view/cons/wchar_t/3.cc
+++ /dev/null
@@ -1,38 +0,0 @@
-// { dg-options "-std=gnu++17" }
-
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-// basic_string_view constructors.
-
-#include <string_view>
-#include <testsuite_hooks.h>
-
-void
-test05()
-{
-  wchar_t const * s = 0;
-  std::wstring_view zero_length_built_with_NULL(s, 0);
-}
-
-int
-main()
-{ 
-  test05();
-
-  return 0;
-}
diff --git a/gdb/unittests/basic_string_view/element_access/char/1.cc b/gdb/unittests/basic_string_view/element_access/char/1.cc
deleted file mode 100644
index 788d174d852..00000000000
--- a/gdb/unittests/basic_string_view/element_access/char/1.cc
+++ /dev/null
@@ -1,70 +0,0 @@
-// { dg-options "-std=gnu++17" }
-
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-// basic_string element access
-
-namespace element_access_1 {
-
-static void
-test01 ()
-{
-  typedef gdb::string_view::size_type csize_type;
-  typedef gdb::string_view::const_reference cref;
-  typedef gdb::string_view::reference ref;
-  csize_type csz01;
-
-  const gdb::string_view str01("tamarindo, costa rica");
-  gdb::string_view str02("41st street beach, capitola, california");
-  gdb::string_view str03;
-
-  // const_reference operator[] (size_type pos) const;
-  csz01 = str01.size();
-  cref cref1 = str01[csz01 - 1];
-  VERIFY( cref1 == 'a' );
-  // Undefined behavior at size().
-  //cref cref2 = str01[csz01];
-  //VERIFY( cref2 == char() );
-
-  // const_reference at(size_type pos) const;
-  csz01 = str01.size();
-  cref cref3 = str01.at(csz01 - 1);
-  VERIFY( cref3 == 'a' );
-  try
-  {
-    str01.at(csz01);
-    VERIFY( false ); // Should not get here, as exception thrown.
-  }
-  catch (gdb_exception& fail)
-  {
-    VERIFY( true );
-  }
-  catch (...)
-  {
-    VERIFY( false );
-  }
-}
-
-static int
-main ()
-{ 
-  test01();
-  return 0;
-}
-
-} // namespace element_access_1
diff --git a/gdb/unittests/basic_string_view/element_access/char/2.cc b/gdb/unittests/basic_string_view/element_access/char/2.cc
deleted file mode 100644
index 938916e2924..00000000000
--- a/gdb/unittests/basic_string_view/element_access/char/2.cc
+++ /dev/null
@@ -1,30 +0,0 @@
-// { dg-do run { xfail *-*-* } }
-// { dg-options "-std=gnu++17 -O0" }
-// { dg-require-debug-mode "" }
-
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-#include <string_view>
-
-int
-main()
-{
-  typedef std::string_view string_view_type;
-  string_view_type s;
-  s[0]; // abort
-}
diff --git a/gdb/unittests/basic_string_view/element_access/char/empty.cc b/gdb/unittests/basic_string_view/element_access/char/empty.cc
deleted file mode 100644
index 030c96aa073..00000000000
--- a/gdb/unittests/basic_string_view/element_access/char/empty.cc
+++ /dev/null
@@ -1,39 +0,0 @@
-// { dg-options "-std=gnu++17" }
-
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-//
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-//
-
-namespace element_access_empty {
-
-static int
-main ()
-{
-  {
-    gdb::string_view empty;
-    VERIFY( empty.empty() );
-  }
-
-  {
-    const gdb::string_view empty;
-    VERIFY( empty.empty() );
-  }
-
-  return 0;
-}
-
-} // namespace element_access_empty
diff --git a/gdb/unittests/basic_string_view/element_access/char/front_back.cc b/gdb/unittests/basic_string_view/element_access/char/front_back.cc
deleted file mode 100644
index 7e767fc7910..00000000000
--- a/gdb/unittests/basic_string_view/element_access/char/front_back.cc
+++ /dev/null
@@ -1,43 +0,0 @@
-// { dg-options "-std=gnu++17" }
-// { dg-require-string-conversions "" }
-
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-namespace element_access_front_back {
-
-static void
-test01 ()
-{
-  gdb::string_view str("ramifications");
-  const gdb::string_view cstr("melodien");
-
-  VERIFY( str.front() == 'r' );
-  VERIFY( str.back() == 's' );
-  VERIFY( cstr.front() == 'm' );
-  VERIFY( cstr.back() == 'n' );
-}
-
-static int
-main ()
-{
-  test01();
-
-  return 0;
-}
-
-} // namespace element_access_front_back
diff --git a/gdb/unittests/basic_string_view/element_access/wchar_t/1.cc b/gdb/unittests/basic_string_view/element_access/wchar_t/1.cc
deleted file mode 100644
index 679772b4c57..00000000000
--- a/gdb/unittests/basic_string_view/element_access/wchar_t/1.cc
+++ /dev/null
@@ -1,71 +0,0 @@
-// { dg-options "-std=gnu++17" }
-
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-// basic_string_view element access
-
-#include <string_view>
-#include <stdexcept>
-#include <testsuite_hooks.h>
-
-void
-test01()
-{
-  typedef std::wstring_view::size_type csize_type;
-  typedef std::wstring_view::const_reference cref;
-  typedef std::wstring_view::reference ref;
-  csize_type csz01, csz02;
-
-  const std::wstring_view str01(L"tamarindo, costa rica");
-  std::wstring_view str02(L"41st street beach, capitola, california");
-  std::wstring_view str03;
-
-  // const_reference operator[] (size_type pos) const;
-  csz01 = str01.size();
-  cref cref1 = str01[csz01 - 1];
-  VERIFY( cref1 == L'a' );
-  // Undefined behavior at size().
-  //cref cref2 = str01[csz01];
-  //VERIFY( cref2 == wchar_t() );
-
-  // const_reference at(size_type pos) const;
-  csz01 = str01.size();
-  cref cref3 = str01.at(csz01 - 1);
-  VERIFY( cref3 == L'a' );
-  try
-  {
-    str01.at(csz01);
-    VERIFY( false ); // Should not get here, as exception thrown.
-  }
-  catch (std::out_of_range& fail)
-  {
-    VERIFY( true );
-  }
-  catch (...)
-  {
-    VERIFY( false );
-  }
-}
-
-int
-main()
-{ 
-  test01();
-
-  return 0;
-}
diff --git a/gdb/unittests/basic_string_view/element_access/wchar_t/2.cc b/gdb/unittests/basic_string_view/element_access/wchar_t/2.cc
deleted file mode 100644
index cdbc6a5e5a8..00000000000
--- a/gdb/unittests/basic_string_view/element_access/wchar_t/2.cc
+++ /dev/null
@@ -1,32 +0,0 @@
-// { dg-do run { xfail *-*-* } }
-// { dg-options "-std=gnu++17 -O0" }
-// { dg-require-debug-mode "" }
-
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-#include <string_view>
-
-// libstdc++/21674
-// NB: Should work without any inlining or optimizations (ie. -O0).
-int
-main()
-{
-  typedef std::wstring_view string_view_type;
-  string_view_type s;
-  s[0]; // abort
-}
diff --git a/gdb/unittests/basic_string_view/element_access/wchar_t/empty.cc b/gdb/unittests/basic_string_view/element_access/wchar_t/empty.cc
deleted file mode 100644
index f31d34aa42b..00000000000
--- a/gdb/unittests/basic_string_view/element_access/wchar_t/empty.cc
+++ /dev/null
@@ -1,38 +0,0 @@
-// { dg-options "-std=gnu++17" }
-
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-//
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-//
-
-#include <string_view>
-#include <testsuite_hooks.h>
-
-int
-main()
-{
-  {
-    std::wstring_view empty;
-    VERIFY( empty.empty() );
-  }
-
-  {
-    const std::wstring_view empty;
-    VERIFY( empty.empty() );
-  }
-
-  return 0;
-}
diff --git a/gdb/unittests/basic_string_view/element_access/wchar_t/front_back.cc b/gdb/unittests/basic_string_view/element_access/wchar_t/front_back.cc
deleted file mode 100644
index c17a08a45c7..00000000000
--- a/gdb/unittests/basic_string_view/element_access/wchar_t/front_back.cc
+++ /dev/null
@@ -1,42 +0,0 @@
-// { dg-options "-std=gnu++17" }
-// { dg-require-string-conversions "" }
-
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-#include <string_view>
-#include <testsuite_hooks.h>
-
-void
-test01()
-{
-  std::wstring_view str(L"ramifications");
-  const std::wstring_view cstr(L"melodien");
-
-  VERIFY( str.front() == L'r' );
-  VERIFY( str.back() == L's' );
-  VERIFY( cstr.front() == L'm' );
-  VERIFY( cstr.back() == L'n' );
-}
-
-int
-main()
-{
-  test01();
-
-  return 0;
-}
diff --git a/gdb/unittests/basic_string_view/include.cc b/gdb/unittests/basic_string_view/include.cc
deleted file mode 100644
index ef01b7c478c..00000000000
--- a/gdb/unittests/basic_string_view/include.cc
+++ /dev/null
@@ -1,25 +0,0 @@
-// -*- C++ -*-
-
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-// NB: This issue affected only debug-mode.
-
-// { dg-options "-std=gnu++17 -fno-rtti" }
-// { dg-do compile }
-
-#include <string_view>
diff --git a/gdb/unittests/basic_string_view/inserters/char/1.cc b/gdb/unittests/basic_string_view/inserters/char/1.cc
deleted file mode 100644
index e0a33bf13bd..00000000000
--- a/gdb/unittests/basic_string_view/inserters/char/1.cc
+++ /dev/null
@@ -1,65 +0,0 @@
-// { dg-options "-std=gnu++17" }
-
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-// inserters
-
-// NB: This file is predicated on sstreams, istreams, and ostreams
-// working, not to mention other major details like char_traits, and
-// all of the string_view class.
-
-#include <string_view>
-#include <stdexcept>
-#include <sstream>
-#include <fstream>
-#include <iostream>
-#include <testsuite_hooks.h>
-
-void
-test01()
-{
-  typedef std::string_view::size_type csize_type;
-  typedef std::string_view::const_reference cref;
-  typedef std::string_view::reference ref;
-
-  const std::string_view str01("sailing grand traverse bay\n"
-	       "\t\t\t    from Elk Rapids to the point reminds me of miles");
-    
-  // ostream& operator<<(ostream&, const basic_string_view&)
-  std::ostringstream ostrs01;
-  try 
-    {
-      ostrs01 << str01;
-      VERIFY( ostrs01.str() == str01 );
-    }
-  catch(std::exception& fail) 
-    {
-      VERIFY( false );
-    }
-  
-  std::string_view hello_world;
-  std::cout << hello_world;
-}
-
-int
-main()
-{ 
-  test01();
-
-  return 0;
-}
diff --git a/gdb/unittests/basic_string_view/inserters/char/2.cc b/gdb/unittests/basic_string_view/inserters/char/2.cc
deleted file mode 100644
index 840f52185df..00000000000
--- a/gdb/unittests/basic_string_view/inserters/char/2.cc
+++ /dev/null
@@ -1,91 +0,0 @@
-
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-// inserters
-
-// NB: This file is predicated on sstreams, ostreams
-// working, not to mention other major details like char_traits, and
-// all of the string_view class.
-
-// { dg-options "-std=gnu++17" }
-// { dg-require-fileio "" }
-
-namespace inserters_2 {
-
-// testing basic_filebuf::xsputn via stress testing with large string_views
-// based on a bug report libstdc++ 9
-// mode == out
-static void
-test05 (std::size_t size)
-{
-  bool test ATTRIBUTE_UNUSED = true;
-
-  const char filename[] = "inserters_extractors-2.txt";
-  const char fillc = 'f';
-  std::ofstream ofs(filename);
-  std::string str(size, fillc);
-  gdb::string_view strv{str};
-
-  // sanity checks
-  VERIFY( str.size() == size );
-  VERIFY( ofs.good() );
-
-  // stress test
-  ofs << str << std::endl;
-  if (!ofs.good()) 
-    test = false;
-
-  ofs << str << std::endl;
-  if (!ofs.good()) 
-    test = false;
-
-  VERIFY( str.size() == size );
-  VERIFY( ofs.good() );
-
-  ofs.close();
-
-  // sanity check on the written file
-  std::ifstream ifs(filename);
-  std::size_t count = 0;
-  char c;
-  while (count <= (2 * size) + 4)
-    {
-      ifs >> c;
-      if (ifs.good() && c == fillc)
-	{
-	  ++count;
-	  c = '0';
-	}
-      else 
-	break;
-    }
-
-  VERIFY( count == 2 * size );
-}
-
-static int
-main ()
-{
-  test05(1); 
-  test05(1000); 
-  test05(10000);
-
-  return 0;
-}
-
-} // namespace inserters_2
diff --git a/gdb/unittests/basic_string_view/inserters/char/3.cc b/gdb/unittests/basic_string_view/inserters/char/3.cc
deleted file mode 100644
index 43e3ae05ba7..00000000000
--- a/gdb/unittests/basic_string_view/inserters/char/3.cc
+++ /dev/null
@@ -1,54 +0,0 @@
-// { dg-options "-std=gnu++17" }
-
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-// inserters
-
-// NB: This file is predicated on sstreams, and ostreams
-// working, not to mention other major details like char_traits, and
-// all of the string_view class.
-
-#include <string_view>
-#include <sstream>
-#include <iomanip>
-#include <testsuite_hooks.h>
-
-// libstdc++/2830
-void
-test09()
-{
-  std::string_view foo{"peace\0\0\0& love"};
-
-  std::ostringstream oss1;
-  oss1 << foo;
-  VERIFY( oss1.str() == foo );
-
-  std::ostringstream oss2;
-  oss2.width(20);
-  oss2 << foo;
-  VERIFY( oss2.str() != foo );
-  VERIFY( oss2.str().size() == 20 );
-}
-
-int
-main()
-{ 
-  test09();
-
-  return 0;
-}
diff --git a/gdb/unittests/basic_string_view/inserters/pod/10081-out.cc b/gdb/unittests/basic_string_view/inserters/pod/10081-out.cc
deleted file mode 100644
index 4b5d81d33cf..00000000000
--- a/gdb/unittests/basic_string_view/inserters/pod/10081-out.cc
+++ /dev/null
@@ -1,75 +0,0 @@
-// { dg-options "-std=gnu++17" }
-
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-// class basic_istream::sentry
-
-#include <string_view>
-#include <ostream>
-#include <sstream>
-#include <locale>
-#include <typeinfo>
-#include <testsuite_hooks.h>
-#include <testsuite_character.h>
-
-void
-test01()
-{
-  using namespace std;
-
-  using __gnu_test::pod_ushort;
-  typedef basic_string_view<pod_ushort> 	string_type;
-  typedef basic_stringbuf<pod_ushort> 	stringbuf_type;
-  typedef basic_ostream<pod_ushort> 	ostream_type;
-
-  string_type str;
-  stringbuf_type strbuf01;
-  ostream_type stream(&strbuf01);
-
-  try
-    {
-      stream << str;
-    }
-  catch (std::bad_cast& obj)
-    {
-      // Ok, throws bad_cast because locale has no ctype facet.
-    }
-  catch (...)
-    {
-      VERIFY( false );
-    }
-
-  const std::locale loc(std::locale::classic(), new std::ctype<pod_ushort>);
-  stream.imbue(loc);
-  try
-    {
-      stream << str;
-    }
-  catch (...)
-    {
-      VERIFY( false );
-    }
-}
-
-int
-main()
-{
-  test01();
-
-  return 0;
-}
diff --git a/gdb/unittests/basic_string_view/inserters/wchar_t/1.cc b/gdb/unittests/basic_string_view/inserters/wchar_t/1.cc
deleted file mode 100644
index 69754254e4f..00000000000
--- a/gdb/unittests/basic_string_view/inserters/wchar_t/1.cc
+++ /dev/null
@@ -1,70 +0,0 @@
-// { dg-options "-std=gnu++17" }
-
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-// inserters
-
-// NB: This file is predicated on sstreams, and ostreams
-// working, not to mention other major details like char_traits, and
-// all of the string_view class.
-
-#include <string_view>
-#include <stdexcept>
-#include <sstream>
-#include <fstream>
-#include <iostream>
-#include <testsuite_hooks.h>
-
-void
-test01()
-{
-  typedef std::wstring_view::size_type csize_type;
-  typedef std::wstring_view::const_reference cref;
-  typedef std::wstring_view::reference ref;
-
-  const std::wstring_view str01(L"sailing grand traverse bay\n"
-	       L"\t\t\t    from Elk Rapids to the point reminds me of miles");
-  const std::wstring_view str02(L"sailing");
-  const std::wstring_view str03(L"grand");
-  const std::wstring_view str04(L"traverse");
-  const std::wstring_view str05;
-  std::wstring_view str10;
-
-  // ostream& operator<<(ostream&, const basic_string_view&)
-  std::wostringstream ostrs01;
-  try 
-    {
-      ostrs01 << str01;
-      VERIFY( ostrs01.str() == str01 );
-    }
-  catch(std::exception& fail) 
-    {
-      VERIFY( false );
-    }
-  
-  std::wstring_view hello_world;
-  std::wcout << hello_world;
-}
-
-int
-main()
-{ 
-  test01();
-
-  return 0;
-}
diff --git a/gdb/unittests/basic_string_view/inserters/wchar_t/2.cc b/gdb/unittests/basic_string_view/inserters/wchar_t/2.cc
deleted file mode 100644
index 5cc3e93e5b7..00000000000
--- a/gdb/unittests/basic_string_view/inserters/wchar_t/2.cc
+++ /dev/null
@@ -1,91 +0,0 @@
-// { dg-options "-std=gnu++17" }
-
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-// inserters
-
-// NB: This file is predicated on sstreams, istreams, and ostreams
-// working, not to mention other major details like char_traits, and
-// all of the string_view class.
-
-#include <string_view>
-#include <string>
-#include <fstream>
-#include <iostream>
-#include <testsuite_hooks.h>
-
-// testing basic_filebuf::xsputn via stress testing with large string_views
-// based on a bug report libstdc++ 9
-// mode == out
-void
-test05(std::size_t size)
-{
-  bool test = true;
-
-  const char filename[] = "inserters_extractors-2.txt";
-  const wchar_t fillc = L'f';
-  std::wofstream ofs(filename);
-  std::wstring str(size, fillc);
-  std::wstring_view strv(str);
-
-  // sanity checks
-  VERIFY( str.size() == size );
-  VERIFY( ofs.good() );
-
-  // stress test
-  ofs << str << std::endl;
-  if (!ofs.good()) 
-    test = false;
-
-  ofs << str << std::endl;
-  if (!ofs.good()) 
-    test = false;
-
-  VERIFY( str.size() == size );
-  VERIFY( ofs.good() );
-
-  ofs.close();
-
-  // sanity check on the written file
-  std::wifstream ifs(filename);
-  std::size_t count = 0;
-  wchar_t c;
-  while (count <= (2 * size) + 4)
-    {
-      ifs >> c;
-      if (ifs.good() && c == fillc)
-	{
-	  ++count;
-	  c = '0';
-	}
-      else 
-	break;
-    }
-
-  VERIFY( count == 2 * size );
-}
-
-int
-main()
-{
-  test05(1); 
-  test05(1000); 
-  test05(10000);
-
-  return 0;
-}
diff --git a/gdb/unittests/basic_string_view/inserters/wchar_t/3.cc b/gdb/unittests/basic_string_view/inserters/wchar_t/3.cc
deleted file mode 100644
index 5eabf46dd44..00000000000
--- a/gdb/unittests/basic_string_view/inserters/wchar_t/3.cc
+++ /dev/null
@@ -1,53 +0,0 @@
-// { dg-options "-std=gnu++17" }
-
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-// inserters
-
-// NB: This file is predicated on sstreams, istreams, and ostreams
-// working, not to mention other major details like char_traits, and
-// all of the string_view class.
-
-#include <string_view>
-#include <sstream>
-#include <iomanip>
-#include <testsuite_hooks.h>
-
-void
-test09()
-{
-  std::wstring_view foo{L"peace\0\0\0& love"};
-  
-  std::wostringstream oss1;
-  oss1 << foo;
-  VERIFY( oss1.str() == foo );
-  
-  std::wostringstream oss2;
-  oss2.width(20);
-  oss2 << foo;
-  VERIFY( oss2.str() != foo );
-  VERIFY( oss2.str().size() == 20 );
-}
-
-int
-main()
-{ 
-  test09();
-
-  return 0;
-}
diff --git a/gdb/unittests/basic_string_view/literals/types.cc b/gdb/unittests/basic_string_view/literals/types.cc
deleted file mode 100644
index de0aa1e7569..00000000000
--- a/gdb/unittests/basic_string_view/literals/types.cc
+++ /dev/null
@@ -1,45 +0,0 @@
-// { dg-options "-std=gnu++17" }
-// { dg-do compile }
-
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-#include <string_view>
-#include <type_traits>
-
-void
-test01()
-{
-  using namespace std::literals::string_view_literals;
-
-  static_assert(std::is_same<decltype("Hello"sv), std::string_view>::value,
-		"\"Hello\"s is std::string_view");
-
-  static_assert(std::is_same<decltype(u8"Hello"sv), std::string_view>::value,
-		"u8\"Hello\"s is std::string_view");
-
-#ifdef _GLIBCXX_USE_WCHAR_T
-  static_assert(std::is_same<decltype(L"Hello"sv), std::wstring_view>::value,
-		"L\"Hello\"s is std::wstring_view");
-#endif
-
-  static_assert(std::is_same<decltype(u"Hello"sv), std::u16string_view>::value,
-		"u\"Hello\"s is std::u16string_view");
-
-  static_assert(std::is_same<decltype(U"Hello"sv), std::u32string_view>::value,
-		"U\"Hello\"s is std::u32string_view");
-}
diff --git a/gdb/unittests/basic_string_view/literals/values.cc b/gdb/unittests/basic_string_view/literals/values.cc
deleted file mode 100644
index ebd69b84455..00000000000
--- a/gdb/unittests/basic_string_view/literals/values.cc
+++ /dev/null
@@ -1,72 +0,0 @@
-// { dg-options "-std=gnu++17" }
-
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-#include <string_view>
-#include <testsuite_hooks.h>
-
-void
-test01()
-{
-  using namespace std::literals::string_view_literals;
-
-  std::string_view planet = "Mercury"sv;
-#ifdef _GLIBCXX_USE_WCHAR_T
-  std::wstring_view wplanet = L"Venus"sv;
-#endif
-  std::string_view u8planet = u8"Mars"sv;
-  std::u16string_view u16planet = u"Jupiter"sv;
-  std::u32string_view u32planet = U"Saturn"sv;
-
-  VERIFY( planet == std::string_view("Mercury") );
-#ifdef _GLIBCXX_USE_WCHAR_T
-  VERIFY( wplanet == std::wstring_view(L"Venus") );
-#endif
-  VERIFY( u8planet == std::string_view(u8"Mars") );
-  VERIFY( u16planet == std::u16string_view(u"Jupiter") );
-  VERIFY( u32planet == std::u32string_view(U"Saturn") );
-}
-
-void
-test02()
-{
-  using namespace std::literals::string_view_literals;
-
-  std::string_view planet_cratered = "Mercury\0cratered"sv;
-#ifdef _GLIBCXX_USE_WCHAR_T
-  std::wstring_view wplanet_cratered = L"Venus\0cratered"sv;
-#endif
-  std::string_view u8planet_cratered = u8"Mars\0cratered"sv;
-  std::u16string_view u16planet_cratered = u"Jupiter\0cratered"sv;
-  std::u32string_view u32planet_cratered = U"Saturn\0cratered"sv;
-
-  VERIFY( planet_cratered == std::string_view("Mercury\0cratered", 16) );
-#ifdef _GLIBCXX_USE_WCHAR_T
-  VERIFY( wplanet_cratered == std::wstring_view(L"Venus\0cratered", 14) );
-#endif
-  VERIFY( u8planet_cratered == std::string_view(u8"Mars\0cratered", 13) );
-  VERIFY( u16planet_cratered == std::u16string_view(u"Jupiter\0cratered", 16) );
-  VERIFY( u32planet_cratered == std::u32string_view(U"Saturn\0cratered", 15) );
-}
-
-int
-main()
-{
-  test01();
-  test02();
-}
diff --git a/gdb/unittests/basic_string_view/modifiers/remove_prefix/char/1.cc b/gdb/unittests/basic_string_view/modifiers/remove_prefix/char/1.cc
deleted file mode 100644
index 4ebf4c04ad2..00000000000
--- a/gdb/unittests/basic_string_view/modifiers/remove_prefix/char/1.cc
+++ /dev/null
@@ -1,66 +0,0 @@
-// { dg-options "-std=gnu++17" }
-
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-namespace modifiers_remove_prefix {
-
-static void
-test01 ()
-{
-  using gdb::string_view;
-
-  string_view str0{"olympus mons"};
-  string_view::pointer p = str0.data();
-  str0.remove_prefix(4);
-  VERIFY( str0.data() == p + 4);
-  VERIFY( str0.length() == 8 );
-  VERIFY( str0 == string_view{"pus mons"} );
-}
-
-#ifndef GDB_STRING_VIEW
-constexpr bool
-test02()
-{
-  using std::string_view;
-
-  string_view str0{"olympus mons"};
-  string_view::pointer p = str0.data();
-  str0.remove_prefix(4);
-  if ( str0.data() != p + 4)
-    return false;
-  if ( str0.length() != 8 )
-    return false;
-  if ( str0 != string_view{"pus mons"} )
-    return false;
-
-  return true;
-}
-#endif
-
-static int
-main ()
-{ 
-  test01();
-#ifndef GDB_STRING_VIEW
-  static_assert( test02() );
-#endif
-
-  return 0;
-}
-
-} // namespace modifiers_remove_prefix
diff --git a/gdb/unittests/basic_string_view/modifiers/remove_prefix/wchar_t/1.cc b/gdb/unittests/basic_string_view/modifiers/remove_prefix/wchar_t/1.cc
deleted file mode 100644
index 3503dcbab53..00000000000
--- a/gdb/unittests/basic_string_view/modifiers/remove_prefix/wchar_t/1.cc
+++ /dev/null
@@ -1,61 +0,0 @@
-// { dg-options "-std=gnu++17" }
-
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-#include <string_view>
-#include <testsuite_hooks.h>
-
-void
-test01()
-{
-  using std::wstring_view;
-
-  wstring_view str0{L"olympus mons"};
-  wstring_view::pointer p = str0.data();
-  str0.remove_prefix(4);
-  VERIFY( str0.data() == p + 4);
-  VERIFY( str0.length() == 8 );
-  VERIFY( str0 == wstring_view{L"pus mons"} );
-}
-
-constexpr bool
-test02()
-{
-  using std::wstring_view;
-
-  wstring_view str0{L"olympus mons"};
-  wstring_view::pointer p = str0.data();
-  str0.remove_prefix(4);
-  if ( str0.data() != p + 4)
-    return false;
-  if ( str0.length() != 8 )
-    return false;
-  if ( str0 != wstring_view{L"pus mons"} )
-    return false;
-
-  return true;
-}
-
-int
-main()
-{ 
-  test01();
-  static_assert( test02() );
-
-  return 0;
-}
diff --git a/gdb/unittests/basic_string_view/modifiers/remove_suffix/char/1.cc b/gdb/unittests/basic_string_view/modifiers/remove_suffix/char/1.cc
deleted file mode 100644
index 5e9259eecad..00000000000
--- a/gdb/unittests/basic_string_view/modifiers/remove_suffix/char/1.cc
+++ /dev/null
@@ -1,66 +0,0 @@
-// { dg-options "-std=gnu++17" }
-
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-namespace modifiers_remove_suffix {
-
-static void
-test01 ()
-{
-  using gdb::string_view;
-
-  string_view str0{"olympus mons"};
-  string_view::pointer p = str0.data();
-  str0.remove_suffix(2);
-  VERIFY( str0.data() == p);
-  VERIFY( str0.length() == 10 );
-  VERIFY( str0 == string_view{"olympus mo"} );
-}
-
-#ifndef GDB_STRING_VIEW
-constexpr bool
-test02()
-{
-  using std::string_view;
-
-  string_view str0{"olympus mons"};
-  string_view::pointer p = str0.data();
-  str0.remove_suffix(2);
-  if ( str0.data() != p)
-    return false;
-  if ( str0.length() != 10 )
-    return false;
-  if ( str0 != string_view{"olympus mo"} )
-    return false;
-
-  return true;
-}
-#endif
-
-static int
-main ()
-{ 
-  test01();
-#ifndef GDB_STRING_VIEW
-  static_assert( test02() );
-#endif
-
-  return 0;
-}
-
-} // namespace modifiers_remove_suffix
diff --git a/gdb/unittests/basic_string_view/modifiers/remove_suffix/wchar_t/1.cc b/gdb/unittests/basic_string_view/modifiers/remove_suffix/wchar_t/1.cc
deleted file mode 100644
index 7f9e051d986..00000000000
--- a/gdb/unittests/basic_string_view/modifiers/remove_suffix/wchar_t/1.cc
+++ /dev/null
@@ -1,61 +0,0 @@
-// { dg-options "-std=gnu++17" }
-
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-#include <string_view>
-#include <testsuite_hooks.h>
-
-void
-test01()
-{
-  using std::wstring_view;
-
-  wstring_view str0{L"olympus mons"};
-  wstring_view::pointer p = str0.data();
-  str0.remove_suffix(2);
-  VERIFY( str0.data() == p);
-  VERIFY( str0.length() == 10 );
-  VERIFY( str0 == wstring_view{L"olympus mo"} );
-}
-
-constexpr bool
-test02()
-{
-  using std::wstring_view;
-
-  wstring_view str0{L"olympus mons"};
-  wstring_view::pointer p = str0.data();
-  str0.remove_suffix(2);
-  if ( str0.data() != p)
-    return false;
-  if ( str0.length() != 10 )
-    return false;
-  if ( str0 != wstring_view{L"olympus mo"} )
-    return false;
-
-  return true;
-}
-
-int
-main()
-{ 
-  test01();
-  static_assert( test02() );
-
-  return 0;
-}
diff --git a/gdb/unittests/basic_string_view/modifiers/swap/char/1.cc b/gdb/unittests/basic_string_view/modifiers/swap/char/1.cc
deleted file mode 100644
index d583566c4bd..00000000000
--- a/gdb/unittests/basic_string_view/modifiers/swap/char/1.cc
+++ /dev/null
@@ -1,36 +0,0 @@
-// Copyright (C) 2017-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-// { dg-options "-std=gnu++17" }
-// { dg-do compile { target c++17 } }
-
-namespace modifiers_swap {
-
-static void
-test01 ()
-{
-  using gdb::string_view;
-
-  string_view s1{"last"};
-  string_view s2{"first"};
-
-  s1.swap(s2);
-  VERIFY( s1 == "first" );
-  VERIFY( s2 == "last" );
-}
-
-} // namespace modifiers_swap
diff --git a/gdb/unittests/basic_string_view/modifiers/swap/wchar_t/1.cc b/gdb/unittests/basic_string_view/modifiers/swap/wchar_t/1.cc
deleted file mode 100644
index b986088f1e2..00000000000
--- a/gdb/unittests/basic_string_view/modifiers/swap/wchar_t/1.cc
+++ /dev/null
@@ -1,35 +0,0 @@
-// Copyright (C) 2017-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-// { dg-options "-std=gnu++17" }
-// { dg-do compile { target c++17 } }
-
-#include <string_view>
-
-constexpr bool
-test01()
-{
-  using std::wstring_view;
-
-  wstring_view s1{L"last"};
-  wstring_view s2{L"first"};
-
-  s1.swap(s2);
-  return s1 == L"first" && s2 == L"last";
-}
-
-static_assert( test01() );
diff --git a/gdb/unittests/basic_string_view/operations/compare/char/1.cc b/gdb/unittests/basic_string_view/operations/compare/char/1.cc
deleted file mode 100644
index d824c8e2277..00000000000
--- a/gdb/unittests/basic_string_view/operations/compare/char/1.cc
+++ /dev/null
@@ -1,132 +0,0 @@
-// { dg-options "-std=gnu++17" }
-
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-// basic_string_view::compare
-// int compare(const basic_string_view& str) const;
-// int compare(size_type pos1, size_type n1, const basic_string_view& str) const;
-// int compare(size_type pos1, size_type n1, const basic_string_view& str,
-//             size_type pos2, size_type n2) const;
-// int compare(const charT* s) const;
-// int compare(size_type pos1, size_type n1,
-//             const charT* s, size_type n2 = npos) const;
-
-// NB compare should be thought of as a lexographical compare, ie how
-// things would be sorted in a dictionary.
-
-namespace operations_compare_1 {
-
-enum want_value {lt=0, z=1, gt=2};
-
-int
-test_value(int result, want_value expected);
-
-int
-test_value(int result, want_value expected)
-{
-  bool pass = false;
-
-  switch (expected) {
-  case lt:
-    if (result < 0)
-      pass = true;
-    break;
-  case z:
-    if (!result)
-      pass = true;
-    break;
-  case gt:
-    if (result > 0)
-      pass = true;
-    break;
-  default:
-    pass = false; //should not get here
-  }
-  VERIFY(pass);
-  return 0;
-}
-
-static int
-test01 ()
-{
-  using gdb::string_view;
-
-  string_view 	str_0("costa rica");
-  string_view 	str_1("costa marbella");
-  string_view 	str_2;
-
-  //sanity check
-  test_value(strcmp("costa marbella", "costa rica"), lt);
-  test_value(strcmp("costa rica", "costa rica"), z);
-  test_value(strcmp(str_1.data(), str_0.data()), lt);
-  test_value(strcmp(str_0.data(), str_1.data()), gt);
-  test_value(strncmp(str_1.data(), str_0.data(), 6), z);
-  test_value(strncmp(str_1.data(), str_0.data(), 14), lt);
-  test_value(memcmp(str_1.data(), str_0.data(), 6), z);
-  test_value(memcmp(str_1.data(), str_0.data(), 10), lt);
-  test_value(memcmp("costa marbella", "costa rica", 10), lt);
-
-  // int compare(const basic_string_view& str) const;
-  test_value(str_0.compare(str_1), gt); //because r>m
-  test_value(str_1.compare(str_0), lt); //because m<r
-  str_2 = str_0;
-  test_value(str_2.compare(str_0), z);
-  str_2 = "cost";
-  test_value(str_2.compare(str_0), lt);
-  str_2 = "costa ricans";
-  test_value(str_2.compare(str_0), gt);
-
-  // int compare(size_type pos1, size_type n1, const basic_string_view& str) const;
-  test_value(str_1.compare(0, 6, str_0), lt);
-  str_2 = "cost";
-  test_value(str_1.compare(0, 4, str_2), z);
-  test_value(str_1.compare(0, 5, str_2), gt);
-
-  // int compare(size_type pos1, size_type n1, const basic_string_view& str,
-  //		 size_type pos2, size_type n2) const;
-  test_value(str_1.compare(0, 6, str_0, 0, 6), z);
-  test_value(str_1.compare(0, 7, str_0, 0, 7), lt);
-  test_value(str_0.compare(0, 7, str_1, 0, 7), gt);
-
-  // int compare(const charT* s) const;
-  test_value(str_0.compare("costa marbella"), gt);
-  test_value(str_1.compare("costa rica"), lt);
-  str_2 = str_0;
-  test_value(str_2.compare("costa rica"), z);
-  test_value(str_2.compare("cost"), gt);
-  test_value(str_2.compare("costa ricans"), lt);
-
-  // int compare(size_type pos, size_type n1, const charT* str,
-  //             size_type n2 = npos) const;
-  test_value(str_1.compare(0, 6, "costa rica", 0, 6), z);
-  test_value(str_1.compare(0, 7, "costa rica", 0, 7), lt);
-  test_value(str_0.compare(0, 7, "costa marbella", 0, 7), gt);
-
-  return 0;
-}
-
-
-static int
-main ()
-{
-  test01();
-
-  return 0;
-}
-
-} // namespace operations_compare_1
diff --git a/gdb/unittests/basic_string_view/operations/compare/char/13650.cc b/gdb/unittests/basic_string_view/operations/compare/char/13650.cc
deleted file mode 100644
index cbfe4a07444..00000000000
--- a/gdb/unittests/basic_string_view/operations/compare/char/13650.cc
+++ /dev/null
@@ -1,50 +0,0 @@
-// { dg-options "-std=gnu++17" }
-
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-// basic_string_view::compare [lib.string_view::compare]
-
-namespace operations_compare_13650 {
-
-// libstdc++/13650
-static void
-test01 ()
-{
-  using gdb::string_view;
-
-  const char lit_01[]{ 'w', 'e', '\0', 'r', 'd' };
-  const char lit_02[]{ 'w', 'e', 'i', '\0', 'd' };
-
-  const char lit_ref_a[]{ 'w', 'e', '\0', 'q', 'd' };
-  const string_view str_a(lit_ref_a, 5);
-  VERIFY( str_a.compare(0, 5, lit_01, 5) < 0 );
-
-  const char lit_ref_b[]{ 'w', 'e', 'i' };
-  const string_view str_b(lit_ref_b, 3);
-  VERIFY( str_b.compare(0, 3, lit_02, 5) < 0 );
-}
-
-static int
-main()
-{
-  test01();
-
-  return 0;
-}
-
-} // namespace operations_compare_13650
diff --git a/gdb/unittests/basic_string_view/operations/compare/char/2.cc b/gdb/unittests/basic_string_view/operations/compare/char/2.cc
deleted file mode 100644
index f0b76afb427..00000000000
--- a/gdb/unittests/basic_string_view/operations/compare/char/2.cc
+++ /dev/null
@@ -1,30 +0,0 @@
-// Copyright (C) 2017-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-// { dg-options "-std=gnu++17" }
-// { dg-do compile { target c++17 } }
-
-#include <string_view>
-
-constexpr char c1[] = "one";
-constexpr char c2[] = "two";
-
-constexpr std::string_view s1{c1};
-constexpr std::string_view s2{c2};
-
-constexpr int n1 = s1.compare(s1);
-constexpr int n2 = s1.compare(s2);
diff --git a/gdb/unittests/basic_string_view/operations/compare/char/70483.cc b/gdb/unittests/basic_string_view/operations/compare/char/70483.cc
deleted file mode 100644
index 259f95f5180..00000000000
--- a/gdb/unittests/basic_string_view/operations/compare/char/70483.cc
+++ /dev/null
@@ -1,89 +0,0 @@
-// Copyright (C) 2017-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-// { dg-options "-std=gnu++17" }
-// { dg-do compile { target c++17 } }
-
-#include <string_view>
-
-struct constexpr_char_traits : std::char_traits<char>
-{
-  static constexpr size_t
-  length(const char* val)
-  {
-    size_t res = 0;
-    for (; val[res] != '\0'; ++res)
-      ;
-    return res;
-  }
-
-  static constexpr int
-  compare(const char* lhs, const char* rhs, std::size_t count)
-  {
-    for (size_t pos = 0; pos < count; ++pos)
-    {
-      if (lhs[pos] != rhs[pos])
-        return lhs[pos] - rhs[pos];
-    }
-    return 0;
-  }
-};
-
-using string_view = std::basic_string_view<char, constexpr_char_traits>;
-
-constexpr
-string_view get()
-{
-    string_view res = "x::";
-    string_view start_pattern = "x";
-    res = res.substr(res.find(start_pattern) + start_pattern.size());
-    res = res.substr(0, res.find_first_of(";]"));
-    res = res.substr(res.rfind("::"));
-    return res;
-}
-
-static_assert( get() == get() );
-
-using std::u16string_view;
-
-constexpr
-u16string_view get16()
-{
-    u16string_view res = u"x::";
-    u16string_view start_pattern = u"x";
-    res = res.substr(res.find(start_pattern) + start_pattern.size());
-    res = res.substr(0, res.find_first_of(u";]"));
-    res = res.substr(res.rfind(u"::"));
-    return res;
-}
-
-static_assert( get16() == get16() );
-
-using std::u32string_view;
-
-constexpr
-u32string_view get32()
-{
-    u32string_view res = U"x::";
-    u32string_view start_pattern = U"x";
-    res = res.substr(res.find(start_pattern) + start_pattern.size());
-    res = res.substr(0, res.find_first_of(U";]"));
-    res = res.substr(res.rfind(U"::"));
-    return res;
-}
-
-static_assert( get32() == get32() );
diff --git a/gdb/unittests/basic_string_view/operations/compare/wchar_t/1.cc b/gdb/unittests/basic_string_view/operations/compare/wchar_t/1.cc
deleted file mode 100644
index 8a05a4053a1..00000000000
--- a/gdb/unittests/basic_string_view/operations/compare/wchar_t/1.cc
+++ /dev/null
@@ -1,133 +0,0 @@
-// { dg-options "-std=gnu++17" }
-
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-// basic_string_view::compare
-// int compare(const basic_string_view& str) const;
-// int compare(size_type pos1, size_type n1, const basic_string_view& str) const;
-// int compare(size_type pos1, size_type n1, const basic_string_view& str,
-//             size_type pos2, size_type n2) const;
-// int compare(const charT* s) const;
-// int compare(size_type pos1, size_type n1,
-//             const charT* s, size_type n2 = npos) const;
-
-// NB compare should be thought of as a lexographical compare, ie how
-// things would be sorted in a dictionary.
-
-#include <string_view>
-#include <testsuite_hooks.h>
-
-enum want_value {lt=0, z=1, gt=2};
-
-int
-test_value(int result, want_value expected);
-
-int
-test_value(int result, want_value expected)
-{
-  bool pass = false;
-
-  switch (expected) {
-  case lt:
-    if (result < 0)
-      pass = true;
-    break;
-  case z:
-    if (!result)
-      pass = true;
-    break;
-  case gt:
-    if (result > 0)
-      pass = true;
-    break;
-  default:
-    pass = false; //should not get here
-  }
-
-  VERIFY(pass);
-  return 0;
-}
-
-
-int
-test01()
-{
-  using std::wstring_view;
-
-  wstring_view 	str_0(L"costa rica");
-  wstring_view 	str_1(L"costa marbella");
-  wstring_view 	str_2;
-
-  //sanity check
-  test_value(wcscmp(L"costa marbella", L"costa rica"), lt);
-  test_value(wcscmp(L"costa rica", L"costa rica"), z);
-  test_value(wcscmp(str_1.data(), str_0.data()), lt);
-  test_value(wcscmp(str_0.data(), str_1.data()), gt);
-  test_value(wcsncmp(str_1.data(), str_0.data(), 6), z);
-  test_value(wcsncmp(str_1.data(), str_0.data(), 14), lt);
-  test_value(wmemcmp(str_1.data(), str_0.data(), 6), z);
-  test_value(wmemcmp(str_1.data(), str_0.data(), 14), lt);
-  test_value(wmemcmp(L"costa marbella", L"costa rica", 14), lt);
-
-  // int compare(const basic_string_view& str) const;
-  test_value(str_0.compare(str_1), gt); //because r>m
-  test_value(str_1.compare(str_0), lt); //because m<r
-  str_2 = str_0;
-  test_value(str_2.compare(str_0), z);
-  str_2 = L"cost";
-  test_value(str_2.compare(str_0), lt);
-  str_2 = L"costa ricans";
-  test_value(str_2.compare(str_0), gt);
-
-  // int compare(size_type pos1, size_type n1, const basic_string_view& str) const;
-  test_value(str_1.compare(0, 6, str_0), lt);
-  str_2 = L"cost";
-  test_value(str_1.compare(0, 4, str_2), z);
-  test_value(str_1.compare(0, 5, str_2), gt);
-
-  // int compare(size_type pos1, size_type n1, const basic_string_view& str,
-  //		 size_type pos2, size_type n2) const;
-  test_value(str_1.compare(0, 6, str_0, 0, 6), z);
-  test_value(str_1.compare(0, 7, str_0, 0, 7), lt);
-  test_value(str_0.compare(0, 7, str_1, 0, 7), gt);
-
-  // int compare(const charT* s) const;
-  test_value(str_0.compare(L"costa marbella"), gt);
-  test_value(str_1.compare(L"costa rica"), lt);
-  str_2 = str_0;
-  test_value(str_2.compare(L"costa rica"), z);
-  test_value(str_2.compare(L"cost"), gt);
-  test_value(str_2.compare(L"costa ricans"), lt);
-
-  // int compare(size_type pos, size_type n1, const charT* str,
-  //             size_type n2 = npos) const;
-  test_value(str_1.compare(0, 6, L"costa rica", 0, 6), z);
-  test_value(str_1.compare(0, 7, L"costa rica", 0, 7), lt);
-  test_value(str_0.compare(0, 7, L"costa marbella", 0, 7), gt);
-
-  return 0;
-}
-
-
-int
-main()
-{
-  test01();
-
-  return 0;
-}
diff --git a/gdb/unittests/basic_string_view/operations/compare/wchar_t/13650.cc b/gdb/unittests/basic_string_view/operations/compare/wchar_t/13650.cc
deleted file mode 100644
index 86df7d0a377..00000000000
--- a/gdb/unittests/basic_string_view/operations/compare/wchar_t/13650.cc
+++ /dev/null
@@ -1,49 +0,0 @@
-// { dg-options "-std=gnu++17" }
-
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-// basic_string_view::compare [lib.string_view::compare]
-
-#include <string_view>
-#include <testsuite_hooks.h>
-
-// libstdc++/13650
-void
-test01()
-{
-  using std::wstring_view;
-
-  const wchar_t lit_01[] = { L'w', L'e', L'\0', L'r', L'd' };
-  const wchar_t lit_02[] = { L'w', L'e', L'i', L'\0', L'd' };
-
-  const wchar_t lit_ref_a[] = { L'w', L'e', L'\0', L'q', L'd' };
-  const wstring_view str_a(lit_ref_a, 5);
-  VERIFY( str_a.compare(0, 5, lit_01, 5) < 0 );
-
-  const wchar_t lit_ref_b[] = { L'w', L'e', L'i' };
-  const wstring_view str_b(lit_ref_b, 3);
-  VERIFY( str_b.compare(0, 3, lit_02, 5) < 0 );
-}
-
-int
-main()
-{
-  test01();
-
-  return 0;
-}
diff --git a/gdb/unittests/basic_string_view/operations/compare/wchar_t/2.cc b/gdb/unittests/basic_string_view/operations/compare/wchar_t/2.cc
deleted file mode 100644
index c6b6eb91d42..00000000000
--- a/gdb/unittests/basic_string_view/operations/compare/wchar_t/2.cc
+++ /dev/null
@@ -1,30 +0,0 @@
-// Copyright (C) 2017-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-// { dg-options "-std=gnu++17" }
-// { dg-do compile { target c++17 } }
-
-#include <string_view>
-
-constexpr wchar_t c1[] = L"one";
-constexpr wchar_t c2[] = L"two";
-
-constexpr std::wstring_view s1{c1};
-constexpr std::wstring_view s2{c2};
-
-constexpr int n1 = s1.compare(s1);
-constexpr int n2 = s1.compare(s2);
diff --git a/gdb/unittests/basic_string_view/operations/copy/char/1.cc b/gdb/unittests/basic_string_view/operations/copy/char/1.cc
deleted file mode 100644
index f124f3aab46..00000000000
--- a/gdb/unittests/basic_string_view/operations/copy/char/1.cc
+++ /dev/null
@@ -1,46 +0,0 @@
-// { dg-options "-std=gnu++17" }
-
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-// basic_string_view::copy
-
-namespace operations_copy_1 {
-
-static void
-test01 ()
-{
-  typedef gdb::string_view::size_type csize_type;
-
-  const char str_lit01[] = "123456789A";
-  const gdb::string_view str01(str_lit01);
-  char buffer[4] = { 0 };
-
-  csize_type len = str01.copy(buffer, sizeof(buffer), 8);
-  VERIFY( 2 == len );
-  VERIFY( '9' == buffer[0] );
-}
-
-static int
-main ()
-{ 
-  test01();
-
-  return 0;
-}
-
-} // namespace operations_copy_1
diff --git a/gdb/unittests/basic_string_view/operations/copy/wchar_t/1.cc b/gdb/unittests/basic_string_view/operations/copy/wchar_t/1.cc
deleted file mode 100644
index 56a48841ca7..00000000000
--- a/gdb/unittests/basic_string_view/operations/copy/wchar_t/1.cc
+++ /dev/null
@@ -1,46 +0,0 @@
-// { dg-options "-std=gnu++17" }
-
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-// basic_string_view::copy
-
-#include <string_view>
-#include <testsuite_hooks.h>
-
-void
-test01()
-{
-  typedef std::wstring_view::size_type csize_type;
-  csize_type csz01;
-
-  const wchar_t str_lit01[] = L"123456789A";
-  const std::wstring_view str01(str_lit01);
-  wchar_t buffer[4] = { 0 };
-
-  csize_type len = str01.copy(buffer, sizeof(buffer), 8);
-  VERIFY( 2 == len );
-  VERIFY( L'9' == buffer[0] );
-}
-
-int
-main()
-{ 
-  test01();
-
-  return 0;
-}
diff --git a/gdb/unittests/basic_string_view/operations/data/char/1.cc b/gdb/unittests/basic_string_view/operations/data/char/1.cc
deleted file mode 100644
index 0309f5f555d..00000000000
--- a/gdb/unittests/basic_string_view/operations/data/char/1.cc
+++ /dev/null
@@ -1,44 +0,0 @@
-// { dg-options "-std=gnu++17" }
-
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-// string_view operations
-
-namespace operations_data_1 {
-
-static int
-test01 ()
-{
-  gdb::string_view empty;
-
-  VERIFY( empty.size() == 0 );
-  const gdb::string_view::value_type* p = empty.data();
-  VERIFY( p == nullptr );
-
-  return 0;
-}
-
-static int
-main ()
-{ 
-  test01();
-
-  return 0;
-}
-
-} // namespace operations_data_1
diff --git a/gdb/unittests/basic_string_view/operations/data/wchar_t/1.cc b/gdb/unittests/basic_string_view/operations/data/wchar_t/1.cc
deleted file mode 100644
index 31c58b6a3c2..00000000000
--- a/gdb/unittests/basic_string_view/operations/data/wchar_t/1.cc
+++ /dev/null
@@ -1,43 +0,0 @@
-// { dg-options "-std=gnu++17" }
-
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-// string_view operations
-
-#include <string_view>
-#include <testsuite_hooks.h>
-
-int
-test01()
-{
-  std::wstring_view empty;
-
-  VERIFY( empty.size() == 0 );
-  const std::wstring_view::value_type* p = empty.data();
-  VERIFY( p == nullptr );
-
-  return 0;
-}
-
-int
-main()
-{ 
-  test01();
-
-  return 0;
-}
diff --git a/gdb/unittests/basic_string_view/operations/find/char/1.cc b/gdb/unittests/basic_string_view/operations/find/char/1.cc
deleted file mode 100644
index 79706e05aca..00000000000
--- a/gdb/unittests/basic_string_view/operations/find/char/1.cc
+++ /dev/null
@@ -1,168 +0,0 @@
-// { dg-options "-std=gnu++17" }
-
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-// basic_string_view find
-
-namespace operations_find_1 {
-
-static void
-test01 ()
-{
-  typedef gdb::string_view::size_type csize_type;
-  typedef gdb::string_view::const_reference cref;
-  typedef gdb::string_view::reference ref;
-  csize_type npos = gdb::string_view::npos;
-  csize_type csz01, csz02;
-
-  const char str_lit01[] = "mave";
-  const gdb::string_view str01("mavericks, santa cruz");
-  gdb::string_view str02(str_lit01);
-  gdb::string_view str03("s, s");
-  gdb::string_view str04;
-
-  // size_type find(const string_view&, size_type pos = 0) const;
-  csz01 = str01.find(str01);
-  VERIFY( csz01 == 0 );
-  csz01 = str01.find(str01, 4);
-  VERIFY( csz01 == npos );
-  csz01 = str01.find(str02, 0);
-  VERIFY( csz01 == 0 );
-  csz01 = str01.find(str02, 3);
-  VERIFY( csz01 == npos );
-  csz01 = str01.find(str03, 0);
-  VERIFY( csz01 == 8 );
-  csz01 = str01.find(str03, 3);
-  VERIFY( csz01 == 8 );
-  csz01 = str01.find(str03, 12);
-  VERIFY( csz01 == npos );
-
-  // An empty string_view consists of no characters
-  // therefore it should be found at every point in a string_view,
-  // except beyond the end
-  csz01 = str01.find(str04, 0);
-  VERIFY( csz01 == 0 );
-  csz01 = str01.find(str04, 5);
-  VERIFY( csz01 == 5 );
-  csz01 = str01.find(str04, str01.size());
-  VERIFY( csz01 == str01.size() );
-  csz01 = str01.find(str04, str01.size()+1);
-  VERIFY( csz01 == npos );
-
-  // size_type find(const char* s, size_type pos, size_type n) const;
-  csz01 = str01.find(str_lit01, 0, 3);
-  VERIFY( csz01 == 0 );
-  csz01 = str01.find(str_lit01, 3, 0);
-  VERIFY( csz01 == 3 );
-
-  // size_type find(const char* s, size_type pos = 0) const;
-  csz01 = str01.find(str_lit01);
-  VERIFY( csz01 == 0 );
-  csz01 = str01.find(str_lit01, 3);
-  VERIFY( csz01 == npos );
-
-  // size_type find(char c, size_type pos = 0) const;
-  csz01 = str01.find('z');
-  csz02 = str01.size() - 1;
-  VERIFY( csz01 == csz02 );
-  csz01 = str01.find('/');
-  VERIFY( csz01 == npos );
-}
-
-#ifndef GDB_STRING_VIEW
-constexpr bool
-test02()
-{
-  typedef std::string_view::size_type csize_type;
-  typedef std::string_view::const_reference cref;
-  typedef std::string_view::reference ref;
-  csize_type npos = std::string_view::npos;
-  csize_type csz01 = 0, csz02 = 0;
-
-  const char str_lit01[] = "mave";
-  const std::string_view str01("mavericks, santa cruz");
-  std::string_view str02(str_lit01);
-  std::string_view str03("s, s");
-  std::string_view str04;
-
-#undef VERIFY
-#define VERIFY(x) if(!(x)) return false
-
-  // size_type find(const string_view&, size_type pos = 0) const;
-  csz01 = str01.find(str01);
-  VERIFY( csz01 == 0 );
-  csz01 = str01.find(str01, 4);
-  VERIFY( csz01 == npos );
-  csz01 = str01.find(str02, 0);
-  VERIFY( csz01 == 0 );
-  csz01 = str01.find(str02, 3);
-  VERIFY( csz01 == npos );
-  csz01 = str01.find(str03, 0);
-  VERIFY( csz01 == 8 );
-  csz01 = str01.find(str03, 3);
-  VERIFY( csz01 == 8 );
-  csz01 = str01.find(str03, 12);
-  VERIFY( csz01 == npos );
-
-  // An empty string_view consists of no characters
-  // therefore it should be found at every point in a string_view,
-  // except beyond the end
-  csz01 = str01.find(str04, 0);
-  VERIFY( csz01 == 0 );
-  csz01 = str01.find(str04, 5);
-  VERIFY( csz01 == 5 );
-  csz01 = str01.find(str04, str01.size());
-  VERIFY( csz01 == str01.size() );
-  csz01 = str01.find(str04, str01.size()+1);
-  VERIFY( csz01 == npos );
-
-  // size_type find(const char* s, size_type pos, size_type n) const;
-  csz01 = str01.find(str_lit01, 0, 3);
-  VERIFY( csz01 == 0 );
-  csz01 = str01.find(str_lit01, 3, 0);
-  VERIFY( csz01 == 3 );
-
-  // size_type find(const char* s, size_type pos = 0) const;
-  csz01 = str01.find(str_lit01);
-  VERIFY( csz01 == 0 );
-  csz01 = str01.find(str_lit01, 3);
-  VERIFY( csz01 == npos );
-
-  // size_type find(char c, size_type pos = 0) const;
-  csz01 = str01.find('z');
-  csz02 = str01.size() - 1;
-  VERIFY( csz01 == csz02 );
-  csz01 = str01.find('/');
-  VERIFY( csz01 == npos );
-
-  return true;
-}
-#endif
-
-static int
-main ()
-{
-  test01();
-#ifndef GDB_STRING_VIEW
-  static_assert( test02() );
-#endif
-
-  return 0;
-}
-
-} // namespace operations_find_1
diff --git a/gdb/unittests/basic_string_view/operations/find/char/2.cc b/gdb/unittests/basic_string_view/operations/find/char/2.cc
deleted file mode 100644
index c6bb97f10a6..00000000000
--- a/gdb/unittests/basic_string_view/operations/find/char/2.cc
+++ /dev/null
@@ -1,166 +0,0 @@
-// { dg-options "-std=gnu++17" }
-
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-// basic_string_view find_first_of
-
-namespace operations_find_2 {
-
-static void
-test02 ()
-{
-  typedef gdb::string_view::size_type csize_type;
-  csize_type npos = gdb::string_view::npos;
-  csize_type csz01, csz02;
-
-  const char str_lit01[] = "mave";
-  const gdb::string_view str01("mavericks, santa cruz");
-  gdb::string_view str02(str_lit01);
-  gdb::string_view str03("s, s");
-  gdb::string_view str04;
-
-  // size_type find_first_of(const string_view&, size_type pos = 0) const;
-  gdb::string_view str05("xena rulez");
-  csz01 = str01.find_first_of(str01);
-  VERIFY( csz01 == 0 );
-  csz01 = str01.find_first_of(str01, 4);
-  VERIFY( csz01 == 4 );
-  csz01 = str01.find_first_of(str02, 0);
-  VERIFY( csz01 == 0 );
-  csz01 = str01.find_first_of(str02, 3);
-  VERIFY( csz01 == 3 );
-  csz01 = str01.find_first_of(str03, 0);
-  VERIFY( csz01 == 8 );
-  csz01 = str01.find_first_of(str03, 3);
-  VERIFY( csz01 == 8 );
-  csz01 = str01.find_first_of(str03, 12);
-  VERIFY( csz01 == 16 );
-  csz01 = str01.find_first_of(str05, 0);
-  VERIFY( csz01 == 1 );
-  csz01 = str01.find_first_of(str05, 4);
-  VERIFY( csz01 == 4 );
-
-  // An empty string_view consists of no characters
-  // therefore it should be found at every point in a string_view,
-  // except beyond the end
-  // However, str1.find_first_of(str2,pos) finds the first character in
-  // str1 (starting at pos) that exists in str2, which is none for empty str2
-  csz01 = str01.find_first_of(str04, 0);
-  VERIFY( csz01 == npos );
-  csz01 = str01.find_first_of(str04, 5);
-  VERIFY( csz01 == npos );
-
-  // size_type find_first_of(const char* s, size_type pos, size_type n) const;
-  csz01 = str01.find_first_of(str_lit01, 0, 3);
-  VERIFY( csz01 == 0 );
-  csz01 = str01.find_first_of(str_lit01, 3, 0);
-  VERIFY( csz01 == npos );
-
-  // size_type find_first_of(const char* s, size_type pos = 0) const;
-  csz01 = str01.find_first_of(str_lit01);
-  VERIFY( csz01 == 0 );
-  csz01 = str01.find_first_of(str_lit01, 3);
-  VERIFY( csz01 == 3 );
-
-  // size_type find_first_of(char c, size_type pos = 0) const;
-  csz01 = str01.find_first_of('z');
-  csz02 = str01.size() - 1;
-  VERIFY( csz01 == csz02 );
-}
-
-#ifndef GDB_STRING_VIEW
-constexpr bool
-test03()
-{
-  typedef std::string_view::size_type csize_type;
-  csize_type npos = std::string_view::npos;
-  csize_type csz01 = 0, csz02 = 0;
-
-  const char str_lit01[] = "mave";
-  const std::string_view str01("mavericks, santa cruz");
-  std::string_view str02(str_lit01);
-  std::string_view str03("s, s");
-  std::string_view str04;
-
-#undef VERIFY
-#define VERIFY(x) if(!(x)) return false
-
-  // size_type find_first_of(const string_view&, size_type pos = 0) const;
-  std::string_view str05("xena rulez");
-  csz01 = str01.find_first_of(str01);
-  VERIFY( csz01 == 0 );
-  csz01 = str01.find_first_of(str01, 4);
-  VERIFY( csz01 == 4 );
-  csz01 = str01.find_first_of(str02, 0);
-  VERIFY( csz01 == 0 );
-  csz01 = str01.find_first_of(str02, 3);
-  VERIFY( csz01 == 3 );
-  csz01 = str01.find_first_of(str03, 0);
-  VERIFY( csz01 == 8 );
-  csz01 = str01.find_first_of(str03, 3);
-  VERIFY( csz01 == 8 );
-  csz01 = str01.find_first_of(str03, 12);
-  VERIFY( csz01 == 16 );
-  csz01 = str01.find_first_of(str05, 0);
-  VERIFY( csz01 == 1 );
-  csz01 = str01.find_first_of(str05, 4);
-  VERIFY( csz01 == 4 );
-
-  // An empty string_view consists of no characters
-  // therefore it should be found at every point in a string_view,
-  // except beyond the end
-  // However, str1.find_first_of(str2,pos) finds the first character in
-  // str1 (starting at pos) that exists in str2, which is none for empty str2
-  csz01 = str01.find_first_of(str04, 0);
-  VERIFY( csz01 == npos );
-  csz01 = str01.find_first_of(str04, 5);
-  VERIFY( csz01 == npos );
-
-  // size_type find_first_of(const char* s, size_type pos, size_type n) const;
-  csz01 = str01.find_first_of(str_lit01, 0, 3);
-  VERIFY( csz01 == 0 );
-  csz01 = str01.find_first_of(str_lit01, 3, 0);
-  VERIFY( csz01 == npos );
-
-  // size_type find_first_of(const char* s, size_type pos = 0) const;
-  csz01 = str01.find_first_of(str_lit01);
-  VERIFY( csz01 == 0 );
-  csz01 = str01.find_first_of(str_lit01, 3);
-  VERIFY( csz01 == 3 );
-
-  // size_type find_first_of(char c, size_type pos = 0) const;
-  csz01 = str01.find_first_of('z');
-  csz02 = str01.size() - 1;
-  VERIFY( csz01 == csz02 );
-
-  return true;
-}
-#endif
-
-static int
-main ()
-{
-  test02();
-#ifndef GDB_STRING_VIEW
-  static_assert( test03() );
-#endif
-
-  return 0;
-}
-
-} // namespace operations_find_2 {
diff --git a/gdb/unittests/basic_string_view/operations/find/char/3.cc b/gdb/unittests/basic_string_view/operations/find/char/3.cc
deleted file mode 100644
index 078fda35d45..00000000000
--- a/gdb/unittests/basic_string_view/operations/find/char/3.cc
+++ /dev/null
@@ -1,166 +0,0 @@
-// { dg-options "-std=gnu++17" }
-
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-// basic_string_view find_first_not_of
-
-namespace operations_find_3 {
-
-static void
-test03 ()
-{
-  typedef gdb::string_view::size_type csize_type;
-  csize_type npos = gdb::string_view::npos;
-  csize_type csz01;
-
-  const gdb::string_view str01("Bob Rock, per me");
-  const char str_lit01[] = "Bob Rock";
-  gdb::string_view str02("ovvero Trivi");
-  gdb::string_view str03(str_lit01);
-  gdb::string_view str04;
-
-  // size_type find_first_not_of(const string_view&, size_type pos = 0) const;
-  csz01 = str01.find_first_not_of(str01);
-  VERIFY( csz01 == npos );
-  csz01 = str01.find_first_not_of(str02, 0);
-  VERIFY( csz01 == 0 );
-  csz01 = str01.find_first_not_of(str02, 10);
-  VERIFY( csz01 == 10 );
-  csz01 = str01.find_first_not_of(str02, 12);
-  VERIFY( csz01 == 14 );
-  csz01 = str01.find_first_not_of(str03, 0);
-  VERIFY( csz01 == 8 );
-  csz01 = str01.find_first_not_of(str03, 15);
-  VERIFY( csz01 == 15 );
-  csz01 = str01.find_first_not_of(str03, 16);
-  VERIFY( csz01 == npos );
-  csz01 = str01.find_first_not_of(str04, 0);
-  VERIFY( csz01 == 0 );
-  csz01 = str01.find_first_not_of(str04, 12);
-  VERIFY( csz01 == 12 );
-  csz01 = str03.find_first_not_of(str01, 0);
-  VERIFY( csz01 == npos );
-  csz01 = str04.find_first_not_of(str02, 0);
-  VERIFY( csz01 == npos );
-
-  // size_type find_first_not_of(const char* s, size_type pos, size_type n) const;
-  csz01 = str01.find_first_not_of(str_lit01, 0, 0);
-  VERIFY( csz01 == 0 );
-  csz01 = str01.find_first_not_of(str_lit01, 0, 8);
-  VERIFY( csz01 == 8 );
-  csz01 = str01.find_first_not_of(str_lit01, 10, 0);
-  VERIFY( csz01 == 10 );
-
-  // size_type find_first_not_of(const char* s, size_type pos = 0) const;
-  csz01 = str01.find_first_not_of(str_lit01);
-  VERIFY( csz01 == 8 );
-  csz01 = str02.find_first_not_of(str_lit01, 2);
-  VERIFY( csz01 == 2 );
-
-  // size_type find_first_not_of(char c, size_type pos = 0) const;
-  csz01 = str01.find_first_not_of('B');
-  VERIFY( csz01 == 1 );
-  csz01 = str01.find_first_not_of('o', 1);
-  VERIFY( csz01 == 2 );
-  csz01 = str02.find_first_not_of('z');
-  VERIFY( csz01 == 0 );
-  csz01 = str04.find_first_not_of('S');
-  VERIFY( csz01 == npos );
-}
-
-#ifndef GDB_STRING_VIEW
-constexpr bool
-test04()
-{
-  typedef std::string_view::size_type csize_type;
-  csize_type npos = std::string_view::npos;
-  csize_type csz01 = 0;
-
-  const std::string_view str01("Bob Rock, per me");
-  const char str_lit01[] = "Bob Rock";
-  std::string_view str02("ovvero Trivi");
-  std::string_view str03(str_lit01);
-  std::string_view str04;
-
-#undef VERIFY
-#define VERIFY(x) if(!(x)) return false
-
-  // size_type find_first_not_of(const string_view&, size_type pos = 0) const;
-  csz01 = str01.find_first_not_of(str01);
-  VERIFY( csz01 == npos );
-  csz01 = str01.find_first_not_of(str02, 0);
-  VERIFY( csz01 == 0 );
-  csz01 = str01.find_first_not_of(str02, 10);
-  VERIFY( csz01 == 10 );
-  csz01 = str01.find_first_not_of(str02, 12);
-  VERIFY( csz01 == 14 );
-  csz01 = str01.find_first_not_of(str03, 0);
-  VERIFY( csz01 == 8 );
-  csz01 = str01.find_first_not_of(str03, 15);
-  VERIFY( csz01 == 15 );
-  csz01 = str01.find_first_not_of(str03, 16);
-  VERIFY( csz01 == npos );
-  csz01 = str01.find_first_not_of(str04, 0);
-  VERIFY( csz01 == 0 );
-  csz01 = str01.find_first_not_of(str04, 12);
-  VERIFY( csz01 == 12 );
-  csz01 = str03.find_first_not_of(str01, 0);
-  VERIFY( csz01 == npos );
-  csz01 = str04.find_first_not_of(str02, 0);
-  VERIFY( csz01 == npos );
-
-  // size_type find_first_not_of(const char* s, size_type pos, size_type n) const;
-  csz01 = str01.find_first_not_of(str_lit01, 0, 0);
-  VERIFY( csz01 == 0 );
-  csz01 = str01.find_first_not_of(str_lit01, 0, 8);
-  VERIFY( csz01 == 8 );
-  csz01 = str01.find_first_not_of(str_lit01, 10, 0);
-  VERIFY( csz01 == 10 );
-
-  // size_type find_first_not_of(const char* s, size_type pos = 0) const;
-  csz01 = str01.find_first_not_of(str_lit01);
-  VERIFY( csz01 == 8 );
-  csz01 = str02.find_first_not_of(str_lit01, 2);
-  VERIFY( csz01 == 2 );
-
-  // size_type find_first_not_of(char c, size_type pos = 0) const;
-  csz01 = str01.find_first_not_of('B');
-  VERIFY( csz01 == 1 );
-  csz01 = str01.find_first_not_of('o', 1);
-  VERIFY( csz01 == 2 );
-  csz01 = str02.find_first_not_of('z');
-  VERIFY( csz01 == 0 );
-  csz01 = str04.find_first_not_of('S');
-  VERIFY( csz01 == npos );
-
-  return true;
-}
-#endif
-
-static int
-main ()
-{
-  test03();
-#ifndef GDB_STRING_VIEW
-  static_assert( test04() );
-#endif
-
-  return 0;
-}
-
-} // namespace operations_find_3
diff --git a/gdb/unittests/basic_string_view/operations/find/char/4.cc b/gdb/unittests/basic_string_view/operations/find/char/4.cc
deleted file mode 100644
index 9e19c01030d..00000000000
--- a/gdb/unittests/basic_string_view/operations/find/char/4.cc
+++ /dev/null
@@ -1,45 +0,0 @@
-// { dg-options "-std=gnu++17" }
-
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-// basic_string_view find
-
-namespace operations_find_4 {
-
-// libstdc++/31401
-static void
-test01()
-{
-  typedef gdb::string_view::size_type csize_type;
-  csize_type npos = gdb::string_view::npos;
-
-  gdb::string_view use = "anu";
-  csize_type pos1 = use.find("a", npos);
-
-  VERIFY( pos1 == npos );
-}
-
-static int
-main ()
-{
-  test01();
-
-  return 0;
-}
-
-} // namespace operations_find_4
diff --git a/gdb/unittests/basic_string_view/operations/find/wchar_t/1.cc b/gdb/unittests/basic_string_view/operations/find/wchar_t/1.cc
deleted file mode 100644
index 08e9e7249c8..00000000000
--- a/gdb/unittests/basic_string_view/operations/find/wchar_t/1.cc
+++ /dev/null
@@ -1,163 +0,0 @@
-// { dg-options "-std=gnu++17" }
-
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-// basic_string_view find
-
-#include <string_view>
-#include <testsuite_hooks.h>
-
-void
-test01()
-{
-  typedef std::wstring_view::size_type csize_type;
-  typedef std::wstring_view::const_reference cref;
-  typedef std::wstring_view::reference ref;
-  csize_type npos = std::wstring_view::npos;
-  csize_type csz01, csz02;
-
-  const wchar_t str_lit01[] = L"mave";
-  const std::wstring_view str01(L"mavericks, santa cruz");
-  std::wstring_view str02(str_lit01);
-  std::wstring_view str03(L"s, s");
-  std::wstring_view str04;
-
-  // size_type find(const wstring_view&, size_type pos = 0) const;
-  csz01 = str01.find(str01);
-  VERIFY( csz01 == 0 );
-  csz01 = str01.find(str01, 4);
-  VERIFY( csz01 == npos );
-  csz01 = str01.find(str02, 0);
-  VERIFY( csz01 == 0 );
-  csz01 = str01.find(str02, 3);
-  VERIFY( csz01 == npos );
-  csz01 = str01.find(str03, 0);
-  VERIFY( csz01 == 8 );
-  csz01 = str01.find(str03, 3);
-  VERIFY( csz01 == 8 );
-  csz01 = str01.find(str03, 12);
-  VERIFY( csz01 == npos );
-
-  // An empty string_view consists of no characters
-  // therefore it should be found at every point in a string_view,
-  // except beyond the end
-  csz01 = str01.find(str04, 0);
-  VERIFY( csz01 == 0 );
-  csz01 = str01.find(str04, 5);
-  VERIFY( csz01 == 5 );
-  csz01 = str01.find(str04, str01.size());
-  VERIFY( csz01 == str01.size() );
-  csz01 = str01.find(str04, str01.size()+1);
-  VERIFY( csz01 == npos );
-
-  // size_type find(const wchar_t* s, size_type pos, size_type n) const;
-  csz01 = str01.find(str_lit01, 0, 3);
-  VERIFY( csz01 == 0 );
-  csz01 = str01.find(str_lit01, 3, 0);
-  VERIFY( csz01 == 3 );
-
-  // size_type find(const wchar_t* s, size_type pos = 0) const;
-  csz01 = str01.find(str_lit01);
-  VERIFY( csz01 == 0 );
-  csz01 = str01.find(str_lit01, 3);
-  VERIFY( csz01 == npos );
-
-  // size_type find(wchar_t c, size_type pos = 0) const;
-  csz01 = str01.find(L'z');
-  csz02 = str01.size() - 1;
-  VERIFY( csz01 == csz02 );
-  csz01 = str01.find(L'/');
-  VERIFY( csz01 == npos );
-}
-
-constexpr bool
-test02()
-{
-  typedef std::wstring_view::size_type csize_type;
-  typedef std::wstring_view::const_reference cref;
-  typedef std::wstring_view::reference ref;
-  csize_type npos = std::wstring_view::npos;
-  csize_type csz01 = 0, csz02 = 0;
-
-  const wchar_t str_lit01[] = L"mave";
-  const std::wstring_view str01(L"mavericks, santa cruz");
-  std::wstring_view str02(str_lit01);
-  std::wstring_view str03(L"s, s");
-  std::wstring_view str04;
-
-#undef VERIFY
-#define VERIFY(x) if(!(x)) return false
-
-  // size_type find(const wstring_view&, size_type pos = 0) const;
-  csz01 = str01.find(str01);
-  VERIFY( csz01 == 0 );
-  csz01 = str01.find(str01, 4);
-  VERIFY( csz01 == npos );
-  csz01 = str01.find(str02, 0);
-  VERIFY( csz01 == 0 );
-  csz01 = str01.find(str02, 3);
-  VERIFY( csz01 == npos );
-  csz01 = str01.find(str03, 0);
-  VERIFY( csz01 == 8 );
-  csz01 = str01.find(str03, 3);
-  VERIFY( csz01 == 8 );
-  csz01 = str01.find(str03, 12);
-  VERIFY( csz01 == npos );
-
-  // An empty string_view consists of no characters
-  // therefore it should be found at every point in a string_view,
-  // except beyond the end
-  csz01 = str01.find(str04, 0);
-  VERIFY( csz01 == 0 );
-  csz01 = str01.find(str04, 5);
-  VERIFY( csz01 == 5 );
-  csz01 = str01.find(str04, str01.size());
-  VERIFY( csz01 == str01.size() );
-  csz01 = str01.find(str04, str01.size()+1);
-  VERIFY( csz01 == npos );
-
-  // size_type find(const wchar_t* s, size_type pos, size_type n) const;
-  csz01 = str01.find(str_lit01, 0, 3);
-  VERIFY( csz01 == 0 );
-  csz01 = str01.find(str_lit01, 3, 0);
-  VERIFY( csz01 == 3 );
-
-  // size_type find(const wchar_t* s, size_type pos = 0) const;
-  csz01 = str01.find(str_lit01);
-  VERIFY( csz01 == 0 );
-  csz01 = str01.find(str_lit01, 3);
-  VERIFY( csz01 == npos );
-
-  // size_type find(wchar_t c, size_type pos = 0) const;
-  csz01 = str01.find(L'z');
-  csz02 = str01.size() - 1;
-  VERIFY( csz01 == csz02 );
-  csz01 = str01.find(L'/');
-  VERIFY( csz01 == npos );
-
-  return true;
-}
-
-int
-main()
-{
-  test01();
-  static_assert( test02() );
-
-  return 0;
-}
diff --git a/gdb/unittests/basic_string_view/operations/find/wchar_t/2.cc b/gdb/unittests/basic_string_view/operations/find/wchar_t/2.cc
deleted file mode 100644
index fa38fe8e79c..00000000000
--- a/gdb/unittests/basic_string_view/operations/find/wchar_t/2.cc
+++ /dev/null
@@ -1,161 +0,0 @@
-// { dg-options "-std=gnu++17" }
-
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-// basic_string_view find_first_of
-
-#include <string_view>
-#include <testsuite_hooks.h>
-
-void
-test02()
-{
-  typedef std::wstring_view::size_type csize_type;
-  csize_type npos = std::wstring_view::npos;
-  csize_type csz01, csz02;
-
-  const wchar_t str_lit01[] = L"mave";
-  const std::wstring_view str01(L"mavericks, santa cruz");
-  std::wstring_view str02(str_lit01);
-  std::wstring_view str03(L"s, s");
-  std::wstring_view str04;
-
-  // size_type find_first_of(const wstring_view&, size_type pos = 0) const;
-  std::wstring_view str05(L"xena rulez");
-  csz01 = str01.find_first_of(str01);
-  VERIFY( csz01 == 0 );
-  csz01 = str01.find_first_of(str01, 4);
-  VERIFY( csz01 == 4 );
-  csz01 = str01.find_first_of(str02, 0);
-  VERIFY( csz01 == 0 );
-  csz01 = str01.find_first_of(str02, 3);
-  VERIFY( csz01 == 3 );
-  csz01 = str01.find_first_of(str03, 0);
-  VERIFY( csz01 == 8 );
-  csz01 = str01.find_first_of(str03, 3);
-  VERIFY( csz01 == 8 );
-  csz01 = str01.find_first_of(str03, 12);
-  VERIFY( csz01 == 16 );
-  csz01 = str01.find_first_of(str05, 0);
-  VERIFY( csz01 == 1 );
-  csz01 = str01.find_first_of(str05, 4);
-  VERIFY( csz01 == 4 );
-
-  // An empty string_view consists of no characters
-  // therefore it should be found at every point in a string_view,
-  // except beyond the end
-  // However, str1.find_first_of(str2,pos) finds the first character in
-  // str1 (starting at pos) that exists in str2, which is none for empty str2
-  csz01 = str01.find_first_of(str04, 0);
-  VERIFY( csz01 == npos );
-  csz01 = str01.find_first_of(str04, 5);
-  VERIFY( csz01 == npos );
-
-  // size_type find_first_of(const wchar_t* s, size_type pos, size_type n) const;
-  csz01 = str01.find_first_of(str_lit01, 0, 3);
-  VERIFY( csz01 == 0 );
-  csz01 = str01.find_first_of(str_lit01, 3, 0);
-  VERIFY( csz01 == npos );
-
-  // size_type find_first_of(const wchar_t* s, size_type pos = 0) const;
-  csz01 = str01.find_first_of(str_lit01);
-  VERIFY( csz01 == 0 );
-  csz01 = str01.find_first_of(str_lit01, 3);
-  VERIFY( csz01 == 3 );
-
-  // size_type find_first_of(wchar_t c, size_type pos = 0) const;
-  csz01 = str01.find_first_of(L'z');
-  csz02 = str01.size() - 1;
-  VERIFY( csz01 == csz02 );
-}
-
-constexpr bool
-test04()
-{
-  typedef std::wstring_view::size_type csize_type;
-  csize_type npos = std::wstring_view::npos;
-  csize_type csz01 = 0, csz02 = 0;
-
-  const wchar_t str_lit01[] = L"mave";
-  const std::wstring_view str01(L"mavericks, santa cruz");
-  std::wstring_view str02(str_lit01);
-  std::wstring_view str03(L"s, s");
-  std::wstring_view str04;
-
-#undef VERIFY
-#define VERIFY(x) if(!(x)) return false
-
-  // size_type find_first_of(const wstring_view&, size_type pos = 0) const;
-  std::wstring_view str05(L"xena rulez");
-  csz01 = str01.find_first_of(str01);
-  VERIFY( csz01 == 0 );
-  csz01 = str01.find_first_of(str01, 4);
-  VERIFY( csz01 == 4 );
-  csz01 = str01.find_first_of(str02, 0);
-  VERIFY( csz01 == 0 );
-  csz01 = str01.find_first_of(str02, 3);
-  VERIFY( csz01 == 3 );
-  csz01 = str01.find_first_of(str03, 0);
-  VERIFY( csz01 == 8 );
-  csz01 = str01.find_first_of(str03, 3);
-  VERIFY( csz01 == 8 );
-  csz01 = str01.find_first_of(str03, 12);
-  VERIFY( csz01 == 16 );
-  csz01 = str01.find_first_of(str05, 0);
-  VERIFY( csz01 == 1 );
-  csz01 = str01.find_first_of(str05, 4);
-  VERIFY( csz01 == 4 );
-
-  // An empty string_view consists of no characters
-  // therefore it should be found at every point in a string_view,
-  // except beyond the end
-  // However, str1.find_first_of(str2,pos) finds the first character in
-  // str1 (starting at pos) that exists in str2, which is none for empty str2
-  csz01 = str01.find_first_of(str04, 0);
-  VERIFY( csz01 == npos );
-  csz01 = str01.find_first_of(str04, 5);
-  VERIFY( csz01 == npos );
-
-  // size_type find_first_of(const wchar_t* s, size_type pos, size_type n) const;
-  csz01 = str01.find_first_of(str_lit01, 0, 3);
-  VERIFY( csz01 == 0 );
-  csz01 = str01.find_first_of(str_lit01, 3, 0);
-  VERIFY( csz01 == npos );
-
-  // size_type find_first_of(const wchar_t* s, size_type pos = 0) const;
-  csz01 = str01.find_first_of(str_lit01);
-  VERIFY( csz01 == 0 );
-  csz01 = str01.find_first_of(str_lit01, 3);
-  VERIFY( csz01 == 3 );
-
-  // size_type find_first_of(wchar_t c, size_type pos = 0) const;
-  csz01 = str01.find_first_of(L'z');
-  csz02 = str01.size() - 1;
-  VERIFY( csz01 == csz02 );
-
-  return true;
-}
-
-int
-main()
-{
-  test02();
-  static_assert( test04() );
-
-  return 0;
-}
diff --git a/gdb/unittests/basic_string_view/operations/find/wchar_t/3.cc b/gdb/unittests/basic_string_view/operations/find/wchar_t/3.cc
deleted file mode 100644
index 93a238c3865..00000000000
--- a/gdb/unittests/basic_string_view/operations/find/wchar_t/3.cc
+++ /dev/null
@@ -1,161 +0,0 @@
-// { dg-options "-std=gnu++17" }
-
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-// basic_string_view find_first_not_of
-
-#include <string_view>
-#include <testsuite_hooks.h>
-
-void
-test03()
-{
-  typedef std::wstring_view::size_type csize_type;
-  csize_type npos = std::wstring_view::npos;
-  csize_type csz01;
-
-  const std::wstring_view str01(L"Bob Rock, per me");
-  const wchar_t str_lit01[] = L"Bob Rock";
-  std::wstring_view str02(L"ovvero Trivi");
-  std::wstring_view str03(str_lit01);
-  std::wstring_view str04;
-
-  // size_type find_first_not_of(const string_view&, size_type pos = 0) const;
-  csz01 = str01.find_first_not_of(str01);
-  VERIFY( csz01 == npos );
-  csz01 = str01.find_first_not_of(str02, 0);
-  VERIFY( csz01 == 0 );
-  csz01 = str01.find_first_not_of(str02, 10);
-  VERIFY( csz01 == 10 );
-  csz01 = str01.find_first_not_of(str02, 12);
-  VERIFY( csz01 == 14 );
-  csz01 = str01.find_first_not_of(str03, 0);
-  VERIFY( csz01 == 8 );
-  csz01 = str01.find_first_not_of(str03, 15);
-  VERIFY( csz01 == 15 );
-  csz01 = str01.find_first_not_of(str03, 16);
-  VERIFY( csz01 == npos );
-  csz01 = str01.find_first_not_of(str04, 0);
-  VERIFY( csz01 == 0 );
-  csz01 = str01.find_first_not_of(str04, 12);
-  VERIFY( csz01 == 12 );
-  csz01 = str03.find_first_not_of(str01, 0);
-  VERIFY( csz01 == npos );
-  csz01 = str04.find_first_not_of(str02, 0);
-  VERIFY( csz01 == npos );
-
-  // size_type find_first_not_of(const char* s, size_type pos, size_type n) const;
-  csz01 = str01.find_first_not_of(str_lit01, 0, 0);
-  VERIFY( csz01 == 0 );
-  csz01 = str01.find_first_not_of(str_lit01, 0, 8);
-  VERIFY( csz01 == 8 );
-  csz01 = str01.find_first_not_of(str_lit01, 10, 0);
-  VERIFY( csz01 == 10 );
-
-  // size_type find_first_not_of(const char* s, size_type pos = 0) const;
-  csz01 = str01.find_first_not_of(str_lit01);
-  VERIFY( csz01 == 8 );
-  csz01 = str02.find_first_not_of(str_lit01, 2);
-  VERIFY( csz01 == 2 );
-
-  // size_type find_first_not_of(char c, size_type pos = 0) const;
-  csz01 = str01.find_first_not_of(L'B');
-  VERIFY( csz01 == 1 );
-  csz01 = str01.find_first_not_of(L'o', 1);
-  VERIFY( csz01 == 2 );
-  csz01 = str02.find_first_not_of(L'z');
-  VERIFY( csz01 == 0 );
-  csz01 = str04.find_first_not_of(L'S');
-  VERIFY( csz01 == npos );
-}
-
-constexpr bool
-test04()
-{
-  typedef std::wstring_view::size_type csize_type;
-  csize_type npos = std::wstring_view::npos;
-  csize_type csz01 = 0;
-
-  const std::wstring_view str01(L"Bob Rock, per me");
-  const wchar_t str_lit01[] = L"Bob Rock";
-  std::wstring_view str02(L"ovvero Trivi");
-  std::wstring_view str03(str_lit01);
-  std::wstring_view str04;
-
-#undef VERIFY
-#define VERIFY(x) if(!(x)) return false
-
-  // size_type find_first_not_of(const string_view&, size_type pos = 0) const;
-  csz01 = str01.find_first_not_of(str01);
-  VERIFY( csz01 == npos );
-  csz01 = str01.find_first_not_of(str02, 0);
-  VERIFY( csz01 == 0 );
-  csz01 = str01.find_first_not_of(str02, 10);
-  VERIFY( csz01 == 10 );
-  csz01 = str01.find_first_not_of(str02, 12);
-  VERIFY( csz01 == 14 );
-  csz01 = str01.find_first_not_of(str03, 0);
-  VERIFY( csz01 == 8 );
-  csz01 = str01.find_first_not_of(str03, 15);
-  VERIFY( csz01 == 15 );
-  csz01 = str01.find_first_not_of(str03, 16);
-  VERIFY( csz01 == npos );
-  csz01 = str01.find_first_not_of(str04, 0);
-  VERIFY( csz01 == 0 );
-  csz01 = str01.find_first_not_of(str04, 12);
-  VERIFY( csz01 == 12 );
-  csz01 = str03.find_first_not_of(str01, 0);
-  VERIFY( csz01 == npos );
-  csz01 = str04.find_first_not_of(str02, 0);
-  VERIFY( csz01 == npos );
-
-  // size_type find_first_not_of(const char* s, size_type pos, size_type n) const;
-  csz01 = str01.find_first_not_of(str_lit01, 0, 0);
-  VERIFY( csz01 == 0 );
-  csz01 = str01.find_first_not_of(str_lit01, 0, 8);
-  VERIFY( csz01 == 8 );
-  csz01 = str01.find_first_not_of(str_lit01, 10, 0);
-  VERIFY( csz01 == 10 );
-
-  // size_type find_first_not_of(const char* s, size_type pos = 0) const;
-  csz01 = str01.find_first_not_of(str_lit01);
-  VERIFY( csz01 == 8 );
-  csz01 = str02.find_first_not_of(str_lit01, 2);
-  VERIFY( csz01 == 2 );
-
-  // size_type find_first_not_of(char c, size_type pos = 0) const;
-  csz01 = str01.find_first_not_of(L'B');
-  VERIFY( csz01 == 1 );
-  csz01 = str01.find_first_not_of(L'o', 1);
-  VERIFY( csz01 == 2 );
-  csz01 = str02.find_first_not_of(L'z');
-  VERIFY( csz01 == 0 );
-  csz01 = str04.find_first_not_of(L'S');
-  VERIFY( csz01 == npos );
-
-  return true;
-}
-
-int
-main()
-{
-  test03();
-  static_assert( test04() );
-
-  return 0;
-}
diff --git a/gdb/unittests/basic_string_view/operations/find/wchar_t/4.cc b/gdb/unittests/basic_string_view/operations/find/wchar_t/4.cc
deleted file mode 100644
index 7b484bd6b9b..00000000000
--- a/gdb/unittests/basic_string_view/operations/find/wchar_t/4.cc
+++ /dev/null
@@ -1,44 +0,0 @@
-// { dg-options "-std=gnu++17" }
-
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-// basic_string_view find
-
-#include <string_view>
-#include <testsuite_hooks.h>
-
-// libstdc++/31401
-void
-test01()
-{
-  typedef std::wstring_view::size_type csize_type;
-  csize_type npos = std::wstring_view::npos;
-
-  std::wstring_view use = L"anu";
-  csize_type pos1 = use.find(L"a", npos);
-
-  VERIFY( pos1 == npos );
-}
-
-int
-main()
-{
-  test01();
-
-  return 0;
-}
diff --git a/gdb/unittests/basic_string_view/operations/rfind/char/1.cc b/gdb/unittests/basic_string_view/operations/rfind/char/1.cc
deleted file mode 100644
index b764cd959ab..00000000000
--- a/gdb/unittests/basic_string_view/operations/rfind/char/1.cc
+++ /dev/null
@@ -1,95 +0,0 @@
-// { dg-options "-std=gnu++17" }
-
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-namespace operations_rfind_1 {
-
-// basic_string_view rfind
-
-static void
-test01 ()
-{
-  typedef gdb::string_view::size_type csize_type;
-  typedef gdb::string_view::const_reference cref;
-  typedef gdb::string_view::reference ref;
-  csize_type npos = gdb::string_view::npos;
-  csize_type csz01, csz02;
-
-  const char str_lit01[] = "mave";
-  const gdb::string_view str01("mavericks, santa cruz");
-  gdb::string_view str02(str_lit01);
-  gdb::string_view str03("s, s");
-  gdb::string_view str04;
-
-  // size_type rfind(const string_view&, size_type pos = 0) const;
-  csz01 = str01.rfind(str01);
-  VERIFY( csz01 == 0 );
-  csz01 = str01.rfind(str01, 4);
-  VERIFY( csz01 == 0 );
-  csz01 = str01.rfind(str02,3);
-  VERIFY( csz01 == 0 );
-  csz01 = str01.rfind(str02);
-  VERIFY( csz01 == 0 );
-  csz01 = str01.rfind(str03);
-  VERIFY( csz01 == 8 );
-  csz01 = str01.rfind(str03, 3);
-  VERIFY( csz01 == npos );
-  csz01 = str01.rfind(str03, 12);
-  VERIFY( csz01 == 8 );
-
-  // An empty string_view consists of no characters
-  // therefore it should be found at every point in a string_view,
-  // except beyond the end
-  csz01 = str01.rfind(str04, 0);
-  VERIFY( csz01 == 0 );
-  csz01 = str01.rfind(str04, 5);
-  VERIFY( csz01 == 5 );
-  csz01 = str01.rfind(str04, str01.size());
-  VERIFY( csz01 == str01.size() );
-  csz01 = str01.rfind(str04, str01.size()+1);
-  VERIFY( csz01 == str01.size() );
-
-  // size_type rfind(const char* s, size_type pos, size_type n) const;
-  csz01 = str01.rfind(str_lit01, 0, 3);
-  VERIFY( csz01 == 0 );
-  csz01 = str01.rfind(str_lit01, 3, 0);
-  VERIFY( csz01 == 3 );
-
-  // size_type rfind(const char* s, size_type pos = 0) const;
-  csz01 = str01.rfind(str_lit01);
-  VERIFY( csz01 == 0 );
-  csz01 = str01.rfind(str_lit01, 3);
-  VERIFY( csz01 == 0 );
-
-  // size_type rfind(char c, size_type pos = 0) const;
-  csz01 = str01.rfind('z');
-  csz02 = str01.size() - 1;
-  VERIFY( csz01 == csz02 );
-  csz01 = str01.rfind('/');
-  VERIFY( csz01 == npos );
-}
-
-static int
-main ()
-{
-  test01();
-
-  return 0;
-}
-
-} // namespace operations_rfind_1
diff --git a/gdb/unittests/basic_string_view/operations/rfind/char/2.cc b/gdb/unittests/basic_string_view/operations/rfind/char/2.cc
deleted file mode 100644
index 915a111fbcc..00000000000
--- a/gdb/unittests/basic_string_view/operations/rfind/char/2.cc
+++ /dev/null
@@ -1,53 +0,0 @@
-// { dg-options "-std=gnu++17" }
-
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-namespace operations_rfind_2 {
-
-// basic_string_view::find_last_of
-
-static void
-test02 ()
-{
-  gdb::string_view z("ab");
-  gdb::string_view::size_type pos;
-  pos = z.find_last_of("ab");
-  VERIFY( pos == 1 );
-  pos = z.find_last_of("Xa");
-  VERIFY( pos == 0 );
-  pos = z.find_last_of("Xb");
-  VERIFY( pos == 1 );
-  pos = z.find_last_of("XYZ");
-  VERIFY( pos == gdb::string_view::npos );
-  pos = z.find_last_of('a');
-  VERIFY( pos == 0 );
-  pos = z.find_last_of('b');
-  VERIFY( pos == 1 );
-  pos = z.find_last_of('X');
-  VERIFY( pos == gdb::string_view::npos );
-}
-
-static int
-main ()
-{
-  test02();
-
-  return 0;
-}
-
-} // namespace operations_rfind_2
diff --git a/gdb/unittests/basic_string_view/operations/rfind/char/3.cc b/gdb/unittests/basic_string_view/operations/rfind/char/3.cc
deleted file mode 100644
index a15debf97ec..00000000000
--- a/gdb/unittests/basic_string_view/operations/rfind/char/3.cc
+++ /dev/null
@@ -1,68 +0,0 @@
-// { dg-options "-std=gnu++17" }
-
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-namespace operations_rfind_3 {
-
-// basic_string_view::find_last_not_of
-
-static void
-test03 ()
-{
-  typedef gdb::string_view::size_type csize_type;
-  gdb::string_view::size_type pos;
-  csize_type npos = gdb::string_view::npos;
-
-  gdb::string_view x;
-  pos = x.find_last_not_of('X');
-  VERIFY( pos == npos );
-  pos = x.find_last_not_of("XYZ");
-  VERIFY( pos == npos );
-
-  gdb::string_view y("a");
-  pos = y.find_last_not_of('X');
-  VERIFY( pos == 0 );
-  pos = y.find_last_not_of('a');
-  VERIFY( pos == npos );
-  pos = y.find_last_not_of("XYZ");
-  VERIFY( pos == 0 );
-  pos = y.find_last_not_of("a");
-  VERIFY( pos == npos );
-
-  gdb::string_view z("ab");
-  pos = z.find_last_not_of('X');
-  VERIFY( pos == 1 );
-  pos = z.find_last_not_of("XYZ");
-  VERIFY( pos == 1 );
-  pos = z.find_last_not_of('b');
-  VERIFY( pos == 0 );
-  pos = z.find_last_not_of("Xb");
-  VERIFY( pos == 0 );
-  pos = z.find_last_not_of("Xa");
-  VERIFY( pos == 1 );
-}
-
-static int
-main ()
-{
-  test03();
-
-  return 0;
-}
-
-} // namespace operations_rfind_3
diff --git a/gdb/unittests/basic_string_view/operations/rfind/wchar_t/1.cc b/gdb/unittests/basic_string_view/operations/rfind/wchar_t/1.cc
deleted file mode 100644
index d5ad681eded..00000000000
--- a/gdb/unittests/basic_string_view/operations/rfind/wchar_t/1.cc
+++ /dev/null
@@ -1,94 +0,0 @@
-// { dg-options "-std=gnu++17" }
-
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-#include <string_view>
-#include <testsuite_hooks.h>
-
-// basic_string_view rfind
-
-void
-test01()
-{
-  typedef std::wstring_view::size_type csize_type;
-  typedef std::wstring_view::const_reference cref;
-  typedef std::wstring_view::reference ref;
-  csize_type npos = std::wstring_view::npos;
-  csize_type csz01, csz02;
-
-  const wchar_t str_lit01[] = L"mave";
-  const std::wstring_view str01(L"mavericks, santa cruz");
-  std::wstring_view str02(str_lit01);
-  std::wstring_view str03(L"s, s");
-  std::wstring_view str04;
-
-  // size_type rfind(const wstring_view&, size_type pos = 0) const;
-  csz01 = str01.rfind(str01);
-  VERIFY( csz01 == 0 );
-  csz01 = str01.rfind(str01, 4);
-  VERIFY( csz01 == 0 );
-  csz01 = str01.rfind(str02,3);
-  VERIFY( csz01 == 0 );
-  csz01 = str01.rfind(str02);
-  VERIFY( csz01 == 0 );
-  csz01 = str01.rfind(str03);
-  VERIFY( csz01 == 8 );
-  csz01 = str01.rfind(str03, 3);
-  VERIFY( csz01 == npos );
-  csz01 = str01.rfind(str03, 12);
-  VERIFY( csz01 == 8 );
-
-  // An empty string_view consists of no characters
-  // therefore it should be found at every point in a string_view,
-  // except beyond the end
-  csz01 = str01.rfind(str04, 0);
-  VERIFY( csz01 == 0 );
-  csz01 = str01.rfind(str04, 5);
-  VERIFY( csz01 == 5 );
-  csz01 = str01.rfind(str04, str01.size());
-  VERIFY( csz01 == str01.size() );
-  csz01 = str01.rfind(str04, str01.size()+1);
-  VERIFY( csz01 == str01.size() );
-
-  // size_type rfind(const wchar_t* s, size_type pos, size_type n) const;
-  csz01 = str01.rfind(str_lit01, 0, 3);
-  VERIFY( csz01 == 0 );
-  csz01 = str01.rfind(str_lit01, 3, 0);
-  VERIFY( csz01 == 3 );
-
-  // size_type rfind(const wchar_t* s, size_type pos = 0) const;
-  csz01 = str01.rfind(str_lit01);
-  VERIFY( csz01 == 0 );
-  csz01 = str01.rfind(str_lit01, 3);
-  VERIFY( csz01 == 0 );
-
-  // size_type rfind(wchar_t c, size_type pos = 0) const;
-  csz01 = str01.rfind(L'z');
-  csz02 = str01.size() - 1;
-  VERIFY( csz01 == csz02 );
-  csz01 = str01.rfind(L'/');
-  VERIFY( csz01 == npos );
-}
-
-int
-main()
-{
-  test01();
-
-  return 0;
-}
diff --git a/gdb/unittests/basic_string_view/operations/rfind/wchar_t/2.cc b/gdb/unittests/basic_string_view/operations/rfind/wchar_t/2.cc
deleted file mode 100644
index 6f3dc744ad7..00000000000
--- a/gdb/unittests/basic_string_view/operations/rfind/wchar_t/2.cc
+++ /dev/null
@@ -1,52 +0,0 @@
-// { dg-options "-std=gnu++17" }
-
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-#include <string_view>
-#include <testsuite_hooks.h>
-
-// basic_string_view::find_last_of
-
-void
-test02()
-{
-  std::wstring_view::size_type pos;
-  std::wstring_view z(L"ab");
-  pos = z.find_last_of(L"ab");
-  VERIFY( pos == 1 );
-  pos = z.find_last_of(L"Xa");
-  VERIFY( pos == 0 );
-  pos = z.find_last_of(L"Xb");
-  VERIFY( pos == 1 );
-  pos = z.find_last_of(L"XYZ");
-  VERIFY( pos == std::wstring_view::npos );
-  pos = z.find_last_of(L'a');
-  VERIFY( pos == 0 );
-  pos = z.find_last_of(L'b');
-  VERIFY( pos == 1 );
-  pos = z.find_last_of(L'X');
-  VERIFY( pos == std::wstring_view::npos );
-}
-
-int
-main()
-{
-  test02();
-
-  return 0;
-}
diff --git a/gdb/unittests/basic_string_view/operations/rfind/wchar_t/3.cc b/gdb/unittests/basic_string_view/operations/rfind/wchar_t/3.cc
deleted file mode 100644
index b67f8ec08af..00000000000
--- a/gdb/unittests/basic_string_view/operations/rfind/wchar_t/3.cc
+++ /dev/null
@@ -1,66 +0,0 @@
-// { dg-options "-std=gnu++17" }
-
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-#include <string_view>
-#include <testsuite_hooks.h>
-
-// basic_string_view::find_last_not_of
-
-void
-test03()
-{
-  typedef std::wstring_view::size_type csize_type;
-  std::wstring_view::size_type pos;
-  csize_type npos = std::wstring_view::npos;
-
-  std::wstring_view x;
-  pos = x.find_last_not_of(L'X');
-  VERIFY( pos == npos );
-  pos = x.find_last_not_of(L"XYZ");
-  VERIFY( pos == npos );
-
-  std::wstring_view y(L"a");
-  pos = y.find_last_not_of(L'X');
-  VERIFY( pos == 0 );
-  pos = y.find_last_not_of(L'a');
-  VERIFY( pos == npos );
-  pos = y.find_last_not_of(L"XYZ");
-  VERIFY( pos == 0 );
-  pos = y.find_last_not_of(L"a");
-  VERIFY( pos == npos );
-
-  std::wstring_view z(L"ab");
-  pos = z.find_last_not_of(L'X');
-  VERIFY( pos == 1 );
-  pos = z.find_last_not_of(L"XYZ");
-  VERIFY( pos == 1 );
-  pos = z.find_last_not_of(L'b');
-  VERIFY( pos == 0 );
-  pos = z.find_last_not_of(L"Xb");
-  VERIFY( pos == 0 );
-  pos = z.find_last_not_of(L"Xa");
-  VERIFY( pos == 1 );
-}
-int
-main()
-{
-  test03();
-
-  return 0;
-}
diff --git a/gdb/unittests/basic_string_view/operations/string_conversion/1.cc b/gdb/unittests/basic_string_view/operations/string_conversion/1.cc
deleted file mode 100644
index 33784231d8d..00000000000
--- a/gdb/unittests/basic_string_view/operations/string_conversion/1.cc
+++ /dev/null
@@ -1,51 +0,0 @@
-// { dg-options "-std=gnu++17" }
-
-// Copyright (C) 2014-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-// basic_string_view::to_string
-
-#include <string_view>
-#include <string>
-#include <algorithm>
-#include <testsuite_hooks.h>
-#include <testsuite_allocator.h>
-
-void
-test01()
-{
-  const char str_lit[] = "123456789A";
-  const std::string_view sv(str_lit);
-  char buffer[4] = { 0 };
-
-  std::string s1{sv};
-  VERIFY( s1 == str_lit );
-  using test_alloc = __gnu_test::tracker_allocator<char>;
-  std::basic_string<char, std::char_traits<char>, test_alloc>
-    s2{sv, test_alloc{}};
-  static_assert( std::is_same<decltype(s2)::allocator_type, test_alloc>::value,
-                 "to_string() uses custom allocator" );
-  VERIFY( std::equal(s1.begin(), s1.end(), s2.begin(), s2.end()) );
-  auto s3 = static_cast<std::string>(sv);
-  VERIFY( s3 == s1 );
-}
-
-int
-main()
-{
-  test01();
-}
diff --git a/gdb/unittests/basic_string_view/operations/substr/char/1.cc b/gdb/unittests/basic_string_view/operations/substr/char/1.cc
deleted file mode 100644
index 19454466699..00000000000
--- a/gdb/unittests/basic_string_view/operations/substr/char/1.cc
+++ /dev/null
@@ -1,79 +0,0 @@
-// { dg-options "-std=gnu++17" }
-
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-// basic_string_view::substr
-
-namespace operations_substr_1 {
-
-static void
-test01 ()
-{
-  typedef gdb::string_view::size_type csize_type;
-  typedef gdb::string_view::const_reference cref;
-  typedef gdb::string_view::reference ref;
-  csize_type csz01;
-
-  const char str_lit01[] = "rockaway, pacifica";
-  const gdb::string_view str01(str_lit01);
-  gdb::string_view str02;
-
-  // basic_string_view<charT, _Traits, _Alloc>
-  //  substr(size_type pos = 0, size_type n = npos) const;
-  csz01 = str01.size();
-  str02 = str01.substr(0, 1);
-  VERIFY( str02 == "r" );
-  str02 = str01.substr(10);
-  VERIFY( str02 == "pacifica" );
-
-  try
-  {
-    str02 = str01.substr(csz01 + 1);
-    VERIFY( false ); 
-  }
-  catch(gdb_exception& fail)
-  {
-    VERIFY( true );
-  }
-  catch(...)
-  {
-    VERIFY( false );
-  }
-
-  try
-  {
-    str02 = str01.substr(csz01);
-    VERIFY( str02.size() == 0 );
-    VERIFY( str02.begin() == str01.end() );
-    VERIFY( true );
-  }
-  catch(...)
-  {
-    VERIFY( false );
-  }
-}
-
-static int
-main ()
-{ 
-  test01();
-
-  return 0;
-}
-
-} // namespace operations_substr_1
diff --git a/gdb/unittests/basic_string_view/operations/substr/wchar_t/1.cc b/gdb/unittests/basic_string_view/operations/substr/wchar_t/1.cc
deleted file mode 100644
index bfe79ac7a55..00000000000
--- a/gdb/unittests/basic_string_view/operations/substr/wchar_t/1.cc
+++ /dev/null
@@ -1,79 +0,0 @@
-// { dg-options "-std=gnu++17" }
-
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-// basic_string_view::substr
-
-#include <string_view>
-#include <stdexcept>
-#include <testsuite_hooks.h>
-
-void
-test01()
-{
-  typedef std::wstring_view::size_type csize_type;
-  typedef std::wstring_view::const_reference cref;
-  typedef std::wstring_view::reference ref;
-  csize_type csz01;
-
-  const wchar_t str_lit01[] = L"rockaway, pacifica";
-  const std::wstring_view str01(str_lit01);
-  std::wstring_view str02;
-
-  // basic_string_view<charT, _Traits, _Alloc>
-  //  substr(size_type pos = 0, size_type n = npos) const;
-  csz01 = str01.size();
-  str02 = str01.substr(0, 1);
-  VERIFY( str02 == L"r" );
-  str02 = str01.substr(10);
-  VERIFY( str02 == L"pacifica" );
-
-  try
-  {
-    str02 = str01.substr(csz01 + 1);
-    VERIFY( false ); 
-  }
-  catch(std::out_of_range& fail)
-  {
-    VERIFY( true );
-  }
-  catch(...)
-  {
-    VERIFY( false );
-  }
-
-  try
-  {
-    str02 = str01.substr(csz01);
-    VERIFY( str02.size() == 0 );
-    VERIFY( str02.begin() == str01.end() );
-    VERIFY( true );
-  }
-  catch(...)
-  {
-    VERIFY( false );
-  }
-}
-
-int
-main()
-{ 
-  test01();
-
-  return 0;
-}
diff --git a/gdb/unittests/basic_string_view/operators/char/2.cc b/gdb/unittests/basic_string_view/operators/char/2.cc
deleted file mode 100644
index 30e557f4599..00000000000
--- a/gdb/unittests/basic_string_view/operators/char/2.cc
+++ /dev/null
@@ -1,373 +0,0 @@
-// { dg-options "-std=gnu++17" }
-
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-// basic_string non-member functions
-
-// operator==
-/*
-template<class charT, class traits, class Allocator>
-  bool operator==(const basic_string<charT,traits,Allocator>& lhs,
-                  const basic_string<charT,traits,Allocator>& rhs);
-
-template<class charT, class traits, class Allocator>
-  bool operator==(const charT* lhs,
-                  const basic_string<charT,traits,Allocator>& rhs);
-
-template<class charT, class traits, class Allocator>
-  bool operator==(const basic_string<charT,traits,Allocator>& lhs,
-                  const charT* rhs);
-*/
-
-// operator!=
-/*
-template<class charT, class traits, class Allocator>
-  bool operator!=(const basic_string<charT,traits,Allocator>& lhs,
-                  const basic_string<charT,traits,Allocator>& rhs);
-
-template<class charT, class traits, class Allocator>
-  bool operator!=(const charT* lhs,
-                  const basic_string<charT,traits,Allocator>& rhs);
-
-template<class charT, class traits, class Allocator>
-  bool operator!=(const basic_string<charT,traits,Allocator>& lhs, 
-                  const charT* rhs);
-*/
-
-// operator<
-/*
-template<class charT, class traits, class Allocator>
-  bool operator< (const basic_string<charT,traits,Allocator>& lhs,
-                  const basic_string<charT,traits,Allocator>& rhs);
-
-template<class charT, class traits, class Allocator>
-  bool operator< (const basic_string<charT,traits,Allocator>& lhs,
-                  const charT* rhs);
-
-template<class charT, class traits, class Allocator>
-  bool operator< (const charT* lhs, 
-                  const basic_string<charT,traits,Allocator>& rhs);
-*/
-
-// operator>
-/*
-template<class charT, class traits, class Allocator>
-  bool operator> (const basic_string<charT,traits,Allocator>& lhs,
-                  const basic_string<charT,traits,Allocator>& rhs);
-
-template<class charT, class traits, class Allocator>
-  bool operator> (const basic_string<charT,traits,Allocator>& lhs,
-                  const charT* rhs);
-
-template<class charT, class traits, class Allocator>
-  bool operator> (const charT* lhs,
-                  const basic_string<charT,traits,Allocator>& rhs);
-*/
-
-// operator<=
-/*
-template<class charT, class traits, class Allocator>
-  bool operator<=(const basic_string<charT,traits,Allocator>& lhs,
-                  const basic_string<charT,traits,Allocator>& rhs);
-
-template<class charT, class traits, class Allocator>
-  bool operator<=(const basic_string<charT,traits,Allocator>& lhs,
-                  const charT* rhs);
-
-template<class charT, class traits, class Allocator>
-  bool operator<=(const charT* lhs,
-                  const basic_string<charT,traits,Allocator>& rhs);
-*/
-
-// operator>=
-/*
-template<class charT, class traits, class Allocator>
-  bool operator>=(const basic_string<charT,traits,Allocator>& lhs,
-                const basic_string<charT,traits,Allocator>& rhs);
-
-template<class charT, class traits, class Allocator>
-  bool operator>=(const basic_string<charT,traits,Allocator>& lhs,
-                  const charT* rhs);
-
-template<class charT, class traits, class Allocator>
-  bool operator>=(const charT* lhs,
-                  const basic_string<charT,traits,Allocator>& rhs);
-*/
-
-namespace operators_2 {
-
-static void
-test01()
-{
-  gdb::string_view 	str_0("costa rica");
-  gdb::string_view 	str_1("costa marbella");
-  gdb::string_view 	str_2("cost");
-  gdb::string_view	str_3("costa ricans");
-  gdb::string_view      str_4;
-
-  str_4 = str_0;
-  //comparisons between string objects
-  VERIFY( !(str_0 == str_1) );
-  VERIFY( !(str_0 == str_2) );
-  VERIFY( !(str_0 == str_3) );
-  VERIFY( !(str_1 == str_0) );
-  VERIFY( !(str_2 == str_0) );
-  VERIFY( !(str_3 == str_0) );
-  VERIFY( str_4 == str_0 );
-  VERIFY( str_0 == str_4 );
-
-  VERIFY( str_0 != str_1 );
-  VERIFY( str_0 != str_2 );
-  VERIFY( str_0 != str_3 );
-  VERIFY( str_1 != str_0 );
-  VERIFY( str_2 != str_0 );
-  VERIFY( str_3 != str_0 );
-  VERIFY( !(str_0 != str_4) );
-  VERIFY( !(str_4 != str_0) );
-
-  VERIFY( str_0 > str_1 ); //true cuz r>m
-  VERIFY( str_0 > str_2 );
-  VERIFY( !(str_0 > str_3) );
-  VERIFY( !(str_1 > str_0) ); //false cuz m<r
-  VERIFY( !(str_2 > str_0) );
-  VERIFY( str_3 > str_0 );
-  VERIFY( !(str_0 > str_4) );
-  VERIFY( !(str_4 > str_0) );
-
-  VERIFY( !(str_0 < str_1) ); //false cuz r>m
-  VERIFY( !(str_0 < str_2) );
-  VERIFY( str_0 < str_3 );
-  VERIFY( str_1 < str_0 ); //true cuz m<r
-  VERIFY( str_2 < str_0 );
-  VERIFY( !(str_3 < str_0) );
-  VERIFY( !(str_0 < str_4) );
-  VERIFY( !(str_4 < str_0) );
-
-  VERIFY( str_0 >= str_1 ); //true cuz r>m
-  VERIFY( str_0 >= str_2 );
-  VERIFY( !(str_0 >= str_3) );
-  VERIFY( !(str_1 >= str_0) );//false cuz m<r
-  VERIFY( !(str_2 >= str_0) );
-  VERIFY( str_3 >= str_0 );
-  VERIFY( str_0 >= str_4 );
-  VERIFY( str_4 >= str_0 );
-
-  VERIFY( !(str_0 <= str_1) );//false cuz r>m
-  VERIFY( !(str_0 <= str_2) );
-  VERIFY( str_0 <= str_3 );
-  VERIFY( str_1 <= str_0 );//true cuz m<r
-  VERIFY( str_2 <= str_0 );
-  VERIFY( !(str_3 <= str_0) );
-  VERIFY( str_0 <= str_4 );
-  VERIFY( str_4 <= str_0 );
-
-  //comparisons between string object and string literal
-  VERIFY( !(str_0 == "costa marbella") );
-  VERIFY( !(str_0 == "cost") );
-  VERIFY( !(str_0 == "costa ricans") );
-  VERIFY( !("costa marbella" == str_0) );
-  VERIFY( !("cost" == str_0) );
-  VERIFY( !("costa ricans" == str_0) );
-  VERIFY( "costa rica" == str_0 );
-  VERIFY( str_0 == "costa rica" );
-
-  VERIFY( str_0 != "costa marbella" );
-  VERIFY( str_0 != "cost" );
-  VERIFY( str_0 != "costa ricans" );
-  VERIFY( "costa marbella" != str_0 );
-  VERIFY( "cost" != str_0 );
-  VERIFY( "costa ricans" != str_0 );
-  VERIFY( !("costa rica" != str_0) );
-  VERIFY( !(str_0 != "costa rica") );
-
-  VERIFY( str_0 > "costa marbella" ); //true cuz r>m
-  VERIFY( str_0 > "cost" );
-  VERIFY( !(str_0 > "costa ricans") );
-  VERIFY( !("costa marbella" > str_0) );//false cuz m<r
-  VERIFY( !("cost" > str_0) );
-  VERIFY( "costa ricans" > str_0 );
-  VERIFY( !("costa rica" > str_0) );
-  VERIFY( !(str_0 > "costa rica") );
-
-  VERIFY( !(str_0 < "costa marbella") );//false cuz r>m
-  VERIFY( !(str_0 < "cost") );
-  VERIFY( str_0 < "costa ricans" );
-  VERIFY( "costa marbella" < str_0 );//true cuz m<r
-  VERIFY( "cost" < str_0 );
-  VERIFY( !("costa ricans" < str_0) );
-  VERIFY( !("costa rica" < str_0) );
-  VERIFY( !(str_0 < "costa rica") );
-
-  VERIFY( str_0 >= "costa marbella" );//true cuz r>m
-  VERIFY( str_0 >= "cost" );
-  VERIFY( !(str_0 >= "costa ricans") );
-  VERIFY( !("costa marbella" >= str_0) );//false cuz m<r
-  VERIFY( !("cost" >= str_0) );
-  VERIFY( "costa ricans" >= str_0 );
-  VERIFY( "costa rica" >= str_0 );
-  VERIFY( str_0 >= "costa rica" );
-
-  VERIFY( !(str_0 <= "costa marbella") );//false cuz r>m
-  VERIFY( !(str_0 <= "cost") );
-  VERIFY( str_0 <= "costa ricans" );
-  VERIFY( "costa marbella" <= str_0 );//true cuz m<r
-  VERIFY( "cost" <= str_0 );
-  VERIFY( !("costa ricans" <= str_0) );
-  VERIFY( "costa rica" <= str_0 );
-  VERIFY( str_0 <= "costa rica" );
-}
-
-#ifndef GDB_STRING_VIEW
-constexpr bool
-test02()
-{
-  std::string_view 	str_0("costa rica");
-  std::string_view 	str_1("costa marbella");
-  std::string_view 	str_2("cost");
-  std::string_view	str_3("costa ricans");
-  std::string_view        str_4;
-
-#undef VERIFY
-#define VERIFY(x) if (!(x)) return false
-
-  str_4 = str_0;
-  //comparisons between string objects
-  VERIFY( !(str_0 == str_1) );
-  VERIFY( !(str_0 == str_2) );
-  VERIFY( !(str_0 == str_3) );
-  VERIFY( !(str_1 == str_0) );
-  VERIFY( !(str_2 == str_0) );
-  VERIFY( !(str_3 == str_0) );
-  VERIFY( str_4 == str_0 );
-  VERIFY( str_0 == str_4 );
-
-  VERIFY( str_0 != str_1 );
-  VERIFY( str_0 != str_2 );
-  VERIFY( str_0 != str_3 );
-  VERIFY( str_1 != str_0 );
-  VERIFY( str_2 != str_0 );
-  VERIFY( str_3 != str_0 );
-  VERIFY( !(str_0 != str_4) );
-  VERIFY( !(str_4 != str_0) );
-
-  VERIFY( str_0 > str_1 ); //true cuz r>m
-  VERIFY( str_0 > str_2 );
-  VERIFY( !(str_0 > str_3) );
-  VERIFY( !(str_1 > str_0) ); //false cuz m<r
-  VERIFY( !(str_2 > str_0) );
-  VERIFY( str_3 > str_0 );
-  VERIFY( !(str_0 > str_4) );
-  VERIFY( !(str_4 > str_0) );
-
-  VERIFY( !(str_0 < str_1) ); //false cuz r>m
-  VERIFY( !(str_0 < str_2) );
-  VERIFY( str_0 < str_3 );
-  VERIFY( str_1 < str_0 ); //true cuz m<r
-  VERIFY( str_2 < str_0 );
-  VERIFY( !(str_3 < str_0) );
-  VERIFY( !(str_0 < str_4) );
-  VERIFY( !(str_4 < str_0) );
-
-  VERIFY( str_0 >= str_1 ); //true cuz r>m
-  VERIFY( str_0 >= str_2 );
-  VERIFY( !(str_0 >= str_3) );
-  VERIFY( !(str_1 >= str_0) );//false cuz m<r
-  VERIFY( !(str_2 >= str_0) );
-  VERIFY( str_3 >= str_0 );
-  VERIFY( str_0 >= str_4 );
-  VERIFY( str_4 >= str_0 );
-
-  VERIFY( !(str_0 <= str_1) );//false cuz r>m
-  VERIFY( !(str_0 <= str_2) );
-  VERIFY( str_0 <= str_3 );
-  VERIFY( str_1 <= str_0 );//true cuz m<r
-  VERIFY( str_2 <= str_0 );
-  VERIFY( !(str_3 <= str_0) );
-  VERIFY( str_0 <= str_4 );
-  VERIFY( str_4 <= str_0 );
-
-  //comparisons between string object and string literal
-  VERIFY( !(str_0 == "costa marbella") );
-  VERIFY( !(str_0 == "cost") );
-  VERIFY( !(str_0 == "costa ricans") );
-  VERIFY( !("costa marbella" == str_0) );
-  VERIFY( !("cost" == str_0) );
-  VERIFY( !("costa ricans" == str_0) );
-  VERIFY( "costa rica" == str_0 );
-  VERIFY( str_0 == "costa rica" );
-
-  VERIFY( str_0 != "costa marbella" );
-  VERIFY( str_0 != "cost" );
-  VERIFY( str_0 != "costa ricans" );
-  VERIFY( "costa marbella" != str_0 );
-  VERIFY( "cost" != str_0 );
-  VERIFY( "costa ricans" != str_0 );
-  VERIFY( !("costa rica" != str_0) );
-  VERIFY( !(str_0 != "costa rica") );
-
-  VERIFY( str_0 > "costa marbella" ); //true cuz r>m
-  VERIFY( str_0 > "cost" );
-  VERIFY( !(str_0 > "costa ricans") );
-  VERIFY( !("costa marbella" > str_0) );//false cuz m<r
-  VERIFY( !("cost" > str_0) );
-  VERIFY( "costa ricans" > str_0 );
-  VERIFY( !("costa rica" > str_0) );
-  VERIFY( !(str_0 > "costa rica") );
-
-  VERIFY( !(str_0 < "costa marbella") );//false cuz r>m
-  VERIFY( !(str_0 < "cost") );
-  VERIFY( str_0 < "costa ricans" );
-  VERIFY( "costa marbella" < str_0 );//true cuz m<r
-  VERIFY( "cost" < str_0 );
-  VERIFY( !("costa ricans" < str_0) );
-  VERIFY( !("costa rica" < str_0) );
-  VERIFY( !(str_0 < "costa rica") );
-
-  VERIFY( str_0 >= "costa marbella" );//true cuz r>m
-  VERIFY( str_0 >= "cost" );
-  VERIFY( !(str_0 >= "costa ricans") );
-  VERIFY( !("costa marbella" >= str_0) );//false cuz m<r
-  VERIFY( !("cost" >= str_0) );
-  VERIFY( "costa ricans" >= str_0 );
-  VERIFY( "costa rica" >= str_0 );
-  VERIFY( str_0 >= "costa rica" );
-
-  VERIFY( !(str_0 <= "costa marbella") );//false cuz r>m
-  VERIFY( !(str_0 <= "cost") );
-  VERIFY( str_0 <= "costa ricans" );
-  VERIFY( "costa marbella" <= str_0 );//true cuz m<r
-  VERIFY( "cost" <= str_0 );
-  VERIFY( !("costa ricans" <= str_0) );
-  VERIFY( "costa rica" <= str_0 );
-  VERIFY( str_0 <= "costa rica" );
-
-  return true;
-}
-#endif
-
-static int
-main ()
-{
-  test01();
-#ifndef GDB_STRING_VIEW
-  static_assert( test02() );
-#endif
-  return 0;
-}
-
-} // namespace operators_2
diff --git a/gdb/unittests/basic_string_view/operators/wchar_t/2.cc b/gdb/unittests/basic_string_view/operators/wchar_t/2.cc
deleted file mode 100644
index 5e043bc3fdb..00000000000
--- a/gdb/unittests/basic_string_view/operators/wchar_t/2.cc
+++ /dev/null
@@ -1,367 +0,0 @@
-// { dg-options "-std=gnu++17" }
-
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-// basic_string_view non-member functions
-
-// operator==
-/*
-template<class charT, class traits, class Allocator>
-  bool operator==(const basic_string_view<charT,traits,Allocator>& lhs,
-                  const basic_string_view<charT,traits,Allocator>& rhs);
-
-template<class charT, class traits, class Allocator>
-  bool operator==(const charT* lhs,
-                  const basic_string_view<charT,traits,Allocator>& rhs);
-
-template<class charT, class traits, class Allocator>
-  bool operator==(const basic_string_view<charT,traits,Allocator>& lhs,
-                  const charT* rhs);
-*/
-
-// operator!=
-/*
-template<class charT, class traits, class Allocator>
-  bool operator!=(const basic_string_view<charT,traits,Allocator>& lhs,
-                  const basic_string_view<charT,traits,Allocator>& rhs);
-
-template<class charT, class traits, class Allocator>
-  bool operator!=(const charT* lhs,
-                  const basic_string_view<charT,traits,Allocator>& rhs);
-
-template<class charT, class traits, class Allocator>
-  bool operator!=(const basic_string_view<charT,traits,Allocator>& lhs,
-                  const charT* rhs);
-*/
-
-// operator<
-/*
-template<class charT, class traits, class Allocator>
-  bool operator< (const basic_string_view<charT,traits,Allocator>& lhs,
-                  const basic_string_view<charT,traits,Allocator>& rhs);
-
-template<class charT, class traits, class Allocator>
-  bool operator< (const basic_string_view<charT,traits,Allocator>& lhs,
-                  const charT* rhs);
-
-template<class charT, class traits, class Allocator>
-  bool operator< (const charT* lhs,
-                  const basic_string_view<charT,traits,Allocator>& rhs);
-*/
-
-// operator>
-/*
-template<class charT, class traits, class Allocator>
-  bool operator> (const basic_string_view<charT,traits,Allocator>& lhs,
-                  const basic_string_view<charT,traits,Allocator>& rhs);
-
-template<class charT, class traits, class Allocator>
-  bool operator> (const basic_string_view<charT,traits,Allocator>& lhs,
-                  const charT* rhs);
-
-template<class charT, class traits, class Allocator>
-  bool operator> (const charT* lhs,
-                  const basic_string_view<charT,traits,Allocator>& rhs);
-*/
-
-// operator<=
-/*
-template<class charT, class traits, class Allocator>
-  bool operator<=(const basic_string_view<charT,traits,Allocator>& lhs,
-                  const basic_string_view<charT,traits,Allocator>& rhs);
-
-template<class charT, class traits, class Allocator>
-  bool operator<=(const basic_string_view<charT,traits,Allocator>& lhs,
-                  const charT* rhs);
-
-template<class charT, class traits, class Allocator>
-  bool operator<=(const charT* lhs,
-                  const basic_string_view<charT,traits,Allocator>& rhs);
-*/
-
-// operator>=
-/*
-template<class charT, class traits, class Allocator>
-  bool operator>=(const basic_string_view<charT,traits,Allocator>& lhs,
-                const basic_string_view<charT,traits,Allocator>& rhs);
-
-template<class charT, class traits, class Allocator>
-  bool operator>=(const basic_string_view<charT,traits,Allocator>& lhs,
-                  const charT* rhs);
-
-template<class charT, class traits, class Allocator>
-  bool operator>=(const charT* lhs,
-                  const basic_string_view<charT,traits,Allocator>& rhs);
-*/
-
-#include <string_view>
-#include <testsuite_hooks.h>
-
-void
-test01()
-{
-  std::wstring_view 	str_0(L"costa rica");
-  std::wstring_view 	str_1(L"costa marbella");
-  std::wstring_view 	str_2(L"cost");
-  std::wstring_view	str_3(L"costa ricans");
-  std::wstring_view  str_4;
-
-  str_4 = str_0;
-  //comparisons between string_view objects
-  VERIFY( !(str_0 == str_1) );
-  VERIFY( !(str_0 == str_2) );
-  VERIFY( !(str_0 == str_3) );
-  VERIFY( !(str_1 == str_0) );
-  VERIFY( !(str_2 == str_0) );
-  VERIFY( !(str_3 == str_0) );
-  VERIFY( str_4 == str_0 );
-  VERIFY( str_0 == str_4 );
-
-  VERIFY( str_0 != str_1 );
-  VERIFY( str_0 != str_2 );
-  VERIFY( str_0 != str_3 );
-  VERIFY( str_1 != str_0 );
-  VERIFY( str_2 != str_0 );
-  VERIFY( str_3 != str_0 );
-  VERIFY( !(str_0 != str_4) );
-  VERIFY( !(str_4 != str_0) );
-
-  VERIFY( str_0 > str_1 ); //true cuz r>m
-  VERIFY( str_0 > str_2 );
-  VERIFY( !(str_0 > str_3) );
-  VERIFY( !(str_1 > str_0) ); //false cuz m<r
-  VERIFY( !(str_2 > str_0) );
-  VERIFY( str_3 > str_0 );
-  VERIFY( !(str_0 > str_4) );
-  VERIFY( !(str_4 > str_0) );
-
-  VERIFY( !(str_0 < str_1) ); //false cuz r>m
-  VERIFY( !(str_0 < str_2) );
-  VERIFY( str_0 < str_3 );
-  VERIFY( str_1 < str_0 ); //true cuz m<r
-  VERIFY( str_2 < str_0 );
-  VERIFY( !(str_3 < str_0) );
-  VERIFY( !(str_0 < str_4) );
-  VERIFY( !(str_4 < str_0) );
-
-  VERIFY( str_0 >= str_1 ); //true cuz r>m
-  VERIFY( str_0 >= str_2 );
-  VERIFY( !(str_0 >= str_3) );
-  VERIFY( !(str_1 >= str_0) );//false cuz m<r
-  VERIFY( !(str_2 >= str_0) );
-  VERIFY( str_3 >= str_0 );
-  VERIFY( str_0 >= str_4 );
-  VERIFY( str_4 >= str_0 );
-
-  VERIFY( !(str_0 <= str_1) );//false cuz r>m
-  VERIFY( !(str_0 <= str_2) );
-  VERIFY( str_0 <= str_3 );
-  VERIFY( str_1 <= str_0 );//true cuz m<r
-  VERIFY( str_2 <= str_0 );
-  VERIFY( !(str_3 <= str_0) );
-  VERIFY( str_0 <= str_4 );
-  VERIFY( str_4 <= str_0 );
-
-  //comparisons between string_view object and string_view literal
-  VERIFY( !(str_0 == L"costa marbella") );
-  VERIFY( !(str_0 == L"cost") );
-  VERIFY( !(str_0 == L"costa ricans") );
-  VERIFY( !(L"costa marbella" == str_0) );
-  VERIFY( !(L"cost" == str_0) );
-  VERIFY( !(L"costa ricans" == str_0) );
-  VERIFY( L"costa rica" == str_0 );
-  VERIFY( str_0 == L"costa rica" );
-
-  VERIFY( str_0 != L"costa marbella" );
-  VERIFY( str_0 != L"cost" );
-  VERIFY( str_0 != L"costa ricans" );
-  VERIFY( L"costa marbella" != str_0 );
-  VERIFY( L"cost" != str_0 );
-  VERIFY( L"costa ricans" != str_0 );
-  VERIFY( !(L"costa rica" != str_0) );
-  VERIFY( !(str_0 != L"costa rica") );
-
-  VERIFY( str_0 > L"costa marbella" ); //true cuz r>m
-  VERIFY( str_0 > L"cost" );
-  VERIFY( !(str_0 > L"costa ricans") );
-  VERIFY( !(L"costa marbella" > str_0) );//false cuz m<r
-  VERIFY( !(L"cost" > str_0) );
-  VERIFY( L"costa ricans" > str_0 );
-  VERIFY( !(L"costa rica" > str_0) );
-  VERIFY( !(str_0 > L"costa rica") );
-
-  VERIFY( !(str_0 < L"costa marbella") );//false cuz r>m
-  VERIFY( !(str_0 < L"cost") );
-  VERIFY( str_0 < L"costa ricans" );
-  VERIFY( L"costa marbella" < str_0 );//true cuz m<r
-  VERIFY( L"cost" < str_0 );
-  VERIFY( !(L"costa ricans" < str_0) );
-  VERIFY( !(L"costa rica" < str_0) );
-  VERIFY( !(str_0 < L"costa rica") );
-
-  VERIFY( str_0 >= L"costa marbella" );//true cuz r>m
-  VERIFY( str_0 >= L"cost" );
-  VERIFY( !(str_0 >= L"costa ricans") );
-  VERIFY( !(L"costa marbella" >= str_0) );//false cuz m<r
-  VERIFY( !(L"cost" >= str_0) );
-  VERIFY( L"costa ricans" >= str_0 );
-  VERIFY( L"costa rica" >= str_0 );
-  VERIFY( str_0 >= L"costa rica" );
-
-  VERIFY( !(str_0 <= L"costa marbella") );//false cuz r>m
-  VERIFY( !(str_0 <= L"cost") );
-  VERIFY( str_0 <= L"costa ricans" );
-  VERIFY( L"costa marbella" <= str_0 );//true cuz m<r
-  VERIFY( L"cost" <= str_0 );
-  VERIFY( !(L"costa ricans" <= str_0) );
-  VERIFY( L"costa rica" <= str_0 );
-  VERIFY( str_0 <= L"costa rica" );
-}
-
-constexpr bool
-test02()
-{
-  std::wstring_view 	str_0(L"costa rica");
-  std::wstring_view 	str_1(L"costa marbella");
-  std::wstring_view 	str_2(L"cost");
-  std::wstring_view	str_3(L"costa ricans");
-  std::wstring_view  str_4;
-
-#undef VERIFY
-#define VERIFY(x) if (!(x)) return false
-
-  str_4 = str_0;
-  //comparisons between string_view objects
-  VERIFY( !(str_0 == str_1) );
-  VERIFY( !(str_0 == str_2) );
-  VERIFY( !(str_0 == str_3) );
-  VERIFY( !(str_1 == str_0) );
-  VERIFY( !(str_2 == str_0) );
-  VERIFY( !(str_3 == str_0) );
-  VERIFY( str_4 == str_0 );
-  VERIFY( str_0 == str_4 );
-
-  VERIFY( str_0 != str_1 );
-  VERIFY( str_0 != str_2 );
-  VERIFY( str_0 != str_3 );
-  VERIFY( str_1 != str_0 );
-  VERIFY( str_2 != str_0 );
-  VERIFY( str_3 != str_0 );
-  VERIFY( !(str_0 != str_4) );
-  VERIFY( !(str_4 != str_0) );
-
-  VERIFY( str_0 > str_1 ); //true cuz r>m
-  VERIFY( str_0 > str_2 );
-  VERIFY( !(str_0 > str_3) );
-  VERIFY( !(str_1 > str_0) ); //false cuz m<r
-  VERIFY( !(str_2 > str_0) );
-  VERIFY( str_3 > str_0 );
-  VERIFY( !(str_0 > str_4) );
-  VERIFY( !(str_4 > str_0) );
-
-  VERIFY( !(str_0 < str_1) ); //false cuz r>m
-  VERIFY( !(str_0 < str_2) );
-  VERIFY( str_0 < str_3 );
-  VERIFY( str_1 < str_0 ); //true cuz m<r
-  VERIFY( str_2 < str_0 );
-  VERIFY( !(str_3 < str_0) );
-  VERIFY( !(str_0 < str_4) );
-  VERIFY( !(str_4 < str_0) );
-
-  VERIFY( str_0 >= str_1 ); //true cuz r>m
-  VERIFY( str_0 >= str_2 );
-  VERIFY( !(str_0 >= str_3) );
-  VERIFY( !(str_1 >= str_0) );//false cuz m<r
-  VERIFY( !(str_2 >= str_0) );
-  VERIFY( str_3 >= str_0 );
-  VERIFY( str_0 >= str_4 );
-  VERIFY( str_4 >= str_0 );
-
-  VERIFY( !(str_0 <= str_1) );//false cuz r>m
-  VERIFY( !(str_0 <= str_2) );
-  VERIFY( str_0 <= str_3 );
-  VERIFY( str_1 <= str_0 );//true cuz m<r
-  VERIFY( str_2 <= str_0 );
-  VERIFY( !(str_3 <= str_0) );
-  VERIFY( str_0 <= str_4 );
-  VERIFY( str_4 <= str_0 );
-
-  //comparisons between string_view object and string_view literal
-  VERIFY( !(str_0 == L"costa marbella") );
-  VERIFY( !(str_0 == L"cost") );
-  VERIFY( !(str_0 == L"costa ricans") );
-  VERIFY( !(L"costa marbella" == str_0) );
-  VERIFY( !(L"cost" == str_0) );
-  VERIFY( !(L"costa ricans" == str_0) );
-  VERIFY( L"costa rica" == str_0 );
-  VERIFY( str_0 == L"costa rica" );
-
-  VERIFY( str_0 != L"costa marbella" );
-  VERIFY( str_0 != L"cost" );
-  VERIFY( str_0 != L"costa ricans" );
-  VERIFY( L"costa marbella" != str_0 );
-  VERIFY( L"cost" != str_0 );
-  VERIFY( L"costa ricans" != str_0 );
-  VERIFY( !(L"costa rica" != str_0) );
-  VERIFY( !(str_0 != L"costa rica") );
-
-  VERIFY( str_0 > L"costa marbella" ); //true cuz r>m
-  VERIFY( str_0 > L"cost" );
-  VERIFY( !(str_0 > L"costa ricans") );
-  VERIFY( !(L"costa marbella" > str_0) );//false cuz m<r
-  VERIFY( !(L"cost" > str_0) );
-  VERIFY( L"costa ricans" > str_0 );
-  VERIFY( !(L"costa rica" > str_0) );
-  VERIFY( !(str_0 > L"costa rica") );
-
-  VERIFY( !(str_0 < L"costa marbella") );//false cuz r>m
-  VERIFY( !(str_0 < L"cost") );
-  VERIFY( str_0 < L"costa ricans" );
-  VERIFY( L"costa marbella" < str_0 );//true cuz m<r
-  VERIFY( L"cost" < str_0 );
-  VERIFY( !(L"costa ricans" < str_0) );
-  VERIFY( !(L"costa rica" < str_0) );
-  VERIFY( !(str_0 < L"costa rica") );
-
-  VERIFY( str_0 >= L"costa marbella" );//true cuz r>m
-  VERIFY( str_0 >= L"cost" );
-  VERIFY( !(str_0 >= L"costa ricans") );
-  VERIFY( !(L"costa marbella" >= str_0) );//false cuz m<r
-  VERIFY( !(L"cost" >= str_0) );
-  VERIFY( L"costa ricans" >= str_0 );
-  VERIFY( L"costa rica" >= str_0 );
-  VERIFY( str_0 >= L"costa rica" );
-
-  VERIFY( !(str_0 <= L"costa marbella") );//false cuz r>m
-  VERIFY( !(str_0 <= L"cost") );
-  VERIFY( str_0 <= L"costa ricans" );
-  VERIFY( L"costa marbella" <= str_0 );//true cuz m<r
-  VERIFY( L"cost" <= str_0 );
-  VERIFY( !(L"costa ricans" <= str_0) );
-  VERIFY( L"costa rica" <= str_0 );
-  VERIFY( str_0 <= L"costa rica" );
-
-  return true;
-}
-
-int
-main()
-{
-  test01();
-  static_assert( test02() );
-}
diff --git a/gdb/unittests/basic_string_view/range_access/char/1.cc b/gdb/unittests/basic_string_view/range_access/char/1.cc
deleted file mode 100644
index 4b9e0bde9f1..00000000000
--- a/gdb/unittests/basic_string_view/range_access/char/1.cc
+++ /dev/null
@@ -1,47 +0,0 @@
-// { dg-do compile }
-// { dg-options "-std=gnu++17" }
-
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-// C++17 27.7, range access [iterator.range]
-
-#include <string_view>
-
-void
-test01()
-{
-  std::string_view s("Hello, World!");
-  std::begin(s);
-  std::end(s);
-  std::rbegin(s);
-  std::rend(s);
-}
-
-void
-test02()
-{
-  constexpr std::string_view s("Hello, World!");
-  [[maybe_unused]] constexpr auto b = std::begin(s);
-  [[maybe_unused]] constexpr auto e = std::end(s);
-  [[maybe_unused]] constexpr auto cb = std::cbegin(s);
-  [[maybe_unused]] constexpr auto ce = std::cend(s);
-  [[maybe_unused]] constexpr auto rb = std::rbegin(s);
-  [[maybe_unused]] constexpr auto re = std::rend(s);
-  [[maybe_unused]] constexpr auto crb = std::crbegin(s);
-  [[maybe_unused]] constexpr auto cre = std::crend(s);
-}
diff --git a/gdb/unittests/basic_string_view/range_access/wchar_t/1.cc b/gdb/unittests/basic_string_view/range_access/wchar_t/1.cc
deleted file mode 100644
index 68b6b1c8c96..00000000000
--- a/gdb/unittests/basic_string_view/range_access/wchar_t/1.cc
+++ /dev/null
@@ -1,47 +0,0 @@
-// { dg-do compile }
-// { dg-options "-std=gnu++17" }
-
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-// C++17 27.7, range access [iterator.range]
-
-#include <string_view>
-
-void
-test01()
-{
-  std::wstring_view ws(L"Hello, World!");
-  std::begin(ws);
-  std::end(ws);
-  std::rbegin(ws);
-  std::rend(ws);
-}
-
-void
-test02()
-{
-  constexpr std::wstring_view ws(L"Hello, World!");
-  [[maybe_unused]] constexpr auto b = std::begin(ws);
-  [[maybe_unused]] constexpr auto e = std::end(ws);
-  [[maybe_unused]] constexpr auto cb = std::cbegin(ws);
-  [[maybe_unused]] constexpr auto ce = std::cend(ws);
-  [[maybe_unused]] constexpr auto rb = std::rbegin(ws);
-  [[maybe_unused]] constexpr auto re = std::rend(ws);
-  [[maybe_unused]] constexpr auto crb = std::crbegin(ws);
-  [[maybe_unused]] constexpr auto cre = std::crend(ws);
-}
diff --git a/gdb/unittests/basic_string_view/requirements/explicit_instantiation/1.cc b/gdb/unittests/basic_string_view/requirements/explicit_instantiation/1.cc
deleted file mode 100644
index afea9946bf4..00000000000
--- a/gdb/unittests/basic_string_view/requirements/explicit_instantiation/1.cc
+++ /dev/null
@@ -1,26 +0,0 @@
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-
-// This file tests explicit instantiation of basic_string
-
-#include <string_view>
-
-// { dg-do compile }
-// { dg-options "-std=gnu++17" }
-
-template class std::basic_string_view<int, std::char_traits<int>>;
diff --git a/gdb/unittests/basic_string_view/requirements/explicit_instantiation/char/1.cc b/gdb/unittests/basic_string_view/requirements/explicit_instantiation/char/1.cc
deleted file mode 100644
index 7db0e922257..00000000000
--- a/gdb/unittests/basic_string_view/requirements/explicit_instantiation/char/1.cc
+++ /dev/null
@@ -1,23 +0,0 @@
-// { dg-do compile }
-// { dg-options "-std=gnu++17" }
-
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-//
-// You should have received a copy of the GNU General Public License
-// along with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-#include <string_view>
-
-template class std::basic_string_view<char>;
diff --git a/gdb/unittests/basic_string_view/requirements/explicit_instantiation/char16_t/1.cc b/gdb/unittests/basic_string_view/requirements/explicit_instantiation/char16_t/1.cc
deleted file mode 100644
index 5eb588fce32..00000000000
--- a/gdb/unittests/basic_string_view/requirements/explicit_instantiation/char16_t/1.cc
+++ /dev/null
@@ -1,24 +0,0 @@
-// { dg-do compile }
-// { dg-options "-std=gnu++17" }
-// { dg-require-cstdint "" }
-
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-//
-// You should have received a copy of the GNU General Public License
-// along with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-#include <string_view>
-
-template class std::basic_string_view<char16_t>;
diff --git a/gdb/unittests/basic_string_view/requirements/explicit_instantiation/char32_t/1.cc b/gdb/unittests/basic_string_view/requirements/explicit_instantiation/char32_t/1.cc
deleted file mode 100644
index 2c6460277dd..00000000000
--- a/gdb/unittests/basic_string_view/requirements/explicit_instantiation/char32_t/1.cc
+++ /dev/null
@@ -1,24 +0,0 @@
-// { dg-do compile }
-// { dg-options "-std=gnu++17" }
-// { dg-require-cstdint "" }
-
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-//
-// You should have received a copy of the GNU General Public License
-// along with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-#include <string_view>
-
-template class std::basic_string_view<char32_t>;
diff --git a/gdb/unittests/basic_string_view/requirements/explicit_instantiation/wchar_t/1.cc b/gdb/unittests/basic_string_view/requirements/explicit_instantiation/wchar_t/1.cc
deleted file mode 100644
index 213615f222e..00000000000
--- a/gdb/unittests/basic_string_view/requirements/explicit_instantiation/wchar_t/1.cc
+++ /dev/null
@@ -1,23 +0,0 @@
-// { dg-do compile }
-// { dg-options "-std=gnu++17" }
-
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-//
-// You should have received a copy of the GNU General Public License
-// along with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-#include <string_view>
-
-template class std::basic_string_view<wchar_t>;
diff --git a/gdb/unittests/basic_string_view/requirements/typedefs.cc b/gdb/unittests/basic_string_view/requirements/typedefs.cc
deleted file mode 100644
index 2bb08abfd25..00000000000
--- a/gdb/unittests/basic_string_view/requirements/typedefs.cc
+++ /dev/null
@@ -1,47 +0,0 @@
-
-// { dg-options "-std=gnu++17" }
-// { dg-do compile }
-
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-#include <string_view>
-#include <testsuite_containers.h>
-
-namespace __gnu_test
-{
-  template<typename _Tp1, typename _Tp2>
-    struct traits<std::basic_string_view<_Tp1, _Tp2>> : public traits_base
-    {
-      typedef std::true_type    is_container;
-      typedef std::true_type    is_reversible;
-    };
-}
-
-#include <testsuite_containers.h>
-
-// Check container for required typedefs.
-
-__gnu_test::basic_types<std::string_view> t1b;
-__gnu_test::reversible_types<std::string_view> t1r;
-typedef typename std::string_view::traits_type traits_type1;
-
-#ifdef _GLIBCXX_USE_WCHAR_T
-__gnu_test::basic_types<std::wstring_view> t2b;
-__gnu_test::reversible_types<std::wstring_view> t2r;
-typedef typename std::wstring_view::traits_type traits_type2;
-#endif
diff --git a/gdb/unittests/basic_string_view/typedefs.cc b/gdb/unittests/basic_string_view/typedefs.cc
deleted file mode 100644
index c4222bf8ebf..00000000000
--- a/gdb/unittests/basic_string_view/typedefs.cc
+++ /dev/null
@@ -1,36 +0,0 @@
-// { dg-options "-std=gnu++17" }
-// { dg-do compile }
-
-// Copyright (C) 2014-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-#include <string_view>
-
-template<typename C, typename T>
-  using check1_t = std::basic_string_view<C, T>;
-
-using check2_t = std::string_view;
-
-#ifdef _GLIBCXX_USE_C99_STDINT_TR1
-using check3_t = std::u16string_view;
-using check4_t = std::u32string_view;
-#endif
-
-#ifdef _GLIBCXX_USE_WCHAR_T
-using check5_t = std::wstring_view;
-#endif
-
diff --git a/gdb/unittests/basic_string_view/types/1.cc b/gdb/unittests/basic_string_view/types/1.cc
deleted file mode 100644
index d742df23a44..00000000000
--- a/gdb/unittests/basic_string_view/types/1.cc
+++ /dev/null
@@ -1,43 +0,0 @@
-//
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-//
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-//
-
-// { dg-options "-std=gnu++17" }
-// { dg-do compile }
-
-#include <string_view>
-
-struct T
-{
-  typedef std::string_view String_view;
-  typedef String_view::iterator iterator;
-  typedef String_view::const_iterator const_iterator;
-
-  char t(iterator f)             { return *f; }
-  char t(const_iterator f) const { return *f; }
-};
-
-void
-f()
-{
-  std::string_view s;
-  T t;
-  T::const_iterator i = s.begin();
-  
-  t.t(i);
-}
diff --git a/gdb/unittests/string_view-selftests.c b/gdb/unittests/string_view-selftests.c
deleted file mode 100644
index cf43d29502c..00000000000
--- a/gdb/unittests/string_view-selftests.c
+++ /dev/null
@@ -1,193 +0,0 @@
-/* Self tests for string_view for GDB, the GNU debugger.
-
-   Copyright (C) 2018-2023 Free Software Foundation, Inc.
-
-   This file is part of GDB.
-
-   This program 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 of the License, or
-   (at your option) any later version.
-
-   This program 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.
-
-   You should have received a copy of the GNU General Public License
-   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
-
-/* No need to test string_view if we're using C++17, since we're going to use
-   the "real" version.  */
-#if __cplusplus < 201703L
-
-#define GNULIB_NAMESPACE gnulib
-
-#include "diagnostics.h"
-
-/* Since this file uses GNULIB_NAMESPACE, some code defined in headers ends up
-   using system functions rather than gnulib replacements.  This is not really
-   a problem for this test, but it generates some warnings with Clang, silence
-   them.  */
-DIAGNOSTIC_PUSH
-DIAGNOSTIC_IGNORE_USER_DEFINED_WARNINGS
-
-#include "defs.h"
-#include "gdbsupport/selftest.h"
-#include "gdbsupport/gdb_string_view.h"
-
-/* Used by the included .cc files below.  Included here because the
-   included test files are wrapped in a namespace.  */
-#include <string>
-#include <sstream>
-#include <fstream>
-#include <iostream>
-
-DIAGNOSTIC_POP
-
-/* libstdc++'s testsuite uses VERIFY.  */
-#define VERIFY SELF_CHECK
-
-/* Used to disable testing features not supported by
-   gdb::string_view.  */
-#define GDB_STRING_VIEW
-
-namespace selftests {
-namespace string_view {
-
-/* The actual tests live in separate files, which were originally
-   copied over from libstdc++'s testsuite.  To preserve the structure
-   and help with comparison with the original tests, the file names
-   have been preserved, and only minimal modification was done to have
-   them compile against gdb::string_view instead of std::string_view:
-
-     - std::string_view->gdb::string_view, etc.
-     - ATTRIBUTE_UNUSED in a few places
-     - wrap each file in a namespace so they can all be compiled as a
-       single unit.
-     - libstdc++'s license and formatting style was preserved.
-*/
-
-#include "basic_string_view/capacity/1.cc"
-#include "basic_string_view/cons/char/1.cc"
-#include "basic_string_view/cons/char/2.cc"
-#include "basic_string_view/cons/char/3.cc"
-#include "basic_string_view/element_access/char/1.cc"
-#include "basic_string_view/element_access/char/empty.cc"
-#include "basic_string_view/element_access/char/front_back.cc"
-#include "basic_string_view/inserters/char/2.cc"
-#include "basic_string_view/modifiers/remove_prefix/char/1.cc"
-#include "basic_string_view/modifiers/remove_suffix/char/1.cc"
-#include "basic_string_view/modifiers/swap/char/1.cc"
-#include "basic_string_view/operations/compare/char/1.cc"
-#include "basic_string_view/operations/compare/char/13650.cc"
-#include "basic_string_view/operations/copy/char/1.cc"
-#include "basic_string_view/operations/data/char/1.cc"
-#include "basic_string_view/operations/find/char/1.cc"
-#include "basic_string_view/operations/find/char/2.cc"
-#include "basic_string_view/operations/find/char/3.cc"
-#include "basic_string_view/operations/find/char/4.cc"
-#include "basic_string_view/operations/rfind/char/1.cc"
-#include "basic_string_view/operations/rfind/char/2.cc"
-#include "basic_string_view/operations/rfind/char/3.cc"
-#include "basic_string_view/operations/substr/char/1.cc"
-#include "basic_string_view/operators/char/2.cc"
-
-static void
-run_tests ()
-{
-  capacity_1::main ();
-  cons_1::main ();
-  cons_2::main ();
-  cons_3::main ();
-  element_access_1::main ();
-  element_access_empty::main ();
-  element_access_front_back::main ();
-  inserters_2::main ();
-  modifiers_remove_prefix::main ();
-  modifiers_remove_suffix::main ();
-  modifiers_swap::test01 ();
-  operations_compare_1::main ();
-  operations_compare_13650::main ();
-  operations_copy_1::main ();
-  operations_data_1::main ();
-  operations_find_1::main ();
-  operations_find_2::main ();
-  operations_find_3::main ();
-  operations_find_4::main ();
-  operations_rfind_1::main ();
-  operations_rfind_2::main ();
-  operations_rfind_3::main ();
-  operations_substr_1::main ();
-  operators_2::main ();
-
-  constexpr gdb::string_view sv_empty;
-  SELF_CHECK (sv_empty.empty ());
-
-  std::string std_string = "fika";
-  gdb::string_view sv1 (std_string);
-  SELF_CHECK (sv1 == "fika");
-
-  constexpr const char *fika = "fika";
-  gdb::string_view sv2 (fika);
-  SELF_CHECK (sv2 == "fika");
-
-  constexpr gdb::string_view sv3 (fika, 3);
-  SELF_CHECK (sv3 == "fik");
-
-  constexpr gdb::string_view sv4 (sv3);
-  SELF_CHECK (sv4 == "fik");
-
-  constexpr gdb::string_view::iterator it_begin = sv4.begin ();
-  static_assert (*it_begin == 'f', "");
-
-  constexpr gdb::string_view::iterator it_end = sv4.end ();
-  static_assert (*it_end == 'a', "");
-
-  const gdb::string_view::reverse_iterator it_rbegin = sv4.rbegin ();
-  SELF_CHECK (*it_rbegin == 'k');
-
-  const gdb::string_view::reverse_iterator it_rend = sv4.rend ();
-  SELF_CHECK (*(it_rend - 1) == 'f');
-
-  constexpr gdb::string_view::size_type size = sv4.size ();
-  static_assert (size == 3, "");
-
-  constexpr gdb::string_view::size_type length = sv4.length ();
-  static_assert (length == 3, "");
-
-  constexpr gdb::string_view::size_type max_size = sv4.max_size ();
-  static_assert (max_size > 0, "");
-
-  constexpr bool empty = sv4.empty ();
-  static_assert (!empty, "");
-
-  constexpr char c1 = sv4[1];
-  static_assert (c1 == 'i', "");
-
-  constexpr char c2 = sv4.at (2);
-  static_assert (c2 == 'k', "");
-
-  constexpr char front = sv4.front ();
-  static_assert (front == 'f', "");
-
-  constexpr char back = sv4.back ();
-  static_assert (back == 'k', "");
-
-  constexpr const char *data = sv4.data ();
-  static_assert (data == fika, "");
-}
-
-} /* namespace string_view */
-} /* namespace selftests */
-
-#endif /* __cplusplus < 201703L */
-
-void _initialize_string_view_selftests ();
-void
-_initialize_string_view_selftests ()
-{
-#if defined(GDB_STRING_VIEW)
-  selftests::register_test ("string_view", selftests::string_view::run_tests);
-#endif
-}
diff --git a/gdbsupport/gdb_string_view.h b/gdbsupport/gdb_string_view.h
deleted file mode 100644
index cf7af623327..00000000000
--- a/gdbsupport/gdb_string_view.h
+++ /dev/null
@@ -1,566 +0,0 @@
-// Components for manipulating non-owning sequences of characters -*- C++ -*-
-
-
-#ifndef COMMON_GDB_STRING_VIEW_H
-#define COMMON_GDB_STRING_VIEW_H
-
-// Note: This file has been stolen from the gcc repo
-// (libstdc++-v3/include/experimental/string_view) and has local modifications.
-
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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/>.
-
-//
-// N3762 basic_string_view library
-//
-
-
-#if __cplusplus >= 201703L
-
-#include <string_view>
-
-namespace gdb {
-  using string_view = std::string_view;
-} /* namespace gdb */
-
-#else /* __cplusplus < 201703L */
-
-#include <string>
-#include <limits>
-#include "gdb_assert.h"
-
-namespace gdb {
-
-  /**
-   *  @class basic_string_view <experimental/string_view>
-   *  @brief  A non-owning reference to a string.
-   *
-   *  @ingroup strings
-   *  @ingroup sequences
-   *  @ingroup experimental
-   *
-   *  @tparam _CharT  Type of character
-   *  @tparam _Traits  Traits for character type, defaults to
-   *                   char_traits<_CharT>.
-   *
-   *  A basic_string_view looks like this:
-   *
-   *  @code
-   *    _CharT*    _M_str
-   *    size_t     _M_len
-   *  @endcode
-   */
-  template<typename _CharT, typename _Traits = std::char_traits<_CharT>>
-    class basic_string_view
-    {
-    public:
-
-      // types
-      using traits_type = _Traits;
-      using value_type = _CharT;
-      using pointer = const _CharT*;
-      using const_pointer = const _CharT*;
-      using reference = const _CharT&;
-      using const_reference = const _CharT&;
-      using const_iterator = const _CharT*;
-      using iterator = const_iterator;
-      using const_reverse_iterator = std::reverse_iterator<const_iterator>;
-      using reverse_iterator = const_reverse_iterator;
-      using size_type = size_t;
-      using difference_type = ptrdiff_t;
-      static constexpr size_type npos = size_type(-1);
-
-      // [string.view.cons], construct/copy
-
-      constexpr
-      basic_string_view() noexcept
-      : _M_len{0}, _M_str{nullptr}
-      { }
-
-      constexpr basic_string_view(const basic_string_view&) noexcept = default;
-
-      template<typename _Allocator>
-	basic_string_view(const std::basic_string<_CharT, _Traits,
-			  _Allocator>& __str) noexcept
-	: _M_len{__str.length()}, _M_str{__str.data()}
-	{ }
-
-      /*constexpr*/ basic_string_view(const _CharT* __str)
-      : _M_len{__str == nullptr ? 0 : traits_type::length(__str)},
-	_M_str{__str}
-      { }
-
-      constexpr basic_string_view(const _CharT* __str, size_type __len)
-      : _M_len{__len},
-	_M_str{__str}
-      { }
-
-      basic_string_view&
-      operator=(const basic_string_view&) noexcept = default;
-
-      // [string.view.iterators], iterators
-
-      constexpr const_iterator
-      begin() const noexcept
-      { return this->_M_str; }
-
-      constexpr const_iterator
-      end() const noexcept
-      { return this->_M_str + this->_M_len; }
-
-      constexpr const_iterator
-      cbegin() const noexcept
-      { return this->_M_str; }
-
-      constexpr const_iterator
-      cend() const noexcept
-      { return this->_M_str + this->_M_len; }
-
-      const_reverse_iterator
-      rbegin() const noexcept
-      { return const_reverse_iterator(this->end()); }
-
-      const_reverse_iterator
-      rend() const noexcept
-      { return const_reverse_iterator(this->begin()); }
-
-      const_reverse_iterator
-      crbegin() const noexcept
-      { return const_reverse_iterator(this->end()); }
-
-      const_reverse_iterator
-      crend() const noexcept
-      { return const_reverse_iterator(this->begin()); }
-
-      // [string.view.capacity], capacity
-
-      constexpr size_type
-      size() const noexcept
-      { return this->_M_len; }
-
-      constexpr size_type
-      length() const noexcept
-      { return _M_len; }
-
-      constexpr size_type
-      max_size() const noexcept
-      {
-	return (npos - sizeof(size_type) - sizeof(void*))
-		/ sizeof(value_type) / 4;
-      }
-
-      constexpr bool
-      empty() const noexcept
-      { return this->_M_len == 0; }
-
-      // [string.view.access], element access
-
-      constexpr const _CharT&
-      operator[](size_type __pos) const
-      {
-	// TODO: Assert to restore in a way compatible with the constexpr.
-	// __glibcxx_assert(__pos < this->_M_len);
-	return *(this->_M_str + __pos);
-      }
-
-      constexpr const _CharT&
-      at(size_type __pos) const
-      {
-	return __pos < this->_M_len
-	     ? *(this->_M_str + __pos)
-	     : (error (_("basic_string_view::at: __pos "
-			 "(which is %zu) >= this->size() "
-			 "(which is %zu)"),
-		       __pos, this->size()),
-		*this->_M_str);
-      }
-
-      constexpr const _CharT&
-      front() const
-      {
-	// TODO: Assert to restore in a way compatible with the constexpr.
-	// __glibcxx_assert(this->_M_len > 0);
-	return *this->_M_str;
-      }
-
-      constexpr const _CharT&
-      back() const
-      {
-	// TODO: Assert to restore in a way compatible with the constexpr.
-	// __glibcxx_assert(this->_M_len > 0);
-	return *(this->_M_str + this->_M_len - 1);
-      }
-
-      constexpr const _CharT*
-      data() const noexcept
-      { return this->_M_str; }
-
-      // [string.view.modifiers], modifiers:
-
-      /*constexpr*/ void
-      remove_prefix(size_type __n)
-      {
-	gdb_assert (this->_M_len >= __n);
-	this->_M_str += __n;
-	this->_M_len -= __n;
-      }
-
-      /*constexpr*/ void
-      remove_suffix(size_type __n)
-      { this->_M_len -= __n; }
-
-      /*constexpr*/ void
-      swap(basic_string_view& __sv) noexcept
-      {
-	auto __tmp = *this;
-	*this = __sv;
-	__sv = __tmp;
-      }
-
-
-      // [string.view.ops], string operations:
-
-      template<typename _Allocator>
-	explicit operator std::basic_string<_CharT, _Traits, _Allocator>() const
-	{
-	  return { this->_M_str, this->_M_len };
-	}
-
-      size_type
-      copy(_CharT* __str, size_type __n, size_type __pos = 0) const
-      {
-	gdb_assert (__str != nullptr || __n == 0);
-	if (__pos > this->_M_len)
-	  error (_("basic_string_view::copy: __pos "
-		   "(which is %zu) > this->size() "
-		   "(which is %zu)"),
-		 __pos, this->size());
-	size_type __rlen{std::min(__n, size_type{this->_M_len  - __pos})};
-	for (auto __begin = this->_M_str + __pos,
-	     __end = __begin + __rlen; __begin != __end;)
-	  *__str++ = *__begin++;
-	return __rlen;
-      }
-
-
-      // [string.view.ops], string operations:
-
-      /*constexpr*/ basic_string_view
-      substr(size_type __pos, size_type __n=npos) const
-      {
-	return __pos <= this->_M_len
-	     ? basic_string_view{this->_M_str + __pos,
-				std::min(__n, size_type{this->_M_len  - __pos})}
-	     : (error (_("basic_string_view::substr: __pos "
-			 "(which is %zu) > this->size() "
-			 "(which is %zu)"),
-		       __pos, this->size()), basic_string_view{});
-      }
-
-      /*constexpr*/ int
-      compare(basic_string_view __str) const noexcept
-      {
-	int __ret = traits_type::compare(this->_M_str, __str._M_str,
-					 std::min(this->_M_len, __str._M_len));
-	if (__ret == 0)
-	  __ret = _S_compare(this->_M_len, __str._M_len);
-	return __ret;
-      }
-
-      /*constexpr*/ int
-      compare(size_type __pos1, size_type __n1, basic_string_view __str) const
-      { return this->substr(__pos1, __n1).compare(__str); }
-
-      /*constexpr*/ int
-      compare(size_type __pos1, size_type __n1,
-	      basic_string_view __str, size_type __pos2, size_type __n2) const
-      { return this->substr(__pos1, __n1).compare(__str.substr(__pos2, __n2)); }
-
-      /*constexpr*/ int
-      compare(const _CharT* __str) const noexcept
-      { return this->compare(basic_string_view{__str}); }
-
-      /*constexpr*/ int
-      compare(size_type __pos1, size_type __n1, const _CharT* __str) const
-      { return this->substr(__pos1, __n1).compare(basic_string_view{__str}); }
-
-      /*constexpr*/ int
-      compare(size_type __pos1, size_type __n1,
-	      const _CharT* __str, size_type __n2) const
-      {
-	return this->substr(__pos1, __n1)
-		   .compare(basic_string_view(__str, __n2));
-      }
-
-      /*constexpr*/ size_type
-      find(basic_string_view __str, size_type __pos = 0) const noexcept
-      { return this->find(__str._M_str, __pos, __str._M_len); }
-
-      /*constexpr*/ size_type
-      find(_CharT __c, size_type __pos=0) const noexcept;
-
-      /*constexpr*/ size_type
-      find(const _CharT* __str, size_type __pos, size_type __n) const noexcept;
-
-      /*constexpr*/ size_type
-      find(const _CharT* __str, size_type __pos=0) const noexcept
-      { return this->find(__str, __pos, traits_type::length(__str)); }
-
-      /*constexpr*/ size_type
-      rfind(basic_string_view __str, size_type __pos = npos) const noexcept
-      { return this->rfind(__str._M_str, __pos, __str._M_len); }
-
-      /*constexpr*/ size_type
-      rfind(_CharT __c, size_type __pos = npos) const noexcept;
-
-      /*constexpr*/ size_type
-      rfind(const _CharT* __str, size_type __pos, size_type __n) const noexcept;
-
-      /*constexpr*/ size_type
-      rfind(const _CharT* __str, size_type __pos = npos) const noexcept
-      { return this->rfind(__str, __pos, traits_type::length(__str)); }
-
-      /*constexpr*/ size_type
-      find_first_of(basic_string_view __str, size_type __pos = 0) const noexcept
-      { return this->find_first_of(__str._M_str, __pos, __str._M_len); }
-
-      /*constexpr*/ size_type
-      find_first_of(_CharT __c, size_type __pos = 0) const noexcept
-      { return this->find(__c, __pos); }
-
-      /*constexpr*/ size_type
-      find_first_of(const _CharT* __str, size_type __pos, size_type __n) const;
-
-      /*constexpr*/ size_type
-      find_first_of(const _CharT* __str, size_type __pos = 0) const noexcept
-      { return this->find_first_of(__str, __pos, traits_type::length(__str)); }
-
-      /*constexpr*/ size_type
-      find_last_of(basic_string_view __str,
-		   size_type __pos = npos) const noexcept
-      { return this->find_last_of(__str._M_str, __pos, __str._M_len); }
-
-      size_type
-      find_last_of(_CharT __c, size_type __pos=npos) const noexcept
-      { return this->rfind(__c, __pos); }
-
-      /*constexpr*/ size_type
-      find_last_of(const _CharT* __str, size_type __pos, size_type __n) const;
-
-      /*constexpr*/ size_type
-      find_last_of(const _CharT* __str, size_type __pos = npos) const noexcept
-      { return this->find_last_of(__str, __pos, traits_type::length(__str)); }
-
-      /*constexpr*/ size_type
-      find_first_not_of(basic_string_view __str,
-			size_type __pos = 0) const noexcept
-      { return this->find_first_not_of(__str._M_str, __pos, __str._M_len); }
-
-      /*constexpr*/ size_type
-      find_first_not_of(_CharT __c, size_type __pos = 0) const noexcept;
-
-      /*constexpr*/ size_type
-      find_first_not_of(const _CharT* __str,
-			size_type __pos, size_type __n) const;
-
-      /*constexpr*/ size_type
-      find_first_not_of(const _CharT* __str, size_type __pos = 0) const noexcept
-      {
-	return this->find_first_not_of(__str, __pos,
-				       traits_type::length(__str));
-      }
-
-      /*constexpr*/ size_type
-      find_last_not_of(basic_string_view __str,
-		       size_type __pos = npos) const noexcept
-      { return this->find_last_not_of(__str._M_str, __pos, __str._M_len); }
-
-      /*constexpr*/ size_type
-      find_last_not_of(_CharT __c, size_type __pos = npos) const noexcept;
-
-      /*constexpr*/ size_type
-      find_last_not_of(const _CharT* __str,
-		       size_type __pos, size_type __n) const;
-
-      /*constexpr*/ size_type
-      find_last_not_of(const _CharT* __str,
-		       size_type __pos = npos) const noexcept
-      {
-	return this->find_last_not_of(__str, __pos,
-				      traits_type::length(__str));
-      }
-
-    private:
-
-      static constexpr int
-      _S_compare(size_type __n1, size_type __n2) noexcept
-      {
-	return difference_type(__n1 - __n2) > std::numeric_limits<int>::max()
-	     ? std::numeric_limits<int>::max()
-	     : difference_type(__n1 - __n2) < std::numeric_limits<int>::min()
-	     ? std::numeric_limits<int>::min()
-	     : static_cast<int>(difference_type(__n1 - __n2));
-      }
-
-      size_t	    _M_len;
-      const _CharT* _M_str;
-    };
-
-  // [string.view.comparison], non-member basic_string_view comparison functions
-
-  namespace __detail
-  {
-    // Identity transform to create a non-deduced context, so that only one
-    // argument participates in template argument deduction and the other
-    // argument gets implicitly converted to the deduced type. See n3766.html.
-    template<typename _Tp>
-      using __idt = typename std::common_type<_Tp>::type;
-  }
-
-  template<typename _CharT, typename _Traits>
-    /*constexpr*/ bool
-    operator==(basic_string_view<_CharT, _Traits> __x,
-	       basic_string_view<_CharT, _Traits> __y) noexcept
-    { return __x.size() == __y.size() && __x.compare(__y) == 0; }
-
-  template<typename _CharT, typename _Traits>
-    /*constexpr*/ bool
-    operator==(basic_string_view<_CharT, _Traits> __x,
-	       __detail::__idt<basic_string_view<_CharT, _Traits>> __y) noexcept
-    { return __x.size() == __y.size() && __x.compare(__y) == 0; }
-
-  template<typename _CharT, typename _Traits>
-    /*constexpr*/ bool
-    operator==(__detail::__idt<basic_string_view<_CharT, _Traits>> __x,
-	       basic_string_view<_CharT, _Traits> __y) noexcept
-    { return __x.size() == __y.size() && __x.compare(__y) == 0; }
-
-  template<typename _CharT, typename _Traits>
-    /*constexpr*/ bool
-    operator!=(basic_string_view<_CharT, _Traits> __x,
-	       basic_string_view<_CharT, _Traits> __y) noexcept
-    { return !(__x == __y); }
-
-  template<typename _CharT, typename _Traits>
-    /*constexpr*/ bool
-    operator!=(basic_string_view<_CharT, _Traits> __x,
-	       __detail::__idt<basic_string_view<_CharT, _Traits>> __y) noexcept
-    { return !(__x == __y); }
-
-  template<typename _CharT, typename _Traits>
-    /*constexpr*/ bool
-    operator!=(__detail::__idt<basic_string_view<_CharT, _Traits>> __x,
-	       basic_string_view<_CharT, _Traits> __y) noexcept
-    { return !(__x == __y); }
-
-  template<typename _CharT, typename _Traits>
-    /*constexpr*/ bool
-    operator< (basic_string_view<_CharT, _Traits> __x,
-	       basic_string_view<_CharT, _Traits> __y) noexcept
-    { return __x.compare(__y) < 0; }
-
-  template<typename _CharT, typename _Traits>
-    /*constexpr*/ bool
-    operator< (basic_string_view<_CharT, _Traits> __x,
-	       __detail::__idt<basic_string_view<_CharT, _Traits>> __y) noexcept
-    { return __x.compare(__y) < 0; }
-
-  template<typename _CharT, typename _Traits>
-    /*constexpr*/ bool
-    operator< (__detail::__idt<basic_string_view<_CharT, _Traits>> __x,
-	       basic_string_view<_CharT, _Traits> __y) noexcept
-    { return __x.compare(__y) < 0; }
-
-  template<typename _CharT, typename _Traits>
-    /*constexpr*/ bool
-    operator> (basic_string_view<_CharT, _Traits> __x,
-	       basic_string_view<_CharT, _Traits> __y) noexcept
-    { return __x.compare(__y) > 0; }
-
-  template<typename _CharT, typename _Traits>
-    /*constexpr*/ bool
-    operator> (basic_string_view<_CharT, _Traits> __x,
-	       __detail::__idt<basic_string_view<_CharT, _Traits>> __y) noexcept
-    { return __x.compare(__y) > 0; }
-
-  template<typename _CharT, typename _Traits>
-    /*constexpr*/ bool
-    operator> (__detail::__idt<basic_string_view<_CharT, _Traits>> __x,
-	       basic_string_view<_CharT, _Traits> __y) noexcept
-    { return __x.compare(__y) > 0; }
-
-  template<typename _CharT, typename _Traits>
-    /*constexpr*/ bool
-    operator<=(basic_string_view<_CharT, _Traits> __x,
-	       basic_string_view<_CharT, _Traits> __y) noexcept
-    { return __x.compare(__y) <= 0; }
-
-  template<typename _CharT, typename _Traits>
-    /*constexpr*/ bool
-    operator<=(basic_string_view<_CharT, _Traits> __x,
-	       __detail::__idt<basic_string_view<_CharT, _Traits>> __y) noexcept
-    { return __x.compare(__y) <= 0; }
-
-  template<typename _CharT, typename _Traits>
-    /*constexpr*/ bool
-    operator<=(__detail::__idt<basic_string_view<_CharT, _Traits>> __x,
-	       basic_string_view<_CharT, _Traits> __y) noexcept
-    { return __x.compare(__y) <= 0; }
-
-  template<typename _CharT, typename _Traits>
-    /*constexpr*/ bool
-    operator>=(basic_string_view<_CharT, _Traits> __x,
-	       basic_string_view<_CharT, _Traits> __y) noexcept
-    { return __x.compare(__y) >= 0; }
-
-  template<typename _CharT, typename _Traits>
-    /*constexpr*/ bool
-    operator>=(basic_string_view<_CharT, _Traits> __x,
-	       __detail::__idt<basic_string_view<_CharT, _Traits>> __y) noexcept
-    { return __x.compare(__y) >= 0; }
-
-  template<typename _CharT, typename _Traits>
-    /*constexpr*/ bool
-    operator>=(__detail::__idt<basic_string_view<_CharT, _Traits>> __x,
-	       basic_string_view<_CharT, _Traits> __y) noexcept
-    { return __x.compare(__y) >= 0; }
-
-  // basic_string_view typedef names
-
-  using string_view = basic_string_view<char>;
-} /* namespace gdb */
-
-#include "gdb_string_view.tcc"
-
-#endif // __cplusplus < 201703L
-
-namespace gdb {
-
-static inline std::string
-to_string(const std::string_view &view)
-{
-  return { view.data (), view.size () };
-}
-
-}
-
-#endif /* COMMON_GDB_STRING_VIEW_H */
diff --git a/gdbsupport/gdb_string_view.tcc b/gdbsupport/gdb_string_view.tcc
deleted file mode 100644
index 0798105673b..00000000000
--- a/gdbsupport/gdb_string_view.tcc
+++ /dev/null
@@ -1,219 +0,0 @@
-// Components for manipulating non-owning sequences of characters -*- C++ -*-
-
-// Note: This file has been stolen from the gcc repo
-// (libstdc++-v3/include/experimental/bits/string_view.tcc) and has local
-// modifications.
-
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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 experimental/bits/string_view.tcc
- *  This is an internal header file, included by other library headers.
- *  Do not attempt to use it directly. @headername{experimental/string_view}
- */
-
-//
-// N3762 basic_string_view library
-//
-
-#ifndef GDB_STRING_VIEW_TCC
-#define GDB_STRING_VIEW_TCC 1
-
-namespace gdb
-{
-  template<typename _CharT, typename _Traits>
-    /*constexpr*/ typename basic_string_view<_CharT, _Traits>::size_type
-    basic_string_view<_CharT, _Traits>::
-    find(const _CharT* __str, size_type __pos, size_type __n) const noexcept
-    {
-      gdb_assert (__str != nullptr || __n == 0);
-
-      if (__n == 0)
-	return __pos <= this->_M_len ? __pos : npos;
-
-      if (__n <= this->_M_len)
-	{
-	  for (; __pos <= this->_M_len - __n; ++__pos)
-	    if (traits_type::eq(this->_M_str[__pos], __str[0])
-		&& traits_type::compare(this->_M_str + __pos + 1,
-					__str + 1, __n - 1) == 0)
-	      return __pos;
-	}
-      return npos;
-    }
-
-  template<typename _CharT, typename _Traits>
-    /*constexpr*/ typename basic_string_view<_CharT, _Traits>::size_type
-    basic_string_view<_CharT, _Traits>::
-    find(_CharT __c, size_type __pos) const noexcept
-    {
-      size_type __ret = npos;
-      if (__pos < this->_M_len)
-	{
-	  const size_type __n = this->_M_len - __pos;
-	  const _CharT* __p = traits_type::find(this->_M_str + __pos, __n, __c);
-	  if (__p)
-	    __ret = __p - this->_M_str;
-	}
-      return __ret;
-    }
-
-  template<typename _CharT, typename _Traits>
-    /*constexpr*/ typename basic_string_view<_CharT, _Traits>::size_type
-    basic_string_view<_CharT, _Traits>::
-    rfind(const _CharT* __str, size_type __pos, size_type __n) const noexcept
-    {
-      gdb_assert (__str != nullptr || __n == 0);
-
-      if (__n <= this->_M_len)
-	{
-	  __pos = std::min(size_type(this->_M_len - __n), __pos);
-	  do
-	    {
-	      if (traits_type::compare(this->_M_str + __pos, __str, __n) == 0)
-		return __pos;
-	    }
-	  while (__pos-- > 0);
-	}
-      return npos;
-    }
-
-  template<typename _CharT, typename _Traits>
-    /*constexpr*/ typename basic_string_view<_CharT, _Traits>::size_type
-    basic_string_view<_CharT, _Traits>::
-    rfind(_CharT __c, size_type __pos) const noexcept
-    {
-      size_type __size = this->_M_len;
-      if (__size > 0)
-	{
-	  if (--__size > __pos)
-	    __size = __pos;
-	  for (++__size; __size-- > 0; )
-	    if (traits_type::eq(this->_M_str[__size], __c))
-	      return __size;
-	}
-      return npos;
-    }
-
-  template<typename _CharT, typename _Traits>
-    /*constexpr*/ typename basic_string_view<_CharT, _Traits>::size_type
-    basic_string_view<_CharT, _Traits>::
-    find_first_of(const _CharT* __str, size_type __pos, size_type __n) const
-    {
-      gdb_assert (__str != nullptr || __n == 0);
-      for (; __n && __pos < this->_M_len; ++__pos)
-	{
-	  const _CharT* __p = traits_type::find(__str, __n,
-						this->_M_str[__pos]);
-	  if (__p)
-	    return __pos;
-	}
-      return npos;
-    }
-
-  template<typename _CharT, typename _Traits>
-    /*constexpr*/ typename basic_string_view<_CharT, _Traits>::size_type
-    basic_string_view<_CharT, _Traits>::
-    find_last_of(const _CharT* __str, size_type __pos, size_type __n) const
-    {
-      gdb_assert (__str != nullptr || __n == 0);
-      size_type __size = this->size();
-      if (__size && __n)
-	{
-	  if (--__size > __pos)
-	    __size = __pos;
-	  do
-	    {
-	      if (traits_type::find(__str, __n, this->_M_str[__size]))
-		return __size;
-	    }
-	  while (__size-- != 0);
-	}
-      return npos;
-    }
-
-  template<typename _CharT, typename _Traits>
-    /*constexpr*/ typename basic_string_view<_CharT, _Traits>::size_type
-    basic_string_view<_CharT, _Traits>::
-    find_first_not_of(const _CharT* __str, size_type __pos, size_type __n) const
-    {
-      gdb_assert (__str != nullptr || __n == 0);
-      for (; __pos < this->_M_len; ++__pos)
-	if (!traits_type::find(__str, __n, this->_M_str[__pos]))
-	  return __pos;
-      return npos;
-    }
-
-  template<typename _CharT, typename _Traits>
-    /*constexpr*/ typename basic_string_view<_CharT, _Traits>::size_type
-    basic_string_view<_CharT, _Traits>::
-    find_first_not_of(_CharT __c, size_type __pos) const noexcept
-    {
-      for (; __pos < this->_M_len; ++__pos)
-	if (!traits_type::eq(this->_M_str[__pos], __c))
-	  return __pos;
-      return npos;
-    }
-
-  template<typename _CharT, typename _Traits>
-    /*constexpr*/ typename basic_string_view<_CharT, _Traits>::size_type
-    basic_string_view<_CharT, _Traits>::
-    find_last_not_of(const _CharT* __str, size_type __pos, size_type __n) const
-    {
-      gdb_assert (__str != nullptr || __n == 0);
-      size_type __size = this->_M_len;
-      if (__size)
-	{
-	  if (--__size > __pos)
-	    __size = __pos;
-	  do
-	    {
-	      if (!traits_type::find(__str, __n, this->_M_str[__size]))
-		return __size;
-	    }
-	  while (__size--);
-	}
-      return npos;
-    }
-
-  template<typename _CharT, typename _Traits>
-    /*constexpr*/ typename basic_string_view<_CharT, _Traits>::size_type
-    basic_string_view<_CharT, _Traits>::
-    find_last_not_of(_CharT __c, size_type __pos) const noexcept
-    {
-      size_type __size = this->_M_len;
-      if (__size)
-	{
-	  if (--__size > __pos)
-	    __size = __pos;
-	  do
-	    {
-	      if (!traits_type::eq(this->_M_str[__size], __c))
-		return __size;
-	    }
-	  while (__size--);
-	}
-      return npos;
-    }
-} // namespace gdb
-
-#endif // GDB_STRING_VIEW_TCC
-- 
2.34.1


^ permalink raw reply	[flat|nested] 39+ messages in thread

* [PATCH 09/11] gdbsupport: Replace gdb::invoke_result with std::invoke_result
  2023-10-13 14:44 [PATCH 00/11] GDB: Require C++17 Lancelot Six
                   ` (7 preceding siblings ...)
  2023-10-13 14:44 ` [PATCH 08/11] gdbsupport: Remove gdb::string_view Lancelot Six
@ 2023-10-13 14:44 ` Lancelot Six
  2023-10-13 14:44 ` [PATCH 10/11] gdb/disasm.h: Mark callbacks noexcept unconditionally Lancelot Six
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 39+ messages in thread
From: Lancelot Six @ 2023-10-13 14:44 UTC (permalink / raw)
  To: gdb-patches; +Cc: Lancelot Six

Given that GDB now requires C++17, we can replace gdb::invoke_result
with std::invoke_result which is provided by <type_traits>.

This patch also removes gdbsupport/invoke-result.h as it is not used
anymore.

Change-Id: I7e567356d38d6b3d85d8797d61cfc83f6f933f22
---
 gdbsupport/filtered-iterator.h |  4 ++--
 gdbsupport/function-view.h     |  4 ++--
 gdbsupport/invoke-result.h     | 37 ----------------------------------
 gdbsupport/parallel-for.h      |  9 ++++-----
 gdbsupport/safe-iterator.h     |  4 ++--
 5 files changed, 10 insertions(+), 48 deletions(-)
 delete mode 100644 gdbsupport/invoke-result.h

diff --git a/gdbsupport/filtered-iterator.h b/gdbsupport/filtered-iterator.h
index 9e9548ef824..aa3366942d1 100644
--- a/gdbsupport/filtered-iterator.h
+++ b/gdbsupport/filtered-iterator.h
@@ -19,7 +19,7 @@
 #ifndef COMMON_FILTERED_ITERATOR_H
 #define COMMON_FILTERED_ITERATOR_H
 
-#include "gdbsupport/invoke-result.h"
+#include <type_traits>
 
 /* A filtered iterator.  This wraps BaseIterator and automatically
    skips elements that FilterFunc filters out.  Requires that
@@ -56,7 +56,7 @@ class filtered_iterator
     : filtered_iterator (static_cast<const filtered_iterator &> (other))
   {}
 
-  typename gdb::invoke_result<decltype(&BaseIterator::operator*),
+  typename std::invoke_result<decltype(&BaseIterator::operator*),
 			      BaseIterator>::type
     operator* () const
   { return *m_it; }
diff --git a/gdbsupport/function-view.h b/gdbsupport/function-view.h
index cd62d40fd5e..ed113c74cfd 100644
--- a/gdbsupport/function-view.h
+++ b/gdbsupport/function-view.h
@@ -192,7 +192,7 @@
   You can find unit tests covering the whole API in
   unittests/function-view-selftests.c.  */
 
-#include "invoke-result.h"
+#include <type_traits>
 namespace gdb {
 
 namespace fv_detail {
@@ -230,7 +230,7 @@ class function_view<Res (Args...)>
   /* True if Func can be called with Args, and either the result is
      Res, convertible to Res or Res is void.  */
   template<typename Callable,
-	   typename Res2 = typename gdb::invoke_result<Callable &, Args...>::type>
+	   typename Res2 = typename std::invoke_result<Callable &, Args...>::type>
   struct IsCompatibleCallable : CompatibleReturnType<Res2, Res>
   {};
 
diff --git a/gdbsupport/invoke-result.h b/gdbsupport/invoke-result.h
deleted file mode 100644
index c9bb55e5b08..00000000000
--- a/gdbsupport/invoke-result.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/* Compatibility wrapper around std::result_of and std::invoke_result.
-
-   Copyright (C) 2022-2023 Free Software Foundation, Inc.
-
-   This file is part of GDB.
-
-   This program 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 of the License, or
-   (at your option) any later version.
-
-   This program 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.
-
-   You should have received a copy of the GNU General Public License
-   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
-
-#ifndef GDBSUPPORT_INVOKE_RESULT_H
-#define GDBSUPPORT_INVOKE_RESULT_H
-
-#include <type_traits>
-
-namespace gdb
-{
-#if __cplusplus >= 201703L
-template<typename Callable, class... Args>
-using invoke_result = std::invoke_result<Callable, Args...>;
-#else
-template<typename Callable, typename... Args>
-using invoke_result = std::result_of<Callable (Args...)>;
-#endif
-
-} /* namespace gdb */
-
-#endif /* GDBSUPPORT_INVOKE_RESULT_H */
diff --git a/gdbsupport/parallel-for.h b/gdbsupport/parallel-for.h
index b57f7ea97e1..ee7bfd948e2 100644
--- a/gdbsupport/parallel-for.h
+++ b/gdbsupport/parallel-for.h
@@ -22,7 +22,6 @@
 
 #include <algorithm>
 #include <type_traits>
-#include "gdbsupport/invoke-result.h"
 #include "gdbsupport/thread-pool.h"
 #include "gdbsupport/function-view.h"
 
@@ -145,14 +144,14 @@ struct par_for_accumulator<void>
 
 template<class RandomIt, class RangeFunction>
 typename gdb::detail::par_for_accumulator<
-    typename gdb::invoke_result<RangeFunction, RandomIt, RandomIt>::type
+    typename std::invoke_result<RangeFunction, RandomIt, RandomIt>::type
   >::result_type
 parallel_for_each (unsigned n, RandomIt first, RandomIt last,
 		   RangeFunction callback,
 		   gdb::function_view<size_t(RandomIt)> task_size = nullptr)
 {
   using result_type
-    = typename gdb::invoke_result<RangeFunction, RandomIt, RandomIt>::type;
+    = typename std::invoke_result<RangeFunction, RandomIt, RandomIt>::type;
 
   /* If enabled, print debug info about how the work is distributed across
      the threads.  */
@@ -305,13 +304,13 @@ parallel_for_each (unsigned n, RandomIt first, RandomIt last,
 
 template<class RandomIt, class RangeFunction>
 typename gdb::detail::par_for_accumulator<
-    typename gdb::invoke_result<RangeFunction, RandomIt, RandomIt>::type
+    typename std::invoke_result<RangeFunction, RandomIt, RandomIt>::type
   >::result_type
 sequential_for_each (unsigned n, RandomIt first, RandomIt last,
 		     RangeFunction callback,
 		     gdb::function_view<size_t(RandomIt)> task_size = nullptr)
 {
-  using result_type = typename gdb::invoke_result<RangeFunction, RandomIt, RandomIt>::type;
+  using result_type = typename std::invoke_result<RangeFunction, RandomIt, RandomIt>::type;
 
   gdb::detail::par_for_accumulator<result_type> results (0);
 
diff --git a/gdbsupport/safe-iterator.h b/gdbsupport/safe-iterator.h
index ccd772ca2a5..b4891328f1a 100644
--- a/gdbsupport/safe-iterator.h
+++ b/gdbsupport/safe-iterator.h
@@ -19,7 +19,7 @@
 #ifndef COMMON_SAFE_ITERATOR_H
 #define COMMON_SAFE_ITERATOR_H
 
-#include "gdbsupport/invoke-result.h"
+#include <type_traits>
 
 /* A forward iterator that wraps Iterator, such that when iterating
    with iterator IT, it is possible to delete *IT without invalidating
@@ -77,7 +77,7 @@ class basic_safe_iterator
   basic_safe_iterator ()
   {}
 
-  typename gdb::invoke_result<decltype(&Iterator::operator*), Iterator>::type
+  typename std::invoke_result<decltype(&Iterator::operator*), Iterator>::type
     operator* () const
   { return *m_it; }
 
-- 
2.34.1


^ permalink raw reply	[flat|nested] 39+ messages in thread

* [PATCH 10/11] gdb/disasm.h: Mark callbacks noexcept unconditionally
  2023-10-13 14:44 [PATCH 00/11] GDB: Require C++17 Lancelot Six
                   ` (8 preceding siblings ...)
  2023-10-13 14:44 ` [PATCH 09/11] gdbsupport: Replace gdb::invoke_result with std::invoke_result Lancelot Six
@ 2023-10-13 14:44 ` Lancelot Six
  2023-10-16 21:51   ` Pedro Alves
  2023-10-13 14:44 ` [PATCH 11/11] gdb: Use initializers in lambda captures unconditionally Lancelot Six
  2023-10-16 19:43 ` [PATCH 00/11] GDB: Require C++17 Tom Tromey
  11 siblings, 1 reply; 39+ messages in thread
From: Lancelot Six @ 2023-10-13 14:44 UTC (permalink / raw)
  To: gdb-patches; +Cc: Lancelot Six

Given that C+17 is now a requirement for GBD, update gdb/disasm.h to
define callback function types noexcept unconditionally.  The pre-C++17
configuration is not supported anymore.

Change-Id: I0a38e22b7912c70a11425363a991f0b01614343e
---
 gdb/disasm.h | 27 ++++++---------------------
 1 file changed, 6 insertions(+), 21 deletions(-)

diff --git a/gdb/disasm.h b/gdb/disasm.h
index 5596bd62a10..90fa1dfc02b 100644
--- a/gdb/disasm.h
+++ b/gdb/disasm.h
@@ -26,12 +26,6 @@ struct gdbarch;
 struct ui_out;
 struct ui_file;
 
-#if __cplusplus >= 201703L
-#define LIBOPCODE_CALLBACK_NOEXCEPT noexcept
-#else
-#define LIBOPCODE_CALLBACK_NOEXCEPT
-#endif
-
 /* A wrapper around a disassemble_info and a gdbarch.  This is the core
    set of data that all disassembler sub-classes will need.  This class
    doesn't actually implement the disassembling process, that is something
@@ -58,27 +52,18 @@ struct gdb_disassemble_info
 protected:
 
   /* Types for the function callbacks within m_di.  The actual function
-     signatures here are taken from include/dis-asm.h.  The noexcept macro
-     expands to 'noexcept' for C++17 and later, otherwise, it expands to
-     nothing.  This is because including noexcept was ignored for function
-     types before C++17, but both GCC and Clang warn that the noexcept
-     will become relevant when you switch to C++17, and this warning
-     causes the build to fail.  */
+     signatures here are taken from include/dis-asm.h.  */
   using read_memory_ftype
     = int (*) (bfd_vma, bfd_byte *, unsigned int, struct disassemble_info *)
-	LIBOPCODE_CALLBACK_NOEXCEPT;
+	noexcept;
   using memory_error_ftype
-    = void (*) (int, bfd_vma, struct disassemble_info *)
-	LIBOPCODE_CALLBACK_NOEXCEPT;
+    = void (*) (int, bfd_vma, struct disassemble_info *) noexcept;
   using print_address_ftype
-    = void (*) (bfd_vma, struct disassemble_info *)
-	LIBOPCODE_CALLBACK_NOEXCEPT;
+    = void (*) (bfd_vma, struct disassemble_info *) noexcept;
   using fprintf_ftype
-    = int (*) (void *, const char *, ...)
-	LIBOPCODE_CALLBACK_NOEXCEPT;
+    = int (*) (void *, const char *, ...) noexcept;
   using fprintf_styled_ftype
-    = int (*) (void *, enum disassembler_style, const char *, ...)
-	LIBOPCODE_CALLBACK_NOEXCEPT;
+    = int (*) (void *, enum disassembler_style, const char *, ...) noexcept;
 
   /* Constructor, many fields in m_di are initialized from GDBARCH.  The
      remaining arguments are function callbacks that are written into m_di.
-- 
2.34.1


^ permalink raw reply	[flat|nested] 39+ messages in thread

* [PATCH 11/11] gdb: Use initializers in lambda captures unconditionally
  2023-10-13 14:44 [PATCH 00/11] GDB: Require C++17 Lancelot Six
                   ` (9 preceding siblings ...)
  2023-10-13 14:44 ` [PATCH 10/11] gdb/disasm.h: Mark callbacks noexcept unconditionally Lancelot Six
@ 2023-10-13 14:44 ` Lancelot Six
  2023-10-16 19:43 ` [PATCH 00/11] GDB: Require C++17 Tom Tromey
  11 siblings, 0 replies; 39+ messages in thread
From: Lancelot Six @ 2023-10-13 14:44 UTC (permalink / raw)
  To: gdb-patches; +Cc: Lancelot Six

Initializers in lambda captures were introduced in C++14, and
conditionally used in gdb/cp-support.c and gdb/dwarf2/cooked-index.c.

Since C++17 is now required by GDB, use this feature unconditionally.

Change-Id: I87a3d567941e5c71217538fa75c952e4d421fa1d
---
 gdb/cp-support.c          | 8 +-------
 gdb/dwarf2/cooked-index.c | 7 +------
 2 files changed, 2 insertions(+), 13 deletions(-)

diff --git a/gdb/cp-support.c b/gdb/cp-support.c
index 579f09303c8..882acfb62a2 100644
--- a/gdb/cp-support.c
+++ b/gdb/cp-support.c
@@ -1658,13 +1658,7 @@ gdb_demangle (const char *name, int options)
 	     we might be in a background thread.  Instead, arrange for
 	     the reporting to happen on the main thread.  */
 	  std::string copy = name;
-	  run_on_main_thread ([
-#if __cplusplus >= 201402L
-			       =, copy = std::move (copy)
-#else
-			       =
-#endif
-			       ] ()
+	  run_on_main_thread ([=, copy = std::move (copy)] ()
 	    {
 	      report_failed_demangle (copy.c_str (), core_dump_allowed,
 				      crash_signal);
diff --git a/gdb/dwarf2/cooked-index.c b/gdb/dwarf2/cooked-index.c
index 7c4af3a1681..10631dccecf 100644
--- a/gdb/dwarf2/cooked-index.c
+++ b/gdb/dwarf2/cooked-index.c
@@ -466,12 +466,7 @@ cooked_index::start_writing_index (dwarf2_per_bfd *per_bfd)
      started, because it may call 'wait'.  */
   m_write_future
     = gdb::thread_pool::g_thread_pool->post_task ([this, per_bfd,
-#if __cplusplus >= 201402L
-						   ctx = std::move (ctx)
-#else
-						   ctx
-#endif
-						   ] ()
+						   ctx = std::move (ctx)] ()
 	{
 	  maybe_write_index (per_bfd, ctx);
 	});
-- 
2.34.1


^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH 02/11] gdb/gdbsupport/gdbserver: Require c++17
  2023-10-13 14:44 ` [PATCH 02/11] gdb/gdbsupport/gdbserver: Require c++17 Lancelot Six
@ 2023-10-13 15:21   ` Eli Zaretskii
  2023-10-16 21:50   ` Pedro Alves
  1 sibling, 0 replies; 39+ messages in thread
From: Eli Zaretskii @ 2023-10-13 15:21 UTC (permalink / raw)
  To: Lancelot Six; +Cc: gdb-patches

> From: Lancelot Six <lancelot.six@amd.com>
> CC: Lancelot Six <lancelot.six@amd.com>
> Date: Fri, 13 Oct 2023 14:44:09 +0000
> 
> This patch proposes to require a C++17 compiler to build gdb /
> gdbsupport / gdbserver.  Before this patch, GDB required a C++11
> compiler.
> 
> The general policy regarding bumping C++ language requirement in GDB (as
> stated in [1]) is:
> 
>     Our general policy is to wait until the oldest compiler that
>     supports C++NN is at least 3 years old.
> 
>     Rationale: We want to ensure reasonably widespread compiler
>     availability, to lower barrier of entry to GDB contributions, and to
>     make it easy for users to easily build new GDB on currently
>     supported stable distributions themselves. 3 years should be
>     sufficient for latest stable releases of distributions to include a
>     compiler for the standard, and/or for new compilers to appear as
>     easily installable optional packages. Requiring everyone to build a
>     compiler first before building GDB, which would happen if we
>     required a too-new compiler, would cause too much inconvenience.
> 
>     See the policy proposal and discussion
>     [here](https://sourceware.org/ml/gdb-patches/2016-10/msg00616.html).
> 
> The first GCC release which with full C++17 support is GCC-9[2],
> released in 2019[3], which is over 4 years ago.  Clang has had C++17
> support since Clang-5[4] released in 2018[5].
> 
> A discussions with many distros showed that a C++17-able compiler is
> always available, meaning that this no hard requirement preventing us to
> require it going forward.
> 
> [1] https://sourceware.org/gdb/wiki/Internals%20GDB-C-Coding-Standards#When_is_GDB_going_to_start_requiring_C.2B-.2B-NN_.3F
> [2] https://gcc.gnu.org/projects/cxx-status.html#cxx17
> [3] https://gcc.gnu.org/gcc-9/
> [4] https://clang.llvm.org/cxx_status.html
> [5] https://releases.llvm.org/
> 
> Change-Id: Id596f5db17ea346e8a978668825787b3a9a443fd
> ---
>  gdb/NEWS                |    3 +
>  gdb/config.in           |    4 +-
>  gdb/configure           | 1970 ++++++++++++++++++++++++++++++++++-----
>  gdb/configure.ac        |    4 +-
>  gdbserver/config.in     |    4 +-
>  gdbserver/configure     | 1970 ++++++++++++++++++++++++++++++++++-----
>  gdbserver/configure.ac  |    4 +-
>  gdbsupport/Makefile.in  |    2 +-
>  gdbsupport/config.in    |    4 +-
>  gdbsupport/configure    | 1970 ++++++++++++++++++++++++++++++++++-----
>  gdbsupport/configure.ac |    4 +-
>  11 files changed, 5212 insertions(+), 727 deletions(-)
> 
> diff --git a/gdb/NEWS b/gdb/NEWS
> index 81264c0cfb3..8ab2e4c593a 100644
> --- a/gdb/NEWS
> +++ b/gdb/NEWS
> @@ -3,6 +3,9 @@
>  
>  *** Changes since GDB 14
>  
> +* Building GDB and GDBserver now requires a C++17 compiler.
> +  For example, GCC 9 or later.
> +
>  * GDB index now contains information about the main function. This speeds up
>    startup when it is being used for some large binaries.

The NEWS part is okay, thanks.

Reviewed-By: Eli Zaretskii <eliz@gnu.org>

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH 06/11] gdb: Use std::string_view instead of gdb::string_view
  2023-10-13 14:44 ` [PATCH 06/11] gdb: Use std::string_view instead of gdb::string_view Lancelot Six
@ 2023-10-14 21:50   ` Tom Tromey
  2023-10-14 23:58     ` Six, Lancelot
  2023-10-16 15:06     ` Lancelot SIX
  0 siblings, 2 replies; 39+ messages in thread
From: Tom Tromey @ 2023-10-14 21:50 UTC (permalink / raw)
  To: Lancelot Six; +Cc: gdb-patches

>>>>> "Lancelot" == Lancelot Six <lancelot.six@amd.com> writes:

Lancelot> Given that GDB now requires a C++17, replace all uses of
Lancelot> gdb::string_view with std::string_view.

Lancelot> This change has mostly been done automatically:
Lancelot> - gdb::string_view -> std::string_view
Lancelot> - #include "gdbsupport/gdb_string_view.h" -> #include <string_view>

Lancelot> The implementation and tests of gdb::string_view are unchanged, they will
Lancelot> be removed in a following patch.

IIRC there are some spots using gdb::string_view that construct one with
nullptr, which isn't allowed by std::string_view.  Maybe a test run
using the libstdc++ debug mode would detect this?

Tom

^ permalink raw reply	[flat|nested] 39+ messages in thread

* RE: [PATCH 06/11] gdb: Use std::string_view instead of gdb::string_view
  2023-10-14 21:50   ` Tom Tromey
@ 2023-10-14 23:58     ` Six, Lancelot
  2023-10-16 15:06     ` Lancelot SIX
  1 sibling, 0 replies; 39+ messages in thread
From: Six, Lancelot @ 2023-10-14 23:58 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

[AMD Official Use Only - General]

> Lancelot> The implementation and tests of gdb::string_view are unchanged,
> they will
> Lancelot> be removed in a following patch.
>
> IIRC there are some spots using gdb::string_view that construct one with
> nullptr, which isn't allowed by std::string_view.  Maybe a test run
> using the libstdc++ debug mode would detect this?
>
> Tom

I was not aware of this. I'll do re-do regression testing using libstdc++'s debug mode.

Thanks,
Lancelot.

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH 06/11] gdb: Use std::string_view instead of gdb::string_view
  2023-10-14 21:50   ` Tom Tromey
  2023-10-14 23:58     ` Six, Lancelot
@ 2023-10-16 15:06     ` Lancelot SIX
  2023-10-16 19:35       ` Tom Tromey
  1 sibling, 1 reply; 39+ messages in thread
From: Lancelot SIX @ 2023-10-16 15:06 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches



On 14/10/2023 22:50, Tom Tromey wrote:
> Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.
> 
> 
>>>>>> "Lancelot" == Lancelot Six <lancelot.six@amd.com> writes:
> 
> Lancelot> Given that GDB now requires a C++17, replace all uses of
> Lancelot> gdb::string_view with std::string_view.
> 
> Lancelot> This change has mostly been done automatically:
> Lancelot> - gdb::string_view -> std::string_view
> Lancelot> - #include "gdbsupport/gdb_string_view.h" -> #include <string_view>
> 
> Lancelot> The implementation and tests of gdb::string_view are unchanged, they will
> Lancelot> be removed in a following patch.
> 
> IIRC there are some spots using gdb::string_view that construct one with
> nullptr, which isn't allowed by std::string_view.  Maybe a test run
> using the libstdc++ debug mode would detect this?
> 
> Tom

Hi,

It looks like libstdc++'s debug mode won't catch this, but this leads to 
a segfault on my system, so I am fairly confident with the testing.

That being said, I went through the patch again. I think one use can be 
a problem (but is not exercised by the testsuite), and one might be 
worth adding an assertion, just in case.  I have added the following 
locally and am extending the commit message.  It will be in a V2, but 
I'll wait for other comment (if any) before sending it.

Best,
Lancelot.

---
diff --git a/gdb/tui/tui-io.c b/gdb/tui/tui-io.c
index 83218dc4797..78bafec38ca 100644
--- a/gdb/tui/tui-io.c
+++ b/gdb/tui/tui-io.c
@@ -1197,7 +1197,10 @@ tui_getc_1 (FILE *fp)
          Compare keyname instead.  */
        if (ch >= KEY_MAX)
         {
-         auto name = std::string_view (keyname (ch));
+         std::string_view name;
+         if (const char *name_str = keyname (ch);
+             name_str != nullptr)
+           name = std::string_view (name_str);

           /* The following sequences are hardcoded in readline as
              well.  */
diff --git a/gdbsupport/format.h b/gdbsupport/format.h
index 5330bbe361e..26e327a60e8 100644
--- a/gdbsupport/format.h
+++ b/gdbsupport/format.h
@@ -56,6 +56,7 @@ struct format_piece
        argclass (argc),
        n_int_args (n)
    {
+    gdb_assert (str != nullptr);
    }

    bool operator== (const format_piece &other) const

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH 03/11] gdb: Use C++17's std::make_unique instead of gdb::make_unique
  2023-10-13 14:44 ` [PATCH 03/11] gdb: Use C++17's std::make_unique instead of gdb::make_unique Lancelot Six
@ 2023-10-16 19:14   ` Tom Tromey
  2023-10-17 14:02     ` Lancelot SIX
  0 siblings, 1 reply; 39+ messages in thread
From: Tom Tromey @ 2023-10-16 19:14 UTC (permalink / raw)
  To: Lancelot Six; +Cc: gdb-patches

>>>>> "Lancelot" == Lancelot Six <lancelot.six@amd.com> writes:

Lancelot> gdb::make_unique is a wrapper around std::make_unique when compiled with
Lancelot> C++17.  Now that C++17 is required, use std::make_unique directly in the
Lancelot> codebase, and remove gdb::make_unique.

Lancelot> +#include <memory>
 
I don't really understand why these includes are needed, since
gdb_unique_ptr.h includes <memory>, so presumably it's already visible
at every spot that's being touched.

Not sure it really matters, but I was curious.

Tom

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH 06/11] gdb: Use std::string_view instead of gdb::string_view
  2023-10-16 15:06     ` Lancelot SIX
@ 2023-10-16 19:35       ` Tom Tromey
  2023-10-16 21:51         ` Pedro Alves
  0 siblings, 1 reply; 39+ messages in thread
From: Tom Tromey @ 2023-10-16 19:35 UTC (permalink / raw)
  To: Lancelot SIX; +Cc: Tom Tromey, gdb-patches

>>>>> "Lancelot" == Lancelot SIX <Lancelot.Six@amd.com> writes:

Lancelot> +         std::string_view name;
Lancelot> +         if (const char *name_str = keyname (ch);
Lancelot> +             name_str != nullptr)

We should probably discuss whether to allow this construct before
letting it in.

Personally I'm ok with it.

Tom

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH 08/11] gdbsupport: Remove gdb::string_view
  2023-10-13 14:44 ` [PATCH 08/11] gdbsupport: Remove gdb::string_view Lancelot Six
@ 2023-10-16 19:38   ` Tom Tromey
  0 siblings, 0 replies; 39+ messages in thread
From: Tom Tromey @ 2023-10-16 19:38 UTC (permalink / raw)
  To: Lancelot Six; +Cc: gdb-patches

>>>>> "Lancelot" == Lancelot Six <lancelot.six@amd.com> writes:

Lancelot> Now that all places using gdb::string_view have been updated to use
Lancelot> std::string_view, this patch drops the gdb::string_view implementation
Lancelot> and the tests which came with it.

I think this fixes PR build/23676.

Tom

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH 00/11] GDB: Require C++17
  2023-10-13 14:44 [PATCH 00/11] GDB: Require C++17 Lancelot Six
                   ` (10 preceding siblings ...)
  2023-10-13 14:44 ` [PATCH 11/11] gdb: Use initializers in lambda captures unconditionally Lancelot Six
@ 2023-10-16 19:43 ` Tom Tromey
  2023-10-16 21:53   ` Pedro Alves
  11 siblings, 1 reply; 39+ messages in thread
From: Tom Tromey @ 2023-10-16 19:43 UTC (permalink / raw)
  To: Lancelot Six; +Cc: gdb-patches

>>>>> "Lancelot" == Lancelot Six <lancelot.six@amd.com> writes:

Lancelot> This series is a followup of the discussions from last Cauldron and Tom's
Lancelot> RFC patch[1] regarding requiring C++17 in GDB.  It seems that the
Lancelot> overall sentiment is positive for such move, so here is a proper series.

Hi.  I've sent a few minor comments, but otherwise everything looks good
to me.

Thank you for doing this.

Approved-By: Tom Tromey <tom@tromey.com>

I'm giving my approval but this should probably wait a little for others
to comment as well.


FWIW I have a follow-up series I'll send after testing is done.  I found
a number of other fairly straightforward C++17 changes.

Tom

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH 02/11] gdb/gdbsupport/gdbserver: Require c++17
  2023-10-13 14:44 ` [PATCH 02/11] gdb/gdbsupport/gdbserver: Require c++17 Lancelot Six
  2023-10-13 15:21   ` Eli Zaretskii
@ 2023-10-16 21:50   ` Pedro Alves
  1 sibling, 0 replies; 39+ messages in thread
From: Pedro Alves @ 2023-10-16 21:50 UTC (permalink / raw)
  To: Lancelot Six, gdb-patches

On 2023-10-13 15:44, Lancelot Six wrote:

> ---
>  gdb/NEWS                |    3 +
>  gdb/config.in           |    4 +-
>  gdb/configure           | 1970 ++++++++++++++++++++++++++++++++++-----
>  gdb/configure.ac        |    4 +-
>  gdbserver/config.in     |    4 +-
>  gdbserver/configure     | 1970 ++++++++++++++++++++++++++++++++++-----
>  gdbserver/configure.ac  |    4 +-
>  gdbsupport/Makefile.in  |    2 +-
>  gdbsupport/config.in    |    4 +-
>  gdbsupport/configure    | 1970 ++++++++++++++++++++++++++++++++++-----
>  gdbsupport/configure.ac |    4 +-


There's another spot that needs C++11 -> C++17 -- gdb/README:

 ...
    GDB requires a C++11 compiler.  If you do not have a
 C++11 compiler for your system, you may be able to download and install
 ...


^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH 06/11] gdb: Use std::string_view instead of gdb::string_view
  2023-10-16 19:35       ` Tom Tromey
@ 2023-10-16 21:51         ` Pedro Alves
  2023-10-17 14:13           ` Lancelot SIX
  0 siblings, 1 reply; 39+ messages in thread
From: Pedro Alves @ 2023-10-16 21:51 UTC (permalink / raw)
  To: Tom Tromey, Lancelot SIX; +Cc: gdb-patches

On 2023-10-16 20:35, Tom Tromey wrote:
>>>>>> "Lancelot" == Lancelot SIX <Lancelot.Six@amd.com> writes:
> 
> Lancelot> +         std::string_view name;
> Lancelot> +         if (const char *name_str = keyname (ch);
> Lancelot> +             name_str != nullptr)
> 
> We should probably discuss whether to allow this construct before
> letting it in.
> 
> Personally I'm ok with it.

I think it may look a little weird if you're not used to it (like I am not), but
OTOH it isn't really different from introducing a variable to scope with "for", like:

 for (const char *name_str = keyname (ch);
      name_str != nullptr; ....)
   ....

so I suspect we'll all just get used to it and think nothing of it in a few years.

So am I fine with it too.


^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH 10/11] gdb/disasm.h: Mark callbacks noexcept unconditionally
  2023-10-13 14:44 ` [PATCH 10/11] gdb/disasm.h: Mark callbacks noexcept unconditionally Lancelot Six
@ 2023-10-16 21:51   ` Pedro Alves
  0 siblings, 0 replies; 39+ messages in thread
From: Pedro Alves @ 2023-10-16 21:51 UTC (permalink / raw)
  To: Lancelot Six, gdb-patches

On 2023-10-13 15:44, Lancelot Six wrote:
> Given that C+17 is now a requirement for GBD, update gdb/disasm.h to define callback function types noexcept unconditionally. The pre-C++17 configuration is not supported anymore.

What is "GBD" ?? :-)


^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH 00/11] GDB: Require C++17
  2023-10-16 19:43 ` [PATCH 00/11] GDB: Require C++17 Tom Tromey
@ 2023-10-16 21:53   ` Pedro Alves
  2023-10-23 13:42     ` Lancelot SIX
  0 siblings, 1 reply; 39+ messages in thread
From: Pedro Alves @ 2023-10-16 21:53 UTC (permalink / raw)
  To: Tom Tromey, Lancelot Six; +Cc: gdb-patches

On 2023-10-16 20:43, Tom Tromey wrote:
>>>>>> "Lancelot" == Lancelot Six <lancelot.six@amd.com> writes:
> 
> Lancelot> This series is a followup of the discussions from last Cauldron and Tom's
> Lancelot> RFC patch[1] regarding requiring C++17 in GDB.  It seems that the
> Lancelot> overall sentiment is positive for such move, so here is a proper series.
> 
> Hi.  I've sent a few minor comments, but otherwise everything looks good
> to me.
> 
> Thank you for doing this.

Ditto.

> 
> Approved-By: Tom Tromey <tom@tromey.com>
> 
> I'm giving my approval but this should probably wait a little for others
> to comment as well.

and ditto here too.  You can add mine:

  Approved-By: Pedro Alves <pedro@palves.net>


^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH 03/11] gdb: Use C++17's std::make_unique instead of gdb::make_unique
  2023-10-16 19:14   ` Tom Tromey
@ 2023-10-17 14:02     ` Lancelot SIX
  0 siblings, 0 replies; 39+ messages in thread
From: Lancelot SIX @ 2023-10-17 14:02 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

> 
> Lancelot> +#include <memory>
> 
> I don't really understand why these includes are needed, since
> gdb_unique_ptr.h includes <memory>, so presumably it's already visible
> at every spot that's being touched.
> 
> Not sure it really matters, but I was curious.
> 
> Tom

Hi,

I don't think they are needed, given the transitive include.  I think 
I got them mostly out of habit of "make_unique" is provided by <memory>. 
  I'll drop those from the patch.

Thanks,
Lancelot.

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH 06/11] gdb: Use std::string_view instead of gdb::string_view
  2023-10-16 21:51         ` Pedro Alves
@ 2023-10-17 14:13           ` Lancelot SIX
  2023-10-17 14:20             ` Simon Marchi
  0 siblings, 1 reply; 39+ messages in thread
From: Lancelot SIX @ 2023-10-17 14:13 UTC (permalink / raw)
  To: Pedro Alves, Tom Tromey; +Cc: gdb-patches

Hi,

On 16/10/2023 22:51, Pedro Alves wrote:

>> Lancelot> +         std::string_view name;
>> Lancelot> +         if (const char *name_str = keyname (ch);
>> Lancelot> +             name_str != nullptr)
>>
>> We should probably discuss whether to allow this construct before
>> letting it in.
>>
>> Personally I'm ok with it.
> 
> I think it may look a little weird if you're not used to it (like I am not), but
> OTOH it isn't really different from introducing a variable to scope with "for", like:
> 
>   for (const char *name_str = keyname (ch);
>        name_str != nullptr; ....)
>     ....
> 
> so I suspect we'll all just get used to it and think nothing of it in a few years.
> 
> So am I fine with it too.
> 

I don't mind not using this for now.  The "name_str" will be declared 
outside of the if scope for now.

If this construct is comes in, there will also be the question of coding 
style (i.e. single line if line length permits or multiple lines as 
I did here).  I guess we could go the same way we do for "for" and 
prefer single line.

Best,
Lancelot.

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH 06/11] gdb: Use std::string_view instead of gdb::string_view
  2023-10-17 14:13           ` Lancelot SIX
@ 2023-10-17 14:20             ` Simon Marchi
  0 siblings, 0 replies; 39+ messages in thread
From: Simon Marchi @ 2023-10-17 14:20 UTC (permalink / raw)
  To: Lancelot SIX, Pedro Alves, Tom Tromey; +Cc: gdb-patches

On 10/17/23 10:13, Lancelot SIX wrote:
> Hi,
> 
> On 16/10/2023 22:51, Pedro Alves wrote:
> 
>>> Lancelot> +         std::string_view name;
>>> Lancelot> +         if (const char *name_str = keyname (ch);
>>> Lancelot> +             name_str != nullptr)
>>>
>>> We should probably discuss whether to allow this construct before
>>> letting it in.
>>>
>>> Personally I'm ok with it.
>>
>> I think it may look a little weird if you're not used to it (like I am not), but
>> OTOH it isn't really different from introducing a variable to scope with "for", like:
>>
>>   for (const char *name_str = keyname (ch);
>>        name_str != nullptr; ....)
>>     ....
>>
>> so I suspect we'll all just get used to it and think nothing of it in a few years.
>>
>> So am I fine with it too.
>>
> 
> I don't mind not using this for now.  The "name_str" will be declared outside of the if scope for now.
> 
> If this construct is comes in, there will also be the question of coding style (i.e. single line if line length permits or multiple lines as I did here).  I guess we could go the same way we do for "for" and prefer single line.

I didn't even know this construct existed, I was a bit shocked at first
:P.  But once you said "it's just like for", it looked just fine to me.

Declaring variables in the narrowest scope possible has its technical
merits, so I think we should allow that construct.  I think it's fine to
put it on one line if it fits.

Simon

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH 00/11] GDB: Require C++17
  2023-10-16 21:53   ` Pedro Alves
@ 2023-10-23 13:42     ` Lancelot SIX
  2023-10-28 20:48       ` Lancelot SIX
  0 siblings, 1 reply; 39+ messages in thread
From: Lancelot SIX @ 2023-10-23 13:42 UTC (permalink / raw)
  To: Pedro Alves, Tom Tromey; +Cc: gdb-patches


>> Lancelot> This series is a followup of the discussions from last Cauldron and Tom's
>> Lancelot> RFC patch[1] regarding requiring C++17 in GDB.  It seems that the
>> Lancelot> overall sentiment is positive for such move, so here is a proper series.
>>
>> Hi.  I've sent a few minor comments, but otherwise everything looks good
>> to me.
>>
>> Thank you for doing this.
> 
> Ditto.
> 
>>
>> Approved-By: Tom Tromey <tom@tromey.com>
>>
>> I'm giving my approval but this should probably wait a little for others
>> to comment as well.
> 
> and ditto here too.  You can add mine:
> 
>    Approved-By: Pedro Alves <pedro@palves.net>
> 

Hi all,

I think I'll wait until about the end of the week and will push the 
first 2 patches of the series.  This will make master require C++17 but 
not actually use C++17 yet.  I'll give a bit more time for the rest of 
the series, so if it causes problems to anyone, it is still easy to revert.

Best,
Lancelot.

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH 00/11] GDB: Require C++17
  2023-10-23 13:42     ` Lancelot SIX
@ 2023-10-28 20:48       ` Lancelot SIX
  2023-11-21 12:04         ` [COMMITTED PATCH v2 0/9] " Lancelot Six
                           ` (9 more replies)
  0 siblings, 10 replies; 39+ messages in thread
From: Lancelot SIX @ 2023-10-28 20:48 UTC (permalink / raw)
  To: Pedro Alves, Tom Tromey; +Cc: gdb-patches

On Mon, Oct 23, 2023 at 02:42:18PM +0100, Lancelot SIX wrote:
> 
> > > Lancelot> This series is a followup of the discussions from last Cauldron and Tom's
> > > Lancelot> RFC patch[1] regarding requiring C++17 in GDB.  It seems that the
> > > Lancelot> overall sentiment is positive for such move, so here is a proper series.
> > > 
> > > Hi.  I've sent a few minor comments, but otherwise everything looks good
> > > to me.
> > > 
> > > Thank you for doing this.
> > 
> > Ditto.
> > 
> > > 
> > > Approved-By: Tom Tromey <tom@tromey.com>
> > > 
> > > I'm giving my approval but this should probably wait a little for others
> > > to comment as well.
> > 
> > and ditto here too.  You can add mine:
> > 
> >    Approved-By: Pedro Alves <pedro@palves.net>
> > 
> 
> Hi all,
> 
> I think I'll wait until about the end of the week and will push the first 2
> patches of the series.  This will make master require C++17 but not actually
> use C++17 yet.  I'll give a bit more time for the rest of the series, so if
> it causes problems to anyone, it is still easy to revert.
> 
> Best,
> Lancelot.

Hi all,

I have pushed the first 2 patches of the series (including the missing
update in gdb/README):
- eb4de4047d8 gdb/ax_cxx_compile_stdcxx.m4: upgrade
- f74dc26792a gdb/gdbsupport/gdbserver: Require c++17

I'll wait a bit more before applying the rest of the series.  The intent
is to have a time-window where C++17 is required but not extensively
used so it is still "easy" to revert the change is someone strongly
objects to it.

I think I'll wait at least a week or two before considering pushing the
rest of the series.

Best,
Lancelot.

^ permalink raw reply	[flat|nested] 39+ messages in thread

* [COMMITTED PATCH v2 0/9] GDB: Require C++17
  2023-10-28 20:48       ` Lancelot SIX
@ 2023-11-21 12:04         ` Lancelot Six
  2023-11-21 12:04         ` [COMMITTED PATCH v2 1/9] gdb: Use C++17's std::make_unique instead of gdb::make_unique Lancelot Six
                           ` (8 subsequent siblings)
  9 siblings, 0 replies; 39+ messages in thread
From: Lancelot Six @ 2023-11-21 12:04 UTC (permalink / raw)
  To: gdb-patches; +Cc: pedro, tom, Lancelot Six

Hi all,

I have rebased, retested and pushed the remainder series on
x86_64-linux.  There have been minor adjustments during the rebase so
I am including a copy of the patches as committed.

All the best,
Lancelot.

Lancelot Six (9):
  gdb: Use C++17's std::make_unique instead of gdb::make_unique
  gdb: Replace gdb::optional with std::optional
  gdbsupport: remove gdb::optional
  gdb: Use std::string_view instead of gdb::string_view
  gdb: Remove uses of gdb::to_string (const std::string_view &)
  gdbsupport: Remove gdb::string_view
  gdbsupport: Replace gdb::invoke_result with std::invoke_result
  gdb/disasm.h: Mark callbacks noexcept unconditionally
  gdb: Use initializers in lambda captures unconditionally

 gdb/Makefile.in                               |   2 -
 gdb/aarch64-linux-tdep.c                      |  10 +-
 gdb/ada-lang.c                                |  34 +-
 gdb/ada-lex.l                                 |   2 +-
 gdb/ada-valprint.c                            |   4 +-
 gdb/addrmap.c                                 |   2 +-
 gdb/amd-dbgapi-target.c                       |   4 +-
 gdb/amdgpu-tdep.c                             |  68 +--
 gdb/annotate.c                                |   2 +-
 gdb/arm-fbsd-tdep.c                           |   6 +-
 gdb/arm-fbsd-tdep.h                           |   2 +-
 gdb/arm-linux-tdep.c                          |   2 +-
 gdb/arm-tdep.c                                |   4 +-
 gdb/auto-load.c                               |   2 +-
 gdb/auxv.c                                    |  10 +-
 gdb/auxv.h                                    |   4 +-
 gdb/avr-tdep.c                                |   2 +-
 gdb/break-catch-load.c                        |   2 +-
 gdb/breakpoint.c                              |  19 +-
 gdb/buildsym.c                                |   2 +-
 gdb/cli/cli-cmds.c                            |   6 +-
 gdb/cli/cli-cmds.h                            |   4 +-
 gdb/cli/cli-decode.c                          |   4 +-
 gdb/cli/cli-decode.h                          |   2 +-
 gdb/cli/cli-option.c                          |  14 +-
 gdb/cli/cli-option.h                          |   2 +-
 gdb/cli/cli-script.c                          |   4 +-
 gdb/command.h                                 |   2 +-
 gdb/compile/compile-c-support.c               |   2 +-
 gdb/compile/compile.c                         |   4 +-
 gdb/cp-name-parser.y                          |   2 +-
 gdb/cp-support.c                              |  10 +-
 gdb/darwin-nat.c                              |   2 +-
 gdb/dbxread.c                                 |  18 +-
 gdb/debuginfod-support.c                      |  19 +-
 gdb/disasm.c                                  |  14 +-
 gdb/disasm.h                                  |  29 +-
 gdb/dwarf2/attribute.h                        |   2 +-
 gdb/dwarf2/cooked-index.c                     |  13 +-
 gdb/dwarf2/cooked-index.h                     |   2 +-
 gdb/dwarf2/cu.h                               |   8 +-
 gdb/dwarf2/die.h                              |   4 +-
 gdb/dwarf2/frame.c                            |   2 +-
 gdb/dwarf2/index-cache.h                      |   2 +-
 gdb/dwarf2/index-common.c                     |   2 +-
 gdb/dwarf2/index-common.h                     |   2 +-
 gdb/dwarf2/index-write.c                      |   4 +-
 gdb/dwarf2/line-header.c                      |   4 +-
 gdb/dwarf2/macro.c                            |   4 +-
 gdb/dwarf2/macro.h                            |   2 +-
 gdb/dwarf2/read-debug-names.c                 |   2 +-
 gdb/dwarf2/read-gdb-index.c                   |   6 +-
 gdb/dwarf2/read.c                             |  30 +-
 gdb/dwarf2/read.h                             |   4 +-
 gdb/elfread.c                                 |   8 +-
 gdb/eval.c                                    |   2 +-
 gdb/event-top.c                               |   2 +-
 gdb/exceptions.c                              |   4 +-
 gdb/extension-priv.h                          |   6 +-
 gdb/extension.c                               |  12 +-
 gdb/extension.h                               |   8 +-
 gdb/f-lang.c                                  |   2 +-
 gdb/fbsd-nat.c                                |   6 +-
 gdb/fbsd-nat.h                                |   4 +-
 gdb/fbsd-tdep.c                               |   8 +-
 gdb/gdb_bfd.c                                 |   2 +-
 gdb/gdbthread.h                               |   8 +-
 gdb/gdbtypes.c                                |  20 +-
 gdb/gdbtypes.h                                |   8 +-
 gdb/guile/scm-ports.c                         |   4 +-
 gdb/ia64-tdep.c                               |   4 +-
 gdb/inf-child.c                               |   2 +-
 gdb/inf-child.h                               |   2 +-
 gdb/infcmd.c                                  |   4 +-
 gdb/inferior.c                                |   4 +-
 gdb/inferior.h                                |   2 +-
 gdb/inflow.c                                  |   4 +-
 gdb/infrun.c                                  |  12 +-
 gdb/interps.c                                 |   2 +-
 gdb/interps.h                                 |   4 +-
 gdb/jit.c                                     |   2 +-
 gdb/language.c                                |   2 +-
 gdb/linux-nat.c                               |  10 +-
 gdb/linux-nat.h                               |   2 +-
 gdb/linux-tdep.c                              |  26 +-
 gdb/linux-tdep.h                              |   4 +-
 gdb/linux-thread-db.c                         |   2 +-
 gdb/main.c                                    |   4 +-
 gdb/mdebugread.c                              |  18 +-
 gdb/mi/mi-cmd-stack.c                         |   4 +-
 gdb/mi/mi-cmd-var.c                           |   2 +-
 gdb/mi/mi-cmds.c                              |   2 +-
 gdb/mi/mi-cmds.h                              |   8 +-
 gdb/mi/mi-interp.c                            |   2 +-
 gdb/mi/mi-interp.h                            |   2 +-
 gdb/mi/mi-main.c                              |  14 +-
 gdb/mi/mi-out.c                               |   6 +-
 gdb/minsyms.c                                 |   4 +-
 gdb/minsyms.h                                 |   2 +-
 gdb/nat/linux-btrace.c                        |   4 +-
 gdb/nat/linux-osdata.c                        |   8 +-
 gdb/nat/windows-nat.c                         |   6 +-
 gdb/nat/windows-nat.h                         |   4 +-
 gdb/observable.h                              |   2 +-
 gdb/osdata.c                                  |   2 +-
 gdb/parse.c                                   |   4 +-
 gdb/ppc-linux-nat.c                           |   4 +-
 gdb/ppc-linux-tdep.c                          |   2 +-
 gdb/ppc-tdep.h                                |   2 +-
 gdb/printcmd.c                                |   6 +-
 gdb/probe.c                                   |  22 +-
 gdb/procfs.c                                  |   2 +-
 gdb/psymtab.c                                 |   4 +-
 gdb/psymtab.h                                 |   6 +-
 gdb/python/py-disasm.c                        |  22 +-
 gdb/python/py-framefilter.c                   |  10 +-
 gdb/python/py-inferior.c                      |   2 +-
 gdb/python/py-mi.c                            |   4 +-
 gdb/python/py-utils.c                         |   4 +-
 gdb/python/py-varobj.c                        |   2 +-
 gdb/python/python-internal.h                  |   4 +-
 gdb/python/python.c                           |   8 +-
 gdb/ravenscar-thread.c                        |   4 +-
 gdb/record-btrace.c                           |   8 +-
 gdb/regcache.c                                |   4 +-
 gdb/remote.c                                  |  16 +-
 gdb/riscv-tdep.c                              |   2 +-
 gdb/s390-linux-tdep.c                         |   2 +-
 gdb/skip.c                                    |   4 +-
 gdb/solib-aix.c                               |  16 +-
 gdb/solib-darwin.c                            |   2 +-
 gdb/solib-dsbt.c                              |   4 +-
 gdb/solib-frv.c                               |   2 +-
 gdb/solib-rocm.c                              |  32 +-
 gdb/solib-svr4.c                              |  24 +-
 gdb/solib-target.c                            |   2 +-
 gdb/source-cache.c                            |   2 +-
 gdb/split-name.c                              |   4 +-
 gdb/split-name.h                              |   4 +-
 gdb/stabsread.c                               |   2 +-
 gdb/stack.c                                   |  16 +-
 gdb/stack.h                                   |   2 +-
 gdb/symfile.c                                 |   2 +-
 gdb/symtab.c                                  |  38 +-
 gdb/symtab.h                                  |  38 +-
 gdb/target.c                                  |  16 +-
 gdb/target.h                                  |  10 +-
 gdb/thread.c                                  |  14 +-
 gdb/tracefile-tfile.c                         |   2 +-
 gdb/tracepoint.c                              |   2 +-
 gdb/tui/tui-disasm.c                          |   2 +-
 gdb/tui/tui-io.c                              |   5 +-
 gdb/tui/tui-layout.c                          |   2 +-
 gdb/tui/tui-win.c                             |   6 +-
 gdb/ui-out.c                                  |   4 +-
 gdb/unittests/basic_string_view/capacity/1.cc | 172 ------
 .../basic_string_view/capacity/empty_neg.cc   |  28 -
 .../basic_string_view/cons/char/1.cc          |  67 ---
 .../basic_string_view/cons/char/2.cc          |  46 --
 .../basic_string_view/cons/char/3.cc          |  39 --
 .../basic_string_view/cons/wchar_t/1.cc       |  68 ---
 .../basic_string_view/cons/wchar_t/2.cc       |  45 --
 .../basic_string_view/cons/wchar_t/3.cc       |  38 --
 .../element_access/char/1.cc                  |  70 ---
 .../element_access/char/2.cc                  |  30 -
 .../element_access/char/empty.cc              |  39 --
 .../element_access/char/front_back.cc         |  43 --
 .../element_access/wchar_t/1.cc               |  71 ---
 .../element_access/wchar_t/2.cc               |  32 -
 .../element_access/wchar_t/empty.cc           |  38 --
 .../element_access/wchar_t/front_back.cc      |  42 --
 gdb/unittests/basic_string_view/include.cc    |  25 -
 .../basic_string_view/inserters/char/1.cc     |  65 --
 .../basic_string_view/inserters/char/2.cc     |  91 ---
 .../basic_string_view/inserters/char/3.cc     |  54 --
 .../inserters/pod/10081-out.cc                |  75 ---
 .../basic_string_view/inserters/wchar_t/1.cc  |  70 ---
 .../basic_string_view/inserters/wchar_t/2.cc  |  91 ---
 .../basic_string_view/inserters/wchar_t/3.cc  |  53 --
 .../basic_string_view/literals/types.cc       |  45 --
 .../basic_string_view/literals/values.cc      |  72 ---
 .../modifiers/remove_prefix/char/1.cc         |  66 --
 .../modifiers/remove_prefix/wchar_t/1.cc      |  61 --
 .../modifiers/remove_suffix/char/1.cc         |  66 --
 .../modifiers/remove_suffix/wchar_t/1.cc      |  61 --
 .../modifiers/swap/char/1.cc                  |  36 --
 .../modifiers/swap/wchar_t/1.cc               |  35 --
 .../operations/compare/char/1.cc              | 132 ----
 .../operations/compare/char/13650.cc          |  50 --
 .../operations/compare/char/2.cc              |  30 -
 .../operations/compare/char/70483.cc          |  89 ---
 .../operations/compare/wchar_t/1.cc           | 133 ----
 .../operations/compare/wchar_t/13650.cc       |  49 --
 .../operations/compare/wchar_t/2.cc           |  30 -
 .../operations/copy/char/1.cc                 |  46 --
 .../operations/copy/wchar_t/1.cc              |  46 --
 .../operations/data/char/1.cc                 |  44 --
 .../operations/data/wchar_t/1.cc              |  43 --
 .../operations/find/char/1.cc                 | 168 ------
 .../operations/find/char/2.cc                 | 166 -----
 .../operations/find/char/3.cc                 | 166 -----
 .../operations/find/char/4.cc                 |  45 --
 .../operations/find/wchar_t/1.cc              | 163 -----
 .../operations/find/wchar_t/2.cc              | 161 -----
 .../operations/find/wchar_t/3.cc              | 161 -----
 .../operations/find/wchar_t/4.cc              |  44 --
 .../operations/rfind/char/1.cc                |  95 ---
 .../operations/rfind/char/2.cc                |  53 --
 .../operations/rfind/char/3.cc                |  68 ---
 .../operations/rfind/wchar_t/1.cc             |  94 ---
 .../operations/rfind/wchar_t/2.cc             |  52 --
 .../operations/rfind/wchar_t/3.cc             |  66 --
 .../operations/string_conversion/1.cc         |  51 --
 .../operations/substr/char/1.cc               |  79 ---
 .../operations/substr/wchar_t/1.cc            |  79 ---
 .../basic_string_view/operators/char/2.cc     | 373 ------------
 .../basic_string_view/operators/wchar_t/2.cc  | 367 ------------
 .../basic_string_view/range_access/char/1.cc  |  47 --
 .../range_access/wchar_t/1.cc                 |  47 --
 .../requirements/explicit_instantiation/1.cc  |  26 -
 .../explicit_instantiation/char/1.cc          |  23 -
 .../explicit_instantiation/char16_t/1.cc      |  24 -
 .../explicit_instantiation/char32_t/1.cc      |  24 -
 .../explicit_instantiation/wchar_t/1.cc       |  23 -
 .../requirements/typedefs.cc                  |  47 --
 gdb/unittests/basic_string_view/typedefs.cc   |  36 --
 gdb/unittests/basic_string_view/types/1.cc    |  43 --
 gdb/unittests/optional-selftests.c            |  95 ---
 gdb/unittests/optional/assignment/1.cc        | 196 ------
 gdb/unittests/optional/assignment/2.cc        | 194 ------
 gdb/unittests/optional/assignment/3.cc        | 157 -----
 gdb/unittests/optional/assignment/4.cc        | 157 -----
 gdb/unittests/optional/assignment/5.cc        |  81 ---
 gdb/unittests/optional/assignment/6.cc        |  91 ---
 gdb/unittests/optional/assignment/7.cc        |  30 -
 gdb/unittests/optional/cons/copy.cc           | 127 ----
 gdb/unittests/optional/cons/default.cc        |  59 --
 gdb/unittests/optional/cons/move.cc           | 125 ----
 gdb/unittests/optional/cons/value.cc          | 295 ---------
 gdb/unittests/optional/in_place.cc            |  66 --
 gdb/unittests/optional/observers/1.cc         |  32 -
 gdb/unittests/optional/observers/2.cc         |  36 --
 gdb/unittests/parallel-for-selftests.c        |   4 +-
 gdb/unittests/string_view-selftests.c         | 193 ------
 gdb/utils.c                                   |   6 +-
 gdb/valarith.c                                |   4 +-
 gdb/valops.c                                  |   6 +-
 gdb/value.c                                   |   2 +-
 gdb/value.h                                   |   4 +-
 gdb/varobj.c                                  |   2 +-
 gdb/windows-nat.c                             |  10 +-
 gdb/xcoffread.c                               |  18 +-
 gdb/xml-support.c                             |   4 +-
 gdb/xml-support.h                             |   6 +-
 gdb/xml-syscall.c                             |   2 +-
 gdb/xml-tdesc.c                               |  12 +-
 gdb/xml-tdesc.h                               |   4 +-
 gdbserver/linux-aarch64-low.cc                |   4 +-
 gdbserver/regcache.cc                         |   4 +-
 gdbserver/regcache.h                          |   2 +-
 gdbserver/win32-low.cc                        |   2 +-
 gdbsupport/common-debug.h                     |   4 +-
 gdbsupport/common-utils.h                     |   8 +-
 gdbsupport/event-loop.cc                      |   6 +-
 gdbsupport/filestuff.cc                       |   2 +-
 gdbsupport/filestuff.h                        |   2 +-
 gdbsupport/filtered-iterator.h                |   4 +-
 gdbsupport/format.h                           |   5 +-
 gdbsupport/forward-scope-exit.h               |   6 +-
 gdbsupport/function-view.h                    |   4 +-
 gdbsupport/gdb_optional.h                     | 233 -------
 gdbsupport/gdb_string_view.h                  | 566 ------------------
 gdbsupport/gdb_string_view.tcc                | 219 -------
 gdbsupport/gdb_unique_ptr.h                   |  13 -
 gdbsupport/invoke-result.h                    |  37 --
 gdbsupport/parallel-for.h                     |   9 +-
 gdbsupport/range-chain.h                      |   2 +-
 gdbsupport/safe-iterator.h                    |   4 +-
 gdbsupport/scoped_ignore_sigttou.h            |   2 +-
 gdbsupport/thread-pool.cc                     |   2 +-
 gdbsupport/thread-pool.h                      |   4 +-
 281 files changed, 617 insertions(+), 8963 deletions(-)
 delete mode 100644 gdb/unittests/basic_string_view/capacity/1.cc
 delete mode 100644 gdb/unittests/basic_string_view/capacity/empty_neg.cc
 delete mode 100644 gdb/unittests/basic_string_view/cons/char/1.cc
 delete mode 100644 gdb/unittests/basic_string_view/cons/char/2.cc
 delete mode 100644 gdb/unittests/basic_string_view/cons/char/3.cc
 delete mode 100644 gdb/unittests/basic_string_view/cons/wchar_t/1.cc
 delete mode 100644 gdb/unittests/basic_string_view/cons/wchar_t/2.cc
 delete mode 100644 gdb/unittests/basic_string_view/cons/wchar_t/3.cc
 delete mode 100644 gdb/unittests/basic_string_view/element_access/char/1.cc
 delete mode 100644 gdb/unittests/basic_string_view/element_access/char/2.cc
 delete mode 100644 gdb/unittests/basic_string_view/element_access/char/empty.cc
 delete mode 100644 gdb/unittests/basic_string_view/element_access/char/front_back.cc
 delete mode 100644 gdb/unittests/basic_string_view/element_access/wchar_t/1.cc
 delete mode 100644 gdb/unittests/basic_string_view/element_access/wchar_t/2.cc
 delete mode 100644 gdb/unittests/basic_string_view/element_access/wchar_t/empty.cc
 delete mode 100644 gdb/unittests/basic_string_view/element_access/wchar_t/front_back.cc
 delete mode 100644 gdb/unittests/basic_string_view/include.cc
 delete mode 100644 gdb/unittests/basic_string_view/inserters/char/1.cc
 delete mode 100644 gdb/unittests/basic_string_view/inserters/char/2.cc
 delete mode 100644 gdb/unittests/basic_string_view/inserters/char/3.cc
 delete mode 100644 gdb/unittests/basic_string_view/inserters/pod/10081-out.cc
 delete mode 100644 gdb/unittests/basic_string_view/inserters/wchar_t/1.cc
 delete mode 100644 gdb/unittests/basic_string_view/inserters/wchar_t/2.cc
 delete mode 100644 gdb/unittests/basic_string_view/inserters/wchar_t/3.cc
 delete mode 100644 gdb/unittests/basic_string_view/literals/types.cc
 delete mode 100644 gdb/unittests/basic_string_view/literals/values.cc
 delete mode 100644 gdb/unittests/basic_string_view/modifiers/remove_prefix/char/1.cc
 delete mode 100644 gdb/unittests/basic_string_view/modifiers/remove_prefix/wchar_t/1.cc
 delete mode 100644 gdb/unittests/basic_string_view/modifiers/remove_suffix/char/1.cc
 delete mode 100644 gdb/unittests/basic_string_view/modifiers/remove_suffix/wchar_t/1.cc
 delete mode 100644 gdb/unittests/basic_string_view/modifiers/swap/char/1.cc
 delete mode 100644 gdb/unittests/basic_string_view/modifiers/swap/wchar_t/1.cc
 delete mode 100644 gdb/unittests/basic_string_view/operations/compare/char/1.cc
 delete mode 100644 gdb/unittests/basic_string_view/operations/compare/char/13650.cc
 delete mode 100644 gdb/unittests/basic_string_view/operations/compare/char/2.cc
 delete mode 100644 gdb/unittests/basic_string_view/operations/compare/char/70483.cc
 delete mode 100644 gdb/unittests/basic_string_view/operations/compare/wchar_t/1.cc
 delete mode 100644 gdb/unittests/basic_string_view/operations/compare/wchar_t/13650.cc
 delete mode 100644 gdb/unittests/basic_string_view/operations/compare/wchar_t/2.cc
 delete mode 100644 gdb/unittests/basic_string_view/operations/copy/char/1.cc
 delete mode 100644 gdb/unittests/basic_string_view/operations/copy/wchar_t/1.cc
 delete mode 100644 gdb/unittests/basic_string_view/operations/data/char/1.cc
 delete mode 100644 gdb/unittests/basic_string_view/operations/data/wchar_t/1.cc
 delete mode 100644 gdb/unittests/basic_string_view/operations/find/char/1.cc
 delete mode 100644 gdb/unittests/basic_string_view/operations/find/char/2.cc
 delete mode 100644 gdb/unittests/basic_string_view/operations/find/char/3.cc
 delete mode 100644 gdb/unittests/basic_string_view/operations/find/char/4.cc
 delete mode 100644 gdb/unittests/basic_string_view/operations/find/wchar_t/1.cc
 delete mode 100644 gdb/unittests/basic_string_view/operations/find/wchar_t/2.cc
 delete mode 100644 gdb/unittests/basic_string_view/operations/find/wchar_t/3.cc
 delete mode 100644 gdb/unittests/basic_string_view/operations/find/wchar_t/4.cc
 delete mode 100644 gdb/unittests/basic_string_view/operations/rfind/char/1.cc
 delete mode 100644 gdb/unittests/basic_string_view/operations/rfind/char/2.cc
 delete mode 100644 gdb/unittests/basic_string_view/operations/rfind/char/3.cc
 delete mode 100644 gdb/unittests/basic_string_view/operations/rfind/wchar_t/1.cc
 delete mode 100644 gdb/unittests/basic_string_view/operations/rfind/wchar_t/2.cc
 delete mode 100644 gdb/unittests/basic_string_view/operations/rfind/wchar_t/3.cc
 delete mode 100644 gdb/unittests/basic_string_view/operations/string_conversion/1.cc
 delete mode 100644 gdb/unittests/basic_string_view/operations/substr/char/1.cc
 delete mode 100644 gdb/unittests/basic_string_view/operations/substr/wchar_t/1.cc
 delete mode 100644 gdb/unittests/basic_string_view/operators/char/2.cc
 delete mode 100644 gdb/unittests/basic_string_view/operators/wchar_t/2.cc
 delete mode 100644 gdb/unittests/basic_string_view/range_access/char/1.cc
 delete mode 100644 gdb/unittests/basic_string_view/range_access/wchar_t/1.cc
 delete mode 100644 gdb/unittests/basic_string_view/requirements/explicit_instantiation/1.cc
 delete mode 100644 gdb/unittests/basic_string_view/requirements/explicit_instantiation/char/1.cc
 delete mode 100644 gdb/unittests/basic_string_view/requirements/explicit_instantiation/char16_t/1.cc
 delete mode 100644 gdb/unittests/basic_string_view/requirements/explicit_instantiation/char32_t/1.cc
 delete mode 100644 gdb/unittests/basic_string_view/requirements/explicit_instantiation/wchar_t/1.cc
 delete mode 100644 gdb/unittests/basic_string_view/requirements/typedefs.cc
 delete mode 100644 gdb/unittests/basic_string_view/typedefs.cc
 delete mode 100644 gdb/unittests/basic_string_view/types/1.cc
 delete mode 100644 gdb/unittests/optional-selftests.c
 delete mode 100644 gdb/unittests/optional/assignment/1.cc
 delete mode 100644 gdb/unittests/optional/assignment/2.cc
 delete mode 100644 gdb/unittests/optional/assignment/3.cc
 delete mode 100644 gdb/unittests/optional/assignment/4.cc
 delete mode 100644 gdb/unittests/optional/assignment/5.cc
 delete mode 100644 gdb/unittests/optional/assignment/6.cc
 delete mode 100644 gdb/unittests/optional/assignment/7.cc
 delete mode 100644 gdb/unittests/optional/cons/copy.cc
 delete mode 100644 gdb/unittests/optional/cons/default.cc
 delete mode 100644 gdb/unittests/optional/cons/move.cc
 delete mode 100644 gdb/unittests/optional/cons/value.cc
 delete mode 100644 gdb/unittests/optional/in_place.cc
 delete mode 100644 gdb/unittests/optional/observers/1.cc
 delete mode 100644 gdb/unittests/optional/observers/2.cc
 delete mode 100644 gdb/unittests/string_view-selftests.c
 delete mode 100644 gdbsupport/gdb_optional.h
 delete mode 100644 gdbsupport/gdb_string_view.h
 delete mode 100644 gdbsupport/gdb_string_view.tcc
 delete mode 100644 gdbsupport/invoke-result.h

-- 
2.34.1


^ permalink raw reply	[flat|nested] 39+ messages in thread

* [COMMITTED PATCH v2 1/9] gdb: Use C++17's std::make_unique instead of gdb::make_unique
  2023-10-28 20:48       ` Lancelot SIX
  2023-11-21 12:04         ` [COMMITTED PATCH v2 0/9] " Lancelot Six
@ 2023-11-21 12:04         ` Lancelot Six
  2023-11-21 12:04         ` [COMMITTED PATCH v2 2/9] gdb: Replace gdb::optional with std::optional Lancelot Six
                           ` (7 subsequent siblings)
  9 siblings, 0 replies; 39+ messages in thread
From: Lancelot Six @ 2023-11-21 12:04 UTC (permalink / raw)
  To: gdb-patches; +Cc: pedro, tom, Lancelot Six

gdb::make_unique is a wrapper around std::make_unique when compiled with
C++17.  Now that C++17 is required, use std::make_unique directly in the
codebase, and remove gdb::make_unique.

Change-Id: I80b615e46e4b7c097f09d78e579a9bdce00254ab
Approved-By: Tom Tromey <tom@tromey.com>
Approved-By: Pedro Alves <pedro@palves.net
---
 gdb/addrmap.c                          |  2 +-
 gdb/break-catch-load.c                 |  2 +-
 gdb/compile/compile-c-support.c        |  2 +-
 gdb/cp-name-parser.y                   |  2 +-
 gdb/cp-support.c                       |  2 +-
 gdb/dwarf2/frame.c                     |  2 +-
 gdb/dwarf2/read-debug-names.c          |  2 +-
 gdb/dwarf2/read-gdb-index.c            |  2 +-
 gdb/dwarf2/read.c                      |  2 +-
 gdb/gdb_bfd.c                          |  2 +-
 gdb/gdbtypes.c                         |  2 +-
 gdb/mi/mi-main.c                       |  2 +-
 gdb/mi/mi-out.c                        |  6 +++---
 gdb/nat/linux-btrace.c                 |  4 ++--
 gdb/python/py-mi.c                     |  2 +-
 gdb/python/py-varobj.c                 |  2 +-
 gdb/solib-aix.c                        |  2 +-
 gdb/solib-darwin.c                     |  2 +-
 gdb/solib-dsbt.c                       |  2 +-
 gdb/solib-frv.c                        |  2 +-
 gdb/solib-rocm.c                       |  4 ++--
 gdb/solib-svr4.c                       |  8 ++++----
 gdb/ui-out.c                           |  4 ++--
 gdb/unittests/parallel-for-selftests.c |  4 ++--
 gdb/varobj.c                           |  2 +-
 gdbsupport/gdb_unique_ptr.h            | 13 -------------
 26 files changed, 34 insertions(+), 47 deletions(-)

diff --git a/gdb/addrmap.c b/gdb/addrmap.c
index d16775d49d4..076062a0206 100644
--- a/gdb/addrmap.c
+++ b/gdb/addrmap.c
@@ -428,7 +428,7 @@ test_addrmap ()
 
   /* Create mutable addrmap.  */
   auto_obstack temp_obstack;
-  auto map = gdb::make_unique<struct addrmap_mutable> ();
+  auto map = std::make_unique<struct addrmap_mutable> ();
   SELF_CHECK (map != nullptr);
 
   /* Check initial state.  */
diff --git a/gdb/break-catch-load.c b/gdb/break-catch-load.c
index 02a98b5d30a..dbf70d8f204 100644
--- a/gdb/break-catch-load.c
+++ b/gdb/break-catch-load.c
@@ -230,7 +230,7 @@ add_solib_catchpoint (const char *arg, bool is_load, bool is_temp, bool enabled)
   if (*arg == '\0')
     arg = nullptr;
 
-  auto c = gdb::make_unique<solib_catchpoint> (gdbarch, is_temp, nullptr,
+  auto c = std::make_unique<solib_catchpoint> (gdbarch, is_temp, nullptr,
 					       is_load, arg);
 
   c->enable_state = enabled ? bp_enabled : bp_disabled;
diff --git a/gdb/compile/compile-c-support.c b/gdb/compile/compile-c-support.c
index 53b7285b366..3a3e4d21136 100644
--- a/gdb/compile/compile-c-support.c
+++ b/gdb/compile/compile-c-support.c
@@ -118,7 +118,7 @@ get_compile_context (const char *fe_libcc, const char *fe_context,
     error (_("The loaded version of GCC does not support the required version "
 	     "of the API."));
 
-  return gdb::make_unique<INSTTYPE> (context);
+  return std::make_unique<INSTTYPE> (context);
 }
 
 /* A C-language implementation of get_compile_context.  */
diff --git a/gdb/cp-name-parser.y b/gdb/cp-name-parser.y
index 324166a03ff..e6c8c4c09a9 100644
--- a/gdb/cp-name-parser.y
+++ b/gdb/cp-name-parser.y
@@ -2038,7 +2038,7 @@ cp_demangled_name_to_comp (const char *demangled_name,
 
   state.demangle_info = allocate_info ();
 
-  auto result = gdb::make_unique<demangle_parse_info> ();
+  auto result = std::make_unique<demangle_parse_info> ();
   result->info = state.demangle_info;
 
   if (yyparse (&state))
diff --git a/gdb/cp-support.c b/gdb/cp-support.c
index e02e859b99a..834c4774755 100644
--- a/gdb/cp-support.c
+++ b/gdb/cp-support.c
@@ -675,7 +675,7 @@ mangled_name_to_comp (const char *mangled_name, int options,
 					      options, memory);
       if (ret)
 	{
-	  auto info = gdb::make_unique<demangle_parse_info> ();
+	  auto info = std::make_unique<demangle_parse_info> ();
 	  info->tree = ret;
 	  *demangled_p = NULL;
 	  return info;
diff --git a/gdb/dwarf2/frame.c b/gdb/dwarf2/frame.c
index abc8d613482..d72dd0ad971 100644
--- a/gdb/dwarf2/frame.c
+++ b/gdb/dwarf2/frame.c
@@ -2126,7 +2126,7 @@ dwarf2_build_frame_info (struct objfile *objfile)
   struct gdbarch *gdbarch = objfile->arch ();
 
   /* Build a minimal decoding of the DWARF2 compilation unit.  */
-  auto unit = gdb::make_unique<comp_unit> (objfile);
+  auto unit = std::make_unique<comp_unit> (objfile);
 
   if (objfile->separate_debug_objfile_backlink == NULL)
     {
diff --git a/gdb/dwarf2/read-debug-names.c b/gdb/dwarf2/read-debug-names.c
index c1b62b38f93..78e0df27314 100644
--- a/gdb/dwarf2/read-debug-names.c
+++ b/gdb/dwarf2/read-debug-names.c
@@ -464,7 +464,7 @@ create_cus_from_debug_names (dwarf2_per_bfd *per_bfd,
 bool
 dwarf2_read_debug_names (dwarf2_per_objfile *per_objfile)
 {
-  auto map = gdb::make_unique<mapped_debug_names> ();
+  auto map = std::make_unique<mapped_debug_names> ();
   mapped_debug_names dwz_map;
   struct objfile *objfile = per_objfile->objfile;
   dwarf2_per_bfd *per_bfd = per_objfile->per_bfd;
diff --git a/gdb/dwarf2/read-gdb-index.c b/gdb/dwarf2/read-gdb-index.c
index e789e9c2654..064a9f17b0e 100644
--- a/gdb/dwarf2/read-gdb-index.c
+++ b/gdb/dwarf2/read-gdb-index.c
@@ -828,7 +828,7 @@ dwarf2_read_gdb_index
   if (main_index_contents.empty ())
     return 0;
 
-  auto map = gdb::make_unique<mapped_gdb_index> ();
+  auto map = std::make_unique<mapped_gdb_index> ();
   if (!read_gdb_index_from_buffer (objfile_name (objfile),
 				   use_deprecated_index_sections,
 				   main_index_contents, map.get (), &cu_list,
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index e8ff4d8f29a..2a7fd8f5de5 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -4372,7 +4372,7 @@ allocate_type_unit_groups_table ()
 static std::unique_ptr<type_unit_group>
 create_type_unit_group (struct dwarf2_cu *cu, sect_offset line_offset_struct)
 {
-  auto tu_group = gdb::make_unique<type_unit_group> ();
+  auto tu_group = std::make_unique<type_unit_group> ();
 
   tu_group->hash.dwo_unit = cu->dwo_unit;
   tu_group->hash.line_sect_off = line_offset_struct;
diff --git a/gdb/gdb_bfd.c b/gdb/gdb_bfd.c
index 56a4c5ecc91..b72821f4c35 100644
--- a/gdb/gdb_bfd.c
+++ b/gdb/gdb_bfd.c
@@ -303,7 +303,7 @@ gdb_bfd_open_from_target_memory (CORE_ADDR addr, ULONGEST size,
 				 const char *target)
 {
   std::unique_ptr<target_buffer> buffer
-    = gdb::make_unique<target_buffer> (addr, size);
+    = std::make_unique<target_buffer> (addr, size);
 
   return gdb_bfd_openr_iovec (buffer->filename (), target,
 			      [&] (bfd *nbfd)
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index 7011fddd695..e424077c1c0 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -5833,7 +5833,7 @@ static const struct registry<objfile>::key<fixed_point_type_storage>
 void
 allocate_fixed_point_type_info (struct type *type)
 {
-  auto up = gdb::make_unique<fixed_point_type_info> ();
+  auto up = std::make_unique<fixed_point_type_info> ();
   fixed_point_type_info *info;
 
   if (type->is_objfile_owned ())
diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c
index abcd0d392ba..14ed2a1fae9 100644
--- a/gdb/mi/mi-main.c
+++ b/gdb/mi/mi-main.c
@@ -1932,7 +1932,7 @@ mi_execute_command (const char *cmd, int from_tty)
     = gdb::checked_static_cast<mi_interp *> (command_interp ());
   try
     {
-      command = gdb::make_unique<mi_parse> (cmd, &token);
+      command = std::make_unique<mi_parse> (cmd, &token);
     }
   catch (const gdb_exception &exception)
     {
diff --git a/gdb/mi/mi-out.c b/gdb/mi/mi-out.c
index bbd21287b28..0bc13f963bc 100644
--- a/gdb/mi/mi-out.c
+++ b/gdb/mi/mi-out.c
@@ -340,13 +340,13 @@ std::unique_ptr<mi_ui_out>
 mi_out_new (const char *mi_version)
 {
   if (streq (mi_version, INTERP_MI4) ||  streq (mi_version, INTERP_MI))
-    return gdb::make_unique<mi_ui_out> (4);
+    return std::make_unique<mi_ui_out> (4);
 
   if (streq (mi_version, INTERP_MI3))
-    return gdb::make_unique<mi_ui_out> (3);
+    return std::make_unique<mi_ui_out> (3);
 
   if (streq (mi_version, INTERP_MI2))
-    return gdb::make_unique<mi_ui_out> (2);
+    return std::make_unique<mi_ui_out> (2);
 
   return nullptr;
 }
diff --git a/gdb/nat/linux-btrace.c b/gdb/nat/linux-btrace.c
index 3c217daa488..c0cebbb2f02 100644
--- a/gdb/nat/linux-btrace.c
+++ b/gdb/nat/linux-btrace.c
@@ -468,7 +468,7 @@ linux_enable_bts (ptid_t ptid, const struct btrace_config_bts *conf)
     error (_("BTS support has been disabled for the target cpu."));
 
   std::unique_ptr<linux_btrace_target_info> tinfo
-    { gdb::make_unique<linux_btrace_target_info> (ptid) };
+    { std::make_unique<linux_btrace_target_info> (ptid) };
 
   tinfo->conf.format = BTRACE_FORMAT_BTS;
 
@@ -617,7 +617,7 @@ linux_enable_pt (ptid_t ptid, const struct btrace_config_pt *conf)
     pid = ptid.pid ();
 
   std::unique_ptr<linux_btrace_target_info> tinfo
-    { gdb::make_unique<linux_btrace_target_info> (ptid) };
+    { std::make_unique<linux_btrace_target_info> (ptid) };
 
   tinfo->conf.format = BTRACE_FORMAT_PT;
 
diff --git a/gdb/python/py-mi.c b/gdb/python/py-mi.c
index a7b4f4fa3cf..aaa225da95e 100644
--- a/gdb/python/py-mi.c
+++ b/gdb/python/py-mi.c
@@ -290,7 +290,7 @@ gdbpy_execute_mi_command (PyObject *self, PyObject *args, PyObject *kw)
   try
     {
       scoped_restore save_uiout = make_scoped_restore (&current_uiout, &uiout);
-      auto parser = gdb::make_unique<mi_parse> (std::move (mi_command),
+      auto parser = std::make_unique<mi_parse> (std::move (mi_command),
 						std::move (arg_strings));
       mi_execute_command (parser.get ());
     }
diff --git a/gdb/python/py-varobj.c b/gdb/python/py-varobj.c
index 98603cec009..3401cf294ac 100644
--- a/gdb/python/py-varobj.c
+++ b/gdb/python/py-varobj.c
@@ -170,5 +170,5 @@ py_varobj_get_iterator (struct varobj *var, PyObject *printer,
       error (_("Could not get children iterator"));
     }
 
-  return gdb::make_unique<py_varobj_iter> (var, std::move (iter), opts);
+  return std::make_unique<py_varobj_iter> (var, std::move (iter), opts);
 }
diff --git a/gdb/solib-aix.c b/gdb/solib-aix.c
index c8fa865f49d..0fc3a153973 100644
--- a/gdb/solib-aix.c
+++ b/gdb/solib-aix.c
@@ -484,7 +484,7 @@ solib_aix_current_sos ()
 
       new_solib->so_original_name = so_name;
       new_solib->so_name = so_name;
-      new_solib->lm_info = gdb::make_unique<lm_info_aix> (info);
+      new_solib->lm_info = std::make_unique<lm_info_aix> (info);
 
       /* Add it to the list.  */
       sos.push_back (*new_solib);
diff --git a/gdb/solib-darwin.c b/gdb/solib-darwin.c
index c18791cd7c2..4819afe8863 100644
--- a/gdb/solib-darwin.c
+++ b/gdb/solib-darwin.c
@@ -274,7 +274,7 @@ darwin_current_sos ()
       /* Create and fill the new struct shobj element.  */
       shobj *newobj = new shobj;
 
-      auto li = gdb::make_unique<lm_info_darwin> ();
+      auto li = std::make_unique<lm_info_darwin> ();
 
       newobj->so_name = file_path.get ();
       newobj->so_original_name = newobj->so_name;
diff --git a/gdb/solib-dsbt.c b/gdb/solib-dsbt.c
index 65bb6251a0e..ef561466945 100644
--- a/gdb/solib-dsbt.c
+++ b/gdb/solib-dsbt.c
@@ -594,7 +594,7 @@ dsbt_current_sos (void)
 	    }
 
 	  shobj *sop = new shobj;
-	  auto li = gdb::make_unique<lm_info_dsbt> ();
+	  auto li = std::make_unique<lm_info_dsbt> ();
 	  li->map = loadmap;
 	  /* Fetch the name.  */
 	  addr = extract_unsigned_integer (lm_buf.l_name,
diff --git a/gdb/solib-frv.c b/gdb/solib-frv.c
index 0897bce2325..7ca28982638 100644
--- a/gdb/solib-frv.c
+++ b/gdb/solib-frv.c
@@ -377,7 +377,7 @@ frv_current_sos ()
 	    }
 
 	  shobj *sop = new shobj;
-	  auto li = gdb::make_unique<lm_info_frv> ();
+	  auto li = std::make_unique<lm_info_frv> ();
 	  li->map = loadmap;
 	  li->got_value = got_addr;
 	  li->lm_addr = lm_addr;
diff --git a/gdb/solib-rocm.c b/gdb/solib-rocm.c
index 3a971b3361e..cf56a81a2ee 100644
--- a/gdb/solib-rocm.c
+++ b/gdb/solib-rocm.c
@@ -212,7 +212,7 @@ so_list_from_rocm_sos (const std::vector<rocm_so> &sos)
   for (const rocm_so &so : sos)
     {
       struct shobj *newobj = new struct shobj;
-      newobj->lm_info = gdb::make_unique<lm_info_svr4> (*so.lm_info);
+      newobj->lm_info = std::make_unique<lm_info_svr4> (*so.lm_info);
 
       newobj->so_name = so.name;
       newobj->so_original_name = so.unique_name;
@@ -725,7 +725,7 @@ rocm_update_solib_list ()
 
       gdb::unique_xmalloc_ptr<char> uri_bytes_holder (uri_bytes);
 
-      lm_info_svr4_up li = gdb::make_unique<lm_info_svr4> ();
+      lm_info_svr4_up li = std::make_unique<lm_info_svr4> ();
       li->l_addr = l_addr;
 
       /* Generate a unique name so that code objects with the same URI but
diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c
index 8a5ad590f6f..5882a4e0070 100644
--- a/gdb/solib-svr4.c
+++ b/gdb/solib-svr4.c
@@ -213,7 +213,7 @@ lm_info_read (CORE_ADDR lm_addr)
       type *ptr_type
 	= builtin_type (current_inferior ()->arch ())->builtin_data_ptr;
 
-      lm_info = gdb::make_unique<lm_info_svr4> ();
+      lm_info = std::make_unique<lm_info_svr4> ();
       lm_info->lm_addr = lm_addr;
 
       lm_info->l_addr_inferior = extract_typed_address (&lm[lmo->l_addr_offset],
@@ -1001,7 +1001,7 @@ so_list_from_svr4_sos (const std::vector<svr4_so> &sos)
 
       newobj->so_name = so.name;
       newobj->so_original_name = so.name;
-      newobj->lm_info = gdb::make_unique<lm_info_svr4> (*so.lm_info);
+      newobj->lm_info = std::make_unique<lm_info_svr4> (*so.lm_info);
 
       dst.push_back (*newobj);
     }
@@ -1032,7 +1032,7 @@ library_list_start_library (struct gdb_xml_parser *parser,
   ULONGEST *l_ldp
     = (ULONGEST *) xml_find_attribute (attributes, "l_ld")->value.get ();
 
-  lm_info_svr4_up li = gdb::make_unique<lm_info_svr4> ();
+  lm_info_svr4_up li = std::make_unique<lm_info_svr4> ();
   li->lm_addr = *lmp;
   li->l_addr_inferior = *l_addrp;
   li->l_ld = *l_ldp;
@@ -1190,7 +1190,7 @@ svr4_default_sos (svr4_info *info)
     return {};
 
   shobj *newobj = new shobj;
-  auto li = gdb::make_unique<lm_info_svr4> ();
+  auto li = std::make_unique<lm_info_svr4> ();
 
   /* Nothing will ever check the other fields if we set l_addr_p.  */
   li->l_addr = li->l_addr_inferior = info->debug_loader_offset;
diff --git a/gdb/ui-out.c b/gdb/ui-out.c
index defa8f9dfa4..e8653c6c127 100644
--- a/gdb/ui-out.c
+++ b/gdb/ui-out.c
@@ -236,7 +236,7 @@ void ui_out_table::append_header (int width, ui_align alignment,
     internal_error (_("table header must be specified after table_begin and "
 		      "before table_body."));
 
-  auto header = gdb::make_unique<ui_out_hdr> (m_headers.size () + 1,
+  auto header = std::make_unique<ui_out_hdr> (m_headers.size () + 1,
 					      width, alignment,
 					      col_name, col_hdr);
 
@@ -328,7 +328,7 @@ ui_out::current_level () const
 void
 ui_out::push_level (ui_out_type type)
 {
-  auto level = gdb::make_unique<ui_out_level> (type);
+  auto level = std::make_unique<ui_out_level> (type);
 
   m_levels.push_back (std::move (level));
 }
diff --git a/gdb/unittests/parallel-for-selftests.c b/gdb/unittests/parallel-for-selftests.c
index 1ad7eaa701c..63e9512ea18 100644
--- a/gdb/unittests/parallel-for-selftests.c
+++ b/gdb/unittests/parallel-for-selftests.c
@@ -160,7 +160,7 @@ TEST (int n_threads)
 	      {
 		if (start == end)
 		  any_empty_tasks = true;
-		return gdb::make_unique<int> (end - start);
+		return std::make_unique<int> (end - start);
 	      });
   SELF_CHECK (!any_empty_tasks);
   SELF_CHECK (std::all_of (intresults.begin (),
@@ -178,7 +178,7 @@ TEST (int n_threads)
 	      {
 		if (start == end)
 		  any_empty_tasks = true;
-		return gdb::make_unique<int> (end - start);
+		return std::make_unique<int> (end - start);
 	      },
 	    task_size_one);
   SELF_CHECK (!any_empty_tasks);
diff --git a/gdb/varobj.c b/gdb/varobj.c
index a4fcbffc311..4ea8d0fd9b3 100644
--- a/gdb/varobj.c
+++ b/gdb/varobj.c
@@ -259,7 +259,7 @@ varobj_create (const char *objname,
 	       const char *expression, CORE_ADDR frame, enum varobj_type type)
 {
   /* Fill out a varobj structure for the (root) variable being constructed.  */
-  auto var = gdb::make_unique<varobj> (new varobj_root);
+  auto var = std::make_unique<varobj> (new varobj_root);
 
   if (expression != NULL)
     {
diff --git a/gdbsupport/gdb_unique_ptr.h b/gdbsupport/gdb_unique_ptr.h
index 2b6c0ce3d53..3bef6ff34d6 100644
--- a/gdbsupport/gdb_unique_ptr.h
+++ b/gdbsupport/gdb_unique_ptr.h
@@ -56,19 +56,6 @@ struct noop_deleter
   void operator() (T *ptr) const { }
 };
 
-/* Create simple std::unique_ptr<T> objects.  */
-
-template<typename T, typename... Arg>
-std::unique_ptr<T>
-make_unique (Arg &&...args)
-{
-#if __cplusplus >= 201402L
-  return std::make_unique<T> (std::forward<Arg> (args)...);
-#else
-  return std::unique_ptr<T> (new T (std::forward<Arg> (args)...));
-#endif /* __cplusplus < 201402L */
-}
-
 } /* namespace gdb */
 
 /* Dup STR and return a unique_xmalloc_ptr for the result.  */
-- 
2.34.1


^ permalink raw reply	[flat|nested] 39+ messages in thread

* [COMMITTED PATCH v2 2/9] gdb: Replace gdb::optional with std::optional
  2023-10-28 20:48       ` Lancelot SIX
  2023-11-21 12:04         ` [COMMITTED PATCH v2 0/9] " Lancelot Six
  2023-11-21 12:04         ` [COMMITTED PATCH v2 1/9] gdb: Use C++17's std::make_unique instead of gdb::make_unique Lancelot Six
@ 2023-11-21 12:04         ` Lancelot Six
  2023-11-21 12:04         ` [COMMITTED PATCH v2 3/9] gdbsupport: remove gdb::optional Lancelot Six
                           ` (6 subsequent siblings)
  9 siblings, 0 replies; 39+ messages in thread
From: Lancelot Six @ 2023-11-21 12:04 UTC (permalink / raw)
  To: gdb-patches; +Cc: pedro, tom, Lancelot Six

Since GDB now requires C++17, we don't need the internally maintained
gdb::optional implementation.  This patch does the following replacing:
  - gdb::optional -> std::optional
  - gdb::in_place -> std::in_place
  - #include "gdbsupport/gdb_optional.h" -> #include <optional>

This change has mostly been done automatically.  One exception is
gdbsupport/thread-pool.* which did not use the gdb:: prefix as it
already lives in the gdb namespace.

Change-Id: I19a92fa03e89637bab136c72e34fd351524f65e9
Approved-By: Tom Tromey <tom@tromey.com>
Approved-By: Pedro Alves <pedro@palves.net>
---
 gdb/aarch64-linux-tdep.c           | 10 +++++-----
 gdb/ada-lang.c                     |  6 +++---
 gdb/ada-lex.l                      |  2 +-
 gdb/ada-valprint.c                 |  4 ++--
 gdb/amd-dbgapi-target.c            |  4 ++--
 gdb/annotate.c                     |  2 +-
 gdb/arm-fbsd-tdep.c                |  6 +++---
 gdb/arm-fbsd-tdep.h                |  2 +-
 gdb/arm-linux-tdep.c               |  2 +-
 gdb/arm-tdep.c                     |  4 ++--
 gdb/auto-load.c                    |  2 +-
 gdb/auxv.c                         | 10 +++++-----
 gdb/auxv.h                         |  4 ++--
 gdb/avr-tdep.c                     |  2 +-
 gdb/breakpoint.c                   | 19 ++++++++++---------
 gdb/buildsym.c                     |  2 +-
 gdb/cli/cli-cmds.c                 |  6 +++---
 gdb/cli/cli-cmds.h                 |  4 ++--
 gdb/cli/cli-decode.c               |  4 ++--
 gdb/cli/cli-decode.h               |  2 +-
 gdb/cli/cli-option.c               | 14 +++++++-------
 gdb/cli/cli-option.h               |  2 +-
 gdb/command.h                      |  2 +-
 gdb/compile/compile.c              |  4 ++--
 gdb/darwin-nat.c                   |  2 +-
 gdb/debuginfod-support.c           | 10 +++++-----
 gdb/disasm.c                       | 14 +++++++-------
 gdb/disasm.h                       |  2 +-
 gdb/dwarf2/attribute.h             |  2 +-
 gdb/dwarf2/cu.h                    |  8 ++++----
 gdb/dwarf2/die.h                   |  4 ++--
 gdb/dwarf2/index-cache.h           |  2 +-
 gdb/dwarf2/index-write.c           |  4 ++--
 gdb/dwarf2/line-header.c           |  4 ++--
 gdb/dwarf2/macro.c                 |  4 ++--
 gdb/dwarf2/macro.h                 |  2 +-
 gdb/dwarf2/read-gdb-index.c        |  4 ++--
 gdb/dwarf2/read.c                  | 24 ++++++++++++------------
 gdb/dwarf2/read.h                  |  4 ++--
 gdb/eval.c                         |  2 +-
 gdb/event-top.c                    |  2 +-
 gdb/exceptions.c                   |  4 ++--
 gdb/extension-priv.h               |  6 +++---
 gdb/extension.c                    | 12 ++++++------
 gdb/extension.h                    |  8 ++++----
 gdb/f-lang.c                       |  2 +-
 gdb/fbsd-nat.c                     |  6 +++---
 gdb/fbsd-nat.h                     |  4 ++--
 gdb/fbsd-tdep.c                    |  8 ++++----
 gdb/gdbthread.h                    |  8 ++++----
 gdb/gdbtypes.c                     | 18 +++++++++---------
 gdb/gdbtypes.h                     |  8 ++++----
 gdb/guile/scm-ports.c              |  4 ++--
 gdb/ia64-tdep.c                    |  4 ++--
 gdb/inf-child.c                    |  2 +-
 gdb/inf-child.h                    |  2 +-
 gdb/infcmd.c                       |  4 ++--
 gdb/inferior.c                     |  4 ++--
 gdb/inferior.h                     |  2 +-
 gdb/inflow.c                       |  4 ++--
 gdb/infrun.c                       | 12 ++++++------
 gdb/interps.c                      |  2 +-
 gdb/interps.h                      |  4 ++--
 gdb/jit.c                          |  2 +-
 gdb/linux-nat.c                    | 10 +++++-----
 gdb/linux-nat.h                    |  2 +-
 gdb/linux-tdep.c                   | 18 +++++++++---------
 gdb/linux-tdep.h                   |  4 ++--
 gdb/linux-thread-db.c              |  2 +-
 gdb/main.c                         |  4 ++--
 gdb/mi/mi-cmd-stack.c              |  4 ++--
 gdb/mi/mi-cmd-var.c                |  2 +-
 gdb/mi/mi-cmds.c                   |  2 +-
 gdb/mi/mi-cmds.h                   |  8 ++++----
 gdb/mi/mi-interp.c                 |  2 +-
 gdb/mi/mi-interp.h                 |  2 +-
 gdb/mi/mi-main.c                   | 12 ++++++------
 gdb/nat/linux-osdata.c             |  8 ++++----
 gdb/nat/windows-nat.c              |  6 +++---
 gdb/nat/windows-nat.h              |  4 ++--
 gdb/observable.h                   |  2 +-
 gdb/osdata.c                       |  2 +-
 gdb/parse.c                        |  4 ++--
 gdb/ppc-linux-nat.c                |  4 ++--
 gdb/ppc-linux-tdep.c               |  2 +-
 gdb/ppc-tdep.h                     |  2 +-
 gdb/printcmd.c                     |  6 +++---
 gdb/probe.c                        | 22 +++++++++++-----------
 gdb/procfs.c                       |  2 +-
 gdb/psymtab.c                      |  2 +-
 gdb/psymtab.h                      |  2 +-
 gdb/python/py-disasm.c             | 22 +++++++++++-----------
 gdb/python/py-framefilter.c        | 10 +++++-----
 gdb/python/py-inferior.c           |  2 +-
 gdb/python/py-mi.c                 |  2 +-
 gdb/python/py-utils.c              |  4 ++--
 gdb/python/python-internal.h       |  4 ++--
 gdb/python/python.c                |  8 ++++----
 gdb/ravenscar-thread.c             |  4 ++--
 gdb/record-btrace.c                |  8 ++++----
 gdb/regcache.c                     |  4 ++--
 gdb/remote.c                       | 16 ++++++++--------
 gdb/riscv-tdep.c                   |  2 +-
 gdb/s390-linux-tdep.c              |  2 +-
 gdb/skip.c                         |  4 ++--
 gdb/solib-aix.c                    | 14 +++++++-------
 gdb/solib-dsbt.c                   |  2 +-
 gdb/solib-svr4.c                   | 16 ++++++++--------
 gdb/solib-target.c                 |  2 +-
 gdb/source-cache.c                 |  2 +-
 gdb/stack.c                        | 16 ++++++++--------
 gdb/stack.h                        |  2 +-
 gdb/symfile.c                      |  2 +-
 gdb/symtab.c                       | 24 ++++++++++++------------
 gdb/symtab.h                       | 24 ++++++++++++------------
 gdb/target.c                       | 16 ++++++++--------
 gdb/target.h                       | 10 +++++-----
 gdb/thread.c                       | 14 +++++++-------
 gdb/tracefile-tfile.c              |  2 +-
 gdb/tracepoint.c                   |  2 +-
 gdb/tui/tui-disasm.c               |  2 +-
 gdb/tui/tui-layout.c               |  2 +-
 gdb/unittests/optional-selftests.c |  4 ++--
 gdb/utils.c                        |  6 +++---
 gdb/valarith.c                     |  4 ++--
 gdb/valops.c                       |  6 +++---
 gdb/value.c                        |  2 +-
 gdb/value.h                        |  4 ++--
 gdb/windows-nat.c                  | 10 +++++-----
 gdb/xml-support.c                  |  4 ++--
 gdb/xml-support.h                  |  6 +++---
 gdb/xml-syscall.c                  |  2 +-
 gdb/xml-tdesc.c                    | 12 ++++++------
 gdb/xml-tdesc.h                    |  4 ++--
 gdbserver/linux-aarch64-low.cc     |  4 ++--
 gdbserver/regcache.cc              |  4 ++--
 gdbserver/regcache.h               |  2 +-
 gdbserver/win32-low.cc             |  2 +-
 gdbsupport/common-debug.h          |  4 ++--
 gdbsupport/event-loop.cc           |  6 +++---
 gdbsupport/filestuff.cc            |  2 +-
 gdbsupport/filestuff.h             |  2 +-
 gdbsupport/forward-scope-exit.h    |  6 +++---
 gdbsupport/range-chain.h           |  2 +-
 gdbsupport/scoped_ignore_sigttou.h |  2 +-
 gdbsupport/thread-pool.cc          |  2 +-
 gdbsupport/thread-pool.h           |  4 ++--
 147 files changed, 417 insertions(+), 416 deletions(-)

diff --git a/gdb/aarch64-linux-tdep.c b/gdb/aarch64-linux-tdep.c
index f1fcce9b9eb..cd99b33fed2 100644
--- a/gdb/aarch64-linux-tdep.c
+++ b/gdb/aarch64-linux-tdep.c
@@ -1609,7 +1609,7 @@ static const struct target_desc *
 aarch64_linux_core_read_description (struct gdbarch *gdbarch,
 				     struct target_ops *target, bfd *abfd)
 {
-  gdb::optional<gdb::byte_vector> auxv = target_read_auxv_raw (target);
+  std::optional<gdb::byte_vector> auxv = target_read_auxv_raw (target);
   CORE_ADDR hwcap = linux_get_hwcap (auxv, target, gdbarch);
   CORE_ADDR hwcap2 = linux_get_hwcap2 (auxv, target, gdbarch);
 
@@ -2427,7 +2427,7 @@ aarch64_linux_gcc_target_options (struct gdbarch *gdbarch)
 
    Return the allocation tag if successful and nullopt otherwise.  */
 
-static gdb::optional<CORE_ADDR>
+static std::optional<CORE_ADDR>
 aarch64_mte_get_atag (CORE_ADDR address)
 {
   gdb::byte_vector tags;
@@ -2481,7 +2481,7 @@ aarch64_linux_memtag_matches_p (struct gdbarch *gdbarch,
   CORE_ADDR addr = value_as_address (address);
 
   /* Fetch the allocation tag for ADDRESS.  */
-  gdb::optional<CORE_ADDR> atag
+  std::optional<CORE_ADDR> atag
     = aarch64_mte_get_atag (gdbarch_remove_non_address_bits (gdbarch, addr));
 
   if (!atag.has_value ())
@@ -2579,7 +2579,7 @@ aarch64_linux_get_memtag (struct gdbarch *gdbarch, struct value *address,
 
       /* Remove the top byte.  */
       addr = gdbarch_remove_non_address_bits (gdbarch, addr);
-      gdb::optional<CORE_ADDR> atag = aarch64_mte_get_atag (addr);
+      std::optional<CORE_ADDR> atag = aarch64_mte_get_atag (addr);
 
       if (!atag.has_value ())
 	return nullptr;
@@ -2651,7 +2651,7 @@ aarch64_linux_report_signal_info (struct gdbarch *gdbarch,
       uiout->field_core_addr ("fault-addr", gdbarch, fault_addr);
       uiout->text ("\n");
 
-      gdb::optional<CORE_ADDR> atag
+      std::optional<CORE_ADDR> atag
 	= aarch64_mte_get_atag (gdbarch_remove_non_address_bits (gdbarch,
 								 fault_addr));
       gdb_byte ltag = aarch64_mte_get_ltag (fault_addr);
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 9bb649e901d..58c70160d31 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -3098,7 +3098,7 @@ ada_value_slice_from_ptr (struct value *array_ptr, struct type *type,
 			       type0->dyn_prop (DYN_PROP_BYTE_STRIDE),
 			       type0->field (0).bitsize ());
   int base_low =  ada_discrete_type_low_bound (type0->index_type ());
-  gdb::optional<LONGEST> base_low_pos, low_pos;
+  std::optional<LONGEST> base_low_pos, low_pos;
   CORE_ADDR base;
 
   low_pos = discrete_position (base_index_type, low);
@@ -3132,7 +3132,7 @@ ada_value_slice (struct value *array, int low, int high)
 			      (alloc, type->target_type (), index_type,
 			       type->dyn_prop (DYN_PROP_BYTE_STRIDE),
 			       type->field (0).bitsize ());
-  gdb::optional<LONGEST> low_pos, high_pos;
+  std::optional<LONGEST> low_pos, high_pos;
 
 
   low_pos = discrete_position (base_index_type, low);
@@ -8792,7 +8792,7 @@ pos_atr (struct value *arg)
   if (!discrete_type_p (type))
     error (_("'POS only defined on discrete types"));
 
-  gdb::optional<LONGEST> result = discrete_position (type, value_as_long (val));
+  std::optional<LONGEST> result = discrete_position (type, value_as_long (val));
   if (!result.has_value ())
     error (_("enumeration value is invalid: can't find 'POS"));
 
diff --git a/gdb/ada-lex.l b/gdb/ada-lex.l
index 0547b704eaf..0576f361a42 100644
--- a/gdb/ada-lex.l
+++ b/gdb/ada-lex.l
@@ -713,7 +713,7 @@ processAttribute (const char *str)
     if (strcasecmp (str, item.name) == 0)
       return item.code;
 
-  gdb::optional<int> found;
+  std::optional<int> found;
   for (const auto &item : attributes)
     if (subseqMatch (str, item.name))
       {
diff --git a/gdb/ada-valprint.c b/gdb/ada-valprint.c
index b32f1e506d1..f1c4e8b0b70 100644
--- a/gdb/ada-valprint.c
+++ b/gdb/ada-valprint.c
@@ -385,7 +385,7 @@ ada_print_scalar (struct type *type, LONGEST val, struct ui_file *stream)
 
     case TYPE_CODE_ENUM:
       {
-	gdb::optional<LONGEST> posn = discrete_position (type, val);
+	std::optional<LONGEST> posn = discrete_position (type, val);
 	if (posn.has_value ())
 	  fputs_styled (ada_enum_name (type->field (*posn).name ()),
 			variable_name_style.style (), stream);
@@ -827,7 +827,7 @@ ada_val_print_enum (struct value *value, struct ui_file *stream, int recurse,
   int offset_aligned = ada_aligned_value_addr (type, valaddr) - valaddr;
 
   val = unpack_long (type, valaddr + offset_aligned);
-  gdb::optional<LONGEST> posn = discrete_position (type, val);
+  std::optional<LONGEST> posn = discrete_position (type, val);
   if (posn.has_value ())
     {
       const char *name = ada_enum_name (type->field (*posn).name ());
diff --git a/gdb/amd-dbgapi-target.c b/gdb/amd-dbgapi-target.c
index c03b64ce190..18c0543c40e 100644
--- a/gdb/amd-dbgapi-target.c
+++ b/gdb/amd-dbgapi-target.c
@@ -528,7 +528,7 @@ amd_dbgapi_target::xfer_partial (enum target_object object, const char *annex,
 			       ULONGEST offset, ULONGEST requested_len,
 			       ULONGEST *xfered_len)
 {
-  gdb::optional<scoped_restore_current_thread> maybe_restore_thread;
+  std::optional<scoped_restore_current_thread> maybe_restore_thread;
 
   if (!ptid_is_gpu (inferior_ptid))
     return beneath ()->xfer_partial (object, annex, readbuf, writebuf, offset,
@@ -1901,7 +1901,7 @@ static void
 amd_dbgapi_log_message_callback (amd_dbgapi_log_level_t level,
 				 const char *message)
 {
-  gdb::optional<target_terminal::scoped_restore_terminal_state> tstate;
+  std::optional<target_terminal::scoped_restore_terminal_state> tstate;
 
   if (target_supports_terminal_ours ())
     {
diff --git a/gdb/annotate.c b/gdb/annotate.c
index 8385429042d..f3ead9e3ce2 100644
--- a/gdb/annotate.c
+++ b/gdb/annotate.c
@@ -233,7 +233,7 @@ annotate_thread_changed (void)
 
 static void
 annotate_thread_exited (thread_info *t,
-			gdb::optional<ULONGEST> exit_code,
+			std::optional<ULONGEST> exit_code,
 			bool /* silent */)
 {
   if (annotation_level > 1)
diff --git a/gdb/arm-fbsd-tdep.c b/gdb/arm-fbsd-tdep.c
index 90273a3f5ef..391afec9e67 100644
--- a/gdb/arm-fbsd-tdep.c
+++ b/gdb/arm-fbsd-tdep.c
@@ -215,7 +215,7 @@ arm_fbsd_iterate_over_regset_sections (struct gdbarch *gdbarch,
 /* See arm-fbsd-tdep.h.  */
 
 const struct target_desc *
-arm_fbsd_read_description_auxv (const gdb::optional<gdb::byte_vector> &auxv,
+arm_fbsd_read_description_auxv (const std::optional<gdb::byte_vector> &auxv,
 				target_ops *target, gdbarch *gdbarch, bool tls)
 {
   CORE_ADDR arm_hwcap = 0;
@@ -244,7 +244,7 @@ arm_fbsd_read_description_auxv (const gdb::optional<gdb::byte_vector> &auxv,
 const struct target_desc *
 arm_fbsd_read_description_auxv (bool tls)
 {
-  const gdb::optional<gdb::byte_vector> &auxv = target_read_auxv ();
+  const std::optional<gdb::byte_vector> &auxv = target_read_auxv ();
   return arm_fbsd_read_description_auxv (auxv,
 					 current_inferior ()->top_target (),
 					 current_inferior ()->arch (),
@@ -260,7 +260,7 @@ arm_fbsd_core_read_description (struct gdbarch *gdbarch,
 {
   asection *tls = bfd_get_section_by_name (abfd, ".reg-aarch-tls");
 
-  gdb::optional<gdb::byte_vector> auxv = target_read_auxv_raw (target);
+  std::optional<gdb::byte_vector> auxv = target_read_auxv_raw (target);
   return arm_fbsd_read_description_auxv (auxv, target, gdbarch, tls != nullptr);
 }
 
diff --git a/gdb/arm-fbsd-tdep.h b/gdb/arm-fbsd-tdep.h
index 3478e4b6860..7eb1850c1a7 100644
--- a/gdb/arm-fbsd-tdep.h
+++ b/gdb/arm-fbsd-tdep.h
@@ -47,7 +47,7 @@ extern const struct regset arm_fbsd_tls_regset;
    AUXV.  */
 
 extern const struct target_desc *
-  arm_fbsd_read_description_auxv (const gdb::optional<gdb::byte_vector> &auxv,
+  arm_fbsd_read_description_auxv (const std::optional<gdb::byte_vector> &auxv,
 				  target_ops *target, gdbarch *gdbarch,
 				  bool tls);
 
diff --git a/gdb/arm-linux-tdep.c b/gdb/arm-linux-tdep.c
index 86fa3de0fd2..8117d35a4d3 100644
--- a/gdb/arm-linux-tdep.c
+++ b/gdb/arm-linux-tdep.c
@@ -732,7 +732,7 @@ arm_linux_core_read_description (struct gdbarch *gdbarch,
 				 struct target_ops *target,
 				 bfd *abfd)
 {
-  gdb::optional<gdb::byte_vector> auxv = target_read_auxv_raw (target);
+  std::optional<gdb::byte_vector> auxv = target_read_auxv_raw (target);
   CORE_ADDR arm_hwcap = linux_get_hwcap (auxv, target, gdbarch);
 
   if (arm_hwcap & HWCAP_VFP)
diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c
index d4047ddbb86..7a93b098247 100644
--- a/gdb/arm-tdep.c
+++ b/gdb/arm-tdep.c
@@ -302,7 +302,7 @@ struct arm_prologue_cache
   int framereg;
 
   /* True if the return address is signed, false otherwise.  */
-  gdb::optional<bool> ra_signed_state;
+  std::optional<bool> ra_signed_state;
 
   /* Saved register offsets.  */
   trad_frame_saved_reg *saved_regs;
@@ -1035,7 +1035,7 @@ thumb_analyze_prologue (struct gdbarch *gdbarch,
   while (start < limit)
     {
       unsigned short insn;
-      gdb::optional<bool> ra_signed_state;
+      std::optional<bool> ra_signed_state;
 
       insn = read_code_unsigned_integer (start, 2, byte_order_for_code);
 
diff --git a/gdb/auto-load.c b/gdb/auto-load.c
index 8bbe6696dcc..daea75b7437 100644
--- a/gdb/auto-load.c
+++ b/gdb/auto-load.c
@@ -914,7 +914,7 @@ source_script_file (struct auto_load_pspace_info *pspace_info,
       return;
     }
 
-  gdb::optional<open_script> opened = find_and_open_script (file,
+  std::optional<open_script> opened = find_and_open_script (file,
 							    1 /*search_path*/);
 
   if (opened)
diff --git a/gdb/auxv.c b/gdb/auxv.c
index 61acd48fc98..994d97c1a2c 100644
--- a/gdb/auxv.c
+++ b/gdb/auxv.c
@@ -331,7 +331,7 @@ parse_auxv (target_ops *ops, gdbarch *gdbarch, const gdb_byte **readptr,
     overhead of transfering data from a remote target to the local host.  */
 struct auxv_info
 {
-  gdb::optional<gdb::byte_vector> data;
+  std::optional<gdb::byte_vector> data;
 };
 
 /* Per-inferior data key for auxv.  */
@@ -357,7 +357,7 @@ auxv_all_objfiles_removed (program_space *pspace)
 
 /* See auxv.h.  */
 
-const gdb::optional<gdb::byte_vector> &
+const std::optional<gdb::byte_vector> &
 target_read_auxv ()
 {
   inferior *inf = current_inferior ();
@@ -374,7 +374,7 @@ target_read_auxv ()
 
 /* See auxv.h.  */
 
-gdb::optional<gdb::byte_vector>
+std::optional<gdb::byte_vector>
 target_read_auxv_raw (target_ops *ops)
 {
   return target_read_alloc (ops, TARGET_OBJECT_AUXV, NULL);
@@ -413,7 +413,7 @@ target_auxv_search (const gdb::byte_vector &auxv, target_ops *ops,
 int
 target_auxv_search (CORE_ADDR match, CORE_ADDR *valp)
 {
-  const gdb::optional<gdb::byte_vector> &auxv = target_read_auxv ();
+  const std::optional<gdb::byte_vector> &auxv = target_read_auxv ();
 
   if (!auxv.has_value ())
     return -1;
@@ -572,7 +572,7 @@ fprint_target_auxv (struct ui_file *file)
   gdbarch *gdbarch = current_inferior ()->arch ();
   CORE_ADDR type, val;
   int ents = 0;
-  const gdb::optional<gdb::byte_vector> &auxv = target_read_auxv ();
+  const std::optional<gdb::byte_vector> &auxv = target_read_auxv ();
 
   if (!auxv.has_value ())
     return -1;
diff --git a/gdb/auxv.h b/gdb/auxv.h
index a920f7a5da8..10f31dc84e8 100644
--- a/gdb/auxv.h
+++ b/gdb/auxv.h
@@ -48,11 +48,11 @@ extern int svr4_auxv_parse (struct gdbarch *gdbarch, const gdb_byte **readptr,
 
 /* Read auxv data from the current inferior's target stack.  */
 
-extern const gdb::optional<gdb::byte_vector> &target_read_auxv ();
+extern const std::optional<gdb::byte_vector> &target_read_auxv ();
 
 /* Read auxv data from OPS.  */
 
-extern gdb::optional<gdb::byte_vector> target_read_auxv_raw (target_ops *ops);
+extern std::optional<gdb::byte_vector> target_read_auxv_raw (target_ops *ops);
 
 /* Search AUXV for an entry with a_type matching MATCH.
 
diff --git a/gdb/avr-tdep.c b/gdb/avr-tdep.c
index 92aec3b510f..598d740883c 100644
--- a/gdb/avr-tdep.c
+++ b/gdb/avr-tdep.c
@@ -1566,7 +1566,7 @@ avr_io_reg_read_command (const char *args, int from_tty)
   unsigned int val;
 
   /* Find out how many io registers the target has.  */
-  gdb::optional<gdb::byte_vector> buf
+  std::optional<gdb::byte_vector> buf
     = target_read_alloc (current_inferior ()->top_target (),
 			 TARGET_OBJECT_AVR, "avr.io_reg");
 
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index cd8f36fbf05..af395fde14a 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -82,7 +82,7 @@
 #include <algorithm>
 #include "progspace-and-thread.h"
 #include "gdbsupport/array-view.h"
-#include "gdbsupport/gdb_optional.h"
+#include <optional>
 #include "gdbsupport/common-utils.h"
 
 /* Prototypes for local functions.  */
@@ -2067,7 +2067,7 @@ update_watchpoint (struct watchpoint *b, bool reparse)
   if (b->disposition == disp_del_at_next_stop)
     return;
 
-  gdb::optional<scoped_restore_selected_frame> restore_frame;
+  std::optional<scoped_restore_selected_frame> restore_frame;
 
   /* Determine if the watchpoint is within scope.  */
   if (b->exp_valid_block == NULL)
@@ -3365,7 +3365,7 @@ remove_breakpoints (void)
 
 static void
 remove_threaded_breakpoints (thread_info *tp,
-			     gdb::optional<ULONGEST> /* exit_code */,
+			     std::optional<ULONGEST> /* exit_code */,
 			     int /* silent */)
 {
   for (breakpoint &b : all_breakpoints_safe ())
@@ -6776,8 +6776,8 @@ print_one_breakpoint_location (struct breakpoint *b,
 	(uiout->test_flags (fix_breakpoint_script_output)
 	 || fix_breakpoint_script_output_globally);
 
-      gdb::optional<ui_out_emit_tuple> tuple_emitter;
-      gdb::optional<ui_out_emit_list> list_emitter;
+      std::optional<ui_out_emit_tuple> tuple_emitter;
+      std::optional<ui_out_emit_list> list_emitter;
 
       if (use_fixed_output)
 	list_emitter.emplace (uiout, "script");
@@ -6850,7 +6850,8 @@ print_one_breakpoint (breakpoint *b, const bp_location **last_loc, int allflag)
     = (uiout->test_flags (fix_multi_location_breakpoint_output)
        || fix_multi_location_breakpoint_output_globally);
 
-  gdb::optional<ui_out_emit_tuple> bkpt_tuple_emitter (gdb::in_place, uiout, "bkpt");
+  std::optional<ui_out_emit_tuple> bkpt_tuple_emitter (std::in_place, uiout,
+						       "bkpt");
   bool printed = print_one_breakpoint_location (b, NULL, 0, last_loc,
 						allflag, false);
 
@@ -6885,7 +6886,7 @@ print_one_breakpoint (breakpoint *b, const bp_location **last_loc, int allflag)
 		      || !b->first_loc ().enabled
 		      || b->first_loc ().disabled_by_cond))))
 	{
-	  gdb::optional<ui_out_emit_list> locations_list;
+	  std::optional<ui_out_emit_list> locations_list;
 
 	  /* For MI version <= 2, keep the behavior where GDB outputs an invalid
 	     MI record.  For later versions, place breakpoint locations in a
@@ -9950,7 +9951,7 @@ watchpoint::print_it (const bpstat *bs) const
 
   string_file stb;
 
-  gdb::optional<ui_out_emit_tuple> tuple_emitter;
+  std::optional<ui_out_emit_tuple> tuple_emitter;
   switch (this->type)
     {
     case bp_watchpoint:
@@ -10928,7 +10929,7 @@ until_break_command (const char *arg, int from_tty, int anywhere)
 
   std::vector<breakpoint_up> breakpoints;
 
-  gdb::optional<delete_longjmp_breakpoint_cleanup> lj_deleter;
+  std::optional<delete_longjmp_breakpoint_cleanup> lj_deleter;
 
   if (frame_id_p (caller_frame_id))
     {
diff --git a/gdb/buildsym.c b/gdb/buildsym.c
index b982afea3d2..32d60cc22d4 100644
--- a/gdb/buildsym.c
+++ b/gdb/buildsym.c
@@ -643,7 +643,7 @@ buildsym_compunit::record_line (struct subfile *subfile, int line,
      anyway.  */
   if (line == 0)
     {
-      gdb::optional<int> last_line;
+      std::optional<int> last_line;
 
       while (!subfile->line_vector_entries.empty ())
 	{
diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c
index fd93e5b4ccb..cb9ff554884 100644
--- a/gdb/cli/cli-cmds.c
+++ b/gdb/cli/cli-cmds.c
@@ -655,12 +655,12 @@ show_script_ext_mode (struct ui_file *file, int from_tty,
    If SEARCH_PATH is non-zero, and the file isn't found in cwd,
    search for it in the source search path.  */
 
-gdb::optional<open_script>
+std::optional<open_script>
 find_and_open_script (const char *script_file, int search_path)
 {
   int fd;
   openp_flags search_flags = OPF_TRY_CWD_FIRST | OPF_RETURN_REALPATH;
-  gdb::optional<open_script> opened;
+  std::optional<open_script> opened;
 
   gdb::unique_xmalloc_ptr<char> file (tilde_expand (script_file));
 
@@ -742,7 +742,7 @@ source_script_with_search (const char *file, int from_tty, int search_path)
   if (file == NULL || *file == 0)
     error (_("source command requires file name of file to source."));
 
-  gdb::optional<open_script> opened = find_and_open_script (file, search_path);
+  std::optional<open_script> opened = find_and_open_script (file, search_path);
   if (!opened)
     {
       /* The script wasn't found, or was otherwise inaccessible.
diff --git a/gdb/cli/cli-cmds.h b/gdb/cli/cli-cmds.h
index 429574426ac..a2579dc25f2 100644
--- a/gdb/cli/cli-cmds.h
+++ b/gdb/cli/cli-cmds.h
@@ -18,7 +18,7 @@
 #define CLI_CLI_CMDS_H
 
 #include "gdbsupport/filestuff.h"
-#include "gdbsupport/gdb_optional.h"
+#include <optional>
 #include "completer.h"
 
 /* Chain containing all defined commands.  */
@@ -179,7 +179,7 @@ struct open_script
   }
 };
 
-extern gdb::optional<open_script>
+extern std::optional<open_script>
     find_and_open_script (const char *file, int search_path);
 
 /* Command tracing state.  */
diff --git a/gdb/cli/cli-decode.c b/gdb/cli/cli-decode.c
index 0bbe96b5334..940cd6a2c8e 100644
--- a/gdb/cli/cli-decode.c
+++ b/gdb/cli/cli-decode.c
@@ -24,7 +24,7 @@
 #include "cli/cli-cmds.h"
 #include "cli/cli-decode.h"
 #include "cli/cli-style.h"
-#include "gdbsupport/gdb_optional.h"
+#include <optional>
 
 /* Prototypes for local functions.  */
 
@@ -2727,7 +2727,7 @@ cmd_func (struct cmd_list_element *cmd, const char *args, int from_tty)
 {
   if (!cmd->is_command_class_help ())
     {
-      gdb::optional<scoped_restore_tmpl<bool>> restore_suppress;
+      std::optional<scoped_restore_tmpl<bool>> restore_suppress;
 
       if (cmd->suppress_notification != NULL)
 	restore_suppress.emplace (cmd->suppress_notification, true);
diff --git a/gdb/cli/cli-decode.h b/gdb/cli/cli-decode.h
index 8fe9325c2da..14d9c29b464 100644
--- a/gdb/cli/cli-decode.h
+++ b/gdb/cli/cli-decode.h
@@ -233,7 +233,7 @@ struct cmd_list_element
   void (*destroyer) (struct cmd_list_element *self, void *context) = nullptr;
 
   /* Setting affected by "set" and "show".  Not used if type is not_set_cmd.  */
-  gdb::optional<setting> var;
+  std::optional<setting> var;
 
   /* Pointer to NULL terminated list of enumerated values (like
      argv).  */
diff --git a/gdb/cli/cli-option.c b/gdb/cli/cli-option.c
index 9b303b1304e..d2d489b7219 100644
--- a/gdb/cli/cli-option.c
+++ b/gdb/cli/cli-option.c
@@ -58,11 +58,11 @@ struct option_def_and_value
   void *ctx;
 
   /* The option's value, if any.  */
-  gdb::optional<option_value> value;
+  std::optional<option_value> value;
 
   /* Constructor.  */
   option_def_and_value (const option_def &option_, void *ctx_,
-			gdb::optional<option_value> &&value_ = {})
+			std::optional<option_value> &&value_ = {})
     : option (option_),
       ctx (ctx_),
       value (std::move (value_))
@@ -99,7 +99,7 @@ struct option_def_and_value
      allocated on the heap, so we must clear the pointer in the
      source, to avoid a double free.  */
   static void clear_value (const option_def &option,
-			   gdb::optional<option_value> &value)
+			   std::optional<option_value> &value)
   {
     if (value.has_value ())
       {
@@ -109,7 +109,7 @@ struct option_def_and_value
   }
 };
 
-static void save_option_value_in_ctx (gdb::optional<option_def_and_value> &ov);
+static void save_option_value_in_ctx (std::optional<option_def_and_value> &ov);
 
 /* Info passed around when handling completion.  */
 struct parse_option_completion_info
@@ -177,7 +177,7 @@ complete_on_all_options (completion_tracker &tracker,
 /* Parse ARGS, guided by OPTIONS_GROUP.  HAVE_DELIMITER is true if the
    whole ARGS line included the "--" options-terminator delimiter.  */
 
-static gdb::optional<option_def_and_value>
+static std::optional<option_def_and_value>
 parse_option (gdb::array_view<const option_def_group> options_group,
 	      process_options_mode mode,
 	      bool have_delimiter,
@@ -496,7 +496,7 @@ complete_options (completion_tracker &tracker,
 	    }
 	  else if (**args == '-')
 	    {
-	      gdb::optional<option_def_and_value> ov
+	      std::optional<option_def_and_value> ov
 		= parse_option (options_group, mode, have_delimiter,
 				args, &completion_info);
 	      if (!ov && !tracker.have_completions ())
@@ -589,7 +589,7 @@ complete_options (completion_tracker &tracker,
 /* Save the parsed value in the option's context.  */
 
 static void
-save_option_value_in_ctx (gdb::optional<option_def_and_value> &ov)
+save_option_value_in_ctx (std::optional<option_def_and_value> &ov)
 {
   switch (ov->option.type)
     {
diff --git a/gdb/cli/cli-option.h b/gdb/cli/cli-option.h
index 7b015b89f47..4c62227f31c 100644
--- a/gdb/cli/cli-option.h
+++ b/gdb/cli/cli-option.h
@@ -20,7 +20,7 @@
 #ifndef CLI_OPTION_H
 #define CLI_OPTION_H 1
 
-#include "gdbsupport/gdb_optional.h"
+#include <optional>
 #include "gdbsupport/array-view.h"
 #include "completer.h"
 #include <string>
diff --git a/gdb/command.h b/gdb/command.h
index 467bb283cdc..1ab953b996b 100644
--- a/gdb/command.h
+++ b/gdb/command.h
@@ -126,7 +126,7 @@ struct literal_def
   LONGEST use;
 
   /* An optional number accepted that stands for the literal.  */
-  gdb::optional<LONGEST> val;
+  std::optional<LONGEST> val;
 };
 
 /* Return true if a setting of type VAR_TYPE is backed with type T.
diff --git a/gdb/compile/compile.c b/gdb/compile/compile.c
index a93c9404660..be1bcca47b4 100644
--- a/gdb/compile/compile.c
+++ b/gdb/compile/compile.c
@@ -40,7 +40,7 @@
 #include "osabi.h"
 #include "gdbsupport/gdb_wait.h"
 #include "valprint.h"
-#include "gdbsupport/gdb_optional.h"
+#include <optional>
 #include "gdbsupport/gdb_unlinker.h"
 #include "gdbsupport/pathstuff.h"
 #include "gdbsupport/scoped_ignore_signal.h"
@@ -768,7 +768,7 @@ compile_to_object (struct command_line *cmd, const char *cmd_string,
 
   compile_file_names fnames = get_new_file_names ();
 
-  gdb::optional<gdb::unlinker> source_remover;
+  std::optional<gdb::unlinker> source_remover;
 
   {
     gdb_file_up src = gdb_fopen_cloexec (fnames.source_file (), "w");
diff --git a/gdb/darwin-nat.c b/gdb/darwin-nat.c
index 0de476b022b..f5624956e76 100644
--- a/gdb/darwin-nat.c
+++ b/gdb/darwin-nat.c
@@ -1968,7 +1968,7 @@ darwin_nat_target::create_inferior (const char *exec_file,
 				    const std::string &allargs,
 				    char **env, int from_tty)
 {
-  gdb::optional<scoped_restore_tmpl<bool>> restore_startup_with_shell;
+  std::optional<scoped_restore_tmpl<bool>> restore_startup_with_shell;
   darwin_nat_target *the_target = this;
 
   if (startup_with_shell && may_have_sip ())
diff --git a/gdb/debuginfod-support.c b/gdb/debuginfod-support.c
index 902af405cc6..1ebd98ca705 100644
--- a/gdb/debuginfod-support.c
+++ b/gdb/debuginfod-support.c
@@ -21,7 +21,7 @@
 #include <errno.h>
 #include "gdbsupport/scoped_fd.h"
 #include "debuginfod-support.h"
-#include "gdbsupport/gdb_optional.h"
+#include <optional>
 #include "cli/cli-cmds.h"
 #include "cli/cli-style.h"
 #include "cli-out.h"
@@ -320,7 +320,7 @@ debuginfod_source_query (const unsigned char *build_id,
 
   char *dname = nullptr;
   scoped_fd fd;
-  gdb::optional<target_terminal::scoped_restore_terminal_state> term_state;
+  std::optional<target_terminal::scoped_restore_terminal_state> term_state;
 
   {
     user_data data ("source file", srcpath);
@@ -366,7 +366,7 @@ debuginfod_debuginfo_query (const unsigned char *build_id,
 
   char *dname = nullptr;
   scoped_fd fd;
-  gdb::optional<target_terminal::scoped_restore_terminal_state> term_state;
+  std::optional<target_terminal::scoped_restore_terminal_state> term_state;
 
   {
     user_data data ("separate debug info for", filename);
@@ -409,7 +409,7 @@ debuginfod_exec_query (const unsigned char *build_id,
 
   char *dname = nullptr;
   scoped_fd fd;
-  gdb::optional<target_terminal::scoped_restore_terminal_state> term_state;
+  std::optional<target_terminal::scoped_restore_terminal_state> term_state;
 
   {
     user_data data ("executable for", filename);
@@ -458,7 +458,7 @@ debuginfod_section_query (const unsigned char *build_id,
   char *dname = nullptr;
   std::string desc = std::string ("section ") + section_name + " for";
   scoped_fd fd;
-  gdb::optional<target_terminal::scoped_restore_terminal_state> term_state;
+  std::optional<target_terminal::scoped_restore_terminal_state> term_state;
 
   {
     user_data data (desc.c_str (), filename);
diff --git a/gdb/disasm.c b/gdb/disasm.c
index 2e866f6865e..82b7e990ff9 100644
--- a/gdb/disasm.c
+++ b/gdb/disasm.c
@@ -29,7 +29,7 @@
 #include "source.h"
 #include "gdbsupport/gdb-safe-ctype.h"
 #include <algorithm>
-#include "gdbsupport/gdb_optional.h"
+#include <optional>
 #include "valprint.h"
 #include "cli/cli-style.h"
 #include "objfiles.h"
@@ -653,8 +653,8 @@ do_mixed_source_and_assembly_deprecated
 
   ui_out_emit_list asm_insns_list (uiout, "asm_insns");
 
-  gdb::optional<ui_out_emit_tuple> outer_tuple_emitter;
-  gdb::optional<ui_out_emit_list> inner_list_emitter;
+  std::optional<ui_out_emit_tuple> outer_tuple_emitter;
+  std::optional<ui_out_emit_list> inner_list_emitter;
 
   for (i = 0; i < newlines; i++)
     {
@@ -810,8 +810,8 @@ do_mixed_source_and_assembly (struct gdbarch *gdbarch,
 
   ui_out_emit_list asm_insns_emitter (uiout, "asm_insns");
 
-  gdb::optional<ui_out_emit_tuple> tuple_emitter;
-  gdb::optional<ui_out_emit_list> list_emitter;
+  std::optional<ui_out_emit_tuple> tuple_emitter;
+  std::optional<ui_out_emit_list> list_emitter;
 
   last_symtab = NULL;
   last_line = 0;
@@ -1093,7 +1093,7 @@ gdb_print_insn_1 (struct gdbarch *gdbarch, CORE_ADDR vma,
 		  struct disassemble_info *info)
 {
   /* Call into the extension languages to do the disassembly.  */
-  gdb::optional<int> length = ext_lang_print_insn (gdbarch, vma, info);
+  std::optional<int> length = ext_lang_print_insn (gdbarch, vma, info);
   if (length.has_value ())
     return *length;
 
@@ -1125,7 +1125,7 @@ gdb_disassembler::print_insn (CORE_ADDR memaddr,
      this output.  */
   if (length > 0 && use_ext_lang_for_styling ())
     {
-      gdb::optional<std::string> ext_contents;
+      std::optional<std::string> ext_contents;
       ext_contents = ext_lang_colorize_disasm (m_buffer.string (), arch ());
       if (ext_contents.has_value ())
 	m_buffer = std::move (*ext_contents);
diff --git a/gdb/disasm.h b/gdb/disasm.h
index dbc63e52ed2..5596bd62a10 100644
--- a/gdb/disasm.h
+++ b/gdb/disasm.h
@@ -275,7 +275,7 @@ struct gdb_disassembler : public gdb_printing_disassembler,
      negative value (which indicates an error), then, if this variable has
      a value, we report a memory error to the user, otherwise, we report a
      non-memory error.  */
-  gdb::optional<CORE_ADDR> m_err_memaddr;
+  std::optional<CORE_ADDR> m_err_memaddr;
 
   /* The stream to which disassembler output will be written.  */
   ui_file *m_dest;
diff --git a/gdb/dwarf2/attribute.h b/gdb/dwarf2/attribute.h
index 4cfdaa1e355..fdb579a368a 100644
--- a/gdb/dwarf2/attribute.h
+++ b/gdb/dwarf2/attribute.h
@@ -29,7 +29,7 @@
 
 #include "dwarf2.h"
 #include "dwarf2/types.h"
-#include "gdbsupport/gdb_optional.h"
+#include <optional>
 
 /* Blocks are a bunch of untyped bytes.  */
 struct dwarf_block
diff --git a/gdb/dwarf2/cu.h b/gdb/dwarf2/cu.h
index ef8db480e3f..a8879de73e5 100644
--- a/gdb/dwarf2/cu.h
+++ b/gdb/dwarf2/cu.h
@@ -22,7 +22,7 @@
 
 #include "buildsym.h"
 #include "dwarf2/comp-unit-head.h"
-#include "gdbsupport/gdb_optional.h"
+#include <optional>
 #include "language.h"
 
 /* Type used for delaying computation of method physnames.
@@ -101,7 +101,7 @@ struct dwarf2_cu
   struct comp_unit_head header;
 
   /* Base address of this compilation unit.  */
-  gdb::optional<unrelocated_addr> base_address;
+  std::optional<unrelocated_addr> base_address;
 
   /* The language we are debugging.  */
   const struct language_defn *language_defn = nullptr;
@@ -189,7 +189,7 @@ struct dwarf2_cu
 
   /* The DW_AT_addr_base (DW_AT_GNU_addr_base) attribute if present.
      Note this value comes from the Fission stub CU/TU's DIE.  */
-  gdb::optional<ULONGEST> addr_base;
+  std::optional<ULONGEST> addr_base;
 
   /* The DW_AT_GNU_ranges_base attribute, if present.
 
@@ -242,7 +242,7 @@ struct dwarf2_cu
      files, the value is implicitly zero.  For DWARF 5 version DWO files, the
      value is often implicit and is the size of the header of
      .debug_str_offsets section (8 or 4, depending on the address size).  */
-  gdb::optional<ULONGEST> str_offsets_base;
+  std::optional<ULONGEST> str_offsets_base;
 
   /* Mark used when releasing cached dies.  */
   bool m_mark : 1;
diff --git a/gdb/dwarf2/die.h b/gdb/dwarf2/die.h
index cdee46996d6..c7040776b07 100644
--- a/gdb/dwarf2/die.h
+++ b/gdb/dwarf2/die.h
@@ -59,7 +59,7 @@ struct die_info
   /* Return the address base of the compile unit, which, if exists, is
      stored either at the attribute DW_AT_GNU_addr_base, or
      DW_AT_addr_base.  */
-  gdb::optional<ULONGEST> addr_base ()
+  std::optional<ULONGEST> addr_base ()
   {
     for (unsigned i = 0; i < num_attrs; ++i)
       if (attrs[i].name == DW_AT_addr_base
@@ -73,7 +73,7 @@ struct die_info
 	  complaint (_("address base attribute (offset %s) as wrong form"),
 		     sect_offset_str (sect_off));
 	}
-    return gdb::optional<ULONGEST> ();
+    return std::optional<ULONGEST> ();
   }
 
   /* Return the base address of the compile unit into the .debug_ranges section,
diff --git a/gdb/dwarf2/index-cache.h b/gdb/dwarf2/index-cache.h
index cfa45435fbd..023fc86fc89 100644
--- a/gdb/dwarf2/index-cache.h
+++ b/gdb/dwarf2/index-cache.h
@@ -52,7 +52,7 @@ struct index_cache_store_context
   std::string build_id_str;
 
   /* Captured value of dwz build id.  */
-  gdb::optional<std::string> dwz_build_id_str;
+  std::optional<std::string> dwz_build_id_str;
 };
 
 /* Class to manage the access to the DWARF index cache.  */
diff --git a/gdb/dwarf2/index-write.c b/gdb/dwarf2/index-write.c
index c9d6e633bf3..d1b10a28823 100644
--- a/gdb/dwarf2/index-write.c
+++ b/gdb/dwarf2/index-write.c
@@ -1474,7 +1474,7 @@ struct index_wip_file
      FILENAME_TEMP is unlinked, because on MS-Windows one cannot
      delete a file that is still open.  So, we wrap the unlinker in an
      optional and emplace it once we know the file name.  */
-  gdb::optional<gdb::unlinker> unlink_file;
+  std::optional<gdb::unlinker> unlink_file;
 
   gdb_file_up out_file;
 };
@@ -1497,7 +1497,7 @@ write_dwarf_index (dwarf2_per_bfd *per_bfd, const char *dir,
 			      ? INDEX5_SUFFIX : INDEX4_SUFFIX);
 
   index_wip_file objfile_index_wip (dir, basename, index_suffix);
-  gdb::optional<index_wip_file> dwz_index_wip;
+  std::optional<index_wip_file> dwz_index_wip;
 
   if (dwz_basename != NULL)
       dwz_index_wip.emplace (dir, dwz_basename, index_suffix);
diff --git a/gdb/dwarf2/line-header.c b/gdb/dwarf2/line-header.c
index d072a91bac9..ddaf7e4a527 100644
--- a/gdb/dwarf2/line-header.c
+++ b/gdb/dwarf2/line-header.c
@@ -160,8 +160,8 @@ read_formatted_entries (dwarf2_per_objfile *per_objfile, bfd *abfd,
 	  ULONGEST form  = read_unsigned_leb128 (abfd, format, &bytes_read);
 	  format += bytes_read;
 
-	  gdb::optional<const char *> string;
-	  gdb::optional<unsigned int> uint;
+	  std::optional<const char *> string;
+	  std::optional<unsigned int> uint;
 
 	  switch (form)
 	    {
diff --git a/gdb/dwarf2/macro.c b/gdb/dwarf2/macro.c
index 78cce2d69eb..2e88e670216 100644
--- a/gdb/dwarf2/macro.c
+++ b/gdb/dwarf2/macro.c
@@ -444,7 +444,7 @@ dwarf_decode_macro_bytes (dwarf2_per_objfile *per_objfile,
 			  unsigned int offset_size,
 			  struct dwarf2_section_info *str_section,
 			  struct dwarf2_section_info *str_offsets_section,
-			  gdb::optional<ULONGEST> str_offsets_base,
+			  std::optional<ULONGEST> str_offsets_base,
 			  htab_t include_hash, struct dwarf2_cu *cu)
 {
   struct objfile *objfile = per_objfile->objfile;
@@ -805,7 +805,7 @@ dwarf_decode_macros (dwarf2_per_objfile *per_objfile,
 		     const struct line_header *lh, unsigned int offset_size,
 		     unsigned int offset, struct dwarf2_section_info *str_section,
 		     struct dwarf2_section_info *str_offsets_section,
-		     gdb::optional<ULONGEST> str_offsets_base,
+		     std::optional<ULONGEST> str_offsets_base,
 		     int section_is_gnu, struct dwarf2_cu *cu)
 {
   bfd *abfd;
diff --git a/gdb/dwarf2/macro.h b/gdb/dwarf2/macro.h
index d92994fef16..7daf147033a 100644
--- a/gdb/dwarf2/macro.h
+++ b/gdb/dwarf2/macro.h
@@ -30,7 +30,7 @@ extern void dwarf_decode_macros (dwarf2_per_objfile *per_objfile,
 				 unsigned int offset,
 				 dwarf2_section_info *str_section,
 				 dwarf2_section_info *str_offsets_section,
-				 gdb::optional<ULONGEST> str_offsets_base,
+				 std::optional<ULONGEST> str_offsets_base,
 				 int section_is_gnu, struct dwarf2_cu *cu);
 
 #endif /* GDB_DWARF2_MACRO_H */
diff --git a/gdb/dwarf2/read-gdb-index.c b/gdb/dwarf2/read-gdb-index.c
index 064a9f17b0e..7788626b67a 100644
--- a/gdb/dwarf2/read-gdb-index.c
+++ b/gdb/dwarf2/read-gdb-index.c
@@ -181,7 +181,7 @@ struct dw2_symtab_iterator
   dwarf2_per_objfile *per_objfile;
   /* If set, only look for symbols that match that block.  Valid values are
      GLOBAL_BLOCK and STATIC_BLOCK.  */
-  gdb::optional<block_enum> block_index;
+  std::optional<block_enum> block_index;
   /* The kind of symbol we're looking for.  */
   domain_enum domain;
   /* The list of CUs from the index entry of the symbol,
@@ -203,7 +203,7 @@ struct dw2_symtab_iterator
 static void
 dw2_symtab_iter_init (struct dw2_symtab_iterator *iter,
 		      dwarf2_per_objfile *per_objfile,
-		      gdb::optional<block_enum> block_index,
+		      std::optional<block_enum> block_index,
 		      domain_enum domain, offset_type namei,
 		      mapped_gdb_index &index)
 {
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 2a7fd8f5de5..6d86d28d8c0 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -78,7 +78,7 @@
 #include "build-id.h"
 #include "namespace.h"
 #include "gdbsupport/function-view.h"
-#include "gdbsupport/gdb_optional.h"
+#include <optional>
 #include "gdbsupport/underlying.h"
 #include "gdbsupport/hash_enum.h"
 #include "filename-seen-cache.h"
@@ -3916,7 +3916,7 @@ read_cutu_die_from_dwo (dwarf2_cu *cu,
 /* Return the signature of the compile unit, if found. In DWARF 4 and before,
    the signature is in the DW_AT_GNU_dwo_id attribute. In DWARF 5 and later, the
    signature is part of the header.  */
-static gdb::optional<ULONGEST>
+static std::optional<ULONGEST>
 lookup_dwo_id (struct dwarf2_cu *cu, struct die_info* comp_unit_die)
 {
   if (cu->header.version >= 5)
@@ -3924,7 +3924,7 @@ lookup_dwo_id (struct dwarf2_cu *cu, struct die_info* comp_unit_die)
   struct attribute *attr;
   attr = dwarf2_attr (comp_unit_die, DW_AT_GNU_dwo_id, cu);
   if (attr == nullptr || !attr->form_is_unsigned ())
-    return gdb::optional<ULONGEST> ();
+    return std::optional<ULONGEST> ();
   return attr->as_unsigned ();
 }
 
@@ -3957,7 +3957,7 @@ lookup_dwo_unit (dwarf2_cu *cu, die_info *comp_unit_die, const char *dwo_name)
     dwo_unit = lookup_dwo_type_unit (cu, dwo_name, comp_dir);
   else
     {
-      gdb::optional<ULONGEST> signature = lookup_dwo_id (cu, comp_unit_die);
+      std::optional<ULONGEST> signature = lookup_dwo_id (cu, comp_unit_die);
 
       if (!signature.has_value ())
 	error (_("Dwarf Error: missing dwo_id for dwo_name %s"
@@ -7829,7 +7829,7 @@ create_dwo_cu_reader (const struct die_reader_specs *reader,
   sect_offset sect_off = cu->per_cu->sect_off;
   struct dwarf2_section_info *section = cu->per_cu->section;
 
-  gdb::optional<ULONGEST> signature = lookup_dwo_id (cu, comp_unit_die);
+  std::optional<ULONGEST> signature = lookup_dwo_id (cu, comp_unit_die);
   if (!signature.has_value ())
     {
       complaint (_("Dwarf Error: debug entry at offset %s is missing"
@@ -10633,7 +10633,7 @@ dwarf2_rnglists_process (unsigned offset, struct dwarf2_cu *cu,
   struct objfile *objfile = per_objfile->objfile;
   bfd *obfd = objfile->obfd.get ();
   /* Base address selection entry.  */
-  gdb::optional<unrelocated_addr> base;
+  std::optional<unrelocated_addr> base;
   const gdb_byte *buffer;
   bool overflow = false;
   ULONGEST addr_index;
@@ -10839,7 +10839,7 @@ dwarf2_ranges_process (unsigned offset, struct dwarf2_cu *cu, dwarf_tag tag,
   unsigned int addr_size = cu_header->addr_size;
   CORE_ADDR mask = ~(~(CORE_ADDR)1 << (addr_size * 8 - 1));
   /* Base address selection entry.  */
-  gdb::optional<unrelocated_addr> base;
+  std::optional<unrelocated_addr> base;
   unsigned int dummy;
   const gdb_byte *buffer;
 
@@ -16070,8 +16070,8 @@ cooked_indexer::scan_attributes (dwarf2_per_cu_data *scanning_per_cu,
   bool is_declaration = false;
   sect_offset origin_offset {};
 
-  gdb::optional<unrelocated_addr> low_pc;
-  gdb::optional<unrelocated_addr> high_pc;
+  std::optional<unrelocated_addr> low_pc;
+  std::optional<unrelocated_addr> high_pc;
   bool high_pc_relative = false;
 
   for (int i = 0; i < abbrev->num_attrs; ++i)
@@ -17448,7 +17448,7 @@ dwarf2_per_objfile::read_line_string (const gdb_byte *buf,
 
 static unrelocated_addr
 read_addr_index_1 (dwarf2_per_objfile *per_objfile, unsigned int addr_index,
-		   gdb::optional<ULONGEST> addr_base, int addr_size)
+		   std::optional<ULONGEST> addr_base, int addr_size)
 {
   struct objfile *objfile = per_objfile->objfile;
   bfd *abfd = objfile->obfd.get ();
@@ -17501,7 +17501,7 @@ dwarf2_read_addr_index (dwarf2_per_cu_data *per_cu,
 			unsigned int addr_index)
 {
   struct dwarf2_cu *cu = per_objfile->get_cu (per_cu);
-  gdb::optional<ULONGEST> addr_base;
+  std::optional<ULONGEST> addr_base;
   int addr_size;
 
   /* We need addr_base and addr_size.
@@ -21270,7 +21270,7 @@ dwarf_decode_macros (struct dwarf2_cu *cu, unsigned int offset,
 
   struct dwarf2_section_info *str_offsets_section;
   struct dwarf2_section_info *str_section;
-  gdb::optional<ULONGEST> str_offsets_base;
+  std::optional<ULONGEST> str_offsets_base;
 
   if (cu->dwo_unit != nullptr)
     {
diff --git a/gdb/dwarf2/read.h b/gdb/dwarf2/read.h
index da907729320..7bb6d4c4d4b 100644
--- a/gdb/dwarf2/read.h
+++ b/gdb/dwarf2/read.h
@@ -524,7 +524,7 @@ struct dwarf2_per_bfd
 
   /* The shared '.dwz' file, if one exists.  This is used when the
      original data was compressed using 'dwz -m'.  */
-  gdb::optional<std::unique_ptr<struct dwz_file>> dwz_file;
+  std::optional<std::unique_ptr<struct dwz_file>> dwz_file;
 
   /* Whether copy relocations are supported by this object format.  */
   bool can_copy;
@@ -743,7 +743,7 @@ struct dwarf2_per_objfile
   dwarf2_cu *sym_cu = nullptr;
 
   /* CUs that are queued to be read.  */
-  gdb::optional<std::queue<dwarf2_queue_item>> queue;
+  std::optional<std::queue<dwarf2_queue_item>> queue;
 
 private:
   /* Hold the corresponding compunit_symtab for each CU or TU.  This
diff --git a/gdb/eval.c b/gdb/eval.c
index b859e825925..3358b0d8d32 100644
--- a/gdb/eval.c
+++ b/gdb/eval.c
@@ -102,7 +102,7 @@ expression::uses_objfile (struct objfile *objfile) const
 struct value *
 expression::evaluate (struct type *expect_type, enum noside noside)
 {
-  gdb::optional<enable_thread_stack_temporaries> stack_temporaries;
+  std::optional<enable_thread_stack_temporaries> stack_temporaries;
   if (target_has_execution () && inferior_ptid != null_ptid
       && language_defn->la_language == language_cplus
       && !thread_stack_temporaries_enabled_p (inferior_thread ()))
diff --git a/gdb/event-top.c b/gdb/event-top.c
index 6ce53704539..d47e703d961 100644
--- a/gdb/event-top.c
+++ b/gdb/event-top.c
@@ -706,7 +706,7 @@ void
 gdb_rl_deprep_term_function (void)
 {
 #ifdef RL_STATE_EOF
-  gdb::optional<scoped_restore_tmpl<int>> restore_eof_found;
+  std::optional<scoped_restore_tmpl<int>> restore_eof_found;
 
   if (RL_ISSTATE (RL_STATE_EOF))
     {
diff --git a/gdb/exceptions.c b/gdb/exceptions.c
index 2ba5a9c9fad..61fe74f648c 100644
--- a/gdb/exceptions.c
+++ b/gdb/exceptions.c
@@ -27,7 +27,7 @@
 #include "serial.h"
 #include "gdbthread.h"
 #include "ui.h"
-#include "gdbsupport/gdb_optional.h"
+#include <optional>
 
 static void
 print_flush (void)
@@ -38,7 +38,7 @@ print_flush (void)
   if (deprecated_error_begin_hook)
     deprecated_error_begin_hook ();
 
-  gdb::optional<target_terminal::scoped_restore_terminal_state> term_state;
+  std::optional<target_terminal::scoped_restore_terminal_state> term_state;
   if (target_supports_terminal_ours ())
     {
       term_state.emplace ();
diff --git a/gdb/extension-priv.h b/gdb/extension-priv.h
index e71eac20d4e..ccb63e694a5 100644
--- a/gdb/extension-priv.h
+++ b/gdb/extension-priv.h
@@ -256,13 +256,13 @@ struct extension_language_ops
      CONTENTS is the contents of the file.  This should either return
      colorized (using ANSI terminal escapes) version of the contents,
      or an empty option.  */
-  gdb::optional<std::string> (*colorize) (const std::string &name,
+  std::optional<std::string> (*colorize) (const std::string &name,
 					  const std::string &contents);
 
   /* Colorize a single line of disassembler output, CONTENT.  This should
      either return colorized (using ANSI terminal escapes) version of the
      contents, or an empty optional.  */
-  gdb::optional<std::string> (*colorize_disasm) (const std::string &content,
+  std::optional<std::string> (*colorize_disasm) (const std::string &content,
 						 gdbarch *gdbarch);
 
   /* Print a single instruction from ADDRESS in architecture GDBARCH.  INFO
@@ -276,7 +276,7 @@ struct extension_language_ops
      If no instruction can be disassembled then return an empty value and
      other extension languages will get a chance to perform the
      disassembly.  */
-  gdb::optional<int> (*print_insn) (struct gdbarch *gdbarch,
+  std::optional<int> (*print_insn) (struct gdbarch *gdbarch,
 				    CORE_ADDR address,
 				    struct disassemble_info *info);
 
diff --git a/gdb/extension.c b/gdb/extension.c
index 9cb393e1d50..2d7a381e426 100644
--- a/gdb/extension.c
+++ b/gdb/extension.c
@@ -939,10 +939,10 @@ xmethod_worker::get_result_type (value *object, gdb::array_view<value *> args)
 
 /* See extension.h.  */
 
-gdb::optional<std::string>
+std::optional<std::string>
 ext_lang_colorize (const std::string &filename, const std::string &contents)
 {
-  gdb::optional<std::string> result;
+  std::optional<std::string> result;
 
   for (const struct extension_language_defn *extlang : extension_languages)
     {
@@ -959,10 +959,10 @@ ext_lang_colorize (const std::string &filename, const std::string &contents)
 
 /* See extension.h.  */
 
-gdb::optional<std::string>
+std::optional<std::string>
 ext_lang_colorize_disasm (const std::string &content, gdbarch *gdbarch)
 {
-  gdb::optional<std::string> result;
+  std::optional<std::string> result;
 
   for (const struct extension_language_defn *extlang : extension_languages)
     {
@@ -979,7 +979,7 @@ ext_lang_colorize_disasm (const std::string &content, gdbarch *gdbarch)
 
 /* See extension.h.  */
 
-gdb::optional<int>
+std::optional<int>
 ext_lang_print_insn (struct gdbarch *gdbarch, CORE_ADDR address,
 		     struct disassemble_info *info)
 {
@@ -988,7 +988,7 @@ ext_lang_print_insn (struct gdbarch *gdbarch, CORE_ADDR address,
       if (extlang->ops == nullptr
 	  || extlang->ops->print_insn == nullptr)
 	continue;
-      gdb::optional<int> length
+      std::optional<int> length
 	= extlang->ops->print_insn (gdbarch, address, info);
       if (length.has_value ())
 	return length;
diff --git a/gdb/extension.h b/gdb/extension.h
index 282d591be43..530f6ce72ac 100644
--- a/gdb/extension.h
+++ b/gdb/extension.h
@@ -22,7 +22,7 @@
 
 #include "mi/mi-cmds.h"
 #include "gdbsupport/array-view.h"
-#include "gdbsupport/gdb_optional.h"
+#include <optional>
 
 struct breakpoint;
 struct command_line;
@@ -316,7 +316,7 @@ extern void get_matching_xmethod_workers
    either a colorized (using ANSI terminal escapes) version of the
    source code, or an empty value if colorizing could not be done.  */
 
-extern gdb::optional<std::string> ext_lang_colorize
+extern std::optional<std::string> ext_lang_colorize
   (const std::string &filename, const std::string &contents);
 
 /* Try to colorize a single line of disassembler output, CONTENT for
@@ -324,7 +324,7 @@ extern gdb::optional<std::string> ext_lang_colorize
    escapes) version of CONTENT, or an empty value if colorizing could not
    be done.  */
 
-extern gdb::optional<std::string> ext_lang_colorize_disasm
+extern std::optional<std::string> ext_lang_colorize_disasm
   (const std::string &content, gdbarch *gdbarch);
 
 /* Calls extension_language_ops::print_insn for each extension language,
@@ -334,7 +334,7 @@ extern gdb::optional<std::string> ext_lang_colorize_disasm
    All arguments are forwarded to extension_language_ops::print_insn, see
    that function for a full description.  */
 
-extern gdb::optional<int> ext_lang_print_insn
+extern std::optional<int> ext_lang_print_insn
   (struct gdbarch *gdbarch, CORE_ADDR address, struct disassemble_info *info);
 
 /* When GDB calls into an extension language because an objfile was
diff --git a/gdb/f-lang.c b/gdb/f-lang.c
index fc0614e5761..ebcca7adea3 100644
--- a/gdb/f-lang.c
+++ b/gdb/f-lang.c
@@ -306,7 +306,7 @@ class fortran_array_repacker_base_impl
 
   /* Set and reset to handle removing intermediate values from the
      value chain.  */
-  gdb::optional<scoped_value_mark> m_mark;
+  std::optional<scoped_value_mark> m_mark;
 };
 
 /* A class used by FORTRAN_VALUE_SUBARRAY when repacking Fortran array
diff --git a/gdb/fbsd-nat.c b/gdb/fbsd-nat.c
index 0e0d0cdf621..211b83f555a 100644
--- a/gdb/fbsd-nat.c
+++ b/gdb/fbsd-nat.c
@@ -99,7 +99,7 @@ fbsd_nat_target::have_pending_event (ptid_t filter)
 
 /* See fbsd-nat.h.  */
 
-gdb::optional<fbsd_nat_target::pending_event>
+std::optional<fbsd_nat_target::pending_event>
 fbsd_nat_target::take_pending_event (ptid_t filter)
 {
   for (auto it = m_pending_events.begin (); it != m_pending_events.end (); it++)
@@ -1663,7 +1663,7 @@ fbsd_nat_target::wait (ptid_t ptid, struct target_waitstatus *ourstatus,
 			 target_options_to_string (target_options).c_str ());
 
   /* If there is a valid pending event, return it.  */
-  gdb::optional<pending_event> event = take_pending_event (ptid);
+  std::optional<pending_event> event = take_pending_event (ptid);
   if (event.has_value ())
     {
       /* Stop any other inferiors currently running.  */
@@ -1899,7 +1899,7 @@ fbsd_nat_target::detach_fork_children (inferior *inf)
 
   while (1)
     {
-      gdb::optional<pending_event> event = take_pending_event (ptid);
+      std::optional<pending_event> event = take_pending_event (ptid);
       if (!event.has_value ())
 	break;
 
diff --git a/gdb/fbsd-nat.h b/gdb/fbsd-nat.h
index 7016cc0242a..8118408bf47 100644
--- a/gdb/fbsd-nat.h
+++ b/gdb/fbsd-nat.h
@@ -20,7 +20,7 @@
 #ifndef FBSD_NAT_H
 #define FBSD_NAT_H
 
-#include "gdbsupport/gdb_optional.h"
+#include <optional>
 #include "inf-ptrace.h"
 #include "regcache.h"
 #include "regset.h"
@@ -262,7 +262,7 @@ class fbsd_nat_target : public inf_ptrace_target
      FILTER.  If there is a matching event, the event is removed from
      the pending list and returned.  */
 
-  gdb::optional<pending_event> take_pending_event (ptid_t filter);
+  std::optional<pending_event> take_pending_event (ptid_t filter);
 
   /* List of pending events.  */
 
diff --git a/gdb/fbsd-tdep.c b/gdb/fbsd-tdep.c
index d166d785736..4ac33697082 100644
--- a/gdb/fbsd-tdep.c
+++ b/gdb/fbsd-tdep.c
@@ -650,10 +650,10 @@ find_signalled_thread (struct thread_info *info, void *data)
    the data is prefixed with a 32-bit integer size to match the format
    used in FreeBSD NT_PROCSTAT_* notes.  */
 
-static gdb::optional<gdb::byte_vector>
+static std::optional<gdb::byte_vector>
 fbsd_make_note_desc (enum target_object object, uint32_t structsize)
 {
-  gdb::optional<gdb::byte_vector> buf =
+  std::optional<gdb::byte_vector> buf =
     target_read_alloc (current_inferior ()->top_target (), object, NULL);
   if (!buf || buf->empty ())
     return {};
@@ -735,7 +735,7 @@ fbsd_make_corefile_notes (struct gdbarch *gdbarch, bfd *obfd, int *note_size)
 
   /* Auxiliary vector.  */
   uint32_t structsize = gdbarch_ptr_bit (gdbarch) / 4; /* Elf_Auxinfo  */
-  gdb::optional<gdb::byte_vector> note_desc =
+  std::optional<gdb::byte_vector> note_desc =
     fbsd_make_note_desc (TARGET_OBJECT_AUXV, structsize);
   if (note_desc && !note_desc->empty ())
     {
@@ -2340,7 +2340,7 @@ fbsd_vdso_range (struct gdbarch *gdbarch, struct mem_range *range)
   else
     {
       /* Fetch the list of address space entries from the running target. */
-      gdb::optional<gdb::byte_vector> buf =
+      std::optional<gdb::byte_vector> buf =
 	target_read_alloc (current_inferior ()->top_target (),
 			   TARGET_OBJECT_FREEBSD_VMMAP, nullptr);
       if (!buf || buf->empty ())
diff --git a/gdb/gdbthread.h b/gdb/gdbthread.h
index 938a47ff012..b2c6baf4432 100644
--- a/gdb/gdbthread.h
+++ b/gdb/gdbthread.h
@@ -211,10 +211,10 @@ struct thread_suspend_state
 
      - If the thread is running, then this field has its value removed by
        calling stop_pc.reset() (see thread_info::set_executing()).
-       Attempting to read a gdb::optional with no value is undefined
+       Attempting to read a std::optional with no value is undefined
        behaviour and will trigger an assertion error when _GLIBCXX_DEBUG is
        defined, which should make error easier to track down.  */
-  gdb::optional<CORE_ADDR> stop_pc;
+  std::optional<CORE_ADDR> stop_pc;
 };
 
 /* Base class for target-specific thread data.  */
@@ -661,7 +661,7 @@ extern void delete_thread_silent (struct thread_info *thread);
    available.  If SILENT, then don't inform the CLI about the
    exit.  */
 extern void set_thread_exited (thread_info *tp,
-			       gdb::optional<ULONGEST> exit_code = {},
+			       std::optional<ULONGEST> exit_code = {},
 			       bool silent = false);
 
 /* Delete a step_resume_breakpoint from the thread database.  */
@@ -1058,7 +1058,7 @@ extern bool switch_to_thread_if_alive (thread_info *thr);
    exception if !FLAGS.SILENT and !FLAGS.CONT and CMD fails.  */
 
 extern void thread_try_catch_cmd (thread_info *thr,
-				  gdb::optional<int> ada_task,
+				  std::optional<int> ada_task,
 				  const char *cmd, int from_tty,
 				  const qcs_flags &flags);
 
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index e424077c1c0..04598c6f4be 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -1045,7 +1045,7 @@ has_static_range (const struct range_bounds *bounds)
 
 /* See gdbtypes.h.  */
 
-gdb::optional<LONGEST>
+std::optional<LONGEST>
 get_discrete_low_bound (struct type *type)
 {
   type = check_typedef (type);
@@ -1061,7 +1061,7 @@ get_discrete_low_bound (struct type *type)
 
 	if (type->target_type ()->code () == TYPE_CODE_ENUM)
 	  {
-	    gdb::optional<LONGEST> low_pos
+	    std::optional<LONGEST> low_pos
 	      = discrete_position (type->target_type (), low);
 
 	    if (low_pos.has_value ())
@@ -1112,7 +1112,7 @@ get_discrete_low_bound (struct type *type)
 
 /* See gdbtypes.h.  */
 
-gdb::optional<LONGEST>
+std::optional<LONGEST>
 get_discrete_high_bound (struct type *type)
 {
   type = check_typedef (type);
@@ -1128,7 +1128,7 @@ get_discrete_high_bound (struct type *type)
 
 	if (type->target_type ()->code () == TYPE_CODE_ENUM)
 	  {
-	    gdb::optional<LONGEST> high_pos
+	    std::optional<LONGEST> high_pos
 	      = discrete_position (type->target_type (), high);
 
 	    if (high_pos.has_value ())
@@ -1191,11 +1191,11 @@ get_discrete_high_bound (struct type *type)
 bool
 get_discrete_bounds (struct type *type, LONGEST *lowp, LONGEST *highp)
 {
-  gdb::optional<LONGEST> low = get_discrete_low_bound (type);
+  std::optional<LONGEST> low = get_discrete_low_bound (type);
   if (!low.has_value ())
     return false;
 
-  gdb::optional<LONGEST> high = get_discrete_high_bound (type);
+  std::optional<LONGEST> high = get_discrete_high_bound (type);
   if (!high.has_value ())
     return false;
 
@@ -1243,7 +1243,7 @@ get_array_bounds (struct type *type, LONGEST *low_bound, LONGEST *high_bound)
    in which case the value of POS is unmodified.
 */
 
-gdb::optional<LONGEST>
+std::optional<LONGEST>
 discrete_position (struct type *type, LONGEST val)
 {
   if (type->code () == TYPE_CODE_RANGE)
@@ -2534,7 +2534,7 @@ compute_variant_fields_inner (struct type *type,
 			      std::vector<bool> &flags)
 {
   /* Evaluate the discriminant.  */
-  gdb::optional<ULONGEST> discr_value;
+  std::optional<ULONGEST> discr_value;
   if (part.discriminant_index != -1)
     {
       int idx = part.discriminant_index;
@@ -2757,7 +2757,7 @@ resolve_dynamic_type_internal (struct type *type,
   if (!is_dynamic_type_internal (real_type, top_level))
     return type;
 
-  gdb::optional<CORE_ADDR> type_length;
+  std::optional<CORE_ADDR> type_length;
   prop = TYPE_DYNAMIC_LENGTH (type);
   if (prop != NULL
       && dwarf2_evaluate_property (prop, frame, addr_stack, &value))
diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h
index 505c8ba12b5..d5bd6d2d2d7 100644
--- a/gdb/gdbtypes.h
+++ b/gdb/gdbtypes.h
@@ -47,7 +47,7 @@
 #include "hashtab.h"
 #include "gdbsupport/array-view.h"
 #include "gdbsupport/gdb-hashtab.h"
-#include "gdbsupport/gdb_optional.h"
+#include <optional>
 #include "gdbsupport/offset-type.h"
 #include "gdbsupport/enum-flags.h"
 #include "gdbsupport/underlying.h"
@@ -2663,11 +2663,11 @@ extern bool get_discrete_bounds (struct type *type, LONGEST *lowp,
 
 /* If TYPE's low bound is a known constant, return it, else return nullopt.  */
 
-extern gdb::optional<LONGEST> get_discrete_low_bound (struct type *type);
+extern std::optional<LONGEST> get_discrete_low_bound (struct type *type);
 
 /* If TYPE's high bound is a known constant, return it, else return nullopt.  */
 
-extern gdb::optional<LONGEST> get_discrete_high_bound (struct type *type);
+extern std::optional<LONGEST> get_discrete_high_bound (struct type *type);
 
 /* Assuming TYPE is a simple, non-empty array type, compute its upper
    and lower bound.  Save the low bound into LOW_BOUND if not NULL.
@@ -2679,7 +2679,7 @@ extern gdb::optional<LONGEST> get_discrete_high_bound (struct type *type);
 extern bool get_array_bounds (struct type *type, LONGEST *low_bound,
 			      LONGEST *high_bound);
 
-extern gdb::optional<LONGEST> discrete_position (struct type *type,
+extern std::optional<LONGEST> discrete_position (struct type *type,
 						 LONGEST val);
 
 extern int class_types_same_p (const struct type *, const struct type *);
diff --git a/gdb/guile/scm-ports.c b/gdb/guile/scm-ports.c
index a27ea8b3c80..ceca60b37e5 100644
--- a/gdb/guile/scm-ports.c
+++ b/gdb/guile/scm-ports.c
@@ -26,7 +26,7 @@
 #include "ui.h"
 #include "target.h"
 #include "guile-internal.h"
-#include "gdbsupport/gdb_optional.h"
+#include <optional>
 
 #ifdef HAVE_POLL
 #if defined (HAVE_POLL_H)
@@ -602,7 +602,7 @@ ioscm_with_output_to_port_worker (SCM port, SCM thunk, enum oport oport,
 						  ? &gdb_stderr : &gdb_stdout);
 
   {
-    gdb::optional<ui_out_redirect_pop> redirect_popper;
+    std::optional<ui_out_redirect_pop> redirect_popper;
     if (oport == GDB_STDERR)
       gdb_stderr = port_file.get ();
     else
diff --git a/gdb/ia64-tdep.c b/gdb/ia64-tdep.c
index cdd5553cf5d..6d537c4c8d3 100644
--- a/gdb/ia64-tdep.c
+++ b/gdb/ia64-tdep.c
@@ -69,7 +69,7 @@ struct ia64_table_entry
   };
 
 static struct ia64_table_entry *ktab = NULL;
-static gdb::optional<gdb::byte_vector> ktab_buf;
+static std::optional<gdb::byte_vector> ktab_buf;
 
 #endif
 
@@ -2648,7 +2648,7 @@ ia64_access_mem (unw_addr_space_t as,
 }
 
 /* Call low-level function to access the kernel unwind table.  */
-static gdb::optional<gdb::byte_vector>
+static std::optional<gdb::byte_vector>
 getunwind_table ()
 {
   /* FIXME drow/2005-09-10: This code used to call
diff --git a/gdb/inf-child.c b/gdb/inf-child.c
index 25afdb2202e..4eeb68be8f0 100644
--- a/gdb/inf-child.c
+++ b/gdb/inf-child.c
@@ -352,7 +352,7 @@ inf_child_target::fileio_unlink (struct inferior *inf, const char *filename,
 
 /* Implementation of to_fileio_readlink.  */
 
-gdb::optional<std::string>
+std::optional<std::string>
 inf_child_target::fileio_readlink (struct inferior *inf, const char *filename,
 				   fileio_error *target_errno)
 {
diff --git a/gdb/inf-child.h b/gdb/inf-child.h
index 017e8e35680..4aeb3898028 100644
--- a/gdb/inf-child.h
+++ b/gdb/inf-child.h
@@ -85,7 +85,7 @@ class inf_child_target
   int fileio_unlink (struct inferior *inf,
 		     const char *filename,
 		     fileio_error *target_errno) override;
-  gdb::optional<std::string> fileio_readlink (struct inferior *inf,
+  std::optional<std::string> fileio_readlink (struct inferior *inf,
 					      const char *filename,
 					      fileio_error *target_errno) override;
   bool use_agent (bool use) override;
diff --git a/gdb/infcmd.c b/gdb/infcmd.c
index 2fc0eb138a6..ec818bc6936 100644
--- a/gdb/infcmd.c
+++ b/gdb/infcmd.c
@@ -52,7 +52,7 @@
 #include "ui.h"
 #include "interps.h"
 #include "skip.h"
-#include "gdbsupport/gdb_optional.h"
+#include <optional>
 #include "source.h"
 #include "cli/cli-style.h"
 #include "dwarf2/loc.h"
@@ -2790,7 +2790,7 @@ notice_new_inferior (thread_info *thr, bool leave_running, int from_tty)
   enum attach_post_wait_mode mode
     = leave_running ? ATTACH_POST_WAIT_RESUME : ATTACH_POST_WAIT_NOTHING;
 
-  gdb::optional<scoped_restore_current_thread> restore_thread;
+  std::optional<scoped_restore_current_thread> restore_thread;
 
   if (inferior_ptid != null_ptid)
     restore_thread.emplace ();
diff --git a/gdb/inferior.c b/gdb/inferior.c
index 927c5f16ae2..fbe27c8b873 100644
--- a/gdb/inferior.c
+++ b/gdb/inferior.c
@@ -728,10 +728,10 @@ switch_to_inferior_no_thread (inferior *inf)
 
 /* See regcache.h.  */
 
-gdb::optional<scoped_restore_current_thread>
+std::optional<scoped_restore_current_thread>
 maybe_switch_inferior (inferior *inf)
 {
-  gdb::optional<scoped_restore_current_thread> maybe_restore_thread;
+  std::optional<scoped_restore_current_thread> maybe_restore_thread;
   if (inf != current_inferior ())
     {
       maybe_restore_thread.emplace ();
diff --git a/gdb/inferior.h b/gdb/inferior.h
index 33eff7a9141..f8f9395aec4 100644
--- a/gdb/inferior.h
+++ b/gdb/inferior.h
@@ -340,7 +340,7 @@ extern void switch_to_inferior_no_thread (inferior *inf);
 
    If the current inferior was changed, return an RAII object that will
    restore the original current context.  */
-extern gdb::optional<scoped_restore_current_thread> maybe_switch_inferior
+extern std::optional<scoped_restore_current_thread> maybe_switch_inferior
   (inferior *inf);
 
 /* Info about an inferior's target description.  There's one of these
diff --git a/gdb/inflow.c b/gdb/inflow.c
index 095c5f03672..749f620739d 100644
--- a/gdb/inflow.c
+++ b/gdb/inflow.c
@@ -113,9 +113,9 @@ static struct terminal_info *get_inflow_inferior_data (struct inferior *);
    we save our handlers in these two variables and set SIGINT and SIGQUIT
    to SIG_IGN.  */
 
-static gdb::optional<sighandler_t> sigint_ours;
+static std::optional<sighandler_t> sigint_ours;
 #ifdef SIGQUIT
-static gdb::optional<sighandler_t> sigquit_ours;
+static std::optional<sighandler_t> sigquit_ours;
 #endif
 
 /* The name of the tty (from the `tty' command) that we're giving to
diff --git a/gdb/infrun.c b/gdb/infrun.c
index 70c33a9c392..a1543ab2443 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -62,7 +62,7 @@
 #include "thread-fsm.h"
 #include "gdbsupport/enum-flags.h"
 #include "progspace-and-thread.h"
-#include "gdbsupport/gdb_optional.h"
+#include <optional>
 #include "arch-utils.h"
 #include "gdbsupport/scope-exit.h"
 #include "gdbsupport/forward-scope-exit.h"
@@ -713,7 +713,7 @@ holding the child stopped.  Try \"set detach-on-fork\" or \
     {
       /* If FOLLOW_CHILD, we leave CHILD_INF as the current inferior
 	 (do not restore the parent as the current inferior).  */
-      gdb::optional<scoped_restore_current_thread> maybe_restore;
+      std::optional<scoped_restore_current_thread> maybe_restore;
 
       if (!follow_child && !sched_multi)
 	maybe_restore.emplace ();
@@ -4587,7 +4587,7 @@ fetch_inferior_event ()
        debugging.  If we're looking at traceframes while the target is
        running, we're going to need to get back to that mode after
        handling the event.  */
-    gdb::optional<scoped_restore_current_traceframe> maybe_restore_traceframe;
+    std::optional<scoped_restore_current_traceframe> maybe_restore_traceframe;
     if (non_stop)
       {
 	maybe_restore_traceframe.emplace ();
@@ -4960,7 +4960,7 @@ adjust_pc_after_break (struct thread_info *thread,
       || (target_is_non_stop_p ()
 	  && moribund_breakpoint_here_p (aspace, breakpoint_pc)))
     {
-      gdb::optional<scoped_restore_tmpl<int>> restore_operation_disable;
+      std::optional<scoped_restore_tmpl<int>> restore_operation_disable;
 
       if (record_full_is_used ())
 	restore_operation_disable.emplace
@@ -7109,7 +7109,7 @@ handle_signal_stop (struct execution_control_state *ecs)
 	  decr_pc = gdbarch_decr_pc_after_break (gdbarch);
 	  if (decr_pc != 0)
 	    {
-	      gdb::optional<scoped_restore_tmpl<int>>
+	      std::optional<scoped_restore_tmpl<int>>
 		restore_operation_disable;
 
 	      if (record_full_is_used ())
@@ -9343,7 +9343,7 @@ normal_stop ()
 	   && last.kind () != TARGET_WAITKIND_THREAD_EXITED)
     finish_ptid = inferior_ptid;
 
-  gdb::optional<scoped_finish_thread_state> maybe_finish_thread_state;
+  std::optional<scoped_finish_thread_state> maybe_finish_thread_state;
   if (finish_ptid != null_ptid)
     {
       maybe_finish_thread_state.emplace
diff --git a/gdb/interps.c b/gdb/interps.c
index 2fbf92fa0a2..bec2c85e2fd 100644
--- a/gdb/interps.c
+++ b/gdb/interps.c
@@ -430,7 +430,7 @@ interps_notify_new_thread (thread_info *t)
 
 void
 interps_notify_thread_exited (thread_info *t,
-			      gdb::optional<ULONGEST> exit_code,
+			      std::optional<ULONGEST> exit_code,
 			      int silent)
 {
   interps_notify (&interp::on_thread_exited, t, exit_code, silent);
diff --git a/gdb/interps.h b/gdb/interps.h
index 728155ae81b..f662f54e950 100644
--- a/gdb/interps.h
+++ b/gdb/interps.h
@@ -123,7 +123,7 @@ class interp : public intrusive_list_node<interp>
 
   /* Notify the interpreter that thread T has exited.  */
   virtual void on_thread_exited (thread_info *,
-				 gdb::optional<ULONGEST> exit_code,
+				 std::optional<ULONGEST> exit_code,
 				 int silent) {}
 
   /* Notify the interpreter that inferior INF was added.  */
@@ -292,7 +292,7 @@ extern void interps_notify_new_thread (thread_info *t);
 
 /* Notify all interpreters that thread T has exited.  */
 extern void interps_notify_thread_exited (thread_info *t,
-					  gdb::optional<ULONGEST> exit_code,
+					  std::optional<ULONGEST> exit_code,
 					  int silent);
 
 /* Notify all interpreters that inferior INF was added.  */
diff --git a/gdb/jit.c b/gdb/jit.c
index 9e8325ab803..0e3a4285bdd 100644
--- a/gdb/jit.c
+++ b/gdb/jit.c
@@ -76,7 +76,7 @@ maint_info_jit_cmd (const char *args, int from_tty)
   inferior *inf = current_inferior ();
   bool printed_header = false;
 
-  gdb::optional<ui_out_emit_table> table_emitter;
+  std::optional<ui_out_emit_table> table_emitter;
 
   /* Print a line for each JIT-ed objfile.  */
   for (objfile *obj : inf->pspace->objfiles ())
diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c
index d3e9560c2fc..7b0562cf89b 100644
--- a/gdb/linux-nat.c
+++ b/gdb/linux-nat.c
@@ -1295,7 +1295,7 @@ get_detach_signal (struct lwp_info *lp)
 
 /* If LP has a pending fork/vfork/clone status, return it.  */
 
-static gdb::optional<target_waitstatus>
+static std::optional<target_waitstatus>
 get_pending_child_status (lwp_info *lp)
 {
   LINUX_NAT_SCOPED_DEBUG_ENTER_EXIT;
@@ -1369,7 +1369,7 @@ detach_one_lwp (struct lwp_info *lp, int *signo_p)
      event, there is a process/thread GDB is attached to that the core
      of GDB doesn't know about.  Detach from it.  */
 
-  gdb::optional<target_waitstatus> ws = get_pending_child_status (lp);
+  std::optional<target_waitstatus> ws = get_pending_child_status (lp);
   if (ws.has_value ())
     detach_one_pid (ws->child_ptid ().lwp (), 0);
 
@@ -3616,7 +3616,7 @@ kill_wait_callback (struct lwp_info *lp)
 static int
 kill_unfollowed_child_callback (lwp_info *lp)
 {
-  gdb::optional<target_waitstatus> ws = get_pending_child_status (lp);
+  std::optional<target_waitstatus> ws = get_pending_child_status (lp);
   if (ws.has_value ())
     {
       ptid_t child_ptid = ws->child_ptid ();
@@ -4074,7 +4074,7 @@ linux_proc_xfer_memory_partial (int pid, gdb_byte *readbuf,
 static bool
 proc_mem_file_is_writable ()
 {
-  static gdb::optional<bool> writable;
+  static std::optional<bool> writable;
 
   if (writable.has_value ())
     return *writable;
@@ -4463,7 +4463,7 @@ linux_nat_target::fileio_open (struct inferior *inf, const char *filename,
 
 /* Implementation of to_fileio_readlink.  */
 
-gdb::optional<std::string>
+std::optional<std::string>
 linux_nat_target::fileio_readlink (struct inferior *inf, const char *filename,
 				   fileio_error *target_errno)
 {
diff --git a/gdb/linux-nat.h b/gdb/linux-nat.h
index cce8bb3ddcc..428bb9f1628 100644
--- a/gdb/linux-nat.h
+++ b/gdb/linux-nat.h
@@ -103,7 +103,7 @@ class linux_nat_target : public inf_ptrace_target
 		   int flags, int mode, int warn_if_slow,
 		   fileio_error *target_errno) override;
 
-  gdb::optional<std::string>
+  std::optional<std::string>
     fileio_readlink (struct inferior *inf,
 		     const char *filename,
 		     fileio_error *target_errno) override;
diff --git a/gdb/linux-tdep.c b/gdb/linux-tdep.c
index eff7a0ca42e..db29b032018 100644
--- a/gdb/linux-tdep.c
+++ b/gdb/linux-tdep.c
@@ -38,7 +38,7 @@
 #include "gdbcmd.h"
 #include "gdbsupport/gdb_regex.h"
 #include "gdbsupport/enum-flags.h"
-#include "gdbsupport/gdb_optional.h"
+#include <optional>
 #include "gcore.h"
 #include "gcore-elf.h"
 #include "solib-svr4.h"
@@ -229,7 +229,7 @@ struct linux_info
   int vsyscall_range_p = 0;
 
   /* Inferior's displaced step buffers.  */
-  gdb::optional<displaced_step_buffers> disp_step_bufs;
+  std::optional<displaced_step_buffers> disp_step_bufs;
 };
 
 /* Per-inferior data key.  */
@@ -589,7 +589,7 @@ struct mapping_regexes
 static int
 mapping_is_anonymous_p (const char *filename)
 {
-  static gdb::optional<mapping_regexes> regexes;
+  static std::optional<mapping_regexes> regexes;
   static int init_regex_p = 0;
 
   if (!init_regex_p)
@@ -873,7 +873,7 @@ linux_info_proc (struct gdbarch *gdbarch, const char *args,
   if (cwd_f)
     {
       xsnprintf (filename, sizeof filename, "/proc/%ld/cwd", pid);
-      gdb::optional<std::string> contents
+      std::optional<std::string> contents
 	= target_fileio_readlink (NULL, filename, &target_errno);
       if (contents.has_value ())
 	gdb_printf ("cwd = '%s'\n", contents->c_str ());
@@ -883,7 +883,7 @@ linux_info_proc (struct gdbarch *gdbarch, const char *args,
   if (exe_f)
     {
       xsnprintf (filename, sizeof filename, "/proc/%ld/exe", pid);
-      gdb::optional<std::string> contents
+      std::optional<std::string> contents
 	= target_fileio_readlink (NULL, filename, &target_errno);
       if (contents.has_value ())
 	gdb_printf ("exe = '%s'\n", contents->c_str ());
@@ -2108,7 +2108,7 @@ linux_make_corefile_notes (struct gdbarch *gdbarch, bfd *obfd, int *note_size)
     return NULL;
 
   /* Auxillary vector.  */
-  gdb::optional<gdb::byte_vector> auxv =
+  std::optional<gdb::byte_vector> auxv =
     target_read_alloc (current_inferior ()->top_target (),
 		       TARGET_OBJECT_AUXV, NULL);
   if (auxv && !auxv->empty ())
@@ -2675,7 +2675,7 @@ linux_displaced_step_restore_all_in_ptid (inferior *parent_inf, ptid_t ptid)
 /* Helper for linux_get_hwcap and linux_get_hwcap2.  */
 
 static CORE_ADDR
-linux_get_hwcap_helper (const gdb::optional<gdb::byte_vector> &auxv,
+linux_get_hwcap_helper (const std::optional<gdb::byte_vector> &auxv,
 			target_ops *target, gdbarch *gdbarch, CORE_ADDR match)
 {
   CORE_ADDR field;
@@ -2688,7 +2688,7 @@ linux_get_hwcap_helper (const gdb::optional<gdb::byte_vector> &auxv,
 /* See linux-tdep.h.  */
 
 CORE_ADDR
-linux_get_hwcap (const gdb::optional<gdb::byte_vector> &auxv,
+linux_get_hwcap (const std::optional<gdb::byte_vector> &auxv,
 		 target_ops *target, gdbarch *gdbarch)
 {
   return linux_get_hwcap_helper (auxv, target, gdbarch, AT_HWCAP);
@@ -2707,7 +2707,7 @@ linux_get_hwcap ()
 /* See linux-tdep.h.  */
 
 CORE_ADDR
-linux_get_hwcap2 (const gdb::optional<gdb::byte_vector> &auxv,
+linux_get_hwcap2 (const std::optional<gdb::byte_vector> &auxv,
 		  target_ops *target, gdbarch *gdbarch)
 {
   return linux_get_hwcap_helper (auxv, target, gdbarch, AT_HWCAP2);
diff --git a/gdb/linux-tdep.h b/gdb/linux-tdep.h
index e09a6ef32b1..819b221e599 100644
--- a/gdb/linux-tdep.h
+++ b/gdb/linux-tdep.h
@@ -94,7 +94,7 @@ extern int linux_is_uclinux (void);
    parse auxv entries.
 
    On error, 0 is returned.  */
-extern CORE_ADDR linux_get_hwcap (const gdb::optional<gdb::byte_vector> &auxv,
+extern CORE_ADDR linux_get_hwcap (const std::optional<gdb::byte_vector> &auxv,
 				  struct target_ops *target, gdbarch *gdbarch);
 
 /* Same as the above, but obtain all the inputs from the current inferior.  */
@@ -105,7 +105,7 @@ extern CORE_ADDR linux_get_hwcap ();
    parse auxv entries.
 
    On error, 0 is returned.  */
-extern CORE_ADDR linux_get_hwcap2 (const gdb::optional<gdb::byte_vector> &auxv,
+extern CORE_ADDR linux_get_hwcap2 (const std::optional<gdb::byte_vector> &auxv,
 				   struct target_ops *target, gdbarch *gdbarch);
 
 /* Same as the above, but obtain all the inputs from the current inferior.  */
diff --git a/gdb/linux-thread-db.c b/gdb/linux-thread-db.c
index cef78f599be..c2ec422b7f3 100644
--- a/gdb/linux-thread-db.c
+++ b/gdb/linux-thread-db.c
@@ -312,7 +312,7 @@ struct thread_db_thread_info : public private_thread_info
   /* Cached thread state.  */
   td_thrhandle_t th {};
   thread_t tid {};
-  gdb::optional<gdb::byte_vector> thread_handle;
+  std::optional<gdb::byte_vector> thread_handle;
 };
 
 static thread_db_thread_info *
diff --git a/gdb/main.c b/gdb/main.c
index 2da39f89a90..486c1ffe071 100644
--- a/gdb/main.c
+++ b/gdb/main.c
@@ -361,7 +361,7 @@ get_init_files (std::vector<std::string> *system_gdbinit,
 {
   /* Cache the file lookup object so we only actually search for the files
      once.  */
-  static gdb::optional<gdb_initfile_finder> init_files;
+  static std::optional<gdb_initfile_finder> init_files;
   if (!init_files.has_value ())
     init_files.emplace (GDBINIT, SYSTEM_GDBINIT, SYSTEM_GDBINIT_RELOCATABLE,
 			SYSTEM_GDBINIT_DIR, SYSTEM_GDBINIT_DIR_RELOCATABLE,
@@ -381,7 +381,7 @@ get_earlyinit_files (std::string *home_gdbearlyinit)
 {
   /* Cache the file lookup object so we only actually search for the files
      once.  */
-  static gdb::optional<gdb_initfile_finder> init_files;
+  static std::optional<gdb_initfile_finder> init_files;
   if (!init_files.has_value ())
     init_files.emplace (GDBEARLYINIT, nullptr, false, nullptr, false, false);
 
diff --git a/gdb/mi/mi-cmd-stack.c b/gdb/mi/mi-cmd-stack.c
index e473be7d465..6982338751a 100644
--- a/gdb/mi/mi-cmd-stack.c
+++ b/gdb/mi/mi-cmd-stack.c
@@ -34,7 +34,7 @@
 #include "extension.h"
 #include <ctype.h>
 #include "mi-parse.h"
-#include "gdbsupport/gdb_optional.h"
+#include <optional>
 #include "gdbsupport/gdb-safe-ctype.h"
 #include "inferior.h"
 #include "observable.h"
@@ -515,7 +515,7 @@ list_arg_or_local (const struct frame_arg *arg, enum what_to_list what,
 					     arg->val->type ()->length ()))))
     return;
 
-  gdb::optional<ui_out_emit_tuple> tuple_emitter;
+  std::optional<ui_out_emit_tuple> tuple_emitter;
   if (values != PRINT_NO_VALUES || what == all)
     tuple_emitter.emplace (uiout, nullptr);
 
diff --git a/gdb/mi/mi-cmd-var.c b/gdb/mi/mi-cmd-var.c
index 8b4dd6d0c96..87c54c8c95d 100644
--- a/gdb/mi/mi-cmd-var.c
+++ b/gdb/mi/mi-cmd-var.c
@@ -30,7 +30,7 @@
 #include "mi-getopt.h"
 #include "gdbthread.h"
 #include "mi-parse.h"
-#include "gdbsupport/gdb_optional.h"
+#include <optional>
 #include "inferior.h"
 
 static void varobj_update_one (struct varobj *var,
diff --git a/gdb/mi/mi-cmds.c b/gdb/mi/mi-cmds.c
index 5ea31fc98d1..dbee2d010ea 100644
--- a/gdb/mi/mi-cmds.c
+++ b/gdb/mi/mi-cmds.c
@@ -183,7 +183,7 @@ mi_command::mi_command (const char *name, int *suppress_notification)
 
 /* See mi-cmds.h.  */
 
-gdb::optional<scoped_restore_tmpl<int>>
+std::optional<scoped_restore_tmpl<int>>
 mi_command::do_suppress_notification () const
 {
   if (m_suppress_notification != nullptr)
diff --git a/gdb/mi/mi-cmds.h b/gdb/mi/mi-cmds.h
index e67c486a997..f99c24313b9 100644
--- a/gdb/mi/mi-cmds.h
+++ b/gdb/mi/mi-cmds.h
@@ -23,7 +23,7 @@
 #define MI_MI_CMDS_H
 
 #include "gdbsupport/function-view.h"
-#include "gdbsupport/gdb_optional.h"
+#include <optional>
 #include "mi/mi-main.h"
 
 enum print_values {
@@ -180,12 +180,12 @@ struct mi_command
 
   /* If this command was created with a suppress notifications pointer,
      then this function will set the suppress flag and return a
-     gdb::optional with its value set to an object that will restore the
+     std::optional with its value set to an object that will restore the
      previous value of the suppress notifications flag.
 
      If this command was created without a suppress notifications points,
-     then this function returns an empty gdb::optional.  */
-  gdb::optional<scoped_restore_tmpl<int>> do_suppress_notification () const;
+     then this function returns an empty std::optional.  */
+  std::optional<scoped_restore_tmpl<int>> do_suppress_notification () const;
 
 private:
 
diff --git a/gdb/mi/mi-interp.c b/gdb/mi/mi-interp.c
index ebd7f150c49..afd2737e29d 100644
--- a/gdb/mi/mi-interp.c
+++ b/gdb/mi/mi-interp.c
@@ -278,7 +278,7 @@ mi_interp::on_new_thread (thread_info *t)
 
 void
 mi_interp::on_thread_exited (thread_info *t,
-			     gdb::optional<ULONGEST> /* exit_code */,
+			     std::optional<ULONGEST> /* exit_code */,
 			     int /* silent */)
 {
   target_terminal::scoped_restore_terminal_state term_state;
diff --git a/gdb/mi/mi-interp.h b/gdb/mi/mi-interp.h
index 3110c0a6a48..25c25512fba 100644
--- a/gdb/mi/mi-interp.h
+++ b/gdb/mi/mi-interp.h
@@ -51,7 +51,7 @@ class mi_interp final : public interp
   void on_command_error () override;
   void on_user_selected_context_changed (user_selected_what selection) override;
   void on_new_thread (thread_info *t) override;
-  void on_thread_exited (thread_info *t, gdb::optional<ULONGEST> exit_code,
+  void on_thread_exited (thread_info *t, std::optional<ULONGEST> exit_code,
 			 int silent) override;
   void on_inferior_added (inferior *inf) override;
   void on_inferior_appeared (inferior *inf) override;
diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c
index 14ed2a1fae9..487b0a92025 100644
--- a/gdb/mi/mi-main.c
+++ b/gdb/mi/mi-main.c
@@ -52,7 +52,7 @@
 #include "extension.h"
 #include "gdbcmd.h"
 #include "observable.h"
-#include "gdbsupport/gdb_optional.h"
+#include <optional>
 #include "gdbsupport/byte-vector.h"
 
 #include <ctype.h>
@@ -2095,7 +2095,7 @@ mi_cmd_execute (struct mi_parse *parse)
 
   user_selected_context current_user_selected_context;
 
-  gdb::optional<scoped_restore_current_thread> thread_saver;
+  std::optional<scoped_restore_current_thread> thread_saver;
   if (parse->thread != -1)
     {
       thread_info *tp = find_thread_global_id (parse->thread);
@@ -2112,7 +2112,7 @@ mi_cmd_execute (struct mi_parse *parse)
       switch_to_thread (tp);
     }
 
-  gdb::optional<scoped_restore_selected_frame> frame_saver;
+  std::optional<scoped_restore_selected_frame> frame_saver;
   if (parse->frame != -1)
     {
       frame_info_ptr fid;
@@ -2130,7 +2130,7 @@ mi_cmd_execute (struct mi_parse *parse)
 	error (_("Invalid frame id: %d"), frame);
     }
 
-  gdb::optional<scoped_restore_current_language> lang_saver;
+  std::optional<scoped_restore_current_language> lang_saver;
   if (parse->language != language_unknown)
     {
       lang_saver.emplace ();
@@ -2141,7 +2141,7 @@ mi_cmd_execute (struct mi_parse *parse)
 
   gdb_assert (parse->cmd != nullptr);
 
-  gdb::optional<scoped_restore_tmpl<int>> restore_suppress_notification
+  std::optional<scoped_restore_tmpl<int>> restore_suppress_notification
     = parse->cmd->do_suppress_notification ();
 
   parse->cmd->invoke (parse);
@@ -2512,7 +2512,7 @@ print_variable_or_computed (const char *expression, enum print_values values)
   else
     val = expr->evaluate ();
 
-  gdb::optional<ui_out_emit_tuple> tuple_emitter;
+  std::optional<ui_out_emit_tuple> tuple_emitter;
   if (values != PRINT_NO_VALUES)
     tuple_emitter.emplace (uiout, nullptr);
   uiout->field_string ("name", expression);
diff --git a/gdb/nat/linux-osdata.c b/gdb/nat/linux-osdata.c
index 103b7ab26cd..e85384660d4 100644
--- a/gdb/nat/linux-osdata.c
+++ b/gdb/nat/linux-osdata.c
@@ -66,7 +66,7 @@ linux_common_core_of_thread (ptid_t ptid)
   sprintf (filename, "/proc/%lld/task/%lld/stat",
 	   (PID_T) ptid.pid (), (PID_T) ptid.lwp ());
 
-  gdb::optional<std::string> content = read_text_file_to_string (filename);
+  std::optional<std::string> content = read_text_file_to_string (filename);
   if (!content.has_value ())
     return -1;
 
@@ -257,10 +257,10 @@ get_cores_used_by_process (PID_T pid, int *cores, const int num_cores)
 
 /* get_core_array_size helper that uses /sys/devices/system/cpu/possible.  */
 
-static gdb::optional<size_t>
+static std::optional<size_t>
 get_core_array_size_using_sys_possible ()
 {
-  gdb::optional<std::string> possible
+  std::optional<std::string> possible
     = read_text_file_to_string ("/sys/devices/system/cpu/possible");
 
   if (!possible.has_value ())
@@ -310,7 +310,7 @@ get_core_array_size ()
      we are in a container that has access to a subset of the host's cores.
      It will return a size that considers all the CPU cores available to the
      host.  If that fails for some reason, fall back to sysconf.  */
-  gdb::optional<size_t> count = get_core_array_size_using_sys_possible ();
+  std::optional<size_t> count = get_core_array_size_using_sys_possible ();
   if (count.has_value ())
     return *count;
 
diff --git a/gdb/nat/windows-nat.c b/gdb/nat/windows-nat.c
index 8028494de20..bf4c4387886 100644
--- a/gdb/nat/windows-nat.c
+++ b/gdb/nat/windows-nat.c
@@ -698,10 +698,10 @@ windows_process_info::matching_pending_stop (bool debug_events)
 
 /* See nat/windows-nat.h.  */
 
-gdb::optional<pending_stop>
+std::optional<pending_stop>
 windows_process_info::fetch_pending_stop (bool debug_events)
 {
-  gdb::optional<pending_stop> result;
+  std::optional<pending_stop> result;
   for (auto iter = pending_stops.begin ();
        iter != pending_stops.end ();
        ++iter)
@@ -818,7 +818,7 @@ create_process_wrapper (FUNC *do_create_process, const CHAR *image,
 	  InitializeProcThreadAttributeList (info_ex.lpAttributeList,
 					     1, 0, &size);
 
-	  gdb::optional<BOOL> return_value;
+	  std::optional<BOOL> return_value;
 	  DWORD attr_flags = relocate_aslr_flags;
 	  if (!UpdateProcThreadAttribute (info_ex.lpAttributeList, 0,
 					  mitigation_policy,
diff --git a/gdb/nat/windows-nat.h b/gdb/nat/windows-nat.h
index e3ea7dbb525..0dc37b29705 100644
--- a/gdb/nat/windows-nat.h
+++ b/gdb/nat/windows-nat.h
@@ -23,7 +23,7 @@
 #include <psapi.h>
 #include <vector>
 
-#include "gdbsupport/gdb_optional.h"
+#include <optional>
 #include "target/waitstatus.h"
 
 #define STATUS_WX86_BREAKPOINT 0x4000001F
@@ -246,7 +246,7 @@ struct windows_process_info
      remove it from the list of pending stops, set 'current_event', and
      return it.  Otherwise, return an empty optional.  */
 
-  gdb::optional<pending_stop> fetch_pending_stop (bool debug_events);
+  std::optional<pending_stop> fetch_pending_stop (bool debug_events);
 
   const char *pid_to_exec_file (int);
 
diff --git a/gdb/observable.h b/gdb/observable.h
index 5869489bcff..32ef65435cc 100644
--- a/gdb/observable.h
+++ b/gdb/observable.h
@@ -123,7 +123,7 @@ extern observable<struct thread_info */* t */> new_thread;
    removing the thread from its tables without wanting to notify the
    CLI about it.  */
 extern observable<thread_info */* t */,
-		  gdb::optional<ULONGEST> /* exit_code */,
+		  std::optional<ULONGEST> /* exit_code */,
 		  bool /* silent */> thread_exit;
 
 /* An explicit stop request was issued to PTID.  If PTID equals
diff --git a/gdb/osdata.c b/gdb/osdata.c
index 21b8eb01f6b..cb1e950df5c 100644
--- a/gdb/osdata.c
+++ b/gdb/osdata.c
@@ -162,7 +162,7 @@ std::unique_ptr<osdata>
 get_osdata (const char *type)
 {
   std::unique_ptr<osdata> osdata;
-  gdb::optional<gdb::char_vector> xml = target_get_osdata (type);
+  std::optional<gdb::char_vector> xml = target_get_osdata (type);
 
   if (xml)
     {
diff --git a/gdb/parse.c b/gdb/parse.c
index c69b53addff..b57d112fafd 100644
--- a/gdb/parse.c
+++ b/gdb/parse.c
@@ -49,7 +49,7 @@
 #include "objfiles.h"
 #include "user-regs.h"
 #include <algorithm>
-#include "gdbsupport/gdb_optional.h"
+#include <optional>
 #include "c-exp.h"
 
 static unsigned int expressiondebug = 0;
@@ -471,7 +471,7 @@ parse_expression (const char *string, innermost_block_tracker *tracker,
 expression_up
 parse_expression_with_language (const char *string, enum language lang)
 {
-  gdb::optional<scoped_restore_current_language> lang_saver;
+  std::optional<scoped_restore_current_language> lang_saver;
   if (current_language->la_language != lang)
     {
       lang_saver.emplace ();
diff --git a/gdb/ppc-linux-nat.c b/gdb/ppc-linux-nat.c
index a0205119f00..f34de9cb666 100644
--- a/gdb/ppc-linux-nat.c
+++ b/gdb/ppc-linux-nat.c
@@ -464,7 +464,7 @@ class ppc_linux_dreg_interface
     };
 
   /* The interface option.  Initialized if has_value () returns true.  */
-  gdb::optional<enum debug_reg_interface> m_interface;
+  std::optional<enum debug_reg_interface> m_interface;
 
   /* The info returned by the kernel with PPC_PTRACE_GETHWDBGINFO.  Only
      valid if we determined that the interface is HWDEBUG.  */
@@ -485,7 +485,7 @@ struct ppc_linux_process_info
   /* The watchpoint value that GDB requested for this process.
 
      Only used when the interface is DEBUGREG.  */
-  gdb::optional<long> requested_wp_val;
+  std::optional<long> requested_wp_val;
 };
 
 struct ppc_linux_nat_target final : public linux_nat_target
diff --git a/gdb/ppc-linux-tdep.c b/gdb/ppc-linux-tdep.c
index 1cc26ed69a5..24e1b455afd 100644
--- a/gdb/ppc-linux-tdep.c
+++ b/gdb/ppc-linux-tdep.c
@@ -1611,7 +1611,7 @@ ppc_linux_core_read_description (struct gdbarch *gdbarch,
   if (vsx)
     features.vsx = true;
 
-  gdb::optional<gdb::byte_vector> auxv = target_read_auxv_raw (target);
+  std::optional<gdb::byte_vector> auxv = target_read_auxv_raw (target);
   CORE_ADDR hwcap = linux_get_hwcap (auxv, target, gdbarch);
 
   features.isa205 = ppc_linux_has_isa205 (hwcap);
diff --git a/gdb/ppc-tdep.h b/gdb/ppc-tdep.h
index ddeb810f35b..b24154998ec 100644
--- a/gdb/ppc-tdep.h
+++ b/gdb/ppc-tdep.h
@@ -447,7 +447,7 @@ struct ppc_inferior_data
   /* This is an optional in case we add more fields to ppc_inferior_data, we
      don't want it instantiated as soon as we get the ppc_inferior_data for an
      inferior.  */
-  gdb::optional<displaced_step_buffers> disp_step_buf;
+  std::optional<displaced_step_buffers> disp_step_buf;
 };
 
 extern ppc_inferior_data * get_ppc_per_inferior (inferior *inf);
diff --git a/gdb/printcmd.c b/gdb/printcmd.c
index c5e6a815580..98f38b2598d 100644
--- a/gdb/printcmd.c
+++ b/gdb/printcmd.c
@@ -52,7 +52,7 @@
 #include "gdbsupport/format.h"
 #include "source.h"
 #include "gdbsupport/byte-vector.h"
-#include "gdbsupport/gdb_optional.h"
+#include <optional>
 #include "gdbsupport/gdb-safe-ctype.h"
 #include "gdbsupport/rsp-low.h"
 #include "inferior.h"
@@ -435,7 +435,7 @@ print_scalar_formatted (const gdb_byte *valaddr, struct type *type,
   /* Some cases below will unpack the value again.  In the biased
      range case, we want to avoid this, so we store the unpacked value
      here for possible use later.  */
-  gdb::optional<LONGEST> val_long;
+  std::optional<LONGEST> val_long;
   if ((is_fixed_point_type (type)
        && (options->format == 'o'
 	   || options->format == 'x'
@@ -2452,7 +2452,7 @@ printf_wide_c_string (struct ui_file *stream, const char *format,
   struct type *wctype = lookup_typename (current_language,
 					 "wchar_t", NULL, 0);
   int wcwidth = wctype->length ();
-  gdb::optional<gdb::byte_vector> tem_str;
+  std::optional<gdb::byte_vector> tem_str;
 
   if (value->lval () == lval_internalvar
       && c_is_string_type_p (value->type ()))
diff --git a/gdb/probe.c b/gdb/probe.c
index 13e95bcfb20..d9079be4d62 100644
--- a/gdb/probe.c
+++ b/gdb/probe.c
@@ -36,7 +36,7 @@
 #include "location.h"
 #include <ctype.h>
 #include <algorithm>
-#include "gdbsupport/gdb_optional.h"
+#include <optional>
 
 /* Class that implements the static probe methods for "any" probe.  */
 
@@ -280,7 +280,7 @@ collect_probes (const std::string &objname, const std::string &provider,
 		const std::string &probe_name, const static_probe_ops *spops)
 {
   std::vector<bound_probe> result;
-  gdb::optional<compiled_regex> obj_pat, prov_pat, probe_pat;
+  std::optional<compiled_regex> obj_pat, prov_pat, probe_pat;
 
   if (!provider.empty ())
     prov_pat.emplace (provider.c_str (), REG_NOSUB,
@@ -683,9 +683,9 @@ disable_probes_command (const char *arg, int from_tty)
 static bool ignore_probes_p = false;
 static bool ignore_probes_idx = 0;
 static bool ignore_probes_verbose_p;
-static gdb::optional<compiled_regex> ignore_probes_prov_pat[2];
-static gdb::optional<compiled_regex> ignore_probes_name_pat[2];
-static gdb::optional<compiled_regex> ignore_probes_obj_pat[2];
+static std::optional<compiled_regex> ignore_probes_prov_pat[2];
+static std::optional<compiled_regex> ignore_probes_name_pat[2];
+static std::optional<compiled_regex> ignore_probes_obj_pat[2];
 
 /* See comments in probe.h.  */
 
@@ -696,11 +696,11 @@ ignore_probe_p (const char *provider, const char *name,
   if (!ignore_probes_p)
     return false;
 
-  gdb::optional<compiled_regex> &re_prov
+  std::optional<compiled_regex> &re_prov
     = ignore_probes_prov_pat[ignore_probes_idx];
-  gdb::optional<compiled_regex> &re_name
+  std::optional<compiled_regex> &re_name
     = ignore_probes_name_pat[ignore_probes_idx];
-  gdb::optional<compiled_regex> &re_obj
+  std::optional<compiled_regex> &re_obj
     = ignore_probes_obj_pat[ignore_probes_idx];
 
   bool res
@@ -755,11 +755,11 @@ ignore_probes_command (const char *arg, int from_tty)
   /* Parse the regular expressions, making sure that the old regular
      expressions are still valid if an exception is throw.  */
   int new_ignore_probes_idx = 1 - ignore_probes_idx;
-  gdb::optional<compiled_regex> &re_prov
+  std::optional<compiled_regex> &re_prov
     = ignore_probes_prov_pat[new_ignore_probes_idx];
-  gdb::optional<compiled_regex> &re_name
+  std::optional<compiled_regex> &re_name
     = ignore_probes_name_pat[new_ignore_probes_idx];
-  gdb::optional<compiled_regex> &re_obj
+  std::optional<compiled_regex> &re_obj
     = ignore_probes_obj_pat[new_ignore_probes_idx];
   re_prov.reset ();
   re_name.reset ();
diff --git a/gdb/procfs.c b/gdb/procfs.c
index 3a5d173ee42..1a543a60202 100644
--- a/gdb/procfs.c
+++ b/gdb/procfs.c
@@ -3615,7 +3615,7 @@ procfs_target::make_corefile_notes (bfd *obfd, int *note_size)
   proc_iterate_over_threads (pi, procfs_corefile_thread_callback,
 			     &thread_args);
 
-  gdb::optional<gdb::byte_vector> auxv =
+  std::optional<gdb::byte_vector> auxv =
     target_read_alloc (current_inferior ()->top_target (),
 		       TARGET_OBJECT_AUXV, NULL);
   if (auxv && !auxv->empty ())
diff --git a/gdb/psymtab.c b/gdb/psymtab.c
index 41ecf31424b..484d4eaa651 100644
--- a/gdb/psymtab.c
+++ b/gdb/psymtab.c
@@ -1025,7 +1025,7 @@ psymbol_functions::expand_symtabs_matching
   for (partial_symtab *ps : partial_symbols (objfile))
     ps->searched_flag = PST_NOT_SEARCHED;
 
-  gdb::optional<lookup_name_info> psym_lookup_name;
+  std::optional<lookup_name_info> psym_lookup_name;
   if (lookup_name != nullptr)
     psym_lookup_name = lookup_name->make_ignore_params ();
 
diff --git a/gdb/psymtab.h b/gdb/psymtab.h
index 41337d0db89..4bafc6e998e 100644
--- a/gdb/psymtab.h
+++ b/gdb/psymtab.h
@@ -131,7 +131,7 @@ class psymtab_storage
   /* The obstack where allocations are made.  This is lazily allocated
      so that we don't waste memory when there are no psymtabs.  */
 
-  gdb::optional<auto_obstack> m_obstack;
+  std::optional<auto_obstack> m_obstack;
 };
 
 /* A partial_symbol records the name, domain, and address class of
diff --git a/gdb/python/py-disasm.c b/gdb/python/py-disasm.c
index 6f0fed137e6..7a13b81a0c2 100644
--- a/gdb/python/py-disasm.c
+++ b/gdb/python/py-disasm.c
@@ -176,7 +176,7 @@ struct gdbpy_disassembler : public gdb_disassemble_info
   /* Return a reference to an optional that contains the address at which a
      memory error occurred.  The optional will only have a value if a
      memory error actually occurred.  */
-  const gdb::optional<CORE_ADDR> &memory_error_address () const
+  const std::optional<CORE_ADDR> &memory_error_address () const
   { return m_memory_error_address; }
 
   /* Return the content of the disassembler as a string.  The contents are
@@ -221,7 +221,7 @@ struct gdbpy_disassembler : public gdb_disassemble_info
 
   /* When the user indicates that a memory error has occurred then the
      address of the memory error is stored in here.  */
-  gdb::optional<CORE_ADDR> m_memory_error_address;
+  std::optional<CORE_ADDR> m_memory_error_address;
 
   /* When the user calls the builtin_disassemble function, if they pass a
      memory source object then a pointer to the object is placed in here,
@@ -245,7 +245,7 @@ struct gdbpy_disassembler : public gdb_disassemble_info
 
   /* Store a single exception.  This is used to pass Python exceptions back
      from ::memory_read to disasmpy_builtin_disassemble.  */
-  gdb::optional<gdbpy_err_fetch> m_stored_exception;
+  std::optional<gdbpy_err_fetch> m_stored_exception;
 };
 
 /* Return true if OBJ is still valid, otherwise, return false.  A valid OBJ
@@ -1215,7 +1215,7 @@ struct scoped_disasm_info_object
 
 /* See python-internal.h.  */
 
-gdb::optional<int>
+std::optional<int>
 gdbpy_print_insn (struct gdbarch *gdbarch, CORE_ADDR memaddr,
 		  disassemble_info *info)
 {
@@ -1294,7 +1294,7 @@ gdbpy_print_insn (struct gdbarch *gdbarch, CORE_ADDR memaddr,
 	    addr = disasm_info->address;
 
 	  info->memory_error_func (-1, addr, info);
-	  return gdb::optional<int> (-1);
+	  return std::optional<int> (-1);
 	}
       else if (PyErr_ExceptionMatches (gdbpy_gdberror_exc))
 	{
@@ -1302,12 +1302,12 @@ gdbpy_print_insn (struct gdbarch *gdbarch, CORE_ADDR memaddr,
 	  gdb::unique_xmalloc_ptr<char> msg = err.to_string ();
 
 	  info->fprintf_func (info->stream, "%s", msg.get ());
-	  return gdb::optional<int> (-1);
+	  return std::optional<int> (-1);
 	}
       else
 	{
 	  gdbpy_print_stack ();
-	  return gdb::optional<int> (-1);
+	  return std::optional<int> (-1);
 	}
 
     }
@@ -1326,7 +1326,7 @@ gdbpy_print_insn (struct gdbarch *gdbarch, CORE_ADDR memaddr,
       PyErr_SetString (PyExc_TypeError,
 		       _("Result is not a DisassemblerResult."));
       gdbpy_print_stack ();
-      return gdb::optional<int> (-1);
+      return std::optional<int> (-1);
     }
 
   /* The result from the Python disassembler has the correct type.  Convert
@@ -1345,7 +1345,7 @@ gdbpy_print_insn (struct gdbarch *gdbarch, CORE_ADDR memaddr,
 	(PyExc_ValueError,
 	 _("Invalid length attribute: length must be greater than 0."));
       gdbpy_print_stack ();
-      return gdb::optional<int> (-1);
+      return std::optional<int> (-1);
     }
   if (length > max_insn_length)
     {
@@ -1354,7 +1354,7 @@ gdbpy_print_insn (struct gdbarch *gdbarch, CORE_ADDR memaddr,
 	 _("Invalid length attribute: length %d greater than architecture maximum of %d"),
 	 length, max_insn_length);
       gdbpy_print_stack ();
-      return gdb::optional<int> (-1);
+      return std::optional<int> (-1);
     }
 
   /* It is impossible to create a DisassemblerResult object with an empty
@@ -1390,7 +1390,7 @@ gdbpy_print_insn (struct gdbarch *gdbarch, CORE_ADDR memaddr,
 	}
     }
 
-  return gdb::optional<int> (length);
+  return std::optional<int> (length);
 }
 
 /* The tp_dealloc callback for the DisassemblerResult type.  Takes care of
diff --git a/gdb/python/py-framefilter.c b/gdb/python/py-framefilter.c
index e555dc3d879..dc7e47d70f0 100644
--- a/gdb/python/py-framefilter.c
+++ b/gdb/python/py-framefilter.c
@@ -32,7 +32,7 @@
 #include "demangle.h"
 #include "mi/mi-cmds.h"
 #include "python-internal.h"
-#include "gdbsupport/gdb_optional.h"
+#include <optional>
 #include "cli/cli-style.h"
 
 enum mi_print_types
@@ -322,7 +322,7 @@ py_print_single_arg (struct ui_out *out,
   else
     val = fv;
 
-  gdb::optional<ui_out_emit_tuple> maybe_tuple;
+  std::optional<ui_out_emit_tuple> maybe_tuple;
 
   /*  MI has varying rules for tuples, but generally if there is only
       one element in each item in the list, do not start a tuple.  The
@@ -562,7 +562,7 @@ enumerate_locals (PyObject *iter,
       struct symbol *sym;
       const struct block *sym_block;
       int local_indent = 8 + (8 * indent);
-      gdb::optional<ui_out_emit_tuple> tuple;
+      std::optional<ui_out_emit_tuple> tuple;
 
       gdbpy_ref<> item (PyIter_Next (iter));
       if (item == NULL)
@@ -773,7 +773,7 @@ py_print_frame (PyObject *filter, frame_filter_flags flags,
   get_user_print_options (&opts);
   if (print_frame_info)
     {
-      gdb::optional<enum print_what> user_frame_info_print_what;
+      std::optional<enum print_what> user_frame_info_print_what;
 
       get_user_print_what_frame_info (&user_frame_info_print_what);
       if (!out->is_mi_like_p () && user_frame_info_print_what.has_value ())
@@ -808,7 +808,7 @@ py_print_frame (PyObject *filter, frame_filter_flags flags,
       return EXT_LANG_BT_OK;
     }
 
-  gdb::optional<ui_out_emit_tuple> tuple;
+  std::optional<ui_out_emit_tuple> tuple;
 
   /* -stack-list-locals does not require a
      wrapping frame attribute.  */
diff --git a/gdb/python/py-inferior.c b/gdb/python/py-inferior.c
index c0bd6a69895..ed153d668ac 100644
--- a/gdb/python/py-inferior.c
+++ b/gdb/python/py-inferior.c
@@ -364,7 +364,7 @@ add_thread_object (struct thread_info *tp)
 
 static void
 delete_thread_object (thread_info *tp,
-		      gdb::optional<ULONGEST> /* exit_code */,
+		      std::optional<ULONGEST> /* exit_code */,
 		      bool /* silent */)
 {
   if (!gdb_python_initialized)
diff --git a/gdb/python/py-mi.c b/gdb/python/py-mi.c
index aaa225da95e..d38a0ff1724 100644
--- a/gdb/python/py-mi.c
+++ b/gdb/python/py-mi.c
@@ -145,7 +145,7 @@ class py_ui_out : public ui_out
 
   /* If an error occurred, this holds the exception information for
      use by the 'release' method.  */
-  gdb::optional<gdbpy_err_fetch> m_error;
+  std::optional<gdbpy_err_fetch> m_error;
 
   /* Return a reference to the object under construction.  */
   object_desc &current ()
diff --git a/gdb/python/py-utils.c b/gdb/python/py-utils.c
index 15520849f15..f1ca9ea0a5d 100644
--- a/gdb/python/py-utils.c
+++ b/gdb/python/py-utils.c
@@ -469,12 +469,12 @@ gdbpy_fix_doc_string_indentation (gdb::unique_xmalloc_ptr<char> doc)
      (user left a single stray space at the start of an otherwise blank
      line), we don't consider lines without content when updating the
      MIN_WHITESPACE value.  */
-  gdb::optional<int> min_whitespace;
+  std::optional<int> min_whitespace;
 
   /* The index into WS_INFO at which the processing of DOC can be
      considered "all done", that is, after this point there are no further
      lines with useful content and we should just stop.  */
-  gdb::optional<size_t> all_done_idx;
+  std::optional<size_t> all_done_idx;
 
   /* White-space information for each line in DOC.  */
   std::vector<line_whitespace> ws_info;
diff --git a/gdb/python/python-internal.h b/gdb/python/python-internal.h
index 847bed84dfe..86eb5436f2a 100644
--- a/gdb/python/python-internal.h
+++ b/gdb/python/python-internal.h
@@ -732,7 +732,7 @@ class gdbpy_enter
 
   /* An optional is used here because we don't want to call
      PyErr_Fetch too early.  */
-  gdb::optional<gdbpy_err_fetch> m_error;
+  std::optional<gdbpy_err_fetch> m_error;
 };
 
 /* Like gdbpy_enter, but takes a varobj.  This is a subclass just to
@@ -953,7 +953,7 @@ extern gdb::unique_xmalloc_ptr<char> gdbpy_fix_doc_string_indentation
 
    If no instruction can be disassembled then return an empty value.  */
 
-extern gdb::optional<int> gdbpy_print_insn (struct gdbarch *gdbarch,
+extern std::optional<int> gdbpy_print_insn (struct gdbarch *gdbarch,
 					    CORE_ADDR address,
 					    disassemble_info *info);
 
diff --git a/gdb/python/python.c b/gdb/python/python.c
index 7e48165db21..8a36673a3e4 100644
--- a/gdb/python/python.c
+++ b/gdb/python/python.c
@@ -124,9 +124,9 @@ static void gdbpy_set_quit_flag (const struct extension_language_defn *);
 static int gdbpy_check_quit_flag (const struct extension_language_defn *);
 static enum ext_lang_rc gdbpy_before_prompt_hook
   (const struct extension_language_defn *, const char *current_gdb_prompt);
-static gdb::optional<std::string> gdbpy_colorize
+static std::optional<std::string> gdbpy_colorize
   (const std::string &filename, const std::string &contents);
-static gdb::optional<std::string> gdbpy_colorize_disasm
+static std::optional<std::string> gdbpy_colorize_disasm
 (const std::string &content, gdbarch *gdbarch);
 static ext_lang_missing_debuginfo_result gdbpy_handle_missing_debuginfo
   (const struct extension_language_defn *extlang, struct objfile *objfile);
@@ -1198,7 +1198,7 @@ gdbpy_before_prompt_hook (const struct extension_language_defn *extlang,
 
 /* This is the extension_language_ops.colorize "method".  */
 
-static gdb::optional<std::string>
+static std::optional<std::string>
 gdbpy_colorize (const std::string &filename, const std::string &contents)
 {
   if (!gdb_python_initialized)
@@ -1275,7 +1275,7 @@ gdbpy_colorize (const std::string &filename, const std::string &contents)
 
 /* This is the extension_language_ops.colorize_disasm "method".  */
 
-static gdb::optional<std::string>
+static std::optional<std::string>
 gdbpy_colorize_disasm (const std::string &content, gdbarch *gdbarch)
 {
   if (!gdb_python_initialized)
diff --git a/gdb/ravenscar-thread.c b/gdb/ravenscar-thread.c
index 3558cfd3875..f147b66b3c6 100644
--- a/gdb/ravenscar-thread.c
+++ b/gdb/ravenscar-thread.c
@@ -685,7 +685,7 @@ ravenscar_thread_target::fetch_registers (struct regcache *regcache,
       struct gdbarch *gdbarch = regcache->arch ();
       bool is_active = task_is_currently_active (ptid);
       struct ravenscar_arch_ops *arch_ops = gdbarch_ravenscar_ops (gdbarch);
-      gdb::optional<fpu_state> fp_state;
+      std::optional<fpu_state> fp_state;
 
       int low_reg = regnum == -1 ? 0 : regnum;
       int high_reg = regnum == -1 ? gdbarch_num_regs (gdbarch) : regnum + 1;
@@ -731,7 +731,7 @@ ravenscar_thread_target::store_registers (struct regcache *regcache,
       struct gdbarch *gdbarch = regcache->arch ();
       bool is_active = task_is_currently_active (ptid);
       struct ravenscar_arch_ops *arch_ops = gdbarch_ravenscar_ops (gdbarch);
-      gdb::optional<fpu_state> fp_state;
+      std::optional<fpu_state> fp_state;
 
       int low_reg = regnum == -1 ? 0 : regnum;
       int high_reg = regnum == -1 ? gdbarch_num_regs (gdbarch) : regnum + 1;
diff --git a/gdb/record-btrace.c b/gdb/record-btrace.c
index f0e190f9bf7..e084196b841 100644
--- a/gdb/record-btrace.c
+++ b/gdb/record-btrace.c
@@ -758,8 +758,8 @@ btrace_find_line_range (CORE_ADDR pc)
 
 static void
 btrace_print_lines (struct btrace_line_range lines, struct ui_out *uiout,
-		    gdb::optional<ui_out_emit_tuple> *src_and_asm_tuple,
-		    gdb::optional<ui_out_emit_list> *asm_list,
+		    std::optional<ui_out_emit_tuple> *src_and_asm_tuple,
+		    std::optional<ui_out_emit_list> *asm_list,
 		    gdb_disassembly_flags flags)
 {
   print_source_lines_flags psl_flags;
@@ -798,8 +798,8 @@ btrace_insn_history (struct ui_out *uiout,
 
   ui_out_emit_list list_emitter (uiout, "asm_insns");
 
-  gdb::optional<ui_out_emit_tuple> src_and_asm_tuple;
-  gdb::optional<ui_out_emit_list> asm_list;
+  std::optional<ui_out_emit_tuple> src_and_asm_tuple;
+  std::optional<ui_out_emit_list> asm_list;
 
   gdb_pretty_print_disassembler disasm (gdbarch, uiout);
 
diff --git a/gdb/regcache.c b/gdb/regcache.c
index 48d7db47c06..9dc354ec2b3 100644
--- a/gdb/regcache.c
+++ b/gdb/regcache.c
@@ -578,7 +578,7 @@ regcache::raw_update (int regnum)
 
   if (get_register_status (regnum) == REG_UNKNOWN)
     {
-      gdb::optional<scoped_restore_current_thread> maybe_restore_thread
+      std::optional<scoped_restore_current_thread> maybe_restore_thread
 	= maybe_switch_inferior (m_inf_for_target_calls);
 
       target_fetch_registers (this, regnum);
@@ -832,7 +832,7 @@ regcache::raw_write (int regnum, const gdb_byte *buf)
 		  m_descr->sizeof_register[regnum]) == 0))
     return;
 
-  gdb::optional<scoped_restore_current_thread> maybe_restore_thread
+  std::optional<scoped_restore_current_thread> maybe_restore_thread
     = maybe_switch_inferior (m_inf_for_target_calls);
 
   target_prepare_to_store (this);
diff --git a/gdb/remote.c b/gdb/remote.c
index 501270041d8..1bc59928dcf 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -930,7 +930,7 @@ class remote_target : public process_stratum_target
 		     const char *filename,
 		     fileio_error *target_errno) override;
 
-  gdb::optional<std::string>
+  std::optional<std::string>
     fileio_readlink (struct inferior *inf,
 		     const char *filename,
 		     fileio_error *target_errno) override;
@@ -4091,7 +4091,7 @@ remote_target::remote_get_threads_with_qxfer (threads_listing_context *context)
 #if defined(HAVE_LIBEXPAT)
   if (m_features.packet_support (PACKET_qXfer_threads) == PACKET_ENABLE)
     {
-      gdb::optional<gdb::char_vector> xml
+      std::optional<gdb::char_vector> xml
 	= target_read_stralloc (this, TARGET_OBJECT_THREADS, NULL);
 
       if (xml && (*xml)[0] != '\0')
@@ -11913,7 +11913,7 @@ std::vector<mem_region>
 remote_target::memory_map ()
 {
   std::vector<mem_region> result;
-  gdb::optional<gdb::char_vector> text
+  std::optional<gdb::char_vector> text
     = target_read_stralloc (current_inferior ()->top_target (),
 			    TARGET_OBJECT_MEMORY_MAP, NULL);
 
@@ -12878,7 +12878,7 @@ remote_target::fileio_unlink (struct inferior *inf, const char *filename,
 
 /* Implementation of to_fileio_readlink.  */
 
-gdb::optional<std::string>
+std::optional<std::string>
 remote_target::fileio_readlink (struct inferior *inf, const char *filename,
 				fileio_error *remote_errno)
 {
@@ -14145,7 +14145,7 @@ remote_target::set_circular_trace_buffer (int val)
 traceframe_info_up
 remote_target::traceframe_info ()
 {
-  gdb::optional<gdb::char_vector> text
+  std::optional<gdb::char_vector> text
     = target_read_stralloc (current_inferior ()->top_target (),
 			    TARGET_OBJECT_TRACEFRAME_INFO,
 			    NULL);
@@ -14686,7 +14686,7 @@ btrace_read_config (thread_info *tp, btrace_config *conf)
   scoped_restore_current_thread restore_thread;
   switch_to_thread (tp);
 
-  gdb::optional<gdb::char_vector> xml
+  std::optional<gdb::char_vector> xml
     = target_read_stralloc (current_inferior ()->top_target (),
 			    TARGET_OBJECT_BTRACE_CONF, "");
   if (xml)
@@ -14886,7 +14886,7 @@ remote_target::read_btrace (struct btrace_data *btrace,
 		      (unsigned int) type);
     }
 
-  gdb::optional<gdb::char_vector> xml
+  std::optional<gdb::char_vector> xml
     = target_read_stralloc (current_inferior ()->top_target (),
 			    TARGET_OBJECT_BTRACE, annex);
   if (!xml)
@@ -14926,7 +14926,7 @@ remote_target::load (const char *name, int from_tty)
 const char *
 remote_target::pid_to_exec_file (int pid)
 {
-  static gdb::optional<gdb::char_vector> filename;
+  static std::optional<gdb::char_vector> filename;
   char *annex = NULL;
 
   if (m_features.packet_support (PACKET_qXfer_exec_file) != PACKET_ENABLE)
diff --git a/gdb/riscv-tdep.c b/gdb/riscv-tdep.c
index 3a2891c2c92..3725be44276 100644
--- a/gdb/riscv-tdep.c
+++ b/gdb/riscv-tdep.c
@@ -1676,7 +1676,7 @@ class riscv_insn
      passed, is the value to place in rs1, otherwise rd is duplicated into
      rs1.  */
   void decode_ci_type_insn (enum opcode opcode, ULONGEST ival,
-			    gdb::optional<int> rs1_regnum = {})
+			    std::optional<int> rs1_regnum = {})
   {
     m_opcode = opcode;
     m_rd = decode_register_index (ival, OP_SH_CRS1S);
diff --git a/gdb/s390-linux-tdep.c b/gdb/s390-linux-tdep.c
index 414238a4db2..ae45ec6b5df 100644
--- a/gdb/s390-linux-tdep.c
+++ b/gdb/s390-linux-tdep.c
@@ -332,7 +332,7 @@ s390_core_read_description (struct gdbarch *gdbarch,
 			    struct target_ops *target, bfd *abfd)
 {
   asection *section = bfd_get_section_by_name (abfd, ".reg");
-  gdb::optional<gdb::byte_vector> auxv = target_read_auxv_raw (target);
+  std::optional<gdb::byte_vector> auxv = target_read_auxv_raw (target);
   CORE_ADDR hwcap = linux_get_hwcap (auxv, target, gdbarch);
   bool high_gprs, v1, v2, te, vx, gs;
 
diff --git a/gdb/skip.c b/gdb/skip.c
index 28902a6d326..465978ff9cc 100644
--- a/gdb/skip.c
+++ b/gdb/skip.c
@@ -34,7 +34,7 @@
 #include "filenames.h"
 #include "fnmatch.h"
 #include "gdbsupport/gdb_regex.h"
-#include "gdbsupport/gdb_optional.h"
+#include <optional>
 #include <list>
 #include "cli/cli-style.h"
 #include "gdbsupport/buildargv.h"
@@ -113,7 +113,7 @@ class skiplist_entry
   std::string m_function;
 
   /* If this is a function regexp, the compiled form.  */
-  gdb::optional<compiled_regex> m_compiled_function_regexp;
+  std::optional<compiled_regex> m_compiled_function_regexp;
 
   /* Enabled/disabled state.  */
   bool m_enabled = true;
diff --git a/gdb/solib-aix.c b/gdb/solib-aix.c
index 0fc3a153973..1a70f98ba59 100644
--- a/gdb/solib-aix.c
+++ b/gdb/solib-aix.c
@@ -65,7 +65,7 @@ struct solib_aix_inferior_data
      the same principles applied to shared libraries also apply
      to the main executable.  So it's simpler to keep it as part
      of this list.  */
-  gdb::optional<std::vector<lm_info_aix>> library_list;
+  std::optional<std::vector<lm_info_aix>> library_list;
 };
 
 /* Key to our per-inferior data.  */
@@ -91,7 +91,7 @@ get_solib_aix_inferior_data (struct inferior *inf)
 
 /* Dummy implementation if XML support is not compiled in.  */
 
-static gdb::optional<std::vector<lm_info_aix>>
+static std::optional<std::vector<lm_info_aix>>
 solib_aix_parse_libraries (const char *library)
 {
   static int have_warned;
@@ -201,7 +201,7 @@ static const struct gdb_xml_element library_list_elements[] =
 
    Return an empty option if the parsing failed.  */
 
-static gdb::optional<std::vector<lm_info_aix>>
+static std::optional<std::vector<lm_info_aix>>
 solib_aix_parse_libraries (const char *library)
 {
   std::vector<lm_info_aix> result;
@@ -225,7 +225,7 @@ solib_aix_parse_libraries (const char *library)
    is not NULL, then print a warning including WARNING_MSG and
    a description of the error.  */
 
-static gdb::optional<std::vector<lm_info_aix>> &
+static std::optional<std::vector<lm_info_aix>> &
 solib_aix_get_library_list (struct inferior *inf, const char *warning_msg)
 {
   struct solib_aix_inferior_data *data;
@@ -235,7 +235,7 @@ solib_aix_get_library_list (struct inferior *inf, const char *warning_msg)
   if (data->library_list.has_value ())
     return data->library_list;
 
-  gdb::optional<gdb::char_vector> library_document
+  std::optional<gdb::char_vector> library_document
     = target_read_stralloc (current_inferior ()->top_target (),
 			    TARGET_OBJECT_LIBRARIES_AIX,
 			    NULL);
@@ -421,7 +421,7 @@ solib_aix_solib_create_inferior_hook (int from_tty)
 
   /* We need to relocate the main executable...  */
 
-  gdb::optional<std::vector<lm_info_aix>> &library_list
+  std::optional<std::vector<lm_info_aix>> &library_list
     = solib_aix_get_library_list (current_inferior (), warning_msg);
   if (!library_list.has_value ())
     return;  /* Warning already printed.  */
@@ -448,7 +448,7 @@ solib_aix_solib_create_inferior_hook (int from_tty)
 static intrusive_list<shobj>
 solib_aix_current_sos ()
 {
-  gdb::optional<std::vector<lm_info_aix>> &library_list
+  std::optional<std::vector<lm_info_aix>> &library_list
     = solib_aix_get_library_list (current_inferior (), NULL);
   if (!library_list.has_value ())
     return {};
diff --git a/gdb/solib-dsbt.c b/gdb/solib-dsbt.c
index ef561466945..0d98ae85cc0 100644
--- a/gdb/solib-dsbt.c
+++ b/gdb/solib-dsbt.c
@@ -276,7 +276,7 @@ static void
 dsbt_get_initial_loadmaps (void)
 {
   dsbt_info *info = get_dsbt_info (current_program_space);
-  gdb::optional<gdb::byte_vector> buf
+  std::optional<gdb::byte_vector> buf
     = target_read_alloc (current_inferior ()->top_target (),
 			 TARGET_OBJECT_FDPIC, "exec");
 
diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c
index 5882a4e0070..d7fd199703c 100644
--- a/gdb/solib-svr4.c
+++ b/gdb/solib-svr4.c
@@ -454,7 +454,7 @@ static int match_main (const char *);
    architecture size (32-bit or 64-bit) is returned to *P_ARCH_SIZE.  Likewise,
    the base address of the section is returned in *BASE_ADDR.  */
 
-static gdb::optional<gdb::byte_vector>
+static std::optional<gdb::byte_vector>
 read_program_header (int type, int *p_arch_size, CORE_ADDR *base_addr)
 {
   bfd_endian byte_order = gdbarch_byte_order (current_inferior ()->arch ());
@@ -587,7 +587,7 @@ read_program_header (int type, int *p_arch_size, CORE_ADDR *base_addr)
 
 
 /* Return program interpreter string.  */
-static gdb::optional<gdb::byte_vector>
+static std::optional<gdb::byte_vector>
 find_program_interpreter (void)
 {
   /* If we have a current exec_bfd, use its section table.  */
@@ -632,7 +632,7 @@ scan_dyntag_auxv (const int desired_dyntag, CORE_ADDR *ptr,
   CORE_ADDR base_addr;
 
   /* Read in .dynamic section.  */
-  gdb::optional<gdb::byte_vector> ph_data
+  std::optional<gdb::byte_vector> ph_data
     = read_program_header (PT_DYNAMIC, &arch_size, &base_addr);
   if (!ph_data)
     return 0;
@@ -1159,7 +1159,7 @@ svr4_current_sos_via_xfer_libraries (struct svr4_library_list *list,
   gdb_assert (annex == NULL || target_augmented_libraries_svr4_read ());
 
   /* Fetch the list of shared libraries.  */
-  gdb::optional<gdb::char_vector> svr4_library_document
+  std::optional<gdb::char_vector> svr4_library_document
     = target_read_stralloc (current_inferior ()->top_target (),
 			    TARGET_OBJECT_LIBRARIES_SVR4,
 			    annex);
@@ -2309,7 +2309,7 @@ enable_break (struct svr4_info *info, int from_tty)
 
   /* Find the program interpreter; if not found, warn the user and drop
      into the old breakpoint at symbol code.  */
-  gdb::optional<gdb::byte_vector> interp_name_holder
+  std::optional<gdb::byte_vector> interp_name_holder
     = find_program_interpreter ();
   if (interp_name_holder)
     {
@@ -2519,7 +2519,7 @@ enable_break (struct svr4_info *info, int from_tty)
 
 /* Read the ELF program headers from ABFD.  */
 
-static gdb::optional<gdb::byte_vector>
+static std::optional<gdb::byte_vector>
 read_program_headers_from_bfd (bfd *abfd)
 {
   Elf_Internal_Ehdr *ehdr = elf_elfheader (abfd);
@@ -2632,9 +2632,9 @@ svr4_exec_displacement (CORE_ADDR *displacementp)
 	 really do not match.  */
       int arch_size;
 
-      gdb::optional<gdb::byte_vector> phdrs_target
+      std::optional<gdb::byte_vector> phdrs_target
 	= read_program_header (-1, &arch_size, NULL);
-      gdb::optional<gdb::byte_vector> phdrs_binary
+      std::optional<gdb::byte_vector> phdrs_binary
 	= read_program_headers_from_bfd (current_program_space->exec_bfd ());
       if (phdrs_target && phdrs_binary)
 	{
diff --git a/gdb/solib-target.c b/gdb/solib-target.c
index c6125072812..b311c76965d 100644
--- a/gdb/solib-target.c
+++ b/gdb/solib-target.c
@@ -233,7 +233,7 @@ solib_target_current_sos (void)
   intrusive_list<shobj> sos;
 
   /* Fetch the list of shared libraries.  */
-  gdb::optional<gdb::char_vector> library_document
+  std::optional<gdb::char_vector> library_document
     = target_read_stralloc (current_inferior ()->top_target (),
 			    TARGET_OBJECT_LIBRARIES, NULL);
   if (!library_document)
diff --git a/gdb/source-cache.c b/gdb/source-cache.c
index c955929b543..eb467fd3da5 100644
--- a/gdb/source-cache.c
+++ b/gdb/source-cache.c
@@ -343,7 +343,7 @@ source_cache::ensure (struct symtab *s)
 
       if (!already_styled)
 	{
-	  gdb::optional<std::string> ext_contents;
+	  std::optional<std::string> ext_contents;
 	  ext_contents = ext_lang_colorize (fullname, contents);
 	  if (ext_contents.has_value ())
 	    {
diff --git a/gdb/stack.c b/gdb/stack.c
index ef565445c16..20bb85efd19 100644
--- a/gdb/stack.c
+++ b/gdb/stack.c
@@ -97,7 +97,7 @@ static const char *const print_frame_info_choices[] =
 
 /* print_frame_info_print_what[i] maps a choice to the corresponding
    print_what enum.  */
-static const gdb::optional<enum print_what> print_frame_info_print_what[] =
+static const std::optional<enum print_what> print_frame_info_print_what[] =
   {{}, /* Empty value for "auto".  */
    SRC_LINE, LOCATION, SRC_AND_LOC, LOC_AND_ADDRESS, SHORT_LOCATION};
 
@@ -973,7 +973,7 @@ do_gdb_disassembly (struct gdbarch *gdbarch,
    Value not present indicates to the caller to use default values
    specific to the command being executed.  */
 
-static gdb::optional<enum print_what>
+static std::optional<enum print_what>
 print_frame_info_to_print_what (const char *print_frame_info)
 {
   for (int i = 0; print_frame_info_choices[i] != NULL; i++)
@@ -1004,7 +1004,7 @@ print_pc (struct ui_out *uiout, struct gdbarch *gdbarch, frame_info_ptr frame,
 /* See stack.h.  */
 
 void
-get_user_print_what_frame_info (gdb::optional<enum print_what> *what)
+get_user_print_what_frame_info (std::optional<enum print_what> *what)
 {
   *what
     = print_frame_info_to_print_what
@@ -2261,8 +2261,8 @@ iterate_over_block_local_vars (const struct block *block,
 
 struct print_variable_and_value_data
 {
-  gdb::optional<compiled_regex> preg;
-  gdb::optional<compiled_regex> treg;
+  std::optional<compiled_regex> preg;
+  std::optional<compiled_regex> treg;
   struct frame_id frame_id;
   int num_tabs;
   struct ui_file *stream;
@@ -2307,7 +2307,7 @@ print_variable_and_value_data::operator() (const char *print_name,
    If REGEXP is NULL, it results in an empty regular expression.  */
 
 static void
-prepare_reg (const char *regexp, gdb::optional<compiled_regex> *reg)
+prepare_reg (const char *regexp, std::optional<compiled_regex> *reg)
 {
   if (regexp != NULL)
     {
@@ -2499,8 +2499,8 @@ print_frame_arg_vars (frame_info_ptr frame,
   struct print_variable_and_value_data cb_data;
   struct symbol *func;
   CORE_ADDR pc;
-  gdb::optional<compiled_regex> preg;
-  gdb::optional<compiled_regex> treg;
+  std::optional<compiled_regex> preg;
+  std::optional<compiled_regex> treg;
 
   if (!get_frame_pc_if_available (frame, &pc))
     {
diff --git a/gdb/stack.h b/gdb/stack.h
index 1b0c2b342a4..a64abaf52b5 100644
--- a/gdb/stack.h
+++ b/gdb/stack.h
@@ -38,7 +38,7 @@ void iterate_over_block_local_vars (const struct block *block,
    information to print, otherwise the printing function should print
    the relevant information.  */
 
-void get_user_print_what_frame_info (gdb::optional<enum print_what> *what);
+void get_user_print_what_frame_info (std::optional<enum print_what> *what);
 
 /* Return true if we should display the address in addition to the location,
    because we are in the middle of a statement.  */
diff --git a/gdb/symfile.c b/gdb/symfile.c
index bbac6ad9df1..c5af186ad33 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -913,7 +913,7 @@ syms_from_objfile_1 (struct objfile *objfile,
 
   /* Make sure that partially constructed symbol tables will be cleaned up
      if an error occurs during symbol reading.  */
-  gdb::optional<clear_symtab_users_cleanup> defer_clear_users;
+  std::optional<clear_symtab_users_cleanup> defer_clear_users;
 
   objfile_up objfile_holder (objfile);
 
diff --git a/gdb/symtab.c b/gdb/symtab.c
index 5ec56f4f2af..17d1987608f 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -66,7 +66,7 @@
 #include "parser-defs.h"
 #include "completer.h"
 #include "progspace-and-thread.h"
-#include "gdbsupport/gdb_optional.h"
+#include <optional>
 #include "filename-seen-cache.h"
 #include "arch-utils.h"
 #include <algorithm>
@@ -943,7 +943,7 @@ void
 general_symbol_info::compute_and_set_names (gdb::string_view linkage_name,
 					    bool copy_name,
 					    objfile_per_bfd_storage *per_bfd,
-					    gdb::optional<hashval_t> hash)
+					    std::optional<hashval_t> hash)
 {
   struct demangled_name_entry **slot;
 
@@ -3714,7 +3714,7 @@ skip_prologue_using_lineinfo (CORE_ADDR func_addr, struct symtab *symtab)
    the function starting at FUNC_ADDR which has prologue_end set to true if
    such entry exist, otherwise return an empty optional.  */
 
-static gdb::optional<CORE_ADDR>
+static std::optional<CORE_ADDR>
 skip_prologue_using_linetable (CORE_ADDR func_addr)
 {
   CORE_ADDR start_pc, end_pc;
@@ -3838,7 +3838,7 @@ skip_prologue_sal (struct symtab_and_line *sal)
 	 be placed to skip the prologue.  */
       if (!ignore_prologue_end_flag && skip)
 	{
-	  gdb::optional<CORE_ADDR> linetable_pc
+	  std::optional<CORE_ADDR> linetable_pc
 	    = skip_prologue_using_linetable (pc);
 	  if (linetable_pc)
 	    {
@@ -4450,8 +4450,8 @@ info_sources_worker (struct ui_out *uiout,
   output_source_filename_data data (uiout, filter);
 
   ui_out_emit_list results_emitter (uiout, "files");
-  gdb::optional<ui_out_emit_tuple> output_tuple;
-  gdb::optional<ui_out_emit_list> sources_list;
+  std::optional<ui_out_emit_tuple> output_tuple;
+  std::optional<ui_out_emit_list> sources_list;
 
   gdb_assert (group_by_objfile || uiout->is_mi_like_p ());
 
@@ -4652,7 +4652,7 @@ global_symbol_searcher::is_suitable_msymbol
 
 bool
 global_symbol_searcher::expand_symtabs
-	(objfile *objfile, const gdb::optional<compiled_regex> &preg) const
+	(objfile *objfile, const std::optional<compiled_regex> &preg) const
 {
   enum search_domain kind = m_kind;
   bool found_msymbol = false;
@@ -4734,8 +4734,8 @@ global_symbol_searcher::expand_symtabs
 bool
 global_symbol_searcher::add_matching_symbols
 	(objfile *objfile,
-	 const gdb::optional<compiled_regex> &preg,
-	 const gdb::optional<compiled_regex> &treg,
+	 const std::optional<compiled_regex> &preg,
+	 const std::optional<compiled_regex> &treg,
 	 std::set<symbol_search> *result_set) const
 {
   enum search_domain kind = m_kind;
@@ -4813,7 +4813,7 @@ global_symbol_searcher::add_matching_symbols
 
 bool
 global_symbol_searcher::add_matching_msymbols
-	(objfile *objfile, const gdb::optional<compiled_regex> &preg,
+	(objfile *objfile, const std::optional<compiled_regex> &preg,
 	 std::vector<symbol_search> *results) const
 {
   enum search_domain kind = m_kind;
@@ -4860,8 +4860,8 @@ global_symbol_searcher::add_matching_msymbols
 std::vector<symbol_search>
 global_symbol_searcher::search () const
 {
-  gdb::optional<compiled_regex> preg;
-  gdb::optional<compiled_regex> treg;
+  std::optional<compiled_regex> preg;
+  std::optional<compiled_regex> treg;
 
   gdb_assert (m_kind != ALL_DOMAIN);
 
diff --git a/gdb/symtab.h b/gdb/symtab.h
index 8dfc873b1c9..0fb0c8683cb 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -30,7 +30,7 @@
 #include "gdbsupport/gdb_regex.h"
 #include "gdbsupport/enum-flags.h"
 #include "gdbsupport/function-view.h"
-#include "gdbsupport/gdb_optional.h"
+#include <optional>
 #include "gdbsupport/gdb_string_view.h"
 #include "gdbsupport/next-iterator.h"
 #include "gdbsupport/iterator-range.h"
@@ -364,10 +364,10 @@ class lookup_name_info final
      around by const reference (see intro), and they're conceptually
      "cache" that can always be reconstructed from the non-mutable
      fields.  */
-  mutable gdb::optional<ada_lookup_name_info> m_ada;
-  mutable gdb::optional<demangle_for_lookup_info> m_cplus;
-  mutable gdb::optional<demangle_for_lookup_info> m_d;
-  mutable gdb::optional<demangle_for_lookup_info> m_go;
+  mutable std::optional<ada_lookup_name_info> m_ada;
+  mutable std::optional<demangle_for_lookup_info> m_cplus;
+  mutable std::optional<demangle_for_lookup_info> m_d;
+  mutable std::optional<demangle_for_lookup_info> m_go;
 
   /* The demangled hashes.  Stored in an array with one entry for each
      possible language.  The second array records whether we've
@@ -511,8 +511,8 @@ struct general_symbol_info
      copy_name must be set to true.  */
   void compute_and_set_names (gdb::string_view linkage_name, bool copy_name,
 			      struct objfile_per_bfd_storage *per_bfd,
-			      gdb::optional<hashval_t> hash
-				= gdb::optional<hashval_t> ());
+			      std::optional<hashval_t> hash
+				= std::optional<hashval_t> ());
 
   CORE_ADDR value_address () const
   {
@@ -2598,7 +2598,7 @@ class global_symbol_searcher
      true if any msymbols were seen that we should later consider adding to
      the results list.  */
   bool expand_symtabs (objfile *objfile,
-		       const gdb::optional<compiled_regex> &preg) const;
+		       const std::optional<compiled_regex> &preg) const;
 
   /* Add symbols from symtabs in OBJFILE that match PREG, and TREG, and are
      of type M_KIND, to the results set RESULTS_SET.  Return false if we
@@ -2607,8 +2607,8 @@ class global_symbol_searcher
      Returning true does not indicate that any results were added, just
      that we didn't _not_ add a result due to reaching MAX_SEARCH_RESULTS.  */
   bool add_matching_symbols (objfile *objfile,
-			     const gdb::optional<compiled_regex> &preg,
-			     const gdb::optional<compiled_regex> &treg,
+			     const std::optional<compiled_regex> &preg,
+			     const std::optional<compiled_regex> &treg,
 			     std::set<symbol_search> *result_set) const;
 
   /* Add msymbols from OBJFILE that match PREG and M_KIND, to the results
@@ -2618,7 +2618,7 @@ class global_symbol_searcher
      does not indicate that any results were added, just that we didn't
      _not_ add a result due to reaching MAX_SEARCH_RESULTS.  */
   bool add_matching_msymbols (objfile *objfile,
-			      const gdb::optional<compiled_regex> &preg,
+			      const std::optional<compiled_regex> &preg,
 			      std::vector<symbol_search> *results) const;
 
   /* Return true if MSYMBOL is of type KIND.  */
@@ -2907,7 +2907,7 @@ struct info_sources_filter
 
   /* A compiled version of M_REGEXP.  This object is only given a value if
      M_REGEXP is not nullptr and is not the empty string.  */
-  gdb::optional<compiled_regex> m_c_regexp;
+  std::optional<compiled_regex> m_c_regexp;
 };
 
 /* Perform the core of the 'info sources' command.
diff --git a/gdb/target.c b/gdb/target.c
index 92aa1dd882e..c3dad38f317 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -2231,7 +2231,7 @@ target_write (struct target_ops *ops,
    for details.  */
 
 template <typename T>
-gdb::optional<gdb::def_vector<T>>
+std::optional<gdb::def_vector<T>>
 target_read_alloc_1 (struct target_ops *ops, enum target_object object,
 		     const char *annex)
 {
@@ -2280,7 +2280,7 @@ target_read_alloc_1 (struct target_ops *ops, enum target_object object,
 
 /* See target.h  */
 
-gdb::optional<gdb::byte_vector>
+std::optional<gdb::byte_vector>
 target_read_alloc (struct target_ops *ops, enum target_object object,
 		   const char *annex)
 {
@@ -2289,11 +2289,11 @@ target_read_alloc (struct target_ops *ops, enum target_object object,
 
 /* See target.h.  */
 
-gdb::optional<gdb::char_vector>
+std::optional<gdb::char_vector>
 target_read_stralloc (struct target_ops *ops, enum target_object object,
 		      const char *annex)
 {
-  gdb::optional<gdb::char_vector> buf
+  std::optional<gdb::char_vector> buf
     = target_read_alloc_1<char> (ops, object, annex);
 
   if (!buf)
@@ -2977,7 +2977,7 @@ target_supports_multi_process (void)
 
 /* See target.h.  */
 
-gdb::optional<gdb::char_vector>
+std::optional<gdb::char_vector>
 target_get_osdata (const char *type)
 {
   struct target_ops *t;
@@ -3206,7 +3206,7 @@ target_ops::fileio_unlink (struct inferior *inf, const char *filename,
   return -1;
 }
 
-gdb::optional<std::string>
+std::optional<std::string>
 target_ops::fileio_readlink (struct inferior *inf, const char *filename,
 			     fileio_error *target_errno)
 {
@@ -3377,13 +3377,13 @@ target_fileio_unlink (struct inferior *inf, const char *filename,
 
 /* See target.h.  */
 
-gdb::optional<std::string>
+std::optional<std::string>
 target_fileio_readlink (struct inferior *inf, const char *filename,
 			fileio_error *target_errno)
 {
   for (target_ops *t = default_fileio_target (); t != NULL; t = t->beneath ())
     {
-      gdb::optional<std::string> ret
+      std::optional<std::string> ret
 	= t->fileio_readlink (inf, filename, target_errno);
 
       if (!ret.has_value () && *target_errno == FILEIO_ENOSYS)
diff --git a/gdb/target.h b/gdb/target.h
index fca0bbbf66e..c54bd28c88c 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -345,7 +345,7 @@ LONGEST target_write_with_progress (struct target_ops *ops,
    size is known in advance.  Don't try to read TARGET_OBJECT_MEMORY
    through this function.  */
 
-extern gdb::optional<gdb::byte_vector> target_read_alloc
+extern std::optional<gdb::byte_vector> target_read_alloc
     (struct target_ops *ops, enum target_object object, const char *annex);
 
 /* Read OBJECT/ANNEX using OPS.  The result is a NUL-terminated character vector
@@ -355,7 +355,7 @@ extern gdb::optional<gdb::byte_vector> target_read_alloc
    the returned vector is guaranteed to have at least one element.  A warning is
    issued if the result contains any embedded NUL bytes.  */
 
-extern gdb::optional<gdb::char_vector> target_read_stralloc
+extern std::optional<gdb::char_vector> target_read_stralloc
     (struct target_ops *ops, enum target_object object, const char *annex);
 
 /* See target_ops->to_xfer_partial.  */
@@ -1001,7 +1001,7 @@ struct target_ops
        seen by the debugger (GDB or, for remote targets, the remote
        stub).  Return a string, or an empty optional if an error
        occurs (and set *TARGET_ERRNO).  */
-    virtual gdb::optional<std::string> fileio_readlink (struct inferior *inf,
+    virtual std::optional<std::string> fileio_readlink (struct inferior *inf,
 							const char *filename,
 							fileio_error *target_errno);
 
@@ -2206,7 +2206,7 @@ extern int target_fileio_unlink (struct inferior *inf,
    by the debugger (GDB or, for remote targets, the remote stub).
    Return a null-terminated string allocated via xmalloc, or NULL if
    an error occurs (and set *TARGET_ERRNO).  */
-extern gdb::optional<std::string> target_fileio_readlink
+extern std::optional<std::string> target_fileio_readlink
     (struct inferior *inf, const char *filename, fileio_error *target_errno);
 
 /* Read target file FILENAME, in the filesystem as seen by INF.  If
@@ -2469,7 +2469,7 @@ struct target_ops *find_target_at (enum strata stratum);
 /* Read OS data object of type TYPE from the target, and return it in XML
    format.  The return value follows the same rules as target_read_stralloc.  */
 
-extern gdb::optional<gdb::char_vector> target_get_osdata (const char *type);
+extern std::optional<gdb::char_vector> target_get_osdata (const char *type);
 
 /* Stuff that should be shared among the various remote targets.  */
 
diff --git a/gdb/thread.c b/gdb/thread.c
index 810fdae18a8..c0ed64e5f8b 100644
--- a/gdb/thread.c
+++ b/gdb/thread.c
@@ -46,7 +46,7 @@
 #include "thread-fsm.h"
 #include "tid-parse.h"
 #include <algorithm>
-#include "gdbsupport/gdb_optional.h"
+#include <optional>
 #include "inline-frame.h"
 #include "stack.h"
 #include "interps.h"
@@ -194,7 +194,7 @@ clear_thread_inferior_resources (struct thread_info *tp)
 /* Notify interpreters and observers that thread T has exited.  */
 
 static void
-notify_thread_exited (thread_info *t, gdb::optional<ULONGEST> exit_code,
+notify_thread_exited (thread_info *t, std::optional<ULONGEST> exit_code,
 		      int silent)
 {
   if (!silent && print_thread_events)
@@ -215,7 +215,7 @@ notify_thread_exited (thread_info *t, gdb::optional<ULONGEST> exit_code,
 /* See gdbthread.h.  */
 
 void
-set_thread_exited (thread_info *tp, gdb::optional<ULONGEST> exit_code,
+set_thread_exited (thread_info *tp, std::optional<ULONGEST> exit_code,
 		   bool silent)
 {
   /* Dead threads don't need to step-over.  Remove from chain.  */
@@ -504,7 +504,7 @@ global_thread_step_over_chain_remove (struct thread_info *tp)
 /* Helper for the different delete_thread variants.  */
 
 static void
-delete_thread_1 (thread_info *thr, gdb::optional<ULONGEST> exit_code,
+delete_thread_1 (thread_info *thr, std::optional<ULONGEST> exit_code,
 		 bool silent)
 {
   gdb_assert (thr != nullptr);
@@ -1112,8 +1112,8 @@ print_thread_info_1 (struct ui_out *uiout, const char *requested_threads,
     /* For backward compatibility, we make a list for MI.  A table is
        preferable for the CLI, though, because it shows table
        headers.  */
-    gdb::optional<ui_out_emit_list> list_emitter;
-    gdb::optional<ui_out_emit_table> table_emitter;
+    std::optional<ui_out_emit_list> list_emitter;
+    std::optional<ui_out_emit_table> table_emitter;
 
     /* We'll be switching threads temporarily below.  */
     scoped_restore_current_thread restore_thread;
@@ -1543,7 +1543,7 @@ tp_array_compar_descending (const thread_info_ref &a, const thread_info_ref &b)
 /* See gdbthread.h.  */
 
 void
-thread_try_catch_cmd (thread_info *thr, gdb::optional<int> ada_task,
+thread_try_catch_cmd (thread_info *thr, std::optional<int> ada_task,
 		      const char *cmd, int from_tty,
 		      const qcs_flags &flags)
 {
diff --git a/gdb/tracefile-tfile.c b/gdb/tracefile-tfile.c
index b698b4004cc..a710246d7ad 100644
--- a/gdb/tracefile-tfile.c
+++ b/gdb/tracefile-tfile.c
@@ -305,7 +305,7 @@ tfile_write_tdesc (struct trace_file_writer *self)
   struct tfile_trace_file_writer *writer
     = (struct tfile_trace_file_writer *) self;
 
-  gdb::optional<std::string> tdesc
+  std::optional<std::string> tdesc
     = target_fetch_description_xml (current_inferior ()->top_target ());
 
   if (!tdesc)
diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c
index 750185341ea..05b5f681571 100644
--- a/gdb/tracepoint.c
+++ b/gdb/tracepoint.c
@@ -3732,7 +3732,7 @@ sdata_make_value (struct gdbarch *gdbarch, struct internalvar *var,
 		  void *ignore)
 {
   /* We need to read the whole object before we know its size.  */
-  gdb::optional<gdb::byte_vector> buf
+  std::optional<gdb::byte_vector> buf
     = target_read_alloc (current_inferior ()->top_target (),
 			 TARGET_OBJECT_STATIC_TRACE_DATA,
 			 NULL);
diff --git a/gdb/tui/tui-disasm.c b/gdb/tui/tui-disasm.c
index ffcb95bb635..b5d5a4cc20f 100644
--- a/gdb/tui/tui-disasm.c
+++ b/gdb/tui/tui-disasm.c
@@ -234,7 +234,7 @@ tui_find_disassembly_address (struct gdbarch *gdbarch, CORE_ADDR pc, int from)
 	 promising starting point then we record it in this structure.  If
 	 the next address we try is not a suitable starting point then we
 	 will fall back to the address held here.  */
-      gdb::optional<CORE_ADDR> possible_new_low;
+      std::optional<CORE_ADDR> possible_new_low;
 
       /* The previous value of NEW_LOW so we know if the new value is
 	 different or not.  */
diff --git a/gdb/tui/tui-layout.c b/gdb/tui/tui-layout.c
index 159445dc520..b932649b3ac 100644
--- a/gdb/tui/tui-layout.c
+++ b/gdb/tui/tui-layout.c
@@ -819,7 +819,7 @@ tui_layout_split::apply (int x_, int y_, int width_, int height_,
   };
 
   /* This is given a value only if we fix the size of the cmd window.  */
-  gdb::optional<old_size_info> old_cmd_info;
+  std::optional<old_size_info> old_cmd_info;
 
   std::vector<size_info> info (m_splits.size ());
 
diff --git a/gdb/unittests/optional-selftests.c b/gdb/unittests/optional-selftests.c
index 8a727c02159..51135b8b98c 100644
--- a/gdb/unittests/optional-selftests.c
+++ b/gdb/unittests/optional-selftests.c
@@ -31,7 +31,7 @@
 #define VERIFY SELF_CHECK
 
 /* Used to disable testing features not supported by
-   gdb::optional.  */
+   std::optional.  */
 #define GDB_OPTIONAL
 
 namespace selftests {
@@ -41,7 +41,7 @@ namespace optional {
    copied over from libstdc++'s testsuite.  To preserve the structure
    and help with comparison with the original tests, the file names
    have been preserved, and only minimal modification was done to have
-   them compile against gdb::optional instead of std::optional:
+   them compile against std::optional instead of std::optional:
 
      - std::optional->gdb:optional, etc.
      - ATTRIBUTE_UNUSED in a few places
diff --git a/gdb/utils.c b/gdb/utils.c
index f959af3219b..7a1841ba21e 100644
--- a/gdb/utils.c
+++ b/gdb/utils.c
@@ -68,7 +68,7 @@
 #include "gdbsupport/gdb_regex.h"
 #include "gdbsupport/job-control.h"
 #include "gdbsupport/selftest.h"
-#include "gdbsupport/gdb_optional.h"
+#include <optional>
 #include "cp-support.h"
 #include <algorithm>
 #include "gdbsupport/pathstuff.h"
@@ -143,7 +143,7 @@ vwarning (const char *string, va_list args)
     (*deprecated_warning_hook) (string, args);
   else
     {
-      gdb::optional<target_terminal::scoped_restore_terminal_state> term_state;
+      std::optional<target_terminal::scoped_restore_terminal_state> term_state;
       if (target_supports_terminal_ours ())
 	{
 	  term_state.emplace ();
@@ -375,7 +375,7 @@ internal_vproblem (struct internal_problem *problem,
     }
 
   /* Try to get the message out and at the start of a new line.  */
-  gdb::optional<target_terminal::scoped_restore_terminal_state> term_state;
+  std::optional<target_terminal::scoped_restore_terminal_state> term_state;
   if (target_supports_terminal_ours ())
     {
       term_state.emplace ();
diff --git a/gdb/valarith.c b/gdb/valarith.c
index f3acf98c98b..6cf56302aee 100644
--- a/gdb/valarith.c
+++ b/gdb/valarith.c
@@ -150,14 +150,14 @@ value_subscript (struct value *array, LONGEST index)
       || tarray->code () == TYPE_CODE_STRING)
     {
       struct type *range_type = tarray->index_type ();
-      gdb::optional<LONGEST> lowerbound = get_discrete_low_bound (range_type);
+      std::optional<LONGEST> lowerbound = get_discrete_low_bound (range_type);
       if (!lowerbound.has_value ())
 	lowerbound = 0;
 
       if (array->lval () != lval_memory)
 	return value_subscripted_rvalue (array, index, *lowerbound);
 
-      gdb::optional<LONGEST> upperbound
+      std::optional<LONGEST> upperbound
 	= get_discrete_high_bound (range_type);
 
       if (!upperbound.has_value ())
diff --git a/gdb/valops.c b/gdb/valops.c
index 70851cd40b4..a8760ccf3e4 100644
--- a/gdb/valops.c
+++ b/gdb/valops.c
@@ -52,7 +52,7 @@ static struct value *search_struct_field (const char *, struct value *,
 					  struct type *, int);
 
 static struct value *search_struct_method (const char *, struct value **,
-					   gdb::optional<gdb::array_view<value *>>,
+					   std::optional<gdb::array_view<value *>>,
 					   LONGEST, int *, struct type *);
 
 static int find_oload_champ_namespace (gdb::array_view<value *> args,
@@ -2196,7 +2196,7 @@ search_struct_field (const char *name, struct value *arg1,
 
 static struct value *
 search_struct_method (const char *name, struct value **arg1p,
-		      gdb::optional<gdb::array_view<value *>> args,
+		      std::optional<gdb::array_view<value *>> args,
 		      LONGEST offset, int *static_memfuncp,
 		      struct type *type)
 {
@@ -2332,7 +2332,7 @@ search_struct_method (const char *name, struct value **arg1p,
 
 struct value *
 value_struct_elt (struct value **argp,
-		  gdb::optional<gdb::array_view<value *>> args,
+		  std::optional<gdb::array_view<value *>> args,
 		  const char *name, int *static_memfuncp, const char *err)
 {
   struct type *t;
diff --git a/gdb/value.c b/gdb/value.c
index 17b7c53d052..7067ae94df0 100644
--- a/gdb/value.c
+++ b/gdb/value.c
@@ -826,7 +826,7 @@ exceeds_max_value_size (ULONGEST length)
 /* When this has a value, it is used to limit the number of array elements
    of an array that are loaded into memory when an array value is made
    non-lazy.  */
-static gdb::optional<int> array_length_limiting_element_count;
+static std::optional<int> array_length_limiting_element_count;
 
 /* See value.h.  */
 scoped_array_length_limiting::scoped_array_length_limiting (int elements)
diff --git a/gdb/value.h b/gdb/value.h
index e4912717684..6d91e8eee7a 100644
--- a/gdb/value.h
+++ b/gdb/value.h
@@ -1269,7 +1269,7 @@ extern struct value *value_neg (struct value *arg1);
 extern struct value *value_complement (struct value *arg1);
 
 extern struct value *value_struct_elt (struct value **argp,
-				       gdb::optional<gdb::array_view <value *>> args,
+				       std::optional<gdb::array_view <value *>> args,
 				       const char *name, int *static_memfuncp,
 				       const char *err);
 
@@ -1635,7 +1635,7 @@ struct scoped_array_length_limiting
 
 private:
   /* Used to hold the previous array value element limit.  */
-  gdb::optional<int> m_old_value;
+  std::optional<int> m_old_value;
 };
 
 #endif /* !defined (VALUE_H) */
diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c
index 205bf01174f..b3440344c74 100644
--- a/gdb/windows-nat.c
+++ b/gdb/windows-nat.c
@@ -1335,7 +1335,7 @@ windows_nat_target::windows_continue (DWORD continue_status, int id,
 	th->suspend ();
       }
 
-  gdb::optional<unsigned> err;
+  std::optional<unsigned> err;
   do_synchronously ([&] ()
     {
       if (!continue_last_debug_event (continue_status, debug_events))
@@ -1561,7 +1561,7 @@ windows_nat_target::get_windows_debug_event
   /* If there is a relevant pending stop, report it now.  See the
      comment by the definition of "pending_stops" for details on why
      this is needed.  */
-  gdb::optional<pending_stop> stop
+  std::optional<pending_stop> stop
     = windows_process.fetch_pending_stop (debug_events);
   if (stop.has_value ())
     {
@@ -2024,7 +2024,7 @@ windows_nat_target::attach (const char *args, int from_tty)
   windows_init_thread_list ();
   windows_process.saw_create = 0;
 
-  gdb::optional<unsigned> err;
+  std::optional<unsigned> err;
   do_synchronously ([&] ()
     {
       BOOL ok = DebugActiveProcess (pid);
@@ -2074,7 +2074,7 @@ windows_nat_target::detach (inferior *inf, int from_tty)
 {
   windows_continue (DBG_CONTINUE, -1, 0, true);
 
-  gdb::optional<unsigned> err;
+  std::optional<unsigned> err;
   do_synchronously ([&] ()
     {
       if (!DebugActiveProcessStop (windows_process.current_event.dwProcessId))
@@ -2533,7 +2533,7 @@ windows_nat_target::create_inferior (const char *exec_file,
 #endif	/* !__CYGWIN__ */
   const char *allargs = origallargs.c_str ();
   PROCESS_INFORMATION pi;
-  gdb::optional<unsigned> ret;
+  std::optional<unsigned> ret;
   DWORD flags = 0;
   const std::string &inferior_tty = current_inferior ()->tty ();
 
diff --git a/gdb/xml-support.c b/gdb/xml-support.c
index 0c98dc7e6b4..2d231b6f4bb 100644
--- a/gdb/xml-support.c
+++ b/gdb/xml-support.c
@@ -785,7 +785,7 @@ xinclude_start_include (struct gdb_xml_parser *parser,
     gdb_xml_error (parser, _("Maximum XInclude depth (%d) exceeded"),
 		   MAX_XINCLUDE_DEPTH);
 
-  gdb::optional<gdb::char_vector> text = data->fetcher (href);
+  std::optional<gdb::char_vector> text = data->fetcher (href);
   if (!text)
     gdb_xml_error (parser, _("Could not load XML document \"%s\""), href);
 
@@ -960,7 +960,7 @@ show_debug_xml (struct ui_file *file, int from_tty,
   gdb_printf (file, _("XML debugging is %s.\n"), value);
 }
 
-gdb::optional<gdb::char_vector>
+std::optional<gdb::char_vector>
 xml_fetch_content_from_file (const char *filename, const char *dirname)
 {
   gdb_file_up file;
diff --git a/gdb/xml-support.h b/gdb/xml-support.h
index 1f9ac68b745..8388276df25 100644
--- a/gdb/xml-support.h
+++ b/gdb/xml-support.h
@@ -24,7 +24,7 @@
 #include "gdbsupport/gdb_obstack.h"
 #include "gdbsupport/xml-utils.h"
 #include "gdbsupport/byte-vector.h"
-#include "gdbsupport/gdb_optional.h"
+#include <optional>
 #include "gdbsupport/function-view.h"
 
 struct gdb_xml_parser;
@@ -49,7 +49,7 @@ LONGEST xml_builtin_xfer_partial (const char *filename,
 
 /* Callback to fetch a new XML file, based on the provided HREF.  */
 
-using xml_fetch_another = gdb::function_view<gdb::optional<gdb::char_vector>
+using xml_fetch_another = gdb::function_view<std::optional<gdb::char_vector>
 					     (const char * /* href */)>;
 
 /* Append the expansion of TEXT after processing <xi:include> tags in
@@ -230,7 +230,7 @@ ULONGEST gdb_xml_parse_ulongest (struct gdb_xml_parser *parser,
    the text.  If something goes wrong, return an uninstantiated optional
    and warn.  */
 
-extern gdb::optional<gdb::char_vector> xml_fetch_content_from_file
+extern std::optional<gdb::char_vector> xml_fetch_content_from_file
     (const char *filename, const char *dirname);
 
 #endif
diff --git a/gdb/xml-syscall.c b/gdb/xml-syscall.c
index da1211ef8e9..cfb54347431 100644
--- a/gdb/xml-syscall.c
+++ b/gdb/xml-syscall.c
@@ -314,7 +314,7 @@ syscall_parse_xml (const char *document, xml_fetch_another fetcher)
 static struct syscalls_info *
 xml_init_syscalls_info (const char *filename)
 {
-  gdb::optional<gdb::char_vector> full_file
+  std::optional<gdb::char_vector> full_file
     = xml_fetch_content_from_file (filename,
 				   const_cast<char *>(gdb_datadir.c_str ()));
   if (!full_file)
diff --git a/gdb/xml-tdesc.c b/gdb/xml-tdesc.c
index a8b0b0566c7..daf123af69d 100644
--- a/gdb/xml-tdesc.c
+++ b/gdb/xml-tdesc.c
@@ -663,7 +663,7 @@ tdesc_parse_xml (const char *document, xml_fetch_another fetcher)
 const struct target_desc *
 file_read_description_xml (const char *filename)
 {
-  gdb::optional<gdb::char_vector> tdesc_str
+  std::optional<gdb::char_vector> tdesc_str
     = xml_fetch_content_from_file (filename, NULL);
   if (!tdesc_str)
     {
@@ -687,7 +687,7 @@ file_read_description_xml (const char *filename)
    is "target.xml".  Other calls may be performed for the DTD or
    for <xi:include>.  */
 
-static gdb::optional<gdb::char_vector>
+static std::optional<gdb::char_vector>
 fetch_available_features_from_target (const char *name, target_ops *ops)
 {
   /* Read this object as a string.  This ensures that a NUL
@@ -704,7 +704,7 @@ fetch_available_features_from_target (const char *name, target_ops *ops)
 const struct target_desc *
 target_read_description_xml (struct target_ops *ops)
 {
-  gdb::optional<gdb::char_vector> tdesc_str
+  std::optional<gdb::char_vector> tdesc_str
     = fetch_available_features_from_target ("target.xml", ops);
   if (!tdesc_str)
     return NULL;
@@ -721,7 +721,7 @@ target_read_description_xml (struct target_ops *ops)
    includes, but not parsing it.  Used to dump whole tdesc
    as a single XML file.  */
 
-gdb::optional<std::string>
+std::optional<std::string>
 target_fetch_description_xml (struct target_ops *ops)
 {
 #if !defined(HAVE_LIBEXPAT)
@@ -736,7 +736,7 @@ target_fetch_description_xml (struct target_ops *ops)
 
   return {};
 #else
-  gdb::optional<gdb::char_vector>
+  std::optional<gdb::char_vector>
     tdesc_str = fetch_available_features_from_target ("target.xml", ops);
   if (!tdesc_str)
     return {};
@@ -765,6 +765,6 @@ string_read_description_xml (const char *xml)
   return tdesc_parse_xml (xml, [] (const char *href)
     {
       error (_("xincludes are unsupported with this method"));
-      return gdb::optional<gdb::char_vector> ();
+      return std::optional<gdb::char_vector> ();
     });
 }
diff --git a/gdb/xml-tdesc.h b/gdb/xml-tdesc.h
index 0fbfc7e043e..0ffca92ed7a 100644
--- a/gdb/xml-tdesc.h
+++ b/gdb/xml-tdesc.h
@@ -22,7 +22,7 @@
 #ifndef XML_TDESC_H
 #define XML_TDESC_H
 
-#include "gdbsupport/gdb_optional.h"
+#include <optional>
 #include <string>
 
 struct target_ops;
@@ -42,7 +42,7 @@ const struct target_desc *target_read_description_xml (struct target_ops *);
    but not parsing it.  Used to dump whole tdesc as a single XML file.
    Returns the description on success, and a disengaged optional
    otherwise.  */
-gdb::optional<std::string> target_fetch_description_xml (target_ops *ops);
+std::optional<std::string> target_fetch_description_xml (target_ops *ops);
 
 /* Take an xml string, parse it, and return the parsed description.  Does not
    handle a string containing includes.  */
diff --git a/gdbserver/linux-aarch64-low.cc b/gdbserver/linux-aarch64-low.cc
index fcbe7bb64d7..70454652720 100644
--- a/gdbserver/linux-aarch64-low.cc
+++ b/gdbserver/linux-aarch64-low.cc
@@ -299,7 +299,7 @@ aarch64_fill_tlsregset (struct regcache *regcache, void *buf)
   collect_register (regcache, tls_regnum, tls_buf);
 
   /* Read TPIDR2, if it exists.  */
-  gdb::optional<int> regnum = find_regno_no_throw (regcache->tdesc, "tpidr2");
+  std::optional<int> regnum = find_regno_no_throw (regcache->tdesc, "tpidr2");
 
   if (regnum.has_value ())
     collect_register (regcache, *regnum, tls_buf + sizeof (uint64_t));
@@ -316,7 +316,7 @@ aarch64_store_tlsregset (struct regcache *regcache, const void *buf)
   supply_register (regcache, tls_regnum, tls_buf);
 
   /* Write TPIDR2, if it exists.  */
-  gdb::optional<int> regnum = find_regno_no_throw (regcache->tdesc, "tpidr2");
+  std::optional<int> regnum = find_regno_no_throw (regcache->tdesc, "tpidr2");
 
   if (regnum.has_value ())
     supply_register (regcache, *regnum, tls_buf + sizeof (uint64_t));
diff --git a/gdbserver/regcache.cc b/gdbserver/regcache.cc
index 0b1141662ac..2e75a948a19 100644
--- a/gdbserver/regcache.cc
+++ b/gdbserver/regcache.cc
@@ -249,7 +249,7 @@ registers_from_string (struct regcache *regcache, char *buf)
 
 /* See regcache.h */
 
-gdb::optional<int>
+std::optional<int>
 find_regno_no_throw (const struct target_desc *tdesc, const char *name)
 {
   for (int i = 0; i < tdesc->reg_defs.size (); ++i)
@@ -263,7 +263,7 @@ find_regno_no_throw (const struct target_desc *tdesc, const char *name)
 int
 find_regno (const struct target_desc *tdesc, const char *name)
 {
-  gdb::optional<int> regnum = find_regno_no_throw (tdesc, name);
+  std::optional<int> regnum = find_regno_no_throw (tdesc, name);
 
   if (regnum.has_value ())
     return *regnum;
diff --git a/gdbserver/regcache.h b/gdbserver/regcache.h
index 7248bcf5808..4700c03f104 100644
--- a/gdbserver/regcache.h
+++ b/gdbserver/regcache.h
@@ -112,7 +112,7 @@ int register_size (const struct target_desc *tdesc, int n);
 
 /* No throw version of find_regno.  If NAME is not a known register, return
    an empty value.  */
-gdb::optional<int> find_regno_no_throw (const struct target_desc *tdesc,
+std::optional<int> find_regno_no_throw (const struct target_desc *tdesc,
 					const char *name);
 
 int find_regno (const struct target_desc *tdesc, const char *name);
diff --git a/gdbserver/win32-low.cc b/gdbserver/win32-low.cc
index 3246957ec44..3842c80daff 100644
--- a/gdbserver/win32-low.cc
+++ b/gdbserver/win32-low.cc
@@ -1019,7 +1019,7 @@ get_child_debug_event (DWORD *continue_status,
 
   windows_process.attaching = 0;
   {
-    gdb::optional<pending_stop> stop
+    std::optional<pending_stop> stop
       = windows_process.fetch_pending_stop (debug_threads);
     if (stop.has_value ())
       {
diff --git a/gdbsupport/common-debug.h b/gdbsupport/common-debug.h
index 33b15a005f1..8908669696c 100644
--- a/gdbsupport/common-debug.h
+++ b/gdbsupport/common-debug.h
@@ -20,7 +20,7 @@
 #ifndef COMMON_COMMON_DEBUG_H
 #define COMMON_COMMON_DEBUG_H
 
-#include "gdbsupport/gdb_optional.h"
+#include <optional>
 #include "gdbsupport/preprocessor.h"
 
 #include <stdarg.h>
@@ -200,7 +200,7 @@ struct scoped_debug_start_end
   const char *m_end_prefix;
 
   /* The result of formatting the format string in the constructor.  */
-  gdb::optional<std::string> m_msg;
+  std::optional<std::string> m_msg;
 
   /* True is a non-nullptr format was passed to the constructor.  */
   bool m_with_format;
diff --git a/gdbsupport/event-loop.cc b/gdbsupport/event-loop.cc
index 52e7fd2223f..031c2ff500f 100644
--- a/gdbsupport/event-loop.cc
+++ b/gdbsupport/event-loop.cc
@@ -33,7 +33,7 @@
 #include <sys/types.h>
 #include "gdbsupport/gdb_sys_time.h"
 #include "gdbsupport/gdb_select.h"
-#include "gdbsupport/gdb_optional.h"
+#include <optional>
 #include "gdbsupport/scope-exit.h"
 
 /* See event-loop.h.  */
@@ -246,7 +246,7 @@ gdb_do_one_event (int mstimeout)
      When the timeout is reached, events are not monitored again:
      they already have been checked in the loop above. */
 
-  gdb::optional<int> timer_id;
+  std::optional<int> timer_id;
 
   SCOPE_EXIT 
     {
@@ -258,7 +258,7 @@ gdb_do_one_event (int mstimeout)
     timer_id = create_timer (mstimeout,
 			     [] (gdb_client_data arg)
 			     {
-			       ((gdb::optional<int> *) arg)->reset ();
+			       ((std::optional<int> *) arg)->reset ();
 			     },
 			     &timer_id);
   return gdb_wait_for_event (1);
diff --git a/gdbsupport/filestuff.cc b/gdbsupport/filestuff.cc
index 9e61fea1195..334bae88dce 100644
--- a/gdbsupport/filestuff.cc
+++ b/gdbsupport/filestuff.cc
@@ -504,7 +504,7 @@ mkdir_recursive (const char *dir)
 
 /* See gdbsupport/filestuff.h.  */
 
-gdb::optional<std::string>
+std::optional<std::string>
 read_text_file_to_string (const char *path)
 {
   gdb_file_up file = gdb_fopen_cloexec (path, "r");
diff --git a/gdbsupport/filestuff.h b/gdbsupport/filestuff.h
index 48bef51f259..206b51e50e9 100644
--- a/gdbsupport/filestuff.h
+++ b/gdbsupport/filestuff.h
@@ -131,6 +131,6 @@ extern bool mkdir_recursive (const char *dir);
 
 /* Read the entire content of file PATH into an std::string.  */
 
-extern gdb::optional<std::string> read_text_file_to_string (const char *path);
+extern std::optional<std::string> read_text_file_to_string (const char *path);
 
 #endif /* COMMON_FILESTUFF_H */
diff --git a/gdbsupport/forward-scope-exit.h b/gdbsupport/forward-scope-exit.h
index bf591ddf170..0552e1132f0 100644
--- a/gdbsupport/forward-scope-exit.h
+++ b/gdbsupport/forward-scope-exit.h
@@ -52,9 +52,9 @@
       obj.release ();  // Optional cancel if needed.
 
    forward_scope_exit is also handy when you would need to wrap a
-   scope_exit in a gdb::optional:
+   scope_exit in a std::optional:
 
-      gdb::optional<longjmp_breakpoint_cleanup> cleanup;
+      std::optional<longjmp_breakpoint_cleanup> cleanup;
       if (some condition)
 	cleanup.emplace (thread);
       ...
@@ -62,7 +62,7 @@
 	cleanup->release ();
 
    since with scope exit, you would have to know the scope_exit's
-   callable template type when you create the gdb::optional:
+   callable template type when you create the std::optional:
 
      gdb:optional<scope_exit<what goes here?>>
 
diff --git a/gdbsupport/range-chain.h b/gdbsupport/range-chain.h
index 01d6cf0e4fc..3cebce014ad 100644
--- a/gdbsupport/range-chain.h
+++ b/gdbsupport/range-chain.h
@@ -90,7 +90,7 @@ struct range_chain
     /* The current iterator into one of the vector ranges.  If no
        value then this (outer) iterator is at the end of the overall
        range.  */
-    gdb::optional<typename Range::iterator> m_current;
+    std::optional<typename Range::iterator> m_current;
     /* Vector of ranges.  */
     const std::vector<Range> &m_ranges;
   };
diff --git a/gdbsupport/scoped_ignore_sigttou.h b/gdbsupport/scoped_ignore_sigttou.h
index a3f8361512a..558fb7f0a29 100644
--- a/gdbsupport/scoped_ignore_sigttou.h
+++ b/gdbsupport/scoped_ignore_sigttou.h
@@ -26,7 +26,7 @@
 #ifdef SIGTTOU
 
 /* Simple wrapper that allows lazy initialization / destruction of T.
-   Slightly more efficient than gdb::optional, because it doesn't
+   Slightly more efficient than std::optional, because it doesn't
    carry storage to track whether the object has been initialized.  */
 template<typename T>
 class lazy_init
diff --git a/gdbsupport/thread-pool.cc b/gdbsupport/thread-pool.cc
index 1c871ed378f..bbe043dc0a3 100644
--- a/gdbsupport/thread-pool.cc
+++ b/gdbsupport/thread-pool.cc
@@ -225,7 +225,7 @@ thread_pool::thread_function ()
 
   while (true)
     {
-      optional<task_t> t;
+      std::optional<task_t> t;
 
       {
 	/* We want to hold the lock while examining the task list, but
diff --git a/gdbsupport/thread-pool.h b/gdbsupport/thread-pool.h
index cb8696e1fa4..d5e1dc7fce1 100644
--- a/gdbsupport/thread-pool.h
+++ b/gdbsupport/thread-pool.h
@@ -30,7 +30,7 @@
 #include <condition_variable>
 #include <future>
 #endif
-#include "gdbsupport/gdb_optional.h"
+#include <optional>
 
 namespace gdb
 {
@@ -198,7 +198,7 @@ class thread_pool
      to represent a task.  If the optional is empty, then this means
      that the receiving thread should terminate.  If the optional is
      non-empty, then it is an actual task to evaluate.  */
-  std::queue<optional<task_t>> m_tasks;
+  std::queue<std::optional<task_t>> m_tasks;
 
   /* A condition variable and mutex that are used for communication
      between the main thread and the worker threads.  */
-- 
2.34.1


^ permalink raw reply	[flat|nested] 39+ messages in thread

* [COMMITTED PATCH v2 3/9] gdbsupport: remove gdb::optional
  2023-10-28 20:48       ` Lancelot SIX
                           ` (2 preceding siblings ...)
  2023-11-21 12:04         ` [COMMITTED PATCH v2 2/9] gdb: Replace gdb::optional with std::optional Lancelot Six
@ 2023-11-21 12:04         ` Lancelot Six
  2023-11-21 12:04         ` [COMMITTED PATCH v2 4/9] gdb: Use std::string_view instead of gdb::string_view Lancelot Six
                           ` (5 subsequent siblings)
  9 siblings, 0 replies; 39+ messages in thread
From: Lancelot Six @ 2023-11-21 12:04 UTC (permalink / raw)
  To: gdb-patches; +Cc: pedro, tom, Lancelot Six

The previous patch migrated all the uses of gdb::optional to use
std::optional instead,  so gdb::optional can be removed entirely
as well as the self-tests which came with it.

Change-Id: I96ecd67b850b01be10ef00eb85a78ac647d5adc7
Approved-By: Tom Tromey <tom@tromey.com>
Approved-By: Pedro Alves <pedro@palves.net>
---
 gdb/Makefile.in                        |   1 -
 gdb/unittests/optional-selftests.c     |  95 --------
 gdb/unittests/optional/assignment/1.cc | 196 ----------------
 gdb/unittests/optional/assignment/2.cc | 194 ----------------
 gdb/unittests/optional/assignment/3.cc | 157 -------------
 gdb/unittests/optional/assignment/4.cc | 157 -------------
 gdb/unittests/optional/assignment/5.cc |  81 -------
 gdb/unittests/optional/assignment/6.cc |  91 --------
 gdb/unittests/optional/assignment/7.cc |  30 ---
 gdb/unittests/optional/cons/copy.cc    | 127 -----------
 gdb/unittests/optional/cons/default.cc |  59 -----
 gdb/unittests/optional/cons/move.cc    | 125 -----------
 gdb/unittests/optional/cons/value.cc   | 295 -------------------------
 gdb/unittests/optional/in_place.cc     |  66 ------
 gdb/unittests/optional/observers/1.cc  |  32 ---
 gdb/unittests/optional/observers/2.cc  |  36 ---
 gdbsupport/gdb_optional.h              | 233 -------------------
 17 files changed, 1975 deletions(-)
 delete mode 100644 gdb/unittests/optional-selftests.c
 delete mode 100644 gdb/unittests/optional/assignment/1.cc
 delete mode 100644 gdb/unittests/optional/assignment/2.cc
 delete mode 100644 gdb/unittests/optional/assignment/3.cc
 delete mode 100644 gdb/unittests/optional/assignment/4.cc
 delete mode 100644 gdb/unittests/optional/assignment/5.cc
 delete mode 100644 gdb/unittests/optional/assignment/6.cc
 delete mode 100644 gdb/unittests/optional/assignment/7.cc
 delete mode 100644 gdb/unittests/optional/cons/copy.cc
 delete mode 100644 gdb/unittests/optional/cons/default.cc
 delete mode 100644 gdb/unittests/optional/cons/move.cc
 delete mode 100644 gdb/unittests/optional/cons/value.cc
 delete mode 100644 gdb/unittests/optional/in_place.cc
 delete mode 100644 gdb/unittests/optional/observers/1.cc
 delete mode 100644 gdb/unittests/optional/observers/2.cc
 delete mode 100644 gdbsupport/gdb_optional.h

diff --git a/gdb/Makefile.in b/gdb/Makefile.in
index 52b08692b52..714564f27b4 100644
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -469,7 +469,6 @@ SELFTESTS_SRCS = \
 	unittests/memrange-selftests.c \
 	unittests/offset-type-selftests.c \
 	unittests/observable-selftests.c \
-	unittests/optional-selftests.c \
 	unittests/packed-selftests.c \
 	unittests/parallel-for-selftests.c \
 	unittests/parse-connection-spec-selftests.c \
diff --git a/gdb/unittests/optional-selftests.c b/gdb/unittests/optional-selftests.c
deleted file mode 100644
index 51135b8b98c..00000000000
--- a/gdb/unittests/optional-selftests.c
+++ /dev/null
@@ -1,95 +0,0 @@
-/* Self tests for optional for GDB, the GNU debugger.
-
-   Copyright (C) 2017-2023 Free Software Foundation, Inc.
-
-   This file is part of GDB.
-
-   This program 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 of the License, or
-   (at your option) any later version.
-
-   This program 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.
-
-   You should have received a copy of the GNU General Public License
-   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
-
-#include "defs.h"
-#include "gdbsupport/selftest.h"
-#include "gdbsupport/gdb_optional.h"
-
-/* Used by the included .cc files below.  Included here because the
-   included test files are wrapped in a namespace.  */
-#include <vector>
-#include <string>
-#include <memory>
-
-/* libstdc++'s testsuite uses VERIFY.  */
-#define VERIFY SELF_CHECK
-
-/* Used to disable testing features not supported by
-   std::optional.  */
-#define GDB_OPTIONAL
-
-namespace selftests {
-namespace optional {
-
-/* The actual tests live in separate files, which were originally
-   copied over from libstdc++'s testsuite.  To preserve the structure
-   and help with comparison with the original tests, the file names
-   have been preserved, and only minimal modification was done to have
-   them compile against std::optional instead of std::optional:
-
-     - std::optional->gdb:optional, etc.
-     - ATTRIBUTE_UNUSED in a few places
-     - wrap each file in a namespace so they can all be compiled as a
-       single unit.
-     - libstdc++'s license and formatting style was preserved.
-*/
-
-#include "optional/assignment/1.cc"
-#include "optional/assignment/2.cc"
-#include "optional/assignment/3.cc"
-#include "optional/assignment/4.cc"
-#include "optional/assignment/5.cc"
-#include "optional/assignment/6.cc"
-#include "optional/assignment/7.cc"
-#include "optional/cons/copy.cc"
-#include "optional/cons/default.cc"
-#include "optional/cons/move.cc"
-#include "optional/cons/value.cc"
-#include "optional/in_place.cc"
-#include "optional/observers/1.cc"
-#include "optional/observers/2.cc"
-
-static void
-run_tests ()
-{
-  assign_1::test ();
-  assign_2::test ();
-  assign_3::test ();
-  assign_4::test ();
-  assign_5::test ();
-  assign_6::test ();
-  assign_7::test ();
-  cons_copy::test ();
-  cons_default::test ();
-  cons_move::test ();
-  cons_value::test ();
-  in_place::test ();
-  observers_1::test ();
-  observers_2::test ();
-}
-
-} /* namespace optional */
-} /* namespace selftests */
-
-void _initialize_optional_selftests ();
-void
-_initialize_optional_selftests ()
-{
-  selftests::register_test ("optional", selftests::optional::run_tests);
-}
diff --git a/gdb/unittests/optional/assignment/1.cc b/gdb/unittests/optional/assignment/1.cc
deleted file mode 100644
index 6a68f7d4002..00000000000
--- a/gdb/unittests/optional/assignment/1.cc
+++ /dev/null
@@ -1,196 +0,0 @@
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-namespace assign_1 {
-
-struct exception {};
-
-static int counter = 0;
-
-struct mixin_counter
-{
-  mixin_counter() { ++counter; }
-  mixin_counter(mixin_counter const&) { ++counter; }
-  ~mixin_counter() { --counter; }
-};
-
-struct value_type : private mixin_counter
-{
-  enum state_type
-  {
-    zero,
-    moved_from,
-    throwing_construction,
-    throwing_copy,
-    throwing_copy_assignment,
-    throwing_move,
-    throwing_move_assignment,
-    threw,
-  };
-
-  value_type() = default;
-
-  explicit value_type(state_type state_)
-  : state(state_)
-  {
-    throw_if(throwing_construction);
-  }
-
-  value_type(value_type const& other)
-  : state(other.state)
-  {
-    throw_if(throwing_copy);
-  }
-
-  value_type&
-  operator=(value_type const& other)
-  {
-    state = other.state;
-    throw_if(throwing_copy_assignment);
-    return *this;
-  }
-
-  value_type(value_type&& other)
-  : state(other.state)
-  {
-    other.state = moved_from;
-    throw_if(throwing_move);
-  }
-
-  value_type&
-  operator=(value_type&& other)
-  {
-    state = other.state;
-    other.state = moved_from;
-    throw_if(throwing_move_assignment);
-    return *this;
-  }
-
-  void throw_if(state_type match)
-  {
-    if(state == match)
-    {
-      state = threw;
-      throw exception {};
-    }
-  }
-
-  state_type state = zero;
-};
-
-static void
-test ()
-{
-  using O = gdb::optional<value_type>;
-  using S = value_type::state_type;
-  auto const make = [](S s = S::zero) { return O { gdb::in_place, s }; };
-
-  enum outcome_type { nothrow, caught, bad_catch };
-
-  // Check copy/move assignment for disengaged optional
-
-  // From disengaged optional
-  {
-    O o;
-    VERIFY( !o );
-    O p;
-    o = p;
-    VERIFY( !o );
-    VERIFY( !p );
-  }
-
-  {
-    O o;
-    VERIFY( !o );
-    O p;
-    o = std::move(p);
-    VERIFY( !o );
-    VERIFY( !p );
-  }
-
-#ifndef GDB_OPTIONAL
-  {
-    O o;
-    VERIFY( !o );
-    o = {};
-    VERIFY( !o );
-  }
-#endif
-
-  // From engaged optional
-  {
-    O o;
-    VERIFY( !o );
-    O p = make(S::throwing_copy_assignment);
-    o = p;
-    VERIFY( o && o->state == S::throwing_copy_assignment );
-    VERIFY( p && p->state == S::throwing_copy_assignment );
-  }
-
-  {
-    O o;
-    VERIFY( !o );
-    O p = make(S::throwing_move_assignment);
-    o = std::move(p);
-    VERIFY( o && o->state == S::throwing_move_assignment );
-    VERIFY( p && p->state == S::moved_from );
-  }
-
-  {
-    outcome_type outcome {};
-    O o;
-    VERIFY( !o );
-    O p = make(S::throwing_copy);
-
-    try
-    {
-      o = p;
-    }
-    catch(exception const&)
-    { outcome = caught; }
-    catch(...)
-    { outcome = bad_catch; }
-
-    VERIFY( outcome == caught );
-    VERIFY( !o );
-    VERIFY( p && p->state == S::throwing_copy );
-  }
-
-  {
-    outcome_type outcome {};
-    O o;
-    VERIFY( !o );
-    O p = make(S::throwing_move);
-
-    try
-    {
-      o = std::move(p);
-    }
-    catch(exception const&)
-    { outcome = caught; }
-    catch(...)
-    { outcome = bad_catch; }
-
-    VERIFY( outcome == caught );
-    VERIFY( !o );
-    VERIFY( p && p->state == S::moved_from );
-  }
-
-  VERIFY( counter == 0 );
-}
-
-} // namespace assign_1
diff --git a/gdb/unittests/optional/assignment/2.cc b/gdb/unittests/optional/assignment/2.cc
deleted file mode 100644
index 2e63a491920..00000000000
--- a/gdb/unittests/optional/assignment/2.cc
+++ /dev/null
@@ -1,194 +0,0 @@
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-namespace assign_2 {
-
-struct exception {};
-
-static int counter = 0;
-
-struct mixin_counter
-{
-  mixin_counter() { ++counter; }
-  mixin_counter(mixin_counter const&) { ++counter; }
-  ~mixin_counter() { --counter; }
-};
-
-struct value_type : private mixin_counter
-{
-  enum state_type
-  {
-    zero,
-    moved_from,
-    throwing_construction,
-    throwing_copy,
-    throwing_copy_assignment,
-    throwing_move,
-    throwing_move_assignment,
-    threw,
-  };
-
-  value_type() = default;
-
-  explicit value_type(state_type state_)
-  : state(state_)
-  {
-    throw_if(throwing_construction);
-  }
-
-  value_type(value_type const& other)
-  : state(other.state)
-  {
-    throw_if(throwing_copy);
-  }
-
-  value_type&
-  operator=(value_type const& other)
-  {
-    state = other.state;
-    throw_if(throwing_copy_assignment);
-    return *this;
-  }
-
-  value_type(value_type&& other)
-  : state(other.state)
-  {
-    other.state = moved_from;
-    throw_if(throwing_move);
-  }
-
-  value_type&
-  operator=(value_type&& other)
-  {
-    state = other.state;
-    other.state = moved_from;
-    throw_if(throwing_move_assignment);
-    return *this;
-  }
-
-  void throw_if(state_type match)
-  {
-    if(state == match)
-    {
-      state = threw;
-      throw exception {};
-    }
-  }
-
-  state_type state = zero;
-};
-
-static void
-test ()
-{
-  using O = gdb::optional<value_type>;
-  using S = value_type::state_type;
-  auto const make = [](S s = S::zero) { return O { gdb::in_place, s }; };
-
-  enum outcome_type { nothrow, caught, bad_catch };
-
-  // Check copy/move assignment for engaged optional
-
-  // From disengaged optional
-  {
-    O o = make(S::zero);
-    VERIFY( o );
-    O p;
-    o = p;
-    VERIFY( !o );
-    VERIFY( !p );
-  }
-
-  {
-    O o = make(S::zero);
-    VERIFY( o );
-    O p;
-    o = std::move(p);
-    VERIFY( !o );
-    VERIFY( !p );
-  }
-
-#ifndef GDB_OPTIONAL
-  {
-    O o = make(S::zero);
-    VERIFY( o );
-    o = {};
-    VERIFY( !o );
-  }
-#endif
-
-  // From engaged optional
-  {
-    O o = make(S::zero);
-    VERIFY( o );
-    O p = make(S::throwing_copy);
-    o = p;
-    VERIFY( o && o->state == S::throwing_copy);
-    VERIFY( p && p->state == S::throwing_copy);
-  }
-
-  {
-    O o = make(S::zero);
-    VERIFY( o );
-    O p = make(S::throwing_move);
-    o = std::move(p);
-    VERIFY( o && o->state == S::throwing_move);
-    VERIFY( p && p->state == S::moved_from);
-  }
-
-  {
-    ATTRIBUTE_UNUSED outcome_type outcome {};
-    O o = make(S::zero);
-    VERIFY( o );
-    O p = make(S::throwing_copy_assignment);
-
-    try
-    {
-      o = p;
-    }
-    catch(exception const&)
-    { outcome = caught; }
-    catch(...)
-    { outcome = bad_catch; }
-
-    VERIFY( o && o->state == S::threw);
-    VERIFY( p && p->state == S::throwing_copy_assignment);
-  }
-
-  {
-    ATTRIBUTE_UNUSED outcome_type outcome {};
-    O o = make(S::zero);
-    VERIFY( o );
-    O p = make(S::throwing_move_assignment);
-
-    try
-    {
-      o = std::move(p);
-    }
-    catch(exception const&)
-    { outcome = caught; }
-    catch(...)
-    { outcome = bad_catch; }
-
-    VERIFY( o && o->state == S::threw);
-    VERIFY( p && p->state == S::moved_from);
-  }
-
-  VERIFY( counter == 0 );
-}
-
-} // namespace assign_2
diff --git a/gdb/unittests/optional/assignment/3.cc b/gdb/unittests/optional/assignment/3.cc
deleted file mode 100644
index a1d0934fe79..00000000000
--- a/gdb/unittests/optional/assignment/3.cc
+++ /dev/null
@@ -1,157 +0,0 @@
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-namespace assign_3 {
-
-struct exception {};
-
-static int counter = 0;
-
-struct mixin_counter
-{
-  mixin_counter() { ++counter; }
-  mixin_counter(mixin_counter const&) { ++counter; }
-  ~mixin_counter() { --counter; }
-};
-
-struct value_type : private mixin_counter
-{
-  enum state_type
-  {
-    zero,
-    moved_from,
-    throwing_construction,
-    throwing_copy,
-    throwing_copy_assignment,
-    throwing_move,
-    throwing_move_assignment,
-    threw,
-  };
-
-  value_type() = default;
-
-  explicit value_type(state_type state_)
-  : state(state_)
-  {
-    throw_if(throwing_construction);
-  }
-
-  value_type(value_type const& other)
-  : state(other.state)
-  {
-    throw_if(throwing_copy);
-  }
-
-  value_type&
-  operator=(value_type const& other)
-  {
-    state = other.state;
-    throw_if(throwing_copy_assignment);
-    return *this;
-  }
-
-  value_type(value_type&& other)
-  : state(other.state)
-  {
-    other.state = moved_from;
-    throw_if(throwing_move);
-  }
-
-  value_type&
-  operator=(value_type&& other)
-  {
-    state = other.state;
-    other.state = moved_from;
-    throw_if(throwing_move_assignment);
-    return *this;
-  }
-
-  void throw_if(state_type match)
-  {
-    if(state == match)
-    {
-      state = threw;
-      throw exception {};
-    }
-  }
-
-  state_type state = zero;
-};
-
-static void
-test ()
-{
-  using O = gdb::optional<value_type>;
-  using S = value_type::state_type;
-  auto const make = [](S s = S::zero) { return value_type { s }; };
-
-  enum outcome_type { nothrow, caught, bad_catch };
-
-  // Check value assignment for disengaged optional
-
-  {
-    O o;
-    value_type v = make(S::throwing_copy_assignment);
-    o = v;
-    VERIFY( o && o->state == S::throwing_copy_assignment );
-  }
-
-  {
-    O o;
-    value_type v = make(S::throwing_move_assignment);
-    o = std::move(v);
-    VERIFY( o && o->state == S::throwing_move_assignment );
-  }
-
-  {
-    ATTRIBUTE_UNUSED outcome_type outcome {};
-    O o;
-    value_type v = make(S::throwing_copy);
-
-    try
-    {
-      o = v;
-    }
-    catch(exception const&)
-    { outcome = caught; }
-    catch(...)
-    { outcome = bad_catch; }
-
-    VERIFY( !o );
-  }
-
-  {
-    ATTRIBUTE_UNUSED outcome_type outcome {};
-    O o;
-    value_type v = make(S::throwing_move);
-
-    try
-    {
-      o = std::move(v);
-    }
-    catch(exception const&)
-    { outcome = caught; }
-    catch(...)
-    { outcome = bad_catch; }
-
-    VERIFY( !o );
-  }
-
-  VERIFY( counter == 0 );
-}
-
-} // namespace assign_3
diff --git a/gdb/unittests/optional/assignment/4.cc b/gdb/unittests/optional/assignment/4.cc
deleted file mode 100644
index 2ad5978a5b4..00000000000
--- a/gdb/unittests/optional/assignment/4.cc
+++ /dev/null
@@ -1,157 +0,0 @@
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-namespace assign_4 {
-
-struct exception {};
-
-static int counter = 0;
-
-struct mixin_counter
-{
-  mixin_counter() { ++counter; }
-  mixin_counter(mixin_counter const&) { ++counter; }
-  ~mixin_counter() { --counter; }
-};
-
-struct value_type : private mixin_counter
-{
-  enum state_type
-  {
-    zero,
-    moved_from,
-    throwing_construction,
-    throwing_copy,
-    throwing_copy_assignment,
-    throwing_move,
-    throwing_move_assignment,
-    threw,
-  };
-
-  value_type() = default;
-
-  explicit value_type(state_type state_)
-  : state(state_)
-  {
-    throw_if(throwing_construction);
-  }
-
-  value_type(value_type const& other)
-  : state(other.state)
-  {
-    throw_if(throwing_copy);
-  }
-
-  value_type&
-  operator=(value_type const& other)
-  {
-    state = other.state;
-    throw_if(throwing_copy_assignment);
-    return *this;
-  }
-
-  value_type(value_type&& other)
-  : state(other.state)
-  {
-    other.state = moved_from;
-    throw_if(throwing_move);
-  }
-
-  value_type&
-  operator=(value_type&& other)
-  {
-    state = other.state;
-    other.state = moved_from;
-    throw_if(throwing_move_assignment);
-    return *this;
-  }
-
-  void throw_if(state_type match)
-  {
-    if(state == match)
-    {
-      state = threw;
-      throw exception {};
-    }
-  }
-
-  state_type state = zero;
-};
-
-static void
-test ()
-{
-  using O = gdb::optional<value_type>;
-  using S = value_type::state_type;
-  auto const make = [](S s = S::zero) { return value_type { s }; };
-
-  enum outcome_type { nothrow, caught, bad_catch };
-
-  // Check value assignment for engaged optional
-
-  {
-    O o = make();
-    value_type v = make(S::throwing_copy);
-    o = v;
-    VERIFY( o && o->state == S::throwing_copy);
-  }
-
-  {
-    O o = make();
-    value_type v = make(S::throwing_move);
-    o = std::move(v);
-    VERIFY( o && o->state == S::throwing_move);
-  }
-
-  {
-    ATTRIBUTE_UNUSED outcome_type outcome {};
-    O o = make();
-    value_type v = make(S::throwing_copy_assignment);
-
-    try
-    {
-      o = v;
-    }
-    catch(exception const&)
-    { outcome = caught; }
-    catch(...)
-    { outcome = bad_catch; }
-
-    VERIFY( o && o->state == S::threw );
-  }
-
-  {
-    ATTRIBUTE_UNUSED outcome_type outcome {};
-    O o = make();
-    value_type v = make(S::throwing_move_assignment);
-
-    try
-    {
-      o = std::move(v);
-    }
-    catch(exception const&)
-    { outcome = caught; }
-    catch(...)
-    { outcome = bad_catch; }
-
-    VERIFY( o && o->state == S::threw );
-  }
-
-  VERIFY( counter == 0 );
-}
-
-} // namespace assign_4
diff --git a/gdb/unittests/optional/assignment/5.cc b/gdb/unittests/optional/assignment/5.cc
deleted file mode 100644
index 85016a27bfa..00000000000
--- a/gdb/unittests/optional/assignment/5.cc
+++ /dev/null
@@ -1,81 +0,0 @@
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-namespace assign_5 {
-
-static int counter = 0;
-
-struct mixin_counter
-{
-  mixin_counter() { ++counter; }
-  mixin_counter(mixin_counter const&) { ++counter; }
-  ~mixin_counter() { --counter; }
-};
-
-struct value_type : private mixin_counter { };
-
-static void
-test ()
-{
-  using O = gdb::optional<value_type>;
-
-  // Check std::nullopt_t and 'default' (= {}) assignment
-
-#ifndef GDB_OPTIONAL
-  {
-    O o;
-    o = std::nullopt;
-    VERIFY( !o );
-  }
-#endif
-
-#ifndef GDB_OPTIONAL
-  {
-    O o { gdb::in_place };
-    o = std::nullopt;
-    VERIFY( !o );
-  }
-#endif
-
-#ifndef GDB_OPTIONAL
-  {
-    O o;
-    o = {};
-    VERIFY( !o );
-  }
-#endif
-
-#ifndef GDB_OPTIONAL
-  {
-    O o { gdb::in_place };
-    o = {};
-    VERIFY( !o );
-  }
-#endif
-  {
-    gdb::optional<std::vector<int>> ovi{{1, 2, 3}};
-    VERIFY(ovi->size() == 3);
-    VERIFY((*ovi)[0] == 1 && (*ovi)[1] == 2 && (*ovi)[2] == 3);
-    ovi = {4, 5, 6, 7};
-    VERIFY(ovi->size() == 4);
-    VERIFY((*ovi)[0] == 4 && (*ovi)[1] == 5 &&
-	   (*ovi)[2] == 6 && (*ovi)[3] == 7);
-  }
-  VERIFY( counter == 0 );
-}
-
-} // namespace assign_5
diff --git a/gdb/unittests/optional/assignment/6.cc b/gdb/unittests/optional/assignment/6.cc
deleted file mode 100644
index d0ea95fa556..00000000000
--- a/gdb/unittests/optional/assignment/6.cc
+++ /dev/null
@@ -1,91 +0,0 @@
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-namespace assign_6 {
-
-static int counter = 0;
-
-struct mixin_counter
-{
-  mixin_counter() { ++counter; }
-  mixin_counter(mixin_counter const&) { ++counter; }
-  ~mixin_counter() { --counter; }
-};
-
-struct value_type : private mixin_counter
-{
-  value_type() = default;
-  value_type(int) : state(1) { }
-  value_type(std::initializer_list<char>, const char*) : state(2) { }
-  int state = 0;
-};
-
-static void
-test ()
-{
-  using O = gdb::optional<value_type>;
-
-  // Check emplace
-
-  {
-    O o;
-    o.emplace();
-    VERIFY( o && o->state == 0 );
-  }
-  {
-    O o { gdb::in_place, 0 };
-    o.emplace();
-    VERIFY( o && o->state == 0 );
-  }
-
-  {
-    O o;
-    o.emplace(0);
-    VERIFY( o && o->state == 1 );
-  }
-  {
-    O o { gdb::in_place };
-    o.emplace(0);
-    VERIFY( o && o->state == 1 );
-  }
-
-#ifndef GDB_OPTIONAL
-  {
-    O o;
-    o.emplace({ 'a' }, "");
-    VERIFY( o && o->state == 2 );
-  }
-  {
-    O o { gdb::in_place };
-    o.emplace({ 'a' }, "");
-    VERIFY( o && o->state == 2 );
-  }
-#endif
-  {
-    O o;
-    VERIFY(&o.emplace(0) == &*o);
-#ifndef GDB_OPTIONAL
-    VERIFY(&o.emplace({ 'a' }, "") == &*o);
-#endif
-  }
-
-  static_assert( !std::is_constructible<O, std::initializer_list<int>, int>(), "" );
-
-  VERIFY( counter == 0 );
-}
-
-} // namespace assign_6
diff --git a/gdb/unittests/optional/assignment/7.cc b/gdb/unittests/optional/assignment/7.cc
deleted file mode 100644
index a9bd181e317..00000000000
--- a/gdb/unittests/optional/assignment/7.cc
+++ /dev/null
@@ -1,30 +0,0 @@
-// Copyright (C) 2016-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-namespace assign_7 {
-
-static void
-test ()
-{
-  gdb::optional<int> o{666};
-  VERIFY(o && *o == 666);
-  o.reset();
-  VERIFY(!o);
-  static_assert(noexcept(std::declval<gdb::optional<int>>().reset()), "");
-}
-
-} // namespace assign_7
diff --git a/gdb/unittests/optional/cons/copy.cc b/gdb/unittests/optional/cons/copy.cc
deleted file mode 100644
index 87a08f9a52b..00000000000
--- a/gdb/unittests/optional/cons/copy.cc
+++ /dev/null
@@ -1,127 +0,0 @@
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-namespace cons_copy {
-
-struct tracker
-{
-  tracker(int value) : value(value) { ++count; }
-  ~tracker() { --count; }
-
-  tracker(tracker const& other) : value(other.value) { ++count; }
-  tracker(tracker&& other) : value(other.value)
-  {
-    other.value = -1;
-    ++count;
-  }
-
-  tracker& operator=(tracker const&) = default;
-  tracker& operator=(tracker&&) = default;
-
-  int value;
-
-  static int count;
-};
-
-int tracker::count = 0;
-
-struct exception { };
-
-struct throwing_copy
-{
-  throwing_copy() = default;
-  throwing_copy(throwing_copy const&) { throw exception {}; }
-};
-
-static void
-test ()
-{
-  // [20.5.4.1] Constructors
-
-  {
-    gdb::optional<long> o;
-    auto copy = o;
-    VERIFY( !copy );
-    VERIFY( !o );
-  }
-
-  {
-    const long val = 0x1234ABCD;
-    gdb::optional<long> o { gdb::in_place, val};
-    auto copy = o;
-    VERIFY( copy );
-    VERIFY( *copy == val );
-#ifndef GDB_OPTIONAL
-    VERIFY( o && o == val );
-#endif
-  }
-
-  {
-    gdb::optional<tracker> o;
-    auto copy = o;
-    VERIFY( !copy );
-    VERIFY( tracker::count == 0 );
-    VERIFY( !o );
-  }
-
-  {
-    gdb::optional<tracker> o { gdb::in_place, 333 };
-    auto copy = o;
-    VERIFY( copy );
-    VERIFY( copy->value == 333 );
-    VERIFY( tracker::count == 2 );
-    VERIFY( o && o->value == 333 );
-  }
-
-  enum outcome { nothrow, caught, bad_catch };
-
-  {
-    outcome result = nothrow;
-    gdb::optional<throwing_copy> o;
-
-    try
-    {
-      auto copy = o;
-    }
-    catch(exception const&)
-    { result = caught; }
-    catch(...)
-    { result = bad_catch; }
-
-    VERIFY( result == nothrow );
-  }
-
-  {
-    outcome result = nothrow;
-    gdb::optional<throwing_copy> o { gdb::in_place };
-
-    try
-    {
-      auto copy = o;
-    }
-    catch(exception const&)
-    { result = caught; }
-    catch(...)
-    { result = bad_catch; }
-
-    VERIFY( result == caught );
-  }
-
-  VERIFY( tracker::count == 0 );
-}
-
-} // namespace cons_copy
diff --git a/gdb/unittests/optional/cons/default.cc b/gdb/unittests/optional/cons/default.cc
deleted file mode 100644
index 6ed99c3b9e5..00000000000
--- a/gdb/unittests/optional/cons/default.cc
+++ /dev/null
@@ -1,59 +0,0 @@
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-namespace cons_default {
-
-struct tracker
-{
-  tracker() { ++count; }
-  ~tracker() { --count; }
-
-  tracker(tracker const&) { ++count; }
-  tracker(tracker&&) { ++count; }
-
-  tracker& operator=(tracker const&) = default;
-  tracker& operator=(tracker&&) = default;
-
-  static int count;
-};
-
-int tracker::count = 0;
-
-static void
-test ()
-{
-  // [20.5.4.1] Constructors
-
-  {
-    gdb::optional<tracker> o;
-    VERIFY( !o );
-  }
-
-  {
-    gdb::optional<tracker> o {};
-    VERIFY( !o );
-  }
-
-  {
-    gdb::optional<tracker> o = {};
-    VERIFY( !o );
-  }
-
-  VERIFY( tracker::count == 0 );
-}
-
-} // namespace cons_default
diff --git a/gdb/unittests/optional/cons/move.cc b/gdb/unittests/optional/cons/move.cc
deleted file mode 100644
index 398784ae7ec..00000000000
--- a/gdb/unittests/optional/cons/move.cc
+++ /dev/null
@@ -1,125 +0,0 @@
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-namespace cons_move {
-
-struct tracker
-{
-  tracker(int value) : value(value) { ++count; }
-  ~tracker() { --count; }
-
-  tracker(tracker const& other) : value(other.value) { ++count; }
-  tracker(tracker&& other) : value(other.value)
-  {
-    other.value = -1;
-    ++count;
-  }
-
-  tracker& operator=(tracker const&) = default;
-  tracker& operator=(tracker&&) = default;
-
-  int value;
-
-  static int count;
-};
-
-int tracker::count = 0;
-
-struct exception { };
-
-struct throwing_move
-{
-  throwing_move() = default;
-  throwing_move(throwing_move const&) { throw exception {}; }
-};
-
-static void
-test ()
-{
-  // [20.5.4.1] Constructors
-
-  {
-    gdb::optional<long> o;
-    auto moved_to = std::move(o);
-    VERIFY( !moved_to );
-    VERIFY( !o );
-  }
-
-  {
-    const long val = 0x1234ABCD;
-    gdb::optional<long> o { gdb::in_place, val};
-    auto moved_to = std::move(o);
-    VERIFY( moved_to );
-    VERIFY( *moved_to == val );
-    VERIFY( o && *o == val );
-  }
-
-  {
-    gdb::optional<tracker> o;
-    auto moved_to = std::move(o);
-    VERIFY( !moved_to );
-    VERIFY( tracker::count == 0 );
-    VERIFY( !o );
-  }
-
-  {
-    gdb::optional<tracker> o { gdb::in_place, 333 };
-    auto moved_to = std::move(o);
-    VERIFY( moved_to );
-    VERIFY( moved_to->value == 333 );
-    VERIFY( tracker::count == 2 );
-    VERIFY( o && o->value == -1 );
-  }
-
-  enum outcome { nothrow, caught, bad_catch };
-
-  {
-    outcome result = nothrow;
-    gdb::optional<throwing_move> o;
-
-    try
-    {
-      auto moved_to = std::move(o);
-    }
-    catch(exception const&)
-    { result = caught; }
-    catch(...)
-    { result = bad_catch; }
-
-    VERIFY( result == nothrow );
-  }
-
-  {
-    outcome result = nothrow;
-    gdb::optional<throwing_move> o { gdb::in_place };
-
-    try
-    {
-      auto moved_to = std::move(o);
-    }
-    catch(exception const&)
-    { result = caught; }
-    catch(...)
-    { result = bad_catch; }
-
-    VERIFY( result == caught );
-  }
-
-  VERIFY( tracker::count == 0 );
-}
-
-} // namespace cons_move
diff --git a/gdb/unittests/optional/cons/value.cc b/gdb/unittests/optional/cons/value.cc
deleted file mode 100644
index 7d4fd91cfe6..00000000000
--- a/gdb/unittests/optional/cons/value.cc
+++ /dev/null
@@ -1,295 +0,0 @@
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-namespace cons_value {
-
-struct tracker
-{
-  tracker(int value) : value(value) { ++count; }
-  ~tracker() { --count; }
-
-  tracker(tracker const& other) : value(other.value) { ++count; }
-  tracker(tracker&& other) : value(other.value)
-  {
-    other.value = -1;
-    ++count;
-  }
-
-  tracker& operator=(tracker const&) = default;
-  tracker& operator=(tracker&&) = default;
-
-  int value;
-
-  static int count;
-};
-
-int tracker::count = 0;
-
-struct exception { };
-
-struct throwing_construction
-{
-  explicit throwing_construction(bool propagate) : propagate(propagate) { }
-
-  throwing_construction(throwing_construction const& other)
-  : propagate(other.propagate)
-  {
-    if(propagate)
-      throw exception {};
-  }
-
-  bool propagate;
-};
-
-static void
-test ()
-{
-  // [20.5.4.1] Constructors
-
-  {
-    auto i = 0x1234ABCD;
-    gdb::optional<long> o { i };
-    VERIFY( o );
-    VERIFY( *o == 0x1234ABCD );
-    VERIFY( i == 0x1234ABCD );
-  }
-
-  {
-    auto i = 0x1234ABCD;
-    gdb::optional<long> o = i;
-    VERIFY( o );
-    VERIFY( *o == 0x1234ABCD );
-    VERIFY( i == 0x1234ABCD );
-  }
-
-  {
-    auto i = 0x1234ABCD;
-    gdb::optional<long> o = { i };
-    VERIFY( o );
-    VERIFY( *o == 0x1234ABCD );
-    VERIFY( i == 0x1234ABCD );
-  }
-
-  {
-    auto i = 0x1234ABCD;
-    gdb::optional<long> o { std::move(i) };
-    VERIFY( o );
-    VERIFY( *o == 0x1234ABCD );
-    VERIFY( i == 0x1234ABCD );
-  }
-
-  {
-    auto i = 0x1234ABCD;
-    gdb::optional<long> o = std::move(i);
-    VERIFY( o );
-    VERIFY( *o == 0x1234ABCD );
-    VERIFY( i == 0x1234ABCD );
-  }
-
-  {
-    auto i = 0x1234ABCD;
-    gdb::optional<long> o = { std::move(i) };
-    VERIFY( o );
-    VERIFY( *o == 0x1234ABCD );
-    VERIFY( i == 0x1234ABCD );
-  }
-
-#ifndef GDB_OPTIONAL
-  {
-    std::vector<int> v = { 0, 1, 2, 3, 4, 5 };
-    gdb::optional<std::vector<int>> o { v };
-    VERIFY( !v.empty() );
-    VERIFY( o->size() == 6 );
-  }
-#endif
-
-  {
-    std::vector<int> v = { 0, 1, 2, 3, 4, 5 };
-    gdb::optional<std::vector<int>> o = v;
-    VERIFY( !v.empty() );
-    VERIFY( o->size() == 6 );
-  }
-
-  {
-    std::vector<int> v = { 0, 1, 2, 3, 4, 5 };
-    gdb::optional<std::vector<int>> o { v };
-    VERIFY( !v.empty() );
-    VERIFY( o->size() == 6 );
-  }
-
-  {
-    std::vector<int> v = { 0, 1, 2, 3, 4, 5 };
-    gdb::optional<std::vector<int>> o { std::move(v) };
-    VERIFY( v.empty() );
-    VERIFY( o->size() == 6 );
-  }
-
-  {
-    std::vector<int> v = { 0, 1, 2, 3, 4, 5 };
-    gdb::optional<std::vector<int>> o = std::move(v);
-    VERIFY( v.empty() );
-    VERIFY( o->size() == 6 );
-  }
-
-  {
-    std::vector<int> v = { 0, 1, 2, 3, 4, 5 };
-    gdb::optional<std::vector<int>> o { std::move(v) };
-    VERIFY( v.empty() );
-    VERIFY( o->size() == 6 );
-  }
-
-  {
-    tracker t { 333 };
-    gdb::optional<tracker> o = t;
-    VERIFY( o->value == 333 );
-    VERIFY( tracker::count == 2 );
-    VERIFY( t.value == 333 );
-  }
-
-  {
-    tracker t { 333 };
-    gdb::optional<tracker> o = std::move(t);
-    VERIFY( o->value == 333 );
-    VERIFY( tracker::count == 2 );
-    VERIFY( t.value == -1 );
-  }
-
-  enum outcome { nothrow, caught, bad_catch };
-
-  {
-    outcome result = nothrow;
-    throwing_construction t { false };
-
-    try
-    {
-      gdb::optional<throwing_construction> o { t };
-    }
-    catch(exception const&)
-    { result = caught; }
-    catch(...)
-    { result = bad_catch; }
-
-    VERIFY( result == nothrow );
-  }
-
-  {
-    outcome result = nothrow;
-    throwing_construction t { true };
-
-    try
-    {
-      gdb::optional<throwing_construction> o { t };
-    }
-    catch(exception const&)
-    { result = caught; }
-    catch(...)
-    { result = bad_catch; }
-
-    VERIFY( result == caught );
-  }
-
-  {
-    outcome result = nothrow;
-    throwing_construction t { false };
-
-    try
-    {
-      gdb::optional<throwing_construction> o { std::move(t) };
-    }
-    catch(exception const&)
-    { result = caught; }
-    catch(...)
-    { result = bad_catch; }
-
-    VERIFY( result == nothrow );
-  }
-
-  {
-    outcome result = nothrow;
-    throwing_construction t { true };
-
-    try
-    {
-      gdb::optional<throwing_construction> o { std::move(t) };
-    }
-    catch(exception const&)
-    { result = caught; }
-    catch(...)
-    { result = bad_catch; }
-
-    VERIFY( result == caught );
-  }
-
-  {
-#ifndef GDB_OPTIONAL
-    gdb::optional<std::string> os = "foo";
-#endif
-    struct X
-    {
-      explicit X(int) {}
-      X& operator=(int) {return *this;}
-    };
-#ifndef GDB_OPTIONAL
-    gdb::optional<X> ox{42};
-#endif
-    gdb::optional<int> oi{42};
-#ifndef GDB_OPTIONAL
-    gdb::optional<X> ox2{oi};
-#endif
-    gdb::optional<std::string> os2;
-    os2 = "foo";
-#ifndef GDB_OPTIONAL
-    gdb::optional<X> ox3;
-    ox3 = 42;
-    gdb::optional<X> ox4;
-    ox4 = oi;
-#endif
-  }
-  {
-    // no converting construction.
-#ifndef GDB_OPTIONAL
-    gdb::optional<int> oi = gdb::optional<short>();
-    VERIFY(!bool(oi));
-    gdb::optional<std::string> os = gdb::optional<const char*>();
-    VERIFY(!bool(os));
-#endif
-    gdb::optional<gdb::optional<int>> ooi = gdb::optional<int>();
-    VERIFY(bool(ooi));
-    ooi = gdb::optional<int>();
-    VERIFY(bool(ooi));
-    ooi = gdb::optional<int>(42);
-    VERIFY(bool(ooi));
-    VERIFY(bool(*ooi));
-#ifndef GDB_OPTIONAL
-    gdb::optional<gdb::optional<int>> ooi2 = gdb::optional<short>();
-    VERIFY(bool(ooi2));
-    ooi2 = gdb::optional<short>();
-    VERIFY(bool(ooi2));
-    ooi2 = gdb::optional<short>(6);
-    VERIFY(bool(ooi2));
-    VERIFY(bool(*ooi2));
-    gdb::optional<gdb::optional<int>> ooi3 = gdb::optional<int>(42);
-    VERIFY(bool(ooi3));
-    VERIFY(bool(*ooi3));
-    gdb::optional<gdb::optional<int>> ooi4 = gdb::optional<short>(6);
-    VERIFY(bool(ooi4));
-    VERIFY(bool(*ooi4));
-#endif
-  }
-}
-
-} // namespace cons_value
diff --git a/gdb/unittests/optional/in_place.cc b/gdb/unittests/optional/in_place.cc
deleted file mode 100644
index 067f975a0d3..00000000000
--- a/gdb/unittests/optional/in_place.cc
+++ /dev/null
@@ -1,66 +0,0 @@
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-namespace in_place {
-
-static void
-test ()
-{
-  // [20.5.5] In-place construction
-  {
-    gdb::optional<int> o { gdb::in_place };
-    VERIFY( o );
-    VERIFY( *o == int() );
-
-#ifndef GDB_OPTIONAL
-    static_assert( !std::is_convertible<gdb::in_place_t, gdb::optional<int>>(), "" );
-#endif
-  }
-
-  {
-    gdb::optional<int> o { gdb::in_place, 42 };
-    VERIFY( o );
-    VERIFY( *o == 42 );
-  }
-
-  {
-    gdb::optional<std::vector<int>> o { gdb::in_place, 18, 4 };
-    VERIFY( o );
-    VERIFY( o->size() == 18 );
-    VERIFY( (*o)[17] == 4 );
-  }
-
-#ifndef GDB_OPTIONAL
-  {
-    gdb::optional<std::vector<int>> o { gdb::in_place, { 18, 4 } };
-    VERIFY( o );
-    VERIFY( o->size() == 2 );
-    VERIFY( (*o)[0] == 18 );
-  }
-#endif
-
-#ifndef GDB_OPTIONAL
-  {
-    gdb::optional<std::vector<int>> o { gdb::in_place, { 18, 4 }, std::allocator<int> {} };
-    VERIFY( o );
-    VERIFY( o->size() == 2 );
-    VERIFY( (*o)[0] == 18 );
-  }
-#endif
-}
-
-} // namespace in_place
diff --git a/gdb/unittests/optional/observers/1.cc b/gdb/unittests/optional/observers/1.cc
deleted file mode 100644
index 20f4176adf1..00000000000
--- a/gdb/unittests/optional/observers/1.cc
+++ /dev/null
@@ -1,32 +0,0 @@
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-namespace observers_1 {
-
-struct value_type
-{
-  int i;
-};
-
-static void
-test ()
-{
-  gdb::optional<value_type> o { value_type { 51 } };
-  VERIFY( (*o).i == 51 );
-}
-
-} // namespace observers_1
diff --git a/gdb/unittests/optional/observers/2.cc b/gdb/unittests/optional/observers/2.cc
deleted file mode 100644
index 0ad09ab5011..00000000000
--- a/gdb/unittests/optional/observers/2.cc
+++ /dev/null
@@ -1,36 +0,0 @@
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-namespace observers_2 {
-
-struct value_type
-{
-  int i;
-};
-
-void* operator&(const value_type&) = delete;
-
-static void
-test ()
-{
-  gdb::optional<value_type> o { value_type { 51 } };
-  VERIFY( o->i == 51 );
-  VERIFY( o->i == (*o).i );
-  VERIFY( &o->i == &(*o).i );
-}
-
-} // namespace observers_2
diff --git a/gdbsupport/gdb_optional.h b/gdbsupport/gdb_optional.h
deleted file mode 100644
index 9b7b7b2f7f4..00000000000
--- a/gdbsupport/gdb_optional.h
+++ /dev/null
@@ -1,233 +0,0 @@
-/* An optional object.
-
-   Copyright (C) 2017-2023 Free Software Foundation, Inc.
-
-   This file is part of GDB.
-
-   This program 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 of the License, or
-   (at your option) any later version.
-
-   This program 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.
-
-   You should have received a copy of the GNU General Public License
-   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
-
-#ifndef COMMON_GDB_OPTIONAL_H
-#define COMMON_GDB_OPTIONAL_H
-
-#include "gdbsupport/traits.h"
-
-namespace gdb
-{
-
-struct in_place_t
-{
-  explicit in_place_t () = default;
-};
-
-constexpr gdb::in_place_t in_place {};
-
-/* This class attempts to be a compatible subset of std::optional,
-   which is slated to be available in C++17.  This class optionally
-   holds an object of some type -- by default it is constructed not
-   holding an object, but later the object can be "emplaced".  This is
-   similar to using std::unique_ptr, but in-object allocation is
-   guaranteed.
-
-   Unlike std::optional, we currently only support copy/move
-   construction/assignment of an optional<T> from either exactly
-   optional<T> or T.  I.e., we don't support copy/move
-   construction/assignment from optional<U> or U, when U is a type
-   convertible to T.  Making that work depending on the definitions of
-   T and U is somewhat complicated, and currently the users of this
-   class don't need it.  */
-
-template<typename T>
-class optional
-{
-public:
-
-  constexpr optional ()
-    : m_dummy ()
-  {}
-
-  template<typename... Args>
-  constexpr optional (in_place_t, Args &&... args)
-    : m_item (std::forward<Args> (args)...),
-      m_instantiated (true)
-  {}
-
-  ~optional ()
-  { this->reset (); }
-
-  /* Copy and move constructors.  */
-
-  optional (const optional &other)
-  {
-    if (other.m_instantiated)
-      this->emplace (other.get ());
-  }
-
-  optional (optional &&other)
-    noexcept(std::is_nothrow_move_constructible<T> ())
-  {
-    if (other.m_instantiated)
-      this->emplace (std::move (other.get ()));
-  }
-
-  constexpr optional (const T &other)
-    : m_item (other),
-      m_instantiated (true)
-  {}
-
-  constexpr optional (T &&other)
-    noexcept (std::is_nothrow_move_constructible<T> ())
-    : m_item (std::move (other)),
-      m_instantiated (true)
-  {}
-
-  /* Assignment operators.  */
-
-  optional &
-  operator= (const optional &other)
-  {
-    if (m_instantiated && other.m_instantiated)
-      this->get () = other.get ();
-    else
-      {
-	if (other.m_instantiated)
-	  this->emplace (other.get ());
-	else
-	  this->reset ();
-      }
-
-    return *this;
-  }
-
-  optional &
-  operator= (optional &&other)
-    noexcept (And<std::is_nothrow_move_constructible<T>,
-	      std::is_nothrow_move_assignable<T>> ())
-  {
-    if (m_instantiated && other.m_instantiated)
-      this->get () = std::move (other.get ());
-    else
-      {
-	if (other.m_instantiated)
-	  this->emplace (std::move (other.get ()));
-	else
-	  this->reset ();
-      }
-    return *this;
-  }
-
-  optional &
-  operator= (const T &other)
-  {
-    if (m_instantiated)
-      this->get () = other;
-    else
-      this->emplace (other);
-    return *this;
-  }
-
-  optional &
-  operator= (T &&other)
-    noexcept (And<std::is_nothrow_move_constructible<T>,
-	      std::is_nothrow_move_assignable<T>> ())
-  {
-    if (m_instantiated)
-      this->get () = std::move (other);
-    else
-      this->emplace (std::move (other));
-    return *this;
-  }
-
-  template<typename... Args>
-  T &emplace (Args &&... args)
-  {
-    this->reset ();
-    new (&m_item) T (std::forward<Args>(args)...);
-    m_instantiated = true;
-    return this->get ();
-  }
-
-  /* Observers.  */
-  constexpr const T *operator-> () const
-  { return std::addressof (this->get ()); }
-
-  T *operator-> ()
-  { return std::addressof (this->get ()); }
-
-  constexpr const T &operator* () const &
-  { return this->get (); }
-
-  T &operator* () &
-  { return this->get (); }
-
-  T &&operator* () &&
-  { return std::move (this->get ()); }
-
-  constexpr const T &&operator* () const &&
-  { return std::move (this->get ()); }
-
-  constexpr explicit operator bool () const noexcept
-  { return m_instantiated; }
-
-  constexpr bool has_value () const noexcept
-  { return m_instantiated; }
-
-  /* 'reset' is a 'safe' operation with no precondition.  */
-  void reset () noexcept
-  {
-    if (m_instantiated)
-      this->destroy ();
-  }
-
-private:
-
-  /* Destroy the object.  */
-  void destroy ()
-  {
-    gdb_assert (m_instantiated);
-    m_instantiated = false;
-    m_item.~T ();
-  }
-
-  /* The get operations have m_instantiated as a precondition.  */
-  T &get () noexcept
-  {
-#if defined(_GLIBCXX_DEBUG) && __cplusplus >= 201402L
-    gdb_assert (this->has_value ());
-#endif
-    return m_item;
-  }
-  constexpr const T &get () const noexcept
-  {
-#if defined(_GLIBCXX_DEBUG) && __cplusplus >= 201402L
-    gdb_assert (this->has_value ());
-#endif
-    return m_item;
-  }
-
-  /* The object.  */
-  union
-  {
-    struct { } m_dummy;
-    T m_item;
-    volatile char dont_use; /* Silences -Wmaybe-uninitialized warning, see
-			       PR gcc/80635.  */
-  };
-
-  /* True if the object was ever emplaced.  */
-  bool m_instantiated = false;
-};
-
-}
-
-#endif /* COMMON_GDB_OPTIONAL_H */
-- 
2.34.1


^ permalink raw reply	[flat|nested] 39+ messages in thread

* [COMMITTED PATCH v2 4/9] gdb: Use std::string_view instead of gdb::string_view
  2023-10-28 20:48       ` Lancelot SIX
                           ` (3 preceding siblings ...)
  2023-11-21 12:04         ` [COMMITTED PATCH v2 3/9] gdbsupport: remove gdb::optional Lancelot Six
@ 2023-11-21 12:04         ` Lancelot Six
  2023-11-21 12:04         ` [COMMITTED PATCH v2 5/9] gdb: Remove uses of gdb::to_string (const std::string_view &) Lancelot Six
                           ` (4 subsequent siblings)
  9 siblings, 0 replies; 39+ messages in thread
From: Lancelot Six @ 2023-11-21 12:04 UTC (permalink / raw)
  To: gdb-patches; +Cc: pedro, tom, Lancelot Six

Given that GDB now requires a C++17, replace all uses of
gdb::string_view with std::string_view.

This change has mostly been done automatically:
- gdb::string_view -> std::string_view
- #include "gdbsupport/gdb_string_view.h" -> #include <string_view>

One things which got brought up during review is that gdb::stging_view
does support being built from "nullptr" while std::sting_view does not.
Two places are manually adjusted to account for this difference:
gdb/tui/tui-io.c:tui_getc_1 and
gdbsupport/format.h:format_piece::format_piece.

The above automatic change transformed
"gdb::to_string (const gdb::string_view &)" into
"gdb::to_string (const std::string_view &)".  The various direct users
of this function are now explicitly including
"gdbsupport/gdb_string_view.h".  A later patch will remove the users of
gdb::to_string.

The implementation and tests of gdb::string_view are unchanged, they will
be removed in a following patch.

Change-Id: Ibb806a7e9c79eb16a55c87c6e41ad396fecf0207
Approved-By: Tom Tromey <tom@tromey.com>
Approved-By: Pedro Alves <pedro@palves.net>
---
 gdb/ada-lang.c               |  9 ++++---
 gdb/amdgpu-tdep.c            | 51 ++++++++++++++++++------------------
 gdb/cli/cli-script.c         |  4 +--
 gdb/dbxread.c                | 18 ++++++-------
 gdb/debuginfod-support.c     |  7 ++---
 gdb/dwarf2/cooked-index.c    |  6 ++---
 gdb/dwarf2/cooked-index.h    |  2 +-
 gdb/dwarf2/index-common.c    |  2 +-
 gdb/dwarf2/index-common.h    |  2 +-
 gdb/dwarf2/read.c            |  3 ++-
 gdb/elfread.c                |  8 +++---
 gdb/eval.c                   |  1 +
 gdb/language.c               |  2 +-
 gdb/linux-tdep.c             |  8 +++---
 gdb/mdebugread.c             | 18 ++++++-------
 gdb/minsyms.c                |  4 +--
 gdb/minsyms.h                |  2 +-
 gdb/psymtab.c                |  2 +-
 gdb/psymtab.h                |  4 +--
 gdb/solib-rocm.c             | 21 ++++++++-------
 gdb/split-name.c             |  4 +--
 gdb/split-name.h             |  4 +--
 gdb/stabsread.c              |  2 +-
 gdb/symtab.c                 | 14 +++++-----
 gdb/symtab.h                 | 14 +++++-----
 gdb/tui/tui-io.c             |  5 +++-
 gdb/tui/tui-win.c            |  6 ++---
 gdb/xcoffread.c              | 18 ++++++-------
 gdbsupport/common-utils.h    |  8 +++---
 gdbsupport/format.h          |  5 ++--
 gdbsupport/gdb_string_view.h |  2 +-
 31 files changed, 133 insertions(+), 123 deletions(-)

diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 58c70160d31..843583ecb40 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -58,6 +58,7 @@
 #include "gdbsupport/function-view.h"
 #include "gdbsupport/byte-vector.h"
 #include "gdbsupport/selftest.h"
+#include "gdbsupport/gdb_string_view.h"
 #include <algorithm>
 #include "ada-exp.h"
 #include "charset.h"
@@ -1035,7 +1036,7 @@ find_case_fold_entry (uint32_t c)
    rather than emitting a warning.  Result good to next call.  */
 
 static const char *
-ada_fold_name (gdb::string_view name, bool throw_on_error = false)
+ada_fold_name (std::string_view name, bool throw_on_error = false)
 {
   static std::string fold_storage;
 
@@ -13250,7 +13251,7 @@ do_exact_match (const char *symbol_search_name,
 
 ada_lookup_name_info::ada_lookup_name_info (const lookup_name_info &lookup_name)
 {
-  gdb::string_view user_name = lookup_name.name ();
+  std::string_view user_name = lookup_name.name ();
 
   if (!user_name.empty () && user_name[0] == '<')
     {
@@ -13269,7 +13270,7 @@ ada_lookup_name_info::ada_lookup_name_info (const lookup_name_info &lookup_name)
     {
       m_verbatim_p = false;
 
-      m_encoded_p = user_name.find ("__") != gdb::string_view::npos;
+      m_encoded_p = user_name.find ("__") != std::string_view::npos;
 
       if (!m_encoded_p)
 	{
@@ -13326,7 +13327,7 @@ literal_symbol_name_matcher (const char *symbol_search_name,
 			     const lookup_name_info &lookup_name,
 			     completion_match_result *comp_match_res)
 {
-  gdb::string_view name_view = lookup_name.name ();
+  std::string_view name_view = lookup_name.name ();
 
   if (lookup_name.completion_mode ()
       ? (strncmp (symbol_search_name, name_view.data (),
diff --git a/gdb/amdgpu-tdep.c b/gdb/amdgpu-tdep.c
index 3a521a43977..58d26fc0b6b 100644
--- a/gdb/amdgpu-tdep.c
+++ b/gdb/amdgpu-tdep.c
@@ -27,6 +27,7 @@
 #include "frame-unwind.h"
 #include "gdbarch.h"
 #include "gdbsupport/selftest.h"
+#include "gdbsupport/gdb_string_view.h"
 #include "gdbtypes.h"
 #include "inferior.h"
 #include "objfiles.h"
@@ -237,7 +238,7 @@ struct amd_dbgapi_register_type_flags : public amd_dbgapi_register_type
   using container_type = std::vector<field>;
   using const_iterator_type = container_type::const_iterator;
 
-  amd_dbgapi_register_type_flags (unsigned int bit_size, gdb::string_view name)
+  amd_dbgapi_register_type_flags (unsigned int bit_size, std::string_view name)
     : amd_dbgapi_register_type (kind::FLAGS,
 				make_lookup_name (bit_size, name)),
       m_bit_size (bit_size),
@@ -270,7 +271,7 @@ struct amd_dbgapi_register_type_flags : public amd_dbgapi_register_type
   const std::string &name () const
   { return m_name; }
 
-  static std::string make_lookup_name (int bits, gdb::string_view name)
+  static std::string make_lookup_name (int bits, std::string_view name)
   {
     std::string res = string_printf ("flags%d_t ", bits);
     res.append (name.data (), name.size ());
@@ -297,7 +298,7 @@ struct amd_dbgapi_register_type_enum : public amd_dbgapi_register_type
   using container_type = std::vector<enumerator>;
   using const_iterator_type = container_type::const_iterator;
 
-  amd_dbgapi_register_type_enum (gdb::string_view name)
+  amd_dbgapi_register_type_enum (std::string_view name)
     : amd_dbgapi_register_type (kind::ENUM, make_lookup_name (name)),
       m_name (name.data (), name.length ())
   {}
@@ -326,7 +327,7 @@ struct amd_dbgapi_register_type_enum : public amd_dbgapi_register_type
   const std::string &name () const
   { return m_name; }
 
-  static std::string make_lookup_name (gdb::string_view name)
+  static std::string make_lookup_name (std::string_view name)
   {
     std::string res = "enum ";
     res.append (name.data (), name.length ());
@@ -349,7 +350,7 @@ using amd_dbgapi_register_type_map
 /* Parse S as a ULONGEST, raise an error on overflow.  */
 
 static ULONGEST
-try_strtoulst (gdb::string_view s)
+try_strtoulst (std::string_view s)
 {
   errno = 0;
   ULONGEST value = strtoulst (s.data (), nullptr, 0);
@@ -365,7 +366,7 @@ try_strtoulst (gdb::string_view s)
 #define WSOPT "[ \t]*"
 
 static const amd_dbgapi_register_type &
-parse_amd_dbgapi_register_type (gdb::string_view type_name,
+parse_amd_dbgapi_register_type (std::string_view type_name,
 				amd_dbgapi_register_type_map &type_map);
 
 
@@ -373,7 +374,7 @@ parse_amd_dbgapi_register_type (gdb::string_view type_name,
 
 static void
 parse_amd_dbgapi_register_type_enum_fields
-  (amd_dbgapi_register_type_enum &enum_type, gdb::string_view fields)
+  (amd_dbgapi_register_type_enum &enum_type, std::string_view fields)
 {
   compiled_regex regex (/* name */
 			"^(" IDENTIFIER ")"
@@ -394,8 +395,8 @@ parse_amd_dbgapi_register_type_enum_fields
       auto sv_from_match = [fields] (const regmatch_t &m)
 	{ return fields.substr (m.rm_so, m.rm_eo - m.rm_so); };
 
-      gdb::string_view name = sv_from_match (matches[1]);
-      gdb::string_view value_str = sv_from_match (matches[2]);
+      std::string_view name = sv_from_match (matches[1]);
+      std::string_view value_str = sv_from_match (matches[2]);
       ULONGEST value = try_strtoulst (value_str);
 
       if (value > std::numeric_limits<uint32_t>::max ())
@@ -412,7 +413,7 @@ parse_amd_dbgapi_register_type_enum_fields
 static void
 parse_amd_dbgapi_register_type_flags_fields
   (amd_dbgapi_register_type_flags &flags_type,
-   int bits, gdb::string_view name, gdb::string_view fields,
+   int bits, std::string_view name, std::string_view fields,
    amd_dbgapi_register_type_map &type_map)
 {
   gdb_assert (bits == 32 || bits == 64);
@@ -439,9 +440,9 @@ parse_amd_dbgapi_register_type_flags_fields
       auto sv_from_match = [fields] (const regmatch_t &m)
 	{ return fields.substr (m.rm_so, m.rm_eo - m.rm_so); };
 
-      gdb::string_view field_type_str = sv_from_match (matches[1]);
-      gdb::string_view field_name = sv_from_match (matches[3]);
-      gdb::string_view pos_begin_str = sv_from_match (matches[4]);
+      std::string_view field_type_str = sv_from_match (matches[1]);
+      std::string_view field_name = sv_from_match (matches[3]);
+      std::string_view pos_begin_str = sv_from_match (matches[4]);
       ULONGEST pos_begin = try_strtoulst (pos_begin_str);
 
       if (field_type_str == "bool")
@@ -452,7 +453,7 @@ parse_amd_dbgapi_register_type_flags_fields
 	  if (matches[5].rm_so == -1)
 	    error (_("Missing end bit position"));
 
-	  gdb::string_view pos_end_str = sv_from_match (matches[5]);
+	  std::string_view pos_end_str = sv_from_match (matches[5]);
 	  ULONGEST pos_end = try_strtoulst (pos_end_str.substr (1));
 	  const amd_dbgapi_register_type &field_type
 	    = parse_amd_dbgapi_register_type (field_type_str, type_map);
@@ -467,7 +468,7 @@ parse_amd_dbgapi_register_type_flags_fields
 /* parse_amd_dbgapi_register_type helper for scalars.  */
 
 static const amd_dbgapi_register_type &
-parse_amd_dbgapi_register_type_scalar (gdb::string_view name,
+parse_amd_dbgapi_register_type_scalar (std::string_view name,
 				       amd_dbgapi_register_type_map &type_map)
 {
   std::string name_str = gdb::to_string (name);
@@ -513,24 +514,24 @@ parse_amd_dbgapi_register_type_scalar (gdb::string_view name,
    details about the format.  */
 
 static const amd_dbgapi_register_type &
-parse_amd_dbgapi_register_type (gdb::string_view type_str,
+parse_amd_dbgapi_register_type (std::string_view type_str,
 				amd_dbgapi_register_type_map &type_map)
 {
   size_t pos_open_bracket = type_str.find_last_of ('[');
   auto sv_from_match = [type_str] (const regmatch_t &m)
     { return type_str.substr (m.rm_so, m.rm_eo - m.rm_so); };
 
-  if (pos_open_bracket != gdb::string_view::npos)
+  if (pos_open_bracket != std::string_view::npos)
     {
       /* Vector types.  */
-      gdb::string_view element_type_str
+      std::string_view element_type_str
 	= type_str.substr (0, pos_open_bracket);
       const amd_dbgapi_register_type &element_type
 	= parse_amd_dbgapi_register_type (element_type_str, type_map);
 
       size_t pos_close_bracket = type_str.find_last_of (']');
-      gdb_assert (pos_close_bracket != gdb::string_view::npos);
-      gdb::string_view count_str_view
+      gdb_assert (pos_close_bracket != std::string_view::npos);
+      std::string_view count_str_view
 	= type_str.substr (pos_open_bracket + 1,
 			    pos_close_bracket - pos_open_bracket);
       std::string count_str = gdb::to_string (count_str_view);
@@ -567,9 +568,9 @@ parse_amd_dbgapi_register_type (gdb::string_view type_str,
       if (res == REG_NOMATCH)
 	error (_("Failed to parse flags type string"));
 
-      gdb::string_view flags_keyword = sv_from_match (matches[1]);
+      std::string_view flags_keyword = sv_from_match (matches[1]);
       unsigned int bit_size = flags_keyword == "flags32_t" ? 32 : 64;
-      gdb::string_view name = sv_from_match (matches[2]);
+      std::string_view name = sv_from_match (matches[2]);
       std::string lookup_name
 	= amd_dbgapi_register_type_flags::make_lookup_name (bit_size, name);
       auto existing_type_it = type_map.find (lookup_name);
@@ -596,7 +597,7 @@ parse_amd_dbgapi_register_type (gdb::string_view type_str,
 
 	  amd_dbgapi_register_type_flags_up flags_type
 	    (new amd_dbgapi_register_type_flags (bit_size, name));
-	  gdb::string_view fields_without_braces = sv_from_match (matches[4]);
+	  std::string_view fields_without_braces = sv_from_match (matches[4]);
 
 	  parse_amd_dbgapi_register_type_flags_fields
 	    (*flags_type, bit_size, name, fields_without_braces, type_map);
@@ -620,7 +621,7 @@ parse_amd_dbgapi_register_type (gdb::string_view type_str,
       if (res == REG_NOMATCH)
 	error (_("Failed to parse flags type string"));
 
-      gdb::string_view name = sv_from_match (matches[1]);
+      std::string_view name = sv_from_match (matches[1]);
 
       std::string lookup_name
 	= amd_dbgapi_register_type_enum::make_lookup_name (name);
@@ -648,7 +649,7 @@ parse_amd_dbgapi_register_type (gdb::string_view type_str,
 
 	  amd_dbgapi_register_type_enum_up enum_type
 	    (new amd_dbgapi_register_type_enum (name));
-	  gdb::string_view fields_without_braces = sv_from_match (matches[3]);
+	  std::string_view fields_without_braces = sv_from_match (matches[3]);
 
 	  parse_amd_dbgapi_register_type_enum_fields
 	    (*enum_type, fields_without_braces);
diff --git a/gdb/cli/cli-script.c b/gdb/cli/cli-script.c
index 8ec5689ebcf..b355a6dc81e 100644
--- a/gdb/cli/cli-script.c
+++ b/gdb/cli/cli-script.c
@@ -35,7 +35,7 @@
 #include "extension.h"
 #include "interps.h"
 #include "compile/compile.h"
-#include "gdbsupport/gdb_string_view.h"
+#include <string_view>
 #include "python/python.h"
 #include "guile/guile.h"
 
@@ -103,7 +103,7 @@ class user_args
   std::string m_command_line;
 
   /* The arguments.  Each element points inside M_COMMAND_LINE.  */
-  std::vector<gdb::string_view> m_args;
+  std::vector<std::string_view> m_args;
 };
 
 /* The stack of arguments passed to user defined functions.  We need a
diff --git a/gdb/dbxread.c b/gdb/dbxread.c
index 3afafa77fb4..b92193bdadd 100644
--- a/gdb/dbxread.c
+++ b/gdb/dbxread.c
@@ -1483,7 +1483,7 @@ read_dbx_symtab (minimal_symbol_reader &reader,
 	    {
 	    case 'S':
 	      if (pst != nullptr)
-		pst->add_psymbol (gdb::string_view (sym_name, sym_len), true,
+		pst->add_psymbol (std::string_view (sym_name, sym_len), true,
 				  VAR_DOMAIN, LOC_STATIC,
 				  data_sect_index,
 				  psymbol_placement::STATIC,
@@ -1500,7 +1500,7 @@ read_dbx_symtab (minimal_symbol_reader &reader,
 	      /* The addresses in these entries are reported to be
 		 wrong.  See the code that reads 'G's for symtabs.  */
 	      if (pst != nullptr)
-		pst->add_psymbol (gdb::string_view (sym_name, sym_len), true,
+		pst->add_psymbol (std::string_view (sym_name, sym_len), true,
 				  VAR_DOMAIN, LOC_STATIC,
 				  data_sect_index,
 				  psymbol_placement::GLOBAL,
@@ -1525,7 +1525,7 @@ read_dbx_symtab (minimal_symbol_reader &reader,
 		      && namestring[0] != ' '))
 		{
 		  if (pst != nullptr)
-		    pst->add_psymbol (gdb::string_view (sym_name, sym_len),
+		    pst->add_psymbol (std::string_view (sym_name, sym_len),
 				      true, STRUCT_DOMAIN, LOC_TYPEDEF, -1,
 				      psymbol_placement::STATIC,
 				      unrelocated_addr (0),
@@ -1540,7 +1540,7 @@ read_dbx_symtab (minimal_symbol_reader &reader,
 		    {
 		      /* Also a typedef with the same name.  */
 		      if (pst != nullptr)
-			pst->add_psymbol (gdb::string_view (sym_name, sym_len),
+			pst->add_psymbol (std::string_view (sym_name, sym_len),
 					  true, VAR_DOMAIN, LOC_TYPEDEF, -1,
 					  psymbol_placement::STATIC,
 					  unrelocated_addr (0),
@@ -1559,7 +1559,7 @@ read_dbx_symtab (minimal_symbol_reader &reader,
 	      if (p != namestring)	/* a name is there, not just :T...  */
 		{
 		  if (pst != nullptr)
-		    pst->add_psymbol (gdb::string_view (sym_name, sym_len),
+		    pst->add_psymbol (std::string_view (sym_name, sym_len),
 				      true, VAR_DOMAIN, LOC_TYPEDEF, -1,
 				      psymbol_placement::STATIC,
 				      unrelocated_addr (0),
@@ -1627,7 +1627,7 @@ read_dbx_symtab (minimal_symbol_reader &reader,
 		      /* Note that the value doesn't matter for
 			 enum constants in psymtabs, just in symtabs.  */
 		      if (pst != nullptr)
-			pst->add_psymbol (gdb::string_view (p, q - p), true,
+			pst->add_psymbol (std::string_view (p, q - p), true,
 					  VAR_DOMAIN, LOC_CONST, -1,
 					  psymbol_placement::STATIC,
 					  unrelocated_addr (0),
@@ -1652,7 +1652,7 @@ read_dbx_symtab (minimal_symbol_reader &reader,
 	    case 'c':
 	      /* Constant, e.g. from "const" in Pascal.  */
 	      if (pst != nullptr)
-		pst->add_psymbol (gdb::string_view (sym_name, sym_len), true,
+		pst->add_psymbol (std::string_view (sym_name, sym_len), true,
 				  VAR_DOMAIN, LOC_CONST, -1,
 				  psymbol_placement::STATIC,
 				  unrelocated_addr (0),
@@ -1712,7 +1712,7 @@ read_dbx_symtab (minimal_symbol_reader &reader,
 		  textlow_not_set = 0;
 		}
 	      if (pst != nullptr)
-		pst->add_psymbol (gdb::string_view (sym_name, sym_len), true,
+		pst->add_psymbol (std::string_view (sym_name, sym_len), true,
 				  VAR_DOMAIN, LOC_BLOCK,
 				  SECT_OFF_TEXT (objfile),
 				  psymbol_placement::STATIC,
@@ -1771,7 +1771,7 @@ read_dbx_symtab (minimal_symbol_reader &reader,
 		  textlow_not_set = 0;
 		}
 	      if (pst != nullptr)
-		pst->add_psymbol (gdb::string_view (sym_name, sym_len), true,
+		pst->add_psymbol (std::string_view (sym_name, sym_len), true,
 				  VAR_DOMAIN, LOC_BLOCK,
 				  SECT_OFF_TEXT (objfile),
 				  psymbol_placement::GLOBAL,
diff --git a/gdb/debuginfod-support.c b/gdb/debuginfod-support.c
index 1ebd98ca705..a989eb9cb97 100644
--- a/gdb/debuginfod-support.c
+++ b/gdb/debuginfod-support.c
@@ -20,6 +20,7 @@
 #include "diagnostics.h"
 #include <errno.h>
 #include "gdbsupport/scoped_fd.h"
+#include "gdbsupport/gdb_string_view.h"
 #include "debuginfod-support.h"
 #include <optional>
 #include "cli/cli-cmds.h"
@@ -246,11 +247,11 @@ debuginfod_is_enabled ()
       gdb_printf (_("\nThis GDB supports auto-downloading debuginfo " \
 		    "from the following URLs:\n"));
 
-      gdb::string_view url_view (urls);
+      std::string_view url_view (urls);
       while (true)
 	{
 	  size_t off = url_view.find_first_not_of (' ');
-	  if (off == gdb::string_view::npos)
+	  if (off == std::string_view::npos)
 	    break;
 	  url_view = url_view.substr (off);
 	  /* g++ 11.2.1 on s390x, g++ 11.3.1 on ppc64le and g++ 11 on
@@ -266,7 +267,7 @@ debuginfod_is_enabled ()
 	     styled_string (file_name_style.style (),
 			    gdb::to_string (url_view.substr (0,
 							     off)).c_str ()));
-	  if (off == gdb::string_view::npos)
+	  if (off == std::string_view::npos)
 	    break;
 	  url_view = url_view.substr (off);
 	}
diff --git a/gdb/dwarf2/cooked-index.c b/gdb/dwarf2/cooked-index.c
index 58ea541a5c9..7c4af3a1681 100644
--- a/gdb/dwarf2/cooked-index.c
+++ b/gdb/dwarf2/cooked-index.c
@@ -266,9 +266,9 @@ cooked_index_shard::handle_gnat_encoded_entry (cooked_index_entry *entry,
   std::string canonical = ada_decode (entry->name, false, false);
   if (canonical.empty ())
     return {};
-  std::vector<gdb::string_view> names = split_name (canonical.c_str (),
+  std::vector<std::string_view> names = split_name (canonical.c_str (),
 						    split_style::DOT_STYLE);
-  gdb::string_view tail = names.back ();
+  std::string_view tail = names.back ();
   names.pop_back ();
 
   const cooked_index_entry *parent = nullptr;
@@ -333,7 +333,7 @@ cooked_index_shard::do_finalize ()
   auto eq_entry = [] (const void *a, const void *b) -> int
     {
       const cooked_index_entry *ae = (const cooked_index_entry *) a;
-      const gdb::string_view *sv = (const gdb::string_view *) b;
+      const std::string_view *sv = (const std::string_view *) b;
       return (strlen (ae->canonical) == sv->length ()
 	      && strncasecmp (ae->canonical, sv->data (), sv->length ()) == 0);
     };
diff --git a/gdb/dwarf2/cooked-index.h b/gdb/dwarf2/cooked-index.h
index 5aacb321c91..5675ea68bb8 100644
--- a/gdb/dwarf2/cooked-index.h
+++ b/gdb/dwarf2/cooked-index.h
@@ -25,7 +25,7 @@
 #include "symtab.h"
 #include "hashtab.h"
 #include "dwarf2/index-common.h"
-#include "gdbsupport/gdb_string_view.h"
+#include <string_view>
 #include "quick-symbol.h"
 #include "gdbsupport/gdb_obstack.h"
 #include "addrmap.h"
diff --git a/gdb/dwarf2/index-common.c b/gdb/dwarf2/index-common.c
index 07330a86da1..04b04f93a61 100644
--- a/gdb/dwarf2/index-common.c
+++ b/gdb/dwarf2/index-common.c
@@ -58,7 +58,7 @@ dwarf5_djb_hash (const char *str_)
 /* See dwarf-index-common.h.  */
 
 uint32_t
-dwarf5_djb_hash (gdb::string_view str)
+dwarf5_djb_hash (std::string_view str)
 {
   /* Note: tolower here ignores UTF-8, which isn't fully compliant.
      See http://dwarfstd.org/ShowIssue.php?issue=161027.1.  */
diff --git a/gdb/dwarf2/index-common.h b/gdb/dwarf2/index-common.h
index 23e814a240b..79d3a59220e 100644
--- a/gdb/dwarf2/index-common.h
+++ b/gdb/dwarf2/index-common.h
@@ -54,6 +54,6 @@ uint32_t dwarf5_djb_hash (const char *str_);
 
 /* Symbol name hashing function as specified by DWARF-5.  */
 
-uint32_t dwarf5_djb_hash (gdb::string_view str_);
+uint32_t dwarf5_djb_hash (std::string_view str_);
 
 #endif /* DWARF_INDEX_COMMON_H */
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 6d86d28d8c0..a16139dad1e 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -96,6 +96,7 @@
 #include "split-name.h"
 #include "gdbsupport/parallel-for.h"
 #include "gdbsupport/thread-pool.h"
+#include "gdbsupport/gdb_string_view.h"
 
 /* When == 1, print basic high level tracing messages.
    When > 1, be more verbose.
@@ -16767,7 +16768,7 @@ cooked_index_functions::expand_symtabs_matching
 
   for (enum language lang : unique_styles)
     {
-      std::vector<gdb::string_view> name_vec
+      std::vector<std::string_view> name_vec
 	= lookup_name_without_params.split_name (lang);
       std::string last_name = gdb::to_string (name_vec.back ());
 
diff --git a/gdb/elfread.c b/gdb/elfread.c
index 86e7f61586e..5dc8f21d7c7 100644
--- a/gdb/elfread.c
+++ b/gdb/elfread.c
@@ -45,7 +45,7 @@
 #include "auxv.h"
 #include "mdebugread.h"
 #include "ctfread.h"
-#include "gdbsupport/gdb_string_view.h"
+#include <string_view>
 #include "gdbsupport/scoped_fd.h"
 #include "dwarf2/public.h"
 #include "cli/cli-cmds.h"
@@ -195,7 +195,7 @@ elf_locate_sections (asection *sectp, struct elfinfo *ei)
 
 static struct minimal_symbol *
 record_minimal_symbol (minimal_symbol_reader &reader,
-		       gdb::string_view name, bool copy_name,
+		       std::string_view name, bool copy_name,
 		       unrelocated_addr address,
 		       enum minimal_symbol_type ms_type,
 		       asection *bfd_section, struct objfile *objfile)
@@ -503,7 +503,7 @@ elf_symtab_read (minimal_symbol_reader &reader,
 		  && !is_plt
 		  && (elf_sym->version & VERSYM_HIDDEN) == 0)
 		record_minimal_symbol (reader,
-				       gdb::string_view (sym->name, len),
+				       std::string_view (sym->name, len),
 				       true, unrelocated_addr (symaddr),
 				       ms_type, sym->section, objfile);
 	      else if (is_plt)
@@ -517,7 +517,7 @@ elf_symtab_read (minimal_symbol_reader &reader,
 		      struct minimal_symbol *mtramp;
 
 		      mtramp = record_minimal_symbol
-			(reader, gdb::string_view (sym->name, len), true,
+			(reader, std::string_view (sym->name, len), true,
 			 unrelocated_addr (symaddr),
 			 mst_solib_trampoline, sym->section, objfile);
 		      if (mtramp)
diff --git a/gdb/eval.c b/gdb/eval.c
index 3358b0d8d32..8664d4980b7 100644
--- a/gdb/eval.c
+++ b/gdb/eval.c
@@ -37,6 +37,7 @@
 #include "user-regs.h"
 #include "valprint.h"
 #include "gdbsupport/gdb_obstack.h"
+#include "gdbsupport/gdb_string_view.h"
 #include "objfiles.h"
 #include "typeprint.h"
 #include <ctype.h>
diff --git a/gdb/language.c b/gdb/language.c
index c768971be42..cfd4a621e6b 100644
--- a/gdb/language.c
+++ b/gdb/language.c
@@ -641,7 +641,7 @@ default_symbol_name_matcher (const char *symbol_search_name,
 			     const lookup_name_info &lookup_name,
 			     completion_match_result *comp_match_res)
 {
-  gdb::string_view name = lookup_name.name ();
+  std::string_view name = lookup_name.name ();
   completion_match_for_lcd *match_for_lcd
     = (comp_match_res != NULL ? &comp_match_res->match_for_lcd : NULL);
   strncmp_iw_mode mode = (lookup_name.completion_mode ()
diff --git a/gdb/linux-tdep.c b/gdb/linux-tdep.c
index db29b032018..26cf483b04a 100644
--- a/gdb/linux-tdep.c
+++ b/gdb/linux-tdep.c
@@ -457,13 +457,13 @@ struct mapping
 {
   ULONGEST addr;
   ULONGEST endaddr;
-  gdb::string_view permissions;
+  std::string_view permissions;
   ULONGEST offset;
-  gdb::string_view device;
+  std::string_view device;
   ULONGEST inode;
 
   /* This field is guaranteed to be NULL-terminated, hence it is not a
-     gdb::string_view.  */
+     std::string_view.  */
   const char *filename;
 };
 
@@ -1384,7 +1384,7 @@ parse_smaps_data (const char *data,
 
       /* Decode permissions.  */
       auto has_perm = [&m] (char c)
-	{ return m.permissions.find (c) != gdb::string_view::npos; };
+	{ return m.permissions.find (c) != std::string_view::npos; };
       read = has_perm ('r');
       write = has_perm ('w');
       exec = has_perm ('x');
diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c
index cd6638224e7..fc731605991 100644
--- a/gdb/mdebugread.c
+++ b/gdb/mdebugread.c
@@ -3050,7 +3050,7 @@ parse_partial_symbols (minimal_symbol_reader &reader,
 		    switch (p[1])
 		      {
 		      case 'S':
-			pst->add_psymbol (gdb::string_view (namestring,
+			pst->add_psymbol (std::string_view (namestring,
 							    p - namestring),
 					  true, VAR_DOMAIN, LOC_STATIC,
 					  SECT_OFF_DATA (objfile),
@@ -3063,7 +3063,7 @@ parse_partial_symbols (minimal_symbol_reader &reader,
 			/* The addresses in these entries are reported
 			   to be wrong.  See the code that reads 'G's
 			   for symtabs.  */
-			pst->add_psymbol (gdb::string_view (namestring,
+			pst->add_psymbol (std::string_view (namestring,
 							    p - namestring),
 					  true, VAR_DOMAIN, LOC_STATIC,
 					  SECT_OFF_DATA (objfile),
@@ -3085,7 +3085,7 @@ parse_partial_symbols (minimal_symbol_reader &reader,
 				&& namestring[0] != ' '))
 			  {
 			    pst->add_psymbol
-			      (gdb::string_view (namestring, p - namestring),
+			      (std::string_view (namestring, p - namestring),
 			       true, STRUCT_DOMAIN, LOC_TYPEDEF, -1,
 			       psymbol_placement::STATIC,
 			       unrelocated_addr (0),
@@ -3095,7 +3095,7 @@ parse_partial_symbols (minimal_symbol_reader &reader,
 			      {
 				/* Also a typedef with the same name.  */
 				pst->add_psymbol
-				  (gdb::string_view (namestring,
+				  (std::string_view (namestring,
 						     p - namestring),
 				   true, VAR_DOMAIN, LOC_TYPEDEF, -1,
 				   psymbol_placement::STATIC,
@@ -3111,7 +3111,7 @@ parse_partial_symbols (minimal_symbol_reader &reader,
 						   just :T...  */
 			  {
 			    pst->add_psymbol
-			      (gdb::string_view (namestring,
+			      (std::string_view (namestring,
 						 p - namestring),
 			       true, VAR_DOMAIN, LOC_TYPEDEF, -1,
 			       psymbol_placement::STATIC,
@@ -3178,7 +3178,7 @@ parse_partial_symbols (minimal_symbol_reader &reader,
 				/* Note that the value doesn't matter for
 				   enum constants in psymtabs, just in
 				   symtabs.  */
-				pst->add_psymbol (gdb::string_view (p,
+				pst->add_psymbol (std::string_view (p,
 								    q - p),
 						  true, VAR_DOMAIN,
 						  LOC_CONST, -1,
@@ -3199,7 +3199,7 @@ parse_partial_symbols (minimal_symbol_reader &reader,
 			continue;
 		      case 'c':
 			/* Constant, e.g. from "const" in Pascal.  */
-			pst->add_psymbol (gdb::string_view (namestring,
+			pst->add_psymbol (std::string_view (namestring,
 							    p - namestring),
 					  true, VAR_DOMAIN, LOC_CONST, -1,
 					  psymbol_placement::STATIC,
@@ -3215,7 +3215,7 @@ parse_partial_symbols (minimal_symbol_reader &reader,
 			    function_outside_compilation_unit_complaint
 			      (copy.c_str ());
 			  }
-			pst->add_psymbol (gdb::string_view (namestring,
+			pst->add_psymbol (std::string_view (namestring,
 							    p - namestring),
 					  true, VAR_DOMAIN, LOC_BLOCK,
 					  SECT_OFF_TEXT (objfile),
@@ -3236,7 +3236,7 @@ parse_partial_symbols (minimal_symbol_reader &reader,
 			    function_outside_compilation_unit_complaint
 			      (copy.c_str ());
 			  }
-			pst->add_psymbol (gdb::string_view (namestring,
+			pst->add_psymbol (std::string_view (namestring,
 							    p - namestring),
 					  true, VAR_DOMAIN, LOC_BLOCK,
 					  SECT_OFF_TEXT (objfile),
diff --git a/gdb/minsyms.c b/gdb/minsyms.c
index 1d778822858..72e500be959 100644
--- a/gdb/minsyms.c
+++ b/gdb/minsyms.c
@@ -1170,7 +1170,7 @@ mst_str (minimal_symbol_type t)
 /* See minsyms.h.  */
 
 struct minimal_symbol *
-minimal_symbol_reader::record_full (gdb::string_view name,
+minimal_symbol_reader::record_full (std::string_view name,
 				    bool copy_name, unrelocated_addr address,
 				    enum minimal_symbol_type ms_type,
 				    int section)
@@ -1510,7 +1510,7 @@ minimal_symbol_reader::install ()
 	       {
 		 size_t idx = msym - msymbols;
 		 msym->compute_and_set_names
-		   (gdb::string_view (msym->linkage_name (),
+		   (std::string_view (msym->linkage_name (),
 				      hash_values[idx].name_length),
 		    false,
 		    m_objfile->per_bfd,
diff --git a/gdb/minsyms.h b/gdb/minsyms.h
index f3a2474c796..ee415c4db41 100644
--- a/gdb/minsyms.h
+++ b/gdb/minsyms.h
@@ -118,7 +118,7 @@ class minimal_symbol_reader
      SECTION - the symbol's section
   */
 
-  struct minimal_symbol *record_full (gdb::string_view name,
+  struct minimal_symbol *record_full (std::string_view name,
 				      bool copy_name,
 				      unrelocated_addr address,
 				      enum minimal_symbol_type ms_type,
diff --git a/gdb/psymtab.c b/gdb/psymtab.c
index 484d4eaa651..d4cd5810c20 100644
--- a/gdb/psymtab.c
+++ b/gdb/psymtab.c
@@ -1208,7 +1208,7 @@ partial_symtab::add_psymbol (const partial_symbol &psymbol,
 /* See psymtab.h.  */
 
 void
-partial_symtab::add_psymbol (gdb::string_view name, bool copy_name,
+partial_symtab::add_psymbol (std::string_view name, bool copy_name,
 			     domain_enum domain,
 			     enum address_class theclass,
 			     short section,
diff --git a/gdb/psymtab.h b/gdb/psymtab.h
index 4bafc6e998e..005a63cbba8 100644
--- a/gdb/psymtab.h
+++ b/gdb/psymtab.h
@@ -21,7 +21,7 @@
 #define PSYMTAB_H
 
 #include "objfiles.h"
-#include "gdbsupport/gdb_string_view.h"
+#include <string_view>
 #include "gdbsupport/gdb_obstack.h"
 #include "symfile.h"
 #include "gdbsupport/next-iterator.h"
@@ -346,7 +346,7 @@ struct partial_symtab
      LANGUAGE is the language from which the symbol originates.  This will
      influence, amongst other things, how the symbol name is demangled. */
 
-  void add_psymbol (gdb::string_view name,
+  void add_psymbol (std::string_view name,
 		    bool copy_name, domain_enum domain,
 		    enum address_class theclass,
 		    short section,
diff --git a/gdb/solib-rocm.c b/gdb/solib-rocm.c
index cf56a81a2ee..9ceb7a922e3 100644
--- a/gdb/solib-rocm.c
+++ b/gdb/solib-rocm.c
@@ -31,6 +31,7 @@
 #include "solib-svr4.h"
 #include "solist.h"
 #include "symfile.h"
+#include "gdbsupport/gdb_string_view.h"
 
 #include <unordered_map>
 
@@ -436,8 +437,8 @@ rocm_code_object_stream_memory::read (bfd *, void *buf, file_ptr size,
 static gdb_bfd_iovec_base *
 rocm_bfd_iovec_open (bfd *abfd, inferior *inferior)
 {
-  gdb::string_view uri (bfd_get_filename (abfd));
-  gdb::string_view protocol_delim = "://";
+  std::string_view uri (bfd_get_filename (abfd));
+  std::string_view protocol_delim = "://";
   size_t protocol_end = uri.find (protocol_delim);
   std::string protocol = gdb::to_string (uri.substr (0, protocol_end));
   protocol_end += protocol_delim.length ();
@@ -445,7 +446,7 @@ rocm_bfd_iovec_open (bfd *abfd, inferior *inferior)
   std::transform (protocol.begin (), protocol.end (), protocol.begin (),
 		  [] (unsigned char c) { return std::tolower (c); });
 
-  gdb::string_view path;
+  std::string_view path;
   size_t path_end = uri.find_first_of ("#?", protocol_end);
   if (path_end != std::string::npos)
     path = uri.substr (protocol_end, path_end++ - protocol_end);
@@ -461,7 +462,7 @@ rocm_bfd_iovec_open (bfd *abfd, inferior *inferior)
 	&& std::isxdigit (path[i + 1])
 	&& std::isxdigit (path[i + 2]))
       {
-	gdb::string_view hex_digits = path.substr (i + 1, 2);
+	std::string_view hex_digits = path.substr (i + 1, 2);
 	decoded_path += std::stoi (gdb::to_string (hex_digits), 0, 16);
 	i += 2;
       }
@@ -469,7 +470,7 @@ rocm_bfd_iovec_open (bfd *abfd, inferior *inferior)
       decoded_path += path[i];
 
   /* Tokenize the query/fragment.  */
-  std::vector<gdb::string_view> tokens;
+  std::vector<std::string_view> tokens;
   size_t pos, last = path_end;
   while ((pos = uri.find ('&', last)) != std::string::npos)
     {
@@ -481,15 +482,15 @@ rocm_bfd_iovec_open (bfd *abfd, inferior *inferior)
     tokens.emplace_back (uri.substr (last));
 
   /* Create a tag-value map from the tokenized query/fragment.  */
-  std::unordered_map<gdb::string_view, gdb::string_view,
+  std::unordered_map<std::string_view, std::string_view,
 		     gdb::string_view_hash> params;
-  for (gdb::string_view token : tokens)
+  for (std::string_view token : tokens)
     {
       size_t delim = token.find ('=');
       if (delim != std::string::npos)
 	{
-	  gdb::string_view tag = token.substr (0, delim);
-	  gdb::string_view val = token.substr (delim + 1);
+	  std::string_view tag = token.substr (0, delim);
+	  std::string_view val = token.substr (delim + 1);
 	  params.emplace (tag, val);
 	}
     }
@@ -499,7 +500,7 @@ rocm_bfd_iovec_open (bfd *abfd, inferior *inferior)
       ULONGEST offset = 0;
       ULONGEST size = 0;
 
-      auto try_strtoulst = [] (gdb::string_view v)
+      auto try_strtoulst = [] (std::string_view v)
 	{
 	  errno = 0;
 	  ULONGEST value = strtoulst (v.data (), nullptr, 0);
diff --git a/gdb/split-name.c b/gdb/split-name.c
index 0253b3cf675..0805cb82700 100644
--- a/gdb/split-name.c
+++ b/gdb/split-name.c
@@ -23,10 +23,10 @@
 
 /* See split-name.h.  */
 
-std::vector<gdb::string_view>
+std::vector<std::string_view>
 split_name (const char *name, split_style style)
 {
-  std::vector<gdb::string_view> result;
+  std::vector<std::string_view> result;
   unsigned int previous_len = 0;
 
   switch (style)
diff --git a/gdb/split-name.h b/gdb/split-name.h
index 7648cf9b900..ad2862e222d 100644
--- a/gdb/split-name.h
+++ b/gdb/split-name.h
@@ -20,7 +20,7 @@
 #ifndef GDB_SPLIT_NAME_H
 #define GDB_SPLIT_NAME_H
 
-#include "gdbsupport/gdb_string_view.h"
+#include <string_view>
 
 /* The available styles of name splitting.  */
 
@@ -40,7 +40,7 @@ enum class split_style
 /* Split NAME into components at module boundaries.  STYLE indicates
    which style of splitting to use.  */
 
-extern std::vector<gdb::string_view> split_name (const char *name,
+extern std::vector<std::string_view> split_name (const char *name,
 						 split_style style);
 
 #endif /* GDB_SPLIT_NAME_H */
diff --git a/gdb/stabsread.c b/gdb/stabsread.c
index 7402a26a401..4011475f7ac 100644
--- a/gdb/stabsread.c
+++ b/gdb/stabsread.c
@@ -748,7 +748,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
       if (new_name != nullptr)
 	sym->compute_and_set_names (new_name.get (), true, objfile->per_bfd);
       else
-	sym->compute_and_set_names (gdb::string_view (string, p - string), true,
+	sym->compute_and_set_names (std::string_view (string, p - string), true,
 				    objfile->per_bfd);
 
       if (sym->language () == language_cplus)
diff --git a/gdb/symtab.c b/gdb/symtab.c
index 17d1987608f..15471554f32 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -70,7 +70,7 @@
 #include "filename-seen-cache.h"
 #include "arch-utils.h"
 #include <algorithm>
-#include "gdbsupport/gdb_string_view.h"
+#include <string_view>
 #include "gdbsupport/pathstuff.h"
 #include "gdbsupport/common-utils.h"
 
@@ -828,10 +828,10 @@ general_symbol_info::set_language (enum language language,
 /* Objects of this type are stored in the demangled name hash table.  */
 struct demangled_name_entry
 {
-  demangled_name_entry (gdb::string_view mangled_name)
+  demangled_name_entry (std::string_view mangled_name)
     : mangled (mangled_name) {}
 
-  gdb::string_view mangled;
+  std::string_view mangled;
   enum language language;
   gdb::unique_xmalloc_ptr<char> demangled;
 };
@@ -940,7 +940,7 @@ symbol_find_demangled_name (struct general_symbol_info *gsymbol,
    so the pointer can be discarded after calling this function.  */
 
 void
-general_symbol_info::compute_and_set_names (gdb::string_view linkage_name,
+general_symbol_info::compute_and_set_names (std::string_view linkage_name,
 					    bool copy_name,
 					    objfile_per_bfd_storage *per_bfd,
 					    std::optional<hashval_t> hash)
@@ -991,14 +991,14 @@ general_symbol_info::compute_and_set_names (gdb::string_view linkage_name,
       /* A 0-terminated copy of the linkage name.  Callers must set COPY_NAME
 	 to true if the string might not be nullterminated.  We have to make
 	 this copy because demangling needs a nullterminated string.  */
-      gdb::string_view linkage_name_copy;
+      std::string_view linkage_name_copy;
       if (copy_name)
 	{
 	  char *alloc_name = (char *) alloca (linkage_name.length () + 1);
 	  memcpy (alloc_name, linkage_name.data (), linkage_name.length ());
 	  alloc_name[linkage_name.length ()] = '\0';
 
-	  linkage_name_copy = gdb::string_view (alloc_name,
+	  linkage_name_copy = std::string_view (alloc_name,
 						linkage_name.length ());
 	}
       else
@@ -1038,7 +1038,7 @@ general_symbol_info::compute_and_set_names (gdb::string_view linkage_name,
 	  memcpy (mangled_ptr, linkage_name.data (), linkage_name.length ());
 	  mangled_ptr [linkage_name.length ()] = '\0';
 	  new (*slot) demangled_name_entry
-	    (gdb::string_view (mangled_ptr, linkage_name.length ()));
+	    (std::string_view (mangled_ptr, linkage_name.length ()));
 	}
       (*slot)->demangled = std::move (demangled_name);
       (*slot)->language = language ();
diff --git a/gdb/symtab.h b/gdb/symtab.h
index 0fb0c8683cb..ec2ac4942d3 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -31,7 +31,7 @@
 #include "gdbsupport/enum-flags.h"
 #include "gdbsupport/function-view.h"
 #include <optional>
-#include "gdbsupport/gdb_string_view.h"
+#include <string_view>
 #include "gdbsupport/next-iterator.h"
 #include "gdbsupport/iterator-range.h"
 #include "completer.h"
@@ -126,11 +126,11 @@ class ada_lookup_name_info final
 
   /* A wrapper for ::split_name that handles some Ada-specific
      peculiarities.  */
-  std::vector<gdb::string_view> split_name () const
+  std::vector<std::string_view> split_name () const
   {
     if (m_verbatim_p || m_standard_p)
       {
-	std::vector<gdb::string_view> result;
+	std::vector<std::string_view> result;
 	if (m_standard_p)
 	  result.emplace_back ("standard");
 	result.emplace_back (m_encoded_name);
@@ -238,7 +238,7 @@ class lookup_name_info final
   /* Getters.  See description of each corresponding field.  */
   symbol_name_match_type match_type () const { return m_match_type; }
   bool completion_mode () const { return m_completion_mode; }
-  gdb::string_view name () const { return m_name; }
+  std::string_view name () const { return m_name; }
   const bool ignore_parameters () const { return m_ignore_parameters; }
 
   /* Like the "name" method but guarantees that the returned string is
@@ -292,7 +292,7 @@ class lookup_name_info final
 
   /* A wrapper for ::split_name (see split-name.h) that splits this
      name, and that handles any language-specific peculiarities.  */  
-  std::vector<gdb::string_view> split_name (language lang) const
+  std::vector<std::string_view> split_name (language lang) const
   {
     if (lang == language_ada)
       return ada ().split_name ();
@@ -356,7 +356,7 @@ class lookup_name_info final
   symbol_name_match_type m_match_type;
   bool m_completion_mode;
   bool m_ignore_parameters;
-  gdb::string_view m_name;
+  std::string_view m_name;
 
   /* Language-specific info.  These fields are filled lazily the first
      time a lookup is done in the corresponding language.  They're
@@ -509,7 +509,7 @@ struct general_symbol_info
   /* Set the linkage and natural names of a symbol, by demangling
      the linkage name.  If linkage_name may not be nullterminated,
      copy_name must be set to true.  */
-  void compute_and_set_names (gdb::string_view linkage_name, bool copy_name,
+  void compute_and_set_names (std::string_view linkage_name, bool copy_name,
 			      struct objfile_per_bfd_storage *per_bfd,
 			      std::optional<hashval_t> hash
 				= std::optional<hashval_t> ());
diff --git a/gdb/tui/tui-io.c b/gdb/tui/tui-io.c
index b8954af36e2..84724643fd5 100644
--- a/gdb/tui/tui-io.c
+++ b/gdb/tui/tui-io.c
@@ -1197,7 +1197,10 @@ tui_getc_1 (FILE *fp)
 	 Compare keyname instead.  */
       if (ch >= KEY_MAX)
 	{
-	  auto name = gdb::string_view (keyname (ch));
+	  std::string_view name;
+	  const char *name_str = keyname (ch);
+	  if (name_str != nullptr)
+	    name = std::string_view (name_str);
 
 	  /* The following sequences are hardcoded in readline as
 	     well.  */
diff --git a/gdb/tui/tui-win.c b/gdb/tui/tui-win.c
index a0a123340e3..9219c1f0184 100644
--- a/gdb/tui/tui-win.c
+++ b/gdb/tui/tui-win.c
@@ -54,7 +54,7 @@
 #include "gdb_curses.h"
 #include <ctype.h>
 #include "readline/readline.h"
-#include "gdbsupport/gdb_string_view.h"
+#include <string_view>
 
 #include <signal.h>
 
@@ -663,7 +663,7 @@ tui_scroll_right_command (const char *arg, int from_tty)
 
 /* Answer the window represented by name.  */
 static struct tui_win_info *
-tui_partial_win_by_name (gdb::string_view name)
+tui_partial_win_by_name (std::string_view name)
 {
   struct tui_win_info *best = nullptr;
 
@@ -935,7 +935,7 @@ tui_set_win_size (const char *arg, bool set_width_p)
   buf_ptr = skip_to_space (buf_ptr);
 
   /* Validate the window name.  */
-  gdb::string_view wname (buf, buf_ptr - buf);
+  std::string_view wname (buf, buf_ptr - buf);
   win_info = tui_partial_win_by_name (wname);
 
   if (win_info == NULL)
diff --git a/gdb/xcoffread.c b/gdb/xcoffread.c
index e6ecf2a6de5..829fc1f09c7 100644
--- a/gdb/xcoffread.c
+++ b/gdb/xcoffread.c
@@ -2500,7 +2500,7 @@ scan_xcoff_symtab (minimal_symbol_reader &reader,
 	    switch (p[1])
 	      {
 	      case 'S':
-		pst->add_psymbol (gdb::string_view (namestring,
+		pst->add_psymbol (std::string_view (namestring,
 						    p - namestring),
 				  true, VAR_DOMAIN, LOC_STATIC,
 				  SECT_OFF_DATA (objfile),
@@ -2513,7 +2513,7 @@ scan_xcoff_symtab (minimal_symbol_reader &reader,
 	      case 'G':
 		/* The addresses in these entries are reported to be
 		   wrong.  See the code that reads 'G's for symtabs.  */
-		pst->add_psymbol (gdb::string_view (namestring,
+		pst->add_psymbol (std::string_view (namestring,
 						    p - namestring),
 				  true, VAR_DOMAIN, LOC_STATIC,
 				  SECT_OFF_DATA (objfile),
@@ -2534,7 +2534,7 @@ scan_xcoff_symtab (minimal_symbol_reader &reader,
 		    || (p == namestring + 1
 			&& namestring[0] != ' '))
 		  {
-		    pst->add_psymbol (gdb::string_view (namestring,
+		    pst->add_psymbol (std::string_view (namestring,
 							p - namestring),
 				      true, STRUCT_DOMAIN, LOC_TYPEDEF, -1,
 				      psymbol_placement::STATIC,
@@ -2544,7 +2544,7 @@ scan_xcoff_symtab (minimal_symbol_reader &reader,
 		    if (p[2] == 't')
 		      {
 			/* Also a typedef with the same name.  */
-			pst->add_psymbol (gdb::string_view (namestring,
+			pst->add_psymbol (std::string_view (namestring,
 							    p - namestring),
 					  true, VAR_DOMAIN, LOC_TYPEDEF, -1,
 					  psymbol_placement::STATIC,
@@ -2559,7 +2559,7 @@ scan_xcoff_symtab (minimal_symbol_reader &reader,
 	      case 't':
 		if (p != namestring)	/* a name is there, not just :T...  */
 		  {
-		    pst->add_psymbol (gdb::string_view (namestring,
+		    pst->add_psymbol (std::string_view (namestring,
 							p - namestring),
 				      true, VAR_DOMAIN, LOC_TYPEDEF, -1,
 				      psymbol_placement::STATIC,
@@ -2624,7 +2624,7 @@ scan_xcoff_symtab (minimal_symbol_reader &reader,
 			  ;
 			/* Note that the value doesn't matter for
 			   enum constants in psymtabs, just in symtabs.  */
-			pst->add_psymbol (gdb::string_view (p, q - p), true,
+			pst->add_psymbol (std::string_view (p, q - p), true,
 					  VAR_DOMAIN, LOC_CONST, -1,
 					  psymbol_placement::STATIC,
 					  unrelocated_addr (0),
@@ -2644,7 +2644,7 @@ scan_xcoff_symtab (minimal_symbol_reader &reader,
 
 	      case 'c':
 		/* Constant, e.g. from "const" in Pascal.  */
-		pst->add_psymbol (gdb::string_view (namestring,
+		pst->add_psymbol (std::string_view (namestring,
 						    p - namestring),
 				  true, VAR_DOMAIN, LOC_CONST, -1,
 				  psymbol_placement::STATIC,
@@ -2659,7 +2659,7 @@ scan_xcoff_symtab (minimal_symbol_reader &reader,
 		    std::string name (namestring, (p - namestring));
 		    function_outside_compilation_unit_complaint (name.c_str ());
 		  }
-		pst->add_psymbol (gdb::string_view (namestring,
+		pst->add_psymbol (std::string_view (namestring,
 						    p - namestring),
 				  true, VAR_DOMAIN, LOC_BLOCK,
 				  SECT_OFF_TEXT (objfile),
@@ -2686,7 +2686,7 @@ scan_xcoff_symtab (minimal_symbol_reader &reader,
 		if (startswith (namestring, "@FIX"))
 		  continue;
 
-		pst->add_psymbol (gdb::string_view (namestring,
+		pst->add_psymbol (std::string_view (namestring,
 						    p - namestring),
 				  true, VAR_DOMAIN, LOC_BLOCK,
 				  SECT_OFF_TEXT (objfile),
diff --git a/gdbsupport/common-utils.h b/gdbsupport/common-utils.h
index 4ceb44d88b8..1efc5bbf459 100644
--- a/gdbsupport/common-utils.h
+++ b/gdbsupport/common-utils.h
@@ -26,7 +26,7 @@
 #include "gdbsupport/gdb_unique_ptr.h"
 #include "gdbsupport/array-view.h"
 #include "poison.h"
-#include "gdb_string_view.h"
+#include <string_view>
 
 #if defined HAVE_LIBXXHASH
 #  include <xxhash.h>
@@ -94,7 +94,7 @@ extern const char *safe_strerror (int);
    true if the start of STRING matches PATTERN, false otherwise.  */
 
 static inline bool
-startswith (gdb::string_view string, gdb::string_view pattern)
+startswith (std::string_view string, std::string_view pattern)
 {
   return (string.length () >= pattern.length ()
 	  && strncmp (string.data (), pattern.data (), pattern.length ()) == 0);
@@ -228,7 +228,7 @@ fast_hash (const void *ptr, size_t len, unsigned int start_value = 0)
 namespace gdb
 {
 
-/* Hash type for gdb::string_view.
+/* Hash type for std::string_view.
 
    Even after we switch to C++17 and dump our string_view implementation, we
    might want to keep this hash implementation if it's faster than std::hash
@@ -236,7 +236,7 @@ namespace gdb
 
 struct string_view_hash
 {
-  std::size_t operator() (gdb::string_view view) const
+  std::size_t operator() (std::string_view view) const
   {  return fast_hash (view.data (), view.length ()); }
 };
 
diff --git a/gdbsupport/format.h b/gdbsupport/format.h
index 2af34ab9450..26e327a60e8 100644
--- a/gdbsupport/format.h
+++ b/gdbsupport/format.h
@@ -20,7 +20,7 @@
 #ifndef COMMON_FORMAT_H
 #define COMMON_FORMAT_H
 
-#include "gdbsupport/gdb_string_view.h"
+#include <string_view>
 
 #if defined(__MINGW32__) && !defined(PRINTF_HAS_LONG_LONG)
 # define USE_PRINTF_I64 1
@@ -56,12 +56,13 @@ struct format_piece
       argclass (argc),
       n_int_args (n)
   {
+    gdb_assert (str != nullptr);
   }
 
   bool operator== (const format_piece &other) const
   {
     return (this->argclass == other.argclass
-	    && gdb::string_view (this->string) == other.string);
+	    && std::string_view (this->string) == other.string);
   }
 
   const char *string;
diff --git a/gdbsupport/gdb_string_view.h b/gdbsupport/gdb_string_view.h
index 26a3a9f0910..cf7af623327 100644
--- a/gdbsupport/gdb_string_view.h
+++ b/gdbsupport/gdb_string_view.h
@@ -556,7 +556,7 @@ namespace gdb {
 namespace gdb {
 
 static inline std::string
-to_string(const gdb::string_view &view)
+to_string(const std::string_view &view)
 {
   return { view.data (), view.size () };
 }
-- 
2.34.1


^ permalink raw reply	[flat|nested] 39+ messages in thread

* [COMMITTED PATCH v2 5/9] gdb: Remove uses of gdb::to_string (const std::string_view &)
  2023-10-28 20:48       ` Lancelot SIX
                           ` (4 preceding siblings ...)
  2023-11-21 12:04         ` [COMMITTED PATCH v2 4/9] gdb: Use std::string_view instead of gdb::string_view Lancelot Six
@ 2023-11-21 12:04         ` Lancelot Six
  2023-11-21 12:04         ` [COMMITTED PATCH v2 6/9] gdbsupport: Remove gdb::string_view Lancelot Six
                           ` (3 subsequent siblings)
  9 siblings, 0 replies; 39+ messages in thread
From: Lancelot Six @ 2023-11-21 12:04 UTC (permalink / raw)
  To: gdb-patches; +Cc: pedro, tom, Lancelot Six

This patch removes all uses of to_string(const std::string_view&) and
use the std::string ctor or implicit conversion from std::string_view to
std::string instead.

A later patch will remove this gdb::to_string while removing
gdbsupport/gdb_string_view.h.

Change-Id: I877cde557a0727be7b0435107e3c7a2aac165895
Approved-By: Tom Tromey <tom@tromey.com>
Approved-By: Pedro Alves <pedro@palves.net>
---
 gdb/ada-lang.c           | 21 +++++++++------------
 gdb/amdgpu-tdep.c        | 19 +++++++++----------
 gdb/debuginfod-support.c |  4 +---
 gdb/dwarf2/read.c        |  3 +--
 gdb/eval.c               |  1 -
 gdb/solib-rocm.c         |  9 ++++-----
 6 files changed, 24 insertions(+), 33 deletions(-)

diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 843583ecb40..ff7222c7eed 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -58,7 +58,6 @@
 #include "gdbsupport/function-view.h"
 #include "gdbsupport/byte-vector.h"
 #include "gdbsupport/selftest.h"
-#include "gdbsupport/gdb_string_view.h"
 #include <algorithm>
 #include "ada-exp.h"
 #include "charset.h"
@@ -1041,7 +1040,7 @@ ada_fold_name (std::string_view name, bool throw_on_error = false)
   static std::string fold_storage;
 
   if (!name.empty () && name[0] == '\'')
-    fold_storage = gdb::to_string (name.substr (1, name.size () - 2));
+    fold_storage = name.substr (1, name.size () - 2);
   else
     {
       /* Why convert to UTF-32 and implement our own case-folding,
@@ -1082,12 +1081,12 @@ ada_fold_name (std::string_view name, bool throw_on_error = false)
 	      warned = true;
 	      warning (_("could not convert '%s' from the host encoding (%s) to UTF-32.\n"
 			 "This normally should not happen, please file a bug report."),
-		       gdb::to_string (name).c_str (), host_charset ());
+		       std::string (name).c_str (), host_charset ());
 	    }
 
 	  /* We don't try to recover from errors; just return the
 	     original string.  */
-	  fold_storage = gdb::to_string (name);
+	  fold_storage = name;
 	  return fold_storage.c_str ();
 	}
 
@@ -1136,12 +1135,12 @@ ada_fold_name (std::string_view name, bool throw_on_error = false)
 	      warned = true;
 	      warning (_("could not convert the lower-cased variant of '%s'\n"
 			 "from UTF-32 to the host encoding (%s)."),
-		       gdb::to_string (name).c_str (), host_charset ());
+		       std::string (name).c_str (), host_charset ());
 	    }
 
 	  /* We don't try to recover from errors; just return the
 	     original string.  */
-	  fold_storage = gdb::to_string (name);
+	  fold_storage = name;
 	}
     }
 
@@ -13256,11 +13255,9 @@ ada_lookup_name_info::ada_lookup_name_info (const lookup_name_info &lookup_name)
   if (!user_name.empty () && user_name[0] == '<')
     {
       if (user_name.back () == '>')
-	m_encoded_name
-	  = gdb::to_string (user_name.substr (1, user_name.size () - 2));
+	m_encoded_name = user_name.substr (1, user_name.size () - 2);
       else
-	m_encoded_name
-	  = gdb::to_string (user_name.substr (1, user_name.size () - 1));
+	m_encoded_name = user_name.substr (1, user_name.size () - 1);
       m_encoded_p = true;
       m_verbatim_p = true;
       m_wild_match_p = false;
@@ -13277,10 +13274,10 @@ ada_lookup_name_info::ada_lookup_name_info (const lookup_name_info &lookup_name)
 	  const char *folded = ada_fold_name (user_name);
 	  m_encoded_name = ada_encode_1 (folded, false);
 	  if (m_encoded_name.empty ())
-	    m_encoded_name = gdb::to_string (user_name);
+	    m_encoded_name = user_name;
 	}
       else
-	m_encoded_name = gdb::to_string (user_name);
+	m_encoded_name = user_name;
 
       /* Handle the 'package Standard' special case.  See description
 	 of m_standard_p.  */
diff --git a/gdb/amdgpu-tdep.c b/gdb/amdgpu-tdep.c
index 58d26fc0b6b..15f32885b07 100644
--- a/gdb/amdgpu-tdep.c
+++ b/gdb/amdgpu-tdep.c
@@ -27,7 +27,6 @@
 #include "frame-unwind.h"
 #include "gdbarch.h"
 #include "gdbsupport/selftest.h"
-#include "gdbsupport/gdb_string_view.h"
 #include "gdbtypes.h"
 #include "inferior.h"
 #include "objfiles.h"
@@ -402,7 +401,7 @@ parse_amd_dbgapi_register_type_enum_fields
       if (value > std::numeric_limits<uint32_t>::max ())
 	enum_type.set_bit_size (64);
 
-      enum_type.add_enumerator (gdb::to_string (name), value);
+      enum_type.add_enumerator (std::string (name), value);
 
       fields = fields.substr (matches[0].rm_eo);
     }
@@ -446,7 +445,7 @@ parse_amd_dbgapi_register_type_flags_fields
       ULONGEST pos_begin = try_strtoulst (pos_begin_str);
 
       if (field_type_str == "bool")
-	flags_type.add_field (gdb::to_string (field_name), pos_begin, pos_begin,
+	flags_type.add_field (std::string (field_name), pos_begin, pos_begin,
 			      nullptr);
       else
 	{
@@ -457,7 +456,7 @@ parse_amd_dbgapi_register_type_flags_fields
 	  ULONGEST pos_end = try_strtoulst (pos_end_str.substr (1));
 	  const amd_dbgapi_register_type &field_type
 	    = parse_amd_dbgapi_register_type (field_type_str, type_map);
-	  flags_type.add_field (gdb::to_string (field_name), pos_begin, pos_end,
+	  flags_type.add_field (std::string (field_name), pos_begin, pos_end,
 				&field_type);
 	}
 
@@ -471,7 +470,7 @@ static const amd_dbgapi_register_type &
 parse_amd_dbgapi_register_type_scalar (std::string_view name,
 				       amd_dbgapi_register_type_map &type_map)
 {
-  std::string name_str = gdb::to_string (name);
+  std::string name_str (name);
   auto it = type_map.find (name_str);
   if (it != type_map.end ())
     {
@@ -534,7 +533,7 @@ parse_amd_dbgapi_register_type (std::string_view type_str,
       std::string_view count_str_view
 	= type_str.substr (pos_open_bracket + 1,
 			    pos_close_bracket - pos_open_bracket);
-      std::string count_str = gdb::to_string (count_str_view);
+      std::string count_str (count_str_view);
       unsigned int count = std::stoul (count_str);
 
       std::string lookup_name
@@ -580,7 +579,7 @@ parse_amd_dbgapi_register_type (std::string_view type_str,
 	  /* No braces, lookup existing type.  */
 	  if (existing_type_it == type_map.end ())
 	    error (_("reference to unknown type %s."),
-		   gdb::to_string (name).c_str ());
+		   std::string (name).c_str ());
 
 	  if (existing_type_it->second->kind ()
 	      != amd_dbgapi_register_type::kind::FLAGS)
@@ -593,7 +592,7 @@ parse_amd_dbgapi_register_type (std::string_view type_str,
 	  /* With braces, it's a definition.  */
 	  if (existing_type_it != type_map.end ())
 	    error (_("re-definition of type %s."),
-		   gdb::to_string (name).c_str ());
+		   std::string (name).c_str ());
 
 	  amd_dbgapi_register_type_flags_up flags_type
 	    (new amd_dbgapi_register_type_flags (bit_size, name));
@@ -632,7 +631,7 @@ parse_amd_dbgapi_register_type (std::string_view type_str,
 	  /* No braces, lookup existing type.  */
 	  if (existing_type_it == type_map.end ())
 	    error (_("reference to unknown type %s"),
-		   gdb::to_string (name).c_str ());
+		   std::string (name).c_str ());
 
 	  if (existing_type_it->second->kind ()
 	      != amd_dbgapi_register_type::kind::ENUM)
@@ -645,7 +644,7 @@ parse_amd_dbgapi_register_type (std::string_view type_str,
 	  /* With braces, it's a definition.  */
 	  if (existing_type_it != type_map.end ())
 	    error (_("re-definition of type %s"),
-		   gdb::to_string (name).c_str ());
+		   std::string (name).c_str ());
 
 	  amd_dbgapi_register_type_enum_up enum_type
 	    (new amd_dbgapi_register_type_enum (name));
diff --git a/gdb/debuginfod-support.c b/gdb/debuginfod-support.c
index a989eb9cb97..eb88c406ad6 100644
--- a/gdb/debuginfod-support.c
+++ b/gdb/debuginfod-support.c
@@ -20,7 +20,6 @@
 #include "diagnostics.h"
 #include <errno.h>
 #include "gdbsupport/scoped_fd.h"
-#include "gdbsupport/gdb_string_view.h"
 #include "debuginfod-support.h"
 #include <optional>
 #include "cli/cli-cmds.h"
@@ -265,8 +264,7 @@ debuginfod_is_enabled ()
 	  gdb_printf
 	    (_("  <%ps>\n"),
 	     styled_string (file_name_style.style (),
-			    gdb::to_string (url_view.substr (0,
-							     off)).c_str ()));
+			    std::string (url_view.substr (0, off)).c_str ()));
 	  if (off == std::string_view::npos)
 	    break;
 	  url_view = url_view.substr (off);
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index a16139dad1e..ccf9f18b31b 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -96,7 +96,6 @@
 #include "split-name.h"
 #include "gdbsupport/parallel-for.h"
 #include "gdbsupport/thread-pool.h"
-#include "gdbsupport/gdb_string_view.h"
 
 /* When == 1, print basic high level tracing messages.
    When > 1, be more verbose.
@@ -16770,7 +16769,7 @@ cooked_index_functions::expand_symtabs_matching
     {
       std::vector<std::string_view> name_vec
 	= lookup_name_without_params.split_name (lang);
-      std::string last_name = gdb::to_string (name_vec.back ());
+      std::string last_name (name_vec.back ());
 
       for (const cooked_index_entry *entry : table->find (last_name,
 							  completing))
diff --git a/gdb/eval.c b/gdb/eval.c
index 8664d4980b7..3358b0d8d32 100644
--- a/gdb/eval.c
+++ b/gdb/eval.c
@@ -37,7 +37,6 @@
 #include "user-regs.h"
 #include "valprint.h"
 #include "gdbsupport/gdb_obstack.h"
-#include "gdbsupport/gdb_string_view.h"
 #include "objfiles.h"
 #include "typeprint.h"
 #include <ctype.h>
diff --git a/gdb/solib-rocm.c b/gdb/solib-rocm.c
index 9ceb7a922e3..0384e52d58a 100644
--- a/gdb/solib-rocm.c
+++ b/gdb/solib-rocm.c
@@ -31,7 +31,6 @@
 #include "solib-svr4.h"
 #include "solist.h"
 #include "symfile.h"
-#include "gdbsupport/gdb_string_view.h"
 
 #include <unordered_map>
 
@@ -440,7 +439,7 @@ rocm_bfd_iovec_open (bfd *abfd, inferior *inferior)
   std::string_view uri (bfd_get_filename (abfd));
   std::string_view protocol_delim = "://";
   size_t protocol_end = uri.find (protocol_delim);
-  std::string protocol = gdb::to_string (uri.substr (0, protocol_end));
+  std::string protocol (uri.substr (0, protocol_end));
   protocol_end += protocol_delim.length ();
 
   std::transform (protocol.begin (), protocol.end (), protocol.begin (),
@@ -463,7 +462,7 @@ rocm_bfd_iovec_open (bfd *abfd, inferior *inferior)
 	&& std::isxdigit (path[i + 2]))
       {
 	std::string_view hex_digits = path.substr (i + 1, 2);
-	decoded_path += std::stoi (gdb::to_string (hex_digits), 0, 16);
+	decoded_path += std::stoi (std::string (hex_digits), 0, 16);
 	i += 2;
       }
     else
@@ -549,7 +548,7 @@ rocm_bfd_iovec_open (bfd *abfd, inferior *inferior)
 	  if (pid != inferior->pid)
 	    {
 	      warning (_("`%s': code object is from another inferior"),
-		       gdb::to_string (uri).c_str ());
+		       std::string (uri).c_str ());
 	      bfd_set_error (bfd_error_bad_value);
 	      return nullptr;
 	    }
@@ -566,7 +565,7 @@ rocm_bfd_iovec_open (bfd *abfd, inferior *inferior)
 	}
 
       warning (_("`%s': protocol not supported: %s"),
-	       gdb::to_string (uri).c_str (), protocol.c_str ());
+	       std::string (uri).c_str (), protocol.c_str ());
       bfd_set_error (bfd_error_bad_value);
       return nullptr;
     }
-- 
2.34.1


^ permalink raw reply	[flat|nested] 39+ messages in thread

* [COMMITTED PATCH v2 6/9] gdbsupport: Remove gdb::string_view
  2023-10-28 20:48       ` Lancelot SIX
                           ` (5 preceding siblings ...)
  2023-11-21 12:04         ` [COMMITTED PATCH v2 5/9] gdb: Remove uses of gdb::to_string (const std::string_view &) Lancelot Six
@ 2023-11-21 12:04         ` Lancelot Six
  2023-11-21 12:04         ` [COMMITTED PATCH v2 7/9] gdbsupport: Replace gdb::invoke_result with std::invoke_result Lancelot Six
                           ` (2 subsequent siblings)
  9 siblings, 0 replies; 39+ messages in thread
From: Lancelot Six @ 2023-11-21 12:04 UTC (permalink / raw)
  To: gdb-patches; +Cc: pedro, tom, Lancelot Six

Now that all places using gdb::string_view have been updated to use
std::string_view, this patch drops the gdb::string_view implementation
and the tests which came with it.

As this drops the unittests/string_view-selftests.c, this also
implicitly solves PR build/23676, as pointed-out by Tom Tromey.

Change-Id: Idf5479b09e0ac536917b3f0e13aca48424b90df0
Approved-By: Tom Tromey <tom@tromey.com>
Approved-By: Pedro Alves <pedro@palves.net>
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=23676
---
 gdb/Makefile.in                               |   1 -
 gdb/unittests/basic_string_view/capacity/1.cc | 172 ------
 .../basic_string_view/capacity/empty_neg.cc   |  28 -
 .../basic_string_view/cons/char/1.cc          |  67 ---
 .../basic_string_view/cons/char/2.cc          |  46 --
 .../basic_string_view/cons/char/3.cc          |  39 --
 .../basic_string_view/cons/wchar_t/1.cc       |  68 ---
 .../basic_string_view/cons/wchar_t/2.cc       |  45 --
 .../basic_string_view/cons/wchar_t/3.cc       |  38 --
 .../element_access/char/1.cc                  |  70 ---
 .../element_access/char/2.cc                  |  30 -
 .../element_access/char/empty.cc              |  39 --
 .../element_access/char/front_back.cc         |  43 --
 .../element_access/wchar_t/1.cc               |  71 ---
 .../element_access/wchar_t/2.cc               |  32 -
 .../element_access/wchar_t/empty.cc           |  38 --
 .../element_access/wchar_t/front_back.cc      |  42 --
 gdb/unittests/basic_string_view/include.cc    |  25 -
 .../basic_string_view/inserters/char/1.cc     |  65 --
 .../basic_string_view/inserters/char/2.cc     |  91 ---
 .../basic_string_view/inserters/char/3.cc     |  54 --
 .../inserters/pod/10081-out.cc                |  75 ---
 .../basic_string_view/inserters/wchar_t/1.cc  |  70 ---
 .../basic_string_view/inserters/wchar_t/2.cc  |  91 ---
 .../basic_string_view/inserters/wchar_t/3.cc  |  53 --
 .../basic_string_view/literals/types.cc       |  45 --
 .../basic_string_view/literals/values.cc      |  72 ---
 .../modifiers/remove_prefix/char/1.cc         |  66 --
 .../modifiers/remove_prefix/wchar_t/1.cc      |  61 --
 .../modifiers/remove_suffix/char/1.cc         |  66 --
 .../modifiers/remove_suffix/wchar_t/1.cc      |  61 --
 .../modifiers/swap/char/1.cc                  |  36 --
 .../modifiers/swap/wchar_t/1.cc               |  35 --
 .../operations/compare/char/1.cc              | 132 ----
 .../operations/compare/char/13650.cc          |  50 --
 .../operations/compare/char/2.cc              |  30 -
 .../operations/compare/char/70483.cc          |  89 ---
 .../operations/compare/wchar_t/1.cc           | 133 ----
 .../operations/compare/wchar_t/13650.cc       |  49 --
 .../operations/compare/wchar_t/2.cc           |  30 -
 .../operations/copy/char/1.cc                 |  46 --
 .../operations/copy/wchar_t/1.cc              |  46 --
 .../operations/data/char/1.cc                 |  44 --
 .../operations/data/wchar_t/1.cc              |  43 --
 .../operations/find/char/1.cc                 | 168 ------
 .../operations/find/char/2.cc                 | 166 -----
 .../operations/find/char/3.cc                 | 166 -----
 .../operations/find/char/4.cc                 |  45 --
 .../operations/find/wchar_t/1.cc              | 163 -----
 .../operations/find/wchar_t/2.cc              | 161 -----
 .../operations/find/wchar_t/3.cc              | 161 -----
 .../operations/find/wchar_t/4.cc              |  44 --
 .../operations/rfind/char/1.cc                |  95 ---
 .../operations/rfind/char/2.cc                |  53 --
 .../operations/rfind/char/3.cc                |  68 ---
 .../operations/rfind/wchar_t/1.cc             |  94 ---
 .../operations/rfind/wchar_t/2.cc             |  52 --
 .../operations/rfind/wchar_t/3.cc             |  66 --
 .../operations/string_conversion/1.cc         |  51 --
 .../operations/substr/char/1.cc               |  79 ---
 .../operations/substr/wchar_t/1.cc            |  79 ---
 .../basic_string_view/operators/char/2.cc     | 373 ------------
 .../basic_string_view/operators/wchar_t/2.cc  | 367 ------------
 .../basic_string_view/range_access/char/1.cc  |  47 --
 .../range_access/wchar_t/1.cc                 |  47 --
 .../requirements/explicit_instantiation/1.cc  |  26 -
 .../explicit_instantiation/char/1.cc          |  23 -
 .../explicit_instantiation/char16_t/1.cc      |  24 -
 .../explicit_instantiation/char32_t/1.cc      |  24 -
 .../explicit_instantiation/wchar_t/1.cc       |  23 -
 .../requirements/typedefs.cc                  |  47 --
 gdb/unittests/basic_string_view/typedefs.cc   |  36 --
 gdb/unittests/basic_string_view/types/1.cc    |  43 --
 gdb/unittests/string_view-selftests.c         | 193 ------
 gdbsupport/gdb_string_view.h                  | 566 ------------------
 gdbsupport/gdb_string_view.tcc                | 219 -------
 76 files changed, 6296 deletions(-)
 delete mode 100644 gdb/unittests/basic_string_view/capacity/1.cc
 delete mode 100644 gdb/unittests/basic_string_view/capacity/empty_neg.cc
 delete mode 100644 gdb/unittests/basic_string_view/cons/char/1.cc
 delete mode 100644 gdb/unittests/basic_string_view/cons/char/2.cc
 delete mode 100644 gdb/unittests/basic_string_view/cons/char/3.cc
 delete mode 100644 gdb/unittests/basic_string_view/cons/wchar_t/1.cc
 delete mode 100644 gdb/unittests/basic_string_view/cons/wchar_t/2.cc
 delete mode 100644 gdb/unittests/basic_string_view/cons/wchar_t/3.cc
 delete mode 100644 gdb/unittests/basic_string_view/element_access/char/1.cc
 delete mode 100644 gdb/unittests/basic_string_view/element_access/char/2.cc
 delete mode 100644 gdb/unittests/basic_string_view/element_access/char/empty.cc
 delete mode 100644 gdb/unittests/basic_string_view/element_access/char/front_back.cc
 delete mode 100644 gdb/unittests/basic_string_view/element_access/wchar_t/1.cc
 delete mode 100644 gdb/unittests/basic_string_view/element_access/wchar_t/2.cc
 delete mode 100644 gdb/unittests/basic_string_view/element_access/wchar_t/empty.cc
 delete mode 100644 gdb/unittests/basic_string_view/element_access/wchar_t/front_back.cc
 delete mode 100644 gdb/unittests/basic_string_view/include.cc
 delete mode 100644 gdb/unittests/basic_string_view/inserters/char/1.cc
 delete mode 100644 gdb/unittests/basic_string_view/inserters/char/2.cc
 delete mode 100644 gdb/unittests/basic_string_view/inserters/char/3.cc
 delete mode 100644 gdb/unittests/basic_string_view/inserters/pod/10081-out.cc
 delete mode 100644 gdb/unittests/basic_string_view/inserters/wchar_t/1.cc
 delete mode 100644 gdb/unittests/basic_string_view/inserters/wchar_t/2.cc
 delete mode 100644 gdb/unittests/basic_string_view/inserters/wchar_t/3.cc
 delete mode 100644 gdb/unittests/basic_string_view/literals/types.cc
 delete mode 100644 gdb/unittests/basic_string_view/literals/values.cc
 delete mode 100644 gdb/unittests/basic_string_view/modifiers/remove_prefix/char/1.cc
 delete mode 100644 gdb/unittests/basic_string_view/modifiers/remove_prefix/wchar_t/1.cc
 delete mode 100644 gdb/unittests/basic_string_view/modifiers/remove_suffix/char/1.cc
 delete mode 100644 gdb/unittests/basic_string_view/modifiers/remove_suffix/wchar_t/1.cc
 delete mode 100644 gdb/unittests/basic_string_view/modifiers/swap/char/1.cc
 delete mode 100644 gdb/unittests/basic_string_view/modifiers/swap/wchar_t/1.cc
 delete mode 100644 gdb/unittests/basic_string_view/operations/compare/char/1.cc
 delete mode 100644 gdb/unittests/basic_string_view/operations/compare/char/13650.cc
 delete mode 100644 gdb/unittests/basic_string_view/operations/compare/char/2.cc
 delete mode 100644 gdb/unittests/basic_string_view/operations/compare/char/70483.cc
 delete mode 100644 gdb/unittests/basic_string_view/operations/compare/wchar_t/1.cc
 delete mode 100644 gdb/unittests/basic_string_view/operations/compare/wchar_t/13650.cc
 delete mode 100644 gdb/unittests/basic_string_view/operations/compare/wchar_t/2.cc
 delete mode 100644 gdb/unittests/basic_string_view/operations/copy/char/1.cc
 delete mode 100644 gdb/unittests/basic_string_view/operations/copy/wchar_t/1.cc
 delete mode 100644 gdb/unittests/basic_string_view/operations/data/char/1.cc
 delete mode 100644 gdb/unittests/basic_string_view/operations/data/wchar_t/1.cc
 delete mode 100644 gdb/unittests/basic_string_view/operations/find/char/1.cc
 delete mode 100644 gdb/unittests/basic_string_view/operations/find/char/2.cc
 delete mode 100644 gdb/unittests/basic_string_view/operations/find/char/3.cc
 delete mode 100644 gdb/unittests/basic_string_view/operations/find/char/4.cc
 delete mode 100644 gdb/unittests/basic_string_view/operations/find/wchar_t/1.cc
 delete mode 100644 gdb/unittests/basic_string_view/operations/find/wchar_t/2.cc
 delete mode 100644 gdb/unittests/basic_string_view/operations/find/wchar_t/3.cc
 delete mode 100644 gdb/unittests/basic_string_view/operations/find/wchar_t/4.cc
 delete mode 100644 gdb/unittests/basic_string_view/operations/rfind/char/1.cc
 delete mode 100644 gdb/unittests/basic_string_view/operations/rfind/char/2.cc
 delete mode 100644 gdb/unittests/basic_string_view/operations/rfind/char/3.cc
 delete mode 100644 gdb/unittests/basic_string_view/operations/rfind/wchar_t/1.cc
 delete mode 100644 gdb/unittests/basic_string_view/operations/rfind/wchar_t/2.cc
 delete mode 100644 gdb/unittests/basic_string_view/operations/rfind/wchar_t/3.cc
 delete mode 100644 gdb/unittests/basic_string_view/operations/string_conversion/1.cc
 delete mode 100644 gdb/unittests/basic_string_view/operations/substr/char/1.cc
 delete mode 100644 gdb/unittests/basic_string_view/operations/substr/wchar_t/1.cc
 delete mode 100644 gdb/unittests/basic_string_view/operators/char/2.cc
 delete mode 100644 gdb/unittests/basic_string_view/operators/wchar_t/2.cc
 delete mode 100644 gdb/unittests/basic_string_view/range_access/char/1.cc
 delete mode 100644 gdb/unittests/basic_string_view/range_access/wchar_t/1.cc
 delete mode 100644 gdb/unittests/basic_string_view/requirements/explicit_instantiation/1.cc
 delete mode 100644 gdb/unittests/basic_string_view/requirements/explicit_instantiation/char/1.cc
 delete mode 100644 gdb/unittests/basic_string_view/requirements/explicit_instantiation/char16_t/1.cc
 delete mode 100644 gdb/unittests/basic_string_view/requirements/explicit_instantiation/char32_t/1.cc
 delete mode 100644 gdb/unittests/basic_string_view/requirements/explicit_instantiation/wchar_t/1.cc
 delete mode 100644 gdb/unittests/basic_string_view/requirements/typedefs.cc
 delete mode 100644 gdb/unittests/basic_string_view/typedefs.cc
 delete mode 100644 gdb/unittests/basic_string_view/types/1.cc
 delete mode 100644 gdb/unittests/string_view-selftests.c
 delete mode 100644 gdbsupport/gdb_string_view.h
 delete mode 100644 gdbsupport/gdb_string_view.tcc

diff --git a/gdb/Makefile.in b/gdb/Makefile.in
index 714564f27b4..a50628e8ed0 100644
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -482,7 +482,6 @@ SELFTESTS_SRCS = \
 	unittests/scoped_mmap-selftests.c \
 	unittests/scoped_restore-selftests.c \
 	unittests/search-memory-selftests.c \
-	unittests/string_view-selftests.c \
 	unittests/style-selftests.c \
 	unittests/tracepoint-selftests.c \
 	unittests/tui-selftests.c \
diff --git a/gdb/unittests/basic_string_view/capacity/1.cc b/gdb/unittests/basic_string_view/capacity/1.cc
deleted file mode 100644
index 12470a98279..00000000000
--- a/gdb/unittests/basic_string_view/capacity/1.cc
+++ /dev/null
@@ -1,172 +0,0 @@
-// { dg-options "-std=gnu++17" }
-
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-// string_view size, length
-
-namespace capacity_1 {
-
-template<typename T>
-  struct A { };
-
-template<typename T>
-  bool
-  operator==(const A<T>&, const A<T>&) { return true; }
-
-template<typename T>
-  bool
-  operator<(const A<T>&, const A<T>&) { return true; }
-
-struct B { };
-
-} // namespace capacity_1
-} // namespace string_view
-} // namespace selftests
-
-// char_traits specialization
-namespace std
-{
-  template<>
-    struct char_traits<selftests::string_view::capacity_1::A<
-	selftests::string_view::capacity_1::B> >
-    {
-      typedef selftests::string_view::capacity_1::A<
-	  selftests::string_view::capacity_1::B> char_type;
-      // Unsigned as wint_t in unsigned.
-      typedef unsigned long  	int_type;
-      typedef streampos 	pos_type;
-      typedef streamoff 	off_type;
-      typedef mbstate_t 	state_type;
-      
-      static void 
-      assign(char_type& __c1, const char_type& __c2)
-      { __c1 = __c2; }
-
-      static bool 
-      eq(const char_type& __c1, const char_type& __c2)
-      { return __c1 == __c2; }
-
-      static bool 
-      lt(const char_type& __c1, const char_type& __c2)
-      { return __c1 < __c2; }
-
-      static int 
-      compare(const char_type* __s1, const char_type* __s2, size_t __n)
-      { 
-	for (size_t __i = 0; __i < __n; ++__i)
-	  if (!eq(__s1[__i], __s2[__i]))
-	    return lt(__s1[__i], __s2[__i]) ? -1 : 1;
-	return 0; 
-      }
-
-      static size_t
-      length(const char_type* __s)
-      { 
-	const char_type* __p = __s; 
-	while (__p) 
-	  ++__p; 
-	return (__p - __s); 
-      }
-
-      static const char_type* 
-      find(const char_type* __s, size_t __n, const char_type& __a)
-      { 
-	for (const char_type* __p = __s; size_t(__p - __s) < __n; ++__p)
-	  if (*__p == __a) return __p;
-	return 0;
-      }
-
-      static char_type* 
-      move(char_type* __s1, const char_type* __s2, size_t __n)
-      { return (char_type*) memmove(__s1, __s2, __n * sizeof(char_type)); }
-
-      static char_type* 
-      copy(char_type* __s1, const char_type* __s2, size_t __n)
-      { return (char_type*) memcpy(__s1, __s2, __n * sizeof(char_type)); }
-
-      static char_type* 
-      assign(char_type* __s, size_t __n, char_type __a)
-      { 
-	for (char_type* __p = __s; __p < __s + __n; ++__p) 
-	  assign(*__p, __a);
-        return __s; 
-      }
-
-      static char_type 
-      to_char_type(const int_type&)
-      { return char_type(); }
-
-      static int_type 
-      to_int_type(const char_type&) { return int_type(); }
-
-      static bool 
-      eq_int_type(const int_type& __c1, const int_type& __c2)
-      { return __c1 == __c2; }
-
-      static int_type 
-      eof() { return static_cast<int_type>(-1); }
-
-      static int_type 
-      not_eof(const int_type& __c)
-      { return eq_int_type(__c, eof()) ? int_type(0) : __c; }
-    };
-} // namespace std
-
-namespace selftests {
-namespace string_view {
-namespace capacity_1 {
-
-static void
-test01 ()
-{
-  gdb::basic_string_view<A<B>> str02;
-  typedef gdb::basic_string_view< A<B> >::size_type size_type_o;
-  size_type_o sz03;
-  size_type_o sz04;
-
-  // non-POD types: size, length, max_size, empty()
-  bool b01 = str02.empty();  
-  VERIFY( b01 == true );
-  sz03 = str02.size();
-  sz04 = str02.length();
-  VERIFY( sz03 == sz04 );
-  str02.data();
-  sz03 = str02.size();
-  sz04 = str02.length();
-  VERIFY( sz03 == sz04 );
-
-  sz03 = str02.max_size();  
-  VERIFY( sz03 >= sz04 );
-
-  sz03 = str02.size();
-  str02 = {};
-  b01 = str02.empty(); 
-  VERIFY( b01 == true );
-  sz04 = str02.size();  
-  VERIFY( sz03 >= sz04 );
-}
-
-static int
-main()
-{
-  test01();
-
-  return 0;
-}
-
-} // namespace capacity_1
diff --git a/gdb/unittests/basic_string_view/capacity/empty_neg.cc b/gdb/unittests/basic_string_view/capacity/empty_neg.cc
deleted file mode 100644
index 4cb1beac5a6..00000000000
--- a/gdb/unittests/basic_string_view/capacity/empty_neg.cc
+++ /dev/null
@@ -1,28 +0,0 @@
-// Copyright (C) 2017-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-// { dg-options "-std=gnu++17" }
-// { dg-do compile { target c++17 } }
-
-#include <string_view>
-
-void
-test01()
-{
-  std::string_view s;
-  s.empty();  // { dg-warning "ignoring return value" }
-}
diff --git a/gdb/unittests/basic_string_view/cons/char/1.cc b/gdb/unittests/basic_string_view/cons/char/1.cc
deleted file mode 100644
index b27f999e429..00000000000
--- a/gdb/unittests/basic_string_view/cons/char/1.cc
+++ /dev/null
@@ -1,67 +0,0 @@
-// { dg-options "-std=gnu++17" }
-
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-// basic_string_view constructors.
-
-namespace cons_1 {
-
-static void
-test01 ()
-{
-  typedef gdb::string_view::size_type csize_type;
-
-  // basic_string_view()
-  const gdb::string_view str00{};
-  VERIFY( str00.length() == 0 );
-  VERIFY( str00.data() == nullptr );
-
-  // basic_string_view(const char*)
-  const char str_lit01[] = "rodeo beach, marin";
-  const gdb::string_view str01{str_lit01};
-  VERIFY( str01.length() == 18 );
-  VERIFY( str01.data() == str_lit01 );
-  const gdb::string_view str02{"baker beach, san francisco"};
-  VERIFY( str02.length() == 26 );
-
-  // basic_string_view(const string_view&)
-  gdb::string_view str04{str01};
-  VERIFY( str04.length() == str01.length() );
-  VERIFY( str04.data() == str01.data() );
-
-  // basic_string_view(const char* s)
-  csize_type len_lit01 = strlen(str_lit01);
-  gdb::string_view str05{str_lit01, len_lit01};
-  VERIFY( str05.length() == len_lit01 );
-  VERIFY( str05.data() == str_lit01 );
-
-  // basic_string_view(basic_string& s)
-  std::string istr07(10, 'z');
-  gdb::string_view str07{istr07};
-  VERIFY( str07.length() == 10 );
-}
-
-static int
-main ()
-{ 
-  test01();
-
-  return 0;
-}
-
-} // namespace cons_1
diff --git a/gdb/unittests/basic_string_view/cons/char/2.cc b/gdb/unittests/basic_string_view/cons/char/2.cc
deleted file mode 100644
index 22a7916c9e3..00000000000
--- a/gdb/unittests/basic_string_view/cons/char/2.cc
+++ /dev/null
@@ -1,46 +0,0 @@
-// { dg-options "-std=gnu++17" }
-
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-// basic_string_view constructors.
-
-namespace cons_2 {
-
-static void
-test03 ()
-{
-  const char* with_nulls = "This contains \0 a zero byte.";
-
-  // These are tests to see how basic_string_view handles data with NUL
-  // bytes.  Obviously basic_string_view(char*) will halt at the first one, but
-  // nothing else should.
-  gdb::string_view s1(with_nulls, 28);
-  VERIFY( s1.size() == 28 );
-  gdb::string_view s2(s1);
-  VERIFY( s2.size() == 28 );
-}
-
-static int
-main ()
-{ 
-  test03();
-
-  return 0;
-}
-
-} // namespace cons_2
diff --git a/gdb/unittests/basic_string_view/cons/char/3.cc b/gdb/unittests/basic_string_view/cons/char/3.cc
deleted file mode 100644
index ab98b0b70a4..00000000000
--- a/gdb/unittests/basic_string_view/cons/char/3.cc
+++ /dev/null
@@ -1,39 +0,0 @@
-// { dg-options "-std=gnu++17" }
-
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-// basic_string_view constructors.
-
-namespace cons_3 {
-
-static void
-test05 ()
-{
-  char const * s = 0;
-  gdb::string_view zero_length_built_with_NULL(s, 0);
-}
-
-static int
-main ()
-{ 
-  test05();
-
-  return 0;
-}
-
-} // namespace cons_3
diff --git a/gdb/unittests/basic_string_view/cons/wchar_t/1.cc b/gdb/unittests/basic_string_view/cons/wchar_t/1.cc
deleted file mode 100644
index 8a1599c5b81..00000000000
--- a/gdb/unittests/basic_string_view/cons/wchar_t/1.cc
+++ /dev/null
@@ -1,68 +0,0 @@
-// { dg-options "-std=gnu++17" }
-
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-// basic_string_view constructors.
-
-#include <string_view>
-#include <string>
-#include <cwchar>
-#include <testsuite_hooks.h>
-
-void
-test01()
-{
-  typedef std::wstring_view::size_type csize_type;
-
-  // basic_string_view()
-  const std::wstring_view str00{};
-  VERIFY( str00.length() == 0 );
-  VERIFY( str00.data() == nullptr );
-
-  // basic_string_view(const char*)
-  const wchar_t str_lit01[] = L"rodeo beach, marin";
-  const std::wstring_view str01{str_lit01};
-  VERIFY( str01.length() == 18 );
-  VERIFY( str01.data() == str_lit01 );
-  const std::wstring_view str02{L"baker beach, san francisco"};
-  VERIFY( str02.length() == 26 );
-
-  // basic_string_view(const string_view&)
-  std::wstring_view str04{str01};
-  VERIFY( str04.length() == str01.length() );
-  VERIFY( str04.data() == str01.data() );
-
-  // basic_string_view(const char* s)
-  csize_type len_lit01 = wcslen(str_lit01);
-  std::wstring_view str05{str_lit01, len_lit01};
-  VERIFY( str05.length() == len_lit01 );
-  VERIFY( str05.data() == str_lit01 );
-
-  // basic_string_view(basic_string& s)
-  std::wstring istr07(10, L'z');
-  std::wstring_view str07{istr07};
-  VERIFY( str07.length() == 10 );
-}
-
-int
-main()
-{ 
-  test01();
-
-  return 0;
-}
diff --git a/gdb/unittests/basic_string_view/cons/wchar_t/2.cc b/gdb/unittests/basic_string_view/cons/wchar_t/2.cc
deleted file mode 100644
index 54a7fe509bb..00000000000
--- a/gdb/unittests/basic_string_view/cons/wchar_t/2.cc
+++ /dev/null
@@ -1,45 +0,0 @@
-// { dg-options "-std=gnu++17" }
-
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-// basic_string_view constructors.
-
-#include <string_view>
-#include <testsuite_hooks.h>
-
-void
-test03()
-{
-  const wchar_t* with_nulls = L"This contains \0 a zero byte.";
-
-  // These are tests to see how basic_string_view handles data with NUL
-  // bytes.  Obviously basic_string_view(char*) will halt at the first one, but
-  // nothing else should.
-  std::wstring_view s1 (with_nulls, 28);
-  VERIFY( s1.size() == 28 );
-  std::wstring_view s2 (s1);
-  VERIFY( s2.size() == 28 );
-}
-
-int
-main()
-{ 
-  test03();
-
-  return 0;
-}
diff --git a/gdb/unittests/basic_string_view/cons/wchar_t/3.cc b/gdb/unittests/basic_string_view/cons/wchar_t/3.cc
deleted file mode 100644
index 540683f5421..00000000000
--- a/gdb/unittests/basic_string_view/cons/wchar_t/3.cc
+++ /dev/null
@@ -1,38 +0,0 @@
-// { dg-options "-std=gnu++17" }
-
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-// basic_string_view constructors.
-
-#include <string_view>
-#include <testsuite_hooks.h>
-
-void
-test05()
-{
-  wchar_t const * s = 0;
-  std::wstring_view zero_length_built_with_NULL(s, 0);
-}
-
-int
-main()
-{ 
-  test05();
-
-  return 0;
-}
diff --git a/gdb/unittests/basic_string_view/element_access/char/1.cc b/gdb/unittests/basic_string_view/element_access/char/1.cc
deleted file mode 100644
index 788d174d852..00000000000
--- a/gdb/unittests/basic_string_view/element_access/char/1.cc
+++ /dev/null
@@ -1,70 +0,0 @@
-// { dg-options "-std=gnu++17" }
-
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-// basic_string element access
-
-namespace element_access_1 {
-
-static void
-test01 ()
-{
-  typedef gdb::string_view::size_type csize_type;
-  typedef gdb::string_view::const_reference cref;
-  typedef gdb::string_view::reference ref;
-  csize_type csz01;
-
-  const gdb::string_view str01("tamarindo, costa rica");
-  gdb::string_view str02("41st street beach, capitola, california");
-  gdb::string_view str03;
-
-  // const_reference operator[] (size_type pos) const;
-  csz01 = str01.size();
-  cref cref1 = str01[csz01 - 1];
-  VERIFY( cref1 == 'a' );
-  // Undefined behavior at size().
-  //cref cref2 = str01[csz01];
-  //VERIFY( cref2 == char() );
-
-  // const_reference at(size_type pos) const;
-  csz01 = str01.size();
-  cref cref3 = str01.at(csz01 - 1);
-  VERIFY( cref3 == 'a' );
-  try
-  {
-    str01.at(csz01);
-    VERIFY( false ); // Should not get here, as exception thrown.
-  }
-  catch (gdb_exception& fail)
-  {
-    VERIFY( true );
-  }
-  catch (...)
-  {
-    VERIFY( false );
-  }
-}
-
-static int
-main ()
-{ 
-  test01();
-  return 0;
-}
-
-} // namespace element_access_1
diff --git a/gdb/unittests/basic_string_view/element_access/char/2.cc b/gdb/unittests/basic_string_view/element_access/char/2.cc
deleted file mode 100644
index 938916e2924..00000000000
--- a/gdb/unittests/basic_string_view/element_access/char/2.cc
+++ /dev/null
@@ -1,30 +0,0 @@
-// { dg-do run { xfail *-*-* } }
-// { dg-options "-std=gnu++17 -O0" }
-// { dg-require-debug-mode "" }
-
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-#include <string_view>
-
-int
-main()
-{
-  typedef std::string_view string_view_type;
-  string_view_type s;
-  s[0]; // abort
-}
diff --git a/gdb/unittests/basic_string_view/element_access/char/empty.cc b/gdb/unittests/basic_string_view/element_access/char/empty.cc
deleted file mode 100644
index 030c96aa073..00000000000
--- a/gdb/unittests/basic_string_view/element_access/char/empty.cc
+++ /dev/null
@@ -1,39 +0,0 @@
-// { dg-options "-std=gnu++17" }
-
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-//
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-//
-
-namespace element_access_empty {
-
-static int
-main ()
-{
-  {
-    gdb::string_view empty;
-    VERIFY( empty.empty() );
-  }
-
-  {
-    const gdb::string_view empty;
-    VERIFY( empty.empty() );
-  }
-
-  return 0;
-}
-
-} // namespace element_access_empty
diff --git a/gdb/unittests/basic_string_view/element_access/char/front_back.cc b/gdb/unittests/basic_string_view/element_access/char/front_back.cc
deleted file mode 100644
index 7e767fc7910..00000000000
--- a/gdb/unittests/basic_string_view/element_access/char/front_back.cc
+++ /dev/null
@@ -1,43 +0,0 @@
-// { dg-options "-std=gnu++17" }
-// { dg-require-string-conversions "" }
-
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-namespace element_access_front_back {
-
-static void
-test01 ()
-{
-  gdb::string_view str("ramifications");
-  const gdb::string_view cstr("melodien");
-
-  VERIFY( str.front() == 'r' );
-  VERIFY( str.back() == 's' );
-  VERIFY( cstr.front() == 'm' );
-  VERIFY( cstr.back() == 'n' );
-}
-
-static int
-main ()
-{
-  test01();
-
-  return 0;
-}
-
-} // namespace element_access_front_back
diff --git a/gdb/unittests/basic_string_view/element_access/wchar_t/1.cc b/gdb/unittests/basic_string_view/element_access/wchar_t/1.cc
deleted file mode 100644
index 679772b4c57..00000000000
--- a/gdb/unittests/basic_string_view/element_access/wchar_t/1.cc
+++ /dev/null
@@ -1,71 +0,0 @@
-// { dg-options "-std=gnu++17" }
-
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-// basic_string_view element access
-
-#include <string_view>
-#include <stdexcept>
-#include <testsuite_hooks.h>
-
-void
-test01()
-{
-  typedef std::wstring_view::size_type csize_type;
-  typedef std::wstring_view::const_reference cref;
-  typedef std::wstring_view::reference ref;
-  csize_type csz01, csz02;
-
-  const std::wstring_view str01(L"tamarindo, costa rica");
-  std::wstring_view str02(L"41st street beach, capitola, california");
-  std::wstring_view str03;
-
-  // const_reference operator[] (size_type pos) const;
-  csz01 = str01.size();
-  cref cref1 = str01[csz01 - 1];
-  VERIFY( cref1 == L'a' );
-  // Undefined behavior at size().
-  //cref cref2 = str01[csz01];
-  //VERIFY( cref2 == wchar_t() );
-
-  // const_reference at(size_type pos) const;
-  csz01 = str01.size();
-  cref cref3 = str01.at(csz01 - 1);
-  VERIFY( cref3 == L'a' );
-  try
-  {
-    str01.at(csz01);
-    VERIFY( false ); // Should not get here, as exception thrown.
-  }
-  catch (std::out_of_range& fail)
-  {
-    VERIFY( true );
-  }
-  catch (...)
-  {
-    VERIFY( false );
-  }
-}
-
-int
-main()
-{ 
-  test01();
-
-  return 0;
-}
diff --git a/gdb/unittests/basic_string_view/element_access/wchar_t/2.cc b/gdb/unittests/basic_string_view/element_access/wchar_t/2.cc
deleted file mode 100644
index cdbc6a5e5a8..00000000000
--- a/gdb/unittests/basic_string_view/element_access/wchar_t/2.cc
+++ /dev/null
@@ -1,32 +0,0 @@
-// { dg-do run { xfail *-*-* } }
-// { dg-options "-std=gnu++17 -O0" }
-// { dg-require-debug-mode "" }
-
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-#include <string_view>
-
-// libstdc++/21674
-// NB: Should work without any inlining or optimizations (ie. -O0).
-int
-main()
-{
-  typedef std::wstring_view string_view_type;
-  string_view_type s;
-  s[0]; // abort
-}
diff --git a/gdb/unittests/basic_string_view/element_access/wchar_t/empty.cc b/gdb/unittests/basic_string_view/element_access/wchar_t/empty.cc
deleted file mode 100644
index f31d34aa42b..00000000000
--- a/gdb/unittests/basic_string_view/element_access/wchar_t/empty.cc
+++ /dev/null
@@ -1,38 +0,0 @@
-// { dg-options "-std=gnu++17" }
-
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-//
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-//
-
-#include <string_view>
-#include <testsuite_hooks.h>
-
-int
-main()
-{
-  {
-    std::wstring_view empty;
-    VERIFY( empty.empty() );
-  }
-
-  {
-    const std::wstring_view empty;
-    VERIFY( empty.empty() );
-  }
-
-  return 0;
-}
diff --git a/gdb/unittests/basic_string_view/element_access/wchar_t/front_back.cc b/gdb/unittests/basic_string_view/element_access/wchar_t/front_back.cc
deleted file mode 100644
index c17a08a45c7..00000000000
--- a/gdb/unittests/basic_string_view/element_access/wchar_t/front_back.cc
+++ /dev/null
@@ -1,42 +0,0 @@
-// { dg-options "-std=gnu++17" }
-// { dg-require-string-conversions "" }
-
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-#include <string_view>
-#include <testsuite_hooks.h>
-
-void
-test01()
-{
-  std::wstring_view str(L"ramifications");
-  const std::wstring_view cstr(L"melodien");
-
-  VERIFY( str.front() == L'r' );
-  VERIFY( str.back() == L's' );
-  VERIFY( cstr.front() == L'm' );
-  VERIFY( cstr.back() == L'n' );
-}
-
-int
-main()
-{
-  test01();
-
-  return 0;
-}
diff --git a/gdb/unittests/basic_string_view/include.cc b/gdb/unittests/basic_string_view/include.cc
deleted file mode 100644
index ef01b7c478c..00000000000
--- a/gdb/unittests/basic_string_view/include.cc
+++ /dev/null
@@ -1,25 +0,0 @@
-// -*- C++ -*-
-
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-// NB: This issue affected only debug-mode.
-
-// { dg-options "-std=gnu++17 -fno-rtti" }
-// { dg-do compile }
-
-#include <string_view>
diff --git a/gdb/unittests/basic_string_view/inserters/char/1.cc b/gdb/unittests/basic_string_view/inserters/char/1.cc
deleted file mode 100644
index e0a33bf13bd..00000000000
--- a/gdb/unittests/basic_string_view/inserters/char/1.cc
+++ /dev/null
@@ -1,65 +0,0 @@
-// { dg-options "-std=gnu++17" }
-
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-// inserters
-
-// NB: This file is predicated on sstreams, istreams, and ostreams
-// working, not to mention other major details like char_traits, and
-// all of the string_view class.
-
-#include <string_view>
-#include <stdexcept>
-#include <sstream>
-#include <fstream>
-#include <iostream>
-#include <testsuite_hooks.h>
-
-void
-test01()
-{
-  typedef std::string_view::size_type csize_type;
-  typedef std::string_view::const_reference cref;
-  typedef std::string_view::reference ref;
-
-  const std::string_view str01("sailing grand traverse bay\n"
-	       "\t\t\t    from Elk Rapids to the point reminds me of miles");
-    
-  // ostream& operator<<(ostream&, const basic_string_view&)
-  std::ostringstream ostrs01;
-  try 
-    {
-      ostrs01 << str01;
-      VERIFY( ostrs01.str() == str01 );
-    }
-  catch(std::exception& fail) 
-    {
-      VERIFY( false );
-    }
-  
-  std::string_view hello_world;
-  std::cout << hello_world;
-}
-
-int
-main()
-{ 
-  test01();
-
-  return 0;
-}
diff --git a/gdb/unittests/basic_string_view/inserters/char/2.cc b/gdb/unittests/basic_string_view/inserters/char/2.cc
deleted file mode 100644
index 840f52185df..00000000000
--- a/gdb/unittests/basic_string_view/inserters/char/2.cc
+++ /dev/null
@@ -1,91 +0,0 @@
-
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-// inserters
-
-// NB: This file is predicated on sstreams, ostreams
-// working, not to mention other major details like char_traits, and
-// all of the string_view class.
-
-// { dg-options "-std=gnu++17" }
-// { dg-require-fileio "" }
-
-namespace inserters_2 {
-
-// testing basic_filebuf::xsputn via stress testing with large string_views
-// based on a bug report libstdc++ 9
-// mode == out
-static void
-test05 (std::size_t size)
-{
-  bool test ATTRIBUTE_UNUSED = true;
-
-  const char filename[] = "inserters_extractors-2.txt";
-  const char fillc = 'f';
-  std::ofstream ofs(filename);
-  std::string str(size, fillc);
-  gdb::string_view strv{str};
-
-  // sanity checks
-  VERIFY( str.size() == size );
-  VERIFY( ofs.good() );
-
-  // stress test
-  ofs << str << std::endl;
-  if (!ofs.good()) 
-    test = false;
-
-  ofs << str << std::endl;
-  if (!ofs.good()) 
-    test = false;
-
-  VERIFY( str.size() == size );
-  VERIFY( ofs.good() );
-
-  ofs.close();
-
-  // sanity check on the written file
-  std::ifstream ifs(filename);
-  std::size_t count = 0;
-  char c;
-  while (count <= (2 * size) + 4)
-    {
-      ifs >> c;
-      if (ifs.good() && c == fillc)
-	{
-	  ++count;
-	  c = '0';
-	}
-      else 
-	break;
-    }
-
-  VERIFY( count == 2 * size );
-}
-
-static int
-main ()
-{
-  test05(1); 
-  test05(1000); 
-  test05(10000);
-
-  return 0;
-}
-
-} // namespace inserters_2
diff --git a/gdb/unittests/basic_string_view/inserters/char/3.cc b/gdb/unittests/basic_string_view/inserters/char/3.cc
deleted file mode 100644
index 43e3ae05ba7..00000000000
--- a/gdb/unittests/basic_string_view/inserters/char/3.cc
+++ /dev/null
@@ -1,54 +0,0 @@
-// { dg-options "-std=gnu++17" }
-
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-// inserters
-
-// NB: This file is predicated on sstreams, and ostreams
-// working, not to mention other major details like char_traits, and
-// all of the string_view class.
-
-#include <string_view>
-#include <sstream>
-#include <iomanip>
-#include <testsuite_hooks.h>
-
-// libstdc++/2830
-void
-test09()
-{
-  std::string_view foo{"peace\0\0\0& love"};
-
-  std::ostringstream oss1;
-  oss1 << foo;
-  VERIFY( oss1.str() == foo );
-
-  std::ostringstream oss2;
-  oss2.width(20);
-  oss2 << foo;
-  VERIFY( oss2.str() != foo );
-  VERIFY( oss2.str().size() == 20 );
-}
-
-int
-main()
-{ 
-  test09();
-
-  return 0;
-}
diff --git a/gdb/unittests/basic_string_view/inserters/pod/10081-out.cc b/gdb/unittests/basic_string_view/inserters/pod/10081-out.cc
deleted file mode 100644
index 4b5d81d33cf..00000000000
--- a/gdb/unittests/basic_string_view/inserters/pod/10081-out.cc
+++ /dev/null
@@ -1,75 +0,0 @@
-// { dg-options "-std=gnu++17" }
-
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-// class basic_istream::sentry
-
-#include <string_view>
-#include <ostream>
-#include <sstream>
-#include <locale>
-#include <typeinfo>
-#include <testsuite_hooks.h>
-#include <testsuite_character.h>
-
-void
-test01()
-{
-  using namespace std;
-
-  using __gnu_test::pod_ushort;
-  typedef basic_string_view<pod_ushort> 	string_type;
-  typedef basic_stringbuf<pod_ushort> 	stringbuf_type;
-  typedef basic_ostream<pod_ushort> 	ostream_type;
-
-  string_type str;
-  stringbuf_type strbuf01;
-  ostream_type stream(&strbuf01);
-
-  try
-    {
-      stream << str;
-    }
-  catch (std::bad_cast& obj)
-    {
-      // Ok, throws bad_cast because locale has no ctype facet.
-    }
-  catch (...)
-    {
-      VERIFY( false );
-    }
-
-  const std::locale loc(std::locale::classic(), new std::ctype<pod_ushort>);
-  stream.imbue(loc);
-  try
-    {
-      stream << str;
-    }
-  catch (...)
-    {
-      VERIFY( false );
-    }
-}
-
-int
-main()
-{
-  test01();
-
-  return 0;
-}
diff --git a/gdb/unittests/basic_string_view/inserters/wchar_t/1.cc b/gdb/unittests/basic_string_view/inserters/wchar_t/1.cc
deleted file mode 100644
index 69754254e4f..00000000000
--- a/gdb/unittests/basic_string_view/inserters/wchar_t/1.cc
+++ /dev/null
@@ -1,70 +0,0 @@
-// { dg-options "-std=gnu++17" }
-
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-// inserters
-
-// NB: This file is predicated on sstreams, and ostreams
-// working, not to mention other major details like char_traits, and
-// all of the string_view class.
-
-#include <string_view>
-#include <stdexcept>
-#include <sstream>
-#include <fstream>
-#include <iostream>
-#include <testsuite_hooks.h>
-
-void
-test01()
-{
-  typedef std::wstring_view::size_type csize_type;
-  typedef std::wstring_view::const_reference cref;
-  typedef std::wstring_view::reference ref;
-
-  const std::wstring_view str01(L"sailing grand traverse bay\n"
-	       L"\t\t\t    from Elk Rapids to the point reminds me of miles");
-  const std::wstring_view str02(L"sailing");
-  const std::wstring_view str03(L"grand");
-  const std::wstring_view str04(L"traverse");
-  const std::wstring_view str05;
-  std::wstring_view str10;
-
-  // ostream& operator<<(ostream&, const basic_string_view&)
-  std::wostringstream ostrs01;
-  try 
-    {
-      ostrs01 << str01;
-      VERIFY( ostrs01.str() == str01 );
-    }
-  catch(std::exception& fail) 
-    {
-      VERIFY( false );
-    }
-  
-  std::wstring_view hello_world;
-  std::wcout << hello_world;
-}
-
-int
-main()
-{ 
-  test01();
-
-  return 0;
-}
diff --git a/gdb/unittests/basic_string_view/inserters/wchar_t/2.cc b/gdb/unittests/basic_string_view/inserters/wchar_t/2.cc
deleted file mode 100644
index 5cc3e93e5b7..00000000000
--- a/gdb/unittests/basic_string_view/inserters/wchar_t/2.cc
+++ /dev/null
@@ -1,91 +0,0 @@
-// { dg-options "-std=gnu++17" }
-
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-// inserters
-
-// NB: This file is predicated on sstreams, istreams, and ostreams
-// working, not to mention other major details like char_traits, and
-// all of the string_view class.
-
-#include <string_view>
-#include <string>
-#include <fstream>
-#include <iostream>
-#include <testsuite_hooks.h>
-
-// testing basic_filebuf::xsputn via stress testing with large string_views
-// based on a bug report libstdc++ 9
-// mode == out
-void
-test05(std::size_t size)
-{
-  bool test = true;
-
-  const char filename[] = "inserters_extractors-2.txt";
-  const wchar_t fillc = L'f';
-  std::wofstream ofs(filename);
-  std::wstring str(size, fillc);
-  std::wstring_view strv(str);
-
-  // sanity checks
-  VERIFY( str.size() == size );
-  VERIFY( ofs.good() );
-
-  // stress test
-  ofs << str << std::endl;
-  if (!ofs.good()) 
-    test = false;
-
-  ofs << str << std::endl;
-  if (!ofs.good()) 
-    test = false;
-
-  VERIFY( str.size() == size );
-  VERIFY( ofs.good() );
-
-  ofs.close();
-
-  // sanity check on the written file
-  std::wifstream ifs(filename);
-  std::size_t count = 0;
-  wchar_t c;
-  while (count <= (2 * size) + 4)
-    {
-      ifs >> c;
-      if (ifs.good() && c == fillc)
-	{
-	  ++count;
-	  c = '0';
-	}
-      else 
-	break;
-    }
-
-  VERIFY( count == 2 * size );
-}
-
-int
-main()
-{
-  test05(1); 
-  test05(1000); 
-  test05(10000);
-
-  return 0;
-}
diff --git a/gdb/unittests/basic_string_view/inserters/wchar_t/3.cc b/gdb/unittests/basic_string_view/inserters/wchar_t/3.cc
deleted file mode 100644
index 5eabf46dd44..00000000000
--- a/gdb/unittests/basic_string_view/inserters/wchar_t/3.cc
+++ /dev/null
@@ -1,53 +0,0 @@
-// { dg-options "-std=gnu++17" }
-
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-// inserters
-
-// NB: This file is predicated on sstreams, istreams, and ostreams
-// working, not to mention other major details like char_traits, and
-// all of the string_view class.
-
-#include <string_view>
-#include <sstream>
-#include <iomanip>
-#include <testsuite_hooks.h>
-
-void
-test09()
-{
-  std::wstring_view foo{L"peace\0\0\0& love"};
-  
-  std::wostringstream oss1;
-  oss1 << foo;
-  VERIFY( oss1.str() == foo );
-  
-  std::wostringstream oss2;
-  oss2.width(20);
-  oss2 << foo;
-  VERIFY( oss2.str() != foo );
-  VERIFY( oss2.str().size() == 20 );
-}
-
-int
-main()
-{ 
-  test09();
-
-  return 0;
-}
diff --git a/gdb/unittests/basic_string_view/literals/types.cc b/gdb/unittests/basic_string_view/literals/types.cc
deleted file mode 100644
index de0aa1e7569..00000000000
--- a/gdb/unittests/basic_string_view/literals/types.cc
+++ /dev/null
@@ -1,45 +0,0 @@
-// { dg-options "-std=gnu++17" }
-// { dg-do compile }
-
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-#include <string_view>
-#include <type_traits>
-
-void
-test01()
-{
-  using namespace std::literals::string_view_literals;
-
-  static_assert(std::is_same<decltype("Hello"sv), std::string_view>::value,
-		"\"Hello\"s is std::string_view");
-
-  static_assert(std::is_same<decltype(u8"Hello"sv), std::string_view>::value,
-		"u8\"Hello\"s is std::string_view");
-
-#ifdef _GLIBCXX_USE_WCHAR_T
-  static_assert(std::is_same<decltype(L"Hello"sv), std::wstring_view>::value,
-		"L\"Hello\"s is std::wstring_view");
-#endif
-
-  static_assert(std::is_same<decltype(u"Hello"sv), std::u16string_view>::value,
-		"u\"Hello\"s is std::u16string_view");
-
-  static_assert(std::is_same<decltype(U"Hello"sv), std::u32string_view>::value,
-		"U\"Hello\"s is std::u32string_view");
-}
diff --git a/gdb/unittests/basic_string_view/literals/values.cc b/gdb/unittests/basic_string_view/literals/values.cc
deleted file mode 100644
index ebd69b84455..00000000000
--- a/gdb/unittests/basic_string_view/literals/values.cc
+++ /dev/null
@@ -1,72 +0,0 @@
-// { dg-options "-std=gnu++17" }
-
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-#include <string_view>
-#include <testsuite_hooks.h>
-
-void
-test01()
-{
-  using namespace std::literals::string_view_literals;
-
-  std::string_view planet = "Mercury"sv;
-#ifdef _GLIBCXX_USE_WCHAR_T
-  std::wstring_view wplanet = L"Venus"sv;
-#endif
-  std::string_view u8planet = u8"Mars"sv;
-  std::u16string_view u16planet = u"Jupiter"sv;
-  std::u32string_view u32planet = U"Saturn"sv;
-
-  VERIFY( planet == std::string_view("Mercury") );
-#ifdef _GLIBCXX_USE_WCHAR_T
-  VERIFY( wplanet == std::wstring_view(L"Venus") );
-#endif
-  VERIFY( u8planet == std::string_view(u8"Mars") );
-  VERIFY( u16planet == std::u16string_view(u"Jupiter") );
-  VERIFY( u32planet == std::u32string_view(U"Saturn") );
-}
-
-void
-test02()
-{
-  using namespace std::literals::string_view_literals;
-
-  std::string_view planet_cratered = "Mercury\0cratered"sv;
-#ifdef _GLIBCXX_USE_WCHAR_T
-  std::wstring_view wplanet_cratered = L"Venus\0cratered"sv;
-#endif
-  std::string_view u8planet_cratered = u8"Mars\0cratered"sv;
-  std::u16string_view u16planet_cratered = u"Jupiter\0cratered"sv;
-  std::u32string_view u32planet_cratered = U"Saturn\0cratered"sv;
-
-  VERIFY( planet_cratered == std::string_view("Mercury\0cratered", 16) );
-#ifdef _GLIBCXX_USE_WCHAR_T
-  VERIFY( wplanet_cratered == std::wstring_view(L"Venus\0cratered", 14) );
-#endif
-  VERIFY( u8planet_cratered == std::string_view(u8"Mars\0cratered", 13) );
-  VERIFY( u16planet_cratered == std::u16string_view(u"Jupiter\0cratered", 16) );
-  VERIFY( u32planet_cratered == std::u32string_view(U"Saturn\0cratered", 15) );
-}
-
-int
-main()
-{
-  test01();
-  test02();
-}
diff --git a/gdb/unittests/basic_string_view/modifiers/remove_prefix/char/1.cc b/gdb/unittests/basic_string_view/modifiers/remove_prefix/char/1.cc
deleted file mode 100644
index 4ebf4c04ad2..00000000000
--- a/gdb/unittests/basic_string_view/modifiers/remove_prefix/char/1.cc
+++ /dev/null
@@ -1,66 +0,0 @@
-// { dg-options "-std=gnu++17" }
-
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-namespace modifiers_remove_prefix {
-
-static void
-test01 ()
-{
-  using gdb::string_view;
-
-  string_view str0{"olympus mons"};
-  string_view::pointer p = str0.data();
-  str0.remove_prefix(4);
-  VERIFY( str0.data() == p + 4);
-  VERIFY( str0.length() == 8 );
-  VERIFY( str0 == string_view{"pus mons"} );
-}
-
-#ifndef GDB_STRING_VIEW
-constexpr bool
-test02()
-{
-  using std::string_view;
-
-  string_view str0{"olympus mons"};
-  string_view::pointer p = str0.data();
-  str0.remove_prefix(4);
-  if ( str0.data() != p + 4)
-    return false;
-  if ( str0.length() != 8 )
-    return false;
-  if ( str0 != string_view{"pus mons"} )
-    return false;
-
-  return true;
-}
-#endif
-
-static int
-main ()
-{ 
-  test01();
-#ifndef GDB_STRING_VIEW
-  static_assert( test02() );
-#endif
-
-  return 0;
-}
-
-} // namespace modifiers_remove_prefix
diff --git a/gdb/unittests/basic_string_view/modifiers/remove_prefix/wchar_t/1.cc b/gdb/unittests/basic_string_view/modifiers/remove_prefix/wchar_t/1.cc
deleted file mode 100644
index 3503dcbab53..00000000000
--- a/gdb/unittests/basic_string_view/modifiers/remove_prefix/wchar_t/1.cc
+++ /dev/null
@@ -1,61 +0,0 @@
-// { dg-options "-std=gnu++17" }
-
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-#include <string_view>
-#include <testsuite_hooks.h>
-
-void
-test01()
-{
-  using std::wstring_view;
-
-  wstring_view str0{L"olympus mons"};
-  wstring_view::pointer p = str0.data();
-  str0.remove_prefix(4);
-  VERIFY( str0.data() == p + 4);
-  VERIFY( str0.length() == 8 );
-  VERIFY( str0 == wstring_view{L"pus mons"} );
-}
-
-constexpr bool
-test02()
-{
-  using std::wstring_view;
-
-  wstring_view str0{L"olympus mons"};
-  wstring_view::pointer p = str0.data();
-  str0.remove_prefix(4);
-  if ( str0.data() != p + 4)
-    return false;
-  if ( str0.length() != 8 )
-    return false;
-  if ( str0 != wstring_view{L"pus mons"} )
-    return false;
-
-  return true;
-}
-
-int
-main()
-{ 
-  test01();
-  static_assert( test02() );
-
-  return 0;
-}
diff --git a/gdb/unittests/basic_string_view/modifiers/remove_suffix/char/1.cc b/gdb/unittests/basic_string_view/modifiers/remove_suffix/char/1.cc
deleted file mode 100644
index 5e9259eecad..00000000000
--- a/gdb/unittests/basic_string_view/modifiers/remove_suffix/char/1.cc
+++ /dev/null
@@ -1,66 +0,0 @@
-// { dg-options "-std=gnu++17" }
-
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-namespace modifiers_remove_suffix {
-
-static void
-test01 ()
-{
-  using gdb::string_view;
-
-  string_view str0{"olympus mons"};
-  string_view::pointer p = str0.data();
-  str0.remove_suffix(2);
-  VERIFY( str0.data() == p);
-  VERIFY( str0.length() == 10 );
-  VERIFY( str0 == string_view{"olympus mo"} );
-}
-
-#ifndef GDB_STRING_VIEW
-constexpr bool
-test02()
-{
-  using std::string_view;
-
-  string_view str0{"olympus mons"};
-  string_view::pointer p = str0.data();
-  str0.remove_suffix(2);
-  if ( str0.data() != p)
-    return false;
-  if ( str0.length() != 10 )
-    return false;
-  if ( str0 != string_view{"olympus mo"} )
-    return false;
-
-  return true;
-}
-#endif
-
-static int
-main ()
-{ 
-  test01();
-#ifndef GDB_STRING_VIEW
-  static_assert( test02() );
-#endif
-
-  return 0;
-}
-
-} // namespace modifiers_remove_suffix
diff --git a/gdb/unittests/basic_string_view/modifiers/remove_suffix/wchar_t/1.cc b/gdb/unittests/basic_string_view/modifiers/remove_suffix/wchar_t/1.cc
deleted file mode 100644
index 7f9e051d986..00000000000
--- a/gdb/unittests/basic_string_view/modifiers/remove_suffix/wchar_t/1.cc
+++ /dev/null
@@ -1,61 +0,0 @@
-// { dg-options "-std=gnu++17" }
-
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-#include <string_view>
-#include <testsuite_hooks.h>
-
-void
-test01()
-{
-  using std::wstring_view;
-
-  wstring_view str0{L"olympus mons"};
-  wstring_view::pointer p = str0.data();
-  str0.remove_suffix(2);
-  VERIFY( str0.data() == p);
-  VERIFY( str0.length() == 10 );
-  VERIFY( str0 == wstring_view{L"olympus mo"} );
-}
-
-constexpr bool
-test02()
-{
-  using std::wstring_view;
-
-  wstring_view str0{L"olympus mons"};
-  wstring_view::pointer p = str0.data();
-  str0.remove_suffix(2);
-  if ( str0.data() != p)
-    return false;
-  if ( str0.length() != 10 )
-    return false;
-  if ( str0 != wstring_view{L"olympus mo"} )
-    return false;
-
-  return true;
-}
-
-int
-main()
-{ 
-  test01();
-  static_assert( test02() );
-
-  return 0;
-}
diff --git a/gdb/unittests/basic_string_view/modifiers/swap/char/1.cc b/gdb/unittests/basic_string_view/modifiers/swap/char/1.cc
deleted file mode 100644
index d583566c4bd..00000000000
--- a/gdb/unittests/basic_string_view/modifiers/swap/char/1.cc
+++ /dev/null
@@ -1,36 +0,0 @@
-// Copyright (C) 2017-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-// { dg-options "-std=gnu++17" }
-// { dg-do compile { target c++17 } }
-
-namespace modifiers_swap {
-
-static void
-test01 ()
-{
-  using gdb::string_view;
-
-  string_view s1{"last"};
-  string_view s2{"first"};
-
-  s1.swap(s2);
-  VERIFY( s1 == "first" );
-  VERIFY( s2 == "last" );
-}
-
-} // namespace modifiers_swap
diff --git a/gdb/unittests/basic_string_view/modifiers/swap/wchar_t/1.cc b/gdb/unittests/basic_string_view/modifiers/swap/wchar_t/1.cc
deleted file mode 100644
index b986088f1e2..00000000000
--- a/gdb/unittests/basic_string_view/modifiers/swap/wchar_t/1.cc
+++ /dev/null
@@ -1,35 +0,0 @@
-// Copyright (C) 2017-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-// { dg-options "-std=gnu++17" }
-// { dg-do compile { target c++17 } }
-
-#include <string_view>
-
-constexpr bool
-test01()
-{
-  using std::wstring_view;
-
-  wstring_view s1{L"last"};
-  wstring_view s2{L"first"};
-
-  s1.swap(s2);
-  return s1 == L"first" && s2 == L"last";
-}
-
-static_assert( test01() );
diff --git a/gdb/unittests/basic_string_view/operations/compare/char/1.cc b/gdb/unittests/basic_string_view/operations/compare/char/1.cc
deleted file mode 100644
index d824c8e2277..00000000000
--- a/gdb/unittests/basic_string_view/operations/compare/char/1.cc
+++ /dev/null
@@ -1,132 +0,0 @@
-// { dg-options "-std=gnu++17" }
-
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-// basic_string_view::compare
-// int compare(const basic_string_view& str) const;
-// int compare(size_type pos1, size_type n1, const basic_string_view& str) const;
-// int compare(size_type pos1, size_type n1, const basic_string_view& str,
-//             size_type pos2, size_type n2) const;
-// int compare(const charT* s) const;
-// int compare(size_type pos1, size_type n1,
-//             const charT* s, size_type n2 = npos) const;
-
-// NB compare should be thought of as a lexographical compare, ie how
-// things would be sorted in a dictionary.
-
-namespace operations_compare_1 {
-
-enum want_value {lt=0, z=1, gt=2};
-
-int
-test_value(int result, want_value expected);
-
-int
-test_value(int result, want_value expected)
-{
-  bool pass = false;
-
-  switch (expected) {
-  case lt:
-    if (result < 0)
-      pass = true;
-    break;
-  case z:
-    if (!result)
-      pass = true;
-    break;
-  case gt:
-    if (result > 0)
-      pass = true;
-    break;
-  default:
-    pass = false; //should not get here
-  }
-  VERIFY(pass);
-  return 0;
-}
-
-static int
-test01 ()
-{
-  using gdb::string_view;
-
-  string_view 	str_0("costa rica");
-  string_view 	str_1("costa marbella");
-  string_view 	str_2;
-
-  //sanity check
-  test_value(strcmp("costa marbella", "costa rica"), lt);
-  test_value(strcmp("costa rica", "costa rica"), z);
-  test_value(strcmp(str_1.data(), str_0.data()), lt);
-  test_value(strcmp(str_0.data(), str_1.data()), gt);
-  test_value(strncmp(str_1.data(), str_0.data(), 6), z);
-  test_value(strncmp(str_1.data(), str_0.data(), 14), lt);
-  test_value(memcmp(str_1.data(), str_0.data(), 6), z);
-  test_value(memcmp(str_1.data(), str_0.data(), 10), lt);
-  test_value(memcmp("costa marbella", "costa rica", 10), lt);
-
-  // int compare(const basic_string_view& str) const;
-  test_value(str_0.compare(str_1), gt); //because r>m
-  test_value(str_1.compare(str_0), lt); //because m<r
-  str_2 = str_0;
-  test_value(str_2.compare(str_0), z);
-  str_2 = "cost";
-  test_value(str_2.compare(str_0), lt);
-  str_2 = "costa ricans";
-  test_value(str_2.compare(str_0), gt);
-
-  // int compare(size_type pos1, size_type n1, const basic_string_view& str) const;
-  test_value(str_1.compare(0, 6, str_0), lt);
-  str_2 = "cost";
-  test_value(str_1.compare(0, 4, str_2), z);
-  test_value(str_1.compare(0, 5, str_2), gt);
-
-  // int compare(size_type pos1, size_type n1, const basic_string_view& str,
-  //		 size_type pos2, size_type n2) const;
-  test_value(str_1.compare(0, 6, str_0, 0, 6), z);
-  test_value(str_1.compare(0, 7, str_0, 0, 7), lt);
-  test_value(str_0.compare(0, 7, str_1, 0, 7), gt);
-
-  // int compare(const charT* s) const;
-  test_value(str_0.compare("costa marbella"), gt);
-  test_value(str_1.compare("costa rica"), lt);
-  str_2 = str_0;
-  test_value(str_2.compare("costa rica"), z);
-  test_value(str_2.compare("cost"), gt);
-  test_value(str_2.compare("costa ricans"), lt);
-
-  // int compare(size_type pos, size_type n1, const charT* str,
-  //             size_type n2 = npos) const;
-  test_value(str_1.compare(0, 6, "costa rica", 0, 6), z);
-  test_value(str_1.compare(0, 7, "costa rica", 0, 7), lt);
-  test_value(str_0.compare(0, 7, "costa marbella", 0, 7), gt);
-
-  return 0;
-}
-
-
-static int
-main ()
-{
-  test01();
-
-  return 0;
-}
-
-} // namespace operations_compare_1
diff --git a/gdb/unittests/basic_string_view/operations/compare/char/13650.cc b/gdb/unittests/basic_string_view/operations/compare/char/13650.cc
deleted file mode 100644
index cbfe4a07444..00000000000
--- a/gdb/unittests/basic_string_view/operations/compare/char/13650.cc
+++ /dev/null
@@ -1,50 +0,0 @@
-// { dg-options "-std=gnu++17" }
-
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-// basic_string_view::compare [lib.string_view::compare]
-
-namespace operations_compare_13650 {
-
-// libstdc++/13650
-static void
-test01 ()
-{
-  using gdb::string_view;
-
-  const char lit_01[]{ 'w', 'e', '\0', 'r', 'd' };
-  const char lit_02[]{ 'w', 'e', 'i', '\0', 'd' };
-
-  const char lit_ref_a[]{ 'w', 'e', '\0', 'q', 'd' };
-  const string_view str_a(lit_ref_a, 5);
-  VERIFY( str_a.compare(0, 5, lit_01, 5) < 0 );
-
-  const char lit_ref_b[]{ 'w', 'e', 'i' };
-  const string_view str_b(lit_ref_b, 3);
-  VERIFY( str_b.compare(0, 3, lit_02, 5) < 0 );
-}
-
-static int
-main()
-{
-  test01();
-
-  return 0;
-}
-
-} // namespace operations_compare_13650
diff --git a/gdb/unittests/basic_string_view/operations/compare/char/2.cc b/gdb/unittests/basic_string_view/operations/compare/char/2.cc
deleted file mode 100644
index f0b76afb427..00000000000
--- a/gdb/unittests/basic_string_view/operations/compare/char/2.cc
+++ /dev/null
@@ -1,30 +0,0 @@
-// Copyright (C) 2017-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-// { dg-options "-std=gnu++17" }
-// { dg-do compile { target c++17 } }
-
-#include <string_view>
-
-constexpr char c1[] = "one";
-constexpr char c2[] = "two";
-
-constexpr std::string_view s1{c1};
-constexpr std::string_view s2{c2};
-
-constexpr int n1 = s1.compare(s1);
-constexpr int n2 = s1.compare(s2);
diff --git a/gdb/unittests/basic_string_view/operations/compare/char/70483.cc b/gdb/unittests/basic_string_view/operations/compare/char/70483.cc
deleted file mode 100644
index 259f95f5180..00000000000
--- a/gdb/unittests/basic_string_view/operations/compare/char/70483.cc
+++ /dev/null
@@ -1,89 +0,0 @@
-// Copyright (C) 2017-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-// { dg-options "-std=gnu++17" }
-// { dg-do compile { target c++17 } }
-
-#include <string_view>
-
-struct constexpr_char_traits : std::char_traits<char>
-{
-  static constexpr size_t
-  length(const char* val)
-  {
-    size_t res = 0;
-    for (; val[res] != '\0'; ++res)
-      ;
-    return res;
-  }
-
-  static constexpr int
-  compare(const char* lhs, const char* rhs, std::size_t count)
-  {
-    for (size_t pos = 0; pos < count; ++pos)
-    {
-      if (lhs[pos] != rhs[pos])
-        return lhs[pos] - rhs[pos];
-    }
-    return 0;
-  }
-};
-
-using string_view = std::basic_string_view<char, constexpr_char_traits>;
-
-constexpr
-string_view get()
-{
-    string_view res = "x::";
-    string_view start_pattern = "x";
-    res = res.substr(res.find(start_pattern) + start_pattern.size());
-    res = res.substr(0, res.find_first_of(";]"));
-    res = res.substr(res.rfind("::"));
-    return res;
-}
-
-static_assert( get() == get() );
-
-using std::u16string_view;
-
-constexpr
-u16string_view get16()
-{
-    u16string_view res = u"x::";
-    u16string_view start_pattern = u"x";
-    res = res.substr(res.find(start_pattern) + start_pattern.size());
-    res = res.substr(0, res.find_first_of(u";]"));
-    res = res.substr(res.rfind(u"::"));
-    return res;
-}
-
-static_assert( get16() == get16() );
-
-using std::u32string_view;
-
-constexpr
-u32string_view get32()
-{
-    u32string_view res = U"x::";
-    u32string_view start_pattern = U"x";
-    res = res.substr(res.find(start_pattern) + start_pattern.size());
-    res = res.substr(0, res.find_first_of(U";]"));
-    res = res.substr(res.rfind(U"::"));
-    return res;
-}
-
-static_assert( get32() == get32() );
diff --git a/gdb/unittests/basic_string_view/operations/compare/wchar_t/1.cc b/gdb/unittests/basic_string_view/operations/compare/wchar_t/1.cc
deleted file mode 100644
index 8a05a4053a1..00000000000
--- a/gdb/unittests/basic_string_view/operations/compare/wchar_t/1.cc
+++ /dev/null
@@ -1,133 +0,0 @@
-// { dg-options "-std=gnu++17" }
-
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-// basic_string_view::compare
-// int compare(const basic_string_view& str) const;
-// int compare(size_type pos1, size_type n1, const basic_string_view& str) const;
-// int compare(size_type pos1, size_type n1, const basic_string_view& str,
-//             size_type pos2, size_type n2) const;
-// int compare(const charT* s) const;
-// int compare(size_type pos1, size_type n1,
-//             const charT* s, size_type n2 = npos) const;
-
-// NB compare should be thought of as a lexographical compare, ie how
-// things would be sorted in a dictionary.
-
-#include <string_view>
-#include <testsuite_hooks.h>
-
-enum want_value {lt=0, z=1, gt=2};
-
-int
-test_value(int result, want_value expected);
-
-int
-test_value(int result, want_value expected)
-{
-  bool pass = false;
-
-  switch (expected) {
-  case lt:
-    if (result < 0)
-      pass = true;
-    break;
-  case z:
-    if (!result)
-      pass = true;
-    break;
-  case gt:
-    if (result > 0)
-      pass = true;
-    break;
-  default:
-    pass = false; //should not get here
-  }
-
-  VERIFY(pass);
-  return 0;
-}
-
-
-int
-test01()
-{
-  using std::wstring_view;
-
-  wstring_view 	str_0(L"costa rica");
-  wstring_view 	str_1(L"costa marbella");
-  wstring_view 	str_2;
-
-  //sanity check
-  test_value(wcscmp(L"costa marbella", L"costa rica"), lt);
-  test_value(wcscmp(L"costa rica", L"costa rica"), z);
-  test_value(wcscmp(str_1.data(), str_0.data()), lt);
-  test_value(wcscmp(str_0.data(), str_1.data()), gt);
-  test_value(wcsncmp(str_1.data(), str_0.data(), 6), z);
-  test_value(wcsncmp(str_1.data(), str_0.data(), 14), lt);
-  test_value(wmemcmp(str_1.data(), str_0.data(), 6), z);
-  test_value(wmemcmp(str_1.data(), str_0.data(), 14), lt);
-  test_value(wmemcmp(L"costa marbella", L"costa rica", 14), lt);
-
-  // int compare(const basic_string_view& str) const;
-  test_value(str_0.compare(str_1), gt); //because r>m
-  test_value(str_1.compare(str_0), lt); //because m<r
-  str_2 = str_0;
-  test_value(str_2.compare(str_0), z);
-  str_2 = L"cost";
-  test_value(str_2.compare(str_0), lt);
-  str_2 = L"costa ricans";
-  test_value(str_2.compare(str_0), gt);
-
-  // int compare(size_type pos1, size_type n1, const basic_string_view& str) const;
-  test_value(str_1.compare(0, 6, str_0), lt);
-  str_2 = L"cost";
-  test_value(str_1.compare(0, 4, str_2), z);
-  test_value(str_1.compare(0, 5, str_2), gt);
-
-  // int compare(size_type pos1, size_type n1, const basic_string_view& str,
-  //		 size_type pos2, size_type n2) const;
-  test_value(str_1.compare(0, 6, str_0, 0, 6), z);
-  test_value(str_1.compare(0, 7, str_0, 0, 7), lt);
-  test_value(str_0.compare(0, 7, str_1, 0, 7), gt);
-
-  // int compare(const charT* s) const;
-  test_value(str_0.compare(L"costa marbella"), gt);
-  test_value(str_1.compare(L"costa rica"), lt);
-  str_2 = str_0;
-  test_value(str_2.compare(L"costa rica"), z);
-  test_value(str_2.compare(L"cost"), gt);
-  test_value(str_2.compare(L"costa ricans"), lt);
-
-  // int compare(size_type pos, size_type n1, const charT* str,
-  //             size_type n2 = npos) const;
-  test_value(str_1.compare(0, 6, L"costa rica", 0, 6), z);
-  test_value(str_1.compare(0, 7, L"costa rica", 0, 7), lt);
-  test_value(str_0.compare(0, 7, L"costa marbella", 0, 7), gt);
-
-  return 0;
-}
-
-
-int
-main()
-{
-  test01();
-
-  return 0;
-}
diff --git a/gdb/unittests/basic_string_view/operations/compare/wchar_t/13650.cc b/gdb/unittests/basic_string_view/operations/compare/wchar_t/13650.cc
deleted file mode 100644
index 86df7d0a377..00000000000
--- a/gdb/unittests/basic_string_view/operations/compare/wchar_t/13650.cc
+++ /dev/null
@@ -1,49 +0,0 @@
-// { dg-options "-std=gnu++17" }
-
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-// basic_string_view::compare [lib.string_view::compare]
-
-#include <string_view>
-#include <testsuite_hooks.h>
-
-// libstdc++/13650
-void
-test01()
-{
-  using std::wstring_view;
-
-  const wchar_t lit_01[] = { L'w', L'e', L'\0', L'r', L'd' };
-  const wchar_t lit_02[] = { L'w', L'e', L'i', L'\0', L'd' };
-
-  const wchar_t lit_ref_a[] = { L'w', L'e', L'\0', L'q', L'd' };
-  const wstring_view str_a(lit_ref_a, 5);
-  VERIFY( str_a.compare(0, 5, lit_01, 5) < 0 );
-
-  const wchar_t lit_ref_b[] = { L'w', L'e', L'i' };
-  const wstring_view str_b(lit_ref_b, 3);
-  VERIFY( str_b.compare(0, 3, lit_02, 5) < 0 );
-}
-
-int
-main()
-{
-  test01();
-
-  return 0;
-}
diff --git a/gdb/unittests/basic_string_view/operations/compare/wchar_t/2.cc b/gdb/unittests/basic_string_view/operations/compare/wchar_t/2.cc
deleted file mode 100644
index c6b6eb91d42..00000000000
--- a/gdb/unittests/basic_string_view/operations/compare/wchar_t/2.cc
+++ /dev/null
@@ -1,30 +0,0 @@
-// Copyright (C) 2017-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-// { dg-options "-std=gnu++17" }
-// { dg-do compile { target c++17 } }
-
-#include <string_view>
-
-constexpr wchar_t c1[] = L"one";
-constexpr wchar_t c2[] = L"two";
-
-constexpr std::wstring_view s1{c1};
-constexpr std::wstring_view s2{c2};
-
-constexpr int n1 = s1.compare(s1);
-constexpr int n2 = s1.compare(s2);
diff --git a/gdb/unittests/basic_string_view/operations/copy/char/1.cc b/gdb/unittests/basic_string_view/operations/copy/char/1.cc
deleted file mode 100644
index f124f3aab46..00000000000
--- a/gdb/unittests/basic_string_view/operations/copy/char/1.cc
+++ /dev/null
@@ -1,46 +0,0 @@
-// { dg-options "-std=gnu++17" }
-
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-// basic_string_view::copy
-
-namespace operations_copy_1 {
-
-static void
-test01 ()
-{
-  typedef gdb::string_view::size_type csize_type;
-
-  const char str_lit01[] = "123456789A";
-  const gdb::string_view str01(str_lit01);
-  char buffer[4] = { 0 };
-
-  csize_type len = str01.copy(buffer, sizeof(buffer), 8);
-  VERIFY( 2 == len );
-  VERIFY( '9' == buffer[0] );
-}
-
-static int
-main ()
-{ 
-  test01();
-
-  return 0;
-}
-
-} // namespace operations_copy_1
diff --git a/gdb/unittests/basic_string_view/operations/copy/wchar_t/1.cc b/gdb/unittests/basic_string_view/operations/copy/wchar_t/1.cc
deleted file mode 100644
index 56a48841ca7..00000000000
--- a/gdb/unittests/basic_string_view/operations/copy/wchar_t/1.cc
+++ /dev/null
@@ -1,46 +0,0 @@
-// { dg-options "-std=gnu++17" }
-
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-// basic_string_view::copy
-
-#include <string_view>
-#include <testsuite_hooks.h>
-
-void
-test01()
-{
-  typedef std::wstring_view::size_type csize_type;
-  csize_type csz01;
-
-  const wchar_t str_lit01[] = L"123456789A";
-  const std::wstring_view str01(str_lit01);
-  wchar_t buffer[4] = { 0 };
-
-  csize_type len = str01.copy(buffer, sizeof(buffer), 8);
-  VERIFY( 2 == len );
-  VERIFY( L'9' == buffer[0] );
-}
-
-int
-main()
-{ 
-  test01();
-
-  return 0;
-}
diff --git a/gdb/unittests/basic_string_view/operations/data/char/1.cc b/gdb/unittests/basic_string_view/operations/data/char/1.cc
deleted file mode 100644
index 0309f5f555d..00000000000
--- a/gdb/unittests/basic_string_view/operations/data/char/1.cc
+++ /dev/null
@@ -1,44 +0,0 @@
-// { dg-options "-std=gnu++17" }
-
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-// string_view operations
-
-namespace operations_data_1 {
-
-static int
-test01 ()
-{
-  gdb::string_view empty;
-
-  VERIFY( empty.size() == 0 );
-  const gdb::string_view::value_type* p = empty.data();
-  VERIFY( p == nullptr );
-
-  return 0;
-}
-
-static int
-main ()
-{ 
-  test01();
-
-  return 0;
-}
-
-} // namespace operations_data_1
diff --git a/gdb/unittests/basic_string_view/operations/data/wchar_t/1.cc b/gdb/unittests/basic_string_view/operations/data/wchar_t/1.cc
deleted file mode 100644
index 31c58b6a3c2..00000000000
--- a/gdb/unittests/basic_string_view/operations/data/wchar_t/1.cc
+++ /dev/null
@@ -1,43 +0,0 @@
-// { dg-options "-std=gnu++17" }
-
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-// string_view operations
-
-#include <string_view>
-#include <testsuite_hooks.h>
-
-int
-test01()
-{
-  std::wstring_view empty;
-
-  VERIFY( empty.size() == 0 );
-  const std::wstring_view::value_type* p = empty.data();
-  VERIFY( p == nullptr );
-
-  return 0;
-}
-
-int
-main()
-{ 
-  test01();
-
-  return 0;
-}
diff --git a/gdb/unittests/basic_string_view/operations/find/char/1.cc b/gdb/unittests/basic_string_view/operations/find/char/1.cc
deleted file mode 100644
index 79706e05aca..00000000000
--- a/gdb/unittests/basic_string_view/operations/find/char/1.cc
+++ /dev/null
@@ -1,168 +0,0 @@
-// { dg-options "-std=gnu++17" }
-
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-// basic_string_view find
-
-namespace operations_find_1 {
-
-static void
-test01 ()
-{
-  typedef gdb::string_view::size_type csize_type;
-  typedef gdb::string_view::const_reference cref;
-  typedef gdb::string_view::reference ref;
-  csize_type npos = gdb::string_view::npos;
-  csize_type csz01, csz02;
-
-  const char str_lit01[] = "mave";
-  const gdb::string_view str01("mavericks, santa cruz");
-  gdb::string_view str02(str_lit01);
-  gdb::string_view str03("s, s");
-  gdb::string_view str04;
-
-  // size_type find(const string_view&, size_type pos = 0) const;
-  csz01 = str01.find(str01);
-  VERIFY( csz01 == 0 );
-  csz01 = str01.find(str01, 4);
-  VERIFY( csz01 == npos );
-  csz01 = str01.find(str02, 0);
-  VERIFY( csz01 == 0 );
-  csz01 = str01.find(str02, 3);
-  VERIFY( csz01 == npos );
-  csz01 = str01.find(str03, 0);
-  VERIFY( csz01 == 8 );
-  csz01 = str01.find(str03, 3);
-  VERIFY( csz01 == 8 );
-  csz01 = str01.find(str03, 12);
-  VERIFY( csz01 == npos );
-
-  // An empty string_view consists of no characters
-  // therefore it should be found at every point in a string_view,
-  // except beyond the end
-  csz01 = str01.find(str04, 0);
-  VERIFY( csz01 == 0 );
-  csz01 = str01.find(str04, 5);
-  VERIFY( csz01 == 5 );
-  csz01 = str01.find(str04, str01.size());
-  VERIFY( csz01 == str01.size() );
-  csz01 = str01.find(str04, str01.size()+1);
-  VERIFY( csz01 == npos );
-
-  // size_type find(const char* s, size_type pos, size_type n) const;
-  csz01 = str01.find(str_lit01, 0, 3);
-  VERIFY( csz01 == 0 );
-  csz01 = str01.find(str_lit01, 3, 0);
-  VERIFY( csz01 == 3 );
-
-  // size_type find(const char* s, size_type pos = 0) const;
-  csz01 = str01.find(str_lit01);
-  VERIFY( csz01 == 0 );
-  csz01 = str01.find(str_lit01, 3);
-  VERIFY( csz01 == npos );
-
-  // size_type find(char c, size_type pos = 0) const;
-  csz01 = str01.find('z');
-  csz02 = str01.size() - 1;
-  VERIFY( csz01 == csz02 );
-  csz01 = str01.find('/');
-  VERIFY( csz01 == npos );
-}
-
-#ifndef GDB_STRING_VIEW
-constexpr bool
-test02()
-{
-  typedef std::string_view::size_type csize_type;
-  typedef std::string_view::const_reference cref;
-  typedef std::string_view::reference ref;
-  csize_type npos = std::string_view::npos;
-  csize_type csz01 = 0, csz02 = 0;
-
-  const char str_lit01[] = "mave";
-  const std::string_view str01("mavericks, santa cruz");
-  std::string_view str02(str_lit01);
-  std::string_view str03("s, s");
-  std::string_view str04;
-
-#undef VERIFY
-#define VERIFY(x) if(!(x)) return false
-
-  // size_type find(const string_view&, size_type pos = 0) const;
-  csz01 = str01.find(str01);
-  VERIFY( csz01 == 0 );
-  csz01 = str01.find(str01, 4);
-  VERIFY( csz01 == npos );
-  csz01 = str01.find(str02, 0);
-  VERIFY( csz01 == 0 );
-  csz01 = str01.find(str02, 3);
-  VERIFY( csz01 == npos );
-  csz01 = str01.find(str03, 0);
-  VERIFY( csz01 == 8 );
-  csz01 = str01.find(str03, 3);
-  VERIFY( csz01 == 8 );
-  csz01 = str01.find(str03, 12);
-  VERIFY( csz01 == npos );
-
-  // An empty string_view consists of no characters
-  // therefore it should be found at every point in a string_view,
-  // except beyond the end
-  csz01 = str01.find(str04, 0);
-  VERIFY( csz01 == 0 );
-  csz01 = str01.find(str04, 5);
-  VERIFY( csz01 == 5 );
-  csz01 = str01.find(str04, str01.size());
-  VERIFY( csz01 == str01.size() );
-  csz01 = str01.find(str04, str01.size()+1);
-  VERIFY( csz01 == npos );
-
-  // size_type find(const char* s, size_type pos, size_type n) const;
-  csz01 = str01.find(str_lit01, 0, 3);
-  VERIFY( csz01 == 0 );
-  csz01 = str01.find(str_lit01, 3, 0);
-  VERIFY( csz01 == 3 );
-
-  // size_type find(const char* s, size_type pos = 0) const;
-  csz01 = str01.find(str_lit01);
-  VERIFY( csz01 == 0 );
-  csz01 = str01.find(str_lit01, 3);
-  VERIFY( csz01 == npos );
-
-  // size_type find(char c, size_type pos = 0) const;
-  csz01 = str01.find('z');
-  csz02 = str01.size() - 1;
-  VERIFY( csz01 == csz02 );
-  csz01 = str01.find('/');
-  VERIFY( csz01 == npos );
-
-  return true;
-}
-#endif
-
-static int
-main ()
-{
-  test01();
-#ifndef GDB_STRING_VIEW
-  static_assert( test02() );
-#endif
-
-  return 0;
-}
-
-} // namespace operations_find_1
diff --git a/gdb/unittests/basic_string_view/operations/find/char/2.cc b/gdb/unittests/basic_string_view/operations/find/char/2.cc
deleted file mode 100644
index c6bb97f10a6..00000000000
--- a/gdb/unittests/basic_string_view/operations/find/char/2.cc
+++ /dev/null
@@ -1,166 +0,0 @@
-// { dg-options "-std=gnu++17" }
-
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-// basic_string_view find_first_of
-
-namespace operations_find_2 {
-
-static void
-test02 ()
-{
-  typedef gdb::string_view::size_type csize_type;
-  csize_type npos = gdb::string_view::npos;
-  csize_type csz01, csz02;
-
-  const char str_lit01[] = "mave";
-  const gdb::string_view str01("mavericks, santa cruz");
-  gdb::string_view str02(str_lit01);
-  gdb::string_view str03("s, s");
-  gdb::string_view str04;
-
-  // size_type find_first_of(const string_view&, size_type pos = 0) const;
-  gdb::string_view str05("xena rulez");
-  csz01 = str01.find_first_of(str01);
-  VERIFY( csz01 == 0 );
-  csz01 = str01.find_first_of(str01, 4);
-  VERIFY( csz01 == 4 );
-  csz01 = str01.find_first_of(str02, 0);
-  VERIFY( csz01 == 0 );
-  csz01 = str01.find_first_of(str02, 3);
-  VERIFY( csz01 == 3 );
-  csz01 = str01.find_first_of(str03, 0);
-  VERIFY( csz01 == 8 );
-  csz01 = str01.find_first_of(str03, 3);
-  VERIFY( csz01 == 8 );
-  csz01 = str01.find_first_of(str03, 12);
-  VERIFY( csz01 == 16 );
-  csz01 = str01.find_first_of(str05, 0);
-  VERIFY( csz01 == 1 );
-  csz01 = str01.find_first_of(str05, 4);
-  VERIFY( csz01 == 4 );
-
-  // An empty string_view consists of no characters
-  // therefore it should be found at every point in a string_view,
-  // except beyond the end
-  // However, str1.find_first_of(str2,pos) finds the first character in
-  // str1 (starting at pos) that exists in str2, which is none for empty str2
-  csz01 = str01.find_first_of(str04, 0);
-  VERIFY( csz01 == npos );
-  csz01 = str01.find_first_of(str04, 5);
-  VERIFY( csz01 == npos );
-
-  // size_type find_first_of(const char* s, size_type pos, size_type n) const;
-  csz01 = str01.find_first_of(str_lit01, 0, 3);
-  VERIFY( csz01 == 0 );
-  csz01 = str01.find_first_of(str_lit01, 3, 0);
-  VERIFY( csz01 == npos );
-
-  // size_type find_first_of(const char* s, size_type pos = 0) const;
-  csz01 = str01.find_first_of(str_lit01);
-  VERIFY( csz01 == 0 );
-  csz01 = str01.find_first_of(str_lit01, 3);
-  VERIFY( csz01 == 3 );
-
-  // size_type find_first_of(char c, size_type pos = 0) const;
-  csz01 = str01.find_first_of('z');
-  csz02 = str01.size() - 1;
-  VERIFY( csz01 == csz02 );
-}
-
-#ifndef GDB_STRING_VIEW
-constexpr bool
-test03()
-{
-  typedef std::string_view::size_type csize_type;
-  csize_type npos = std::string_view::npos;
-  csize_type csz01 = 0, csz02 = 0;
-
-  const char str_lit01[] = "mave";
-  const std::string_view str01("mavericks, santa cruz");
-  std::string_view str02(str_lit01);
-  std::string_view str03("s, s");
-  std::string_view str04;
-
-#undef VERIFY
-#define VERIFY(x) if(!(x)) return false
-
-  // size_type find_first_of(const string_view&, size_type pos = 0) const;
-  std::string_view str05("xena rulez");
-  csz01 = str01.find_first_of(str01);
-  VERIFY( csz01 == 0 );
-  csz01 = str01.find_first_of(str01, 4);
-  VERIFY( csz01 == 4 );
-  csz01 = str01.find_first_of(str02, 0);
-  VERIFY( csz01 == 0 );
-  csz01 = str01.find_first_of(str02, 3);
-  VERIFY( csz01 == 3 );
-  csz01 = str01.find_first_of(str03, 0);
-  VERIFY( csz01 == 8 );
-  csz01 = str01.find_first_of(str03, 3);
-  VERIFY( csz01 == 8 );
-  csz01 = str01.find_first_of(str03, 12);
-  VERIFY( csz01 == 16 );
-  csz01 = str01.find_first_of(str05, 0);
-  VERIFY( csz01 == 1 );
-  csz01 = str01.find_first_of(str05, 4);
-  VERIFY( csz01 == 4 );
-
-  // An empty string_view consists of no characters
-  // therefore it should be found at every point in a string_view,
-  // except beyond the end
-  // However, str1.find_first_of(str2,pos) finds the first character in
-  // str1 (starting at pos) that exists in str2, which is none for empty str2
-  csz01 = str01.find_first_of(str04, 0);
-  VERIFY( csz01 == npos );
-  csz01 = str01.find_first_of(str04, 5);
-  VERIFY( csz01 == npos );
-
-  // size_type find_first_of(const char* s, size_type pos, size_type n) const;
-  csz01 = str01.find_first_of(str_lit01, 0, 3);
-  VERIFY( csz01 == 0 );
-  csz01 = str01.find_first_of(str_lit01, 3, 0);
-  VERIFY( csz01 == npos );
-
-  // size_type find_first_of(const char* s, size_type pos = 0) const;
-  csz01 = str01.find_first_of(str_lit01);
-  VERIFY( csz01 == 0 );
-  csz01 = str01.find_first_of(str_lit01, 3);
-  VERIFY( csz01 == 3 );
-
-  // size_type find_first_of(char c, size_type pos = 0) const;
-  csz01 = str01.find_first_of('z');
-  csz02 = str01.size() - 1;
-  VERIFY( csz01 == csz02 );
-
-  return true;
-}
-#endif
-
-static int
-main ()
-{
-  test02();
-#ifndef GDB_STRING_VIEW
-  static_assert( test03() );
-#endif
-
-  return 0;
-}
-
-} // namespace operations_find_2 {
diff --git a/gdb/unittests/basic_string_view/operations/find/char/3.cc b/gdb/unittests/basic_string_view/operations/find/char/3.cc
deleted file mode 100644
index 078fda35d45..00000000000
--- a/gdb/unittests/basic_string_view/operations/find/char/3.cc
+++ /dev/null
@@ -1,166 +0,0 @@
-// { dg-options "-std=gnu++17" }
-
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-// basic_string_view find_first_not_of
-
-namespace operations_find_3 {
-
-static void
-test03 ()
-{
-  typedef gdb::string_view::size_type csize_type;
-  csize_type npos = gdb::string_view::npos;
-  csize_type csz01;
-
-  const gdb::string_view str01("Bob Rock, per me");
-  const char str_lit01[] = "Bob Rock";
-  gdb::string_view str02("ovvero Trivi");
-  gdb::string_view str03(str_lit01);
-  gdb::string_view str04;
-
-  // size_type find_first_not_of(const string_view&, size_type pos = 0) const;
-  csz01 = str01.find_first_not_of(str01);
-  VERIFY( csz01 == npos );
-  csz01 = str01.find_first_not_of(str02, 0);
-  VERIFY( csz01 == 0 );
-  csz01 = str01.find_first_not_of(str02, 10);
-  VERIFY( csz01 == 10 );
-  csz01 = str01.find_first_not_of(str02, 12);
-  VERIFY( csz01 == 14 );
-  csz01 = str01.find_first_not_of(str03, 0);
-  VERIFY( csz01 == 8 );
-  csz01 = str01.find_first_not_of(str03, 15);
-  VERIFY( csz01 == 15 );
-  csz01 = str01.find_first_not_of(str03, 16);
-  VERIFY( csz01 == npos );
-  csz01 = str01.find_first_not_of(str04, 0);
-  VERIFY( csz01 == 0 );
-  csz01 = str01.find_first_not_of(str04, 12);
-  VERIFY( csz01 == 12 );
-  csz01 = str03.find_first_not_of(str01, 0);
-  VERIFY( csz01 == npos );
-  csz01 = str04.find_first_not_of(str02, 0);
-  VERIFY( csz01 == npos );
-
-  // size_type find_first_not_of(const char* s, size_type pos, size_type n) const;
-  csz01 = str01.find_first_not_of(str_lit01, 0, 0);
-  VERIFY( csz01 == 0 );
-  csz01 = str01.find_first_not_of(str_lit01, 0, 8);
-  VERIFY( csz01 == 8 );
-  csz01 = str01.find_first_not_of(str_lit01, 10, 0);
-  VERIFY( csz01 == 10 );
-
-  // size_type find_first_not_of(const char* s, size_type pos = 0) const;
-  csz01 = str01.find_first_not_of(str_lit01);
-  VERIFY( csz01 == 8 );
-  csz01 = str02.find_first_not_of(str_lit01, 2);
-  VERIFY( csz01 == 2 );
-
-  // size_type find_first_not_of(char c, size_type pos = 0) const;
-  csz01 = str01.find_first_not_of('B');
-  VERIFY( csz01 == 1 );
-  csz01 = str01.find_first_not_of('o', 1);
-  VERIFY( csz01 == 2 );
-  csz01 = str02.find_first_not_of('z');
-  VERIFY( csz01 == 0 );
-  csz01 = str04.find_first_not_of('S');
-  VERIFY( csz01 == npos );
-}
-
-#ifndef GDB_STRING_VIEW
-constexpr bool
-test04()
-{
-  typedef std::string_view::size_type csize_type;
-  csize_type npos = std::string_view::npos;
-  csize_type csz01 = 0;
-
-  const std::string_view str01("Bob Rock, per me");
-  const char str_lit01[] = "Bob Rock";
-  std::string_view str02("ovvero Trivi");
-  std::string_view str03(str_lit01);
-  std::string_view str04;
-
-#undef VERIFY
-#define VERIFY(x) if(!(x)) return false
-
-  // size_type find_first_not_of(const string_view&, size_type pos = 0) const;
-  csz01 = str01.find_first_not_of(str01);
-  VERIFY( csz01 == npos );
-  csz01 = str01.find_first_not_of(str02, 0);
-  VERIFY( csz01 == 0 );
-  csz01 = str01.find_first_not_of(str02, 10);
-  VERIFY( csz01 == 10 );
-  csz01 = str01.find_first_not_of(str02, 12);
-  VERIFY( csz01 == 14 );
-  csz01 = str01.find_first_not_of(str03, 0);
-  VERIFY( csz01 == 8 );
-  csz01 = str01.find_first_not_of(str03, 15);
-  VERIFY( csz01 == 15 );
-  csz01 = str01.find_first_not_of(str03, 16);
-  VERIFY( csz01 == npos );
-  csz01 = str01.find_first_not_of(str04, 0);
-  VERIFY( csz01 == 0 );
-  csz01 = str01.find_first_not_of(str04, 12);
-  VERIFY( csz01 == 12 );
-  csz01 = str03.find_first_not_of(str01, 0);
-  VERIFY( csz01 == npos );
-  csz01 = str04.find_first_not_of(str02, 0);
-  VERIFY( csz01 == npos );
-
-  // size_type find_first_not_of(const char* s, size_type pos, size_type n) const;
-  csz01 = str01.find_first_not_of(str_lit01, 0, 0);
-  VERIFY( csz01 == 0 );
-  csz01 = str01.find_first_not_of(str_lit01, 0, 8);
-  VERIFY( csz01 == 8 );
-  csz01 = str01.find_first_not_of(str_lit01, 10, 0);
-  VERIFY( csz01 == 10 );
-
-  // size_type find_first_not_of(const char* s, size_type pos = 0) const;
-  csz01 = str01.find_first_not_of(str_lit01);
-  VERIFY( csz01 == 8 );
-  csz01 = str02.find_first_not_of(str_lit01, 2);
-  VERIFY( csz01 == 2 );
-
-  // size_type find_first_not_of(char c, size_type pos = 0) const;
-  csz01 = str01.find_first_not_of('B');
-  VERIFY( csz01 == 1 );
-  csz01 = str01.find_first_not_of('o', 1);
-  VERIFY( csz01 == 2 );
-  csz01 = str02.find_first_not_of('z');
-  VERIFY( csz01 == 0 );
-  csz01 = str04.find_first_not_of('S');
-  VERIFY( csz01 == npos );
-
-  return true;
-}
-#endif
-
-static int
-main ()
-{
-  test03();
-#ifndef GDB_STRING_VIEW
-  static_assert( test04() );
-#endif
-
-  return 0;
-}
-
-} // namespace operations_find_3
diff --git a/gdb/unittests/basic_string_view/operations/find/char/4.cc b/gdb/unittests/basic_string_view/operations/find/char/4.cc
deleted file mode 100644
index 9e19c01030d..00000000000
--- a/gdb/unittests/basic_string_view/operations/find/char/4.cc
+++ /dev/null
@@ -1,45 +0,0 @@
-// { dg-options "-std=gnu++17" }
-
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-// basic_string_view find
-
-namespace operations_find_4 {
-
-// libstdc++/31401
-static void
-test01()
-{
-  typedef gdb::string_view::size_type csize_type;
-  csize_type npos = gdb::string_view::npos;
-
-  gdb::string_view use = "anu";
-  csize_type pos1 = use.find("a", npos);
-
-  VERIFY( pos1 == npos );
-}
-
-static int
-main ()
-{
-  test01();
-
-  return 0;
-}
-
-} // namespace operations_find_4
diff --git a/gdb/unittests/basic_string_view/operations/find/wchar_t/1.cc b/gdb/unittests/basic_string_view/operations/find/wchar_t/1.cc
deleted file mode 100644
index 08e9e7249c8..00000000000
--- a/gdb/unittests/basic_string_view/operations/find/wchar_t/1.cc
+++ /dev/null
@@ -1,163 +0,0 @@
-// { dg-options "-std=gnu++17" }
-
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-// basic_string_view find
-
-#include <string_view>
-#include <testsuite_hooks.h>
-
-void
-test01()
-{
-  typedef std::wstring_view::size_type csize_type;
-  typedef std::wstring_view::const_reference cref;
-  typedef std::wstring_view::reference ref;
-  csize_type npos = std::wstring_view::npos;
-  csize_type csz01, csz02;
-
-  const wchar_t str_lit01[] = L"mave";
-  const std::wstring_view str01(L"mavericks, santa cruz");
-  std::wstring_view str02(str_lit01);
-  std::wstring_view str03(L"s, s");
-  std::wstring_view str04;
-
-  // size_type find(const wstring_view&, size_type pos = 0) const;
-  csz01 = str01.find(str01);
-  VERIFY( csz01 == 0 );
-  csz01 = str01.find(str01, 4);
-  VERIFY( csz01 == npos );
-  csz01 = str01.find(str02, 0);
-  VERIFY( csz01 == 0 );
-  csz01 = str01.find(str02, 3);
-  VERIFY( csz01 == npos );
-  csz01 = str01.find(str03, 0);
-  VERIFY( csz01 == 8 );
-  csz01 = str01.find(str03, 3);
-  VERIFY( csz01 == 8 );
-  csz01 = str01.find(str03, 12);
-  VERIFY( csz01 == npos );
-
-  // An empty string_view consists of no characters
-  // therefore it should be found at every point in a string_view,
-  // except beyond the end
-  csz01 = str01.find(str04, 0);
-  VERIFY( csz01 == 0 );
-  csz01 = str01.find(str04, 5);
-  VERIFY( csz01 == 5 );
-  csz01 = str01.find(str04, str01.size());
-  VERIFY( csz01 == str01.size() );
-  csz01 = str01.find(str04, str01.size()+1);
-  VERIFY( csz01 == npos );
-
-  // size_type find(const wchar_t* s, size_type pos, size_type n) const;
-  csz01 = str01.find(str_lit01, 0, 3);
-  VERIFY( csz01 == 0 );
-  csz01 = str01.find(str_lit01, 3, 0);
-  VERIFY( csz01 == 3 );
-
-  // size_type find(const wchar_t* s, size_type pos = 0) const;
-  csz01 = str01.find(str_lit01);
-  VERIFY( csz01 == 0 );
-  csz01 = str01.find(str_lit01, 3);
-  VERIFY( csz01 == npos );
-
-  // size_type find(wchar_t c, size_type pos = 0) const;
-  csz01 = str01.find(L'z');
-  csz02 = str01.size() - 1;
-  VERIFY( csz01 == csz02 );
-  csz01 = str01.find(L'/');
-  VERIFY( csz01 == npos );
-}
-
-constexpr bool
-test02()
-{
-  typedef std::wstring_view::size_type csize_type;
-  typedef std::wstring_view::const_reference cref;
-  typedef std::wstring_view::reference ref;
-  csize_type npos = std::wstring_view::npos;
-  csize_type csz01 = 0, csz02 = 0;
-
-  const wchar_t str_lit01[] = L"mave";
-  const std::wstring_view str01(L"mavericks, santa cruz");
-  std::wstring_view str02(str_lit01);
-  std::wstring_view str03(L"s, s");
-  std::wstring_view str04;
-
-#undef VERIFY
-#define VERIFY(x) if(!(x)) return false
-
-  // size_type find(const wstring_view&, size_type pos = 0) const;
-  csz01 = str01.find(str01);
-  VERIFY( csz01 == 0 );
-  csz01 = str01.find(str01, 4);
-  VERIFY( csz01 == npos );
-  csz01 = str01.find(str02, 0);
-  VERIFY( csz01 == 0 );
-  csz01 = str01.find(str02, 3);
-  VERIFY( csz01 == npos );
-  csz01 = str01.find(str03, 0);
-  VERIFY( csz01 == 8 );
-  csz01 = str01.find(str03, 3);
-  VERIFY( csz01 == 8 );
-  csz01 = str01.find(str03, 12);
-  VERIFY( csz01 == npos );
-
-  // An empty string_view consists of no characters
-  // therefore it should be found at every point in a string_view,
-  // except beyond the end
-  csz01 = str01.find(str04, 0);
-  VERIFY( csz01 == 0 );
-  csz01 = str01.find(str04, 5);
-  VERIFY( csz01 == 5 );
-  csz01 = str01.find(str04, str01.size());
-  VERIFY( csz01 == str01.size() );
-  csz01 = str01.find(str04, str01.size()+1);
-  VERIFY( csz01 == npos );
-
-  // size_type find(const wchar_t* s, size_type pos, size_type n) const;
-  csz01 = str01.find(str_lit01, 0, 3);
-  VERIFY( csz01 == 0 );
-  csz01 = str01.find(str_lit01, 3, 0);
-  VERIFY( csz01 == 3 );
-
-  // size_type find(const wchar_t* s, size_type pos = 0) const;
-  csz01 = str01.find(str_lit01);
-  VERIFY( csz01 == 0 );
-  csz01 = str01.find(str_lit01, 3);
-  VERIFY( csz01 == npos );
-
-  // size_type find(wchar_t c, size_type pos = 0) const;
-  csz01 = str01.find(L'z');
-  csz02 = str01.size() - 1;
-  VERIFY( csz01 == csz02 );
-  csz01 = str01.find(L'/');
-  VERIFY( csz01 == npos );
-
-  return true;
-}
-
-int
-main()
-{
-  test01();
-  static_assert( test02() );
-
-  return 0;
-}
diff --git a/gdb/unittests/basic_string_view/operations/find/wchar_t/2.cc b/gdb/unittests/basic_string_view/operations/find/wchar_t/2.cc
deleted file mode 100644
index fa38fe8e79c..00000000000
--- a/gdb/unittests/basic_string_view/operations/find/wchar_t/2.cc
+++ /dev/null
@@ -1,161 +0,0 @@
-// { dg-options "-std=gnu++17" }
-
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-// basic_string_view find_first_of
-
-#include <string_view>
-#include <testsuite_hooks.h>
-
-void
-test02()
-{
-  typedef std::wstring_view::size_type csize_type;
-  csize_type npos = std::wstring_view::npos;
-  csize_type csz01, csz02;
-
-  const wchar_t str_lit01[] = L"mave";
-  const std::wstring_view str01(L"mavericks, santa cruz");
-  std::wstring_view str02(str_lit01);
-  std::wstring_view str03(L"s, s");
-  std::wstring_view str04;
-
-  // size_type find_first_of(const wstring_view&, size_type pos = 0) const;
-  std::wstring_view str05(L"xena rulez");
-  csz01 = str01.find_first_of(str01);
-  VERIFY( csz01 == 0 );
-  csz01 = str01.find_first_of(str01, 4);
-  VERIFY( csz01 == 4 );
-  csz01 = str01.find_first_of(str02, 0);
-  VERIFY( csz01 == 0 );
-  csz01 = str01.find_first_of(str02, 3);
-  VERIFY( csz01 == 3 );
-  csz01 = str01.find_first_of(str03, 0);
-  VERIFY( csz01 == 8 );
-  csz01 = str01.find_first_of(str03, 3);
-  VERIFY( csz01 == 8 );
-  csz01 = str01.find_first_of(str03, 12);
-  VERIFY( csz01 == 16 );
-  csz01 = str01.find_first_of(str05, 0);
-  VERIFY( csz01 == 1 );
-  csz01 = str01.find_first_of(str05, 4);
-  VERIFY( csz01 == 4 );
-
-  // An empty string_view consists of no characters
-  // therefore it should be found at every point in a string_view,
-  // except beyond the end
-  // However, str1.find_first_of(str2,pos) finds the first character in
-  // str1 (starting at pos) that exists in str2, which is none for empty str2
-  csz01 = str01.find_first_of(str04, 0);
-  VERIFY( csz01 == npos );
-  csz01 = str01.find_first_of(str04, 5);
-  VERIFY( csz01 == npos );
-
-  // size_type find_first_of(const wchar_t* s, size_type pos, size_type n) const;
-  csz01 = str01.find_first_of(str_lit01, 0, 3);
-  VERIFY( csz01 == 0 );
-  csz01 = str01.find_first_of(str_lit01, 3, 0);
-  VERIFY( csz01 == npos );
-
-  // size_type find_first_of(const wchar_t* s, size_type pos = 0) const;
-  csz01 = str01.find_first_of(str_lit01);
-  VERIFY( csz01 == 0 );
-  csz01 = str01.find_first_of(str_lit01, 3);
-  VERIFY( csz01 == 3 );
-
-  // size_type find_first_of(wchar_t c, size_type pos = 0) const;
-  csz01 = str01.find_first_of(L'z');
-  csz02 = str01.size() - 1;
-  VERIFY( csz01 == csz02 );
-}
-
-constexpr bool
-test04()
-{
-  typedef std::wstring_view::size_type csize_type;
-  csize_type npos = std::wstring_view::npos;
-  csize_type csz01 = 0, csz02 = 0;
-
-  const wchar_t str_lit01[] = L"mave";
-  const std::wstring_view str01(L"mavericks, santa cruz");
-  std::wstring_view str02(str_lit01);
-  std::wstring_view str03(L"s, s");
-  std::wstring_view str04;
-
-#undef VERIFY
-#define VERIFY(x) if(!(x)) return false
-
-  // size_type find_first_of(const wstring_view&, size_type pos = 0) const;
-  std::wstring_view str05(L"xena rulez");
-  csz01 = str01.find_first_of(str01);
-  VERIFY( csz01 == 0 );
-  csz01 = str01.find_first_of(str01, 4);
-  VERIFY( csz01 == 4 );
-  csz01 = str01.find_first_of(str02, 0);
-  VERIFY( csz01 == 0 );
-  csz01 = str01.find_first_of(str02, 3);
-  VERIFY( csz01 == 3 );
-  csz01 = str01.find_first_of(str03, 0);
-  VERIFY( csz01 == 8 );
-  csz01 = str01.find_first_of(str03, 3);
-  VERIFY( csz01 == 8 );
-  csz01 = str01.find_first_of(str03, 12);
-  VERIFY( csz01 == 16 );
-  csz01 = str01.find_first_of(str05, 0);
-  VERIFY( csz01 == 1 );
-  csz01 = str01.find_first_of(str05, 4);
-  VERIFY( csz01 == 4 );
-
-  // An empty string_view consists of no characters
-  // therefore it should be found at every point in a string_view,
-  // except beyond the end
-  // However, str1.find_first_of(str2,pos) finds the first character in
-  // str1 (starting at pos) that exists in str2, which is none for empty str2
-  csz01 = str01.find_first_of(str04, 0);
-  VERIFY( csz01 == npos );
-  csz01 = str01.find_first_of(str04, 5);
-  VERIFY( csz01 == npos );
-
-  // size_type find_first_of(const wchar_t* s, size_type pos, size_type n) const;
-  csz01 = str01.find_first_of(str_lit01, 0, 3);
-  VERIFY( csz01 == 0 );
-  csz01 = str01.find_first_of(str_lit01, 3, 0);
-  VERIFY( csz01 == npos );
-
-  // size_type find_first_of(const wchar_t* s, size_type pos = 0) const;
-  csz01 = str01.find_first_of(str_lit01);
-  VERIFY( csz01 == 0 );
-  csz01 = str01.find_first_of(str_lit01, 3);
-  VERIFY( csz01 == 3 );
-
-  // size_type find_first_of(wchar_t c, size_type pos = 0) const;
-  csz01 = str01.find_first_of(L'z');
-  csz02 = str01.size() - 1;
-  VERIFY( csz01 == csz02 );
-
-  return true;
-}
-
-int
-main()
-{
-  test02();
-  static_assert( test04() );
-
-  return 0;
-}
diff --git a/gdb/unittests/basic_string_view/operations/find/wchar_t/3.cc b/gdb/unittests/basic_string_view/operations/find/wchar_t/3.cc
deleted file mode 100644
index 93a238c3865..00000000000
--- a/gdb/unittests/basic_string_view/operations/find/wchar_t/3.cc
+++ /dev/null
@@ -1,161 +0,0 @@
-// { dg-options "-std=gnu++17" }
-
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-// basic_string_view find_first_not_of
-
-#include <string_view>
-#include <testsuite_hooks.h>
-
-void
-test03()
-{
-  typedef std::wstring_view::size_type csize_type;
-  csize_type npos = std::wstring_view::npos;
-  csize_type csz01;
-
-  const std::wstring_view str01(L"Bob Rock, per me");
-  const wchar_t str_lit01[] = L"Bob Rock";
-  std::wstring_view str02(L"ovvero Trivi");
-  std::wstring_view str03(str_lit01);
-  std::wstring_view str04;
-
-  // size_type find_first_not_of(const string_view&, size_type pos = 0) const;
-  csz01 = str01.find_first_not_of(str01);
-  VERIFY( csz01 == npos );
-  csz01 = str01.find_first_not_of(str02, 0);
-  VERIFY( csz01 == 0 );
-  csz01 = str01.find_first_not_of(str02, 10);
-  VERIFY( csz01 == 10 );
-  csz01 = str01.find_first_not_of(str02, 12);
-  VERIFY( csz01 == 14 );
-  csz01 = str01.find_first_not_of(str03, 0);
-  VERIFY( csz01 == 8 );
-  csz01 = str01.find_first_not_of(str03, 15);
-  VERIFY( csz01 == 15 );
-  csz01 = str01.find_first_not_of(str03, 16);
-  VERIFY( csz01 == npos );
-  csz01 = str01.find_first_not_of(str04, 0);
-  VERIFY( csz01 == 0 );
-  csz01 = str01.find_first_not_of(str04, 12);
-  VERIFY( csz01 == 12 );
-  csz01 = str03.find_first_not_of(str01, 0);
-  VERIFY( csz01 == npos );
-  csz01 = str04.find_first_not_of(str02, 0);
-  VERIFY( csz01 == npos );
-
-  // size_type find_first_not_of(const char* s, size_type pos, size_type n) const;
-  csz01 = str01.find_first_not_of(str_lit01, 0, 0);
-  VERIFY( csz01 == 0 );
-  csz01 = str01.find_first_not_of(str_lit01, 0, 8);
-  VERIFY( csz01 == 8 );
-  csz01 = str01.find_first_not_of(str_lit01, 10, 0);
-  VERIFY( csz01 == 10 );
-
-  // size_type find_first_not_of(const char* s, size_type pos = 0) const;
-  csz01 = str01.find_first_not_of(str_lit01);
-  VERIFY( csz01 == 8 );
-  csz01 = str02.find_first_not_of(str_lit01, 2);
-  VERIFY( csz01 == 2 );
-
-  // size_type find_first_not_of(char c, size_type pos = 0) const;
-  csz01 = str01.find_first_not_of(L'B');
-  VERIFY( csz01 == 1 );
-  csz01 = str01.find_first_not_of(L'o', 1);
-  VERIFY( csz01 == 2 );
-  csz01 = str02.find_first_not_of(L'z');
-  VERIFY( csz01 == 0 );
-  csz01 = str04.find_first_not_of(L'S');
-  VERIFY( csz01 == npos );
-}
-
-constexpr bool
-test04()
-{
-  typedef std::wstring_view::size_type csize_type;
-  csize_type npos = std::wstring_view::npos;
-  csize_type csz01 = 0;
-
-  const std::wstring_view str01(L"Bob Rock, per me");
-  const wchar_t str_lit01[] = L"Bob Rock";
-  std::wstring_view str02(L"ovvero Trivi");
-  std::wstring_view str03(str_lit01);
-  std::wstring_view str04;
-
-#undef VERIFY
-#define VERIFY(x) if(!(x)) return false
-
-  // size_type find_first_not_of(const string_view&, size_type pos = 0) const;
-  csz01 = str01.find_first_not_of(str01);
-  VERIFY( csz01 == npos );
-  csz01 = str01.find_first_not_of(str02, 0);
-  VERIFY( csz01 == 0 );
-  csz01 = str01.find_first_not_of(str02, 10);
-  VERIFY( csz01 == 10 );
-  csz01 = str01.find_first_not_of(str02, 12);
-  VERIFY( csz01 == 14 );
-  csz01 = str01.find_first_not_of(str03, 0);
-  VERIFY( csz01 == 8 );
-  csz01 = str01.find_first_not_of(str03, 15);
-  VERIFY( csz01 == 15 );
-  csz01 = str01.find_first_not_of(str03, 16);
-  VERIFY( csz01 == npos );
-  csz01 = str01.find_first_not_of(str04, 0);
-  VERIFY( csz01 == 0 );
-  csz01 = str01.find_first_not_of(str04, 12);
-  VERIFY( csz01 == 12 );
-  csz01 = str03.find_first_not_of(str01, 0);
-  VERIFY( csz01 == npos );
-  csz01 = str04.find_first_not_of(str02, 0);
-  VERIFY( csz01 == npos );
-
-  // size_type find_first_not_of(const char* s, size_type pos, size_type n) const;
-  csz01 = str01.find_first_not_of(str_lit01, 0, 0);
-  VERIFY( csz01 == 0 );
-  csz01 = str01.find_first_not_of(str_lit01, 0, 8);
-  VERIFY( csz01 == 8 );
-  csz01 = str01.find_first_not_of(str_lit01, 10, 0);
-  VERIFY( csz01 == 10 );
-
-  // size_type find_first_not_of(const char* s, size_type pos = 0) const;
-  csz01 = str01.find_first_not_of(str_lit01);
-  VERIFY( csz01 == 8 );
-  csz01 = str02.find_first_not_of(str_lit01, 2);
-  VERIFY( csz01 == 2 );
-
-  // size_type find_first_not_of(char c, size_type pos = 0) const;
-  csz01 = str01.find_first_not_of(L'B');
-  VERIFY( csz01 == 1 );
-  csz01 = str01.find_first_not_of(L'o', 1);
-  VERIFY( csz01 == 2 );
-  csz01 = str02.find_first_not_of(L'z');
-  VERIFY( csz01 == 0 );
-  csz01 = str04.find_first_not_of(L'S');
-  VERIFY( csz01 == npos );
-
-  return true;
-}
-
-int
-main()
-{
-  test03();
-  static_assert( test04() );
-
-  return 0;
-}
diff --git a/gdb/unittests/basic_string_view/operations/find/wchar_t/4.cc b/gdb/unittests/basic_string_view/operations/find/wchar_t/4.cc
deleted file mode 100644
index 7b484bd6b9b..00000000000
--- a/gdb/unittests/basic_string_view/operations/find/wchar_t/4.cc
+++ /dev/null
@@ -1,44 +0,0 @@
-// { dg-options "-std=gnu++17" }
-
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-// basic_string_view find
-
-#include <string_view>
-#include <testsuite_hooks.h>
-
-// libstdc++/31401
-void
-test01()
-{
-  typedef std::wstring_view::size_type csize_type;
-  csize_type npos = std::wstring_view::npos;
-
-  std::wstring_view use = L"anu";
-  csize_type pos1 = use.find(L"a", npos);
-
-  VERIFY( pos1 == npos );
-}
-
-int
-main()
-{
-  test01();
-
-  return 0;
-}
diff --git a/gdb/unittests/basic_string_view/operations/rfind/char/1.cc b/gdb/unittests/basic_string_view/operations/rfind/char/1.cc
deleted file mode 100644
index b764cd959ab..00000000000
--- a/gdb/unittests/basic_string_view/operations/rfind/char/1.cc
+++ /dev/null
@@ -1,95 +0,0 @@
-// { dg-options "-std=gnu++17" }
-
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-namespace operations_rfind_1 {
-
-// basic_string_view rfind
-
-static void
-test01 ()
-{
-  typedef gdb::string_view::size_type csize_type;
-  typedef gdb::string_view::const_reference cref;
-  typedef gdb::string_view::reference ref;
-  csize_type npos = gdb::string_view::npos;
-  csize_type csz01, csz02;
-
-  const char str_lit01[] = "mave";
-  const gdb::string_view str01("mavericks, santa cruz");
-  gdb::string_view str02(str_lit01);
-  gdb::string_view str03("s, s");
-  gdb::string_view str04;
-
-  // size_type rfind(const string_view&, size_type pos = 0) const;
-  csz01 = str01.rfind(str01);
-  VERIFY( csz01 == 0 );
-  csz01 = str01.rfind(str01, 4);
-  VERIFY( csz01 == 0 );
-  csz01 = str01.rfind(str02,3);
-  VERIFY( csz01 == 0 );
-  csz01 = str01.rfind(str02);
-  VERIFY( csz01 == 0 );
-  csz01 = str01.rfind(str03);
-  VERIFY( csz01 == 8 );
-  csz01 = str01.rfind(str03, 3);
-  VERIFY( csz01 == npos );
-  csz01 = str01.rfind(str03, 12);
-  VERIFY( csz01 == 8 );
-
-  // An empty string_view consists of no characters
-  // therefore it should be found at every point in a string_view,
-  // except beyond the end
-  csz01 = str01.rfind(str04, 0);
-  VERIFY( csz01 == 0 );
-  csz01 = str01.rfind(str04, 5);
-  VERIFY( csz01 == 5 );
-  csz01 = str01.rfind(str04, str01.size());
-  VERIFY( csz01 == str01.size() );
-  csz01 = str01.rfind(str04, str01.size()+1);
-  VERIFY( csz01 == str01.size() );
-
-  // size_type rfind(const char* s, size_type pos, size_type n) const;
-  csz01 = str01.rfind(str_lit01, 0, 3);
-  VERIFY( csz01 == 0 );
-  csz01 = str01.rfind(str_lit01, 3, 0);
-  VERIFY( csz01 == 3 );
-
-  // size_type rfind(const char* s, size_type pos = 0) const;
-  csz01 = str01.rfind(str_lit01);
-  VERIFY( csz01 == 0 );
-  csz01 = str01.rfind(str_lit01, 3);
-  VERIFY( csz01 == 0 );
-
-  // size_type rfind(char c, size_type pos = 0) const;
-  csz01 = str01.rfind('z');
-  csz02 = str01.size() - 1;
-  VERIFY( csz01 == csz02 );
-  csz01 = str01.rfind('/');
-  VERIFY( csz01 == npos );
-}
-
-static int
-main ()
-{
-  test01();
-
-  return 0;
-}
-
-} // namespace operations_rfind_1
diff --git a/gdb/unittests/basic_string_view/operations/rfind/char/2.cc b/gdb/unittests/basic_string_view/operations/rfind/char/2.cc
deleted file mode 100644
index 915a111fbcc..00000000000
--- a/gdb/unittests/basic_string_view/operations/rfind/char/2.cc
+++ /dev/null
@@ -1,53 +0,0 @@
-// { dg-options "-std=gnu++17" }
-
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-namespace operations_rfind_2 {
-
-// basic_string_view::find_last_of
-
-static void
-test02 ()
-{
-  gdb::string_view z("ab");
-  gdb::string_view::size_type pos;
-  pos = z.find_last_of("ab");
-  VERIFY( pos == 1 );
-  pos = z.find_last_of("Xa");
-  VERIFY( pos == 0 );
-  pos = z.find_last_of("Xb");
-  VERIFY( pos == 1 );
-  pos = z.find_last_of("XYZ");
-  VERIFY( pos == gdb::string_view::npos );
-  pos = z.find_last_of('a');
-  VERIFY( pos == 0 );
-  pos = z.find_last_of('b');
-  VERIFY( pos == 1 );
-  pos = z.find_last_of('X');
-  VERIFY( pos == gdb::string_view::npos );
-}
-
-static int
-main ()
-{
-  test02();
-
-  return 0;
-}
-
-} // namespace operations_rfind_2
diff --git a/gdb/unittests/basic_string_view/operations/rfind/char/3.cc b/gdb/unittests/basic_string_view/operations/rfind/char/3.cc
deleted file mode 100644
index a15debf97ec..00000000000
--- a/gdb/unittests/basic_string_view/operations/rfind/char/3.cc
+++ /dev/null
@@ -1,68 +0,0 @@
-// { dg-options "-std=gnu++17" }
-
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-namespace operations_rfind_3 {
-
-// basic_string_view::find_last_not_of
-
-static void
-test03 ()
-{
-  typedef gdb::string_view::size_type csize_type;
-  gdb::string_view::size_type pos;
-  csize_type npos = gdb::string_view::npos;
-
-  gdb::string_view x;
-  pos = x.find_last_not_of('X');
-  VERIFY( pos == npos );
-  pos = x.find_last_not_of("XYZ");
-  VERIFY( pos == npos );
-
-  gdb::string_view y("a");
-  pos = y.find_last_not_of('X');
-  VERIFY( pos == 0 );
-  pos = y.find_last_not_of('a');
-  VERIFY( pos == npos );
-  pos = y.find_last_not_of("XYZ");
-  VERIFY( pos == 0 );
-  pos = y.find_last_not_of("a");
-  VERIFY( pos == npos );
-
-  gdb::string_view z("ab");
-  pos = z.find_last_not_of('X');
-  VERIFY( pos == 1 );
-  pos = z.find_last_not_of("XYZ");
-  VERIFY( pos == 1 );
-  pos = z.find_last_not_of('b');
-  VERIFY( pos == 0 );
-  pos = z.find_last_not_of("Xb");
-  VERIFY( pos == 0 );
-  pos = z.find_last_not_of("Xa");
-  VERIFY( pos == 1 );
-}
-
-static int
-main ()
-{
-  test03();
-
-  return 0;
-}
-
-} // namespace operations_rfind_3
diff --git a/gdb/unittests/basic_string_view/operations/rfind/wchar_t/1.cc b/gdb/unittests/basic_string_view/operations/rfind/wchar_t/1.cc
deleted file mode 100644
index d5ad681eded..00000000000
--- a/gdb/unittests/basic_string_view/operations/rfind/wchar_t/1.cc
+++ /dev/null
@@ -1,94 +0,0 @@
-// { dg-options "-std=gnu++17" }
-
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-#include <string_view>
-#include <testsuite_hooks.h>
-
-// basic_string_view rfind
-
-void
-test01()
-{
-  typedef std::wstring_view::size_type csize_type;
-  typedef std::wstring_view::const_reference cref;
-  typedef std::wstring_view::reference ref;
-  csize_type npos = std::wstring_view::npos;
-  csize_type csz01, csz02;
-
-  const wchar_t str_lit01[] = L"mave";
-  const std::wstring_view str01(L"mavericks, santa cruz");
-  std::wstring_view str02(str_lit01);
-  std::wstring_view str03(L"s, s");
-  std::wstring_view str04;
-
-  // size_type rfind(const wstring_view&, size_type pos = 0) const;
-  csz01 = str01.rfind(str01);
-  VERIFY( csz01 == 0 );
-  csz01 = str01.rfind(str01, 4);
-  VERIFY( csz01 == 0 );
-  csz01 = str01.rfind(str02,3);
-  VERIFY( csz01 == 0 );
-  csz01 = str01.rfind(str02);
-  VERIFY( csz01 == 0 );
-  csz01 = str01.rfind(str03);
-  VERIFY( csz01 == 8 );
-  csz01 = str01.rfind(str03, 3);
-  VERIFY( csz01 == npos );
-  csz01 = str01.rfind(str03, 12);
-  VERIFY( csz01 == 8 );
-
-  // An empty string_view consists of no characters
-  // therefore it should be found at every point in a string_view,
-  // except beyond the end
-  csz01 = str01.rfind(str04, 0);
-  VERIFY( csz01 == 0 );
-  csz01 = str01.rfind(str04, 5);
-  VERIFY( csz01 == 5 );
-  csz01 = str01.rfind(str04, str01.size());
-  VERIFY( csz01 == str01.size() );
-  csz01 = str01.rfind(str04, str01.size()+1);
-  VERIFY( csz01 == str01.size() );
-
-  // size_type rfind(const wchar_t* s, size_type pos, size_type n) const;
-  csz01 = str01.rfind(str_lit01, 0, 3);
-  VERIFY( csz01 == 0 );
-  csz01 = str01.rfind(str_lit01, 3, 0);
-  VERIFY( csz01 == 3 );
-
-  // size_type rfind(const wchar_t* s, size_type pos = 0) const;
-  csz01 = str01.rfind(str_lit01);
-  VERIFY( csz01 == 0 );
-  csz01 = str01.rfind(str_lit01, 3);
-  VERIFY( csz01 == 0 );
-
-  // size_type rfind(wchar_t c, size_type pos = 0) const;
-  csz01 = str01.rfind(L'z');
-  csz02 = str01.size() - 1;
-  VERIFY( csz01 == csz02 );
-  csz01 = str01.rfind(L'/');
-  VERIFY( csz01 == npos );
-}
-
-int
-main()
-{
-  test01();
-
-  return 0;
-}
diff --git a/gdb/unittests/basic_string_view/operations/rfind/wchar_t/2.cc b/gdb/unittests/basic_string_view/operations/rfind/wchar_t/2.cc
deleted file mode 100644
index 6f3dc744ad7..00000000000
--- a/gdb/unittests/basic_string_view/operations/rfind/wchar_t/2.cc
+++ /dev/null
@@ -1,52 +0,0 @@
-// { dg-options "-std=gnu++17" }
-
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-#include <string_view>
-#include <testsuite_hooks.h>
-
-// basic_string_view::find_last_of
-
-void
-test02()
-{
-  std::wstring_view::size_type pos;
-  std::wstring_view z(L"ab");
-  pos = z.find_last_of(L"ab");
-  VERIFY( pos == 1 );
-  pos = z.find_last_of(L"Xa");
-  VERIFY( pos == 0 );
-  pos = z.find_last_of(L"Xb");
-  VERIFY( pos == 1 );
-  pos = z.find_last_of(L"XYZ");
-  VERIFY( pos == std::wstring_view::npos );
-  pos = z.find_last_of(L'a');
-  VERIFY( pos == 0 );
-  pos = z.find_last_of(L'b');
-  VERIFY( pos == 1 );
-  pos = z.find_last_of(L'X');
-  VERIFY( pos == std::wstring_view::npos );
-}
-
-int
-main()
-{
-  test02();
-
-  return 0;
-}
diff --git a/gdb/unittests/basic_string_view/operations/rfind/wchar_t/3.cc b/gdb/unittests/basic_string_view/operations/rfind/wchar_t/3.cc
deleted file mode 100644
index b67f8ec08af..00000000000
--- a/gdb/unittests/basic_string_view/operations/rfind/wchar_t/3.cc
+++ /dev/null
@@ -1,66 +0,0 @@
-// { dg-options "-std=gnu++17" }
-
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-#include <string_view>
-#include <testsuite_hooks.h>
-
-// basic_string_view::find_last_not_of
-
-void
-test03()
-{
-  typedef std::wstring_view::size_type csize_type;
-  std::wstring_view::size_type pos;
-  csize_type npos = std::wstring_view::npos;
-
-  std::wstring_view x;
-  pos = x.find_last_not_of(L'X');
-  VERIFY( pos == npos );
-  pos = x.find_last_not_of(L"XYZ");
-  VERIFY( pos == npos );
-
-  std::wstring_view y(L"a");
-  pos = y.find_last_not_of(L'X');
-  VERIFY( pos == 0 );
-  pos = y.find_last_not_of(L'a');
-  VERIFY( pos == npos );
-  pos = y.find_last_not_of(L"XYZ");
-  VERIFY( pos == 0 );
-  pos = y.find_last_not_of(L"a");
-  VERIFY( pos == npos );
-
-  std::wstring_view z(L"ab");
-  pos = z.find_last_not_of(L'X');
-  VERIFY( pos == 1 );
-  pos = z.find_last_not_of(L"XYZ");
-  VERIFY( pos == 1 );
-  pos = z.find_last_not_of(L'b');
-  VERIFY( pos == 0 );
-  pos = z.find_last_not_of(L"Xb");
-  VERIFY( pos == 0 );
-  pos = z.find_last_not_of(L"Xa");
-  VERIFY( pos == 1 );
-}
-int
-main()
-{
-  test03();
-
-  return 0;
-}
diff --git a/gdb/unittests/basic_string_view/operations/string_conversion/1.cc b/gdb/unittests/basic_string_view/operations/string_conversion/1.cc
deleted file mode 100644
index 33784231d8d..00000000000
--- a/gdb/unittests/basic_string_view/operations/string_conversion/1.cc
+++ /dev/null
@@ -1,51 +0,0 @@
-// { dg-options "-std=gnu++17" }
-
-// Copyright (C) 2014-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-// basic_string_view::to_string
-
-#include <string_view>
-#include <string>
-#include <algorithm>
-#include <testsuite_hooks.h>
-#include <testsuite_allocator.h>
-
-void
-test01()
-{
-  const char str_lit[] = "123456789A";
-  const std::string_view sv(str_lit);
-  char buffer[4] = { 0 };
-
-  std::string s1{sv};
-  VERIFY( s1 == str_lit );
-  using test_alloc = __gnu_test::tracker_allocator<char>;
-  std::basic_string<char, std::char_traits<char>, test_alloc>
-    s2{sv, test_alloc{}};
-  static_assert( std::is_same<decltype(s2)::allocator_type, test_alloc>::value,
-                 "to_string() uses custom allocator" );
-  VERIFY( std::equal(s1.begin(), s1.end(), s2.begin(), s2.end()) );
-  auto s3 = static_cast<std::string>(sv);
-  VERIFY( s3 == s1 );
-}
-
-int
-main()
-{
-  test01();
-}
diff --git a/gdb/unittests/basic_string_view/operations/substr/char/1.cc b/gdb/unittests/basic_string_view/operations/substr/char/1.cc
deleted file mode 100644
index 19454466699..00000000000
--- a/gdb/unittests/basic_string_view/operations/substr/char/1.cc
+++ /dev/null
@@ -1,79 +0,0 @@
-// { dg-options "-std=gnu++17" }
-
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-// basic_string_view::substr
-
-namespace operations_substr_1 {
-
-static void
-test01 ()
-{
-  typedef gdb::string_view::size_type csize_type;
-  typedef gdb::string_view::const_reference cref;
-  typedef gdb::string_view::reference ref;
-  csize_type csz01;
-
-  const char str_lit01[] = "rockaway, pacifica";
-  const gdb::string_view str01(str_lit01);
-  gdb::string_view str02;
-
-  // basic_string_view<charT, _Traits, _Alloc>
-  //  substr(size_type pos = 0, size_type n = npos) const;
-  csz01 = str01.size();
-  str02 = str01.substr(0, 1);
-  VERIFY( str02 == "r" );
-  str02 = str01.substr(10);
-  VERIFY( str02 == "pacifica" );
-
-  try
-  {
-    str02 = str01.substr(csz01 + 1);
-    VERIFY( false ); 
-  }
-  catch(gdb_exception& fail)
-  {
-    VERIFY( true );
-  }
-  catch(...)
-  {
-    VERIFY( false );
-  }
-
-  try
-  {
-    str02 = str01.substr(csz01);
-    VERIFY( str02.size() == 0 );
-    VERIFY( str02.begin() == str01.end() );
-    VERIFY( true );
-  }
-  catch(...)
-  {
-    VERIFY( false );
-  }
-}
-
-static int
-main ()
-{ 
-  test01();
-
-  return 0;
-}
-
-} // namespace operations_substr_1
diff --git a/gdb/unittests/basic_string_view/operations/substr/wchar_t/1.cc b/gdb/unittests/basic_string_view/operations/substr/wchar_t/1.cc
deleted file mode 100644
index bfe79ac7a55..00000000000
--- a/gdb/unittests/basic_string_view/operations/substr/wchar_t/1.cc
+++ /dev/null
@@ -1,79 +0,0 @@
-// { dg-options "-std=gnu++17" }
-
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-// basic_string_view::substr
-
-#include <string_view>
-#include <stdexcept>
-#include <testsuite_hooks.h>
-
-void
-test01()
-{
-  typedef std::wstring_view::size_type csize_type;
-  typedef std::wstring_view::const_reference cref;
-  typedef std::wstring_view::reference ref;
-  csize_type csz01;
-
-  const wchar_t str_lit01[] = L"rockaway, pacifica";
-  const std::wstring_view str01(str_lit01);
-  std::wstring_view str02;
-
-  // basic_string_view<charT, _Traits, _Alloc>
-  //  substr(size_type pos = 0, size_type n = npos) const;
-  csz01 = str01.size();
-  str02 = str01.substr(0, 1);
-  VERIFY( str02 == L"r" );
-  str02 = str01.substr(10);
-  VERIFY( str02 == L"pacifica" );
-
-  try
-  {
-    str02 = str01.substr(csz01 + 1);
-    VERIFY( false ); 
-  }
-  catch(std::out_of_range& fail)
-  {
-    VERIFY( true );
-  }
-  catch(...)
-  {
-    VERIFY( false );
-  }
-
-  try
-  {
-    str02 = str01.substr(csz01);
-    VERIFY( str02.size() == 0 );
-    VERIFY( str02.begin() == str01.end() );
-    VERIFY( true );
-  }
-  catch(...)
-  {
-    VERIFY( false );
-  }
-}
-
-int
-main()
-{ 
-  test01();
-
-  return 0;
-}
diff --git a/gdb/unittests/basic_string_view/operators/char/2.cc b/gdb/unittests/basic_string_view/operators/char/2.cc
deleted file mode 100644
index 30e557f4599..00000000000
--- a/gdb/unittests/basic_string_view/operators/char/2.cc
+++ /dev/null
@@ -1,373 +0,0 @@
-// { dg-options "-std=gnu++17" }
-
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-// basic_string non-member functions
-
-// operator==
-/*
-template<class charT, class traits, class Allocator>
-  bool operator==(const basic_string<charT,traits,Allocator>& lhs,
-                  const basic_string<charT,traits,Allocator>& rhs);
-
-template<class charT, class traits, class Allocator>
-  bool operator==(const charT* lhs,
-                  const basic_string<charT,traits,Allocator>& rhs);
-
-template<class charT, class traits, class Allocator>
-  bool operator==(const basic_string<charT,traits,Allocator>& lhs,
-                  const charT* rhs);
-*/
-
-// operator!=
-/*
-template<class charT, class traits, class Allocator>
-  bool operator!=(const basic_string<charT,traits,Allocator>& lhs,
-                  const basic_string<charT,traits,Allocator>& rhs);
-
-template<class charT, class traits, class Allocator>
-  bool operator!=(const charT* lhs,
-                  const basic_string<charT,traits,Allocator>& rhs);
-
-template<class charT, class traits, class Allocator>
-  bool operator!=(const basic_string<charT,traits,Allocator>& lhs, 
-                  const charT* rhs);
-*/
-
-// operator<
-/*
-template<class charT, class traits, class Allocator>
-  bool operator< (const basic_string<charT,traits,Allocator>& lhs,
-                  const basic_string<charT,traits,Allocator>& rhs);
-
-template<class charT, class traits, class Allocator>
-  bool operator< (const basic_string<charT,traits,Allocator>& lhs,
-                  const charT* rhs);
-
-template<class charT, class traits, class Allocator>
-  bool operator< (const charT* lhs, 
-                  const basic_string<charT,traits,Allocator>& rhs);
-*/
-
-// operator>
-/*
-template<class charT, class traits, class Allocator>
-  bool operator> (const basic_string<charT,traits,Allocator>& lhs,
-                  const basic_string<charT,traits,Allocator>& rhs);
-
-template<class charT, class traits, class Allocator>
-  bool operator> (const basic_string<charT,traits,Allocator>& lhs,
-                  const charT* rhs);
-
-template<class charT, class traits, class Allocator>
-  bool operator> (const charT* lhs,
-                  const basic_string<charT,traits,Allocator>& rhs);
-*/
-
-// operator<=
-/*
-template<class charT, class traits, class Allocator>
-  bool operator<=(const basic_string<charT,traits,Allocator>& lhs,
-                  const basic_string<charT,traits,Allocator>& rhs);
-
-template<class charT, class traits, class Allocator>
-  bool operator<=(const basic_string<charT,traits,Allocator>& lhs,
-                  const charT* rhs);
-
-template<class charT, class traits, class Allocator>
-  bool operator<=(const charT* lhs,
-                  const basic_string<charT,traits,Allocator>& rhs);
-*/
-
-// operator>=
-/*
-template<class charT, class traits, class Allocator>
-  bool operator>=(const basic_string<charT,traits,Allocator>& lhs,
-                const basic_string<charT,traits,Allocator>& rhs);
-
-template<class charT, class traits, class Allocator>
-  bool operator>=(const basic_string<charT,traits,Allocator>& lhs,
-                  const charT* rhs);
-
-template<class charT, class traits, class Allocator>
-  bool operator>=(const charT* lhs,
-                  const basic_string<charT,traits,Allocator>& rhs);
-*/
-
-namespace operators_2 {
-
-static void
-test01()
-{
-  gdb::string_view 	str_0("costa rica");
-  gdb::string_view 	str_1("costa marbella");
-  gdb::string_view 	str_2("cost");
-  gdb::string_view	str_3("costa ricans");
-  gdb::string_view      str_4;
-
-  str_4 = str_0;
-  //comparisons between string objects
-  VERIFY( !(str_0 == str_1) );
-  VERIFY( !(str_0 == str_2) );
-  VERIFY( !(str_0 == str_3) );
-  VERIFY( !(str_1 == str_0) );
-  VERIFY( !(str_2 == str_0) );
-  VERIFY( !(str_3 == str_0) );
-  VERIFY( str_4 == str_0 );
-  VERIFY( str_0 == str_4 );
-
-  VERIFY( str_0 != str_1 );
-  VERIFY( str_0 != str_2 );
-  VERIFY( str_0 != str_3 );
-  VERIFY( str_1 != str_0 );
-  VERIFY( str_2 != str_0 );
-  VERIFY( str_3 != str_0 );
-  VERIFY( !(str_0 != str_4) );
-  VERIFY( !(str_4 != str_0) );
-
-  VERIFY( str_0 > str_1 ); //true cuz r>m
-  VERIFY( str_0 > str_2 );
-  VERIFY( !(str_0 > str_3) );
-  VERIFY( !(str_1 > str_0) ); //false cuz m<r
-  VERIFY( !(str_2 > str_0) );
-  VERIFY( str_3 > str_0 );
-  VERIFY( !(str_0 > str_4) );
-  VERIFY( !(str_4 > str_0) );
-
-  VERIFY( !(str_0 < str_1) ); //false cuz r>m
-  VERIFY( !(str_0 < str_2) );
-  VERIFY( str_0 < str_3 );
-  VERIFY( str_1 < str_0 ); //true cuz m<r
-  VERIFY( str_2 < str_0 );
-  VERIFY( !(str_3 < str_0) );
-  VERIFY( !(str_0 < str_4) );
-  VERIFY( !(str_4 < str_0) );
-
-  VERIFY( str_0 >= str_1 ); //true cuz r>m
-  VERIFY( str_0 >= str_2 );
-  VERIFY( !(str_0 >= str_3) );
-  VERIFY( !(str_1 >= str_0) );//false cuz m<r
-  VERIFY( !(str_2 >= str_0) );
-  VERIFY( str_3 >= str_0 );
-  VERIFY( str_0 >= str_4 );
-  VERIFY( str_4 >= str_0 );
-
-  VERIFY( !(str_0 <= str_1) );//false cuz r>m
-  VERIFY( !(str_0 <= str_2) );
-  VERIFY( str_0 <= str_3 );
-  VERIFY( str_1 <= str_0 );//true cuz m<r
-  VERIFY( str_2 <= str_0 );
-  VERIFY( !(str_3 <= str_0) );
-  VERIFY( str_0 <= str_4 );
-  VERIFY( str_4 <= str_0 );
-
-  //comparisons between string object and string literal
-  VERIFY( !(str_0 == "costa marbella") );
-  VERIFY( !(str_0 == "cost") );
-  VERIFY( !(str_0 == "costa ricans") );
-  VERIFY( !("costa marbella" == str_0) );
-  VERIFY( !("cost" == str_0) );
-  VERIFY( !("costa ricans" == str_0) );
-  VERIFY( "costa rica" == str_0 );
-  VERIFY( str_0 == "costa rica" );
-
-  VERIFY( str_0 != "costa marbella" );
-  VERIFY( str_0 != "cost" );
-  VERIFY( str_0 != "costa ricans" );
-  VERIFY( "costa marbella" != str_0 );
-  VERIFY( "cost" != str_0 );
-  VERIFY( "costa ricans" != str_0 );
-  VERIFY( !("costa rica" != str_0) );
-  VERIFY( !(str_0 != "costa rica") );
-
-  VERIFY( str_0 > "costa marbella" ); //true cuz r>m
-  VERIFY( str_0 > "cost" );
-  VERIFY( !(str_0 > "costa ricans") );
-  VERIFY( !("costa marbella" > str_0) );//false cuz m<r
-  VERIFY( !("cost" > str_0) );
-  VERIFY( "costa ricans" > str_0 );
-  VERIFY( !("costa rica" > str_0) );
-  VERIFY( !(str_0 > "costa rica") );
-
-  VERIFY( !(str_0 < "costa marbella") );//false cuz r>m
-  VERIFY( !(str_0 < "cost") );
-  VERIFY( str_0 < "costa ricans" );
-  VERIFY( "costa marbella" < str_0 );//true cuz m<r
-  VERIFY( "cost" < str_0 );
-  VERIFY( !("costa ricans" < str_0) );
-  VERIFY( !("costa rica" < str_0) );
-  VERIFY( !(str_0 < "costa rica") );
-
-  VERIFY( str_0 >= "costa marbella" );//true cuz r>m
-  VERIFY( str_0 >= "cost" );
-  VERIFY( !(str_0 >= "costa ricans") );
-  VERIFY( !("costa marbella" >= str_0) );//false cuz m<r
-  VERIFY( !("cost" >= str_0) );
-  VERIFY( "costa ricans" >= str_0 );
-  VERIFY( "costa rica" >= str_0 );
-  VERIFY( str_0 >= "costa rica" );
-
-  VERIFY( !(str_0 <= "costa marbella") );//false cuz r>m
-  VERIFY( !(str_0 <= "cost") );
-  VERIFY( str_0 <= "costa ricans" );
-  VERIFY( "costa marbella" <= str_0 );//true cuz m<r
-  VERIFY( "cost" <= str_0 );
-  VERIFY( !("costa ricans" <= str_0) );
-  VERIFY( "costa rica" <= str_0 );
-  VERIFY( str_0 <= "costa rica" );
-}
-
-#ifndef GDB_STRING_VIEW
-constexpr bool
-test02()
-{
-  std::string_view 	str_0("costa rica");
-  std::string_view 	str_1("costa marbella");
-  std::string_view 	str_2("cost");
-  std::string_view	str_3("costa ricans");
-  std::string_view        str_4;
-
-#undef VERIFY
-#define VERIFY(x) if (!(x)) return false
-
-  str_4 = str_0;
-  //comparisons between string objects
-  VERIFY( !(str_0 == str_1) );
-  VERIFY( !(str_0 == str_2) );
-  VERIFY( !(str_0 == str_3) );
-  VERIFY( !(str_1 == str_0) );
-  VERIFY( !(str_2 == str_0) );
-  VERIFY( !(str_3 == str_0) );
-  VERIFY( str_4 == str_0 );
-  VERIFY( str_0 == str_4 );
-
-  VERIFY( str_0 != str_1 );
-  VERIFY( str_0 != str_2 );
-  VERIFY( str_0 != str_3 );
-  VERIFY( str_1 != str_0 );
-  VERIFY( str_2 != str_0 );
-  VERIFY( str_3 != str_0 );
-  VERIFY( !(str_0 != str_4) );
-  VERIFY( !(str_4 != str_0) );
-
-  VERIFY( str_0 > str_1 ); //true cuz r>m
-  VERIFY( str_0 > str_2 );
-  VERIFY( !(str_0 > str_3) );
-  VERIFY( !(str_1 > str_0) ); //false cuz m<r
-  VERIFY( !(str_2 > str_0) );
-  VERIFY( str_3 > str_0 );
-  VERIFY( !(str_0 > str_4) );
-  VERIFY( !(str_4 > str_0) );
-
-  VERIFY( !(str_0 < str_1) ); //false cuz r>m
-  VERIFY( !(str_0 < str_2) );
-  VERIFY( str_0 < str_3 );
-  VERIFY( str_1 < str_0 ); //true cuz m<r
-  VERIFY( str_2 < str_0 );
-  VERIFY( !(str_3 < str_0) );
-  VERIFY( !(str_0 < str_4) );
-  VERIFY( !(str_4 < str_0) );
-
-  VERIFY( str_0 >= str_1 ); //true cuz r>m
-  VERIFY( str_0 >= str_2 );
-  VERIFY( !(str_0 >= str_3) );
-  VERIFY( !(str_1 >= str_0) );//false cuz m<r
-  VERIFY( !(str_2 >= str_0) );
-  VERIFY( str_3 >= str_0 );
-  VERIFY( str_0 >= str_4 );
-  VERIFY( str_4 >= str_0 );
-
-  VERIFY( !(str_0 <= str_1) );//false cuz r>m
-  VERIFY( !(str_0 <= str_2) );
-  VERIFY( str_0 <= str_3 );
-  VERIFY( str_1 <= str_0 );//true cuz m<r
-  VERIFY( str_2 <= str_0 );
-  VERIFY( !(str_3 <= str_0) );
-  VERIFY( str_0 <= str_4 );
-  VERIFY( str_4 <= str_0 );
-
-  //comparisons between string object and string literal
-  VERIFY( !(str_0 == "costa marbella") );
-  VERIFY( !(str_0 == "cost") );
-  VERIFY( !(str_0 == "costa ricans") );
-  VERIFY( !("costa marbella" == str_0) );
-  VERIFY( !("cost" == str_0) );
-  VERIFY( !("costa ricans" == str_0) );
-  VERIFY( "costa rica" == str_0 );
-  VERIFY( str_0 == "costa rica" );
-
-  VERIFY( str_0 != "costa marbella" );
-  VERIFY( str_0 != "cost" );
-  VERIFY( str_0 != "costa ricans" );
-  VERIFY( "costa marbella" != str_0 );
-  VERIFY( "cost" != str_0 );
-  VERIFY( "costa ricans" != str_0 );
-  VERIFY( !("costa rica" != str_0) );
-  VERIFY( !(str_0 != "costa rica") );
-
-  VERIFY( str_0 > "costa marbella" ); //true cuz r>m
-  VERIFY( str_0 > "cost" );
-  VERIFY( !(str_0 > "costa ricans") );
-  VERIFY( !("costa marbella" > str_0) );//false cuz m<r
-  VERIFY( !("cost" > str_0) );
-  VERIFY( "costa ricans" > str_0 );
-  VERIFY( !("costa rica" > str_0) );
-  VERIFY( !(str_0 > "costa rica") );
-
-  VERIFY( !(str_0 < "costa marbella") );//false cuz r>m
-  VERIFY( !(str_0 < "cost") );
-  VERIFY( str_0 < "costa ricans" );
-  VERIFY( "costa marbella" < str_0 );//true cuz m<r
-  VERIFY( "cost" < str_0 );
-  VERIFY( !("costa ricans" < str_0) );
-  VERIFY( !("costa rica" < str_0) );
-  VERIFY( !(str_0 < "costa rica") );
-
-  VERIFY( str_0 >= "costa marbella" );//true cuz r>m
-  VERIFY( str_0 >= "cost" );
-  VERIFY( !(str_0 >= "costa ricans") );
-  VERIFY( !("costa marbella" >= str_0) );//false cuz m<r
-  VERIFY( !("cost" >= str_0) );
-  VERIFY( "costa ricans" >= str_0 );
-  VERIFY( "costa rica" >= str_0 );
-  VERIFY( str_0 >= "costa rica" );
-
-  VERIFY( !(str_0 <= "costa marbella") );//false cuz r>m
-  VERIFY( !(str_0 <= "cost") );
-  VERIFY( str_0 <= "costa ricans" );
-  VERIFY( "costa marbella" <= str_0 );//true cuz m<r
-  VERIFY( "cost" <= str_0 );
-  VERIFY( !("costa ricans" <= str_0) );
-  VERIFY( "costa rica" <= str_0 );
-  VERIFY( str_0 <= "costa rica" );
-
-  return true;
-}
-#endif
-
-static int
-main ()
-{
-  test01();
-#ifndef GDB_STRING_VIEW
-  static_assert( test02() );
-#endif
-  return 0;
-}
-
-} // namespace operators_2
diff --git a/gdb/unittests/basic_string_view/operators/wchar_t/2.cc b/gdb/unittests/basic_string_view/operators/wchar_t/2.cc
deleted file mode 100644
index 5e043bc3fdb..00000000000
--- a/gdb/unittests/basic_string_view/operators/wchar_t/2.cc
+++ /dev/null
@@ -1,367 +0,0 @@
-// { dg-options "-std=gnu++17" }
-
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-// basic_string_view non-member functions
-
-// operator==
-/*
-template<class charT, class traits, class Allocator>
-  bool operator==(const basic_string_view<charT,traits,Allocator>& lhs,
-                  const basic_string_view<charT,traits,Allocator>& rhs);
-
-template<class charT, class traits, class Allocator>
-  bool operator==(const charT* lhs,
-                  const basic_string_view<charT,traits,Allocator>& rhs);
-
-template<class charT, class traits, class Allocator>
-  bool operator==(const basic_string_view<charT,traits,Allocator>& lhs,
-                  const charT* rhs);
-*/
-
-// operator!=
-/*
-template<class charT, class traits, class Allocator>
-  bool operator!=(const basic_string_view<charT,traits,Allocator>& lhs,
-                  const basic_string_view<charT,traits,Allocator>& rhs);
-
-template<class charT, class traits, class Allocator>
-  bool operator!=(const charT* lhs,
-                  const basic_string_view<charT,traits,Allocator>& rhs);
-
-template<class charT, class traits, class Allocator>
-  bool operator!=(const basic_string_view<charT,traits,Allocator>& lhs,
-                  const charT* rhs);
-*/
-
-// operator<
-/*
-template<class charT, class traits, class Allocator>
-  bool operator< (const basic_string_view<charT,traits,Allocator>& lhs,
-                  const basic_string_view<charT,traits,Allocator>& rhs);
-
-template<class charT, class traits, class Allocator>
-  bool operator< (const basic_string_view<charT,traits,Allocator>& lhs,
-                  const charT* rhs);
-
-template<class charT, class traits, class Allocator>
-  bool operator< (const charT* lhs,
-                  const basic_string_view<charT,traits,Allocator>& rhs);
-*/
-
-// operator>
-/*
-template<class charT, class traits, class Allocator>
-  bool operator> (const basic_string_view<charT,traits,Allocator>& lhs,
-                  const basic_string_view<charT,traits,Allocator>& rhs);
-
-template<class charT, class traits, class Allocator>
-  bool operator> (const basic_string_view<charT,traits,Allocator>& lhs,
-                  const charT* rhs);
-
-template<class charT, class traits, class Allocator>
-  bool operator> (const charT* lhs,
-                  const basic_string_view<charT,traits,Allocator>& rhs);
-*/
-
-// operator<=
-/*
-template<class charT, class traits, class Allocator>
-  bool operator<=(const basic_string_view<charT,traits,Allocator>& lhs,
-                  const basic_string_view<charT,traits,Allocator>& rhs);
-
-template<class charT, class traits, class Allocator>
-  bool operator<=(const basic_string_view<charT,traits,Allocator>& lhs,
-                  const charT* rhs);
-
-template<class charT, class traits, class Allocator>
-  bool operator<=(const charT* lhs,
-                  const basic_string_view<charT,traits,Allocator>& rhs);
-*/
-
-// operator>=
-/*
-template<class charT, class traits, class Allocator>
-  bool operator>=(const basic_string_view<charT,traits,Allocator>& lhs,
-                const basic_string_view<charT,traits,Allocator>& rhs);
-
-template<class charT, class traits, class Allocator>
-  bool operator>=(const basic_string_view<charT,traits,Allocator>& lhs,
-                  const charT* rhs);
-
-template<class charT, class traits, class Allocator>
-  bool operator>=(const charT* lhs,
-                  const basic_string_view<charT,traits,Allocator>& rhs);
-*/
-
-#include <string_view>
-#include <testsuite_hooks.h>
-
-void
-test01()
-{
-  std::wstring_view 	str_0(L"costa rica");
-  std::wstring_view 	str_1(L"costa marbella");
-  std::wstring_view 	str_2(L"cost");
-  std::wstring_view	str_3(L"costa ricans");
-  std::wstring_view  str_4;
-
-  str_4 = str_0;
-  //comparisons between string_view objects
-  VERIFY( !(str_0 == str_1) );
-  VERIFY( !(str_0 == str_2) );
-  VERIFY( !(str_0 == str_3) );
-  VERIFY( !(str_1 == str_0) );
-  VERIFY( !(str_2 == str_0) );
-  VERIFY( !(str_3 == str_0) );
-  VERIFY( str_4 == str_0 );
-  VERIFY( str_0 == str_4 );
-
-  VERIFY( str_0 != str_1 );
-  VERIFY( str_0 != str_2 );
-  VERIFY( str_0 != str_3 );
-  VERIFY( str_1 != str_0 );
-  VERIFY( str_2 != str_0 );
-  VERIFY( str_3 != str_0 );
-  VERIFY( !(str_0 != str_4) );
-  VERIFY( !(str_4 != str_0) );
-
-  VERIFY( str_0 > str_1 ); //true cuz r>m
-  VERIFY( str_0 > str_2 );
-  VERIFY( !(str_0 > str_3) );
-  VERIFY( !(str_1 > str_0) ); //false cuz m<r
-  VERIFY( !(str_2 > str_0) );
-  VERIFY( str_3 > str_0 );
-  VERIFY( !(str_0 > str_4) );
-  VERIFY( !(str_4 > str_0) );
-
-  VERIFY( !(str_0 < str_1) ); //false cuz r>m
-  VERIFY( !(str_0 < str_2) );
-  VERIFY( str_0 < str_3 );
-  VERIFY( str_1 < str_0 ); //true cuz m<r
-  VERIFY( str_2 < str_0 );
-  VERIFY( !(str_3 < str_0) );
-  VERIFY( !(str_0 < str_4) );
-  VERIFY( !(str_4 < str_0) );
-
-  VERIFY( str_0 >= str_1 ); //true cuz r>m
-  VERIFY( str_0 >= str_2 );
-  VERIFY( !(str_0 >= str_3) );
-  VERIFY( !(str_1 >= str_0) );//false cuz m<r
-  VERIFY( !(str_2 >= str_0) );
-  VERIFY( str_3 >= str_0 );
-  VERIFY( str_0 >= str_4 );
-  VERIFY( str_4 >= str_0 );
-
-  VERIFY( !(str_0 <= str_1) );//false cuz r>m
-  VERIFY( !(str_0 <= str_2) );
-  VERIFY( str_0 <= str_3 );
-  VERIFY( str_1 <= str_0 );//true cuz m<r
-  VERIFY( str_2 <= str_0 );
-  VERIFY( !(str_3 <= str_0) );
-  VERIFY( str_0 <= str_4 );
-  VERIFY( str_4 <= str_0 );
-
-  //comparisons between string_view object and string_view literal
-  VERIFY( !(str_0 == L"costa marbella") );
-  VERIFY( !(str_0 == L"cost") );
-  VERIFY( !(str_0 == L"costa ricans") );
-  VERIFY( !(L"costa marbella" == str_0) );
-  VERIFY( !(L"cost" == str_0) );
-  VERIFY( !(L"costa ricans" == str_0) );
-  VERIFY( L"costa rica" == str_0 );
-  VERIFY( str_0 == L"costa rica" );
-
-  VERIFY( str_0 != L"costa marbella" );
-  VERIFY( str_0 != L"cost" );
-  VERIFY( str_0 != L"costa ricans" );
-  VERIFY( L"costa marbella" != str_0 );
-  VERIFY( L"cost" != str_0 );
-  VERIFY( L"costa ricans" != str_0 );
-  VERIFY( !(L"costa rica" != str_0) );
-  VERIFY( !(str_0 != L"costa rica") );
-
-  VERIFY( str_0 > L"costa marbella" ); //true cuz r>m
-  VERIFY( str_0 > L"cost" );
-  VERIFY( !(str_0 > L"costa ricans") );
-  VERIFY( !(L"costa marbella" > str_0) );//false cuz m<r
-  VERIFY( !(L"cost" > str_0) );
-  VERIFY( L"costa ricans" > str_0 );
-  VERIFY( !(L"costa rica" > str_0) );
-  VERIFY( !(str_0 > L"costa rica") );
-
-  VERIFY( !(str_0 < L"costa marbella") );//false cuz r>m
-  VERIFY( !(str_0 < L"cost") );
-  VERIFY( str_0 < L"costa ricans" );
-  VERIFY( L"costa marbella" < str_0 );//true cuz m<r
-  VERIFY( L"cost" < str_0 );
-  VERIFY( !(L"costa ricans" < str_0) );
-  VERIFY( !(L"costa rica" < str_0) );
-  VERIFY( !(str_0 < L"costa rica") );
-
-  VERIFY( str_0 >= L"costa marbella" );//true cuz r>m
-  VERIFY( str_0 >= L"cost" );
-  VERIFY( !(str_0 >= L"costa ricans") );
-  VERIFY( !(L"costa marbella" >= str_0) );//false cuz m<r
-  VERIFY( !(L"cost" >= str_0) );
-  VERIFY( L"costa ricans" >= str_0 );
-  VERIFY( L"costa rica" >= str_0 );
-  VERIFY( str_0 >= L"costa rica" );
-
-  VERIFY( !(str_0 <= L"costa marbella") );//false cuz r>m
-  VERIFY( !(str_0 <= L"cost") );
-  VERIFY( str_0 <= L"costa ricans" );
-  VERIFY( L"costa marbella" <= str_0 );//true cuz m<r
-  VERIFY( L"cost" <= str_0 );
-  VERIFY( !(L"costa ricans" <= str_0) );
-  VERIFY( L"costa rica" <= str_0 );
-  VERIFY( str_0 <= L"costa rica" );
-}
-
-constexpr bool
-test02()
-{
-  std::wstring_view 	str_0(L"costa rica");
-  std::wstring_view 	str_1(L"costa marbella");
-  std::wstring_view 	str_2(L"cost");
-  std::wstring_view	str_3(L"costa ricans");
-  std::wstring_view  str_4;
-
-#undef VERIFY
-#define VERIFY(x) if (!(x)) return false
-
-  str_4 = str_0;
-  //comparisons between string_view objects
-  VERIFY( !(str_0 == str_1) );
-  VERIFY( !(str_0 == str_2) );
-  VERIFY( !(str_0 == str_3) );
-  VERIFY( !(str_1 == str_0) );
-  VERIFY( !(str_2 == str_0) );
-  VERIFY( !(str_3 == str_0) );
-  VERIFY( str_4 == str_0 );
-  VERIFY( str_0 == str_4 );
-
-  VERIFY( str_0 != str_1 );
-  VERIFY( str_0 != str_2 );
-  VERIFY( str_0 != str_3 );
-  VERIFY( str_1 != str_0 );
-  VERIFY( str_2 != str_0 );
-  VERIFY( str_3 != str_0 );
-  VERIFY( !(str_0 != str_4) );
-  VERIFY( !(str_4 != str_0) );
-
-  VERIFY( str_0 > str_1 ); //true cuz r>m
-  VERIFY( str_0 > str_2 );
-  VERIFY( !(str_0 > str_3) );
-  VERIFY( !(str_1 > str_0) ); //false cuz m<r
-  VERIFY( !(str_2 > str_0) );
-  VERIFY( str_3 > str_0 );
-  VERIFY( !(str_0 > str_4) );
-  VERIFY( !(str_4 > str_0) );
-
-  VERIFY( !(str_0 < str_1) ); //false cuz r>m
-  VERIFY( !(str_0 < str_2) );
-  VERIFY( str_0 < str_3 );
-  VERIFY( str_1 < str_0 ); //true cuz m<r
-  VERIFY( str_2 < str_0 );
-  VERIFY( !(str_3 < str_0) );
-  VERIFY( !(str_0 < str_4) );
-  VERIFY( !(str_4 < str_0) );
-
-  VERIFY( str_0 >= str_1 ); //true cuz r>m
-  VERIFY( str_0 >= str_2 );
-  VERIFY( !(str_0 >= str_3) );
-  VERIFY( !(str_1 >= str_0) );//false cuz m<r
-  VERIFY( !(str_2 >= str_0) );
-  VERIFY( str_3 >= str_0 );
-  VERIFY( str_0 >= str_4 );
-  VERIFY( str_4 >= str_0 );
-
-  VERIFY( !(str_0 <= str_1) );//false cuz r>m
-  VERIFY( !(str_0 <= str_2) );
-  VERIFY( str_0 <= str_3 );
-  VERIFY( str_1 <= str_0 );//true cuz m<r
-  VERIFY( str_2 <= str_0 );
-  VERIFY( !(str_3 <= str_0) );
-  VERIFY( str_0 <= str_4 );
-  VERIFY( str_4 <= str_0 );
-
-  //comparisons between string_view object and string_view literal
-  VERIFY( !(str_0 == L"costa marbella") );
-  VERIFY( !(str_0 == L"cost") );
-  VERIFY( !(str_0 == L"costa ricans") );
-  VERIFY( !(L"costa marbella" == str_0) );
-  VERIFY( !(L"cost" == str_0) );
-  VERIFY( !(L"costa ricans" == str_0) );
-  VERIFY( L"costa rica" == str_0 );
-  VERIFY( str_0 == L"costa rica" );
-
-  VERIFY( str_0 != L"costa marbella" );
-  VERIFY( str_0 != L"cost" );
-  VERIFY( str_0 != L"costa ricans" );
-  VERIFY( L"costa marbella" != str_0 );
-  VERIFY( L"cost" != str_0 );
-  VERIFY( L"costa ricans" != str_0 );
-  VERIFY( !(L"costa rica" != str_0) );
-  VERIFY( !(str_0 != L"costa rica") );
-
-  VERIFY( str_0 > L"costa marbella" ); //true cuz r>m
-  VERIFY( str_0 > L"cost" );
-  VERIFY( !(str_0 > L"costa ricans") );
-  VERIFY( !(L"costa marbella" > str_0) );//false cuz m<r
-  VERIFY( !(L"cost" > str_0) );
-  VERIFY( L"costa ricans" > str_0 );
-  VERIFY( !(L"costa rica" > str_0) );
-  VERIFY( !(str_0 > L"costa rica") );
-
-  VERIFY( !(str_0 < L"costa marbella") );//false cuz r>m
-  VERIFY( !(str_0 < L"cost") );
-  VERIFY( str_0 < L"costa ricans" );
-  VERIFY( L"costa marbella" < str_0 );//true cuz m<r
-  VERIFY( L"cost" < str_0 );
-  VERIFY( !(L"costa ricans" < str_0) );
-  VERIFY( !(L"costa rica" < str_0) );
-  VERIFY( !(str_0 < L"costa rica") );
-
-  VERIFY( str_0 >= L"costa marbella" );//true cuz r>m
-  VERIFY( str_0 >= L"cost" );
-  VERIFY( !(str_0 >= L"costa ricans") );
-  VERIFY( !(L"costa marbella" >= str_0) );//false cuz m<r
-  VERIFY( !(L"cost" >= str_0) );
-  VERIFY( L"costa ricans" >= str_0 );
-  VERIFY( L"costa rica" >= str_0 );
-  VERIFY( str_0 >= L"costa rica" );
-
-  VERIFY( !(str_0 <= L"costa marbella") );//false cuz r>m
-  VERIFY( !(str_0 <= L"cost") );
-  VERIFY( str_0 <= L"costa ricans" );
-  VERIFY( L"costa marbella" <= str_0 );//true cuz m<r
-  VERIFY( L"cost" <= str_0 );
-  VERIFY( !(L"costa ricans" <= str_0) );
-  VERIFY( L"costa rica" <= str_0 );
-  VERIFY( str_0 <= L"costa rica" );
-
-  return true;
-}
-
-int
-main()
-{
-  test01();
-  static_assert( test02() );
-}
diff --git a/gdb/unittests/basic_string_view/range_access/char/1.cc b/gdb/unittests/basic_string_view/range_access/char/1.cc
deleted file mode 100644
index 4b9e0bde9f1..00000000000
--- a/gdb/unittests/basic_string_view/range_access/char/1.cc
+++ /dev/null
@@ -1,47 +0,0 @@
-// { dg-do compile }
-// { dg-options "-std=gnu++17" }
-
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-// C++17 27.7, range access [iterator.range]
-
-#include <string_view>
-
-void
-test01()
-{
-  std::string_view s("Hello, World!");
-  std::begin(s);
-  std::end(s);
-  std::rbegin(s);
-  std::rend(s);
-}
-
-void
-test02()
-{
-  constexpr std::string_view s("Hello, World!");
-  [[maybe_unused]] constexpr auto b = std::begin(s);
-  [[maybe_unused]] constexpr auto e = std::end(s);
-  [[maybe_unused]] constexpr auto cb = std::cbegin(s);
-  [[maybe_unused]] constexpr auto ce = std::cend(s);
-  [[maybe_unused]] constexpr auto rb = std::rbegin(s);
-  [[maybe_unused]] constexpr auto re = std::rend(s);
-  [[maybe_unused]] constexpr auto crb = std::crbegin(s);
-  [[maybe_unused]] constexpr auto cre = std::crend(s);
-}
diff --git a/gdb/unittests/basic_string_view/range_access/wchar_t/1.cc b/gdb/unittests/basic_string_view/range_access/wchar_t/1.cc
deleted file mode 100644
index 68b6b1c8c96..00000000000
--- a/gdb/unittests/basic_string_view/range_access/wchar_t/1.cc
+++ /dev/null
@@ -1,47 +0,0 @@
-// { dg-do compile }
-// { dg-options "-std=gnu++17" }
-
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-// C++17 27.7, range access [iterator.range]
-
-#include <string_view>
-
-void
-test01()
-{
-  std::wstring_view ws(L"Hello, World!");
-  std::begin(ws);
-  std::end(ws);
-  std::rbegin(ws);
-  std::rend(ws);
-}
-
-void
-test02()
-{
-  constexpr std::wstring_view ws(L"Hello, World!");
-  [[maybe_unused]] constexpr auto b = std::begin(ws);
-  [[maybe_unused]] constexpr auto e = std::end(ws);
-  [[maybe_unused]] constexpr auto cb = std::cbegin(ws);
-  [[maybe_unused]] constexpr auto ce = std::cend(ws);
-  [[maybe_unused]] constexpr auto rb = std::rbegin(ws);
-  [[maybe_unused]] constexpr auto re = std::rend(ws);
-  [[maybe_unused]] constexpr auto crb = std::crbegin(ws);
-  [[maybe_unused]] constexpr auto cre = std::crend(ws);
-}
diff --git a/gdb/unittests/basic_string_view/requirements/explicit_instantiation/1.cc b/gdb/unittests/basic_string_view/requirements/explicit_instantiation/1.cc
deleted file mode 100644
index afea9946bf4..00000000000
--- a/gdb/unittests/basic_string_view/requirements/explicit_instantiation/1.cc
+++ /dev/null
@@ -1,26 +0,0 @@
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-
-// This file tests explicit instantiation of basic_string
-
-#include <string_view>
-
-// { dg-do compile }
-// { dg-options "-std=gnu++17" }
-
-template class std::basic_string_view<int, std::char_traits<int>>;
diff --git a/gdb/unittests/basic_string_view/requirements/explicit_instantiation/char/1.cc b/gdb/unittests/basic_string_view/requirements/explicit_instantiation/char/1.cc
deleted file mode 100644
index 7db0e922257..00000000000
--- a/gdb/unittests/basic_string_view/requirements/explicit_instantiation/char/1.cc
+++ /dev/null
@@ -1,23 +0,0 @@
-// { dg-do compile }
-// { dg-options "-std=gnu++17" }
-
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-//
-// You should have received a copy of the GNU General Public License
-// along with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-#include <string_view>
-
-template class std::basic_string_view<char>;
diff --git a/gdb/unittests/basic_string_view/requirements/explicit_instantiation/char16_t/1.cc b/gdb/unittests/basic_string_view/requirements/explicit_instantiation/char16_t/1.cc
deleted file mode 100644
index 5eb588fce32..00000000000
--- a/gdb/unittests/basic_string_view/requirements/explicit_instantiation/char16_t/1.cc
+++ /dev/null
@@ -1,24 +0,0 @@
-// { dg-do compile }
-// { dg-options "-std=gnu++17" }
-// { dg-require-cstdint "" }
-
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-//
-// You should have received a copy of the GNU General Public License
-// along with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-#include <string_view>
-
-template class std::basic_string_view<char16_t>;
diff --git a/gdb/unittests/basic_string_view/requirements/explicit_instantiation/char32_t/1.cc b/gdb/unittests/basic_string_view/requirements/explicit_instantiation/char32_t/1.cc
deleted file mode 100644
index 2c6460277dd..00000000000
--- a/gdb/unittests/basic_string_view/requirements/explicit_instantiation/char32_t/1.cc
+++ /dev/null
@@ -1,24 +0,0 @@
-// { dg-do compile }
-// { dg-options "-std=gnu++17" }
-// { dg-require-cstdint "" }
-
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-//
-// You should have received a copy of the GNU General Public License
-// along with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-#include <string_view>
-
-template class std::basic_string_view<char32_t>;
diff --git a/gdb/unittests/basic_string_view/requirements/explicit_instantiation/wchar_t/1.cc b/gdb/unittests/basic_string_view/requirements/explicit_instantiation/wchar_t/1.cc
deleted file mode 100644
index 213615f222e..00000000000
--- a/gdb/unittests/basic_string_view/requirements/explicit_instantiation/wchar_t/1.cc
+++ /dev/null
@@ -1,23 +0,0 @@
-// { dg-do compile }
-// { dg-options "-std=gnu++17" }
-
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-//
-// You should have received a copy of the GNU General Public License
-// along with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-#include <string_view>
-
-template class std::basic_string_view<wchar_t>;
diff --git a/gdb/unittests/basic_string_view/requirements/typedefs.cc b/gdb/unittests/basic_string_view/requirements/typedefs.cc
deleted file mode 100644
index 2bb08abfd25..00000000000
--- a/gdb/unittests/basic_string_view/requirements/typedefs.cc
+++ /dev/null
@@ -1,47 +0,0 @@
-
-// { dg-options "-std=gnu++17" }
-// { dg-do compile }
-
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-#include <string_view>
-#include <testsuite_containers.h>
-
-namespace __gnu_test
-{
-  template<typename _Tp1, typename _Tp2>
-    struct traits<std::basic_string_view<_Tp1, _Tp2>> : public traits_base
-    {
-      typedef std::true_type    is_container;
-      typedef std::true_type    is_reversible;
-    };
-}
-
-#include <testsuite_containers.h>
-
-// Check container for required typedefs.
-
-__gnu_test::basic_types<std::string_view> t1b;
-__gnu_test::reversible_types<std::string_view> t1r;
-typedef typename std::string_view::traits_type traits_type1;
-
-#ifdef _GLIBCXX_USE_WCHAR_T
-__gnu_test::basic_types<std::wstring_view> t2b;
-__gnu_test::reversible_types<std::wstring_view> t2r;
-typedef typename std::wstring_view::traits_type traits_type2;
-#endif
diff --git a/gdb/unittests/basic_string_view/typedefs.cc b/gdb/unittests/basic_string_view/typedefs.cc
deleted file mode 100644
index c4222bf8ebf..00000000000
--- a/gdb/unittests/basic_string_view/typedefs.cc
+++ /dev/null
@@ -1,36 +0,0 @@
-// { dg-options "-std=gnu++17" }
-// { dg-do compile }
-
-// Copyright (C) 2014-2023 Free Software Foundation, Inc.
-//
-// 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.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-#include <string_view>
-
-template<typename C, typename T>
-  using check1_t = std::basic_string_view<C, T>;
-
-using check2_t = std::string_view;
-
-#ifdef _GLIBCXX_USE_C99_STDINT_TR1
-using check3_t = std::u16string_view;
-using check4_t = std::u32string_view;
-#endif
-
-#ifdef _GLIBCXX_USE_WCHAR_T
-using check5_t = std::wstring_view;
-#endif
-
diff --git a/gdb/unittests/basic_string_view/types/1.cc b/gdb/unittests/basic_string_view/types/1.cc
deleted file mode 100644
index d742df23a44..00000000000
--- a/gdb/unittests/basic_string_view/types/1.cc
+++ /dev/null
@@ -1,43 +0,0 @@
-//
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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.
-//
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-//
-
-// { dg-options "-std=gnu++17" }
-// { dg-do compile }
-
-#include <string_view>
-
-struct T
-{
-  typedef std::string_view String_view;
-  typedef String_view::iterator iterator;
-  typedef String_view::const_iterator const_iterator;
-
-  char t(iterator f)             { return *f; }
-  char t(const_iterator f) const { return *f; }
-};
-
-void
-f()
-{
-  std::string_view s;
-  T t;
-  T::const_iterator i = s.begin();
-  
-  t.t(i);
-}
diff --git a/gdb/unittests/string_view-selftests.c b/gdb/unittests/string_view-selftests.c
deleted file mode 100644
index cf43d29502c..00000000000
--- a/gdb/unittests/string_view-selftests.c
+++ /dev/null
@@ -1,193 +0,0 @@
-/* Self tests for string_view for GDB, the GNU debugger.
-
-   Copyright (C) 2018-2023 Free Software Foundation, Inc.
-
-   This file is part of GDB.
-
-   This program 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 of the License, or
-   (at your option) any later version.
-
-   This program 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.
-
-   You should have received a copy of the GNU General Public License
-   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
-
-/* No need to test string_view if we're using C++17, since we're going to use
-   the "real" version.  */
-#if __cplusplus < 201703L
-
-#define GNULIB_NAMESPACE gnulib
-
-#include "diagnostics.h"
-
-/* Since this file uses GNULIB_NAMESPACE, some code defined in headers ends up
-   using system functions rather than gnulib replacements.  This is not really
-   a problem for this test, but it generates some warnings with Clang, silence
-   them.  */
-DIAGNOSTIC_PUSH
-DIAGNOSTIC_IGNORE_USER_DEFINED_WARNINGS
-
-#include "defs.h"
-#include "gdbsupport/selftest.h"
-#include "gdbsupport/gdb_string_view.h"
-
-/* Used by the included .cc files below.  Included here because the
-   included test files are wrapped in a namespace.  */
-#include <string>
-#include <sstream>
-#include <fstream>
-#include <iostream>
-
-DIAGNOSTIC_POP
-
-/* libstdc++'s testsuite uses VERIFY.  */
-#define VERIFY SELF_CHECK
-
-/* Used to disable testing features not supported by
-   gdb::string_view.  */
-#define GDB_STRING_VIEW
-
-namespace selftests {
-namespace string_view {
-
-/* The actual tests live in separate files, which were originally
-   copied over from libstdc++'s testsuite.  To preserve the structure
-   and help with comparison with the original tests, the file names
-   have been preserved, and only minimal modification was done to have
-   them compile against gdb::string_view instead of std::string_view:
-
-     - std::string_view->gdb::string_view, etc.
-     - ATTRIBUTE_UNUSED in a few places
-     - wrap each file in a namespace so they can all be compiled as a
-       single unit.
-     - libstdc++'s license and formatting style was preserved.
-*/
-
-#include "basic_string_view/capacity/1.cc"
-#include "basic_string_view/cons/char/1.cc"
-#include "basic_string_view/cons/char/2.cc"
-#include "basic_string_view/cons/char/3.cc"
-#include "basic_string_view/element_access/char/1.cc"
-#include "basic_string_view/element_access/char/empty.cc"
-#include "basic_string_view/element_access/char/front_back.cc"
-#include "basic_string_view/inserters/char/2.cc"
-#include "basic_string_view/modifiers/remove_prefix/char/1.cc"
-#include "basic_string_view/modifiers/remove_suffix/char/1.cc"
-#include "basic_string_view/modifiers/swap/char/1.cc"
-#include "basic_string_view/operations/compare/char/1.cc"
-#include "basic_string_view/operations/compare/char/13650.cc"
-#include "basic_string_view/operations/copy/char/1.cc"
-#include "basic_string_view/operations/data/char/1.cc"
-#include "basic_string_view/operations/find/char/1.cc"
-#include "basic_string_view/operations/find/char/2.cc"
-#include "basic_string_view/operations/find/char/3.cc"
-#include "basic_string_view/operations/find/char/4.cc"
-#include "basic_string_view/operations/rfind/char/1.cc"
-#include "basic_string_view/operations/rfind/char/2.cc"
-#include "basic_string_view/operations/rfind/char/3.cc"
-#include "basic_string_view/operations/substr/char/1.cc"
-#include "basic_string_view/operators/char/2.cc"
-
-static void
-run_tests ()
-{
-  capacity_1::main ();
-  cons_1::main ();
-  cons_2::main ();
-  cons_3::main ();
-  element_access_1::main ();
-  element_access_empty::main ();
-  element_access_front_back::main ();
-  inserters_2::main ();
-  modifiers_remove_prefix::main ();
-  modifiers_remove_suffix::main ();
-  modifiers_swap::test01 ();
-  operations_compare_1::main ();
-  operations_compare_13650::main ();
-  operations_copy_1::main ();
-  operations_data_1::main ();
-  operations_find_1::main ();
-  operations_find_2::main ();
-  operations_find_3::main ();
-  operations_find_4::main ();
-  operations_rfind_1::main ();
-  operations_rfind_2::main ();
-  operations_rfind_3::main ();
-  operations_substr_1::main ();
-  operators_2::main ();
-
-  constexpr gdb::string_view sv_empty;
-  SELF_CHECK (sv_empty.empty ());
-
-  std::string std_string = "fika";
-  gdb::string_view sv1 (std_string);
-  SELF_CHECK (sv1 == "fika");
-
-  constexpr const char *fika = "fika";
-  gdb::string_view sv2 (fika);
-  SELF_CHECK (sv2 == "fika");
-
-  constexpr gdb::string_view sv3 (fika, 3);
-  SELF_CHECK (sv3 == "fik");
-
-  constexpr gdb::string_view sv4 (sv3);
-  SELF_CHECK (sv4 == "fik");
-
-  constexpr gdb::string_view::iterator it_begin = sv4.begin ();
-  static_assert (*it_begin == 'f', "");
-
-  constexpr gdb::string_view::iterator it_end = sv4.end ();
-  static_assert (*it_end == 'a', "");
-
-  const gdb::string_view::reverse_iterator it_rbegin = sv4.rbegin ();
-  SELF_CHECK (*it_rbegin == 'k');
-
-  const gdb::string_view::reverse_iterator it_rend = sv4.rend ();
-  SELF_CHECK (*(it_rend - 1) == 'f');
-
-  constexpr gdb::string_view::size_type size = sv4.size ();
-  static_assert (size == 3, "");
-
-  constexpr gdb::string_view::size_type length = sv4.length ();
-  static_assert (length == 3, "");
-
-  constexpr gdb::string_view::size_type max_size = sv4.max_size ();
-  static_assert (max_size > 0, "");
-
-  constexpr bool empty = sv4.empty ();
-  static_assert (!empty, "");
-
-  constexpr char c1 = sv4[1];
-  static_assert (c1 == 'i', "");
-
-  constexpr char c2 = sv4.at (2);
-  static_assert (c2 == 'k', "");
-
-  constexpr char front = sv4.front ();
-  static_assert (front == 'f', "");
-
-  constexpr char back = sv4.back ();
-  static_assert (back == 'k', "");
-
-  constexpr const char *data = sv4.data ();
-  static_assert (data == fika, "");
-}
-
-} /* namespace string_view */
-} /* namespace selftests */
-
-#endif /* __cplusplus < 201703L */
-
-void _initialize_string_view_selftests ();
-void
-_initialize_string_view_selftests ()
-{
-#if defined(GDB_STRING_VIEW)
-  selftests::register_test ("string_view", selftests::string_view::run_tests);
-#endif
-}
diff --git a/gdbsupport/gdb_string_view.h b/gdbsupport/gdb_string_view.h
deleted file mode 100644
index cf7af623327..00000000000
--- a/gdbsupport/gdb_string_view.h
+++ /dev/null
@@ -1,566 +0,0 @@
-// Components for manipulating non-owning sequences of characters -*- C++ -*-
-
-
-#ifndef COMMON_GDB_STRING_VIEW_H
-#define COMMON_GDB_STRING_VIEW_H
-
-// Note: This file has been stolen from the gcc repo
-// (libstdc++-v3/include/experimental/string_view) and has local modifications.
-
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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/>.
-
-//
-// N3762 basic_string_view library
-//
-
-
-#if __cplusplus >= 201703L
-
-#include <string_view>
-
-namespace gdb {
-  using string_view = std::string_view;
-} /* namespace gdb */
-
-#else /* __cplusplus < 201703L */
-
-#include <string>
-#include <limits>
-#include "gdb_assert.h"
-
-namespace gdb {
-
-  /**
-   *  @class basic_string_view <experimental/string_view>
-   *  @brief  A non-owning reference to a string.
-   *
-   *  @ingroup strings
-   *  @ingroup sequences
-   *  @ingroup experimental
-   *
-   *  @tparam _CharT  Type of character
-   *  @tparam _Traits  Traits for character type, defaults to
-   *                   char_traits<_CharT>.
-   *
-   *  A basic_string_view looks like this:
-   *
-   *  @code
-   *    _CharT*    _M_str
-   *    size_t     _M_len
-   *  @endcode
-   */
-  template<typename _CharT, typename _Traits = std::char_traits<_CharT>>
-    class basic_string_view
-    {
-    public:
-
-      // types
-      using traits_type = _Traits;
-      using value_type = _CharT;
-      using pointer = const _CharT*;
-      using const_pointer = const _CharT*;
-      using reference = const _CharT&;
-      using const_reference = const _CharT&;
-      using const_iterator = const _CharT*;
-      using iterator = const_iterator;
-      using const_reverse_iterator = std::reverse_iterator<const_iterator>;
-      using reverse_iterator = const_reverse_iterator;
-      using size_type = size_t;
-      using difference_type = ptrdiff_t;
-      static constexpr size_type npos = size_type(-1);
-
-      // [string.view.cons], construct/copy
-
-      constexpr
-      basic_string_view() noexcept
-      : _M_len{0}, _M_str{nullptr}
-      { }
-
-      constexpr basic_string_view(const basic_string_view&) noexcept = default;
-
-      template<typename _Allocator>
-	basic_string_view(const std::basic_string<_CharT, _Traits,
-			  _Allocator>& __str) noexcept
-	: _M_len{__str.length()}, _M_str{__str.data()}
-	{ }
-
-      /*constexpr*/ basic_string_view(const _CharT* __str)
-      : _M_len{__str == nullptr ? 0 : traits_type::length(__str)},
-	_M_str{__str}
-      { }
-
-      constexpr basic_string_view(const _CharT* __str, size_type __len)
-      : _M_len{__len},
-	_M_str{__str}
-      { }
-
-      basic_string_view&
-      operator=(const basic_string_view&) noexcept = default;
-
-      // [string.view.iterators], iterators
-
-      constexpr const_iterator
-      begin() const noexcept
-      { return this->_M_str; }
-
-      constexpr const_iterator
-      end() const noexcept
-      { return this->_M_str + this->_M_len; }
-
-      constexpr const_iterator
-      cbegin() const noexcept
-      { return this->_M_str; }
-
-      constexpr const_iterator
-      cend() const noexcept
-      { return this->_M_str + this->_M_len; }
-
-      const_reverse_iterator
-      rbegin() const noexcept
-      { return const_reverse_iterator(this->end()); }
-
-      const_reverse_iterator
-      rend() const noexcept
-      { return const_reverse_iterator(this->begin()); }
-
-      const_reverse_iterator
-      crbegin() const noexcept
-      { return const_reverse_iterator(this->end()); }
-
-      const_reverse_iterator
-      crend() const noexcept
-      { return const_reverse_iterator(this->begin()); }
-
-      // [string.view.capacity], capacity
-
-      constexpr size_type
-      size() const noexcept
-      { return this->_M_len; }
-
-      constexpr size_type
-      length() const noexcept
-      { return _M_len; }
-
-      constexpr size_type
-      max_size() const noexcept
-      {
-	return (npos - sizeof(size_type) - sizeof(void*))
-		/ sizeof(value_type) / 4;
-      }
-
-      constexpr bool
-      empty() const noexcept
-      { return this->_M_len == 0; }
-
-      // [string.view.access], element access
-
-      constexpr const _CharT&
-      operator[](size_type __pos) const
-      {
-	// TODO: Assert to restore in a way compatible with the constexpr.
-	// __glibcxx_assert(__pos < this->_M_len);
-	return *(this->_M_str + __pos);
-      }
-
-      constexpr const _CharT&
-      at(size_type __pos) const
-      {
-	return __pos < this->_M_len
-	     ? *(this->_M_str + __pos)
-	     : (error (_("basic_string_view::at: __pos "
-			 "(which is %zu) >= this->size() "
-			 "(which is %zu)"),
-		       __pos, this->size()),
-		*this->_M_str);
-      }
-
-      constexpr const _CharT&
-      front() const
-      {
-	// TODO: Assert to restore in a way compatible with the constexpr.
-	// __glibcxx_assert(this->_M_len > 0);
-	return *this->_M_str;
-      }
-
-      constexpr const _CharT&
-      back() const
-      {
-	// TODO: Assert to restore in a way compatible with the constexpr.
-	// __glibcxx_assert(this->_M_len > 0);
-	return *(this->_M_str + this->_M_len - 1);
-      }
-
-      constexpr const _CharT*
-      data() const noexcept
-      { return this->_M_str; }
-
-      // [string.view.modifiers], modifiers:
-
-      /*constexpr*/ void
-      remove_prefix(size_type __n)
-      {
-	gdb_assert (this->_M_len >= __n);
-	this->_M_str += __n;
-	this->_M_len -= __n;
-      }
-
-      /*constexpr*/ void
-      remove_suffix(size_type __n)
-      { this->_M_len -= __n; }
-
-      /*constexpr*/ void
-      swap(basic_string_view& __sv) noexcept
-      {
-	auto __tmp = *this;
-	*this = __sv;
-	__sv = __tmp;
-      }
-
-
-      // [string.view.ops], string operations:
-
-      template<typename _Allocator>
-	explicit operator std::basic_string<_CharT, _Traits, _Allocator>() const
-	{
-	  return { this->_M_str, this->_M_len };
-	}
-
-      size_type
-      copy(_CharT* __str, size_type __n, size_type __pos = 0) const
-      {
-	gdb_assert (__str != nullptr || __n == 0);
-	if (__pos > this->_M_len)
-	  error (_("basic_string_view::copy: __pos "
-		   "(which is %zu) > this->size() "
-		   "(which is %zu)"),
-		 __pos, this->size());
-	size_type __rlen{std::min(__n, size_type{this->_M_len  - __pos})};
-	for (auto __begin = this->_M_str + __pos,
-	     __end = __begin + __rlen; __begin != __end;)
-	  *__str++ = *__begin++;
-	return __rlen;
-      }
-
-
-      // [string.view.ops], string operations:
-
-      /*constexpr*/ basic_string_view
-      substr(size_type __pos, size_type __n=npos) const
-      {
-	return __pos <= this->_M_len
-	     ? basic_string_view{this->_M_str + __pos,
-				std::min(__n, size_type{this->_M_len  - __pos})}
-	     : (error (_("basic_string_view::substr: __pos "
-			 "(which is %zu) > this->size() "
-			 "(which is %zu)"),
-		       __pos, this->size()), basic_string_view{});
-      }
-
-      /*constexpr*/ int
-      compare(basic_string_view __str) const noexcept
-      {
-	int __ret = traits_type::compare(this->_M_str, __str._M_str,
-					 std::min(this->_M_len, __str._M_len));
-	if (__ret == 0)
-	  __ret = _S_compare(this->_M_len, __str._M_len);
-	return __ret;
-      }
-
-      /*constexpr*/ int
-      compare(size_type __pos1, size_type __n1, basic_string_view __str) const
-      { return this->substr(__pos1, __n1).compare(__str); }
-
-      /*constexpr*/ int
-      compare(size_type __pos1, size_type __n1,
-	      basic_string_view __str, size_type __pos2, size_type __n2) const
-      { return this->substr(__pos1, __n1).compare(__str.substr(__pos2, __n2)); }
-
-      /*constexpr*/ int
-      compare(const _CharT* __str) const noexcept
-      { return this->compare(basic_string_view{__str}); }
-
-      /*constexpr*/ int
-      compare(size_type __pos1, size_type __n1, const _CharT* __str) const
-      { return this->substr(__pos1, __n1).compare(basic_string_view{__str}); }
-
-      /*constexpr*/ int
-      compare(size_type __pos1, size_type __n1,
-	      const _CharT* __str, size_type __n2) const
-      {
-	return this->substr(__pos1, __n1)
-		   .compare(basic_string_view(__str, __n2));
-      }
-
-      /*constexpr*/ size_type
-      find(basic_string_view __str, size_type __pos = 0) const noexcept
-      { return this->find(__str._M_str, __pos, __str._M_len); }
-
-      /*constexpr*/ size_type
-      find(_CharT __c, size_type __pos=0) const noexcept;
-
-      /*constexpr*/ size_type
-      find(const _CharT* __str, size_type __pos, size_type __n) const noexcept;
-
-      /*constexpr*/ size_type
-      find(const _CharT* __str, size_type __pos=0) const noexcept
-      { return this->find(__str, __pos, traits_type::length(__str)); }
-
-      /*constexpr*/ size_type
-      rfind(basic_string_view __str, size_type __pos = npos) const noexcept
-      { return this->rfind(__str._M_str, __pos, __str._M_len); }
-
-      /*constexpr*/ size_type
-      rfind(_CharT __c, size_type __pos = npos) const noexcept;
-
-      /*constexpr*/ size_type
-      rfind(const _CharT* __str, size_type __pos, size_type __n) const noexcept;
-
-      /*constexpr*/ size_type
-      rfind(const _CharT* __str, size_type __pos = npos) const noexcept
-      { return this->rfind(__str, __pos, traits_type::length(__str)); }
-
-      /*constexpr*/ size_type
-      find_first_of(basic_string_view __str, size_type __pos = 0) const noexcept
-      { return this->find_first_of(__str._M_str, __pos, __str._M_len); }
-
-      /*constexpr*/ size_type
-      find_first_of(_CharT __c, size_type __pos = 0) const noexcept
-      { return this->find(__c, __pos); }
-
-      /*constexpr*/ size_type
-      find_first_of(const _CharT* __str, size_type __pos, size_type __n) const;
-
-      /*constexpr*/ size_type
-      find_first_of(const _CharT* __str, size_type __pos = 0) const noexcept
-      { return this->find_first_of(__str, __pos, traits_type::length(__str)); }
-
-      /*constexpr*/ size_type
-      find_last_of(basic_string_view __str,
-		   size_type __pos = npos) const noexcept
-      { return this->find_last_of(__str._M_str, __pos, __str._M_len); }
-
-      size_type
-      find_last_of(_CharT __c, size_type __pos=npos) const noexcept
-      { return this->rfind(__c, __pos); }
-
-      /*constexpr*/ size_type
-      find_last_of(const _CharT* __str, size_type __pos, size_type __n) const;
-
-      /*constexpr*/ size_type
-      find_last_of(const _CharT* __str, size_type __pos = npos) const noexcept
-      { return this->find_last_of(__str, __pos, traits_type::length(__str)); }
-
-      /*constexpr*/ size_type
-      find_first_not_of(basic_string_view __str,
-			size_type __pos = 0) const noexcept
-      { return this->find_first_not_of(__str._M_str, __pos, __str._M_len); }
-
-      /*constexpr*/ size_type
-      find_first_not_of(_CharT __c, size_type __pos = 0) const noexcept;
-
-      /*constexpr*/ size_type
-      find_first_not_of(const _CharT* __str,
-			size_type __pos, size_type __n) const;
-
-      /*constexpr*/ size_type
-      find_first_not_of(const _CharT* __str, size_type __pos = 0) const noexcept
-      {
-	return this->find_first_not_of(__str, __pos,
-				       traits_type::length(__str));
-      }
-
-      /*constexpr*/ size_type
-      find_last_not_of(basic_string_view __str,
-		       size_type __pos = npos) const noexcept
-      { return this->find_last_not_of(__str._M_str, __pos, __str._M_len); }
-
-      /*constexpr*/ size_type
-      find_last_not_of(_CharT __c, size_type __pos = npos) const noexcept;
-
-      /*constexpr*/ size_type
-      find_last_not_of(const _CharT* __str,
-		       size_type __pos, size_type __n) const;
-
-      /*constexpr*/ size_type
-      find_last_not_of(const _CharT* __str,
-		       size_type __pos = npos) const noexcept
-      {
-	return this->find_last_not_of(__str, __pos,
-				      traits_type::length(__str));
-      }
-
-    private:
-
-      static constexpr int
-      _S_compare(size_type __n1, size_type __n2) noexcept
-      {
-	return difference_type(__n1 - __n2) > std::numeric_limits<int>::max()
-	     ? std::numeric_limits<int>::max()
-	     : difference_type(__n1 - __n2) < std::numeric_limits<int>::min()
-	     ? std::numeric_limits<int>::min()
-	     : static_cast<int>(difference_type(__n1 - __n2));
-      }
-
-      size_t	    _M_len;
-      const _CharT* _M_str;
-    };
-
-  // [string.view.comparison], non-member basic_string_view comparison functions
-
-  namespace __detail
-  {
-    // Identity transform to create a non-deduced context, so that only one
-    // argument participates in template argument deduction and the other
-    // argument gets implicitly converted to the deduced type. See n3766.html.
-    template<typename _Tp>
-      using __idt = typename std::common_type<_Tp>::type;
-  }
-
-  template<typename _CharT, typename _Traits>
-    /*constexpr*/ bool
-    operator==(basic_string_view<_CharT, _Traits> __x,
-	       basic_string_view<_CharT, _Traits> __y) noexcept
-    { return __x.size() == __y.size() && __x.compare(__y) == 0; }
-
-  template<typename _CharT, typename _Traits>
-    /*constexpr*/ bool
-    operator==(basic_string_view<_CharT, _Traits> __x,
-	       __detail::__idt<basic_string_view<_CharT, _Traits>> __y) noexcept
-    { return __x.size() == __y.size() && __x.compare(__y) == 0; }
-
-  template<typename _CharT, typename _Traits>
-    /*constexpr*/ bool
-    operator==(__detail::__idt<basic_string_view<_CharT, _Traits>> __x,
-	       basic_string_view<_CharT, _Traits> __y) noexcept
-    { return __x.size() == __y.size() && __x.compare(__y) == 0; }
-
-  template<typename _CharT, typename _Traits>
-    /*constexpr*/ bool
-    operator!=(basic_string_view<_CharT, _Traits> __x,
-	       basic_string_view<_CharT, _Traits> __y) noexcept
-    { return !(__x == __y); }
-
-  template<typename _CharT, typename _Traits>
-    /*constexpr*/ bool
-    operator!=(basic_string_view<_CharT, _Traits> __x,
-	       __detail::__idt<basic_string_view<_CharT, _Traits>> __y) noexcept
-    { return !(__x == __y); }
-
-  template<typename _CharT, typename _Traits>
-    /*constexpr*/ bool
-    operator!=(__detail::__idt<basic_string_view<_CharT, _Traits>> __x,
-	       basic_string_view<_CharT, _Traits> __y) noexcept
-    { return !(__x == __y); }
-
-  template<typename _CharT, typename _Traits>
-    /*constexpr*/ bool
-    operator< (basic_string_view<_CharT, _Traits> __x,
-	       basic_string_view<_CharT, _Traits> __y) noexcept
-    { return __x.compare(__y) < 0; }
-
-  template<typename _CharT, typename _Traits>
-    /*constexpr*/ bool
-    operator< (basic_string_view<_CharT, _Traits> __x,
-	       __detail::__idt<basic_string_view<_CharT, _Traits>> __y) noexcept
-    { return __x.compare(__y) < 0; }
-
-  template<typename _CharT, typename _Traits>
-    /*constexpr*/ bool
-    operator< (__detail::__idt<basic_string_view<_CharT, _Traits>> __x,
-	       basic_string_view<_CharT, _Traits> __y) noexcept
-    { return __x.compare(__y) < 0; }
-
-  template<typename _CharT, typename _Traits>
-    /*constexpr*/ bool
-    operator> (basic_string_view<_CharT, _Traits> __x,
-	       basic_string_view<_CharT, _Traits> __y) noexcept
-    { return __x.compare(__y) > 0; }
-
-  template<typename _CharT, typename _Traits>
-    /*constexpr*/ bool
-    operator> (basic_string_view<_CharT, _Traits> __x,
-	       __detail::__idt<basic_string_view<_CharT, _Traits>> __y) noexcept
-    { return __x.compare(__y) > 0; }
-
-  template<typename _CharT, typename _Traits>
-    /*constexpr*/ bool
-    operator> (__detail::__idt<basic_string_view<_CharT, _Traits>> __x,
-	       basic_string_view<_CharT, _Traits> __y) noexcept
-    { return __x.compare(__y) > 0; }
-
-  template<typename _CharT, typename _Traits>
-    /*constexpr*/ bool
-    operator<=(basic_string_view<_CharT, _Traits> __x,
-	       basic_string_view<_CharT, _Traits> __y) noexcept
-    { return __x.compare(__y) <= 0; }
-
-  template<typename _CharT, typename _Traits>
-    /*constexpr*/ bool
-    operator<=(basic_string_view<_CharT, _Traits> __x,
-	       __detail::__idt<basic_string_view<_CharT, _Traits>> __y) noexcept
-    { return __x.compare(__y) <= 0; }
-
-  template<typename _CharT, typename _Traits>
-    /*constexpr*/ bool
-    operator<=(__detail::__idt<basic_string_view<_CharT, _Traits>> __x,
-	       basic_string_view<_CharT, _Traits> __y) noexcept
-    { return __x.compare(__y) <= 0; }
-
-  template<typename _CharT, typename _Traits>
-    /*constexpr*/ bool
-    operator>=(basic_string_view<_CharT, _Traits> __x,
-	       basic_string_view<_CharT, _Traits> __y) noexcept
-    { return __x.compare(__y) >= 0; }
-
-  template<typename _CharT, typename _Traits>
-    /*constexpr*/ bool
-    operator>=(basic_string_view<_CharT, _Traits> __x,
-	       __detail::__idt<basic_string_view<_CharT, _Traits>> __y) noexcept
-    { return __x.compare(__y) >= 0; }
-
-  template<typename _CharT, typename _Traits>
-    /*constexpr*/ bool
-    operator>=(__detail::__idt<basic_string_view<_CharT, _Traits>> __x,
-	       basic_string_view<_CharT, _Traits> __y) noexcept
-    { return __x.compare(__y) >= 0; }
-
-  // basic_string_view typedef names
-
-  using string_view = basic_string_view<char>;
-} /* namespace gdb */
-
-#include "gdb_string_view.tcc"
-
-#endif // __cplusplus < 201703L
-
-namespace gdb {
-
-static inline std::string
-to_string(const std::string_view &view)
-{
-  return { view.data (), view.size () };
-}
-
-}
-
-#endif /* COMMON_GDB_STRING_VIEW_H */
diff --git a/gdbsupport/gdb_string_view.tcc b/gdbsupport/gdb_string_view.tcc
deleted file mode 100644
index 0798105673b..00000000000
--- a/gdbsupport/gdb_string_view.tcc
+++ /dev/null
@@ -1,219 +0,0 @@
-// Components for manipulating non-owning sequences of characters -*- C++ -*-
-
-// Note: This file has been stolen from the gcc repo
-// (libstdc++-v3/include/experimental/bits/string_view.tcc) and has local
-// modifications.
-
-// Copyright (C) 2013-2023 Free Software Foundation, Inc.
-//
-// 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 experimental/bits/string_view.tcc
- *  This is an internal header file, included by other library headers.
- *  Do not attempt to use it directly. @headername{experimental/string_view}
- */
-
-//
-// N3762 basic_string_view library
-//
-
-#ifndef GDB_STRING_VIEW_TCC
-#define GDB_STRING_VIEW_TCC 1
-
-namespace gdb
-{
-  template<typename _CharT, typename _Traits>
-    /*constexpr*/ typename basic_string_view<_CharT, _Traits>::size_type
-    basic_string_view<_CharT, _Traits>::
-    find(const _CharT* __str, size_type __pos, size_type __n) const noexcept
-    {
-      gdb_assert (__str != nullptr || __n == 0);
-
-      if (__n == 0)
-	return __pos <= this->_M_len ? __pos : npos;
-
-      if (__n <= this->_M_len)
-	{
-	  for (; __pos <= this->_M_len - __n; ++__pos)
-	    if (traits_type::eq(this->_M_str[__pos], __str[0])
-		&& traits_type::compare(this->_M_str + __pos + 1,
-					__str + 1, __n - 1) == 0)
-	      return __pos;
-	}
-      return npos;
-    }
-
-  template<typename _CharT, typename _Traits>
-    /*constexpr*/ typename basic_string_view<_CharT, _Traits>::size_type
-    basic_string_view<_CharT, _Traits>::
-    find(_CharT __c, size_type __pos) const noexcept
-    {
-      size_type __ret = npos;
-      if (__pos < this->_M_len)
-	{
-	  const size_type __n = this->_M_len - __pos;
-	  const _CharT* __p = traits_type::find(this->_M_str + __pos, __n, __c);
-	  if (__p)
-	    __ret = __p - this->_M_str;
-	}
-      return __ret;
-    }
-
-  template<typename _CharT, typename _Traits>
-    /*constexpr*/ typename basic_string_view<_CharT, _Traits>::size_type
-    basic_string_view<_CharT, _Traits>::
-    rfind(const _CharT* __str, size_type __pos, size_type __n) const noexcept
-    {
-      gdb_assert (__str != nullptr || __n == 0);
-
-      if (__n <= this->_M_len)
-	{
-	  __pos = std::min(size_type(this->_M_len - __n), __pos);
-	  do
-	    {
-	      if (traits_type::compare(this->_M_str + __pos, __str, __n) == 0)
-		return __pos;
-	    }
-	  while (__pos-- > 0);
-	}
-      return npos;
-    }
-
-  template<typename _CharT, typename _Traits>
-    /*constexpr*/ typename basic_string_view<_CharT, _Traits>::size_type
-    basic_string_view<_CharT, _Traits>::
-    rfind(_CharT __c, size_type __pos) const noexcept
-    {
-      size_type __size = this->_M_len;
-      if (__size > 0)
-	{
-	  if (--__size > __pos)
-	    __size = __pos;
-	  for (++__size; __size-- > 0; )
-	    if (traits_type::eq(this->_M_str[__size], __c))
-	      return __size;
-	}
-      return npos;
-    }
-
-  template<typename _CharT, typename _Traits>
-    /*constexpr*/ typename basic_string_view<_CharT, _Traits>::size_type
-    basic_string_view<_CharT, _Traits>::
-    find_first_of(const _CharT* __str, size_type __pos, size_type __n) const
-    {
-      gdb_assert (__str != nullptr || __n == 0);
-      for (; __n && __pos < this->_M_len; ++__pos)
-	{
-	  const _CharT* __p = traits_type::find(__str, __n,
-						this->_M_str[__pos]);
-	  if (__p)
-	    return __pos;
-	}
-      return npos;
-    }
-
-  template<typename _CharT, typename _Traits>
-    /*constexpr*/ typename basic_string_view<_CharT, _Traits>::size_type
-    basic_string_view<_CharT, _Traits>::
-    find_last_of(const _CharT* __str, size_type __pos, size_type __n) const
-    {
-      gdb_assert (__str != nullptr || __n == 0);
-      size_type __size = this->size();
-      if (__size && __n)
-	{
-	  if (--__size > __pos)
-	    __size = __pos;
-	  do
-	    {
-	      if (traits_type::find(__str, __n, this->_M_str[__size]))
-		return __size;
-	    }
-	  while (__size-- != 0);
-	}
-      return npos;
-    }
-
-  template<typename _CharT, typename _Traits>
-    /*constexpr*/ typename basic_string_view<_CharT, _Traits>::size_type
-    basic_string_view<_CharT, _Traits>::
-    find_first_not_of(const _CharT* __str, size_type __pos, size_type __n) const
-    {
-      gdb_assert (__str != nullptr || __n == 0);
-      for (; __pos < this->_M_len; ++__pos)
-	if (!traits_type::find(__str, __n, this->_M_str[__pos]))
-	  return __pos;
-      return npos;
-    }
-
-  template<typename _CharT, typename _Traits>
-    /*constexpr*/ typename basic_string_view<_CharT, _Traits>::size_type
-    basic_string_view<_CharT, _Traits>::
-    find_first_not_of(_CharT __c, size_type __pos) const noexcept
-    {
-      for (; __pos < this->_M_len; ++__pos)
-	if (!traits_type::eq(this->_M_str[__pos], __c))
-	  return __pos;
-      return npos;
-    }
-
-  template<typename _CharT, typename _Traits>
-    /*constexpr*/ typename basic_string_view<_CharT, _Traits>::size_type
-    basic_string_view<_CharT, _Traits>::
-    find_last_not_of(const _CharT* __str, size_type __pos, size_type __n) const
-    {
-      gdb_assert (__str != nullptr || __n == 0);
-      size_type __size = this->_M_len;
-      if (__size)
-	{
-	  if (--__size > __pos)
-	    __size = __pos;
-	  do
-	    {
-	      if (!traits_type::find(__str, __n, this->_M_str[__size]))
-		return __size;
-	    }
-	  while (__size--);
-	}
-      return npos;
-    }
-
-  template<typename _CharT, typename _Traits>
-    /*constexpr*/ typename basic_string_view<_CharT, _Traits>::size_type
-    basic_string_view<_CharT, _Traits>::
-    find_last_not_of(_CharT __c, size_type __pos) const noexcept
-    {
-      size_type __size = this->_M_len;
-      if (__size)
-	{
-	  if (--__size > __pos)
-	    __size = __pos;
-	  do
-	    {
-	      if (!traits_type::eq(this->_M_str[__size], __c))
-		return __size;
-	    }
-	  while (__size--);
-	}
-      return npos;
-    }
-} // namespace gdb
-
-#endif // GDB_STRING_VIEW_TCC
-- 
2.34.1


^ permalink raw reply	[flat|nested] 39+ messages in thread

* [COMMITTED PATCH v2 7/9] gdbsupport: Replace gdb::invoke_result with std::invoke_result
  2023-10-28 20:48       ` Lancelot SIX
                           ` (6 preceding siblings ...)
  2023-11-21 12:04         ` [COMMITTED PATCH v2 6/9] gdbsupport: Remove gdb::string_view Lancelot Six
@ 2023-11-21 12:04         ` Lancelot Six
  2023-11-21 12:04         ` [COMMITTED PATCH v2 8/9] gdb/disasm.h: Mark callbacks noexcept unconditionally Lancelot Six
  2023-11-21 12:05         ` [COMMITTED PATCH v2 9/9] gdb: Use initializers in lambda captures unconditionally Lancelot Six
  9 siblings, 0 replies; 39+ messages in thread
From: Lancelot Six @ 2023-11-21 12:04 UTC (permalink / raw)
  To: gdb-patches; +Cc: pedro, tom, Lancelot Six

Given that GDB now requires C++17, we can replace gdb::invoke_result
with std::invoke_result which is provided by <type_traits>.

This patch also removes gdbsupport/invoke-result.h as it is not used
anymore.

Change-Id: I7e567356d38d6b3d85d8797d61cfc83f6f933f22
Approved-By: Tom Tromey <tom@tromey.com>
Approved-By: Pedro Alves <pedro@palves.net>
---
 gdbsupport/filtered-iterator.h |  4 ++--
 gdbsupport/function-view.h     |  4 ++--
 gdbsupport/invoke-result.h     | 37 ----------------------------------
 gdbsupport/parallel-for.h      |  9 ++++-----
 gdbsupport/safe-iterator.h     |  4 ++--
 5 files changed, 10 insertions(+), 48 deletions(-)
 delete mode 100644 gdbsupport/invoke-result.h

diff --git a/gdbsupport/filtered-iterator.h b/gdbsupport/filtered-iterator.h
index 9e9548ef824..aa3366942d1 100644
--- a/gdbsupport/filtered-iterator.h
+++ b/gdbsupport/filtered-iterator.h
@@ -19,7 +19,7 @@
 #ifndef COMMON_FILTERED_ITERATOR_H
 #define COMMON_FILTERED_ITERATOR_H
 
-#include "gdbsupport/invoke-result.h"
+#include <type_traits>
 
 /* A filtered iterator.  This wraps BaseIterator and automatically
    skips elements that FilterFunc filters out.  Requires that
@@ -56,7 +56,7 @@ class filtered_iterator
     : filtered_iterator (static_cast<const filtered_iterator &> (other))
   {}
 
-  typename gdb::invoke_result<decltype(&BaseIterator::operator*),
+  typename std::invoke_result<decltype(&BaseIterator::operator*),
 			      BaseIterator>::type
     operator* () const
   { return *m_it; }
diff --git a/gdbsupport/function-view.h b/gdbsupport/function-view.h
index cd62d40fd5e..ed113c74cfd 100644
--- a/gdbsupport/function-view.h
+++ b/gdbsupport/function-view.h
@@ -192,7 +192,7 @@
   You can find unit tests covering the whole API in
   unittests/function-view-selftests.c.  */
 
-#include "invoke-result.h"
+#include <type_traits>
 namespace gdb {
 
 namespace fv_detail {
@@ -230,7 +230,7 @@ class function_view<Res (Args...)>
   /* True if Func can be called with Args, and either the result is
      Res, convertible to Res or Res is void.  */
   template<typename Callable,
-	   typename Res2 = typename gdb::invoke_result<Callable &, Args...>::type>
+	   typename Res2 = typename std::invoke_result<Callable &, Args...>::type>
   struct IsCompatibleCallable : CompatibleReturnType<Res2, Res>
   {};
 
diff --git a/gdbsupport/invoke-result.h b/gdbsupport/invoke-result.h
deleted file mode 100644
index c9bb55e5b08..00000000000
--- a/gdbsupport/invoke-result.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/* Compatibility wrapper around std::result_of and std::invoke_result.
-
-   Copyright (C) 2022-2023 Free Software Foundation, Inc.
-
-   This file is part of GDB.
-
-   This program 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 of the License, or
-   (at your option) any later version.
-
-   This program 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.
-
-   You should have received a copy of the GNU General Public License
-   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
-
-#ifndef GDBSUPPORT_INVOKE_RESULT_H
-#define GDBSUPPORT_INVOKE_RESULT_H
-
-#include <type_traits>
-
-namespace gdb
-{
-#if __cplusplus >= 201703L
-template<typename Callable, class... Args>
-using invoke_result = std::invoke_result<Callable, Args...>;
-#else
-template<typename Callable, typename... Args>
-using invoke_result = std::result_of<Callable (Args...)>;
-#endif
-
-} /* namespace gdb */
-
-#endif /* GDBSUPPORT_INVOKE_RESULT_H */
diff --git a/gdbsupport/parallel-for.h b/gdbsupport/parallel-for.h
index b57f7ea97e1..ee7bfd948e2 100644
--- a/gdbsupport/parallel-for.h
+++ b/gdbsupport/parallel-for.h
@@ -22,7 +22,6 @@
 
 #include <algorithm>
 #include <type_traits>
-#include "gdbsupport/invoke-result.h"
 #include "gdbsupport/thread-pool.h"
 #include "gdbsupport/function-view.h"
 
@@ -145,14 +144,14 @@ struct par_for_accumulator<void>
 
 template<class RandomIt, class RangeFunction>
 typename gdb::detail::par_for_accumulator<
-    typename gdb::invoke_result<RangeFunction, RandomIt, RandomIt>::type
+    typename std::invoke_result<RangeFunction, RandomIt, RandomIt>::type
   >::result_type
 parallel_for_each (unsigned n, RandomIt first, RandomIt last,
 		   RangeFunction callback,
 		   gdb::function_view<size_t(RandomIt)> task_size = nullptr)
 {
   using result_type
-    = typename gdb::invoke_result<RangeFunction, RandomIt, RandomIt>::type;
+    = typename std::invoke_result<RangeFunction, RandomIt, RandomIt>::type;
 
   /* If enabled, print debug info about how the work is distributed across
      the threads.  */
@@ -305,13 +304,13 @@ parallel_for_each (unsigned n, RandomIt first, RandomIt last,
 
 template<class RandomIt, class RangeFunction>
 typename gdb::detail::par_for_accumulator<
-    typename gdb::invoke_result<RangeFunction, RandomIt, RandomIt>::type
+    typename std::invoke_result<RangeFunction, RandomIt, RandomIt>::type
   >::result_type
 sequential_for_each (unsigned n, RandomIt first, RandomIt last,
 		     RangeFunction callback,
 		     gdb::function_view<size_t(RandomIt)> task_size = nullptr)
 {
-  using result_type = typename gdb::invoke_result<RangeFunction, RandomIt, RandomIt>::type;
+  using result_type = typename std::invoke_result<RangeFunction, RandomIt, RandomIt>::type;
 
   gdb::detail::par_for_accumulator<result_type> results (0);
 
diff --git a/gdbsupport/safe-iterator.h b/gdbsupport/safe-iterator.h
index ccd772ca2a5..b4891328f1a 100644
--- a/gdbsupport/safe-iterator.h
+++ b/gdbsupport/safe-iterator.h
@@ -19,7 +19,7 @@
 #ifndef COMMON_SAFE_ITERATOR_H
 #define COMMON_SAFE_ITERATOR_H
 
-#include "gdbsupport/invoke-result.h"
+#include <type_traits>
 
 /* A forward iterator that wraps Iterator, such that when iterating
    with iterator IT, it is possible to delete *IT without invalidating
@@ -77,7 +77,7 @@ class basic_safe_iterator
   basic_safe_iterator ()
   {}
 
-  typename gdb::invoke_result<decltype(&Iterator::operator*), Iterator>::type
+  typename std::invoke_result<decltype(&Iterator::operator*), Iterator>::type
     operator* () const
   { return *m_it; }
 
-- 
2.34.1


^ permalink raw reply	[flat|nested] 39+ messages in thread

* [COMMITTED PATCH v2 8/9] gdb/disasm.h: Mark callbacks noexcept unconditionally
  2023-10-28 20:48       ` Lancelot SIX
                           ` (7 preceding siblings ...)
  2023-11-21 12:04         ` [COMMITTED PATCH v2 7/9] gdbsupport: Replace gdb::invoke_result with std::invoke_result Lancelot Six
@ 2023-11-21 12:04         ` Lancelot Six
  2023-11-21 12:05         ` [COMMITTED PATCH v2 9/9] gdb: Use initializers in lambda captures unconditionally Lancelot Six
  9 siblings, 0 replies; 39+ messages in thread
From: Lancelot Six @ 2023-11-21 12:04 UTC (permalink / raw)
  To: gdb-patches; +Cc: pedro, tom, Lancelot Six

Given that C++17 is now a requirement for GDB, update gdb/disasm.h to
define callback function types noexcept unconditionally.  The pre-C++17
configuration is not supported anymore.

Change-Id: I0a38e22b7912c70a11425363a991f0b01614343e
Approved-By: Tom Tromey <tom@tromey.com>
Approved-By: Pedro Alves <pedro@palves.net>
---
 gdb/disasm.h | 27 ++++++---------------------
 1 file changed, 6 insertions(+), 21 deletions(-)

diff --git a/gdb/disasm.h b/gdb/disasm.h
index 5596bd62a10..90fa1dfc02b 100644
--- a/gdb/disasm.h
+++ b/gdb/disasm.h
@@ -26,12 +26,6 @@ struct gdbarch;
 struct ui_out;
 struct ui_file;
 
-#if __cplusplus >= 201703L
-#define LIBOPCODE_CALLBACK_NOEXCEPT noexcept
-#else
-#define LIBOPCODE_CALLBACK_NOEXCEPT
-#endif
-
 /* A wrapper around a disassemble_info and a gdbarch.  This is the core
    set of data that all disassembler sub-classes will need.  This class
    doesn't actually implement the disassembling process, that is something
@@ -58,27 +52,18 @@ struct gdb_disassemble_info
 protected:
 
   /* Types for the function callbacks within m_di.  The actual function
-     signatures here are taken from include/dis-asm.h.  The noexcept macro
-     expands to 'noexcept' for C++17 and later, otherwise, it expands to
-     nothing.  This is because including noexcept was ignored for function
-     types before C++17, but both GCC and Clang warn that the noexcept
-     will become relevant when you switch to C++17, and this warning
-     causes the build to fail.  */
+     signatures here are taken from include/dis-asm.h.  */
   using read_memory_ftype
     = int (*) (bfd_vma, bfd_byte *, unsigned int, struct disassemble_info *)
-	LIBOPCODE_CALLBACK_NOEXCEPT;
+	noexcept;
   using memory_error_ftype
-    = void (*) (int, bfd_vma, struct disassemble_info *)
-	LIBOPCODE_CALLBACK_NOEXCEPT;
+    = void (*) (int, bfd_vma, struct disassemble_info *) noexcept;
   using print_address_ftype
-    = void (*) (bfd_vma, struct disassemble_info *)
-	LIBOPCODE_CALLBACK_NOEXCEPT;
+    = void (*) (bfd_vma, struct disassemble_info *) noexcept;
   using fprintf_ftype
-    = int (*) (void *, const char *, ...)
-	LIBOPCODE_CALLBACK_NOEXCEPT;
+    = int (*) (void *, const char *, ...) noexcept;
   using fprintf_styled_ftype
-    = int (*) (void *, enum disassembler_style, const char *, ...)
-	LIBOPCODE_CALLBACK_NOEXCEPT;
+    = int (*) (void *, enum disassembler_style, const char *, ...) noexcept;
 
   /* Constructor, many fields in m_di are initialized from GDBARCH.  The
      remaining arguments are function callbacks that are written into m_di.
-- 
2.34.1


^ permalink raw reply	[flat|nested] 39+ messages in thread

* [COMMITTED PATCH v2 9/9] gdb: Use initializers in lambda captures unconditionally
  2023-10-28 20:48       ` Lancelot SIX
                           ` (8 preceding siblings ...)
  2023-11-21 12:04         ` [COMMITTED PATCH v2 8/9] gdb/disasm.h: Mark callbacks noexcept unconditionally Lancelot Six
@ 2023-11-21 12:05         ` Lancelot Six
  9 siblings, 0 replies; 39+ messages in thread
From: Lancelot Six @ 2023-11-21 12:05 UTC (permalink / raw)
  To: gdb-patches; +Cc: pedro, tom, Lancelot Six

Initializers in lambda captures were introduced in C++14, and
conditionally used in gdb/cp-support.c and gdb/dwarf2/cooked-index.c.

Since C++17 is now required by GDB, use this feature unconditionally.

Change-Id: I87a3d567941e5c71217538fa75c952e4d421fa1d
Approved-By: Tom Tromey <tom@tromey.com>
Approved-By: Pedro Alves <pedro@palves.net>
---
 gdb/cp-support.c          | 8 +-------
 gdb/dwarf2/cooked-index.c | 7 +------
 2 files changed, 2 insertions(+), 13 deletions(-)

diff --git a/gdb/cp-support.c b/gdb/cp-support.c
index 834c4774755..cb169444d2a 100644
--- a/gdb/cp-support.c
+++ b/gdb/cp-support.c
@@ -1657,13 +1657,7 @@ gdb_demangle (const char *name, int options)
 	     we might be in a background thread.  Instead, arrange for
 	     the reporting to happen on the main thread.  */
 	  std::string copy = name;
-	  run_on_main_thread ([
-#if __cplusplus >= 201402L
-			       =, copy = std::move (copy)
-#else
-			       =
-#endif
-			       ] ()
+	  run_on_main_thread ([=, copy = std::move (copy)] ()
 	    {
 	      report_failed_demangle (copy.c_str (), core_dump_allowed,
 				      crash_signal);
diff --git a/gdb/dwarf2/cooked-index.c b/gdb/dwarf2/cooked-index.c
index 7c4af3a1681..10631dccecf 100644
--- a/gdb/dwarf2/cooked-index.c
+++ b/gdb/dwarf2/cooked-index.c
@@ -466,12 +466,7 @@ cooked_index::start_writing_index (dwarf2_per_bfd *per_bfd)
      started, because it may call 'wait'.  */
   m_write_future
     = gdb::thread_pool::g_thread_pool->post_task ([this, per_bfd,
-#if __cplusplus >= 201402L
-						   ctx = std::move (ctx)
-#else
-						   ctx
-#endif
-						   ] ()
+						   ctx = std::move (ctx)] ()
 	{
 	  maybe_write_index (per_bfd, ctx);
 	});
-- 
2.34.1


^ permalink raw reply	[flat|nested] 39+ messages in thread

end of thread, other threads:[~2023-11-21 12:06 UTC | newest]

Thread overview: 39+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-13 14:44 [PATCH 00/11] GDB: Require C++17 Lancelot Six
2023-10-13 14:44 ` [PATCH 01/11] gdb/ax_cxx_compile_stdcxx.m4: upgrade Lancelot Six
2023-10-13 14:44 ` [PATCH 02/11] gdb/gdbsupport/gdbserver: Require c++17 Lancelot Six
2023-10-13 15:21   ` Eli Zaretskii
2023-10-16 21:50   ` Pedro Alves
2023-10-13 14:44 ` [PATCH 03/11] gdb: Use C++17's std::make_unique instead of gdb::make_unique Lancelot Six
2023-10-16 19:14   ` Tom Tromey
2023-10-17 14:02     ` Lancelot SIX
2023-10-13 14:44 ` [PATCH 04/11] gdb: Replace gdb::optional with std::optional Lancelot Six
2023-10-13 14:44 ` [PATCH 05/11] gdbsupport: remove gdb::optional Lancelot Six
2023-10-13 14:44 ` [PATCH 06/11] gdb: Use std::string_view instead of gdb::string_view Lancelot Six
2023-10-14 21:50   ` Tom Tromey
2023-10-14 23:58     ` Six, Lancelot
2023-10-16 15:06     ` Lancelot SIX
2023-10-16 19:35       ` Tom Tromey
2023-10-16 21:51         ` Pedro Alves
2023-10-17 14:13           ` Lancelot SIX
2023-10-17 14:20             ` Simon Marchi
2023-10-13 14:44 ` [PATCH 07/11] gdb: Remove uses of gdb::to_string (const std::string_view &) Lancelot Six
2023-10-13 14:44 ` [PATCH 08/11] gdbsupport: Remove gdb::string_view Lancelot Six
2023-10-16 19:38   ` Tom Tromey
2023-10-13 14:44 ` [PATCH 09/11] gdbsupport: Replace gdb::invoke_result with std::invoke_result Lancelot Six
2023-10-13 14:44 ` [PATCH 10/11] gdb/disasm.h: Mark callbacks noexcept unconditionally Lancelot Six
2023-10-16 21:51   ` Pedro Alves
2023-10-13 14:44 ` [PATCH 11/11] gdb: Use initializers in lambda captures unconditionally Lancelot Six
2023-10-16 19:43 ` [PATCH 00/11] GDB: Require C++17 Tom Tromey
2023-10-16 21:53   ` Pedro Alves
2023-10-23 13:42     ` Lancelot SIX
2023-10-28 20:48       ` Lancelot SIX
2023-11-21 12:04         ` [COMMITTED PATCH v2 0/9] " Lancelot Six
2023-11-21 12:04         ` [COMMITTED PATCH v2 1/9] gdb: Use C++17's std::make_unique instead of gdb::make_unique Lancelot Six
2023-11-21 12:04         ` [COMMITTED PATCH v2 2/9] gdb: Replace gdb::optional with std::optional Lancelot Six
2023-11-21 12:04         ` [COMMITTED PATCH v2 3/9] gdbsupport: remove gdb::optional Lancelot Six
2023-11-21 12:04         ` [COMMITTED PATCH v2 4/9] gdb: Use std::string_view instead of gdb::string_view Lancelot Six
2023-11-21 12:04         ` [COMMITTED PATCH v2 5/9] gdb: Remove uses of gdb::to_string (const std::string_view &) Lancelot Six
2023-11-21 12:04         ` [COMMITTED PATCH v2 6/9] gdbsupport: Remove gdb::string_view Lancelot Six
2023-11-21 12:04         ` [COMMITTED PATCH v2 7/9] gdbsupport: Replace gdb::invoke_result with std::invoke_result Lancelot Six
2023-11-21 12:04         ` [COMMITTED PATCH v2 8/9] gdb/disasm.h: Mark callbacks noexcept unconditionally Lancelot Six
2023-11-21 12:05         ` [COMMITTED PATCH v2 9/9] gdb: Use initializers in lambda captures unconditionally Lancelot Six

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).