Initial revision

From-SVN: r14840
This commit is contained in:
Jeff Law 1997-08-19 01:34:40 -06:00
parent 45832e2182
commit 921e5a0eb4
2559 changed files with 93270 additions and 0 deletions

1928
gcc/testsuite/ChangeLog Normal file

File diff suppressed because it is too large Load Diff

64
gcc/testsuite/README.g++ Normal file
View File

@ -0,0 +1,64 @@
This file needs a little updating, but is pretty close. Here are some
random last minute notes:
make check and make check-g++ aren't in FSF's gcc yet, I am planning
on getting this work into the tree some time...
> and the command
> runtest --tool g++ --srcdir ./testsuite
> doesn't work. I got it to work by explicitly setting CXX and CXXFLAGS
> on the command line, e.g.
> runtest --tool g++ --srcdir ./testsuite CXX=g++ CXXFLAGS=""
site.exp updated to have right CXXFLAGS and CXX, but not at the FSF yet.
This is a collection of tests for g++, the FSF's C++ compiler. The
driver that runs the testsuite is called DejaGnu. If you do not have
DejaGnu yet, you will need to get it (ftp://ftp.cygnus.com/pub/dejagnu).
You will need a snapshot of DejaGnu of 02/21/97 or later. The tests
were developed and/or collected by Cygnus Support. These tests are
included "as is". If any of the tests fail, don't report a bug. Bug
reports for DejaGnu can go to bug-dejagnu@prep.ai.mit.edu. Discussion
and comments about this testsuite can be sent to me, at the address
below.
Since these are part of the development source tree at Cygnus, this
tar file is supposed to be untarred so that the testsuite directory is
in the gcc source tree. Most of the time DejaGnu is run by hand using
"runtest", but as we believe in solid testing, we've integrated it
into the Makefile as a target. We normally use the testsuite by doing
a "make all; make check-g++" at the top level and building and testing
our whole tree. If you have both the gcc testsuite and the g++
testsuite, you can check both with the "make check" command.
DejaGnu can be run either installed, or uninstalled. Usually it gets
installed so that anyone can just run the tests without having to
configure or build DejaGnu.
To run the tests, first change to the gcc-2.7.1 directory, then type:
runtest --tool g++ --srcdir ./testsuite
Here's a brief explanation.
runtest - Is the name used to invoke DejaGnu. If DejaGnu is not
install this will be the relative path name for runtest.
--tool - This tells DejaGnu which tool you are testing. It is
mainly used to find the testsuite directories for a
particular tool when several testsuites are in the
same directory. (like the gcc and g++ testsuites)
--srcdir - This points to the top level of the directory
containing the sources of the testsuite. This is
./testsuite if you are in the directory that has the
testsuite directory.
Mike Stump
mrs@cygnus.com
FSF C++ developer

71
gcc/testsuite/README.gcc Normal file
View File

@ -0,0 +1,71 @@
This file contains a list of notes for those writing testcases and those
writing expect scripts. At present, they're in random order.
Verbosity Levels
- each level adds verbosity so level 2 prints all level 1 and level 2 stuff.
1) Print a one-liner indicating the testcase being run (and maybe special
compiler options).
2) Print compiler and program invocation including arguments and their output.
Proc's gcc_load and gcc_start handle the latter two.
3) Print detailed testcase analysis like "Looking for pattern ...", etc.
4) Maximum verbosity. Print anything else of interest.
send_log conventions
Various messages are stored in gcc.log by the testing framework and we
try to augment them with some of our own. The format of the framework
messages are:
PASS: blah blah ...
FAIL: blah blah ...
so we use
XXXX: blah blah ...
Current messages are:
EXEC: program being executed (so compiler path and args are recorded)
STAT: intermediate pass/fail statistics
DO NOT PUT NON-PORTABLE TESTCASES IN gcc.c-torture.
ANY TARGET SPECIFIC TESTCASE MUST HAVE APPROPRIATE CODE TO PREVENT IT FROM
CAUSING A `FAILURE' ON UNSUPPORTED PLATFORMS.
Test scripts must ignore the compiler messages "path prefix never used"
and "linker input file unused". Don't let their appearance cause a testcase
to fail. See lib/dg.exp for the exact regsub to use.
If you're unclear about which directory a testcase should be installed in,
ask gcc-local.
Always use abort() for runtime failures, and exit(0) for success.
The testing harness is set up to watch for these and do something appropriate
(when necessary) for target boards.
Have the text of a fail message be the same as that for pass.
IE: have
if ...success...
pass "pr 1234"
else
fail "pr 1234"
not
if ...success...
pass "pr 1234 passed"
else
fail "pr 1234 failed"
This lets test-tool (which drives the nightly tests) do a better job
at tracking which tests have digressed or been fixed.
Add more notes here.

View File

@ -0,0 +1,20 @@
# Copyright (C) 1997 Free Software Foundation, Inc.
# 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 2 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# Please email any bugs, comments, and/or additions to this file to:
# bug-gcc@prep.ai.mit.edu
load_lib "standard.exp"

View File

@ -0,0 +1,12 @@
#### host, target, and site specific Makefile frags come in here.
srcdir = .
# Nothing to do...
all:
clean:
-rm -f *.o *.diff *~ *.bad core *.x
distclean: clean
-rm -f Makefile config.status

View File

@ -0,0 +1,15 @@
# This file is a shell script fragment that supplies the information
# necessary to tailor a template configure script into the configure
# script appropriate for this directory. For more information, check
# any existing configure script.
srctrigger=old-deja.exp
srcname="DejaGnu"
# per-host:
# per-target:
target_makefile_frag=../config/mt-${target_alias}
# post-target:

View File

@ -0,0 +1,2 @@
Makefile
config.status

View File

@ -0,0 +1,5 @@
// Build don't link:
// prms-id: 12475
enum huh { start =-2147483648, next };

View File

@ -0,0 +1,6 @@
// Build don't link:
char *stuff() {
char array[10]; // WARNING -
return array;
}

View File

@ -0,0 +1,4 @@
// Build don't link:
extern const int a[];
extern const int a[];
extern const int a[];

View File

@ -0,0 +1,13 @@
// prms-id: 9028
class Foo;
int main()
{
int i=0;
switch (i)
{
case ((Foo *)0): // ERROR -
case ((Foo *)1): // ERROR -
break;
}
}

View File

@ -0,0 +1,31 @@
// Build don't link:
// prms-id: 9866
class TChar
{
public:
explicit inline TChar(unsigned int aChar);
inline operator unsigned int() const;
private:
unsigned int iChar;
};
inline TChar::TChar(unsigned int aChar)
: iChar(aChar)
{}
inline TChar::operator unsigned int() const
{return(iChar);}
class TDes8
{
public:
inline const unsigned char &operator[](int anIndex) const;
const unsigned char &AtC(int anIndex) const;
};
inline const unsigned char &TDes8::operator[](int anIndex) const
{return(AtC(anIndex));}
void doExponent(TDes8 &aDigBuf)
{
2 ? TChar(aDigBuf[2]) : '0';
}

View File

@ -0,0 +1,22 @@
// prms-id: 7330
#include <stddef.h>
int size = 0;
struct X {
int x;
void *operator new[](size_t sz) {
size = sz;
return 0;
}
void operator delete[] (void *vp) { ::delete[] vp; }
};
int main()
{
X (*px) [10];
px = new X[5][10];
delete [] px;
return 0;
}

View File

@ -0,0 +1,9 @@
// Build don't link:
extern "C" {
class A {
public:
void a();
};
};
void A::a() {}

View File

@ -0,0 +1,4 @@
class C {
public:
static friend int f(); // ERROR -
};

View File

@ -0,0 +1,16 @@
// prms-id: 5274
class VHDLIdentifier;
class VHDLPackageProtoRep {
public:
int thing();
private:
virtual VHDLIdentifier &actual_name() ;
};
extern void form(const char *format, ... );
int
VHDLPackageProtoRep::thing()
{
form("package `%s'", (char *)actual_name()); // ERROR - can't convert from incomplete type
return 0;
}

