[libcxx-commits] [libcxx] ce32e05 - [libc++] Refactor allocator_mismatch.compile.fail.cpp -> .verify.cpp
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Feb 28 09:23:13 PST 2023
Author: Arthur O'Dwyer
Date: 2023-02-28T12:22:49-05:00
New Revision: ce32e057333e410f75a2292772fa2cd67bdb3614
URL: https://github.com/llvm/llvm-project/commit/ce32e057333e410f75a2292772fa2cd67bdb3614
DIFF: https://github.com/llvm/llvm-project/commit/ce32e057333e410f75a2292772fa2cd67bdb3614.diff
LOG: [libc++] Refactor allocator_mismatch.compile.fail.cpp -> .verify.cpp
compile.fail.cpp tests are an anti-feature since they are too easy to
break when evolving code. This patch moves various allocator_mismatch
tests to .verify.cpp and normalizes the error messages from various
containers.
Differential Revision: https://reviews.llvm.org/D144913
Added:
libcxx/test/std/containers/associative/map/allocator_mismatch.verify.cpp
libcxx/test/std/containers/associative/multimap/allocator_mismatch.verify.cpp
libcxx/test/std/containers/associative/multiset/allocator_mismatch.verify.cpp
libcxx/test/std/containers/associative/set/allocator_mismatch.verify.cpp
libcxx/test/std/containers/sequences/deque/allocator_mismatch.verify.cpp
libcxx/test/std/containers/sequences/forwardlist/allocator_mismatch.verify.cpp
libcxx/test/std/containers/sequences/list/allocator_mismatch.verify.cpp
libcxx/test/std/containers/sequences/vector/allocator_mismatch.verify.cpp
libcxx/test/std/containers/unord/unord.map/allocator_mismatch.verify.cpp
libcxx/test/std/containers/unord/unord.multimap/allocator_mismatch.verify.cpp
libcxx/test/std/containers/unord/unord.multiset/allocator_mismatch.verify.cpp
libcxx/test/std/containers/unord/unord.set/allocator_mismatch.verify.cpp
Modified:
libcxx/include/forward_list
libcxx/include/list
libcxx/include/unordered_map
libcxx/include/unordered_set
libcxx/test/std/containers/associative/set/range_concept_conformance.compile.pass.cpp
Removed:
libcxx/test/std/containers/associative/map/allocator_mismatch.compile.fail.cpp
libcxx/test/std/containers/associative/multimap/allocator_mismatch.compile.fail.cpp
libcxx/test/std/containers/associative/multiset/allocator_mismatch.compile.fail.cpp
libcxx/test/std/containers/associative/set/allocator_mismatch.compile.fail.cpp
libcxx/test/std/containers/sequences/deque/allocator_mismatch.compile.fail.cpp
libcxx/test/std/containers/sequences/forwardlist/allocator_mismatch.compile.fail.cpp
libcxx/test/std/containers/sequences/list/allocator_mismatch.compile.fail.cpp
libcxx/test/std/containers/sequences/vector/allocator_mismatch.compile.fail.cpp
libcxx/test/std/containers/unord/unord.map/allocator_mismatch.compile.fail.cpp
libcxx/test/std/containers/unord/unord.multimap/allocator_mismatch.compile.fail.cpp
libcxx/test/std/containers/unord/unord.multiset/allocator_mismatch.compile.fail.cpp
libcxx/test/std/containers/unord/unord.set/allocator_mismatch.compile.fail.cpp
################################################################################
diff --git a/libcxx/include/forward_list b/libcxx/include/forward_list
index 43519b5fa51f0..927637655950a 100644
--- a/libcxx/include/forward_list
+++ b/libcxx/include/forward_list
@@ -482,14 +482,6 @@ protected:
typedef typename allocator_traits<__begin_node_allocator>::pointer
__begin_node_pointer;
- static_assert((!is_same<allocator_type, __node_allocator>::value),
- "internal allocator type must
diff er from user-specified "
- "type; otherwise overload resolution breaks");
-
- static_assert(is_same<allocator_type, __rebind_alloc<__node_traits, value_type> >::value,
- "[allocator.requirements] states that rebinding an allocator to the same type should result in the "
- "original allocator");
-
__compressed_pair<__begin_node, __node_allocator> __before_begin_;
_LIBCPP_INLINE_VISIBILITY
@@ -659,9 +651,17 @@ public:
typedef _Tp value_type;
typedef _Alloc allocator_type;
- static_assert((is_same<typename allocator_type::value_type, value_type>::value),
+ static_assert(is_same<value_type, typename allocator_type::value_type>::value,
"Allocator::value_type must be same type as value_type");
+ static_assert(is_same<allocator_type, __rebind_alloc<allocator_traits<allocator_type>, value_type> >::value,
+ "[allocator.requirements] states that rebinding an allocator to the same type should result in the "
+ "original allocator");
+
+ static_assert((!is_same<allocator_type, __node_allocator>::value),
+ "internal allocator type must
diff er from user-specified "
+ "type; otherwise overload resolution breaks");
+
typedef value_type& reference;
typedef const value_type& const_reference;
typedef typename allocator_traits<allocator_type>::pointer pointer;
diff --git a/libcxx/include/list b/libcxx/include/list
index c0fe2f93830f3..750ccf99d41fb 100644
--- a/libcxx/include/list
+++ b/libcxx/include/list
@@ -828,7 +828,7 @@ public:
typedef _Tp value_type;
typedef _Alloc allocator_type;
static_assert((is_same<value_type, typename allocator_type::value_type>::value),
- "Invalid allocator::value_type");
+ "Allocator::value_type must be same type as value_type");
typedef value_type& reference;
typedef const value_type& const_reference;
typedef typename base::pointer pointer;
diff --git a/libcxx/include/unordered_map b/libcxx/include/unordered_map
index af3cad3c584d3..251a581277cb4 100644
--- a/libcxx/include/unordered_map
+++ b/libcxx/include/unordered_map
@@ -1035,7 +1035,7 @@ public:
typedef value_type& reference;
typedef const value_type& const_reference;
static_assert((is_same<value_type, typename allocator_type::value_type>::value),
- "Invalid allocator::value_type");
+ "Allocator::value_type must be same type as value_type");
private:
typedef __hash_value_type<key_type, mapped_type> __value_type;
@@ -1928,7 +1928,7 @@ public:
typedef value_type& reference;
typedef const value_type& const_reference;
static_assert((is_same<value_type, typename allocator_type::value_type>::value),
- "Invalid allocator::value_type");
+ "Allocator::value_type must be same type as value_type");
private:
typedef __hash_value_type<key_type, mapped_type> __value_type;
diff --git a/libcxx/include/unordered_set b/libcxx/include/unordered_set
index 1c875a5689780..1fdaf96b64b34 100644
--- a/libcxx/include/unordered_set
+++ b/libcxx/include/unordered_set
@@ -513,7 +513,7 @@ public:
typedef value_type& reference;
typedef const value_type& const_reference;
static_assert((is_same<value_type, typename allocator_type::value_type>::value),
- "Invalid allocator::value_type");
+ "Allocator::value_type must be same type as value_type");
static_assert(is_same<allocator_type, __rebind_alloc<allocator_traits<allocator_type>, value_type> >::value,
"[allocator.requirements] states that rebinding an allocator to the same type should result in the "
@@ -1173,7 +1173,7 @@ public:
typedef value_type& reference;
typedef const value_type& const_reference;
static_assert((is_same<value_type, typename allocator_type::value_type>::value),
- "Invalid allocator::value_type");
+ "Allocator::value_type must be same type as value_type");
private:
typedef __hash_table<value_type, hasher, key_equal, allocator_type> __table;
diff --git a/libcxx/test/std/containers/associative/map/allocator_mismatch.compile.fail.cpp b/libcxx/test/std/containers/associative/map/allocator_mismatch.verify.cpp
similarity index 70%
rename from libcxx/test/std/containers/associative/map/allocator_mismatch.compile.fail.cpp
rename to libcxx/test/std/containers/associative/map/allocator_mismatch.verify.cpp
index faec5aa401e13..0a33f25280c99 100644
--- a/libcxx/test/std/containers/associative/map/allocator_mismatch.compile.fail.cpp
+++ b/libcxx/test/std/containers/associative/map/allocator_mismatch.verify.cpp
@@ -11,9 +11,5 @@
#include <map>
-int main(int, char**)
-{
- std::map<int, int, std::less<int>, std::allocator<long> > m;
-
- return 0;
-}
+std::map<int, int, std::less<int>, std::allocator<long> > m;
+ // expected-error-re@*:* {{{{(static_assert|static assertion)}} failed{{.*}}Allocator::value_type must be same type as value_type}}
diff --git a/libcxx/test/std/containers/associative/multimap/allocator_mismatch.compile.fail.cpp b/libcxx/test/std/containers/associative/multimap/allocator_mismatch.verify.cpp
similarity index 70%
rename from libcxx/test/std/containers/associative/multimap/allocator_mismatch.compile.fail.cpp
rename to libcxx/test/std/containers/associative/multimap/allocator_mismatch.verify.cpp
index 47dd64ebcaf5f..122d6569d0c94 100644
--- a/libcxx/test/std/containers/associative/multimap/allocator_mismatch.compile.fail.cpp
+++ b/libcxx/test/std/containers/associative/multimap/allocator_mismatch.verify.cpp
@@ -11,9 +11,5 @@
#include <map>
-int main(int, char**)
-{
- std::multimap<int, int, std::less<int>, std::allocator<long> > m;
-
- return 0;
-}
+std::multimap<int, int, std::less<int>, std::allocator<long> > m;
+ // expected-error-re@*:* {{{{(static_assert|static assertion)}} failed{{.*}}Allocator::value_type must be same type as value_type}}
diff --git a/libcxx/test/std/containers/associative/set/allocator_mismatch.compile.fail.cpp b/libcxx/test/std/containers/associative/multiset/allocator_mismatch.verify.cpp
similarity index 70%
rename from libcxx/test/std/containers/associative/set/allocator_mismatch.compile.fail.cpp
rename to libcxx/test/std/containers/associative/multiset/allocator_mismatch.verify.cpp
index 69e49351e200d..8d4526863d4b6 100644
--- a/libcxx/test/std/containers/associative/set/allocator_mismatch.compile.fail.cpp
+++ b/libcxx/test/std/containers/associative/multiset/allocator_mismatch.verify.cpp
@@ -11,9 +11,5 @@
#include <set>
-int main(int, char**)
-{
- std::set<int, std::less<int>, std::allocator<long> > s;
-
- return 0;
-}
+std::multiset<int, std::less<int>, std::allocator<long> > m;
+ // expected-error-re@*:* {{{{(static_assert|static assertion)}} failed{{.*}}Allocator::value_type must be same type as value_type}}
diff --git a/libcxx/test/std/containers/associative/multiset/allocator_mismatch.compile.fail.cpp b/libcxx/test/std/containers/associative/set/allocator_mismatch.verify.cpp
similarity index 71%
rename from libcxx/test/std/containers/associative/multiset/allocator_mismatch.compile.fail.cpp
rename to libcxx/test/std/containers/associative/set/allocator_mismatch.verify.cpp
index 86e1b307a3de7..eac40e04da53c 100644
--- a/libcxx/test/std/containers/associative/multiset/allocator_mismatch.compile.fail.cpp
+++ b/libcxx/test/std/containers/associative/set/allocator_mismatch.verify.cpp
@@ -11,9 +11,5 @@
#include <set>
-int main(int, char**)
-{
- std::multiset<int, std::less<int>, std::allocator<long> > ms;
-
- return 0;
-}
+std::set<int, std::less<int>, std::allocator<long> > m;
+ // expected-error-re@*:* {{{{(static_assert|static assertion)}} failed{{.*}}Allocator::value_type must be same type as value_type}}
diff --git a/libcxx/test/std/containers/associative/set/range_concept_conformance.compile.pass.cpp b/libcxx/test/std/containers/associative/set/range_concept_conformance.compile.pass.cpp
index 597abbd6bda48..16f4de96c776c 100644
--- a/libcxx/test/std/containers/associative/set/range_concept_conformance.compile.pass.cpp
+++ b/libcxx/test/std/containers/associative/set/range_concept_conformance.compile.pass.cpp
@@ -32,7 +32,7 @@ static_assert(std::same_as<std::ranges::iterator_t<range const>, range::const_it
static_assert(std::ranges::bidirectional_range<range const>);
static_assert(!std::ranges::random_access_range<range const>);
static_assert(std::ranges::common_range<range const>);
-static_assert(std::ranges::input_range<range>);
+static_assert(std::ranges::input_range<range const>);
static_assert(!std::ranges::view<range const>);
static_assert(std::ranges::sized_range<range const>);
static_assert(!std::ranges::borrowed_range<range const>);
diff --git a/libcxx/test/std/containers/sequences/deque/allocator_mismatch.compile.fail.cpp b/libcxx/test/std/containers/sequences/deque/allocator_mismatch.verify.cpp
similarity index 73%
rename from libcxx/test/std/containers/sequences/deque/allocator_mismatch.compile.fail.cpp
rename to libcxx/test/std/containers/sequences/deque/allocator_mismatch.verify.cpp
index 287faf75ec448..6e1310dcdea22 100644
--- a/libcxx/test/std/containers/sequences/deque/allocator_mismatch.compile.fail.cpp
+++ b/libcxx/test/std/containers/sequences/deque/allocator_mismatch.verify.cpp
@@ -11,9 +11,5 @@
#include <deque>
-int main(int, char**)
-{
- std::deque<int, std::allocator<long> > d;
-
- return 0;
-}
+std::deque<int, std::allocator<long> > d;
+ // expected-error-re@*:* {{{{(static_assert|static assertion)}} failed{{.*}}Allocator::value_type must be same type as value_type}}
diff --git a/libcxx/test/std/containers/sequences/forwardlist/allocator_mismatch.compile.fail.cpp b/libcxx/test/std/containers/sequences/forwardlist/allocator_mismatch.verify.cpp
similarity index 72%
rename from libcxx/test/std/containers/sequences/forwardlist/allocator_mismatch.compile.fail.cpp
rename to libcxx/test/std/containers/sequences/forwardlist/allocator_mismatch.verify.cpp
index 42fb8da918de3..617c006d9c054 100644
--- a/libcxx/test/std/containers/sequences/forwardlist/allocator_mismatch.compile.fail.cpp
+++ b/libcxx/test/std/containers/sequences/forwardlist/allocator_mismatch.verify.cpp
@@ -11,9 +11,5 @@
#include <forward_list>
-int main(int, char**)
-{
- std::forward_list<int, std::allocator<long> > fl;
-
- return 0;
-}
+std::forward_list<int, std::allocator<long> > fl;
+ // expected-error-re@*:* {{{{(static_assert|static assertion)}} failed{{.*}}Allocator::value_type must be same type as value_type}}
diff --git a/libcxx/test/std/containers/sequences/list/allocator_mismatch.compile.fail.cpp b/libcxx/test/std/containers/sequences/list/allocator_mismatch.verify.cpp
similarity index 73%
rename from libcxx/test/std/containers/sequences/list/allocator_mismatch.compile.fail.cpp
rename to libcxx/test/std/containers/sequences/list/allocator_mismatch.verify.cpp
index 39dcde477c291..9a850a713a681 100644
--- a/libcxx/test/std/containers/sequences/list/allocator_mismatch.compile.fail.cpp
+++ b/libcxx/test/std/containers/sequences/list/allocator_mismatch.verify.cpp
@@ -11,9 +11,5 @@
#include <list>
-int main(int, char**)
-{
- std::list<int, std::allocator<long> > l;
-
- return 0;
-}
+std::list<int, std::allocator<long> > l;
+ // expected-error-re@*:* {{{{(static_assert|static assertion)}} failed{{.*}}Allocator::value_type must be same type as value_type}}
diff --git a/libcxx/test/std/containers/sequences/vector/allocator_mismatch.compile.fail.cpp b/libcxx/test/std/containers/sequences/vector/allocator_mismatch.verify.cpp
similarity index 73%
rename from libcxx/test/std/containers/sequences/vector/allocator_mismatch.compile.fail.cpp
rename to libcxx/test/std/containers/sequences/vector/allocator_mismatch.verify.cpp
index 0c57f16be6c62..d9619f266c7ad 100644
--- a/libcxx/test/std/containers/sequences/vector/allocator_mismatch.compile.fail.cpp
+++ b/libcxx/test/std/containers/sequences/vector/allocator_mismatch.verify.cpp
@@ -11,9 +11,5 @@
#include <vector>
-int main(int, char**)
-{
- std::vector<int, std::allocator<long> > v;
-
- return 0;
-}
+std::vector<int, std::allocator<long> > v;
+ // expected-error-re@*:* {{{{(static_assert|static assertion)}} failed{{.*}}Allocator::value_type must be same type as value_type}}
diff --git a/libcxx/test/std/containers/unord/unord.map/allocator_mismatch.compile.fail.cpp b/libcxx/test/std/containers/unord/unord.map/allocator_mismatch.verify.cpp
similarity index 69%
rename from libcxx/test/std/containers/unord/unord.map/allocator_mismatch.compile.fail.cpp
rename to libcxx/test/std/containers/unord/unord.map/allocator_mismatch.verify.cpp
index 7059220425dd9..c8e0b8ff18ab9 100644
--- a/libcxx/test/std/containers/unord/unord.map/allocator_mismatch.compile.fail.cpp
+++ b/libcxx/test/std/containers/unord/unord.map/allocator_mismatch.verify.cpp
@@ -11,9 +11,5 @@
#include <unordered_map>
-int main(int, char**)
-{
- std::unordered_map<int, int, std::hash<int>, std::less<int>, std::allocator<long> > m;
-
- return 0;
-}
+std::unordered_map<int, int, std::hash<int>, std::less<int>, std::allocator<long> > m;
+ // expected-error-re@*:* {{{{(static_assert|static assertion)}} failed{{.*}}Allocator::value_type must be same type as value_type}}
diff --git a/libcxx/test/std/containers/unord/unord.multimap/allocator_mismatch.compile.fail.cpp b/libcxx/test/std/containers/unord/unord.multimap/allocator_mismatch.verify.cpp
similarity index 68%
rename from libcxx/test/std/containers/unord/unord.multimap/allocator_mismatch.compile.fail.cpp
rename to libcxx/test/std/containers/unord/unord.multimap/allocator_mismatch.verify.cpp
index ba24ca3cc9562..4f28dc449c788 100644
--- a/libcxx/test/std/containers/unord/unord.multimap/allocator_mismatch.compile.fail.cpp
+++ b/libcxx/test/std/containers/unord/unord.multimap/allocator_mismatch.verify.cpp
@@ -11,9 +11,5 @@
#include <unordered_map>
-int main(int, char**)
-{
- std::unordered_multimap<int, int, std::hash<int>, std::less<int>, std::allocator<long> > m;
-
- return 0;
-}
+std::unordered_multimap<int, int, std::hash<int>, std::less<int>, std::allocator<long> > m;
+ // expected-error-re@*:* {{{{(static_assert|static assertion)}} failed{{.*}}Allocator::value_type must be same type as value_type}}
diff --git a/libcxx/test/std/containers/unord/unord.set/allocator_mismatch.compile.fail.cpp b/libcxx/test/std/containers/unord/unord.multiset/allocator_mismatch.verify.cpp
similarity index 69%
rename from libcxx/test/std/containers/unord/unord.set/allocator_mismatch.compile.fail.cpp
rename to libcxx/test/std/containers/unord/unord.multiset/allocator_mismatch.verify.cpp
index 0d1341e6939cc..16590f0b1371e 100644
--- a/libcxx/test/std/containers/unord/unord.set/allocator_mismatch.compile.fail.cpp
+++ b/libcxx/test/std/containers/unord/unord.multiset/allocator_mismatch.verify.cpp
@@ -11,9 +11,5 @@
#include <unordered_set>
-int main(int, char**)
-{
- std::unordered_set<int, std::hash<int>, std::less<int>, std::allocator<long> > v;
-
- return 0;
-}
+std::unordered_multiset<int, std::hash<int>, std::less<int>, std::allocator<long> > v;
+ // expected-error-re@*:* {{{{(static_assert|static assertion)}} failed{{.*}}Allocator::value_type must be same type as value_type}}
diff --git a/libcxx/test/std/containers/unord/unord.multiset/allocator_mismatch.compile.fail.cpp b/libcxx/test/std/containers/unord/unord.set/allocator_mismatch.verify.cpp
similarity index 69%
rename from libcxx/test/std/containers/unord/unord.multiset/allocator_mismatch.compile.fail.cpp
rename to libcxx/test/std/containers/unord/unord.set/allocator_mismatch.verify.cpp
index 6183761a32ce5..94be4d711ff17 100644
--- a/libcxx/test/std/containers/unord/unord.multiset/allocator_mismatch.compile.fail.cpp
+++ b/libcxx/test/std/containers/unord/unord.set/allocator_mismatch.verify.cpp
@@ -11,9 +11,5 @@
#include <unordered_set>
-int main(int, char**)
-{
- std::unordered_multiset<int, std::hash<int>, std::less<int>, std::allocator<long> > v;
-
- return 0;
-}
+std::unordered_set<int, std::hash<int>, std::less<int>, std::allocator<long> > v;
+ // expected-error-re@*:* {{{{(static_assert|static assertion)}} failed{{.*}}Allocator::value_type must be same type as value_type}}
More information about the libcxx-commits
mailing list