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
This commit is contained in:
@@ -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> >'}}
|
||||
}
|
||||
Reference in New Issue
Block a user