re PR c++/47503 ([C++0x] ICE: in adjust_temp_type, at cp/semantics.c:5876 with -fno...
authorJason Merrill <jason@redhat.com>
Sat, 19 Feb 2011 22:39:50 +0000 (17:39 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Sat, 19 Feb 2011 22:39:50 +0000 (17:39 -0500)
PR c++/47503
* semantics.c (cxx_eval_call_expression): Shortcut trivial copy.

From-SVN: r170330

gcc/cp/ChangeLog
gcc/cp/semantics.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/regress/no-elide1.C [new file with mode: 0644]

index 0f6ece2eb2064a556f55fd68658214445d58b0be..938d3f2c40b9d8f92931c133ae110c00a475c0cf 100644 (file)
@@ -1,3 +1,8 @@
+2011-02-19  Jason Merrill  <jason@redhat.com>
+
+       PR c++/47503
+       * semantics.c (cxx_eval_call_expression): Shortcut trivial copy.
+
 2011-02-18  Paolo Carlini  <paolo.carlini@oracle.com>
 
        PR c++/47795
index e102ba3dcfbf9dd722936697ecfdf4c15d8b324e..8944690288528fa14fcef6f405d7698f9eddc56a 100644 (file)
@@ -6019,6 +6019,10 @@ cxx_eval_call_expression (const constexpr_call *old_call, tree t,
       return t;
     }
 
+  /* Shortcut trivial copy constructor/op=.  */
+  if (call_expr_nargs (t) == 2 && trivial_fn_p (fun))
+    return convert_from_reference (get_nth_callarg (t, 1));
+
   /* If in direct recursive call, optimize definition search.  */
   if (old_call != NULL && old_call->fundef->decl == fun)
     new_call.fundef = old_call->fundef;
index db9b51d32919125b46404ced5d41d9b5adb640d9..2f82fedd25e8ca29e71a47994bb635be0116e11d 100644 (file)
@@ -1,3 +1,7 @@
+2011-02-19  Jason Merrill  <jason@redhat.com>
+
+       * g++.dg/cpp0x/regress/no-elide1.C: New.
+
 2011-02-19  Alexandre Oliva  <aoliva@redhat.com>
 
        PR tree-optimization/46620
diff --git a/gcc/testsuite/g++.dg/cpp0x/regress/no-elide1.C b/gcc/testsuite/g++.dg/cpp0x/regress/no-elide1.C
new file mode 100644 (file)
index 0000000..50df950
--- /dev/null
@@ -0,0 +1,14 @@
+// PR c++/47503
+// { dg-options "-std=c++0x -fno-elide-constructors" }
+
+struct A
+{
+  int i;
+  A ();
+};
+
+struct B
+{
+  A a;
+  B (A &aa) : a (aa) { }
+};