public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Jonathan Wakely <redi@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org
Subject: [gcc r13-3039] libstdc++: Make some tests work on freestanding [PR103626]
Date: Mon, 3 Oct 2022 14:45:56 +0000 (GMT) [thread overview]
Message-ID: <20221003144556.EB2533854838@sourceware.org> (raw)
https://gcc.gnu.org/g:46eb2860942a29b40822570cb6625620f69ed30e
commit r13-3039-g46eb2860942a29b40822570cb6625620f69ed30e
Author: Arsen Arsenović <arsen@aarsen.me>
Date: Fri Sep 30 16:53:18 2022 +0200
libstdc++: Make some tests work on freestanding [PR103626]
PR libstdc++/103626 - _GLIBCXX_HOSTED should respect -ffreestanding
Co-authored-by: Jonathan Wakely <jwakely@redhat.com>
libstdc++-v3/ChangeLog:
PR libstdc++/103626
* testsuite/17_intro/headers/c++1998/stdc++.cc [!__STDC_HOSTED__]:
Do not include C headers that aren't valid for freestanding.
* testsuite/17_intro/tag_type_explicit_ctor.cc [!__STDC_HOSTED__]:
Do not test tag types that aren't defined for freestanding.
* testsuite/18_support/headers/cstdlib/functions_std.cc: Do not
check for std::getenv and std::system for freestanding.
* testsuite/17_intro/using_namespace_std_exp_neg.cc [!__STDC_HOSTED__]:
Do not test hosted parts of the standard library.
* testsuite/17_intro/using_namespace_std_tr1_neg.cc [!__STDC_HOSTED__]:
Likewise.
* testsuite/20_util/allocator_traits/members/rebind_alloc.cc [!__STDC_HOSTED__]:
Likewise.
* testsuite/20_util/allocator_traits/requirements/explicit_instantiation.cc [!HOSTED]:
Likewise.
* testsuite/20_util/headers/bitset/synopsis.cc [!__STDC_HOSTED__]: Likewise.
* testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc [!__STDC_HOSTED__]:
Likewise.
* testsuite/20_util/pointer_traits/requirements/typedefs.cc [!__STDC_HOSTED__]:
Likewise.
* testsuite/20_util/tuple/cons/deduction.cc [!__STDC_HOSTED__]: Likewise.
* testsuite/25_algorithms/move/93872.cc [!__STDC_HOSTED__]: Likewise.
* testsuite/std/ranges/adaptors/100577.cc [!__STDC_HOSTED__]: Likewise.
Diff:
---
| 2 +
.../testsuite/17_intro/tag_type_explicit_ctor.cc | 32 ++++++++-----
.../17_intro/using_namespace_std_exp_neg.cc | 53 ++++++++++++----------
.../17_intro/using_namespace_std_tr1_neg.cc | 53 ++++++++++++----------
| 2 +
.../allocator_traits/members/rebind_alloc.cc | 2 +
.../requirements/explicit_instantiation.cc | 2 +
| 2 +
.../make_unsigned/requirements/typedefs_neg.cc | 4 +-
.../pointer_traits/requirements/typedefs.cc | 2 +
.../testsuite/20_util/tuple/cons/deduction.cc | 2 +
libstdc++-v3/testsuite/25_algorithms/move/93872.cc | 1 +
.../testsuite/std/ranges/adaptors/100577.cc | 11 ++++-
13 files changed, 104 insertions(+), 64 deletions(-)
--git a/libstdc++-v3/testsuite/17_intro/headers/c++1998/stdc++.cc b/libstdc++-v3/testsuite/17_intro/headers/c++1998/stdc++.cc
index 4776c18e1ed..e362dfee329 100644
--- a/libstdc++-v3/testsuite/17_intro/headers/c++1998/stdc++.cc
+++ b/libstdc++-v3/testsuite/17_intro/headers/c++1998/stdc++.cc
@@ -24,6 +24,7 @@
#include <bits/stdc++.h>
+#if __STDC_HOSTED__
// "C" compatibility headers
#include <assert.h>
#include <ctype.h>
@@ -47,3 +48,4 @@
#ifdef _GLIBCXX_HAVE_WCTYPE_H
#include <wctype.h>
#endif
+#endif
diff --git a/libstdc++-v3/testsuite/17_intro/tag_type_explicit_ctor.cc b/libstdc++-v3/testsuite/17_intro/tag_type_explicit_ctor.cc
index 262fc9a04d1..410142d3974 100644
--- a/libstdc++-v3/testsuite/17_intro/tag_type_explicit_ctor.cc
+++ b/libstdc++-v3/testsuite/17_intro/tag_type_explicit_ctor.cc
@@ -20,40 +20,50 @@
#include <new>
#include <utility>
#include <memory>
-#include <mutex>
+
+#if __STDC_HOSTED__
+# include <mutex>
+#endif
void f1(std::nothrow_t);
void f2(std::piecewise_construct_t);
void f3(std::allocator_arg_t);
+#if __STDC_HOSTED__
void f4(std::defer_lock_t);
void f5(std::try_to_lock_t);
void f6(std::adopt_lock_t);
-
+#endif
int main()
{
std::nothrow_t v1;
std::piecewise_construct_t v2;
std::allocator_arg_t v3;
+#if __STDC_HOSTED__
std::defer_lock_t v4;
std::try_to_lock_t v5;
std::try_to_lock_t v6;
+#endif
std::nothrow_t v7 = {}; // { dg-error "explicit" }
std::piecewise_construct_t v8 = {}; // { dg-error "explicit" }
std::allocator_arg_t v9 = {}; // { dg-error "explicit" }
- std::defer_lock_t v10 = {}; // { dg-error "explicit" }
- std::try_to_lock_t v11 = {}; // { dg-error "explicit" }
- std::try_to_lock_t v12 = {}; // { dg-error "explicit" }
+#if __STDC_HOSTED__
+ std::defer_lock_t v10 = {}; // { dg-error "explicit" "" { target hosted } }
+ std::try_to_lock_t v11 = {}; // { dg-error "explicit" "" { target hosted } }
+ std::try_to_lock_t v12 = {}; // { dg-error "explicit" "" { target hosted } }
+#endif
f1(std::nothrow_t{});
f2(std::piecewise_construct_t{});
f3(std::allocator_arg_t{});
- f4(std::defer_lock_t{});
- f5(std::try_to_lock_t{});
- f6(std::adopt_lock_t{});
f1({}); // { dg-error "explicit" }
f2({}); // { dg-error "explicit" }
f3({}); // { dg-error "explicit" }
- f4({}); // { dg-error "explicit" }
- f5({}); // { dg-error "explicit" }
- f6({}); // { dg-error "explicit" }
+#if __STDC_HOSTED__
+ f4(std::defer_lock_t{});
+ f5(std::try_to_lock_t{});
+ f6(std::adopt_lock_t{});
+ f4({}); // { dg-error "explicit" "" { target hosted } }
+ f5({}); // { dg-error "explicit" "" { target hosted } }
+ f6({}); // { dg-error "explicit" "" { target hosted } }
+#endif
}
diff --git a/libstdc++-v3/testsuite/17_intro/using_namespace_std_exp_neg.cc b/libstdc++-v3/testsuite/17_intro/using_namespace_std_exp_neg.cc
index cdec24e9f7f..9fadafdbccf 100644
--- a/libstdc++-v3/testsuite/17_intro/using_namespace_std_exp_neg.cc
+++ b/libstdc++-v3/testsuite/17_intro/using_namespace_std_exp_neg.cc
@@ -20,42 +20,45 @@
#include <algorithm>
#include <array>
#include <bitset>
-#include <complex>
-#include <deque>
#include <exception>
-#include <fstream>
#include <functional>
-#include <iomanip>
-#include <ios>
-#include <iosfwd>
-#include <iostream>
-#include <istream>
#include <iterator>
#include <limits>
-#include <list>
-#include <locale>
-#include <map>
#include <memory>
#include <new>
#include <numeric>
-#include <ostream>
-#include <queue>
-#include <random>
-#include <regex>
-#include <set>
-#include <sstream>
-#include <stack>
-#include <stdexcept>
-#include <streambuf>
-#include <string>
#include <tuple>
#include <typeinfo>
#include <type_traits>
-#include <unordered_map>
-#include <unordered_set>
#include <utility>
-#include <valarray>
-#include <vector>
+
+#if __STDC_HOSTED__
+# include <complex>
+# include <deque>
+# include <fstream>
+# include <iomanip>
+# include <ios>
+# include <iosfwd>
+# include <iostream>
+# include <istream>
+# include <list>
+# include <locale>
+# include <map>
+# include <ostream>
+# include <queue>
+# include <random>
+# include <regex>
+# include <set>
+# include <sstream>
+# include <stack>
+# include <stdexcept>
+# include <streambuf>
+# include <string>
+# include <unordered_map>
+# include <unordered_set>
+# include <valarray>
+# include <vector>
+#endif
namespace gnu
{
diff --git a/libstdc++-v3/testsuite/17_intro/using_namespace_std_tr1_neg.cc b/libstdc++-v3/testsuite/17_intro/using_namespace_std_tr1_neg.cc
index 31c2589da4f..4d08cc5bc91 100644
--- a/libstdc++-v3/testsuite/17_intro/using_namespace_std_tr1_neg.cc
+++ b/libstdc++-v3/testsuite/17_intro/using_namespace_std_tr1_neg.cc
@@ -23,42 +23,45 @@
#include <algorithm>
#include <array>
#include <bitset>
-#include <complex>
-#include <deque>
#include <exception>
-#include <fstream>
#include <functional>
-#include <iomanip>
-#include <ios>
-#include <iosfwd>
-#include <iostream>
-#include <istream>
#include <iterator>
#include <limits>
-#include <list>
-#include <locale>
-#include <map>
#include <memory>
#include <new>
#include <numeric>
-#include <ostream>
-#include <queue>
-#include <random>
-#include <regex>
-#include <set>
-#include <sstream>
-#include <stack>
-#include <stdexcept>
-#include <streambuf>
-#include <string>
#include <tuple>
#include <typeinfo>
#include <type_traits>
-#include <unordered_map>
-#include <unordered_set>
#include <utility>
-#include <valarray>
-#include <vector>
+
+#if __STDC_HOSTED__
+# include <complex>
+# include <deque>
+# include <fstream>
+# include <iomanip>
+# include <ios>
+# include <iosfwd>
+# include <iostream>
+# include <istream>
+# include <list>
+# include <locale>
+# include <map>
+# include <ostream>
+# include <queue>
+# include <random>
+# include <regex>
+# include <set>
+# include <sstream>
+# include <stack>
+# include <stdexcept>
+# include <streambuf>
+# include <string>
+# include <unordered_map>
+# include <unordered_set>
+# include <valarray>
+# include <vector>
+#endif
namespace gnu
{
--git a/libstdc++-v3/testsuite/18_support/headers/cstdlib/functions_std.cc b/libstdc++-v3/testsuite/18_support/headers/cstdlib/functions_std.cc
index e7738899ea0..af1ed6a8652 100644
--- a/libstdc++-v3/testsuite/18_support/headers/cstdlib/functions_std.cc
+++ b/libstdc++-v3/testsuite/18_support/headers/cstdlib/functions_std.cc
@@ -25,6 +25,8 @@ namespace gnu
using std::atexit;
using std::exit;
+#if __STDC_HOSTED__
using std::getenv;
using std::system;
+#endif
}
diff --git a/libstdc++-v3/testsuite/20_util/allocator_traits/members/rebind_alloc.cc b/libstdc++-v3/testsuite/20_util/allocator_traits/members/rebind_alloc.cc
index 32caf53c988..ca2a8044665 100644
--- a/libstdc++-v3/testsuite/20_util/allocator_traits/members/rebind_alloc.cc
+++ b/libstdc++-v3/testsuite/20_util/allocator_traits/members/rebind_alloc.cc
@@ -24,6 +24,7 @@ using std::is_same;
template<typename T, typename U>
using Rebind = typename std::allocator_traits<T>::template rebind_alloc<U>;
+#if __STDC_HOSTED__
template<typename T>
struct HasRebind {
using value_type = T;
@@ -33,6 +34,7 @@ template<typename T>
static_assert(is_same<Rebind<HasRebind<int>, long>,
std::allocator<long>>::value,
"nested alias template is used");
+#endif
template<typename T>
struct NoRebind0 {
diff --git a/libstdc++-v3/testsuite/20_util/allocator_traits/requirements/explicit_instantiation.cc b/libstdc++-v3/testsuite/20_util/allocator_traits/requirements/explicit_instantiation.cc
index 42a2091cf47..8f7c191e94a 100644
--- a/libstdc++-v3/testsuite/20_util/allocator_traits/requirements/explicit_instantiation.cc
+++ b/libstdc++-v3/testsuite/20_util/allocator_traits/requirements/explicit_instantiation.cc
@@ -36,6 +36,8 @@ template<typename T>
namespace std
{
+#if __STDC_HOSTED__
template struct allocator_traits<std::allocator<test_type>>;
+#endif
template struct allocator_traits<minimal_allocator<test_type>>;
}
--git a/libstdc++-v3/testsuite/20_util/headers/bitset/synopsis.cc b/libstdc++-v3/testsuite/20_util/headers/bitset/synopsis.cc
index ed5604b6b22..094f0f268b3 100644
--- a/libstdc++-v3/testsuite/20_util/headers/bitset/synopsis.cc
+++ b/libstdc++-v3/testsuite/20_util/headers/bitset/synopsis.cc
@@ -49,6 +49,7 @@ namespace std {
CONSTEXPR
bitset<N> operator^(const bitset<N>&, const bitset<N>&) NOTHROW;
+#if __STDC_HOSTED__
template <class charT, class traits, size_t N>
basic_istream<charT, traits>&
operator>>(basic_istream<charT, traits>& is, bitset<N>& x);
@@ -56,4 +57,5 @@ namespace std {
template <class charT, class traits, size_t N>
basic_ostream<charT, traits>&
operator<<(basic_ostream<charT, traits>& os, const bitset<N>& x);
+#endif
}
diff --git a/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc b/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc
index 9eebbc400b0..ff98cc42ef7 100644
--- a/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc
+++ b/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc
@@ -20,9 +20,9 @@
// <http://www.gnu.org/licenses/>.
#include <type_traits>
-#include <testsuite_character.h>
enum test_enum { first_selection };
+struct pod_class { };
void test01()
{
@@ -31,7 +31,7 @@ void test01()
// Negative tests.
typedef make_unsigned<bool>::type test1_type;
- typedef make_unsigned<__gnu_test::pod_uint>::type test2_type;
+ typedef make_unsigned<pod_class>::type test2_type;
typedef make_unsigned<int[4]>::type test3_type;
diff --git a/libstdc++-v3/testsuite/20_util/pointer_traits/requirements/typedefs.cc b/libstdc++-v3/testsuite/20_util/pointer_traits/requirements/typedefs.cc
index 93c8a369c25..a88372c4d3a 100644
--- a/libstdc++-v3/testsuite/20_util/pointer_traits/requirements/typedefs.cc
+++ b/libstdc++-v3/testsuite/20_util/pointer_traits/requirements/typedefs.cc
@@ -37,8 +37,10 @@ int main()
{
test01<int*>();
test01<void*>();
+#if __STDC_HOSTED__
test01<std::shared_ptr<int>>();
test01<std::shared_ptr<void>>();
+#endif
test01<std::unique_ptr<int>>();
test01<std::unique_ptr<void>>();
}
diff --git a/libstdc++-v3/testsuite/20_util/tuple/cons/deduction.cc b/libstdc++-v3/testsuite/20_util/tuple/cons/deduction.cc
index 8b9393dd334..c4b5a5c1eaf 100644
--- a/libstdc++-v3/testsuite/20_util/tuple/cons/deduction.cc
+++ b/libstdc++-v3/testsuite/20_util/tuple/cons/deduction.cc
@@ -145,6 +145,7 @@ test04()
void
test05()
{
+#if __STDC_HOSTED__
std::allocator<double> a;
std::tuple x{std::allocator_arg, a, 1};
check_type<std::tuple<int>>(x);
@@ -161,4 +162,5 @@ test05()
check_type<decltype(x)>(x5);
std::tuple x6{std::allocator_arg, a, std::move(x)};
check_type<decltype(x)>(x6);
+#endif
}
diff --git a/libstdc++-v3/testsuite/25_algorithms/move/93872.cc b/libstdc++-v3/testsuite/25_algorithms/move/93872.cc
index 4b0c8105171..8496a221063 100644
--- a/libstdc++-v3/testsuite/25_algorithms/move/93872.cc
+++ b/libstdc++-v3/testsuite/25_algorithms/move/93872.cc
@@ -18,6 +18,7 @@
// { dg-options "-std=gnu++2a" }
// { dg-do compile { target c++2a } }
+#include <iterator>
#include <algorithm>
#include <functional>
diff --git a/libstdc++-v3/testsuite/std/ranges/adaptors/100577.cc b/libstdc++-v3/testsuite/std/ranges/adaptors/100577.cc
index 97401dae39c..c900553743b 100644
--- a/libstdc++-v3/testsuite/std/ranges/adaptors/100577.cc
+++ b/libstdc++-v3/testsuite/std/ranges/adaptors/100577.cc
@@ -22,6 +22,9 @@
#include <ranges>
#include <functional>
+#if __STDC_HOSTED__
+#include <string>
+#endif
namespace ranges = std::ranges;
namespace views = std::ranges::views;
@@ -38,9 +41,11 @@ test01()
static_assert(__adaptor_has_simple_extra_args<decltype(views::take), int>);
static_assert(__adaptor_has_simple_extra_args<decltype(views::take_while), identity>);
static_assert(__adaptor_has_simple_extra_args<decltype(views::drop_while), identity>);
- static_assert(__adaptor_has_simple_extra_args<decltype(views::lazy_split), std::string_view>);
static_assert(__adaptor_has_simple_extra_args<decltype(views::lazy_split), char>);
+#if __STDC_HOSTED__
+ static_assert(__adaptor_has_simple_extra_args<decltype(views::lazy_split), std::string_view>);
static_assert(!__adaptor_has_simple_extra_args<decltype(views::lazy_split), std::string>);
+#endif
using views::__adaptor::__closure_has_simple_call_op;
__closure_has_simple_call_op auto a00 = views::all;
@@ -60,6 +65,7 @@ test01()
__closure_has_simple_call_op auto b
= (a00 | a01) | (a02 | a03) | (a04 | a05 | a06) | (a07 | a08 | a09 | a10) | a11;
+#if __STDC_HOSTED__
// Verify views::lazy_split(non_view_range) is an exception.
extern std::string s;
auto a12 = views::lazy_split(s);
@@ -72,6 +78,7 @@ test01()
static_assert(!__closure_has_simple_call_op<decltype(a12a)>);
static_assert(!__closure_has_simple_call_op<decltype(a12a | a00)>);
static_assert(!__closure_has_simple_call_op<decltype(a00 | a12a)>);
+#endif
}
void
@@ -129,6 +136,7 @@ test03()
void
test04()
{
+#if __STDC_HOSTED__
// Non-trivially-copyable extra arguments make a closure not simple.
using F = std::function<bool(bool)>;
static_assert(!std::is_trivially_copyable_v<F>);
@@ -137,6 +145,7 @@ test04()
static_assert(!__closure_has_simple_call_op<decltype(views::drop_while(std::declval<F>()))>);
static_assert(!__closure_has_simple_call_op<decltype(views::filter(std::declval<F>()))>);
static_assert(!__closure_has_simple_call_op<decltype(views::transform(std::declval<F>()))>);
+#endif
}
// { dg-prune-output "in requirements" }
reply other threads:[~2022-10-03 14:45 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221003144556.EB2533854838@sourceware.org \
--to=redi@gcc.gnu.org \
--cc=gcc-cvs@gcc.gnu.org \
--cc=libstdc++-cvs@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).