Initial revision
[binutils.git] / ld / testsuite / ld-cdtest / cdtest-foo.cc
blob615e33cea78fb72234b146ebfac08e8220d4e157
1 // Class Foo
2 #pragma implementation
5 // We don't use header files, since we only want to see, whether the
6 // compiler is installed properly.
7 //
8 #if (__GNUG__ == 2)
9 typedef __SIZE_TYPE__ size_t;
10 #else
11 typedef unsigned int size_t;
12 #endif
14 extern "C" {
15 char *strncpy (char* dest, const char* dest, size_t len);
16 int printf (const char*, ...);
19 #include "cdtest-foo.h"
21 int Foo::foos = 0;
23 void Foo::init_foo ()
25 printf ("BROKENLY calling Foo::init_foo from __init_start; size_of(Foo) = %d\n", sizeof(Foo));
26 foos = FOOLISH_NUMBER;
30 Foo::Foo ()
32 i = ++foos;
33 strncpy (message, "default-foo", len);
34 #ifdef WITH_ADDR
35 printf ("Constructing Foo(%d) \"default-foo\" at %08x\n", i, this);
36 #else
37 printf ("Constructing Foo(%d) \"default-foo\"\n", i);
38 #endif
41 Foo::Foo (char* msg)
43 i = ++foos;
44 strncpy( message, msg, len);
45 #ifdef WITH_ADDR
46 printf ( "Constructing Foo(%d) \"%s\" at %08x\n", i, message, this);
47 #else
48 printf ( "Constructing Foo(%d) \"%s\"\n", i, message);
49 #endif
53 Foo::Foo (const Foo& foo)
55 i = ++foos;
56 #ifdef WITH_ADDR
57 printf ("Initializing Foo(%d) \"%s\" at %08x with Foo(%d) %08x\n",
58 i, foo.message, this, foo.i, &foo);
59 #else
60 printf ("Initializing Foo(%d) \"%s\" with Foo(%d)\n",i, foo.message, foo.i);
61 #endif
62 for ( int k = 0; k < FOO_MSG_LEN; k++) message[k] = foo.message[k];
66 Foo& Foo::operator= (const Foo& foo)
68 #ifdef WITH_ADDR
69 printf ("Copying Foo(%d) \"%s\" at %08x to Foo(%d) %08x\n",
70 foo.i, foo.message, &foo, i, this);
71 #else
72 printf ("Copying Foo(%d) \"%s\" to Foo(%d)\n", foo.i, foo.message, i);
73 #endif
74 for ( int k = 0; k < FOO_MSG_LEN; k++) message[k] = foo.message[k];
75 return *this;
79 Foo::~Foo ()
81 foos--;
82 #ifdef WITH_ADDR
83 printf ("Destructing Foo(%d) \"%s\" at %08x (remaining foos: %d)\n",
84 i, message, this, foos);
85 #else
86 printf ("Destructing Foo(%d) \"%s\" (remaining foos: %d)\n",
87 i, message, foos);
88 #endif