re PR c++/14230 (ICE in cp_expr_size)
authorMark Mitchell <mark@codesourcery.com>
Tue, 9 Mar 2004 10:08:40 +0000 (10:08 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Tue, 9 Mar 2004 10:08:40 +0000 (10:08 +0000)
PR c++/14230
* call.c (initialize_reference): Handle initializers that are
class-member access expressions applies to rvalues.

PR c++/14230
* g++.dg/init/ref11.C: New test.

From-SVN: r79165

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

index 2f684b4c1fe12e4717207c6e723d855a923b1324..608a23ce7634657a1ffe48a467fbc9a337760d2e 100644 (file)
@@ -1,3 +1,9 @@
+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
index b8b7b7ae11dedc60ab83ae44ae81b7d6f7b05c85..e371d305abe75b80d3f97248abdd5b146897e58a 100644 (file)
@@ -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);
index 8e55c0e3ab44c5916c247170f4817bae3d22911f..624bf21def4aded535af85cf7f60a6cd3e5742d5 100644 (file)
@@ -1,3 +1,8 @@
+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
diff --git a/gcc/testsuite/g++.dg/init/ref11.C b/gcc/testsuite/g++.dg/init/ref11.C
new file mode 100644 (file)
index 0000000..b283e3a
--- /dev/null
@@ -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;