This patch fixes PR34298 (https://bugs.llvm.org/show_bug.cgi?id=34298). Since Clang changed in r284549, Clang and libc++ prohibit the use of std::function with an incomplete return type, like in the example below:
struct Continuation { std::function<Continuation ()> fn; };
This code failed to compile because of the way SFINAE checks were performed in libc++. Essentially when Continuation was defining a copy-constructor, it tried to find a matching overload for the copy constructor of fn, and thus tried to instantiate std::functions function(_Fp) constructor with a std::function<Continuation ()> substitute for _Fp. That constructor did check against function in its SFINAE checks, but it did so after trying to invoke _Fp. This caused an error while evaluating __invokable_r because Continuation is incomplete, and the incomplete type checker for __invokable_r didn't take std::function<> types into account.
This patch ensures that the SFINAE check verify that _Fp is not a std::function before trying to figure out if _Fp is invokable.
Is this file in the right place?
If it's supposed to test functionality that is required by the standard, it should go in test/std somewhere.
If it's supposed to test a libc++ extension, then it should go into test/libcxx.