aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2011-09-05 00:33:48 -0400
committerJason Merrill <jason@gcc.gnu.org>2011-09-05 00:33:48 -0400
commit0ad2cde83d102278cc285ca312747334d3616e31 (patch)
tree5625d935704f1dfefa35c0f60dbbe42c2e8b06ad /gcc
parentfd3faf2b21c97982448edb0aa47092759a3d0b33 (diff)
downloadgcc-0ad2cde83d102278cc285ca312747334d3616e31.zip
gcc-0ad2cde83d102278cc285ca312747334d3616e31.tar.gz
gcc-0ad2cde83d102278cc285ca312747334d3616e31.tar.bz2
re PR c++/49267 (Ambiguity with conversion functions "T&" and "T&&", initializing a "T&&")
PR c++/49267 PR c++/49458 DR 1328 * call.c (reference_binding): Set rvaluedness_matches_p properly for reference to function conversion ops. (compare_ics): Adjust. From-SVN: r178520
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog7
-rw-r--r--gcc/cp/call.c14
-rw-r--r--gcc/testsuite/ChangeLog6
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/rv-conv1.C9
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/rv-func3.C10
5 files changed, 41 insertions, 5 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index d61f5f7..718bcb3 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,12 @@
2011-09-04 Jason Merrill <jason@redhat.com>
+ PR c++/49267
+ PR c++/49458
+ DR 1328
+ * call.c (reference_binding): Set rvaluedness_matches_p properly
+ for reference to function conversion ops.
+ (compare_ics): Adjust.
+
* class.c (trivial_default_constructor_is_constexpr): Rename from
synthesized_default_constructor_is_constexpr.
(type_has_constexpr_default_constructor): Adjust.
diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index 8421260..1fa5fc8 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -1652,6 +1652,10 @@ reference_binding (tree rto, tree rfrom, tree expr, bool c_cast_p, int flags)
/* The top-level caller requested that we pretend that the lvalue
be treated as an rvalue. */
conv->rvaluedness_matches_p = TYPE_REF_IS_RVALUE (rto);
+ else if (TREE_CODE (rfrom) == REFERENCE_TYPE)
+ /* Handle rvalue reference to function properly. */
+ conv->rvaluedness_matches_p
+ = (TYPE_REF_IS_RVALUE (rto) == TYPE_REF_IS_RVALUE (rfrom));
else
conv->rvaluedness_matches_p
= (TYPE_REF_IS_RVALUE (rto) == !is_lvalue);
@@ -7960,13 +7964,13 @@ compare_ics (conversion *ics1, conversion *ics2)
if (ref_conv1 && ref_conv2)
{
- if (!ref_conv1->this_p && !ref_conv2->this_p
- && (TYPE_REF_IS_RVALUE (ref_conv1->type)
- != TYPE_REF_IS_RVALUE (ref_conv2->type)))
+ if (!ref_conv1->this_p && !ref_conv2->this_p)
{
- if (ref_conv1->rvaluedness_matches_p)
+ if (ref_conv1->rvaluedness_matches_p
+ > ref_conv2->rvaluedness_matches_p)
return 1;
- if (ref_conv2->rvaluedness_matches_p)
+ if (ref_conv2->rvaluedness_matches_p
+ > ref_conv1->rvaluedness_matches_p)
return -1;
}
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 2f149c4..1b465ce 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,11 @@
2011-09-04 Jason Merrill <jason@redhat.com>
+ PR c++/49267
+ * g++.dg/cpp0x/rv-conv1.C: New.
+
+ DR 1328
+ * g++.dg/cpp0x/rv-func3.C: New.
+
* g++.dg/cpp0x/constexpr-default-ctor.C: New.
PR c++/50248
diff --git a/gcc/testsuite/g++.dg/cpp0x/rv-conv1.C b/gcc/testsuite/g++.dg/cpp0x/rv-conv1.C
new file mode 100644
index 0000000..3852991
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/rv-conv1.C
@@ -0,0 +1,9 @@
+// PR c++/49267
+// { dg-options -std=c++0x }
+
+struct X {
+ operator int&();
+ operator int&&();
+};
+
+int&&x = X();
diff --git a/gcc/testsuite/g++.dg/cpp0x/rv-func3.C b/gcc/testsuite/g++.dg/cpp0x/rv-func3.C
new file mode 100644
index 0000000..8504682
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/rv-func3.C
@@ -0,0 +1,10 @@
+// DR 1328
+// { dg-options -std=c++0x }
+
+template <class T> struct A {
+ operator T&(); // #1
+ operator T&&(); // #2
+};
+typedef int Fn();
+A<Fn> a;
+Fn&& f = a;