#include "cdtest-foo.h"
+const Foo::len = FOO_MSG_LEN;
+
int Foo::foos = 0;
void Foo::init_foo ()
{
i = ++foos;
#ifdef WITH_ADDR
- printf ("Initializing Foo(%d) \"%s\" at %08x with Foo(%d) %08x\n",
+ 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);
Foo& Foo::operator= (const Foo& foo)
{
#ifdef WITH_ADDR
- printf ("Copying Foo(%d) \"%s\" at %08x to Foo(%d) %08x\n",
+ 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);
class Foo {
static int foos;
int i;
- const len = FOO_MSG_LEN;
- char message[len];
+ static const int len;
+ char message[FOO_MSG_LEN];
public:
static void init_foo ();
static int nb_foos() { return foos; }
// main program for Class Foo
-extern "C" {
-// Some <assert.h> implementations (e.g. SUNOS 4.1) are broken,
-// in that they require <stdio.h>. But, if gcc/g++ is installed
-// correctly, you should get gcc's assert.h.
-// If the compile fails, it means the wrong include files are in use!
-#include <assert.h>
-};
#include "cdtest-foo.h"
+// If we're using "../gcc/xgcc -B../gcc/", we may not have fixed C++
+// header files to work with. So we can't use assert.h here.
+extern "C" void exit (int);
+#define assert(X) if (!(X)) exit(1)
+
extern "C" void __init_start();
extern Foo f(void);
/* This function should *not* be called by the environment. There is
no way in C++ to ``run something after the initializers but before main()''.
- The library that depends on this (NIHCL) is broken. -- John Gilmore
+ The library that depends on this (NIHCL) is broken. -- John Gilmore
We leave this here to test that future changes to the compiler
do not re-introduce this losing ``feature''. */
-void
+void
__init_start()
{
Foo::init_foo();
}
-static Foo static_foo( "static_foo");
+static Foo static_foo( "static_foo");
-main()
-{
+main()
+{
assert (Foo::nb_foos() == 2);
Foo automatic_foo( "automatic_foo");
Foo bla_foo = f();
assert (Foo::nb_foos() == 4);
g();
assert (Foo::nb_foos() == 4);
- // `automatic_foo' and `bla_foo' are destructed here
-}
-
+ // `automatic_foo' and `bla_foo' are destructed here
+}
# Written by Jeffrey Wheat (cassidy@cygnus.com)
#
+#
+# Bugs:
+# + Assumes native toolchain, not cross.
+# + Doesn't detect compilation failures (including lack of C++ compiler)
+# cleanly.
+# + Shouldn't use fixed names in /tmp for temp files -- either use names
+# in current directory, or generate unique names.
+#
+
if $tracelevel then {
strace $tracelevel
}
}
}
# remove generated targets
- verbose "Exec exec rm -f $tmptarget.o $tmptarget.out"
- catch "exec rm -f $tmptarget.o $tmptarget.out" result
- verbose "Exec exec rm -f $tmptarget.grt $tmptarget"
- catch "exec rm -f $tmptarget.grt $tmptarget" result
+ verbose "Exec exec rm -f $tmptarget.o $tmptarget.out $tmptarget $tmptarget.grt"
+ catch "exec rm -f $tmptarget.o $tmptarget.out $tmptarget.grt $tmptarget" result
}
# remove dependant objects