View File

@ -0,0 +1,25 @@
// Build don't link:
class A {
char str[10];
public:
char* m1 () { return str;};
};
class C : public A {
public:
};
class B : public A {
public:
char* m1 () { C::m1(); return ""; } // ERROR -
};
main () {
A a;
B b;
C c;
a.m1();
c.m1();
b.m1();
}

View File

@ -0,0 +1,22 @@
// Build don't link:
class A {
public:
void z();
A(void) {}
private:
A(const A &) { abort(); } // ERROR -
const A& operator =(const A &) { abort(); }
};
class B : public A {
public:
B(void) {}
};
void f(B b) {
};
void g() {
B h;
f(h); // ERROR -
}

View File

@ -0,0 +1,15 @@
// Build don't link:
class A {
class B {
typedef long T;
int i;
};
};
class C {
class B {
typedef float T;
int i;
};
};
C::B::T a;

View File

@ -0,0 +1,16 @@
main() {
struct s
{
int a;
short b;
} __attribute__((packed)) t;
if (sizeof (t) != (sizeof(int)+sizeof(short)))
{
return 1;
}
else
{
return 0;
}
}

View File

@ -0,0 +1,41 @@
// Build don't link:
class A {
public:
int i;
A(int j) : i(j){}
};
class B : protected A {
public:
B(int j) : A(j){}
void f(){
A k(*this);
}
};
class C : protected B {
public:
C(int j) : B(j){}
void f();
void g(){
A k(i);
}
};
class D : public C {
public:
D(int w) : C(i) {}
void j() { A k(*this); }
void h() { i=3; }
};
void C::f() {
A k(*this);
}
B b(3);
main() {
A *z = &b; // ERROR -
}

View File

@ -0,0 +1,12 @@
// Build don't link:
class A {
public:
static int a;
};
class B : public A {
public:
static int b;
};
int B::a; // ERROR -

View File

@ -0,0 +1,27 @@
// Build don't link:
// prms-id: 10038
template < class Referencee >
class Referencer
{
public:
Referencer (Referencee const * pReferencee);
};
template <class T>
class Array
{
public:
int addElement (T const & e);
int addElement ();
};
class ScenarioGroup;
class ScenarioSet : public Array< Referencer<ScenarioGroup> >
{
typedef Array< Referencer<ScenarioGroup> > arrayBase;
void addElement(ScenarioGroup *group)
{
arrayBase::addElement(group);
}
};

View File

@ -0,0 +1,49 @@
// Build don't link:
// prms-id: 10046
template <class T>
class Array
{
public:
T const & operator[] (int i) const;
};
class Referenceable {};
template < class Referencee >
class Referencer
{
public:
operator Referencee *() const { return i_referencee; }
protected:
Referencee* i_referencee;
};
class ScenarioGroup {};
class ScenarioSpace;
class ScenarioSet : public Referenceable,
public Array< Referencer<ScenarioGroup> >
{
public:
ScenarioSet& operator=(ScenarioSet const & s);
};
class ScenarioSpace : public Referenceable,
public Array< Referencer<ScenarioSet> >
{
};
class ScenarioSetNameSelector
{
public:
bool operator () (ScenarioSpace &space)
{
int idx;
i_set = space[idx];
return false;
}
private:
ScenarioSet *i_set;
};

View File

@ -0,0 +1,48 @@
// Build don't link:
// prms-id: 9979
template < class Referencee >
class Referencer
{
public:
Referencer() {}
};
template <class T>
class List
{
public:
List() {}
};
template<class T, class KEY>
class Dictionary
{
public:
Dictionary() : i_buckets (new List<T>[1234]) {}
~Dictionary() { delete [] i_buckets; }
List<T> * i_buckets;
};
class Exchangeable {};
class ExchangeableHandle {};
class ExchangeableList
: public Dictionary<Referencer<Exchangeable>, ExchangeableHandle>
{
public:
ExchangeableList(int size=0);
};
class ObjectExchange
{
public:
ObjectExchange() {};
ExchangeableList i_theWatchList; // Instruments being monitored
};
main()
{
}

View File

@ -0,0 +1,20 @@
// prms-id: 10166
template <class A>
class B {
public:
int f() {
for(int x=0;x<10;x++) {
continue;
return 1;
}
return 0;
}
private:
A w;
};
main() {
B<int> c;
return c.f();
}

View File

