From 1c9a0251aa6d1dd6d17b1c6676a77c1fdd5eda9b Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Fri, 19 Jan 2018 23:37:37 +0100 Subject: [PATCH] re PR c++/81167 (ICE on valid C++ code in deferred_printed_type, at cp/error.c:118) PR c++/81167 * call.c (joust): Use TREE_TYPE (source) if source is a POINTER_TYPE_P rather than if ! DECL_CONSTRUCTOR_P (w->fn). * g++.dg/cpp0x/pr81167.C: New test. From-SVN: r256905 --- gcc/cp/ChangeLog | 4 ++++ gcc/cp/call.c | 2 +- gcc/testsuite/ChangeLog | 3 +++ gcc/testsuite/g++.dg/cpp0x/pr81167.C | 24 ++++++++++++++++++++++++ 4 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/cpp0x/pr81167.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index eb39b402391..5bad14dadd0 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 2018-01-19 Jakub Jelinek + PR c++/81167 + * call.c (joust): Use TREE_TYPE (source) if source is + a POINTER_TYPE_P rather than if ! DECL_CONSTRUCTOR_P (w->fn). + PR c++/83919 * typeck.c (convert_for_assignment): Suppress warn_ignored_qualifiers for direct enum init. diff --git a/gcc/cp/call.c b/gcc/cp/call.c index e08622ce9c2..46d5ef5e7c0 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -10090,7 +10090,7 @@ joust (struct z_candidate *cand1, struct z_candidate *cand2, bool warn, else if (warn) { tree source = source_type (w->convs[0]); - if (! DECL_CONSTRUCTOR_P (w->fn)) + if (POINTER_TYPE_P (source)) source = TREE_TYPE (source); if (warning (OPT_Wconversion, "choosing %qD over %qD", w->fn, l->fn) && warning (OPT_Wconversion, " for conversion from %qH to %qI", diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index d6ea61f5938..ceb16e56772 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2018-01-19 Jakub Jelinek + PR c++/81167 + * g++.dg/cpp0x/pr81167.C: New test. + PR c++/83919 * g++.dg/cpp0x/pr83919.C: New test. diff --git a/gcc/testsuite/g++.dg/cpp0x/pr81167.C b/gcc/testsuite/g++.dg/cpp0x/pr81167.C new file mode 100644 index 00000000000..d0c9d233c49 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/pr81167.C @@ -0,0 +1,24 @@ +// PR c++/81167 +// { dg-do compile { target c++11 } } +// { dg-options "-Wconversion" } + +struct bar; + +struct foo +{ + foo () {} + foo (const bar &) {} +}; + +struct bar +{ + operator foo () && { return foo (); } +}; + +void test () +{ + foo f = bar (); +// { dg-warning "choosing 'bar::operator foo\\(\\) &&' over 'foo::foo\\(const bar&\\)'" "" { target *-*-* } .-1 } +// { dg-warning "for conversion from 'bar' to 'foo'" "" { target *-*-* } .-2 } +// { dg-message "because conversion sequence for the argument is better" "" { target *-*-* } .-3 } +} -- 2.30.2