libstdc++: testsuite/util adjustments for import std

In my import std testing patch, to work around c++/99000 (include after
import) I move #includes of the util/ headers above the import.  And so I
made some adjustments to those headers to support this: adding some missing
dependencies, making sure that in headers that include both importable and
non-importable headers, at least one importable header comes first to work
with my patch to translate e.g. #include <vector> to import <bits/stdc++.h>.

The testsuite_iterators.h avoids a failure in
20_util/specialized_algorithms/uninitialized_copy/constrained.cc from
including <memory> after this header, with a mysterious "no match for
operator<" between long and difference_type.

libstdc++-v3/ChangeLog:

	* testsuite/util/testsuite_allocator.h: Move importable headers up.
	* testsuite/util/testsuite_common_types.h: Likewise.
	* testsuite/util/testsuite_containers.h: Likewise.
	* testsuite/util/testsuite_error.h: Move includes inside
	include guard.
	* testsuite/util/testsuite_greedy_ops.h: #include <cstddef>.
	* testsuite/util/testsuite_iterators.h: #include <utility>.
	* testsuite/util/testsuite_new_operators.h: #include <cstdlib>.
	* testsuite/util/testsuite_random.h: #include <random>.
This commit is contained in:
Jason Merrill 2025-11-17 21:26:40 +05:30
parent c8380ed022
commit 359d48af20
8 changed files with 23 additions and 18 deletions

View File

@ -26,14 +26,14 @@
#ifndef _GLIBCXX_TESTSUITE_ALLOCATOR_H
#define _GLIBCXX_TESTSUITE_ALLOCATOR_H
#include <bits/move.h>
#include <ext/pointer.h>
#include <ext/alloc_traits.h>
#include <testsuite_hooks.h>
#if __cplusplus >= 201703L
# include <memory_resource>
# include <new>
#endif
#include <bits/move.h>
#include <ext/pointer.h>
#include <ext/alloc_traits.h>
#include <testsuite_hooks.h>
#if __cplusplus >= 201103L
# include <unordered_map>

View File

@ -22,14 +22,6 @@
#ifndef _TESTSUITE_COMMON_TYPES_H
#define _TESTSUITE_COMMON_TYPES_H 1
#include <ext/typelist.h>
#include <ext/new_allocator.h>
#include <ext/malloc_allocator.h>
#include <ext/mt_allocator.h>
#include <ext/bitmap_allocator.h>
#include <ext/pool_allocator.h>
#include <algorithm>
#include <vector>
@ -53,6 +45,14 @@ namespace unord = std;
namespace unord = std::tr1;
#endif
#include <ext/typelist.h>
#include <ext/new_allocator.h>
#include <ext/malloc_allocator.h>
#include <ext/mt_allocator.h>
#include <ext/bitmap_allocator.h>
#include <ext/pool_allocator.h>
namespace __gnu_test
{
using __gnu_cxx::typelist::null_type;

View File

@ -20,10 +20,10 @@
#ifndef _GLIBCXX_TESTSUITE_CONTAINERS_H
#define _GLIBCXX_TESTSUITE_CONTAINERS_H
#include <bits/boost_concept_check.h>
#include <cassert>
#include <testsuite_container_traits.h>
#include <utility> // for rel_ops.
#include <bits/boost_concept_check.h>
#include <testsuite_container_traits.h>
// Container requirement testing.
namespace __gnu_test

View File

@ -19,12 +19,13 @@
// <http://www.gnu.org/licenses/>.
//
#include <string>
#include <testsuite_hooks.h>
#ifndef _TESTSUITE_ERROR_H
#define _TESTSUITE_ERROR_H 1
#include <string>
#include <system_error>
#include <testsuite_hooks.h>
namespace __gnu_test
{
struct test_category : public std::error_category

View File

@ -15,6 +15,8 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <cstddef>
namespace greedy_ops
{
struct X

View File

@ -31,7 +31,7 @@
#include <bits/stl_iterator_base_types.h>
#if __cplusplus >= 201103L
#include <bits/move.h>
#include <utility>
#endif
#if __cplusplus > 201703L

View File

@ -23,6 +23,7 @@
#define _GLIBCXX_TESTSUITE_NEW_OPERATORS_H
#include <new>
#include <cstdlib>
#include <testsuite_hooks.h>
namespace __gnu_test

View File

@ -27,6 +27,7 @@
#include <cmath>
#include <initializer_list>
#include <system_error>
#include <random>
#include <testsuite_hooks.h>
namespace __gnu_test