@ -0,0 +1,41 @@
Note: nest4 misses a syntax error
abstract - abstract functions
alignof - gcc alignof builtin
ambiguity - diagnosing ambiguities
arm - ARM cases
array-refs - arrays of references
bit-fields - bit fields
chainon - deaths cuz we call chainon() incorrectly
copy - copy constructors
crash - old compiler crashes/aborts
cvt - user-defined conversions
def-fns - default function generation (in add'n to copy)
enum-clash - int vs enum
enum - enumerated types
err-msg - error messages
friend - dealing with friend functions and classes
groff - crashes derived from groff code
init - initialization bugs
label - handling labels
line - line numbers in error messages
misc - miscellaneous tests that didn't fit another category
nest - nested types
new-array - doing new of an array
new - generic operator new bugs
operators - tests for various overloaded operators
parse - parser bugs
prepost - prefix/postfix operator ++/--
ptolemy - bugs derived from ptolemy
recurse - infinite recursion in the compiler
redecl - handling redeclarations
scope - managing scopes
shadow - shadowing of params, etc
sizeof - ARM compliance w/ sizeof operator
sorry - old "sorry, not implemented" messages
static - handling static data
template - template bugs
union - handling unions
visibility - access control and visibility checking
warnings - warning messages

View File

@ -0,0 +1,25 @@
// Build don't link:
// GROUPS passed abstract-functions
class O
{
public:
virtual int c()=0;
};
class I: public O
{
};
class S: public virtual I
{
public:
int c();
virtual int v()=0;
};
class D: public S
{
int v();
};
D *p=new D();

View File

@ -0,0 +1,23 @@
// Build don't link:
// GROUPS passed access-control
class Base
{
protected:
virtual void DoSomething() = 0;
};
class Fibber : public Base
{
public:
void DoBP() {
DoSomething();
}
};
class Flat : public virtual Fibber
{
public:
void DoIt() {
DoSomething();
}
};

View File

@ -0,0 +1,13 @@
// Build don't link:
// GROUPS passed extensions
struct bar { int bit : 1; };
void foo (int *r, bar t)
{
// doing alignof on a bit-field should be illegal
__alignof__ (t.bit);// ERROR - .*
// both of these (a regular ref and an INDIRECT_REF) should work
__alignof__ (r);
__alignof__ (*r);
}

View File

@ -0,0 +1,17 @@
// Build don't link:
// GROUPS passed ambiguity
struct A {
A (int);
};
struct B {
B (int);
};
void myfunc (const A& t0); // ERROR -
void myfunc (const B& t0); // ERROR -
int main ()
{
myfunc(1); // ERROR - ambiguous call
}

View File

@ -0,0 +1,7 @@
// Build don't link:
// GROUPS passed anonymous-unions
static union {
char* uC;
private:
int uI;// ERROR - .*private member.*
};

View File

@ -0,0 +1,10 @@
// Build don't link:
// Special g++ Options: -pedantic-errors
// GROUPS passed ARM-compliance
// ARM $5.7, it's illegal to do math on a `void*'.
main()
{
void *p;
++p;// ERROR - .*
}

View File

@ -0,0 +1,19 @@
// Build don't link:
// GROUPS passed ARM-compliance
// ARM 9.4 ``There cannot be a static and a nonstatic member function
// with the same name and the same argument types.''
//
// The trick is to make sure it's caught with both orders (static,
// then normal, and vice-versa.
class X {
public:
int foo();
static int foo(); // error: redeclaration// ERROR - .*
};
class Y {
public:
static int foo();
int foo(); // error: redeclaration// ERROR - .*
};

View File

@ -0,0 +1,9 @@
// Build don't link:
// GROUPS passed initialization
// ARM $11.4: A function first declared in a friend decl is equivalent
// to an extern decl, so the below is illegal.
class X {
friend g(); // ERROR - previous declaration
};
static g() { return 1; }// ERROR - previously declared

View File

@ -0,0 +1,6 @@
// Build don't link:
// GROUPS passed arm
int a, b;
// declaring an array of references should be illegal
int & v[ 2] = { a, b};// ERROR - .*

View File

@ -0,0 +1,7 @@
// Build don't link:
// Special g++ Options: -fconserve-space -fcommon
// GROUPS passed array-bindings
// excess errors test - XFAIL sparc64-*-*
extern "C" void printf (char *, ...);
char array[(unsigned) 0x90000000];// ERROR - overflow in array dimension.* , XFAIL sparc64-*-* alpha*-*-*
int main () { printf ("PASS\n"); return 0; }

View File

@ -0,0 +1,14 @@
// Build don't link:
// Special g++ Options: -S
// GROUPS passed asm-extension
// excess errors test - XFAIL a29k-*-*
// This used to crash because c_expand_asm_keyword didn't know what to
// do with this. The parser rules were changed to accept an expr, instead
// of a stmt.
extern void traptable(void);
main()
{
asm("wr %0,%%tbr" : : "r" (traptable));
}

View File

@ -0,0 +1,5 @@
// Build don't link:
// GROUPS passed bit-fields
struct bar {
int : 2 = 1;// ERROR - .*
};

View File

@ -0,0 +1,13 @@
// Build don't link:
// GROUPS passed bit-fields
struct {
char c;
int i:8;
} s;
main()
{
int &ir = s.i;
int *ip = &s.i;// ERROR - .* , XFAIL *-*-*
ir = 10;
}

View File

@ -0,0 +1,11 @@
// Build don't link:
// GROUPS passed boolean
main()
{
typedef char Boolean; // Instrinsic.h
Boolean c = false;
bool b = true;
if (!c != !b)
;
}

View File

@ -0,0 +1,40 @@
// GROUPS passed code-generation
// Check that sub-word sized structs/classes are passed correctly
// if the struct/class has a constructor (i.e. ANY constructor).
extern "C" void printf (char *, ...);
struct base {
unsigned int f1 : 8;
unsigned int f2 : 8;
base (int ii)
{
}
};
base global_base (7);
int test2 (base formal_base);
int main ()
{
global_base.f1 = 0x55;
global_base.f2 = 0xee;
if (test2 (global_base) == 0)
printf ("PASS\n");
else
printf ("FAIL\n");
return 0;
}
int test2 (base formal_base)
{
if (formal_base.f1 != global_base.f1)
return -1;
if (formal_base.f2 != global_base.f2)
return -1;
return 0;
}

View File

@ -0,0 +1,18 @@
// GROUPS passed code-generation
// Check that declarations with initializations are executed
// correctly.
extern "C" void printf (char *, ...);
int main ()
{
char buff[40] ;
char *tmp = &buff[0]; // also fails for char *tmp = buff;
if ((unsigned int) tmp != (unsigned int) &buff[0])
printf ("FAIL\n");
else
printf ("PASS\n");
return 0;
}

View File

@ -0,0 +1,34 @@
// GROUPS passed code-generation
// Check that passing things which are not a multiple of
// 4 bytes in size doesn't mess up other subsequent parameters.
extern "C" void printf (char *, ...);
struct base {
int f1 : 8;
int f2 : 8;
};
base global_base;
int val1;
int test2 (struct base formal_base, int v1);
int main ()
{
val1 = 0x5e5e;
return test2 (global_base, val1);
}
int test2 (struct base formal_base, int v1)
{
formal_base.f1 = formal_base.f2; // prevent warnings
if (v1 != 0x5e5e)
printf ("FAIL\n");
else
printf ("PASS\n");
return 0;
}

View File

@ -0,0 +1,31 @@
// Special g++ Options: -O
// GROUPS passed code-generation
// Options: -O
//
// Check that when an int value is assigned to a short int, the proper
// half of the int (i.e. the low order half) ends up in the short.
//
// This fails with 1.32.0 with -O and f1() is inline.
//
// Workaround - declare "f1_arg" as type "short int".
extern "C" void printf (char *, ...);
short int v2;
long v1 = 0x11117777;
inline void f1 (long f1_arg)
{
v2 = f1_arg;
}
int main ()
{
f1 (v1);
if (v2 != 0x00007777)
printf ("FAIL\n");
else
printf ("PASS\n");
}

View File

@ -0,0 +1,57 @@
// Special g++ Options: -fthis-is-variable
// GROUPS passed code-generation
// Check that the "this" pointer is zero when a method is
// called for an object pointed to by a null pointer.
// Normally, the "__builtin_new" operation which actually
// allocates objects in heap space is *not* called at the
// actual point of the "new" keyword. Rather, a check is
// made within each constructor and if the "this" pointer
// value passed in is zero, then the actual allocation of
// memory (via __builtin_new) is done at that point (i.e.
// at the very beginning of the constructor).
// A special trick allows one to subvert this mechanism.
// Specifically, if a given constructor contains a statement
// like: "this = this", then no attempt will be made to
// implicitly call __builtin_new within that constructor.
extern "C" void printf (char *, ...);
struct base {
int member;
base ();
void member_function ();
};
base *base_pointer_1 = 0;
base *base_pointer_2 = 0;
int errors = 0;
int main ()
{
//base_pointer_2 = new base();
base_pointer_1->member_function ();
if (errors)
printf ("FAIL\n");
else
printf ("PASS\n");
return 0;
}
base::base ()
{
this = this;
if ((int) this != 0)
errors++;
}
void base::member_function ()
{
if ((int) this != 0)
errors++;
}

View File

@ -0,0 +1,54 @@
// GROUPS passed code-generation
// Check that type float parameters can be correctly passed to
// methods.
extern "C" void printf (char *, ...);
class tres_floats {
float ff1;
float ff2;
float ff3;
public:
tres_floats (float f1, float f2, float f3);
float get_f1 ();
float get_f2 ();
float get_f3 ();
};
float v1 = 1.2345;
float v2 = 3.14159;
float v3 = 0.707;
int main ()
{
tres_floats tf (v1, v2, v3);
if ((tf.get_f1() != v1) || (tf.get_f2() != v2) || (tf.get_f3() != v3))
printf ("FAIL\n");
else
printf ("PASS\n");
return 0;
}
tres_floats::tres_floats (float f1, float f2, float f3)
{
ff1 = f1;
ff2 = f2;
ff3 = f3;
}
float tres_floats::get_f1 ()
{
return ff1;
}
float tres_floats::get_f2 ()
{
return ff2;
}
float tres_floats::get_f3 ()
{
return ff3;
}

View File

@ -0,0 +1,21 @@
// GROUPS passed copy-ctors
extern "C" void printf (char *, ...);
int count = 0;
class C {
public:
C (int) { count++; }
operator int () { return 0; }
};
main ()
{
C c1 (1);
C c2 (c1);
if (count != 1)
printf ("FAIL\n");
else
printf ("PASS\n");
}

View File

@ -0,0 +1,79 @@
// GROUPS passed copy-ctors
/*
The old g++ output is
Item()
Compound()
Pre foo
foo
~Compound()
~Item()
Post foo
~Compound()
~Item()
The output should be something like (produced from ATT 2.1)
Item()
Compound()
Pre foo
Item(const Item& i) <------ missing above
foo
~Compound()
~Item()
Post foo
~Compound()
~Item()
*/
extern "C" void printf (char *, ...);
extern "C" void exit (int);
int count = 0;
void
die (int x)
{
if (x != ++count)
{
printf ("FAIL\n");
exit (1);
}
}
class Item {
public:
Item() { die (1); }
Item(const Item& i) { die (4); }
~Item() { count++; if (count != 7 && count != 10) die (-1); }
};
class Compound {
Item i;
public:
Compound() { die (2); }
~Compound() { count++; if (count != 6 && count != 9) die (-1); }
};
void foo(Compound a)
{
die (5);
}
main()
{
Compound a;
die (3);
foo(a);
die (8);
printf ("PASS\n");
}

View File

@ -0,0 +1,57 @@
// GROUPS passed copy-ctors
/*
If I compile it with cfront (AT&T C++ Translator 2.00.02 08/25/89) and run it
I get:
A::A()
A::A(const A&)
B::Bar()
A::~A()
A::~A()
If I compile it with g++ (gcc version 2.2.2) and run it I get:
A::A()
B::Bar()
A::~A()
A::~A()
*/
extern "C" void printf (char *, ...);
extern "C" void exit (int);
int count = 0;
void
die (int x)
{
if (x != ++count)
{
printf ("FAIL\n");
exit (1);
}
}
class A {
public:
A() { die (1); }
A(const A&) { die (2); }
~A() { count++; if (count != 4 && count != 5) die (-1); }
};
class B : public A {
public:
void Bar() { die (3); }
};
void Foo(B b) { b.Bar(); }
main()
{
B b;
Foo(b);
printf ("PASS\n");
}

View File

@ -0,0 +1,58 @@
// GROUPS passed copy-ctors
// Using Cfront 3.0.1 the programm below prints
//
// A()
// A(const A& a)
// ~A()
// A(A& a) <---- !!!
// ~A()
// ~A()
//
// the g++ 2.2.2 (sparc-sun-sunos4.1) generated code prints
//
// A()
// A(const A& a)
// ~A()
// A(const A& a) <---- !!!
// ~A()
// ~A()
extern "C" void printf (char *, ...);
extern "C" void exit (int);
int count = 0;
void
die (int x)
{
if (x != ++count)
{
printf ("FAIL\n");
exit (1);
}
}
class A {
public:
A() { die (1); }
A(const A& a) { die (2); }
A(A& a) { die (4); }
~A() { count++; if (count != 3 && count != 5 && count != 6) die (-1); }
};
void foo1(const A& a) {
A b = a;
}
void foo2( A& a) {
A b = a;
}
int main() {
A a;
foo1(a);
foo2(a);
printf ("PASS\n");
}

View File

@ -0,0 +1,84 @@
// GROUPS passed copy-ctors
/*
bad:
sibelius402> a.out
a=5 a.virtMember()=30
BaseClass::Increm --> {i=5, virtMember()=30}
a=7 a.virtMember()=30
b=7 b.virtMember()=30
BaseClass::Increm --> {i=7, virtMember()=999}
b=9 b.virtMember()=30
sibelius403>
good:
sibelius406> a.out
a=5 a.virtMember()=30
BaseClass::Increm --> {i=5, virtMember()=30}
a=7 a.virtMember()=30
b=7 b.virtMember()=30
BaseClass::Increm --> {i=7, virtMember()=30}
b=9 b.virtMember()=30
*/
extern "C" void printf (char *, ...);
extern "C" void exit (int);
void die () { printf ("FAIL\n"); exit (1); }
class BaseClass {
friend int operator != (const BaseClass irv, int x);
int i;
public:
BaseClass( const BaseClass& ir ) : i(ir.i) {};
BaseClass() : i(5) {};
virtual int virtMember() { return( 999 ); };
void Increm( int r );
};
void BaseClass::Increm( int r )
{
if ((i == 5 && virtMember () == 30)
|| (i == 7 && virtMember () == 30))
i += r;
else
die ();
};
class DerivedClass : public BaseClass {
public:
int virtMember() { return( 30 ); };
};
int operator != (const BaseClass irv, int x) { return irv.i != x; }
main ()
{
DerivedClass a;
if (a != 5 || a.virtMember () != 30)
die ();
a.Increm(2);
if (a != 7 || a.virtMember () != 30)
die ();
DerivedClass b = a;
if (b != 7 || a.virtMember () != 30)
die ();
b.Increm(2);
if (b != 9 || a.virtMember () != 30)
die ();
printf ("PASS\n");
}

View File

@ -0,0 +1,55 @@
// GROUPS passed copy-ctors
/*
g++ 2.3.3 will prefer using type conversions over the
implicitly generated copy constructor. This is wrong.
If you explicitly define a copy constructor, it will
use it. However, the implicit copy constructor MUST be
called whenever an explicit one would have been called
also. See below: g++ converts from and back into
unsigned, instead of using the implicit copy constructor:
here is the version:
Reading specs from /usr/lib/gcc-lib/i386-linux/2.3.3/specs
gcc version 2.3.3
/usr/lib/gcc-lib/i386-linux/2.3.3/cpp -lang-c++ -v -undef -D__GNUC__=2 -D__GNUG__=2 -D__cplusplus -Dunix -Di386 -Dlinux -D__unix__ -D__i386__ -D__linux__ -D__unix -D__i386 -D__linux bug2.cc /usr/tmp/cca02008.i
GNU CPP version 2.3.3 (80386, BSD syntax)
/usr/lib/gcc-lib/i386-linux/2.3.3/cc1plus /usr/tmp/cca02008.i -quiet -dumpbase bug2.cc -version -o /usr/tmp/cca02008.s
GNU C++ version 2.3.3 (80386, BSD syntax) compiled by GNU C version 2.3.3.
as -o /usr/tmp/cca020081.o /usr/tmp/cca02008.s
ld /usr/lib/crt0.o -nojump -L/usr/lib/gcc-lib/i386-linux/2.3.3 /usr/tmp/cca020081.o -lg++ -lgcc -lc -lgcc
Ok, and here is the output:
test k: constructing from scratch
test l=k: type conversion into unsigned
constructing from unsigned
*/
extern "C" void printf (char *, ...);
extern "C" void exit (int);
int count = 0;
void die () { printf ("FAIL\n"); exit (1); }
struct test {
test() { if (count != 0) die (); }
test(unsigned) {
die ();
}
operator unsigned() {
die ();
return 0;
}
};
int
main() {
test k;
test l=k;
printf ("PASS\n");
return 0;
}

View File

@ -0,0 +1,29 @@
// GROUPS passed copy-ctors
extern "C" void printf (char *, ...);
extern "C" void exit (int);
void die () { printf ("FAIL\n"); exit (1); }
class B {
public:
B() {}
B(const B &) { printf ("PASS\n"); exit (0); };
private:
int x;
};
class A : public B {
public:
A() {}
A(const B &) { printf ("FAIL\n"); exit (1); }
};
main()
{
A a;
A b(a);
printf ("FAIL\n");
return 0;
}

View File

@ -0,0 +1,67 @@
// GROUPS passed copy-ctors
/*
This report is for GCC 2.3.3 running on a Sun/4. The bug is that when
a class instance is passed-by-value, GCC does not correctly copy the value.
At the end of this report is an example program that demonstrates the bug.
It should print:
construct A('x')
copy A('x')
destruct A('x')
destruct A('x')
and in fact does for IBM's xlC C++. However, for GCC 2.3.3, it fails
to print the second line ["copy A('x')"], which indicates that it failed
to call the copy-constructor for class A when it should have. Below is a
typescript that lists the program, shows how I compiled it, and shows the
incorrect output.
*/
extern "C" void printf (char *, ...);
extern "C" void exit (int);
int count = 0;
void
die (int x)
{
if (x != ++count)
{
printf ("FAIL\n");
exit (1);
}
}
class A { // Class with explicit & instrumented copy-constructor and destructor.
public:
const char * id;
A( const char * id1 ) : id(id1) { die (1); }
// Copy constructor
A( const A& a ) : id(a.id) { die (2); }
// Destructor
~A() { count++; if (count != 3 && count != 4) die (-1); }
};
class X { // Class without explicit copy-constructor
private:
A a;
public:
X( const char * id ) : a(id) {}
};
void Func( X x ) { // Function with call-by-value argument
}
int
main() {
X x("x"); // Construct instance of x.
// The next line should call the copy-constructor for X since x is
// being passed by value. For GCC 2.3.3 on a Sun/4, it does not.
Func(x);
printf ("PASS\n");
return 0;
}

View File

@ -0,0 +1,40 @@
// GROUPS passed copy-ctors
#include <iostream.h>
// token types: from state parser
const int T_EOF = 257;
const int T_ERROR = 258;
const int T_Float = 259;
const int T_Int = 260;
const int T_ID = 261;
const int T_STRING = 262;
class Complex;
class State;
// token, from state parser.
class ParseToken {
public:
int tok;
union {
char cval;
const char *sval;
int intval;
double doubleval;
Complex* Complexval;
const State* s;
};
ParseToken () { tok = 0; intval = 0;}
};
main () {
ParseToken a;
a.tok = T_Float;
a.doubleval = 23.2;
ParseToken b(a);
if (b.doubleval == 23.2)
cout << "PASS\n";
else
cout << "FAIL\n";
}

View File

@ -0,0 +1,44 @@
// Build don't link:
// GROUPS passed old-abort
class D_Interval;
class Date
{
public:
Date(const D_Interval*,const Date&);
private:
const D_Interval* interval;
};
class Time_Interval
{
public:
Time_Interval(const Date& start,const Date& stop);
const Date& Start() const { return start; }
const Date& Stop() const { return stop; }
private:
Date start;
Date stop;
};
class Dated_Data
{
public:
Dated_Data(const Time_Interval& dates);
virtual ~Dated_Data();
Time_Interval Dates() const { return dates; }
private:
Time_Interval dates;
};
class Raw_Data : public Dated_Data
{
public:
Raw_Data(const Dated_Data *source,const D_Interval& period);
};
Raw_Data::Raw_Data(const Dated_Data *source,const D_Interval& period)
: Dated_Data(Time_Interval(Date(&period,source->Dates().Start()),
Date(&period,source->Dates().Stop())))
{
}

View File

@ -0,0 +1,28 @@
// Build don't link:
// GROUPS passed old-abort
class word
{
unsigned char b1, b2;
public:
word (unsigned int i = 0) { b1 = i & 0xff; b2 = (i & 0xff00) >> 8; }
operator unsigned int () { return (b2 << 8) + b1; }
};
class just_another
{
int foo;
char bar[23];
};
int mumble(word w)
{
just_another *jap;
unsigned bar;
bar = w;
jap = new just_another [w];
return 0;
}

View File

@ -0,0 +1,23 @@
// Build don't link:
// GROUPS passed old-abort
extern "C" void printf (char *, ...);
class A {
int i;
int j;
public:
int h;
A() { i=10; j=20; }
virtual void f1() { printf("i=%d j=%d\n",i,j); }
friend virtual void f2() { printf("i=%d j=%d\n",i,j); }// ERROR - virtual.*
};
class B : public A {
public:
virtual void f1() { printf("i=%d j=%d\n",i,j); }// ERROR - member.*// ERROR - member.*
friend virtual void f2() { printf("i=%d j=%d\n",i,j); }// ERROR - virtual.*// ERROR - member.*// ERROR - member.*
};
main() {
A * a = new A;
}

View File

@ -0,0 +1,10 @@
// Build don't link:
// GROUPS passed old-abort
class X
{
int i;
public:
X(int j);
}
X *x = new X[10]();// ERROR - .*

View File

@ -0,0 +1,35 @@
// Build don't link:
// GROUPS passed old-abort
class gen_op
{
public:
gen_op ( );
gen_op (const gen_op &Op1);
~gen_op ( );
void operator = (const gen_op &Op1);
};
class spin_op
{
public:
spin_op();
spin_op(const spin_op& SOp);
~spin_op();
void operator= (const spin_op& SOp);
operator gen_op();
};
spin_op Fe();
gen_op Spul_U_axis()
{
gen_op U1;
U1 = Fe();
}; // ERROR - reaches end of non-void function
main () {};

View File

@ -0,0 +1,23 @@
// Build don't link:
// GROUPS passed old-abort
extern "C" void printf (char *, ...);
class cl
{
int i;
public:
cl(int j = 0) {i = j;}
int get_i() {return i;}
};
main()
{
cl ob[3] = {1, 2, 3};
int i;
for(i=0; i<3; i++)
printf("%d\n", ob[i].get_i());
return 0;
}

View File

@ -0,0 +1,21 @@
// Build don't link:
// GROUPS passed old-abort
#include <iostream.h>
class A {
public:
virtual ~A() {cout << "executed ~A()\n";};
};
class B : public A {
public:
virtual ~B() {cout << "executed ~B()\n";};
};
main() {
cout << "starting\n";
B b;
b.~A();// ERROR - destructor
cout << "done\n";
};

View File

@ -0,0 +1,12 @@
// Build don't link:
// GROUPS passed old-abort
class Graph {
public:
unsigned char N;
Graph(void) {}; // ERROR - previously defined here
}
Graph::Graph(void)
{ N = 10;// ERROR - return type.*
}

View File

@ -0,0 +1,35 @@
// Build don't link:
// GROUPS passed old-abort
//
// This one creates
//
// gcc2: Internal compiler error: program cc1plus got fatal signal 11
//
// when compiled with g++.
// The error goes away, if
// 1) int ClassInvariant() is not virtual or
// 2) GnObject has a virtual destructor or
// 3) GnWidget has no virtual destructor or
// 4) GnContracts has a virtual destructor
//
class GnContracts {
public:
virtual int ClassInvariant();
// virtual ~GnContracts();
};
class GnObject : public GnContracts {
public:
// virtual ~GnObject();
};
class GnWidget : public GnObject {
public:
virtual ~GnWidget();
};
class GnOptionGroup : public GnObject, public GnWidget {
};// ERROR - warning

View File

@ -0,0 +1,17 @@
// Build don't link:
// GROUPS passed old-abort
typedef int element;
class Pix {
public:
Pix();
Pix(const Pix&);
// Friend functions so that v == x works as does x == v works
friend int operator==(void *v, const Pix& x)
{ return v == index; }// ERROR - .*
friend int operator==(void *v, const Pix& x)
{ return v != index; }// ERROR - .*
private:
// friend class List<T>;
element *index;
};

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,10 @@
// Build don't link:
// GROUPS passed old-abort
// The compiler used to crash on this example.
class x {
public:
x();
static const x y[23];
};
const x x::y[23];

View File

@ -0,0 +1,13 @@
// Build don't link:
// GROUPS passed old-abort
#include <Complex.h>
Complex ComputeVVself()
{
Complex temp1;
Complex self[3][3];
self[1][2] = 100.0;
return self[1][2];
}

View File

@ -0,0 +1,11 @@
// Build don't link:
// GROUPS passed old-abort
struct A {
void a1();
void a2();
};
struct B {
void A::a1(); // this used to die in chainon(), now grokdeclarator should// ERROR - cannot declare.*
void A::a2(); // should be fixed by the 930629 change.// ERROR - cannot declare.*
};

View File

@ -0,0 +1,15 @@
// Build don't link:
// GROUPS passed old-abort
// This used to die in chainon; it shouldn't any more.
class A
{
public:
class B {
public:
void f ();
void g (int);
};
void B::f () {}// ERROR - .*
void B::g (int val) {}// ERROR - .*
};

View File

@ -0,0 +1,19 @@
// Build don't link:
// Special g++ Options: -O
// GROUPS passed old-abort
// gcc puts the array into a register, and then the store_bit_field () code
// in expmed.c gets confused when it tries to store zero past the end of the
// register (because the index is past the array bounds). It ends up calling
// store_split_bit_field, which then aborts, because we don't have a split bit
// field.
//
// Seems easiest to detect this case in the front end, i.e. access outside the
// array bounds, and then force the array to be allocated on the stack instead
// of a register.
main()
{
char i[1];
i[1] = 0;
}

View File

@ -0,0 +1,18 @@
// Build don't link:
// GROUPS passed old-abort
class memo{
public:
static int rep;
};
class port_head : public memo {
public:
static int rep;
unsigned cap();
};
class buff_head : private port_head {
public:
static int rep;
port_head::cap;
};

View File

@ -0,0 +1,11 @@
// Build don't link:
// GROUPS passed old-abort
struct B {
B();
};
class C : virtual public B
{
public:
C() { }
};

View File

@ -0,0 +1,20 @@
// Build don't link:
// GROUPS passed old-abort
class First {
public:
First(const First& a);
};
class Second {
int i;
First f;
public:
~Second() {}
Second func();
};
void foo()
{
extern Second x;
x = x.func();
}

View File

@ -0,0 +1,12 @@
// Build don't link:
// GROUPS passed old-abort
class abc
{
public:
void F() { return; }
private:
typedef int myint;
typedef struct { int b; } mystruct;
typedef union { int c; } myunion;
};

View File

@ -0,0 +1,18 @@
// Build don't link:
// GROUPS passed old-abort
union Value
{
Value(){}
};
struct GlobalAddress
{
GlobalAddress(Value *nvar){}// ERROR - .*
};// ERROR - candidates .*
main()
{
new GlobalAddress(Value()); // internal error occured here// ERROR - no matching function .*
//new GlobalAddress(new Value()); // This line is correct code
}

View File

@ -0,0 +1,14 @@
// Build don't link:
// GROUPS passed old-abort
int strcmp();
extern "C" {
// dies in common_type, cuz the TREE_TYPE of t2 is 0, so it can't get its
// TYPE_MAIN_VARIANT value.
// <void_type 184510 void permanent VOID
// size <integer_cst 1844e0 type <integer_type 182548 int> constant permanent 0
// align 1 symtab 0
// pointer_to_this <pointer_type 1845e0>
int strcmp(const char*, const char*);
}

View File

@ -0,0 +1,9 @@
// Build don't link:
// GROUPS passed old-abort
#include <String.h>
main(void) {
String a[] = {"Hello"};
}

View File

@ -0,0 +1,16 @@
// Build don't link:
// GROUPS passed old-abort
struct mbuf {
struct mbuf *next;
};
void* malloc(int);
struct mbuf *
mbuf_allocate(int size)
{
struct mbuf *bp;
bp = (struct mbuf *) malloc( 10 /*(unsigned) (size + sizeof(struct mbuf))*/);
return bp;
}

View File

@ -0,0 +1,5 @@
// Build don't link:
// Special g++ Options: -fshort-enums
// GROUPS passed old-abort
enum Bool { FALSE, TRUE };
Bool foo () { return TRUE; }

View File

@ -0,0 +1,6 @@
// Build don't link:
// GROUPS passed old-abort
extern void foo(void *);
main() {
foo((struct bar *)0);
}

View File

@ -0,0 +1,3 @@
// Build don't link:
// GROUPS passed old-abort
operator int () {}// ERROR - .*// ERROR - .*

View File

@ -0,0 +1,20 @@
// Build don't link:
// GROUPS passed old-abort
const unsigned int ENET_INTERRUPT_MID = 5;
extern "C" void ENET_RxP();
class EnetReceiver
{
public:
friend void ENET_RxP();
void receiveMessage();
int *messagePointer;
};
void EnetReceiver::receiveMessage()
{
if (*((unsigned int*) messagePointer) == ENET_INTERRUPT_MID)
{
}
}

View File

@ -0,0 +1,7 @@
// Build don't link:
// GROUPS passed old-abort
struct wait { int w_status; };
int wait();
extern "C" int wait(int*);

View File

@ -0,0 +1,16 @@
// Build don't link:
// GROUPS passed old-abort
typedef int _sigset_t;
extern "C" {
extern int sigaction(int signo, const struct sigaction *action_spec_p, struct sigaction *old_action_p);
}
extern "C" {
extern void foo();
};
class SS {
friend void foo();
protected:
void goo();
};
inline void
SS::goo() { }

View File

@ -0,0 +1,42 @@
// Build don't link:
// GROUPS passed old-abort
/*
I received the following message when using g++ (version 2.3.3):
main.cc: In method 'Implicit<implicit<INTEGER,2>,3>::Implicit()':
main.cc: Internal compiler error 241.
main.cc: Please report this to 'bug-g++@prep.ai.mit.edu'
*/
#include <stream.h>
class INTEGER {
int x;
public:
typedef int BASE;
INTEGER(int y) : x(y) {}
INTEGER() {}
void encode() { cout << "Integer encoder";}
int operator=(int y) { x=y; return x; }
operator int() {return x; }
};
template< class T, int n> class Implicit : public T {
public:
typedef typename T::BASE BASE;
Implicit(BASE value ): T(value) {};
Implicit() : T() {};
int myTag() { return n; }
void encode() { T::encode(); }
BASE operator=(BASE t) { return T::operator=(t); }
};
main()
{
Implicit<Implicit<INTEGER, 2> , 3> y;
y = 10;
};

View File

@ -0,0 +1,8 @@
// Build don't link:
// Special g++ Options: -w
// GROUPS passed old-abort
#include <GetOpt.h>
#include <String.h>
class foo {public: foo () {}};
class bar {public: bar (foo& dflt);};
class baz: public bar {public: baz (): bar (foo ()) {}};

View File

@ -0,0 +1,6 @@
// Build don't link:
// GROUPS passed old-abort
typedef struct Thing {
Thing();
int x;
} Thing;

View File

@ -0,0 +1,17 @@
// Build don't link:
// GROUPS passed old-abort
class foo {
public:
virtual foo &operator <<(foo &(foo::*)(foo &));
};
foo &foo::operator<<(foo &(foo::*manip)(foo &))
{
(this->*manip)(*this);
return *this;
}

View File

@ -0,0 +1,11 @@
// Build don't link:
// GROUPS passed old-abort
typedef void (**ppfn)(void);
int main() {
ppfn fn;
fn = new (void(*)(void));
return 0;
}

View File

@ -0,0 +1,6 @@
// GROUPS passed old-abort
// Build don't link:
int fn();// ERROR - ambiguates.*
int x;
int& fn() {// ERROR - new decl.*
return x;}

View File

@ -0,0 +1,25 @@
// Build don't link:
// Special g++ Options: -g -fno-strict-prototype
// GROUPS passed old-abort
// excess errors test - XFAIL sparc64-*-elf
extern "C" { typedef int jmp_buf[12]; }
enum Error { NO_ERROR };
class ErrorHandler
{
ErrorHandler *previous;
static ErrorHandler *error_stack;
jmp_buf error_buffer;
protected:
static void pop()
{
error_stack = error_stack->previous;
}
public:
jmp_buf *push()
{
previous = error_stack;
error_stack = this;
return &error_buffer;
}
};

View File

@ -0,0 +1,26 @@
// Build don't link:
// GROUPS passed old-abort
template <class T> class bug {
public:
void Foo(const int = 0);
void NotRedeclared(const int);
private:
T TheItem;
};
template <class T> void bug<T>::NotRedeclared(const int)
{
}
template <class T> void bug<T>::Foo(const int)
{
}
main()
{
bug<char> InstantiatedBug;
return 0;
}

View File

@ -0,0 +1,3 @@
// Build don't link:
// GROUPS passed old-abort
void foo() { static const char *const v[] = { 0 }; }

View File

@ -0,0 +1,26 @@
// Build don't link:
// GROUPS passed old-abort
class Rational {
public:
Rational(int v): value(v)
{ }
int value;
};
typedef Rational __Rational;
extern int operator>(const Rational&, const Rational&);
class V {
public:
class Rational {
public:
static int x(const __Rational& value);
};
};
int
V::Rational::x(const __Rational& value)
{
return value > 0;
}

View File

@ -0,0 +1,93 @@
// Build don't link:
// GROUPS passed old-abort
const int TRUE = 1;
const int FALSE = 0;
class Rep {
protected:
Rep(): count(0)
{ }
Rep(const Rep& other): count(0)
{ }
Rep& operator=(const Rep& other)
{ /* DO NOT copy over other.count */
return *this; }
public: // TODO - for now
// Because it is to hard to restrict these operations to the descendants
// of Rep<REP> that we haven't named yet. So we just make them public.
void inc()
{ count++; }
void dec()
{ if (0 == --count) delete this; }
private:
unsigned count;
};
template<class REP>
class Ref {
public:
Ref(): rep(0)
{ }
Ref(const Ref<REP>& other): rep(other.rep)
{ if (rep) rep->inc(); }
~Ref()
{ if (rep) rep->dec();
rep = 0; }
Ref<REP>& operator=(const Ref<REP>& other)
{ if (rep != other.rep) {
if (rep) rep->dec();
rep = other.rep;
if (rep) rep->inc(); }
return *this; }
bool null() const
{ return 0 == rep ? TRUE: FALSE; }
bool valid() const
{ return 0 != rep ? TRUE: FALSE; }
REP* operator->() const // should be a valid() reference
{ return rep; }
operator REP*() const; // should be a valid() reference
protected:
REP *rep;
Ref(REP *r): rep(r)
{ if (rep) rep->inc(); }
Ref<REP>& operator=(REP *r)
{ if (rep != r) {
if (rep) rep->dec();
rep = r;
if (rep) rep->inc(); }
return *this; }
};
template<class REP>
Ref<REP>::operator REP*() const // should be a valid() reference
{ return rep; }
template<class REP>
inline int
operator==(const Ref<REP>& a, const Ref<REP>& b)
{ return (REP *) a == (REP *) b; }
template<class REP>
inline int
operator!=(const Ref<REP>& a, const Ref<REP>& b)
{ return (REP *) a != (REP *) b; }
class XRep: public Rep {
public:
int i;
};
main()
{
Ref<XRep> y;
return y != y;
}

View File

@ -0,0 +1,21 @@
// Build don't link:
// GROUPS passed old-abort
class internal {
int field;
int anotherfield;
}; // ERROR - candidates are
class bug {
internal* numbers;
bug(int size);
}; // ERROR - several errors
bug::bug(int size)
{ // ERROR - candidates
numbers = new internal(size * size);// ERROR - no match.*
}
main()
{
bug test;// ERROR - no match
}

View File

@ -0,0 +1,12 @@
// Build don't link:
// GROUPS passed old-abort
#include<iostream.h>
const /* int */ keys = 10;
const /* int */ key[keys] = {6, key[1], 2, keys, 1, 7, 6, key[2], key[8]};
void main()
{ // ERROR - return type for main
for(int i = 0; i < keys;) cout << key[i++] << " ";
endl(cout);
}

View File

@ -0,0 +1,106 @@
// Build don't link:
// GROUPS passed old-abort
// Should have been fixed by:
//
// Sun Jun 13 12:55:22 1993 Brendan Kehoe (brendan@lisa.cygnus.com)
//
// * cp-cvt.c (build_default_binary_type_conversion): Look deeper into
// what ARG1 and ARG2 are if they're POINTER_TYPEs.
volatile void exit(int);
class CountableSet
{
public:
virtual ~CountableSet() { }
};
template<class T>
class FixedSet : virtual public CountableSet
{
public:
virtual int Get(int, T&) = 0;
virtual ~FixedSet() { }
};
class ShrinkableSet
{
public:
virtual int Remove(int) = 0;
};
template<class T>
class PVSet : virtual public FixedSet<T>, virtual public ShrinkableSet
{
public:
virtual void Append(const T&) = 0;
virtual void operator+=(const T& a) { Append(a); }
virtual ~PVSet() { }
};
template<class T>
class MutSet : virtual public FixedSet<T>, virtual public FixedSet<T *>
{
protected:
typedef T *Tp;
public:
void Append(const Tp& tp) { Append(*tp); }
T& Access(int p)
{
Tp tp;
Get(p, tp);
return *tp;
}
virtual ~MutSet() { }
};
template <class T>
class SimpleSet : virtual public MutSet<T>
{
protected:
T *array;
int size;
virtual void Allocate(int s)
{
array = new T[s];
}
public:
SimpleSet()
{
size = 0;
array = ((void*)0) ; // ERROR - implicit conversion
}
int Get(int p, T& t)
{
t = array[p-1];
return 1;
}
int Get(int p, T *& t)
{
t = &array[p-1];
return 1;
}
inline void Append(const T& a)
{
array[size-1] = a;
}
inline int Remove(int n) { return 0; }
};
class Dummy
{
public:
Dummy() {}
};
main()
{
SimpleSet<Dummy *> bs1;
int i, j;
Dummy foo;
bs1+=&foo;// ERROR - no .*
}

Some files were not shown because too many files have changed in this diff Show More