diff options
author | Eric Fiselier <eric@efcs.ca> | 2017-03-01 02:02:28 +0000 |
---|---|---|
committer | Eric Fiselier <eric@efcs.ca> | 2017-03-01 02:02:28 +0000 |
commit | c6422362d5f9683f7e1003fe244b3fe84d6cca6f (patch) | |
tree | db50ebf653a791d4ca1e77ac643b8c4f0b87415f /test | |
parent | 67f7a781263dad0b1ea54eb2d2afb00f2fd938ef (diff) | |
download | libcxx-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.cpp | 32 |
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> >'}} +} |