aboutsummaryrefslogtreecommitdiff
path: root/ld/cdtest-foo.cc
diff options
context:
space:
mode:
authorPer Bothner <per@bothner.com>1992-08-05 04:15:37 +0000
committerPer Bothner <per@bothner.com>1992-08-05 04:15:37 +0000
commit917bffa7f6dd3a04195a790595a2088683386227 (patch)
treefb5e23a8c1dcef367ae67cc63fed7ea9b45fe0f2 /ld/cdtest-foo.cc
parentc7a535938ed0ac4a601897462e0012ed7b2430e1 (diff)
downloadgdb-917bffa7f6dd3a04195a790595a2088683386227.zip
gdb-917bffa7f6dd3a04195a790595a2088683386227.tar.gz
gdb-917bffa7f6dd3a04195a790595a2088683386227.tar.bz2
* cdtest-main.cc, cdtest-func.cc, cdtest-foo.h, cdtest-foo.cc,
cdtest.exp: A test program (copied from libg++/test-install) that tests that constructor and destructors are handled corrrectly.
Diffstat (limited to 'ld/cdtest-foo.cc')
-rw-r--r--ld/cdtest-foo.cc89
1 files changed, 89 insertions, 0 deletions
diff --git a/ld/cdtest-foo.cc b/ld/cdtest-foo.cc
new file mode 100644
index 0000000..f29930f
--- /dev/null
+++ b/ld/cdtest-foo.cc
@@ -0,0 +1,89 @@
+// Class Foo
+//#pragma implementation
+
+
+// We don't use header files, since we only want to see, whether the
+// compiler is installed properly.
+//
+#if (__GNUG__ == 2)
+typedef __SIZE_TYPE__ size_t;
+#else
+typedef unsigned int size_t;
+#endif
+
+extern "C" {
+ char *strncpy (char* dest, const char* dest, size_t len);
+ int printf (const char*, ...);
+};
+
+#include "cdtest-foo.h"
+
+int Foo::foos = 0;
+
+void Foo::init_foo ()
+{
+ printf ("BROKENLY calling Foo::init_foo from __init_start; size_of(Foo) = %d\n", sizeof(Foo));
+ foos = FOOLISH_NUMBER;
+}
+
+
+Foo::Foo ()
+{
+ i = ++foos;
+ strncpy (message, "default-foo", len);
+#ifdef WITH_ADDR
+ printf ("Constructing Foo(%d) \"default-foo\" at %08x\n", i, this);
+#else
+ printf ("Constructing Foo(%d) \"default-foo\"\n", i);
+#endif
+}
+
+Foo::Foo (char* msg)
+{
+ i = ++foos;
+ strncpy( message, msg, len);
+#ifdef WITH_ADDR
+ printf ( "Constructing Foo(%d) \"%s\" at %08x\n", i, message, this);
+#else
+ printf ( "Constructing Foo(%d) \"%s\"\n", i, message);
+#endif
+}
+
+
+Foo::Foo (const Foo& foo)
+{
+ i = ++foos;
+#ifdef WITH_ADDR
+ printf ("Initializing Foo(%d) \"%s\" at %08x with Foo(%d) %08x\n",
+ i, foo.message, this, foo.i, &foo);
+#else
+ printf ("Initializing Foo(%d) \"%s\" with Foo(%d)\n",i, foo.message, foo.i);
+#endif
+ for ( int k = 0; k < FOO_MSG_LEN; k++) message[k] = foo.message[k];
+}
+
+
+Foo& Foo::operator= (const Foo& foo)
+{
+#ifdef WITH_ADDR
+ printf ("Copying Foo(%d) \"%s\" at %08x to Foo(%d) %08x\n",
+ foo.i, foo.message, &foo, i, this);
+#else
+ printf ("Copying Foo(%d) \"%s\" to Foo(%d)\n", foo.i, foo.message, i);
+#endif
+ for ( int k = 0; k < FOO_MSG_LEN; k++) message[k] = foo.message[k];
+ return *this;
+}
+
+
+Foo::~Foo ()
+{
+ foos--;
+#ifdef WITH_ADDR
+ printf ("Destructing Foo(%d) \"%s\" at %08x (remaining foos: %d)\n",
+ i, message, this, foos);
+#else
+ printf ("Destructing Foo(%d) \"%s\" (remaining foos: %d)\n",
+ i, message, foos);
+#endif
+}