* g++.dg/other/copy2.C: New test.
authorBrian R. Gaeke <brg@dgate.ORG>
Tue, 21 May 2002 17:26:50 +0000 (17:26 +0000)
committerAlexandre Oliva <aoliva@gcc.gnu.org>
Tue, 21 May 2002 17:26:50 +0000 (17:26 +0000)
From-SVN: r53692

gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/other/copy2.C [new file with mode: 0644]

index 4f5290b1c7c8feca757bf040c695d293bba17dff..da87b8c77b9539ca9284b1dc743fdd0e99065bab 100644 (file)
@@ -1,3 +1,7 @@
+Tue May 21 14:25:32 2002  Brian R. Gaeke  <brg@dgate.ORG>
+
+       * g++.dg/other/copy2.C: New test.
+
 Mon May 20 10:51:35 2002  J"orn Rennecke <joern.rennecke@superh.com>
 
        * gcc.c-torture/execute/memcpy-2.c (SEQUENCE_LENGTH): Define.
diff --git a/gcc/testsuite/g++.dg/other/copy2.C b/gcc/testsuite/g++.dg/other/copy2.C
new file mode 100644 (file)
index 0000000..335cab8
--- /dev/null
@@ -0,0 +1,32 @@
+// { dg-do run }
+
+// Test that A's copy assignment method is called when B's instance
+// member array of A is assigned.
+
+// Contributed by Brian Gaeke, public domain.
+int status = 1;
+
+class A
+{
+public:
+  int i;
+  A &operator =(const A &i)
+  {
+    status = 0;
+  }
+};
+
+class B
+{
+public:
+  A arr[10];
+};
+
+int main (int argc, char **argv)
+{
+  B b;
+  b.arr[0].i = 15;
+  B a;
+  a = b; // trigger copy assignment
+  return status;
+}