From 4d031550cc895e3004f9cd23874877facc5d429a Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Fri, 15 Jul 2016 14:49:25 -0400 Subject: [PATCH] PR c++/71117 - core 2189 and generic lambda * call.c (add_template_conv_candidate): Disable if there are viable candidates. From-SVN: r238394 --- gcc/cp/ChangeLog | 5 ++++ gcc/cp/call.c | 6 +++++ gcc/testsuite/g++.dg/cpp0x/conv-tmpl1.C | 1 + .../g++.dg/cpp1y/lambda-generic-conv2.C | 26 +++++++++++++++++++ 4 files changed, 38 insertions(+) create mode 100644 gcc/testsuite/g++.dg/cpp1y/lambda-generic-conv2.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 0178f108f6c..eb96ea3f8db 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,10 @@ 2016-07-15 Jason Merrill + 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. diff --git a/gcc/cp/call.c b/gcc/cp/call.c index 9b028144aaa..6ae5df76b1c 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -3204,6 +3204,12 @@ add_template_conv_candidate (struct z_candidate **candidates, tree tmpl, 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, diff --git a/gcc/testsuite/g++.dg/cpp0x/conv-tmpl1.C b/gcc/testsuite/g++.dg/cpp0x/conv-tmpl1.C index 7f866daf4ea..eb40dd66a5c 100644 --- a/gcc/testsuite/g++.dg/cpp0x/conv-tmpl1.C +++ b/gcc/testsuite/g++.dg/cpp0x/conv-tmpl1.C @@ -1,3 +1,4 @@ +// Test for Core 2189. // { dg-do compile { target c++11 } } template diff --git a/gcc/testsuite/g++.dg/cpp1y/lambda-generic-conv2.C b/gcc/testsuite/g++.dg/cpp1y/lambda-generic-conv2.C new file mode 100644 index 00000000000..5528455fe0b --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/lambda-generic-conv2.C @@ -0,0 +1,26 @@ +// PR c++/71117 +// { dg-do compile { target c++14 } } + +template T&& declval() noexcept; +template +constexpr bool is_same = false; +template +constexpr bool is_same = true; + +template +struct indirected : F { + indirected(F f) : F(f) {} + template + auto operator()(I i) -> decltype(declval()(*i)) { + return static_cast(*this)(*i); + } +}; + +int main() { + auto f = [](auto rng) { + static_assert(is_same, ""); + return 42; + }; + indirected i(f); + static_assert(is_same())), int>, ""); +} -- 2.30.2