]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++: Add effective-target for std::allocator implementation
authorJonathan Wakely <jwakely@redhat.com>
Mon, 22 Nov 2021 14:51:16 +0000 (14:51 +0000)
committerJonathan Wakely <jwakely@redhat.com>
Tue, 23 Nov 2021 21:23:24 +0000 (21:23 +0000)
This allows tests to be skipped if the std::allocator implementation is
not __gnu_cxx::new_allocator.

The 20_util/allocator/overaligned.cc test requires either C++17 or
new_allocator, otherwise we can't guarantee to return overaligned
memory.

libstdc++-v3/ChangeLog:

* testsuite/18_support/50594.cc: Check effective target.
* testsuite/20_util/allocator/1.cc: Likewise.
* testsuite/20_util/allocator/overaligned.cc: Likewise.
* testsuite/23_containers/unordered_map/96088.cc: Likewise.
* testsuite/23_containers/unordered_multimap/96088.cc: Likewise.
* testsuite/23_containers/unordered_multiset/96088.cc: Likewise.
* testsuite/23_containers/unordered_set/96088.cc: Likewise.
* testsuite/ext/throw_allocator/check_delete.cc: Likewise.
* testsuite/ext/throw_allocator/check_new.cc: Likewise.
* testsuite/lib/libstdc++.exp (check_effective_target_std_allocator_new):
Define new proc.

libstdc++-v3/testsuite/18_support/50594.cc
libstdc++-v3/testsuite/20_util/allocator/1.cc
libstdc++-v3/testsuite/20_util/allocator/overaligned.cc
libstdc++-v3/testsuite/23_containers/unordered_map/96088.cc
libstdc++-v3/testsuite/23_containers/unordered_multimap/96088.cc
libstdc++-v3/testsuite/23_containers/unordered_multiset/96088.cc
libstdc++-v3/testsuite/23_containers/unordered_set/96088.cc
libstdc++-v3/testsuite/ext/throw_allocator/check_delete.cc
libstdc++-v3/testsuite/ext/throw_allocator/check_new.cc
libstdc++-v3/testsuite/lib/libstdc++.exp

index a18e8278081033fe6e9a4737df03ea59681ac75c..c15e704debe1a6e1f780d42b1fb9e9590ffba050 100644 (file)
@@ -1,5 +1,6 @@
 // { dg-options "-fwhole-program" }
 // { dg-additional-options "-static-libstdc++" { target *-*-mingw* } }
+// { dg-require-effective-target std_allocator_new }
 // { dg-xfail-run-if "AIX operator new" { powerpc-ibm-aix* } }
 
 // Copyright (C) 2011-2021 Free Software Foundation, Inc.
index ebcd6c28c5f5f024a37019b048dcb42b8b4c031b..79e223c13c2bb31c432987ea21c51906637f8e0e 100644 (file)
@@ -17,6 +17,8 @@
 // with this library; see the file COPYING3.  If not see
 // <http://www.gnu.org/licenses/>.
 
+// { dg-require-effective-target std_allocator_new }
+
 // 20.4.1.1 allocator members
 
 #include <memory>
@@ -35,7 +37,7 @@ struct gnu { };
 bool check_new = false;
 bool check_delete = false;
 
-void* 
+void*
 operator new(std::size_t n) THROW(std::bad_alloc)
 {
   check_new = true;
@@ -59,9 +61,6 @@ void test01()
 {
   std::allocator<gnu> obj;
 
-  // NB: These should work for various size allocation and
-  // deallocations.  Currently, they only work as expected for sizes >
-  // _MAX_BYTES as defined in stl_alloc.h, which happes to be 128. 
   gnu* pobj = obj.allocate(256);
   VERIFY( check_new );
 
index fd03d62b23840bfc537c0a99c5d538aed358c77f..8c90fcc0e92cbfe5e7661fef474cef9865a603eb 100644 (file)
@@ -16,7 +16,7 @@
 // <http://www.gnu.org/licenses/>.
 
 // { dg-options "-faligned-new" }
-// { dg-do run { target c++11 } }
+// { dg-do run { target { c++11 && { c++17 || std_allocator_new } } } }
 // { dg-require-cstdint "" }
 
 #include <memory>
index 83ca1c0afd66baba4c84869825ce8af67b51b475..27c499ed34820bb9a4d8dd01c617c328e249caf4 100644 (file)
@@ -1,4 +1,5 @@
 // { dg-do run { target c++17 } }
+// { dg-require-effective-target std_allocator_new }
 
 // Copyright (C) 2021 Free Software Foundation, Inc.
 //
index de7f009dadc1840a3353845170814326522f5c6f..eaadd08e7cab31c9856282638898aeab916f579c 100644 (file)
@@ -1,4 +1,5 @@
 // { dg-do run { target c++17 } }
+// { dg-require-effective-target std_allocator_new }
 
 // Copyright (C) 2021 Free Software Foundation, Inc.
 //
index b9bbf63b8630141703aa184794f56de8bd18dae1..aa137ec930207c610878a74d1d71c4f46eee17ac 100644 (file)
@@ -1,4 +1,5 @@
 // { dg-do run { target c++17 } }
+// { dg-require-effective-target std_allocator_new }
 
 // Copyright (C) 2021 Free Software Foundation, Inc.
 //
index 83d5475c6779fe542c98ceda78d246f9589cad2a..3f0835ce501321548ee17a016c9e4dcacf84836f 100644 (file)
@@ -1,4 +1,5 @@
 // { dg-do run { target c++17 } }
+// { dg-require-effective-target std_allocator_new }
 
 // Copyright (C) 2021 Free Software Foundation, Inc.
 //
index f5bc652c9dc76c6c88b35ce0994aad8d6ec9bc22..10e5c69edca34af3ed1b35121c8bb379d45557ec 100644 (file)
@@ -18,6 +18,7 @@
 
 // { dg-require-time "" }
 // { dg-require-cstdint "" }
+// { dg-require-effective-target std_allocator_new }
 
 #include <cstdlib>
 #include <ext/throw_allocator.h>
index a4e3874d8411b10cecebf1862e833b7a60ee9b76..4e2a7250e32f1cf685db53bb90ccc28f267c817d 100644 (file)
@@ -18,6 +18,7 @@
 
 // { dg-require-time "" }
 // { dg-require-cstdint "" }
+// { dg-require-effective-target std_allocator_new }
 
 #include <cstdlib>
 #include <ext/throw_allocator.h>
index 35ccbe47c3947cc3e272602cfb4379296a296e8c..4f4c78bed24984f736f0c5750ca46cb82bb9dcb1 100644 (file)
@@ -1338,6 +1338,14 @@ proc check_effective_target_net_ts_ip { } {
     }]
 }
 
+# Return 1 if libstdc++ was built as --enable-libstdcxx-allocator=new
+proc check_effective_target_std_allocator_new { } {
+    return [check_v3_target_prop_cached et_std_alloc_new {
+       set cond "_GLIBCXX_USE_ALLOCATOR_NEW"
+       return [v3_check_preprocessor_condition std_alloc_new $cond]
+    }]
+}
+
 set additional_prunes ""
 
 if { [info exists env(GCC_RUNTEST_PARALLELIZE_DIR)] \