From: Jason Merrill Date: Fri, 17 Jan 2003 22:51:24 +0000 (-0500) Subject: re PR c++/9342 (another ICE in cp_expr_size at cp/cp-lang.c: 304) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=77b996cc58685d44753ff78a3e9f19b10c5be767;p=gcc.git re PR c++/9342 (another ICE in cp_expr_size at cp/cp-lang.c: 304) PR c++/9342 * call.c (build_conditional_expr): Always do lvalue-rvalue conversion. From-SVN: r61457 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 36890c35ff0..7a148f5bd2b 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2003-01-17 Jason Merrill + + PR c++/9342 + * call.c (build_conditional_expr): Always do lvalue-rvalue + conversion. + 2003-01-17 Mark Mitchell PR c++/9294 diff --git a/gcc/cp/call.c b/gcc/cp/call.c index 5340356d4d5..cb0d351069a 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -3187,14 +3187,14 @@ build_conditional_expr (tree arg1, tree arg2, tree arg3) We use ocp_convert rather than build_user_type_conversion because the latter returns NULL_TREE on failure, while the former gives an error. */ - if (IS_AGGR_TYPE (TREE_TYPE (arg2)) && real_lvalue_p (arg2)) + if (IS_AGGR_TYPE (TREE_TYPE (arg2))) arg2 = ocp_convert (TREE_TYPE (arg2), arg2, CONV_IMPLICIT|CONV_FORCE_TEMP, LOOKUP_NORMAL); else arg2 = decay_conversion (arg2); arg2_type = TREE_TYPE (arg2); - if (IS_AGGR_TYPE (TREE_TYPE (arg3)) && real_lvalue_p (arg3)) + if (IS_AGGR_TYPE (TREE_TYPE (arg3))) arg3 = ocp_convert (TREE_TYPE (arg3), arg3, CONV_IMPLICIT|CONV_FORCE_TEMP, LOOKUP_NORMAL); else diff --git a/gcc/testsuite/g++.dg/init/copy4.C b/gcc/testsuite/g++.dg/init/copy4.C new file mode 100644 index 00000000000..bfff685666a --- /dev/null +++ b/gcc/testsuite/g++.dg/init/copy4.C @@ -0,0 +1,19 @@ +// PR c++/9342 +// We were failing to wrap def().user in a TARGET_EXPR, so copying it +// into the reference temp used a bitwise copy. + +struct QString +{ + QString( const QString & ); + QString &operator=( const QString & ); +}; +struct ServerSettings +{ + QString user; +}; +extern ServerSettings def(); +extern void arg( const QString& a ); +void startSession( bool b, QString s ) +{ + arg (b ? def().user : s); +}