aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarek Polacek <polacek@redhat.com>2019-03-25 16:10:06 +0000
committerMarek Polacek <mpolacek@gcc.gnu.org>2019-03-25 16:10:06 +0000
commita55f758221cfd574cc341f969c27f8ecdac087a4 (patch)
treeae37d39cd2ce02bacc7f6f0124440727612d8ee4
parent8d6419db2cd99949022cd76cf6b1d0f93be0394b (diff)
downloadgcc-a55f758221cfd574cc341f969c27f8ecdac087a4.zip
gcc-a55f758221cfd574cc341f969c27f8ecdac087a4.tar.gz
gcc-a55f758221cfd574cc341f969c27f8ecdac087a4.tar.bz2
PR c++/89705 - ICE with reference binding with conversion function.
* call.c (reference_binding): If the result of the conversion function is a prvalue of non-class type, use the cv-unqualified type. * g++.dg/cpp0x/rv-conv2.C: New test. From-SVN: r269918
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/call.c3
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/rv-conv2.C18
4 files changed, 32 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 7589b30..b2b7b41 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,9 @@
+2019-03-25 Marek Polacek <polacek@redhat.com>
+
+ PR c++/89705 - ICE with reference binding with conversion function.
+ * call.c (reference_binding): If the result of the conversion function
+ is a prvalue of non-class type, use the cv-unqualified type.
+
2019-03-25 Nathan Sidwell <nathan@acm.org>
* lambda.c (maybe_add_lambda_conv_op): Don't add to comdat group.
diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index a4adab2..9efca73 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -1853,6 +1853,9 @@ reference_binding (tree rto, tree rfrom, tree expr, bool c_cast_p, int flags,
&& DECL_CONV_FN_P (t->cand->fn))
{
tree ftype = TREE_TYPE (TREE_TYPE (t->cand->fn));
+ /* A prvalue of non-class type is cv-unqualified. */
+ if (!TYPE_REF_P (ftype) && !CLASS_TYPE_P (ftype))
+ ftype = cv_unqualified (ftype);
int sflags = (flags|LOOKUP_NO_CONVERSION)&~LOOKUP_NO_TEMP_BIND;
conversion *new_second
= reference_binding (rto, ftype, NULL_TREE, c_cast_p,
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 7e1978b..01364a9 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2019-03-25 Marek Polacek <polacek@redhat.com>
+
+ PR c++/89705 - ICE with reference binding with conversion function.
+ * g++.dg/cpp0x/rv-conv2.C: New test.
+
2019-03-25 Richard Biener <rguenther@suse.de>
PR tree-optimization/89789
diff --git a/gcc/testsuite/g++.dg/cpp0x/rv-conv2.C b/gcc/testsuite/g++.dg/cpp0x/rv-conv2.C
new file mode 100644
index 0000000..9b9b154
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/rv-conv2.C
@@ -0,0 +1,18 @@
+// PR c++/89705
+// { dg-do compile { target c++11 } }
+
+struct W { operator const volatile int(); };
+const int& rci = W();
+
+struct X { operator const int(); };
+int&& rri = X();
+
+struct Y { operator volatile int(); };
+int&& rri2 = Y();
+
+struct Z { operator const volatile int(); };
+volatile int&& rri3 = Z();
+
+enum E { A };
+struct S { operator const E(); };
+E&& rre = S();