blob: 4577d0bf4d54df21b73a0cfde41d3ec98b00b12e [file] [log] [blame]
Eric Fiselier60b3df42014-12-23 05:54:34 +00001//===----------------------------------------------------------------------===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is dual licensed under the MIT and the University of Illinois Open
6// Source Licenses. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
Eric Fiselier45f63bc2015-07-22 04:14:38 +000010// UNSUPPORTED: c++98, c++03
11
Eric Fiselier60b3df42014-12-23 05:54:34 +000012// <functional>
13
14// template<CopyConstructible Fn, CopyConstructible... Types>
15// unspecified bind(Fn, Types...);
16// template<Returnable R, CopyConstructible Fn, CopyConstructible... Types>
17// unspecified bind(Fn, Types...);
18
19// http://llvm.org/bugs/show_bug.cgi?id=22003
20
21#include <functional>
22
23struct DummyUnaryFunction
24{
25 template <typename S>
Dan Albert1d4a1ed2016-05-25 22:36:09 -070026 int operator()(S const & s) const { return 0; }
Eric Fiselier60b3df42014-12-23 05:54:34 +000027};
28
29struct BadUnaryFunction
30{
31 template <typename S>
32 constexpr int operator()(S const & s) const
33 {
34 // Trigger a compile error if this function is instantiated.
35 // The constexpr is needed so that it is instantiated while checking
36 // __invoke_of<BadUnaryFunction &, ...>.
37 static_assert(!std::is_same<S, S>::value, "Shit");
38 return 0;
39 }
40};
41
Dan Albert1d4a1ed2016-05-25 22:36:09 -070042int main(int argc, char* argv[])
Eric Fiselier60b3df42014-12-23 05:54:34 +000043{
44 // Check that BadUnaryFunction::operator()(S const &) is not
45 // instantiated when checking if BadUnaryFunction is a nested bind
46 // expression during b(0). See PR22003.
47 auto b = std::bind(DummyUnaryFunction(), BadUnaryFunction());
48 b(0);
49 auto b2 = std::bind<long>(DummyUnaryFunction(), BadUnaryFunction());
50 b2(0);
51}