From: Ken Raeburn Date: Fri, 28 Jan 1994 20:09:26 +0000 (+0000) Subject: Fix test case to be valid ANSI C++. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=6e0a904fd01c782a704c2ee383fb1276cc2b2f6a;p=binutils-gdb.git 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. --- diff --git a/ld/testsuite/ld.cdtest/cdtest-foo.cc b/ld/testsuite/ld.cdtest/cdtest-foo.cc index f29930f9776..40be44bd9bd 100644 --- a/ld/testsuite/ld.cdtest/cdtest-foo.cc +++ b/ld/testsuite/ld.cdtest/cdtest-foo.cc @@ -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); diff --git a/ld/testsuite/ld.cdtest/cdtest-foo.h b/ld/testsuite/ld.cdtest/cdtest-foo.h index 0ba2d37b272..35b3a5c2478 100644 --- a/ld/testsuite/ld.cdtest/cdtest-foo.h +++ b/ld/testsuite/ld.cdtest/cdtest-foo.h @@ -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; } diff --git a/ld/testsuite/ld.cdtest/cdtest-main.cc b/ld/testsuite/ld.cdtest/cdtest-main.cc index 4b99b5c5f0f..ac4b0387ea2 100644 --- a/ld/testsuite/ld.cdtest/cdtest-main.cc +++ b/ld/testsuite/ld.cdtest/cdtest-main.cc @@ -1,14 +1,12 @@ // main program for Class Foo -extern "C" { -// Some implementations (e.g. SUNOS 4.1) are broken, -// in that they require . 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 -}; #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 +} diff --git a/ld/testsuite/ld.cdtest/cdtest.exp b/ld/testsuite/ld.cdtest/cdtest.exp index 127e1845195..549cdbd6d00 100644 --- a/ld/testsuite/ld.cdtest/cdtest.exp +++ b/ld/testsuite/ld.cdtest/cdtest.exp @@ -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