2016-07-15 Jason Merrill <jason@redhat.com>
+ PR c++/71117
+ Core 2189
+ * call.c (add_template_conv_candidate): Disable if there are
+ viable candidates.
+
PR c++/71511
* typeck2.c (cxx_incomplete_type_diagnostic): Handle DECLTYPE_TYPE.
tree return_type, tree access_path,
tree conversion_path, tsubst_flags_t complain)
{
+ /* Making this work broke PR 71117, so until the committee resolves core
+ issue 2189, let's disable this candidate if there are any viable call
+ operators. */
+ if (any_strictly_viable (*candidates))
+ return NULL;
+
return
add_template_candidate_real (candidates, tmpl, NULL_TREE, NULL_TREE,
NULL_TREE, arglist, return_type, access_path,
+// Test for Core 2189.
// { dg-do compile { target c++11 } }
template <class T>
--- /dev/null
+// PR c++/71117
+// { dg-do compile { target c++14 } }
+
+template <class T> T&& declval() noexcept;
+template <class, class>
+constexpr bool is_same = false;
+template <class T>
+constexpr bool is_same<T, T> = true;
+
+template <class F>
+struct indirected : F {
+ indirected(F f) : F(f) {}
+ template <class I>
+ auto operator()(I i) -> decltype(declval<F&>()(*i)) {
+ return static_cast<F&>(*this)(*i);
+ }
+};
+
+int main() {
+ auto f = [](auto rng) {
+ static_assert(is_same<decltype(rng), int>, "");
+ return 42;
+ };
+ indirected<decltype(f)> i(f);
+ static_assert(is_same<decltype(i(declval<int*>())), int>, "");
+}