From ebaf3659632c0d5f45ca86593562c6c8367fda67 Mon Sep 17 00:00:00 2001 From: Jonathan Wakely Date: Mon, 3 Jun 2019 14:22:59 +0100 Subject: [PATCH] Enforce allocator::value_type consistency for containers in C++2a In previous standards it is undefined for a container and its allocator to have a different value_type. Libstdc++ has traditionally allowed it as an extension, automatically rebinding the allocator to the container's value_type. Since GCC 8.1 that extension has been disabled for C++11 and later when __STRICT_ANSI__ is defined (i.e. for -std=c++11, -std=c++14, -std=c++17 and -std=c++2a). Since the acceptance of P1463R1 into the C++2a draft an incorrect allocator::value_type now requires a diagnostic. This patch implements that by enabling the static_assert for -std=gnu++2a as well. * doc/xml/manual/status_cxx2020.xml: Document P1463R1 status. * include/bits/forward_list.h [__cplusplus > 201703]: Enable allocator::value_type assertion for C++2a. * include/bits/hashtable.h: Likewise. * include/bits/stl_deque.h: Likewise. * include/bits/stl_list.h: Likewise. * include/bits/stl_map.h: Likewise. * include/bits/stl_multimap.h: Likewise. * include/bits/stl_multiset.h: Likewise. * include/bits/stl_set.h: Likewise. * include/bits/stl_vector.h: Likewise. * testsuite/23_containers/deque/48101-3_neg.cc: New test. * testsuite/23_containers/forward_list/48101-3_neg.cc: New test. * testsuite/23_containers/list/48101-3_neg.cc: New test. * testsuite/23_containers/map/48101-3_neg.cc: New test. * testsuite/23_containers/multimap/48101-3_neg.cc: New test. * testsuite/23_containers/multiset/48101-3_neg.cc: New test. * testsuite/23_containers/set/48101-3_neg.cc: New test. * testsuite/23_containers/unordered_map/48101-3_neg.cc: New test. * testsuite/23_containers/unordered_multimap/48101-3_neg.cc: New test. * testsuite/23_containers/unordered_multiset/48101-3_neg.cc: New test. * testsuite/23_containers/unordered_set/48101-3_neg.cc: New test. * testsuite/23_containers/vector/48101-3_neg.cc: New test. From-SVN: r271866 --- libstdc++-v3/ChangeLog | 26 ++++++++++++++++ .../doc/xml/manual/status_cxx2020.xml | 15 ++++++++++ libstdc++-v3/include/bits/forward_list.h | 2 +- libstdc++-v3/include/bits/hashtable.h | 2 +- libstdc++-v3/include/bits/stl_deque.h | 2 +- libstdc++-v3/include/bits/stl_list.h | 2 +- libstdc++-v3/include/bits/stl_map.h | 2 +- libstdc++-v3/include/bits/stl_multimap.h | 2 +- libstdc++-v3/include/bits/stl_multiset.h | 2 +- libstdc++-v3/include/bits/stl_set.h | 2 +- libstdc++-v3/include/bits/stl_vector.h | 2 +- .../23_containers/deque/48101-3_neg.cc | 29 ++++++++++++++++++ .../23_containers/forward_list/48101-3_neg.cc | 29 ++++++++++++++++++ .../23_containers/list/48101-3_neg.cc | 29 ++++++++++++++++++ .../23_containers/map/48101-3_neg.cc | 29 ++++++++++++++++++ .../23_containers/multimap/48101-3_neg.cc | 29 ++++++++++++++++++ .../23_containers/multiset/48101-3_neg.cc | 29 ++++++++++++++++++ .../23_containers/set/48101-3_neg.cc | 29 ++++++++++++++++++ .../unordered_map/48101-3_neg.cc | 30 +++++++++++++++++++ .../unordered_multimap/48101-3_neg.cc | 30 +++++++++++++++++++ .../unordered_multiset/48101-3_neg.cc | 30 +++++++++++++++++++ .../unordered_set/48101-3_neg.cc | 30 +++++++++++++++++++ .../23_containers/vector/48101-3_neg.cc | 29 ++++++++++++++++++ 23 files changed, 402 insertions(+), 9 deletions(-) create mode 100644 libstdc++-v3/testsuite/23_containers/deque/48101-3_neg.cc create mode 100644 libstdc++-v3/testsuite/23_containers/forward_list/48101-3_neg.cc create mode 100644 libstdc++-v3/testsuite/23_containers/list/48101-3_neg.cc create mode 100644 libstdc++-v3/testsuite/23_containers/map/48101-3_neg.cc create mode 100644 libstdc++-v3/testsuite/23_containers/multimap/48101-3_neg.cc create mode 100644 libstdc++-v3/testsuite/23_containers/multiset/48101-3_neg.cc create mode 100644 libstdc++-v3/testsuite/23_containers/set/48101-3_neg.cc create mode 100644 libstdc++-v3/testsuite/23_containers/unordered_map/48101-3_neg.cc create mode 100644 libstdc++-v3/testsuite/23_containers/unordered_multimap/48101-3_neg.cc create mode 100644 libstdc++-v3/testsuite/23_containers/unordered_multiset/48101-3_neg.cc create mode 100644 libstdc++-v3/testsuite/23_containers/unordered_set/48101-3_neg.cc create mode 100644 libstdc++-v3/testsuite/23_containers/vector/48101-3_neg.cc diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index ed1d676ab54..2fca1a36abf 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,29 @@ +2019-06-03 Jonathan Wakely + + * doc/xml/manual/status_cxx2020.xml: Document P1463R1 status. + * include/bits/forward_list.h [__cplusplus > 201703]: Enable + allocator::value_type assertion for C++2a. + * include/bits/hashtable.h: Likewise. + * include/bits/stl_deque.h: Likewise. + * include/bits/stl_list.h: Likewise. + * include/bits/stl_map.h: Likewise. + * include/bits/stl_multimap.h: Likewise. + * include/bits/stl_multiset.h: Likewise. + * include/bits/stl_set.h: Likewise. + * include/bits/stl_vector.h: Likewise. + * testsuite/23_containers/deque/48101-3_neg.cc: New test. + * testsuite/23_containers/forward_list/48101-3_neg.cc: New test. + * testsuite/23_containers/list/48101-3_neg.cc: New test. + * testsuite/23_containers/map/48101-3_neg.cc: New test. + * testsuite/23_containers/multimap/48101-3_neg.cc: New test. + * testsuite/23_containers/multiset/48101-3_neg.cc: New test. + * testsuite/23_containers/set/48101-3_neg.cc: New test. + * testsuite/23_containers/unordered_map/48101-3_neg.cc: New test. + * testsuite/23_containers/unordered_multimap/48101-3_neg.cc: New test. + * testsuite/23_containers/unordered_multiset/48101-3_neg.cc: New test. + * testsuite/23_containers/unordered_set/48101-3_neg.cc: New test. + * testsuite/23_containers/vector/48101-3_neg.cc: New test. + 2019-05-31 Gerald Pfeifer * doc/xml/manual/allocator.xml: Move hoard.org back to http. diff --git a/libstdc++-v3/doc/xml/manual/status_cxx2020.xml b/libstdc++-v3/doc/xml/manual/status_cxx2020.xml index 8a17747e3bd..4b0336931f4 100644 --- a/libstdc++-v3/doc/xml/manual/status_cxx2020.xml +++ b/libstdc++-v3/doc/xml/manual/status_cxx2020.xml @@ -951,6 +951,21 @@ Feature-testing recommendations for C++. 9.1 + + + + Mandating the Standard Library: + Clause 21 - Containers library + + + + P1463R1 + + + 10 + + + diff --git a/libstdc++-v3/include/bits/forward_list.h b/libstdc++-v3/include/bits/forward_list.h index 4c277845a51..e686283a432 100644 --- a/libstdc++-v3/include/bits/forward_list.h +++ b/libstdc++-v3/include/bits/forward_list.h @@ -421,7 +421,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER { static_assert(is_same::type, _Tp>::value, "std::forward_list must have a non-const, non-volatile value_type"); -#ifdef __STRICT_ANSI__ +#if __cplusplus > 201703L || defined __STRICT_ANSI__ static_assert(is_same::value, "std::forward_list must have the same value_type as its allocator"); #endif diff --git a/libstdc++-v3/include/bits/hashtable.h b/libstdc++-v3/include/bits/hashtable.h index ab24b5bb537..384e39877f2 100644 --- a/libstdc++-v3/include/bits/hashtable.h +++ b/libstdc++-v3/include/bits/hashtable.h @@ -188,7 +188,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { static_assert(is_same::type, _Value>::value, "unordered container must have a non-const, non-volatile value_type"); -#ifdef __STRICT_ANSI__ +#if __cplusplus > 201703L || defined __STRICT_ANSI__ static_assert(is_same{}, "unordered container must have the same value_type as its allocator"); #endif diff --git a/libstdc++-v3/include/bits/stl_deque.h b/libstdc++-v3/include/bits/stl_deque.h index 7dcb53823c4..ac76d681ff0 100644 --- a/libstdc++-v3/include/bits/stl_deque.h +++ b/libstdc++-v3/include/bits/stl_deque.h @@ -824,7 +824,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER #if __cplusplus >= 201103L static_assert(is_same::type, _Tp>::value, "std::deque must have a non-const, non-volatile value_type"); -# ifdef __STRICT_ANSI__ +# if __cplusplus > 201703L || defined __STRICT_ANSI__ static_assert(is_same::value, "std::deque must have the same value_type as its allocator"); # endif diff --git a/libstdc++-v3/include/bits/stl_list.h b/libstdc++-v3/include/bits/stl_list.h index 68bab94af1e..701982538df 100644 --- a/libstdc++-v3/include/bits/stl_list.h +++ b/libstdc++-v3/include/bits/stl_list.h @@ -563,7 +563,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 #if __cplusplus >= 201103L static_assert(is_same::type, _Tp>::value, "std::list must have a non-const, non-volatile value_type"); -# ifdef __STRICT_ANSI__ +# if __cplusplus > 201703L || defined __STRICT_ANSI__ static_assert(is_same::value, "std::list must have the same value_type as its allocator"); # endif diff --git a/libstdc++-v3/include/bits/stl_map.h b/libstdc++-v3/include/bits/stl_map.h index 322d0a8290a..b1083d572d6 100644 --- a/libstdc++-v3/include/bits/stl_map.h +++ b/libstdc++-v3/include/bits/stl_map.h @@ -118,7 +118,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER __glibcxx_class_requires2(value_type, _Alloc_value_type, _SameTypeConcept) #endif -#if __cplusplus >= 201103L && defined(__STRICT_ANSI__) +#if __cplusplus > 201703L || defined __STRICT_ANSI__ static_assert(is_same::value, "std::map must have the same value_type as its allocator"); #endif diff --git a/libstdc++-v3/include/bits/stl_multimap.h b/libstdc++-v3/include/bits/stl_multimap.h index 4c4ccad3ac0..bb4aece96bf 100644 --- a/libstdc++-v3/include/bits/stl_multimap.h +++ b/libstdc++-v3/include/bits/stl_multimap.h @@ -117,7 +117,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER __glibcxx_class_requires2(value_type, _Alloc_value_type, _SameTypeConcept) #endif -#if __cplusplus >= 201103L && defined(__STRICT_ANSI__) +#if __cplusplus > 201703L || defined __STRICT_ANSI__ static_assert(is_same::value, "std::multimap must have the same value_type as its allocator"); #endif diff --git a/libstdc++-v3/include/bits/stl_multiset.h b/libstdc++-v3/include/bits/stl_multiset.h index af733ea34dc..96fa14e2afa 100644 --- a/libstdc++-v3/include/bits/stl_multiset.h +++ b/libstdc++-v3/include/bits/stl_multiset.h @@ -109,7 +109,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER #if __cplusplus >= 201103L static_assert(is_same::type, _Key>::value, "std::multiset must have a non-const, non-volatile value_type"); -# ifdef __STRICT_ANSI__ +# if __cplusplus > 201703L || defined __STRICT_ANSI__ static_assert(is_same::value, "std::multiset must have the same value_type as its allocator"); # endif diff --git a/libstdc++-v3/include/bits/stl_set.h b/libstdc++-v3/include/bits/stl_set.h index 3131a7974b0..279b9705d78 100644 --- a/libstdc++-v3/include/bits/stl_set.h +++ b/libstdc++-v3/include/bits/stl_set.h @@ -107,7 +107,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER #if __cplusplus >= 201103L static_assert(is_same::type, _Key>::value, "std::set must have a non-const, non-volatile value_type"); -# ifdef __STRICT_ANSI__ +# if __cplusplus > 201703L || defined __STRICT_ANSI__ static_assert(is_same::value, "std::set must have the same value_type as its allocator"); # endif diff --git a/libstdc++-v3/include/bits/stl_vector.h b/libstdc++-v3/include/bits/stl_vector.h index dd9382d254d..d33e589498a 100644 --- a/libstdc++-v3/include/bits/stl_vector.h +++ b/libstdc++-v3/include/bits/stl_vector.h @@ -397,7 +397,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER #if __cplusplus >= 201103L static_assert(is_same::type, _Tp>::value, "std::vector must have a non-const, non-volatile value_type"); -# ifdef __STRICT_ANSI__ +# if __cplusplus > 201703L || defined __STRICT_ANSI__ static_assert(is_same::value, "std::vector must have the same value_type as its allocator"); # endif diff --git a/libstdc++-v3/testsuite/23_containers/deque/48101-3_neg.cc b/libstdc++-v3/testsuite/23_containers/deque/48101-3_neg.cc new file mode 100644 index 00000000000..724b3de6a03 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/deque/48101-3_neg.cc @@ -0,0 +1,29 @@ +// Copyright (C) 2017-2019 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 +// . + +// { dg-options "-std=gnu++2a" } +// { dg-do compile { target c++2a } } + +#include + +void +test01() +{ + std::deque> c; +} + +// { dg-error "same value_type as its allocator" "" { target *-*-* } 0 } diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/48101-3_neg.cc b/libstdc++-v3/testsuite/23_containers/forward_list/48101-3_neg.cc new file mode 100644 index 00000000000..d0e56f59494 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/forward_list/48101-3_neg.cc @@ -0,0 +1,29 @@ +// Copyright (C) 2017-2019 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 +// . + +// { dg-options "-std=gnu++2a" } +// { dg-do compile { target c++2a } } + +#include + +void +test01() +{ + std::forward_list> c; +} + +// { dg-error "same value_type as its allocator" "" { target *-*-* } 0 } diff --git a/libstdc++-v3/testsuite/23_containers/list/48101-3_neg.cc b/libstdc++-v3/testsuite/23_containers/list/48101-3_neg.cc new file mode 100644 index 00000000000..ce32e9ced82 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/list/48101-3_neg.cc @@ -0,0 +1,29 @@ +// Copyright (C) 2017-2019 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 +// . + +// { dg-options "-std=gnu++2a" } +// { dg-do compile { target c++2a } } + +#include + +void +test01() +{ + std::list> c; +} + +// { dg-error "same value_type as its allocator" "" { target *-*-* } 0 } diff --git a/libstdc++-v3/testsuite/23_containers/map/48101-3_neg.cc b/libstdc++-v3/testsuite/23_containers/map/48101-3_neg.cc new file mode 100644 index 00000000000..dfce9c2179c --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/map/48101-3_neg.cc @@ -0,0 +1,29 @@ +// Copyright (C) 2017-2019 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 +// . + +// { dg-options "-std=gnu++2a" } +// { dg-do compile { target c++2a } } + +#include + +void +test01() +{ + std::map, std::allocator> c; +} + +// { dg-error "same value_type as its allocator" "" { target *-*-* } 0 } diff --git a/libstdc++-v3/testsuite/23_containers/multimap/48101-3_neg.cc b/libstdc++-v3/testsuite/23_containers/multimap/48101-3_neg.cc new file mode 100644 index 00000000000..77769498548 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/multimap/48101-3_neg.cc @@ -0,0 +1,29 @@ +// Copyright (C) 2017-2019 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 +// . + +// { dg-options "-std=gnu++2a" } +// { dg-do compile { target c++2a } } + +#include + +void +test01() +{ + std::multimap, std::allocator> c; +} + +// { dg-error "same value_type as its allocator" "" { target *-*-* } 0 } diff --git a/libstdc++-v3/testsuite/23_containers/multiset/48101-3_neg.cc b/libstdc++-v3/testsuite/23_containers/multiset/48101-3_neg.cc new file mode 100644 index 00000000000..209a1d5deeb --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/multiset/48101-3_neg.cc @@ -0,0 +1,29 @@ +// Copyright (C) 2017-2019 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 +// . + +// { dg-options "-std=gnu++2a" } +// { dg-do compile { target c++2a } } + +#include + +void +test01() +{ + std::multiset, std::allocator> c; +} + +// { dg-error "same value_type as its allocator" "" { target *-*-* } 0 } diff --git a/libstdc++-v3/testsuite/23_containers/set/48101-3_neg.cc b/libstdc++-v3/testsuite/23_containers/set/48101-3_neg.cc new file mode 100644 index 00000000000..75777370a3a --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/set/48101-3_neg.cc @@ -0,0 +1,29 @@ +// Copyright (C) 2017-2019 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 +// . + +// { dg-options "-std=gnu++2a" } +// { dg-do compile { target c++2a } } + +#include + +void +test01() +{ + std::set, std::allocator> c; +} + +// { dg-error "same value_type as its allocator" "" { target *-*-* } 0 } diff --git a/libstdc++-v3/testsuite/23_containers/unordered_map/48101-3_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_map/48101-3_neg.cc new file mode 100644 index 00000000000..98bcd8c755b --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/unordered_map/48101-3_neg.cc @@ -0,0 +1,30 @@ +// Copyright (C) 2017-2019 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 +// . + +// { dg-options "-std=gnu++2a" } +// { dg-do compile { target c++2a } } + +#include + +void +test01() +{ + using namespace std; + unordered_map, equal_to, allocator> c; +} + +// { dg-error "same value_type as its allocator" "" { target *-*-* } 0 } diff --git a/libstdc++-v3/testsuite/23_containers/unordered_multimap/48101-3_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_multimap/48101-3_neg.cc new file mode 100644 index 00000000000..3bda27b8354 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/unordered_multimap/48101-3_neg.cc @@ -0,0 +1,30 @@ +// Copyright (C) 2017-2019 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 +// . + +// { dg-options "-std=gnu++2a" } +// { dg-do compile { target c++2a } } + +#include + +void +test01() +{ + using namespace std; + unordered_multimap, equal_to, allocator> c; +} + +// { dg-error "same value_type as its allocator" "" { target *-*-* } 0 } diff --git a/libstdc++-v3/testsuite/23_containers/unordered_multiset/48101-3_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_multiset/48101-3_neg.cc new file mode 100644 index 00000000000..620c9b703bd --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/unordered_multiset/48101-3_neg.cc @@ -0,0 +1,30 @@ +// Copyright (C) 2017-2019 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 +// . + +// { dg-options "-std=gnu++2a" } +// { dg-do compile { target c++2a } } + +#include + +void +test01() +{ + using namespace std; + unordered_multiset, equal_to, allocator> c; +} + +// { dg-error "same value_type as its allocator" "" { target *-*-* } 0 } diff --git a/libstdc++-v3/testsuite/23_containers/unordered_set/48101-3_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_set/48101-3_neg.cc new file mode 100644 index 00000000000..c226c5236f8 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/unordered_set/48101-3_neg.cc @@ -0,0 +1,30 @@ +// Copyright (C) 2017-2019 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 +// . + +// { dg-options "-std=gnu++2a" } +// { dg-do compile { target c++2a } } + +#include + +void +test01() +{ + using namespace std; + unordered_set, equal_to, allocator> c; +} + +// { dg-error "same value_type as its allocator" "" { target *-*-* } 0 } diff --git a/libstdc++-v3/testsuite/23_containers/vector/48101-3_neg.cc b/libstdc++-v3/testsuite/23_containers/vector/48101-3_neg.cc new file mode 100644 index 00000000000..2317efa1516 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/vector/48101-3_neg.cc @@ -0,0 +1,29 @@ +// Copyright (C) 2017-2019 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 +// . + +// { dg-options "-std=gnu++2a" } +// { dg-do compile { target c++2a } } + +#include + +void +test01() +{ + std::vector> c; +} + +// { dg-error "same value_type as its allocator" "" { target *-*-* } 0 } -- 2.30.2