aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2011-09-26 13:55:04 -0400
committerJason Merrill <jason@gcc.gnu.org>2011-09-26 13:55:04 -0400
commit6cb1ef51438f731064431977ca56f7db598409d1 (patch)
tree8d459f359d524e6cbe9c6f0cdf60a67a3a1a398d /gcc/cp
parent31fd727b4d33fd4c9814e7796e5770e7643dc7c4 (diff)
downloadgcc-6cb1ef51438f731064431977ca56f7db598409d1.zip
gcc-6cb1ef51438f731064431977ca56f7db598409d1.tar.gz
gcc-6cb1ef51438f731064431977ca56f7db598409d1.tar.bz2
re PR c++/50512 (surprising change in overloading resolution)
PR c++/50512 * call.c (compare_ics): Only consider rvaluedness_matches_p if the target type is the same or it too differs in rvalueness. From-SVN: r179208
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/ChangeLog4
-rw-r--r--gcc/cp/call.c23
2 files changed, 19 insertions, 8 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 865d764..d1c7946 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,9 @@
2011-09-26 Jason Merrill <jason@redhat.com>
+ PR c++/50512
+ * call.c (compare_ics): Only consider rvaluedness_matches_p
+ if the target type is the same or it too differs in rvalueness.
+
PR c++/50523
* call.c (implicit_conversion): Mask out inappropriate LOOKUP
flags at the top of the function.
diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index 579e563..a52ec29 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -7864,18 +7864,25 @@ compare_ics (conversion *ics1, conversion *ics2)
types to which the references refer are the same type except for
top-level cv-qualifiers, and the type to which the reference
initialized by S2 refers is more cv-qualified than the type to
- which the reference initialized by S1 refers */
+ which the reference initialized by S1 refers.
+
+ DR 1328 [over.match.best]: the context is an initialization by
+ conversion function for direct reference binding (13.3.1.6) of a
+ reference to function type, the return type of F1 is the same kind of
+ reference (i.e. lvalue or rvalue) as the reference being initialized,
+ and the return type of F2 is not. */
if (ref_conv1 && ref_conv2)
{
- if (!ref_conv1->this_p && !ref_conv2->this_p)
+ if (!ref_conv1->this_p && !ref_conv2->this_p
+ && (ref_conv1->rvaluedness_matches_p
+ != ref_conv2->rvaluedness_matches_p)
+ && (same_type_p (ref_conv1->type, ref_conv2->type)
+ || (TYPE_REF_IS_RVALUE (ref_conv1->type)
+ != TYPE_REF_IS_RVALUE (ref_conv2->type))))
{
- if (ref_conv1->rvaluedness_matches_p
- > ref_conv2->rvaluedness_matches_p)
- return 1;
- if (ref_conv2->rvaluedness_matches_p
- > ref_conv1->rvaluedness_matches_p)
- return -1;
+ return (ref_conv1->rvaluedness_matches_p
+ - ref_conv2->rvaluedness_matches_p);
}
if (same_type_ignoring_top_level_qualifiers_p (to_type1, to_type2))