re PR c++/57948 (internal compiler error: in initialize_reference, at cp/call.c:9285)

/cp
2013-07-29  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/57948
	* call.c (initialize_reference): Don't crash when reference_binding
	returns a conv with conv->kind == ck_ambig.

/testsuite
2013-07-29  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/57948
	* g++.dg/conversion/ambig2.C: New.

From-SVN: r201318
This commit is contained in:
Paolo Carlini 2013-07-29 20:12:20 +00:00
parent 88e594b6de
commit 3ea1e3286b
4 changed files with 38 additions and 5 deletions

View file

@ -1,3 +1,9 @@
2013-07-29 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/57948
* call.c (initialize_reference): Don't crash when reference_binding
returns a conv with conv->kind == ck_ambig.
2013-07-29 Jason Merrill <jason@redhat.com>
* mangle.c (write_name): Check for null context.

View file

@ -9282,10 +9282,14 @@ initialize_reference (tree type, tree expr,
return error_mark_node;
}
gcc_assert (conv->kind == ck_ref_bind);
/* Perform the conversion. */
expr = convert_like (conv, expr, complain);
if (conv->kind == ck_ref_bind)
/* Perform the conversion. */
expr = convert_like (conv, expr, complain);
else if (conv->kind == ck_ambig)
/* We gave an error in build_user_type_conversion_1. */
expr = error_mark_node;
else
gcc_unreachable ();
/* Free all the conversions we allocated. */
obstack_free (&conversion_obstack, p);

View file

@ -1,3 +1,8 @@
2013-07-29 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/57948
* g++.dg/conversion/ambig2.C: New.
2013-07-29 Maciej W. Rozycki <macro@codesourcery.com>
* gcc.target/mips/fabs-2008.c: New test case.

View file

@ -0,0 +1,18 @@
// PR c++/57948
struct Base { };
struct Derived : Base
{
struct Derived2 : Base
{
struct ConvertibleToBothDerivedRef
{
operator Derived&();
operator Derived2&();
void bind_lvalue_to_conv_lvalue_ambig(ConvertibleToBothDerivedRef both)
{
Base &br1 = both; // { dg-error "ambiguous" }
}
};
};
};