From: Patrick Palka Date: Sat, 25 Jul 2015 23:15:44 +0000 (+0000) Subject: re PR c++/66857 (Reference not bound to lvalue) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=9783ae5a2f44f714809321c4bb2d5534d50c19a4;p=gcc.git 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 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 7cb343f2048..f7669d3ac07 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2015-07-25 Patrick Palka + + PR c++/66857 + * cvt.c (ocp_convert): Don't call scalar_constant_value when + converting to a class type. + 2015-07-24 Jason Merrill PR c++/64969 diff --git a/gcc/cp/cvt.c b/gcc/cp/cvt.c index 13bc1f7766f..6d4bd9aac25 100644 --- a/gcc/cp/cvt.c +++ b/gcc/cp/cvt.c @@ -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; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index d842193a66d..67148bb8162 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2015-07-25 Patrick Palka + + PR c++/66857 + * g++.dg/init/pr66857.C: New test. + 2015-07-25 Uros Bizjak 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 index 00000000000..43b09272279 --- /dev/null +++ b/gcc/testsuite/g++.dg/init/pr66857.C @@ -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; +}