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
This commit is contained in:
Jakub Jelinek 2018-01-19 23:37:37 +01:00 committed by Jakub Jelinek
parent 26fc730dd2
commit 1c9a0251aa
4 changed files with 32 additions and 1 deletions

View file

@ -1,5 +1,9 @@
2018-01-19 Jakub Jelinek <jakub@redhat.com>
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.

View file

@ -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",

View file

@ -1,5 +1,8 @@
2018-01-19 Jakub Jelinek <jakub@redhat.com>
PR c++/81167
* g++.dg/cpp0x/pr81167.C: New test.
PR c++/83919
* g++.dg/cpp0x/pr83919.C: New test.

View file

@ -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 }
}