diff options
author | Jason Merrill <jason@redhat.com> | 2016-07-15 14:49:25 -0400 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2016-07-15 14:49:25 -0400 |
commit | 4d031550cc895e3004f9cd23874877facc5d429a (patch) | |
tree | d29e6966bf822d43bd6e5242f9d921be3b3eaf09 /gcc | |
parent | 2a54351ba7f9a90ede3dbc6dd2e15272b955fdd1 (diff) | |
download | gcc-4d031550cc895e3004f9cd23874877facc5d429a.zip gcc-4d031550cc895e3004f9cd23874877facc5d429a.tar.gz gcc-4d031550cc895e3004f9cd23874877facc5d429a.tar.bz2 |
PR c++/71117 - core 2189 and generic lambda
* call.c (add_template_conv_candidate): Disable if there are
viable candidates.
From-SVN: r238394
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/cp/call.c | 6 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp0x/conv-tmpl1.C | 1 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp1y/lambda-generic-conv2.C | 26 |
4 files changed, 38 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 0178f10..eb96ea3 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,10 @@ 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. diff --git a/gcc/cp/call.c b/gcc/cp/call.c index 9b02814..6ae5df7 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 7f866da..eb40dd6 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 <class T> 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 0000000..5528455 --- /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 <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>, ""); +} |