re PR c++/66857 (Reference not bound to lvalue)
authorPatrick Palka <ppalka@gcc.gnu.org>
Sat, 25 Jul 2015 23:15:44 +0000 (23:15 +0000)
committerPatrick Palka <ppalka@gcc.gnu.org>
Sat, 25 Jul 2015 23:15:44 +0000 (23:15 +0000)
Fix PR c++/66857

gcc/cp/ChangeLog:

PR c++/66857
* cvt.c (ocp_convert): Don't call scalar_constant_value when
converting to a class type.

gcc/testsuite/ChangeLog:

PR c++/66857
* g++.dg/init/pr66857.C: New test.

From-SVN: r226228

gcc/cp/ChangeLog
gcc/cp/cvt.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/init/pr66857.C [new file with mode: 0644]

index 7cb343f20480e55309b60842e995d455409ceabc..f7669d3ac07abbc472caeb8614b4fb12d334a2d3 100644 (file)
@@ -1,3 +1,9 @@
+2015-07-25  Patrick Palka  <ppalka@gcc.gnu.org>
+
+       PR c++/66857
+       * cvt.c (ocp_convert): Don't call scalar_constant_value when
+       converting to a class type.
+
 2015-07-24  Jason Merrill  <jason@redhat.com>
 
        PR c++/64969
index 13bc1f7766fcc954aa4384ad64560d1f72dadbad..6d4bd9aac256bd1b3a61b0948f64b05a2b9760f7 100644 (file)
@@ -687,7 +687,8 @@ ocp_convert (tree type, tree expr, int convtype, int flags,
     }
 
   /* FIXME remove when moving to c_fully_fold model.  */
-  e = scalar_constant_value (e);
+  if (!CLASS_TYPE_P (type))
+    e = scalar_constant_value (e);
   if (error_operand_p (e))
     return error_mark_node;
 
index d842193a66ded27e73536572a51bd7595f4a3d39..67148bb81626343a5efcadb94f3dc367e698aed3 100644 (file)
@@ -1,3 +1,8 @@
+2015-07-25  Patrick Palka  <ppalka@gcc.gnu.org>
+
+       PR c++/66857
+       * g++.dg/init/pr66857.C: New test.
+
 2015-07-25  Uros Bizjak  <ubizjak@gmail.com>
 
        PR target/66648
diff --git a/gcc/testsuite/g++.dg/init/pr66857.C b/gcc/testsuite/g++.dg/init/pr66857.C
new file mode 100644 (file)
index 0000000..43b0927
--- /dev/null
@@ -0,0 +1,19 @@
+// PR c++/66857
+// { dg-do run }
+
+const int i = 0;
+
+struct Test
+{
+  Test (const int &rhs)
+  {
+    if (&rhs != &i)
+      __builtin_abort ();
+  }
+};
+
+int
+main (void)
+{
+  Test test = i;
+}