diff options
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/call.c | 10 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/init/ref11.C | 13 |
4 files changed, 34 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 2f684b4..608a23c 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,11 @@ 2004-03-09 Mark Mitchell <mark@codesourcery.com> + PR c++/14230 + * call.c (initialize_reference): Handle initializers that are + class-member access expressions applies to rvalues. + +2004-03-09 Mark Mitchell <mark@codesourcery.com> + PR c++/14432 * name-lookup.c (supplement_binding): Ignore functions that are marked DECL_ANTICIPATED. diff --git a/gcc/cp/call.c b/gcc/cp/call.c index b8b7b7a..e371d30 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -6463,6 +6463,16 @@ initialize_reference (tree type, tree expr, tree decl, tree *cleanup) type = TREE_TYPE (expr); var = make_temporary_var_for_ref_to_temp (decl, type); layout_decl (var, 0); + /* If the rvalue is the result of a function call it will be + a TARGET_EXPR. If it is some other construct (such as a + member access expression where the underlying object is + itself the result of a function call), turn it into a + TARGET_EXPR here. It is important that EXPR be a + TARGET_EXPR below since otherwise the INIT_EXPR will + attempt to make a bitwise copy of EXPR to intialize + VAR. */ + if (TREE_CODE (init) != TARGET_EXPR) + expr = get_target_expr (expr); /* Create the INIT_EXPR that will initialize the temporary variable. */ init = build (INIT_EXPR, type, var, expr); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 8e55c0e..624bf21 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,10 @@ 2004-03-09 Mark Mitchell <mark@codesourcery.com> + PR c++/14230 + * g++.dg/init/ref11.C: New test. + +2004-03-09 Mark Mitchell <mark@codesourcery.com> + PR c++/14432 * g++.dg/parse/builtin2.C: New test. diff --git a/gcc/testsuite/g++.dg/init/ref11.C b/gcc/testsuite/g++.dg/init/ref11.C new file mode 100644 index 0000000..b283e3a --- /dev/null +++ b/gcc/testsuite/g++.dg/init/ref11.C @@ -0,0 +1,13 @@ +// PR c++/14230 + +struct A { + A (); + A (const A&); + A& operator= (const A&); +}; + +struct D { + A a; +}; + +const A& z = D().a; |