re PR c++/57948 (internal compiler error: in initialize_reference, at cp/call.c:9285)
authorPaolo Carlini <paolo@gcc.gnu.org>
Mon, 29 Jul 2013 20:12:20 +0000 (20:12 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Mon, 29 Jul 2013 20:12:20 +0000 (20:12 +0000)
/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

gcc/cp/ChangeLog
gcc/cp/call.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/conversion/ambig2.C [new file with mode: 0644]

index 21eaa1ff312bda2dbea4ef91b89c049660968e68..1bedc84621582336da388f98c9bd636630507a90 100644 (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.
index e8d526075a768cf7ab73ebfef46b4108a3bdae04..0574a9c15274cb6faa57166be0e3321fb39d11f3 100644 (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);
index 7c022b708263ee0948b83bf3485579573aa0560e..1a706889d673cc1590dd9e804f8e38e37243d179 100644 (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.
@@ -85,7 +90,7 @@
        * gcc.c-torture/execute/builtins/stpcpy-chk.x: Likewise.
 
        * gcc.dg/pr27095.c: For Epiphany, add -mshort-calls.
-       * gcc.dg/tree-ssa/loop-1.c: Likewise. 
+       * gcc.dg/tree-ssa/loop-1.c: Likewise.
 
        * gcc.dg/torture/pr37868.c: Disable for epiphany.
        * gcc.dg/sibcall-6.c: Enable for epiphany.
diff --git a/gcc/testsuite/g++.dg/conversion/ambig2.C b/gcc/testsuite/g++.dg/conversion/ambig2.C
new file mode 100644 (file)
index 0000000..a9d9d69
--- /dev/null
@@ -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" }
+      }
+    };
+  };
+};