Blame SOURCES/gcc32-c++-pass-by-invisible-ref.patch

4ac4fd
2004-12-01  Alexandre Oliva  <aoliva@redhat.com>
4ac4fd
4ac4fd
	* calls.c (initialize_argument_information): Treat NOP_EXPR
4ac4fd
	of TARGET_EXPR the same as TARGET_EXPR itself.
4ac4fd
4ac4fd
2005-01-03  Jakub Jelinek  <jakub@redhat.com>
4ac4fd
4ac4fd
	* g++.dg/other/destruct1.C: New test.
4ac4fd
4ac4fd
--- gcc/calls.c.jj	2003-09-16 16:57:44.000000000 +0200
4ac4fd
+++ gcc/calls.c	2005-01-03 11:00:11.604022891 +0100
4ac4fd
@@ -1239,7 +1239,10 @@ initialize_argument_information (num_act
4ac4fd
 					   args[i].tree_value);
4ac4fd
 	      type = build_pointer_type (type);
4ac4fd
 	    }
4ac4fd
-	  else if (TREE_CODE (args[i].tree_value) == TARGET_EXPR)
4ac4fd
+	  else if (TREE_CODE (args[i].tree_value) == TARGET_EXPR
4ac4fd
+		   || (TREE_CODE (args[i].tree_value) == NOP_EXPR
4ac4fd
+		       && (TREE_CODE (TREE_OPERAND (args[i].tree_value, 0))
4ac4fd
+			   == TARGET_EXPR)))
4ac4fd
 	    {
4ac4fd
 	      /* In the V3 C++ ABI, parameters are destroyed in the caller.
4ac4fd
 		 We implement this by passing the address of the temporary
4ac4fd
--- gcc/testsuite/g++.dg/other/destruct1.C.jj	2005-01-03 11:02:26.440730539 +0100
4ac4fd
+++ gcc/testsuite/g++.dg/other/destruct1.C	2005-01-03 11:02:44.971392180 +0100
4ac4fd
@@ -0,0 +1,41 @@
4ac4fd
+// { dg-do run }
4ac4fd
+
4ac4fd
+int i, j, k;
4ac4fd
+extern "C" void abort ();
4ac4fd
+
4ac4fd
+struct S
4ac4fd
+{
4ac4fd
+  S () { ++i; }
4ac4fd
+  S (const S &x) { ++k; }
4ac4fd
+  S &operator= (const S &x) { abort (); return *this; }
4ac4fd
+  ~S () { ++j; }
4ac4fd
+};
4ac4fd
+
4ac4fd
+const S foo ()
4ac4fd
+{
4ac4fd
+  S s;
4ac4fd
+  return s;
4ac4fd
+}
4ac4fd
+
4ac4fd
+S bar (S x)
4ac4fd
+{
4ac4fd
+  return S ();
4ac4fd
+}
4ac4fd
+
4ac4fd
+S baz (S x)
4ac4fd
+{
4ac4fd
+  return x;
4ac4fd
+}
4ac4fd
+
4ac4fd
+void test ()
4ac4fd
+{
4ac4fd
+  S a = bar (foo ());
4ac4fd
+  S b = baz (foo ());
4ac4fd
+}
4ac4fd
+
4ac4fd
+int main ()
4ac4fd
+{
4ac4fd
+  test ();
4ac4fd
+  if (i != 3 || j != 4 || k != 1)
4ac4fd
+    abort ();
4ac4fd
+}