From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2181) id 5C4773858D28; Tue, 23 Nov 2021 21:29:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5C4773858D28 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Jonathan Wakely To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc r12-5481] libstdc++: Add effective-target for std::allocator implementation X-Act-Checkin: gcc X-Git-Author: Jonathan Wakely X-Git-Refname: refs/heads/master X-Git-Oldrev: 16e95050f71e9fa408e9bd8ccd415b0e7adc66e5 X-Git-Newrev: 39de0e541107bc4b0b3b82f613054f59c6821eb5 Message-Id: <20211123212948.5C4773858D28@sourceware.org> Date: Tue, 23 Nov 2021 21:29:48 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 23 Nov 2021 21:29:48 -0000 https://gcc.gnu.org/g:39de0e541107bc4b0b3b82f613054f59c6821eb5 commit r12-5481-g39de0e541107bc4b0b3b82f613054f59c6821eb5 Author: Jonathan Wakely Date: Mon Nov 22 14:51:16 2021 +0000 libstdc++: Add effective-target for std::allocator implementation 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. Diff: --- libstdc++-v3/testsuite/18_support/50594.cc | 1 + libstdc++-v3/testsuite/20_util/allocator/1.cc | 7 +++---- libstdc++-v3/testsuite/20_util/allocator/overaligned.cc | 2 +- libstdc++-v3/testsuite/23_containers/unordered_map/96088.cc | 1 + libstdc++-v3/testsuite/23_containers/unordered_multimap/96088.cc | 1 + libstdc++-v3/testsuite/23_containers/unordered_multiset/96088.cc | 1 + libstdc++-v3/testsuite/23_containers/unordered_set/96088.cc | 1 + libstdc++-v3/testsuite/ext/throw_allocator/check_delete.cc | 1 + libstdc++-v3/testsuite/ext/throw_allocator/check_new.cc | 1 + libstdc++-v3/testsuite/lib/libstdc++.exp | 8 ++++++++ 10 files changed, 19 insertions(+), 5 deletions(-) diff --git a/libstdc++-v3/testsuite/18_support/50594.cc b/libstdc++-v3/testsuite/18_support/50594.cc index a18e8278081..c15e704debe 100644 --- a/libstdc++-v3/testsuite/18_support/50594.cc +++ b/libstdc++-v3/testsuite/18_support/50594.cc @@ -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. diff --git a/libstdc++-v3/testsuite/20_util/allocator/1.cc b/libstdc++-v3/testsuite/20_util/allocator/1.cc index ebcd6c28c5f..79e223c13c2 100644 --- a/libstdc++-v3/testsuite/20_util/allocator/1.cc +++ b/libstdc++-v3/testsuite/20_util/allocator/1.cc @@ -17,6 +17,8 @@ // with this library; see the file COPYING3. If not see // . +// { dg-require-effective-target std_allocator_new } + // 20.4.1.1 allocator members #include @@ -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 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 ); diff --git a/libstdc++-v3/testsuite/20_util/allocator/overaligned.cc b/libstdc++-v3/testsuite/20_util/allocator/overaligned.cc index fd03d62b238..8c90fcc0e92 100644 --- a/libstdc++-v3/testsuite/20_util/allocator/overaligned.cc +++ b/libstdc++-v3/testsuite/20_util/allocator/overaligned.cc @@ -16,7 +16,7 @@ // . // { 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 diff --git a/libstdc++-v3/testsuite/23_containers/unordered_map/96088.cc b/libstdc++-v3/testsuite/23_containers/unordered_map/96088.cc index 83ca1c0afd6..27c499ed348 100644 --- a/libstdc++-v3/testsuite/23_containers/unordered_map/96088.cc +++ b/libstdc++-v3/testsuite/23_containers/unordered_map/96088.cc @@ -1,4 +1,5 @@ // { dg-do run { target c++17 } } +// { dg-require-effective-target std_allocator_new } // Copyright (C) 2021 Free Software Foundation, Inc. // diff --git a/libstdc++-v3/testsuite/23_containers/unordered_multimap/96088.cc b/libstdc++-v3/testsuite/23_containers/unordered_multimap/96088.cc index de7f009dadc..eaadd08e7ca 100644 --- a/libstdc++-v3/testsuite/23_containers/unordered_multimap/96088.cc +++ b/libstdc++-v3/testsuite/23_containers/unordered_multimap/96088.cc @@ -1,4 +1,5 @@ // { dg-do run { target c++17 } } +// { dg-require-effective-target std_allocator_new } // Copyright (C) 2021 Free Software Foundation, Inc. // diff --git a/libstdc++-v3/testsuite/23_containers/unordered_multiset/96088.cc b/libstdc++-v3/testsuite/23_containers/unordered_multiset/96088.cc index b9bbf63b863..aa137ec9302 100644 --- a/libstdc++-v3/testsuite/23_containers/unordered_multiset/96088.cc +++ b/libstdc++-v3/testsuite/23_containers/unordered_multiset/96088.cc @@ -1,4 +1,5 @@ // { dg-do run { target c++17 } } +// { dg-require-effective-target std_allocator_new } // Copyright (C) 2021 Free Software Foundation, Inc. // diff --git a/libstdc++-v3/testsuite/23_containers/unordered_set/96088.cc b/libstdc++-v3/testsuite/23_containers/unordered_set/96088.cc index 83d5475c677..3f0835ce501 100644 --- a/libstdc++-v3/testsuite/23_containers/unordered_set/96088.cc +++ b/libstdc++-v3/testsuite/23_containers/unordered_set/96088.cc @@ -1,4 +1,5 @@ // { dg-do run { target c++17 } } +// { dg-require-effective-target std_allocator_new } // Copyright (C) 2021 Free Software Foundation, Inc. // diff --git a/libstdc++-v3/testsuite/ext/throw_allocator/check_delete.cc b/libstdc++-v3/testsuite/ext/throw_allocator/check_delete.cc index f5bc652c9dc..10e5c69edca 100644 --- a/libstdc++-v3/testsuite/ext/throw_allocator/check_delete.cc +++ b/libstdc++-v3/testsuite/ext/throw_allocator/check_delete.cc @@ -18,6 +18,7 @@ // { dg-require-time "" } // { dg-require-cstdint "" } +// { dg-require-effective-target std_allocator_new } #include #include diff --git a/libstdc++-v3/testsuite/ext/throw_allocator/check_new.cc b/libstdc++-v3/testsuite/ext/throw_allocator/check_new.cc index a4e3874d841..4e2a7250e32 100644 --- a/libstdc++-v3/testsuite/ext/throw_allocator/check_new.cc +++ b/libstdc++-v3/testsuite/ext/throw_allocator/check_new.cc @@ -18,6 +18,7 @@ // { dg-require-time "" } // { dg-require-cstdint "" } +// { dg-require-effective-target std_allocator_new } #include #include diff --git a/libstdc++-v3/testsuite/lib/libstdc++.exp b/libstdc++-v3/testsuite/lib/libstdc++.exp index 35ccbe47c39..4f4c78bed24 100644 --- a/libstdc++-v3/testsuite/lib/libstdc++.exp +++ b/libstdc++-v3/testsuite/lib/libstdc++.exp @@ -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)] \