re PR c++/66857 (Reference not bound to lvalue)

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
This commit is contained in:
Patrick Palka 2015-07-25 23:15:44 +00:00
parent 39a8bd7b64
commit 9783ae5a2f
4 changed files with 32 additions and 1 deletions

View 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

View 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;

View 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

View File

@ -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;
}