summaryrefslogtreecommitdiffstats
path: root/binutils-2.21/ld/testsuite/ld-cdtest/cdtest-foo.cc
diff options
context:
space:
mode:
authorJing Yu <jingyu@google.com>2011-12-20 10:27:58 -0800
committerJing Yu <jingyu@google.com>2011-12-20 10:27:58 -0800
commitcf3cdbf8b3cda61a619299e7966a83df66244036 (patch)
tree201e2bcfc955f16802d3257112d29736cb3a3ce8 /binutils-2.21/ld/testsuite/ld-cdtest/cdtest-foo.cc
parente4df3e0a5bb640ccfa2f30ee67fe9b3146b152d6 (diff)
downloadtoolchain_binutils-cf3cdbf8b3cda61a619299e7966a83df66244036.zip
toolchain_binutils-cf3cdbf8b3cda61a619299e7966a83df66244036.tar.gz
toolchain_binutils-cf3cdbf8b3cda61a619299e7966a83df66244036.tar.bz2
Add binutils-2.21.
Use --enable-gold=default for dual linker support. Change-Id: Id1a744c7db58a0b5e7a3be174cdfa875f2f86e49
Diffstat (limited to 'binutils-2.21/ld/testsuite/ld-cdtest/cdtest-foo.cc')
-rw-r--r--binutils-2.21/ld/testsuite/ld-cdtest/cdtest-foo.cc89
1 files changed, 89 insertions, 0 deletions
diff --git a/binutils-2.21/ld/testsuite/ld-cdtest/cdtest-foo.cc b/binutils-2.21/ld/testsuite/ld-cdtest/cdtest-foo.cc
new file mode 100644
index 0000000..d8e5cbe
--- /dev/null
+++ b/binutils-2.21/ld/testsuite/ld-cdtest/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* src, 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) = %ld\n", (long) 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 (const 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
+}