URL
https://opencores.org/ocsvn/openrisc/openrisc/trunk
Subversion Repositories openrisc
Compare Revisions
- This comparison shows the changes necessary to convert path
/openrisc/trunk/gnu-old/binutils-2.18.50/ld/testsuite/ld-cdtest
- from Rev 156 to Rev 816
- ↔ Reverse comparison
Rev 156 → Rev 816
/cdtest-nrv.dat
0,0 → 1,13
Constructing Foo(1) "static_foo" |
Constructing Foo(2) "static_foo" |
Constructing Foo(3) "automatic_foo" |
Constructing Foo(4) "default-foo" |
Constructing Foo(5) "other_foo1" |
Constructing Foo(6) "other_foo2" |
Copying Foo(5) "other_foo1" to Foo(6) |
Destructing Foo(6) "other_foo1" (remaining foos: 5) |
Destructing Foo(5) "other_foo1" (remaining foos: 4) |
Destructing Foo(4) "default-foo" (remaining foos: 3) |
Destructing Foo(3) "automatic_foo" (remaining foos: 2) |
Destructing Foo(2) "static_foo" (remaining foos: 1) |
Destructing Foo(1) "static_foo" (remaining foos: 0) |
/cdtest.exp
0,0 → 1,127
# Expect script for LD cdtest Tests |
# Copyright 1993, 1994, 1995, 1997, 2001, 2004, 2007 |
# Free Software Foundation, Inc. |
# |
# This file is part of the GNU Binutils. |
# |
# This program is free software; you can redistribute it and/or modify |
# it under the terms of the GNU General Public License as published by |
# the Free Software Foundation; either version 3 of the License, or |
# (at your option) any later version. |
# |
# This program is distributed in the hope that it will be useful, |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
# GNU General Public License for more details. |
# |
# You should have received a copy of the GNU General Public License |
# along with this program; if not, write to the Free Software |
# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, |
# MA 02110-1301, USA. |
# |
# Written by Jeffrey Wheat (cassidy@cygnus.com) |
# Rewritten by Ian Lance Taylor (ian@cygnus.com) |
# |
|
# Make sure that constructors are handled correctly. |
|
set test1 "cdtest" |
set test2 "cdtest with -Ur" |
|
# This test requires running the executable generated by ld. |
if ![isnative] { |
return |
} |
|
if { [which $CXX] == 0 } { |
untested $test1 |
untested $test2 |
return |
} |
|
if { ![ld_compile "$CXX $CXXFLAGS -fno-exceptions" $srcdir/$subdir/cdtest-foo.cc tmpdir/cdtest-foo.o] |
|| ![ld_compile "$CXX $CXXFLAGS -fno-exceptions" $srcdir/$subdir/cdtest-bar.cc tmpdir/cdtest-bar.o] |
|| ![ld_compile "$CXX $CXXFLAGS -fno-exceptions" $srcdir/$subdir/cdtest-main.cc tmpdir/cdtest-main.o] } { |
unresolved $test1 |
unresolved $test2 |
return |
} |
|
set expected_output "$srcdir/$subdir/cdtest.dat" |
|
if ![ld_link $ld tmpdir/cdtest {tmpdir/cdtest-foo.o tmpdir/cdtest-bar.o tmpdir/cdtest-main.o}] { |
fail $test1 |
} else { |
send_log "tmpdir/cdtest >tmpdir/cdtest.out\n" |
verbose "tmpdir/cdtest >tmpdir/cdtest.out" |
catch "exec tmpdir/cdtest >tmpdir/cdtest.out" exec_output |
|
if ![string match "" $exec_output] then { |
send_log "$exec_output\n" |
verbose "$exec_output" 1 |
|
fail $test1 |
} else { |
send_log "diff tmpdir/cdtest.out $expected_output\n" |
verbose "diff tmpdir/cdtest.out $expected_output" |
catch "exec diff tmpdir/cdtest.out $expected_output" exec_output |
set exec_output [prune_warnings $exec_output] |
|
if ![string match "" $exec_output] then { |
send_log "$exec_output\n" |
verbose "$exec_output" 1 |
|
send_log "Checking against Named Return Value optimization\n" |
verbose "Checking against Named Return Value optimization" 1 |
|
set expected_output "$srcdir/$subdir/cdtest-nrv.dat" |
|
send_log "diff tmpdir/cdtest.out $expected_output\n" |
verbose "diff tmpdir/cdtest.out $expected_output" |
catch "exec diff tmpdir/cdtest.out $expected_output" exec_output |
set exec_output [prune_warnings $exec_output] |
} |
|
if [string match "" $exec_output] then { |
pass $test1 |
} else { |
send_log "$exec_output\n" |
verbose "$exec_output" 1 |
|
fail $test1 |
} |
} |
} |
|
if ![ld_relocate $ld tmpdir/cdtest.o {-Ur tmpdir/cdtest-foo.o tmpdir/cdtest-bar.o tmpdir/cdtest-main.o}] { |
fail $test2 |
} else { |
if ![ld_link $ld tmpdir/cdtest tmpdir/cdtest.o] { |
fail $test2 |
} else { |
send_log "tmpdir/cdtest >tmpdir/cdtest.out\n" |
verbose "tmpdir/cdtest >tmpdir/cdtest.out" |
catch "exec tmpdir/cdtest >tmpdir/cdtest.out" exec_output |
|
if ![string match "" $exec_output] then { |
send_log "$exec_output\n" |
verbose "$exec_output" 1 |
|
fail $test2 |
} else { |
send_log "diff tmpdir/cdtest.out $expected_output\n" |
verbose "diff tmpdir/cdtest.out $expected_output" |
catch "exec diff tmpdir/cdtest.out $expected_output" exec_output |
set exec_output [prune_warnings $exec_output] |
|
if [string match "" $exec_output] then { |
pass $test2 |
} else { |
send_log "$exec_output\n" |
verbose "$exec_output" 1 |
|
fail $test2 |
} |
} |
} |
} |
/cdtest-foo.cc
0,0 → 1,89
// Class Foo |
#pragma implementation |
|
|
// We don't use header files, since we only want to see, whether the |
// compiler is installed properly. |
// |
#if (__GNUG__ == 2) |
typedef __SIZE_TYPE__ size_t; |
#else |
typedef unsigned int size_t; |
#endif |
|
extern "C" { |
char *strncpy (char* dest, const char* src, size_t len); |
int printf (const char*, ...); |
}; |
|
#include "cdtest-foo.h" |
|
int Foo::foos = 0; |
|
void Foo::init_foo () |
{ |
printf ("BROKENLY calling Foo::init_foo from __init_start; size_of(Foo) = %ld\n", (long) sizeof(Foo)); |
foos = FOOLISH_NUMBER; |
} |
|
|
Foo::Foo () |
{ |
i = ++foos; |
strncpy (message, "default-foo", len); |
#ifdef WITH_ADDR |
printf ("Constructing Foo(%d) \"default-foo\" at %08x\n", i, this); |
#else |
printf ("Constructing Foo(%d) \"default-foo\"\n", i); |
#endif |
} |
|
Foo::Foo (const char* msg) |
{ |
i = ++foos; |
strncpy( message, msg, len); |
#ifdef WITH_ADDR |
printf ( "Constructing Foo(%d) \"%s\" at %08x\n", i, message, this); |
#else |
printf ( "Constructing Foo(%d) \"%s\"\n", i, message); |
#endif |
} |
|
|
Foo::Foo (const Foo& foo) |
{ |
i = ++foos; |
#ifdef WITH_ADDR |
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); |
#endif |
for ( int k = 0; k < FOO_MSG_LEN; k++) message[k] = foo.message[k]; |
} |
|
|
Foo& Foo::operator= (const Foo& foo) |
{ |
#ifdef WITH_ADDR |
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); |
#endif |
for ( int k = 0; k < FOO_MSG_LEN; k++) message[k] = foo.message[k]; |
return *this; |
} |
|
|
Foo::~Foo () |
{ |
foos--; |
#ifdef WITH_ADDR |
printf ("Destructing Foo(%d) \"%s\" at %08x (remaining foos: %d)\n", |
i, message, this, foos); |
#else |
printf ("Destructing Foo(%d) \"%s\" (remaining foos: %d)\n", |
i, message, foos); |
#endif |
} |
/cdtest-bar.cc
0,0 → 1,17
// test program for Class Foo |
|
#include "cdtest-foo.h" |
|
static Foo static_foo( "static_foo"); |
|
Foo f() |
{ |
Foo x; |
return x; |
} |
|
void g() |
{ |
Foo other_foo1 = Foo( "other_foo1"), other_foo2 = Foo( "other_foo2"); |
other_foo2 = other_foo1; |
} |
/cdtest-main.cc
0,0 → 1,40
// 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" |
|
extern "C" void __init_start(); |
|
extern Foo f(void); |
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 |
We leave this here to test that future changes to the compiler |
do not re-introduce this losing ``feature''. */ |
void |
__init_start() |
{ |
Foo::init_foo(); |
} |
|
static Foo static_foo( "static_foo"); |
|
int 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 |
} |
|
/cdtest-foo.h
0,0 → 1,24
// Class Foo |
|
#pragma interface |
|
#define FOOLISH_NUMBER -4711 |
|
#ifndef FOO_MSG_LEN |
#define FOO_MSG_LEN 80 |
#endif |
|
class Foo { |
static int foos; |
int i; |
static const int len = FOO_MSG_LEN; |
char message[len]; |
public: |
static void init_foo (); |
static int nb_foos() { return foos; } |
Foo(); |
Foo(const char* message); |
Foo(const Foo&); |
Foo & operator= (const Foo&); |
~Foo (); |
}; |
/cdtest.dat
0,0 → 1,15
Constructing Foo(1) "static_foo" |
Constructing Foo(2) "static_foo" |
Constructing Foo(3) "automatic_foo" |
Constructing Foo(4) "default-foo" |
Initializing Foo(5) "default-foo" with Foo(4) |
Destructing Foo(4) "default-foo" (remaining foos: 4) |
Constructing Foo(5) "other_foo1" |
Constructing Foo(6) "other_foo2" |
Copying Foo(5) "other_foo1" to Foo(6) |
Destructing Foo(6) "other_foo1" (remaining foos: 5) |
Destructing Foo(5) "other_foo1" (remaining foos: 4) |
Destructing Foo(5) "default-foo" (remaining foos: 3) |
Destructing Foo(3) "automatic_foo" (remaining foos: 2) |
Destructing Foo(2) "static_foo" (remaining foos: 1) |
Destructing Foo(1) "static_foo" (remaining foos: 0) |