diff mbox

C++ PATCH for DR 1571 (reference binding)

Message ID 530D0AC3.6030603@redhat.com
State New
Headers show

Commit Message

Jason Merrill Feb. 25, 2014, 9:27 p.m. UTC
Getting the reference binding rules for C++11 right (in the standard) 
has taken quite a few iterations.  I'm pretty happy with the latest 
wording, which deals with user-defined conversions by recursing on the 
result of the conversion.  This patch implements those rules.  I'm a 
little uncertain about applying this so late in the 4.9 cycle, but I 
think it's a significant improvement to C++11 support.

The second patch fixes a diagnostic issue I noticed while working on 
this: when explaining that a conversion from the result of the 
conversion function failed, the compiler was talking about the 'this' 
parameter.

Tested x86_64-pc-linux-gnu, applying to trunk.

Comments

Jason Merrill Feb. 26, 2014, 5:01 p.m. UTC | #1
On 02/25/2014 04:27 PM, Jason Merrill wrote:
> I'm a
> little uncertain about applying this so late in the 4.9 cycle, but I
> think it's a significant improvement to C++11 support.

But it broke firefox, so I've reverted it.  I'll try again in stage 1.

Jason
diff mbox

Patch

commit f84d42ca81f6c327a0356a4dd426a68925db582b
Author: Jason Merrill <jason@redhat.com>
Date:   Tue Feb 11 11:10:04 2014 -0800

    	* call.c (print_conversion_rejection): Handle n_arg of -2.
    	(build_user_type_conversion_1): Pass it.

diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index d3db585..700099d 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -3180,6 +3180,10 @@  print_conversion_rejection (location_t loc, struct conversion_info *info)
     inform (loc, "  no known conversion for implicit "
 	    "%<this%> parameter from %qT to %qT",
 	    info->from_type, info->to_type);
+  else if (info->n_arg == -2)
+    /* Conversion of conversion function return value failed.  */
+    inform (loc, "  no known conversion from %qT to %qT",
+	    info->from_type, info->to_type);
   else
     inform (loc, "  no known conversion for argument %d from %qT to %qT",
 	    info->n_arg+1, info->from_type, info->to_type);
@@ -3604,7 +3608,7 @@  build_user_type_conversion_1 (tree totype, tree expr, int flags,
 	  if (!ics)
 	    {
 	      cand->viable = 0;
-	      cand->reason = arg_conversion_rejection (NULL_TREE, -1,
+	      cand->reason = arg_conversion_rejection (NULL_TREE, -2,
 						       rettype, totype);
 	    }
 	  else if (DECL_NONCONVERTING_P (cand->fn)
@@ -3624,7 +3628,7 @@  build_user_type_conversion_1 (tree totype, tree expr, int flags,
 	    {
 	      cand->viable = -1;
 	      cand->reason
-		= bad_arg_conversion_rejection (NULL_TREE, -1,
+		= bad_arg_conversion_rejection (NULL_TREE, -2,
 						rettype, totype);
 	    }
 	  else if (primary_template_instantiation_p (cand->fn)