aboutsummaryrefslogtreecommitdiff
path: root/ld
diff options
context:
space:
mode:
authorKen Raeburn <raeburn@cygnus>1994-01-28 20:09:26 +0000
committerKen Raeburn <raeburn@cygnus>1994-01-28 20:09:26 +0000
commit6e0a904fd01c782a704c2ee383fb1276cc2b2f6a (patch)
tree52706fa0742ba4d8fe5ec33d4e9d068b9151ccad /ld
parent57e5ec0783eee6ca5872ea824c1b5fd04dabfc16 (diff)
downloadgdb-6e0a904fd01c782a704c2ee383fb1276cc2b2f6a.zip
gdb-6e0a904fd01c782a704c2ee383fb1276cc2b2f6a.tar.gz
gdb-6e0a904fd01c782a704c2ee383fb1276cc2b2f6a.tar.bz2
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.
Diffstat (limited to 'ld')
-rw-r--r--ld/testsuite/ld.cdtest/cdtest-foo.cc6
-rw-r--r--ld/testsuite/ld.cdtest/cdtest-foo.h4
-rw-r--r--ld/testsuite/ld.cdtest/cdtest-main.cc27
-rw-r--r--ld/testsuite/ld.cdtest/cdtest.exp15
4 files changed, 29 insertions, 23 deletions
diff --git a/ld/testsuite/ld.cdtest/cdtest-foo.cc b/ld/testsuite/ld.cdtest/cdtest-foo.cc
index f29930f..40be44b 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 0ba2d37..35b3a5c 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 4b99b5c..ac4b038 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 <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
+}
diff --git a/ld/testsuite/ld.cdtest/cdtest.exp b/ld/testsuite/ld.cdtest/cdtest.exp
index 127e184..549cdbd 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