summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorEric Fiselier <eric@efcs.ca>2017-03-01 02:02:28 +0000
committerEric Fiselier <eric@efcs.ca>2017-03-01 02:02:28 +0000
commitc6422362d5f9683f7e1003fe244b3fe84d6cca6f (patch)
treedb50ebf653a791d4ca1e77ac643b8c4f0b87415f /test
parent67f7a781263dad0b1ea54eb2d2afb00f2fd938ef (diff)
downloadlibcxx-c6422362d5f9683f7e1003fe244b3fe84d6cca6f.tar.gz
Improve diagnostics when an invalid hash is used in an unordered container.
This patch adds a static assertion that the specified hash meets the requirements of an enabled hash, and it ensures that the static assertion is evaluated before __compressed_pair is instantiated. That way the static assertion diagnostic is emitted first. git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@296565 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test')
-rw-r--r--test/libcxx/containers/unord/unord.set/missing_hash_specialization.fail.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/test/libcxx/containers/unord/unord.set/missing_hash_specialization.fail.cpp b/test/libcxx/containers/unord/unord.set/missing_hash_specialization.fail.cpp
new file mode 100644
index 000000000..8a9cde700
--- /dev/null
+++ b/test/libcxx/containers/unord/unord.set/missing_hash_specialization.fail.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++98, c++03
+// REQUIRES: diagnose-if-support
+
+// <unordered_set>
+
+// Test that we generate a reasonable diagnostic when the specified hash is
+// not enabled.
+
+#include <unordered_set>
+#include <utility>
+
+using VT = std::pair<int, int>;
+using Set = std::unordered_set<VT>;
+
+int main() {
+
+ Set s; // expected-error@__hash_table:* {{the specified hash functor does not meet the requirements for an enabled hash}}
+
+ // FIXME: It would be great to suppress the below diagnostic all together.
+ // but for now it's sufficient that it appears last. However there is
+ // currently no way to test the order diagnostics are issued.
+ // expected-error@memory:* {{call to implicitly-deleted default constructor of 'std::__1::hash<std::__1::pair<int, int> >'}}
+}