mirror of
https://github.com/darlinghq/darling-gdb.git
synced 2024-12-02 00:56:27 +00:00
Fix test case to be valid ANSI C++.
Don't require use of fixed C++ header files, so "../gcc/xgcc -B../gcc/" ought to work for CXX. In cdtest.exp: Combine "rm" lines. Added some commentary on things still broken in this test case.
This commit is contained in:
parent
57e5ec0783
commit
6e0a904fd0
@ -18,6 +18,8 @@ extern "C" {
|
||||
|
||||
#include "cdtest-foo.h"
|
||||
|
||||
const Foo::len = FOO_MSG_LEN;
|
||||
|
||||
int Foo::foos = 0;
|
||||
|
||||
void Foo::init_foo ()
|
||||
@ -54,7 +56,7 @@ Foo::Foo (const Foo& 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);
|
||||
@ -66,7 +68,7 @@ Foo::Foo (const Foo& foo)
|
||||
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);
|
||||
|
@ -11,8 +11,8 @@
|
||||
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; }
|
||||
|
@ -1,14 +1,12 @@
|
||||
// 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);
|
||||
@ -16,25 +14,24 @@ extern void g(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
|
||||
}
|
||||
|
@ -21,6 +21,15 @@
|
||||
# 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
|
||||
}
|
||||
@ -68,10 +77,8 @@ foreach test [glob -nocomplain $srcdir/$subdir/*.dat] {
|
||||
}
|
||||
}
|
||||
# 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
|
||||
|
Loading…
Reference in New Issue
Block a user