diff options
Diffstat (limited to 'gcc/testsuite/g++.old-deja/g++.brendan')
310 files changed, 7221 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/README b/gcc/testsuite/g++.old-deja/g++.brendan/README new file mode 100644 index 000000000..93febfb35 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/README @@ -0,0 +1,46 @@ + +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 + + +Copyright (C) 1997, 1998 Free Software Foundation, Inc. + +Copying and distribution of this file, with or without modification, +are permitted in any medium without royalty provided the copyright +notice and this notice are preserved. diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/abstract1.C b/gcc/testsuite/g++.old-deja/g++.brendan/abstract1.C new file mode 100644 index 000000000..e37ee2eac --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/abstract1.C @@ -0,0 +1,25 @@ +// { dg-do assemble } +// 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(); diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/access1.C b/gcc/testsuite/g++.old-deja/g++.brendan/access1.C new file mode 100644 index 000000000..e2e3b2753 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/access1.C @@ -0,0 +1,23 @@ +// { dg-do assemble } +// 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(); + } +}; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/alignof.C b/gcc/testsuite/g++.old-deja/g++.brendan/alignof.C new file mode 100644 index 000000000..a79b65286 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/alignof.C @@ -0,0 +1,13 @@ +// { dg-do assemble } +// 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);// { dg-error "" } .* + + // both of these (a regular ref and an INDIRECT_REF) should work + __alignof__ (r); + __alignof__ (*r); +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/ambiguity1.C b/gcc/testsuite/g++.old-deja/g++.brendan/ambiguity1.C new file mode 100644 index 000000000..4706d7e8a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/ambiguity1.C @@ -0,0 +1,18 @@ +// { dg-do assemble } +// GROUPS passed ambiguity +struct A { + A (int); +}; + +struct B { + B (int); +}; + +void myfunc (const A& t0); // { dg-message "note" } +void myfunc (const B& t0); // { dg-message "note" } + +int main () +{ + myfunc(1); // { dg-error "ambiguous" } + // { dg-message "candidate" "candidate note" { target *-*-* } 16 } +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/anon-union1.C b/gcc/testsuite/g++.old-deja/g++.brendan/anon-union1.C new file mode 100644 index 000000000..3facea984 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/anon-union1.C @@ -0,0 +1,7 @@ +// { dg-do assemble } +// GROUPS passed anonymous-unions +static union { + char* uC; +private: + int uI;// { dg-error "" } .*private member.* +}; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/arm1.C b/gcc/testsuite/g++.old-deja/g++.brendan/arm1.C new file mode 100644 index 000000000..5cd4088a4 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/arm1.C @@ -0,0 +1,11 @@ +// { dg-do assemble } +// { dg-options "-pedantic-errors" } +// GROUPS passed ARM-compliance +// ARM $5.7, it's illegal to do math on a `void*'. + +int +main() +{ + void *p; + ++p;// { dg-error "" } .* +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/arm2.C b/gcc/testsuite/g++.old-deja/g++.brendan/arm2.C new file mode 100644 index 000000000..fb1ee429d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/arm2.C @@ -0,0 +1,19 @@ +// { dg-do assemble } +// 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(); // { dg-error "with" } + static int foo(); // error: redeclaration// { dg-error "overloaded" } .* +}; + +class Y { +public: + static int foo(); // { dg-error "with" } + int foo(); // error: redeclaration// { dg-error "overloaded" } .* +}; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/arm3.C b/gcc/testsuite/g++.old-deja/g++.brendan/arm3.C new file mode 100644 index 000000000..c636ebb7b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/arm3.C @@ -0,0 +1,9 @@ +// { dg-do assemble } +// 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(); // { dg-error "" } previous declaration +}; +static g() { return 1; }// { dg-error "" } previously declared diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/array-refs.C b/gcc/testsuite/g++.old-deja/g++.brendan/array-refs.C new file mode 100644 index 000000000..b834867de --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/array-refs.C @@ -0,0 +1,6 @@ +// { dg-do assemble } +// GROUPS passed arm +int a, b; + +// declaring an array of references should be illegal +int & v[ 2] = { a, b};// { dg-error "" } .* diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/array1.C b/gcc/testsuite/g++.old-deja/g++.brendan/array1.C new file mode 100644 index 000000000..a58d3363b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/array1.C @@ -0,0 +1,7 @@ +// { dg-do assemble } +// { dg-options "-fconserve-space -fcommon" } +// GROUPS passed array-bindings + +extern "C" int printf (const char *, ...); +char array[~(~((__SIZE_TYPE__)0ul)>>1)|~(((__SIZE_TYPE__)0ul)>>3)]; // { dg-error "" } overflow in array dimension.* +int main () { printf ("PASS\n"); return 0; } diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/asm-extn1.C b/gcc/testsuite/g++.old-deja/g++.brendan/asm-extn1.C new file mode 100644 index 000000000..3c39972ba --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/asm-extn1.C @@ -0,0 +1,13 @@ +// { dg-do assemble { target sparc-sun-* } } +// { dg-options "-S" } +// GROUPS passed asm-extension +// 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)); +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/bit-fields1.C b/gcc/testsuite/g++.old-deja/g++.brendan/bit-fields1.C new file mode 100644 index 000000000..9ff4c5d86 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/bit-fields1.C @@ -0,0 +1,5 @@ +// { dg-do assemble } +// GROUPS passed bit-fields +struct bar { + int : 2 = 1;// { dg-error "" } .* +}; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/bit-fields2.C b/gcc/testsuite/g++.old-deja/g++.brendan/bit-fields2.C new file mode 100644 index 000000000..394d03501 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/bit-fields2.C @@ -0,0 +1,13 @@ +// { dg-do assemble } +// GROUPS passed bit-fields + struct S { + char c; + int i:8; + } s; + + int main() + { + int &ir = s.i; // { dg-error "" } address of bitfield + int *ip = &s.i; // { dg-error "" } address of bitfield + ir = 10; + } diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/bool1.C b/gcc/testsuite/g++.old-deja/g++.brendan/bool1.C new file mode 100644 index 000000000..86754e324 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/bool1.C @@ -0,0 +1,12 @@ +// { dg-do assemble } +// GROUPS passed boolean +int +main() +{ + typedef char Boolean; // Instrinsic.h + Boolean c = false; + bool b = true; + + if (!c != !b) + ; +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/code-gen1.C b/gcc/testsuite/g++.old-deja/g++.brendan/code-gen1.C new file mode 100644 index 000000000..a8c9aba36 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/code-gen1.C @@ -0,0 +1,41 @@ +// { dg-do run } +// 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" int printf (const 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 1; } + + 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; +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/code-gen2.C b/gcc/testsuite/g++.old-deja/g++.brendan/code-gen2.C new file mode 100644 index 000000000..730f0f91f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/code-gen2.C @@ -0,0 +1,19 @@ +// { dg-do run } +// GROUPS passed code-generation +// Check that declarations with initializations are executed +// correctly. + +extern "C" int printf (const char *, ...); + +int main () +{ + char buff[40] ; + char *tmp = &buff[0]; // also fails for char *tmp = buff; + + if ((__SIZE_TYPE__) tmp != (__SIZE_TYPE__) &buff[0]) + { printf ("FAIL\n"); return 1; } + else + printf ("PASS\n"); + + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/code-gen3.C b/gcc/testsuite/g++.old-deja/g++.brendan/code-gen3.C new file mode 100644 index 000000000..62f8d7585 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/code-gen3.C @@ -0,0 +1,35 @@ +// { dg-do run } +// 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" int printf (const 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"); return 1; } + else + printf ("PASS\n"); + + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/code-gen4.C b/gcc/testsuite/g++.old-deja/g++.brendan/code-gen4.C new file mode 100644 index 000000000..80b1676cd --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/code-gen4.C @@ -0,0 +1,33 @@ +// { dg-do run } +// { dg-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". + +#include <stdio.h> +#include <stdlib.h> + +short int v2; + +long v1 = 0x11117777; + +inline void f1 (long f1_arg) +{ + v2 = f1_arg; +} + +int main () +{ + f1 (v1); + + if (v2 != 0x00007777) + abort (); + else + printf ("PASS\n"); +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/code-gen6.C b/gcc/testsuite/g++.old-deja/g++.brendan/code-gen6.C new file mode 100644 index 000000000..821038ef6 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/code-gen6.C @@ -0,0 +1,55 @@ +// { dg-do run } +// GROUPS passed code-generation +// Check that type float parameters can be correctly passed to +// methods. + +extern "C" int printf (const 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"); return 1; } + 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; +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/complex1.C b/gcc/testsuite/g++.old-deja/g++.brendan/complex1.C new file mode 100644 index 000000000..393941f88 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/complex1.C @@ -0,0 +1,29 @@ +// { dg-do run } +// { dg-options "" } + +// This test makes sure that the stuff in lex.c (real_yylex) is +// set up to handle real and imag numbers correctly. This test is against +// a bug where the compiler was not converting the integer `90' to a +// complex number, unless you did `90.0'. Fixed 10/1/1997. + +extern "C" { +int printf (const char *, ...); +void exit (int); +void abort (void); +} + +__complex__ double cd; + +int one = 1; + +int +main() +{ + cd = 1.0+90i; + cd *= one; + + if (__real__ cd != 1 || __imag__ cd != 90) + abort (); + + exit (0); +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/copy1.C b/gcc/testsuite/g++.old-deja/g++.brendan/copy1.C new file mode 100644 index 000000000..670cacd64 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/copy1.C @@ -0,0 +1,22 @@ +// { dg-do run } +// GROUPS passed copy-ctors +extern "C" int printf (const char *, ...); +int count = 0; + +class C { +public: + C (int) { count++; } + operator int () { return 0; } +}; + +int +main () +{ + C c1 (1); + C c2 (c1); + + if (count != 1) + { printf ("FAIL\n"); return 1; } + else + printf ("PASS\n"); +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/copy2.C b/gcc/testsuite/g++.old-deja/g++.brendan/copy2.C new file mode 100644 index 000000000..261e4f50a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/copy2.C @@ -0,0 +1,80 @@ +// { dg-do run } +// 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" int printf (const 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); +} + +int +main() +{ + Compound a; + + die (3); + foo(a); + + die (8); + + printf ("PASS\n"); +} + diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/copy3.C b/gcc/testsuite/g++.old-deja/g++.brendan/copy3.C new file mode 100644 index 000000000..c5675696b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/copy3.C @@ -0,0 +1,59 @@ +// { dg-do run } +// 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" int printf (const 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(); } + +int +main() +{ + B b; + Foo(b); + + printf ("PASS\n"); +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/copy4.C b/gcc/testsuite/g++.old-deja/g++.brendan/copy4.C new file mode 100644 index 000000000..bbb6c3e20 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/copy4.C @@ -0,0 +1,59 @@ +// { dg-do run } +// 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" int printf (const 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"); +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/copy5.C b/gcc/testsuite/g++.old-deja/g++.brendan/copy5.C new file mode 100644 index 000000000..c91559645 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/copy5.C @@ -0,0 +1,86 @@ +// { dg-do run } +// 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" int printf (const 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; } + +int +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"); +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/copy6.C b/gcc/testsuite/g++.old-deja/g++.brendan/copy6.C new file mode 100644 index 000000000..8e1513190 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/copy6.C @@ -0,0 +1,56 @@ +// { dg-do run } +// 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" int printf (const 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; +} + diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/copy7.C b/gcc/testsuite/g++.old-deja/g++.brendan/copy7.C new file mode 100644 index 000000000..8fbec3384 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/copy7.C @@ -0,0 +1,31 @@ +// { dg-do run } +// GROUPS passed copy-ctors +extern "C" int printf (const 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); } +}; + +int +main() +{ + A a; + A b(a); + + printf ("FAIL\n"); + return 1; +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/copy8.C b/gcc/testsuite/g++.old-deja/g++.brendan/copy8.C new file mode 100644 index 000000000..096052342 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/copy8.C @@ -0,0 +1,68 @@ +// { dg-do run } +// 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" int printf (const 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; +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/copy9.C b/gcc/testsuite/g++.old-deja/g++.brendan/copy9.C new file mode 100644 index 000000000..f05b1943a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/copy9.C @@ -0,0 +1,46 @@ +// { dg-do run } +// GROUPS passed copy-ctors +#include <iostream> + +// 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;} +}; + +int +main () { + ParseToken a; + a.tok = T_Float; + a.doubleval = 23.2; + ParseToken b(a); + + if (b.doubleval == 23.2) + std::cout << "PASS\n"; + else + { + std::cout << "FAIL\n"; + return 1; + } +} + diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash1.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash1.C new file mode 100644 index 000000000..a71867447 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash1.C @@ -0,0 +1,44 @@ +// { dg-do assemble } +// 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()))) +{ +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash10.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash10.C new file mode 100644 index 000000000..78559b339 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash10.C @@ -0,0 +1,28 @@ +// { dg-do assemble } +// 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; +} + diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash11.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash11.C new file mode 100644 index 000000000..eb08ca264 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash11.C @@ -0,0 +1,24 @@ +// { dg-do assemble } +// GROUPS passed old-abort +extern "C" int printf (const char *, ...); + +class A { + int i; // { dg-error "" } private + int j; // { dg-error "" } private + 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); }// { dg-error "" } virtual.* +}; + +class B : public A { + public: + virtual void f1() { printf("i=%d j=%d\n",i,j); }// { dg-error "" } member.*// ERROR - member.* + friend virtual void f2() { printf("i=%d j=%d\n",i,j); }// { dg-error "" } virtual.*// ERROR - member.*// ERROR - member.* +}; + +int +main() { + A * a = new A; +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash12.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash12.C new file mode 100644 index 000000000..362f1f715 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash12.C @@ -0,0 +1,10 @@ +// { dg-do assemble } +// GROUPS passed old-abort +class X +{ + int i; +public: + X(int j); +} + +X *x = new X[10]();// { dg-error "" } .* diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash13.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash13.C new file mode 100644 index 000000000..c1f0b7dfc --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash13.C @@ -0,0 +1,37 @@ +// { dg-do assemble } +// { dg-options "-Wreturn-type" } +// 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(); +} // { dg-warning "no return" } reaches end of non-void function + +int +main () {} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash14.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash14.C new file mode 100644 index 000000000..e7920588f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash14.C @@ -0,0 +1,24 @@ +// { dg-do assemble } +// GROUPS passed old-abort +extern "C" int printf (const char *, ...); + + +class cl +{ + int i; +public: + cl(int j = 0) {i = j;} + int get_i() {return i;} + }; + +int +main() +{ + cl ob[3] = {1, 2, 3}; + int i; + + for(i=0; i<3; i++) + printf("%d\n", ob[i].get_i()); + + return 0; + } diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash15.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash15.C new file mode 100644 index 000000000..3c59fa64b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash15.C @@ -0,0 +1,22 @@ +// { dg-do assemble } +// GROUPS passed old-abort +#include <iostream> + +class A { + public: + virtual ~A() {std::cout << "executed ~A()\n";} +}; + +class B : public A { + public: + virtual ~B() {std::cout << "executed ~B()\n";} +}; + +int +main() { + std::cout << "starting\n"; + B b; + b.~A(); + std::cout << "done\n"; +} + diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash16.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash16.C new file mode 100644 index 000000000..674fc4fa6 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash16.C @@ -0,0 +1,14 @@ +// { dg-do compile } +// { dg-options "-fshow-column" } +// GROUPS passed old-abort + +class Graph { // { dg-error "1:new types|1: note: \\(perhaps" } +public: + unsigned char N; + Graph(void) {} // { dg-error "7:'Graph" } +} + +Graph::Graph(void) // { dg-error "18:return type|1: error: redefinition" } +{ N = 10; +} + diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash17.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash17.C new file mode 100644 index 000000000..ecbceabce --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash17.C @@ -0,0 +1,35 @@ +// { dg-do assemble } +// 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 {// { dg-warning "inaccessible" } +}; + diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash18.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash18.C new file mode 100644 index 000000000..119ba4605 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash18.C @@ -0,0 +1,18 @@ +// { dg-do compile } +// 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) // { dg-error "previously" } + { return v == index; } // { dg-error "from this location" } + // ??? should be operator!= + friend int operator==(void *v, const Pix& x) // { dg-error "redefinition" } + { return v != index; } +private: +// friend class List<T>; + element *index; // { dg-error "invalid use of non-static data member" } +}; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash2.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash2.C new file mode 100644 index 000000000..50aebdc6d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash2.C @@ -0,0 +1,10 @@ +// { dg-do assemble } +// 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]; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash20.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash20.C new file mode 100644 index 000000000..93dc58cb1 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash20.C @@ -0,0 +1,14 @@ +// { dg-do assemble } +// GROUPS passed old-abort +#include <complex> +typedef std::complex<double> Complex; + +Complex ComputeVVself() +{ +Complex temp1; +Complex self[3][3]; + + self[1][2] = 100.0; + return self[1][2]; + +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash22.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash22.C new file mode 100644 index 000000000..73831a053 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash22.C @@ -0,0 +1,11 @@ +// { dg-do assemble } +// GROUPS passed old-abort +struct A { + void a1(); + void a2(); +}; + +struct B { + void A::a1(); // this used to die in chainon(), now grokdeclarator should// { dg-error "" } cannot declare.* + void A::a2(); // should be fixed by the 930629 change.// { dg-error "" } cannot declare.* +}; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash23.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash23.C new file mode 100644 index 000000000..250686979 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash23.C @@ -0,0 +1,15 @@ +// { dg-do assemble } +// 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 () {}// { dg-error "" } .* + void B::g (int val) {}// { dg-error "" } .* +}; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash24.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash24.C new file mode 100644 index 000000000..42d0fabc2 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash24.C @@ -0,0 +1,19 @@ +// { dg-do assemble } +// { dg-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; +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash25.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash25.C new file mode 100644 index 000000000..dece6f7dc --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash25.C @@ -0,0 +1,18 @@ +// { dg-do assemble } +// 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; +}; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash26.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash26.C new file mode 100644 index 000000000..b89a2fae1 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash26.C @@ -0,0 +1,11 @@ +// { dg-do assemble } +// GROUPS passed old-abort +struct B { + B(); +}; + +class C : virtual public B +{ + public: + C() { } +}; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash27.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash27.C new file mode 100644 index 000000000..7aa0e593b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash27.C @@ -0,0 +1,20 @@ +// { dg-do assemble } +// 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(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash28.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash28.C new file mode 100644 index 000000000..dcb2dce5b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash28.C @@ -0,0 +1,12 @@ +// { dg-do assemble } +// GROUPS passed old-abort + class abc + { + public: + void F() { return; } + + private: + typedef int myint; + typedef struct { int b; } mystruct; + typedef union { int c; } myunion; + }; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash29.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash29.C new file mode 100644 index 000000000..38c9d49a1 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash29.C @@ -0,0 +1,20 @@ +// { dg-do assemble } +// GROUPS passed old-abort + +union Value +{ + Value(){} +}; + +struct GlobalAddress // { dg-message "note" } +{ + GlobalAddress(Value *nvar){} // { dg-message "note" } +}; + +int +main() +{ + new GlobalAddress(Value()); // internal error occured here// { dg-error "no matching" } + // { dg-message "candidate" "candidate note" { target *-*-* } 17 } + //new GlobalAddress(new Value()); // This line is correct code +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash3.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash3.C new file mode 100644 index 000000000..c5088f10d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash3.C @@ -0,0 +1,14 @@ +// { dg-do assemble } +// 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*); +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash30.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash30.C new file mode 100644 index 000000000..937cb1029 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash30.C @@ -0,0 +1,10 @@ +// { dg-do assemble } +// GROUPS passed old-abort +#include <string> + +int +main(void) { + + std::string a[] = {"Hello"}; + +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash31.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash31.C new file mode 100644 index 000000000..83cdf2add --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash31.C @@ -0,0 +1,16 @@ +// { dg-do assemble } +// 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; + +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash32.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash32.C new file mode 100644 index 000000000..955e68c68 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash32.C @@ -0,0 +1,5 @@ +// { dg-do assemble } +// { dg-options "-fshort-enums" } +// GROUPS passed old-abort +enum Bool { FALSE, TRUE }; +Bool foo () { return TRUE; } diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash33.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash33.C new file mode 100644 index 000000000..1f9944826 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash33.C @@ -0,0 +1,7 @@ +// { dg-do assemble } +// GROUPS passed old-abort +extern void foo(void *); +int +main() { + foo((struct bar *)0); +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash34.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash34.C new file mode 100644 index 000000000..6ac1ef0cd --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash34.C @@ -0,0 +1,3 @@ +// { dg-do assemble } +// GROUPS passed old-abort +operator int () {}// { dg-error "" } .*// ERROR - .* diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash35.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash35.C new file mode 100644 index 000000000..93a0aeb9c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash35.C @@ -0,0 +1,20 @@ +// { dg-do assemble } +// 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) + { + } + } diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash36.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash36.C new file mode 100644 index 000000000..79b3e4602 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash36.C @@ -0,0 +1,7 @@ +// { dg-do assemble } +// GROUPS passed old-abort +struct wait { int w_status; }; +int wait(); +extern "C" int wait(int*); + + diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash37.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash37.C new file mode 100644 index 000000000..0e46c9359 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash37.C @@ -0,0 +1,16 @@ +// { dg-do assemble } +// 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() { } diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash38.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash38.C new file mode 100644 index 000000000..80ef47180 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash38.C @@ -0,0 +1,43 @@ +// { dg-do assemble } +// 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 <iostream> + +class INTEGER { +int x; +public: + typedef int BASE; + INTEGER(int y) : x(y) {} + INTEGER() {} + void encode() { std::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); } +}; + +int +main() +{ + Implicit<Implicit<INTEGER, 2> , 3> y; + + y = 10; +} + + + diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash39.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash39.C new file mode 100644 index 000000000..392c0a009 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash39.C @@ -0,0 +1,33 @@ +// { dg-do assemble } +// { dg-options "-w" } +// GROUPS passed old-abort +//#include <GetOpt.h> +#include <stdio.h> + +class GetOpt +{ +private: + static char *nextchar; + enum OrderingEnum { REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER }; + OrderingEnum ordering; + static int first_nonopt; + static int last_nonopt; + void exchange (char **argv); +public: + char *optarg; + int optind; + int opterr; + + int nargc; + char **nargv; + const char *noptstring; + + GetOpt (int argc, char **argv, const char *optstring); + int operator () (void); +}; +//end <GetOpt.h> +#include <string> + +class foo {public: foo () {}}; +class bar {public: bar (const foo& dflt);}; +class baz: public bar {public: baz (): bar (foo ()) {}}; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash4.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash4.C new file mode 100644 index 000000000..34ef2dddb --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash4.C @@ -0,0 +1,6 @@ +// { dg-do assemble } +// GROUPS passed old-abort +typedef struct Thing { + Thing(); + int x; +} Thing; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash40.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash40.C new file mode 100644 index 000000000..e5b174457 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash40.C @@ -0,0 +1,17 @@ +// { dg-do assemble } +// 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; +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash41.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash41.C new file mode 100644 index 000000000..188c09ba3 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash41.C @@ -0,0 +1,11 @@ +// { dg-do assemble } +// GROUPS passed old-abort +typedef void (**ppfn)(void); + +int main() { + ppfn fn; + + fn = new (void(*)(void)); + + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash42.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash42.C new file mode 100644 index 000000000..8777ef82c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash42.C @@ -0,0 +1,6 @@ +// { dg-do assemble } +// GROUPS passed old-abort +int fn();// { dg-error "" } ambiguates.* +int x; +int& fn() {// { dg-error "" } new decl.* +return x;} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash43.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash43.C new file mode 100644 index 000000000..8c73d70d0 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash43.C @@ -0,0 +1,25 @@ +// { dg-do assemble } +// { dg-xfail-if "" { sparc64-*-elf } { "*" } { "" } } +// { dg-options "-g" } +// GROUPS passed old-abort +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; + } +}; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash44.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash44.C new file mode 100644 index 000000000..2439daf91 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash44.C @@ -0,0 +1,27 @@ +// { dg-do assemble } +// 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) +{ +} + +int +main() +{ + bug<char> InstantiatedBug; + + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash45.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash45.C new file mode 100644 index 000000000..b9eb6c7a7 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash45.C @@ -0,0 +1,3 @@ +// { dg-do assemble } +// GROUPS passed old-abort +void foo() { static const char *const v[] = { 0 }; } diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash46.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash46.C new file mode 100644 index 000000000..53cbd1027 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash46.C @@ -0,0 +1,26 @@ +// { dg-do assemble } +// 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; +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash47.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash47.C new file mode 100644 index 000000000..3afa5fa99 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash47.C @@ -0,0 +1,94 @@ +// { dg-do assemble } +// 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; +}; + +int +main() +{ + Ref<XRep> y; + + return y != y; +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash48.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash48.C new file mode 100644 index 000000000..fe759406e --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash48.C @@ -0,0 +1,24 @@ +// { dg-do compile } +// GROUPS passed old-abort +class internal { // { dg-message "internal::internal|candidate expects|no known conversion" } + int field; + int anotherfield; +}; + +class bug { // { dg-message "bug::bug|candidate expects" } + internal* numbers; + bug(int size); +}; + +bug::bug(int size) // { dg-message "bug::bug|candidate expects" } +{ + numbers = new internal(size * size);// { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 15 } +} + +int +main() +{ + bug test; // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 22 } +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash49.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash49.C new file mode 100644 index 000000000..e0664da28 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash49.C @@ -0,0 +1,12 @@ +// { dg-do assemble } +// GROUPS passed old-abort +#include<iostream> + +const int keys = 10; +const int key[keys] = {6, key[1], 2, keys, 1, 7, 6, key[2], key[8]}; + +void main() // { dg-error "must return .int" } +{ + for(int i = 0; i < keys;) std::cout << key[i++] << " "; + std::endl(std::cout); +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash5.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash5.C new file mode 100644 index 000000000..6b9696ea6 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash5.C @@ -0,0 +1,105 @@ +// { dg-do assemble } +// 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. + +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 = 0; + } + 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() {} +}; + +int +main() +{ + SimpleSet<Dummy *> bs1; + int i, j; + Dummy foo; + + bs1+=&foo;// { dg-error "" } no .* +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash50.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash50.C new file mode 100644 index 000000000..598c029f7 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash50.C @@ -0,0 +1,29 @@ +// { dg-do assemble } +// GROUPS passed old-abort +class B + { +public: + int i; + }; +int operator & (const B &s) { return ( s.i );} + + + + + +class C + { +public: + C &operator = (const C &x) + { + return *this; + } + }; + +C &(C::*DD)(const C &x) = &C::operator=; + +int main() +{ + ⅅ + +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash51.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash51.C new file mode 100644 index 000000000..0c4e0beab --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash51.C @@ -0,0 +1,24 @@ +// { dg-do assemble } +// GROUPS passed old-abort +class obj; + +typedef obj *obj_t; + +class obj { +public: + obj( const obj& o ); +}; + +extern obj nowhere; + +class set: public obj { + unsigned bit_vector; +public: + set( const obj& o ); + set& operator|=( const int q ); +}; + +enum pin_enum { E_F, O_C, O_D, O_S, P_D, P_U, R, T, A, C }; + +set t_q = ( ( ( ( ( ( set( nowhere ) |= E_F ) |= O_C ) |= O_D ) |= O_S ) + |= P_U ) |= P_D ) |= T; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash52.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash52.C new file mode 100644 index 000000000..6db818aa1 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash52.C @@ -0,0 +1,13 @@ +// { dg-do assemble } +// { dg-options "-Wreturn-type" } +// GROUPS passed old-abort +#include <iostream> + +class A { +public: + friend A f(A &a);// { dg-error "ambiguates" } +}; + +A &f(A &a) {// { dg-error "new decl" } + std::cout << "Blah\n"; +} // { dg-warning "no return statement" } diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash53.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash53.C new file mode 100644 index 000000000..127c1d0ff --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash53.C @@ -0,0 +1,24 @@ +// { dg-do assemble } +// GROUPS passed old-abort +class A +{ + public: + class B + { + public: + virtual ~B(); + }; +}; + +template<int I> +class C +{ + public: + class B + : public A::B + { + }; // bug2.cc:18: Internal compiler error 233. + // bug2.cc:18: Please submit a full bug report to `bug-g++@prep.ai.mit.edu'. +}; + +C<0> c; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash54.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash54.C new file mode 100644 index 000000000..4ed66d15a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash54.C @@ -0,0 +1,9 @@ +// { dg-do assemble } +// GROUPS passed old-abort +int main() +{ + int a[100], **p; + + p = &a[50];// { dg-error "" } assignment to.* + +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash55.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash55.C new file mode 100644 index 000000000..829596241 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash55.C @@ -0,0 +1,12 @@ +// { dg-do compile } +// GROUPS passed old-abort + extern int f(int); // { dg-error "ambiguates" } + + int& f(int x) // { dg-error "new declaration" } + { + int local; // { dg-warning "reference to local" } + + local = x+2; + + return local; + } diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash56.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash56.C new file mode 100644 index 000000000..ad652cf93 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash56.C @@ -0,0 +1,391 @@ +// { dg-do assemble } +// { dg-options "" } +// GROUPS passed old-abort + +const bool FALSE = 0; +const bool TRUE = 1; +class ListDProto { +protected: + class link; +public: + ListDProto(); + ListDProto(const ListDProto&); + virtual ~ListDProto(); + void operator=(const ListDProto&); + unsigned length() const; + bool empty() const; + void clear(); + void remove_head(); + void remove_tail(); + class Vix { + public: + Vix(); + friend int operator==(void *v, const Vix& x) + { return v == x.item; } + friend int operator==(const Vix& x, void *v) + { return v == x.item; } + friend int operator!=(void *v, const Vix& x) + { return v != x.item; } + friend int operator!=(const Vix& x, void *v) + { return v != x.item; } + friend int operator==(const Vix& x1, const Vix& x2) + { return x1.owner == x2.owner && x1.item == x2.item; } + friend int operator!=(const Vix& x1, const Vix& x2) + { return x1.owner != x2.owner || x1.item != x2.item; } + bool first; + bool last; + protected: + friend class ListDProto; + Vix(const ListDProto *o, link *i); + const ListDProto *owner; + private: + link *item; + }; + enum Action { NORMAL, REMOVE_CURRENT }; + Vix first() const; + void first(Vix& x) const; + void next(Vix& x) const; + void next(Vix& x, Action a = NORMAL); + Vix last() const; + void last(Vix& x) const; + void prev(Vix& x) const; + void prev(Vix& x, Action a = NORMAL); +protected: + struct link { + link *next; + link *prev; + link(link *n = 0, link *p = 0); + virtual ~link(); + private: + link(const link&); + void operator=(const link&); + }; + unsigned count; + link *list_head; + link *list_tail; + virtual link *copy_item(link *old_item) const = 0; + void prepend(link *item); + void append(link *item); + void prepend(const ListDProto& proto); + void append(const ListDProto& proto); + void remove(link *item); + link *ref(const Vix&) const; +}; +template<class T> +class ListD: public ListDProto { +public: + void prepend(const T& item); + void append(const T& item); + const T& head() const; + T& head(); + void head(T& fill) const; + void remove_head() + { ListDProto::remove_head(); } + void remove_head(T& fill); + const T& tail() const; + T& tail(); + void tail(T& fill) const; + void remove_tail() + { ListDProto::remove_tail(); } + void remove_tail(T& fill); + class Vix: public ListDProto::Vix { + public: + Vix(): ListDProto::Vix() + { } + protected: + friend class ListD<T>; + Vix(const ListDProto::Vix& x): ListDProto::Vix(x) + { } + }; + Vix first() const + { return ListDProto::first(); }; + void first(Vix& x) const + { ListDProto::first(x); }; + void next(Vix& x, ListDProto::Action a = NORMAL) const + { ListDProto::next(x, a); }// { dg-error "" } .*// ERROR - .* + Vix last() const + { return ListDProto::last(); } + void last(Vix& x) const + { return ListDProto::last(x); } + void prev(Vix& x, ListDProto::Action a = NORMAL) const + { return ListDProto::prev(x, a); } +protected: + struct link_item: public ListDProto::link { + T item; + link_item(const T& i): link(0, 0), item(i) + { } + private: + link_item(const link_item&); + void operator=(const link_item&); + }; +public: + T& operator()(const Vix& x) + { link_item *li = (link_item *) ref(x); + return li->item; } + const T& operator()(const Vix& x) const + { link_item *li = (link_item *) ref(x); + return li->item; } +private: + ListDProto::link *copy_item(ListDProto::link *old_item) const; +}; +template<class T> +class SetLD: private ListD<T> { +public: + SetLD(); + SetLD(const ListD<T>&); + void add(const T& item); + void add(const ListD<T>& other); + void add(const SetLD<T>& other); + void remove(const T& item); + bool contains(const T& item) const; + ListD<T>::length; + ListD<T>::empty; + ListD<T>::clear; + typedef typename ListD<T>::Vix Vix; + ListD<T>::first; + ListD<T>::next; + ListD<T>::operator(); + + using ListD<T>::NORMAL; + using ListD<T>::REMOVE_CURRENT; +}; +extern "C" { +extern void __eprintf (const char *, const char *, unsigned, const char *); +} +extern "C" { +extern void __eprintf (const char *, const char *, unsigned, const char *); +} +template<class T> +void +ListD<T>::prepend(const T& item) +{ + link *newl = new link_item(item); + ListDProto::prepend(newl); +} +template<class T> +void +ListD<T>::append(const T& item) +{ + link *newl = new link_item(item); + ListDProto::append(newl); +} +template<class T> +const T& +ListD<T>::head() const +{ + ((void) (( 0 != list_head ) ? 0 : (__eprintf ("%s:%u: failed assertion `%s'\n", "/home/wbaker/work/include/templates/ListD.body.h" , 50 , "0 != list_head" ), 0) )) ; + link_item *h = (link_item *) list_head; + return h->item; +} +template<class T> +T& +ListD<T>::head() +{ + ((void) (( 0 != list_head ) ? 0 : (__eprintf ("%s:%u: failed assertion `%s'\n", "/home/wbaker/work/include/templates/ListD.body.h" , 59 , "0 != list_head" ), 0) )) ; + link_item *h = (link_item *) list_head; + return h->item; +} +template<class T> +void +ListD<T>::head(T& fill) const +{ + ((void) (( 0 != list_head ) ? 0 : (__eprintf ("%s:%u: failed assertion `%s'\n", "/home/wbaker/work/include/templates/ListD.body.h" , 68 , "0 != list_head" ), 0) )) ; + link_item *h = (link_item *) list_head; + fill = h->item; +} +template<class T> +void +ListD<T>::remove_head(T& fill) +{ + head(fill); + remove_head(); +} +template<class T> +const T& +ListD<T>::tail() const +{ + ((void) (( 0 != list_tail ) ? 0 : (__eprintf ("%s:%u: failed assertion `%s'\n", "/home/wbaker/work/include/templates/ListD.body.h" , 85 , "0 != list_tail" ), 0) )) ; + link_item *h = (link_item *) list_tail; + return h->item; +} +template<class T> +T& +ListD<T>::tail() +{ + ((void) (( 0 != list_tail ) ? 0 : (__eprintf ("%s:%u: failed assertion `%s'\n", "/home/wbaker/work/include/templates/ListD.body.h" , 94 , "0 != list_tail" ), 0) )) ; + link_item *h = (link_item *) list_tail; + return h->item; +} +template<class T> +void +ListD<T>::tail(T& fill) const +{ + ((void) (( 0 != list_tail ) ? 0 : (__eprintf ("%s:%u: failed assertion `%s'\n", "/home/wbaker/work/include/templates/ListD.body.h" , 103 , "0 != list_tail" ), 0) )) ; + link_item *h = (link_item *) list_tail; + fill = h->item; +} +template<class T> +void +ListD<T>::remove_tail(T& fill) +{ + ((void) (( 0 != list_tail ) ? 0 : (__eprintf ("%s:%u: failed assertion `%s'\n", "/home/wbaker/work/include/templates/ListD.body.h" , 112 , "0 != list_tail" ), 0) )) ; + link_item *h = (link_item *) list_tail; + fill = h->item; +} +template<class T> +ListDProto::link * +ListD<T>::copy_item(ListDProto::link *old) const +{ + link_item *old_item = (link_item *) old; + link_item *new_item = new link_item(old_item->item); + return new_item; +} +template<class T> +SetLD<T>::SetLD(): +ListD<T>() +{ } +template<class T> +SetLD<T>::SetLD(const ListD<T>& other): +ListD<T>(other) +{ } +template<class T> +void +SetLD<T>::add(const T& item) +{ + if ( ! contains(item) ) + append(item); +} +template<class T> +void +SetLD<T>::add(const ListD<T>& other) +{ + typename ListD<T>::Vix x; + for (first(x); 0 != x; next(x)) + add(other(x)); +} +template<class T> +void +SetLD<T>::add(const SetLD<T>& other) +{ + const ListD<T>& lother = other; + add(lother); +} +template<class T> +void +SetLD<T>::remove(const T& item) +{ + typename ListD<T>::Action a = this->NORMAL; + Vix x; + for (first(x); 0 != x && this->REMOVE_CURRENT != a; next(x, a)) + a = operator()(x) == item ? this->REMOVE_CURRENT: this->NORMAL; // { dg-error "" } .* + // { dg-message "candidate" "candidate note" { target *-*-* } 280 } +} +template<class T> +bool +SetLD<T>::contains(const T& item) const +{ + Vix x; + for (first(x); 0 != x; next(x)) { + if (operator()(x) == item)// { dg-error "" } .* + // { dg-message "candidate" "candidate note" { target *-*-* } 289 } + return TRUE; + } + return FALSE; +} +template<class T> +int +operator==(const SetLD<T>& a, const SetLD<T>& b) // { dg-message "note" } +{ + if (a.length() != b.length()) + return FALSE; + typename SetLD<T>::Vix x; + for (a.first(x); 0 != x; a.next(x)) { + if ( ! b.contains(a(x)) ) + return FALSE; + } + for (b.first(x); 0 != x; b.next(x)) { + if ( ! a.contains(b(x)) ) + return FALSE; + } + return TRUE; +} +template<class T> +int +operator!=(const SetLD<T>& a, const SetLD<T>& b) +{ return ! (a == b); } +template<class T> +int +operator<=(const SetLD<T>& a, const SetLD<T>& b) +{ + if (a.length() > b.length()) + return FALSE; + typename SetLD<T>::Vix x; + for (x=a.first(); 0 != x; a.next(x)) { + if ( ! b.contains(a(x)) ) + return FALSE; + } + return TRUE; +} +template<class T> +int +operator<(const SetLD<T>& a, const SetLD<T>& b) +{ + if (a.length() >= b.length()) + return FALSE; + return a <= b; +} +template<class T> +int +operator>(const SetLD<T>& a, const SetLD<T>& b) +{ return ! (a <= b); } +template<class T> +int +operator>=(const SetLD<T>& a, const SetLD<T>& b) +{ return ! (a < b); } +class String { }; +class IcaseString: public String { }; +template <> class SetLD< IcaseString >: public SetLD< String > { public: SetLD (): SetLD< String >() { }; SetLD (const ::ListD< IcaseString >& other): SetLD< String >() { ::ListD< IcaseString >::Vix x; for (other.first(x); 0 != x; other.next(x)) add(other(x)); }; SetLD (const SetLD & other): SetLD< String >(other) { }; const IcaseString & operator()(const Vix& x) const { return ( IcaseString &) SetLD< String >::operator()(x); } }; typedef SetLD< String > SetLD_String_IcaseString_old_tmp99; typedef SetLD< IcaseString > SetLD_String_IcaseString_new_tmp99; +inline int operator== (const SetLD_String_IcaseString_new_tmp99& a, const SetLD_String_IcaseString_new_tmp99& b) // { dg-message "operator==|no known conversion" } +{ +const SetLD_String_IcaseString_old_tmp99& oa = a; +const SetLD_String_IcaseString_old_tmp99& ob = b; +return operator== (oa, ob); } +inline int operator!= (const SetLD_String_IcaseString_new_tmp99& a, const SetLD_String_IcaseString_new_tmp99& b) +{ +const SetLD_String_IcaseString_old_tmp99& oa = a; +const SetLD_String_IcaseString_old_tmp99& ob = b; +return operator!= (oa, ob); } +inline int operator< (const SetLD_String_IcaseString_new_tmp99& a, const SetLD_String_IcaseString_new_tmp99& b) +{ +const SetLD_String_IcaseString_old_tmp99& oa = a; +const SetLD_String_IcaseString_old_tmp99& ob = b; +return operator< (oa, ob); } +inline int operator<= (const SetLD_String_IcaseString_new_tmp99& a, const SetLD_String_IcaseString_new_tmp99& b) +{ +const SetLD_String_IcaseString_old_tmp99& oa = a; +const SetLD_String_IcaseString_old_tmp99& ob = b; +return operator<= (oa, ob); } +inline int operator> (const SetLD_String_IcaseString_new_tmp99& a, const SetLD_String_IcaseString_new_tmp99& b) +{ +const SetLD_String_IcaseString_old_tmp99& oa = a; +const SetLD_String_IcaseString_old_tmp99& ob = b; +return operator> (oa, ob); } +inline int operator>= (const SetLD_String_IcaseString_new_tmp99& a, const SetLD_String_IcaseString_new_tmp99& b) +{ +const SetLD_String_IcaseString_old_tmp99& oa = a; +const SetLD_String_IcaseString_old_tmp99& ob = b; +return operator>= (oa, ob); } +typedef SetLD<IcaseString> SLDiS; +static void +nop(int i) +{ + SetLD<IcaseString> x, y; + nop(x == y); + nop(x != y); +nop(x < y); +nop(x <= y); +nop(x > y); +nop(x >= y); +} + +template class SetLD<String>; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash57.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash57.C new file mode 100644 index 000000000..b4599fc7e --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash57.C @@ -0,0 +1,13 @@ +// { dg-do assemble } +// GROUPS passed old-abort +class foo { +private: + char buffer[1024]; +public: + foo(); +}; + +int main() +{ + static foo& a = *(new foo); +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash58.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash58.C new file mode 100644 index 000000000..7d5f6597c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash58.C @@ -0,0 +1,10 @@ +// { dg-do assemble } +// GROUPS passed old-abort +class X { +public: +void doit(); +}; + +X::::doit()// { dg-error "" } (syntax|parse) error.* +{ +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash6.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash6.C new file mode 100644 index 000000000..b975237a8 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash6.C @@ -0,0 +1,17 @@ +// { dg-do assemble } +// GROUPS passed old-abort +// Should be fixed by: +// Sun Jun 13 12:55:22 1993 Brendan Kehoe (brendan@lisa.cygnus.com) +// +// * cp-decl.c (start_function): Avoid a null-reference on CTYPE. + +template<int> +class Program { +} ; + +template<> +class Program<0> { +public: + inline friend float EvalNextArg() + { return 1.0 ; } +} ; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash60.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash60.C new file mode 100644 index 000000000..a59d72a7b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash60.C @@ -0,0 +1,12 @@ +// { dg-do assemble } +// GROUPS passed old-abort +class X +{ +public: + X (); + int f[4]; +}; + +// Note that we mistakenly initialize the array data member as if it +// was scalar +X::X () : f (0) {}// { dg-error "" } .* diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash61.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash61.C new file mode 100644 index 000000000..86e347fef --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash61.C @@ -0,0 +1,5 @@ +// { dg-do assemble } +// GROUPS passed old-abort + template <class TP> class sapp { }; + class foo {}; + extern foo& __iomanip_setw (foo&, TP);// { dg-error "" } type spec.* diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash62.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash62.C new file mode 100644 index 000000000..7147c9a8e --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash62.C @@ -0,0 +1,32 @@ +// { dg-do assemble } +// GROUPS passed old-abort +#include <iostream> + + void + fubar(std::ostream* out, const char* s) + { + (*out) << s << std::endl; + return; + } + + int + main() + { + // Declare a ref and a pointer to the same ostream. + // + std::ostream* out = &std::cerr; + std::ostream& die = std::cerr; + + // Valid call to fubar. + // + fubar(out, "First line."); + + // Invalid call to fubar. (1st arg is an ostream&. fubar expects + // ostream*.)This should be a syntax error, but g++ does not catch it. + // Call to this function results in a bus error in fubar when the 1st + // arg is dereferenced. + // + fubar(die, "Second line.");// { dg-error "" } cannot convert .die.* + + return 1; + } diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash63.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash63.C new file mode 100644 index 000000000..89685fcae --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash63.C @@ -0,0 +1,16 @@ +// { dg-do assemble } +// GROUPS passed old-abort +class String + { + public: + String (const char *str); + String (const String&); + }; + +class UnitList + { + public: + UnitList (...); + }; + +UnitList unit_list (String("keV")); // { dg-error "" } cannot pass non-pod diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash64.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash64.C new file mode 100644 index 000000000..3c9869283 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash64.C @@ -0,0 +1,19 @@ +// { dg-do assemble } +// GROUPS passed old-abort +typedef __SIZE_TYPE__ size_t; +typedef void (*RF_Ptr)(void *); + +struct _im_pers_mem_spec { + _im_pers_mem_spec(void ); + _im_pers_mem_spec(auto int of, auto int n); +}; + +struct _type_desc { + _type_desc(const char *, int , RF_Ptr , int , int ,...); +}; + +struct metatype { int base_list; }; + +static _type_desc _type_metatype("metatype", sizeof(metatype), + (RF_Ptr)0, 0, 1, 1, + _im_pers_mem_spec( ((size_t)&((( metatype *)0)-> base_list )) , 1)); diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash65.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash65.C new file mode 100644 index 000000000..1bf6c4b6b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash65.C @@ -0,0 +1,14 @@ +// { dg-do assemble } +// GROUPS passed old-abort +class X { +public: + virtual const char* XY(const void* val) const = 0; +}; + + +class Y : public X { +public: + using X::xy;// { dg-error "" } no memb.* + + using X::z;// { dg-error "" } no memb.* +}; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash66.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash66.C new file mode 100644 index 000000000..321c55130 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash66.C @@ -0,0 +1,137 @@ +// { dg-do assemble } +// { dg-options "-O" } +// GROUPS passed old-abort +typedef unsigned char uchar; +typedef unsigned short ushort; +typedef unsigned long ulong; +extern int swap_endian; +inline ushort +swapshort(ushort value) +{ + value &= 0xffff; + return ((value << 8) | (value >> 8)); +} +struct eshort +{ + ushort data; + operator ushort() { return swap_endian ? swapshort(data) : data;} + eshort(ushort t) { data = swap_endian ? swapshort(t) : t;} + eshort() {} +}; +inline ulong +swaplong(ulong value) +{ + ulong v = (value << 16) | (value >> 16); + return ((v >> 8) & 0x00ff00ff) | ((v << 8) & 0xff00ff00); +} +struct elong +{ + ulong data; + operator ulong() { return swap_endian ? swaplong(data) : data;} + elong(ulong t) { data = swap_endian ? swaplong(t) : t; } + elong() {} +}; +struct digiheader +{ + uchar type[2]; + eshort soft_version; + eshort lo_boot_rev; + eshort hi_boot_rev; + eshort load_segment; + eshort length; + eshort exec_start; + eshort image_offset; + elong startup_code[2]; + elong checksum; +}; +extern void uncompress(uchar* buf, ulong len); +extern ulong compress(char* filename, uchar* buffer, ulong); +struct filehdr +{ + eshort f_magic; + eshort f_nscns; + elong f_timdat; + elong f_symptr; + elong f_nsyms; + eshort f_opthdr; + eshort f_flags; +}; +struct aouthdr +{ + eshort magic; + eshort vstamp; + elong tsize; + elong dsize; + elong bsize; + elong entry; + elong text_start; + elong data_start; + elong bss_start; + elong gprmask; + elong cprmask[4]; + elong gp_value; +}; +struct scnhdr +{ + char s_name[8]; + elong s_paddr; + elong s_vaddr; + elong s_size; + elong s_scnptr; + elong s_relptr; + elong s_lnnoptr; + eshort s_nreloc; + eshort s_nlnno; + elong s_flags; +}; +int file_little_endian; +int host_little_endian; +int swap_endian; +int docheck; +int expand; +ulong memsize; +ulong compression_quality; +char *compressfile; +int debug_level; +extern "C" int getopt (int, char**, const char*); +int +main(int argc, char** argv) +{ + uchar checksum; + uchar docrc; + ulong len; + ulong maxlen; + int i; + int c; + int magic; + int tsize; + int dsize; + int quality; + char dummy; + uchar* code; + uchar* buf; + char* ap; + digiheader *dh; + compression_quality = 10000; + docheck = 0; + while ((c = getopt(argc, argv, "Ccdf:k:q:x:")) != -1) + { + switch (c) + { + default: + goto usage; + } + } + if ((expand && (docheck || compressfile || quality)) || + (quality && !compressfile)) + { + usage: + return(2); + } + if (compressfile) + { + dh->image_offset = len; + + len += compress(compressfile, code + len, maxlen - len); + } +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash67.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash67.C new file mode 100644 index 000000000..da7cec475 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash67.C @@ -0,0 +1,3 @@ +// { dg-do assemble } +// GROUPS passed old-abort +#pragma comment(exestr, "@(#) errno.h 10.2 92/03/26 ") diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash68.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash68.C new file mode 100644 index 000000000..82da9f8b9 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash68.C @@ -0,0 +1,28 @@ +// { dg-do assemble } +// { dg-options "-w -O" } +// GROUPS passed old-abort +class RWDlist +{ +public: + RWDlist& operator=(const RWDlist&); +}; +class DataItemRWGDlist : public RWDlist {}; + +class Base {}; +class DataItemList : public Base +{ + private: + DataItemRWGDlist m_diList; +}; + +class StatementGroup +{ + public: + DataItemList dataItemList; + StatementGroup(const StatementGroup&); +}; + +StatementGroup::StatementGroup(const StatementGroup& sg) +{ + dataItemList = sg.dataItemList; +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash7.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash7.C new file mode 100644 index 000000000..44339ea2c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash7.C @@ -0,0 +1,48 @@ +// { dg-do assemble } +// GROUPS passed templates + +template<class T> +class Vector +{ + int sz; + T *v; +public: + Vector (int s) : sz (s) { v = new T[sz]; } + ~Vector () { delete[] v; } + T &operator[] (int i) { return v[i]; } + int size () { return sz; } +}; + +template<class T>// { dg-error "" } previous definition of T +struct Comparator +{ + typedef T T;// { dg-error "" } use of template type T in typedef to T + static int lessthan (T &a, T &b) { return a < b; } +}; + +template<class Comp> +struct Sort +{ + static void sort (Vector<Comp::T> &);// { dg-error "" } use of bad T +}; + +template<class Comp> +void Sort<Comp>::sort (Vector<Comp::T> &v)// { dg-error "" } use of bad T +{ + int n = v.size (); + + for (int i = 0; i < n - 1; i++) + for (int j = n - 1; i < j; j--) + if (Comp::lessthan (v[j], v[j - 1])) + { + typename Comp::T temp = v[j]; + v[j] = v[j - 1]; + v[j - 1] = temp; + } +} + +void +f (Vector<int> &vi) +{ + Sort<Comparator<int> >::sort (vi); // { dg-error "'sort' is not a member of 'Sort<Comparator<int> >'" } +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash8.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash8.C new file mode 100644 index 000000000..487208328 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash8.C @@ -0,0 +1,12 @@ +// { dg-do compile } +// GROUPS passed old-abort +template<int a, int b> +class Elvis // { dg-error "class Elvis" } +{ +} ; + +template<int a> +class Elvis<0> // { dg-error "wrong number of template arguments" } +{ + int geta() { return a ; } +} ; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash9.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash9.C new file mode 100644 index 000000000..004e84212 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash9.C @@ -0,0 +1,24 @@ +// { dg-do assemble } +// GROUPS passed old-abort +class A {}; + +class SimQuery +{ +public: + SimQuery(); + ~SimQuery(); + int SetMeshFile(char name[]); +protected: + A& scaling; + A* mesh; +}; + +SimQuery::SimQuery():scaling(A) {}// { dg-error "" } .* + +SimQuery::~SimQuery() {} + +int SimQuery::SetMeshFile(char name[]) +{ + mesh = new C;// { dg-error "" } .* + return 0; // needed to avoid warning of reaching end of non-void fn +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/ctors1.C b/gcc/testsuite/g++.old-deja/g++.brendan/ctors1.C new file mode 100644 index 000000000..1b0bfd90b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/ctors1.C @@ -0,0 +1,28 @@ +// { dg-do run } +// GROUPS passed constructors +// Check that global level object constructors get called. + +extern "C" int printf (const char *, ...); + +struct base { + int f1; + int f2; + base (int arg1, int arg2); +}; + + +base global_base(0x55, 0xff); + +int main () +{ + if ((global_base.f1 != 0x55) || (global_base.f2 != 0xff)) + { printf ("FAIL\n"); return 1; } + else + printf ("PASS\n"); +} + +base::base(int arg1, int arg2) +{ + f1 = arg1; + f2 = arg2; +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/ctors2.C b/gcc/testsuite/g++.old-deja/g++.brendan/ctors2.C new file mode 100644 index 000000000..c30ab7010 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/ctors2.C @@ -0,0 +1,29 @@ +// { dg-do run } +// GROUPS passed constructors +// Check that sub-words sized class members are correctly set +// by constructors. + +extern "C" int printf (const char *, ...); + +struct base { + int f1 : 8; + int f2 : 8; + base (int arg1, int arg2); +}; + + +base global_base(0x55, 0x7e); + +int main () +{ + if ((global_base.f1 != 0x55) || (global_base.f2 != 0x7e)) + { printf ("FAIL\n"); return 1; } + else + printf ("PASS\n"); +} + +base::base(int arg1, int arg2) +{ + f1 = arg1; + f2 = arg2; +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/ctors3.C b/gcc/testsuite/g++.old-deja/g++.brendan/ctors3.C new file mode 100644 index 000000000..cbfe9d699 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/ctors3.C @@ -0,0 +1,17 @@ +// { dg-do assemble } +// GROUPS passed constructors +class A; + +class B { +public: + B(); +static A sa; +}; + +class A { +public: + A(int i); +}; + +A B::sa(1); + diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/cvt1.C b/gcc/testsuite/g++.old-deja/g++.brendan/cvt1.C new file mode 100644 index 000000000..1327f5ace --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/cvt1.C @@ -0,0 +1,44 @@ +// { dg-do assemble } +// GROUPS passed conversions +#include <iostream> + +class Thing +{ +public: + typedef enum { GOOD_THING, BAD_THING, } ThingType ; // { dg-error "" } comma + Thing (ThingType type) : thingType (type) { } + ~Thing () { } +private: + ThingType thingType ; +} ; + +class Group +{ +public: + typedef enum { THIS_GROUP, THAT_GROUP, } GroupType ; // { dg-error "" } comma + Group (GroupType type) : groupType (type), groupCount (0) { } + ~Group () { } + void append (Thing* const &entry) { groupCount ++ ; } + operator GroupType () const { return groupType ; } + operator int () const { return groupCount ; } // remove this and problem gone + +private: + int groupCount ; + GroupType groupType ; +} ; + +inline Group& operator += (Group& g, Thing* const t) +{ + g.append (t) ; + return g ; // complaint is here +} + +int +main (int argc, char** argv) +{ + Group g (Group::THIS_GROUP) ; + + g += new Thing (Thing::GOOD_THING) ; + std::cout << "Group type is " << (Group::GroupType) g << std::endl ; + return 0 ; +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/cvt2.C b/gcc/testsuite/g++.old-deja/g++.brendan/cvt2.C new file mode 100644 index 000000000..acb173c6e --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/cvt2.C @@ -0,0 +1,9 @@ +// { dg-do assemble } +// GROUPS passed conversions +void f(const short & s) { } + + int +main() { + f(0); + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/cvt3.C b/gcc/testsuite/g++.old-deja/g++.brendan/cvt3.C new file mode 100644 index 000000000..8be5d6ed3 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/cvt3.C @@ -0,0 +1,49 @@ +// { dg-do assemble } +// GROUPS passed conversions +class GttObject {}; +class GctObject: virtual public GttObject {}; +class NDAMObject: virtual public GttObject, virtual public GctObject {}; +class GctHashObject: virtual public GctObject {}; + +class GctRef: virtual public GctHashObject +{ public: operator void*() const; }; + +class NDAMAssemblerObject: virtual public NDAMObject {}; +class GctReferenceObject: virtual public GctHashObject {}; +class NDAMValue: virtual public NDAMAssemblerObject, public GctReferenceObject {}; + +class nnyacc; +class NDAMValueRef : virtual public NDAMObject, public GctRef +{ + NDAMValue *operator->() const; + operator NDAMValue *() const; +friend class nnyacc; +}; + +typedef void* Pix; +class NDAMValueRefSLList +{ +public: + NDAMValueRefSLList(); + NDAMValueRefSLList(const NDAMValueRefSLList& a); + ~NDAMValueRefSLList(); + NDAMValueRef& operator () (Pix p) const; +}; + +struct bar +{ + NDAMValueRefSLList *valueList; +}; + +class nnyacc +{ +public: + static void assign(void*& lval, void*& rval); // { dg-message "nnyacc::assign|no known conversion" } +}; + +void +foo (bar yylval, bar *yyvsp) +{ + nnyacc::assign(yylval.valueList, yyvsp[0].valueList);// { dg-error "no matching" } + // { dg-message "candidate" "candidate note" { target *-*-* } 47 } +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/cvt4.C b/gcc/testsuite/g++.old-deja/g++.brendan/cvt4.C new file mode 100644 index 000000000..6d62209a2 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/cvt4.C @@ -0,0 +1,27 @@ +// { dg-do assemble } +// GROUPS passed conversions +class A {}; + +template <class TP> +class B +{ + A &(*_f) (A &, TP); + TP _a; +public: + B (A &(*f) (A &, TP), TP a) : _f (f), _a (a) {} + friend A &operator<< (A &o, const B<TP> &m) + { (*m._f) (o, m._a); return o; } +}; + +A &setw (A &, int); +B<int> setw (int n) +{ + return B<int> (setw, n); +} + +A x; + +void f () +{ + x << setw (2); +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/cvt5.C b/gcc/testsuite/g++.old-deja/g++.brendan/cvt5.C new file mode 100644 index 000000000..a5f8d84b4 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/cvt5.C @@ -0,0 +1,27 @@ +// { dg-do assemble } +// GROUPS passed conversions +typedef unsigned long Array[3]; + +void sample(const unsigned long (&an_array)[3]); + +class Sample + { + public: + void simple(const Array &an_array); + static void sample(const Array &an_array); + }; + +class A + { + public: + Array array; + }; + + Sample s; + + void simple(const A &a) + { + s.simple(a.array); + sample(a.array); + Sample::sample(a.array); + } diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/def-args1.C b/gcc/testsuite/g++.old-deja/g++.brendan/def-args1.C new file mode 100644 index 000000000..c0cc071a4 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/def-args1.C @@ -0,0 +1,9 @@ +// { dg-do assemble } +// PRMS Id: 10860 +class Beige +{ +public: + static int yellow(); + void white(int green = yellow()); + void aqua(int green = Beige::yellow()); +}; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/def-fns1.C b/gcc/testsuite/g++.old-deja/g++.brendan/def-fns1.C new file mode 100644 index 000000000..8730536d0 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/def-fns1.C @@ -0,0 +1,22 @@ +// { dg-do assemble } +// GROUPS passed default-functions +class dictionary { +public: + dictionary (int); +}; + +class symbol { +public: + symbol (); +}; + +// a default ctor should not be generated for hyphenation_language, +// since a ctor has already been declared; if one is generated, there +// will be an error about not enough args to the ctor for dictionary, +// since dictionary only defines a ctor taking an int (it ALSO should +// not get a default ctor) +struct hyphenation_language { + symbol name; + dictionary exceptions; + hyphenation_language(symbol nm) : name(nm), exceptions(501) {} +}; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/delete1.C b/gcc/testsuite/g++.old-deja/g++.brendan/delete1.C new file mode 100644 index 000000000..8528b1c65 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/delete1.C @@ -0,0 +1,15 @@ +// { dg-do assemble } +// { dg-options "-pedantic-errors" } +// GROUPS passed operator-delete +/* ARM $5.3.4 */ +void f(char *p, char *q[], const char *r, const char *s[]) +{ + delete 0; /* illegal: non-pointer */// { dg-error "" } .*expected pointer.* + delete (char*)0; /* no effect */ + delete p; + delete[] q; + delete[4] q; /* ANSI forbids size arg */// { dg-error "" } anachronistic .* + delete r; /* no longer illegal: const */ + delete[] s; + delete[4] s; /* ANSI forbids size arg */// { dg-error "" } anachronistic.* +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/delete2.C b/gcc/testsuite/g++.old-deja/g++.brendan/delete2.C new file mode 100644 index 000000000..a91700343 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/delete2.C @@ -0,0 +1,26 @@ +// { dg-do run } +// GROUPS passed operator-delete +// Check that using the delete operator with a null pointer +// is allowed (as called for by The Book, pg. 259) + +extern "C" int printf (const char *, ...); + +struct base { + int member; +}; + +base* bp; + +void test () +{ + delete bp; +} + +int main () +{ + bp = (base *) 0; + test (); + + printf ("PASS\n"); + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/dtors1.C b/gcc/testsuite/g++.old-deja/g++.brendan/dtors1.C new file mode 100644 index 000000000..cb5aa280e --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/dtors1.C @@ -0,0 +1,57 @@ +// { dg-do run } +// GROUPS passed destructors +// Check that when an object of a derived class is (implicitly) +// destructed (on exit from the block in which it is declared) +// that the destructor for the base class also gets executed. +// +// (also check that this execution doesn't seg-fault) + +extern "C" int printf (const char *, ...); + +int derived_destructed; +int base_destructed; + +struct base { + int base_data_member; + + base() + { + base_data_member = 0x5e5e; + } + ~base() + { + base_destructed = 0x781f; + } +}; + +struct derived : public base { + int derived_data_member; + + derived() + { + derived_data_member = 0xe5e5; + } + ~derived() + { + derived_destructed = 0xf178; + } +}; + + +void test2 (); + +int main () +{ + test2 (); + if ((base_destructed != 0x781f) || (derived_destructed != 0xf178)) + { printf ("FAIL\n"); return 1; } + else + printf ("PASS\n"); +} + +void test2 () +{ + derived derived_object; + + derived_object.derived_data_member = 99; +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/dtors2.C b/gcc/testsuite/g++.old-deja/g++.brendan/dtors2.C new file mode 100644 index 000000000..924bf4a0b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/dtors2.C @@ -0,0 +1,75 @@ +// { dg-do run } +// GROUPS passed destructors +// Check that virtual destructors work correctly. Specifically, +// check that when you destruct an object of a derived class for +// which the base class had an explicitly declared virtual destructor +// no infinite recursion occurs. +// +// Bug description: +// The generated g++ code apparently calls the base class destructor via +// the virtual table, rather than directly. This, of course, results in the +// infinite recursion. + +extern "C" int printf (const char *, ...); + +int errors = 0; + +struct base { + int member; + base(); + virtual ~base(); +}; + +base::base() +{ +} + +base::~base() +{ +} + +struct derived : public base +{ + int member; + derived(); + ~derived(); +}; + +derived::derived() : base() +{ +} + +int derived_destructor_calls = 0; + +extern void exit (int); + +derived::~derived() +{ + if (++derived_destructor_calls > 2) + errors++; +} + +void test (); + +int main () +{ + test (); + + if (errors) + { printf ("FAIL\n"); return 1; } + else + printf ("PASS\n"); + + return 0; +} + +base* bp; + +void test() +{ + derived a; + + a.member = 99; + bp = new derived; + delete bp; +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/dtors3.C b/gcc/testsuite/g++.old-deja/g++.brendan/dtors3.C new file mode 100644 index 000000000..053bb0dae --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/dtors3.C @@ -0,0 +1,67 @@ +// { dg-do run } +// GROUPS passed destructors +// Check that member and base classes get properly destructed +// when an object of a derived class is destructed via a pointer +// to it which only has a "compile-time" type of "pointer-to-base". +// +// Note that in order for this test to work properly, the destructor +// for the base class should be explicitly declared to be virtual. + +extern "C" int printf (const char *, ...); + +int member_destructor_calls = 0; +int middle_destructor_calls = 0; + +struct member_type { + int data_member; + member_type () {} + ~member_type (); +}; + +struct base { + int data_member; + base () {} + virtual ~base (); +}; + +struct middle : public base { + member_type member1; + member_type member2; + middle () {} + ~middle (); // should be implicitly virtual +}; + +struct derived : public middle { + member_type member1; + member_type member2; + //~derived () {} +}; + +int main () +{ + base* bp = new derived; + delete bp; + derived *dp = new derived; + delete dp; + + if ((member_destructor_calls != 8) || (middle_destructor_calls != 2)) + { printf ("FAIL\n"); return 1; } + else + printf ("PASS\n"); + + return 0; +} + +member_type::~member_type () +{ + member_destructor_calls++; +} + +base::~base () +{ +} + +middle::~middle () +{ + middle_destructor_calls++; +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/eh1.C b/gcc/testsuite/g++.old-deja/g++.brendan/eh1.C new file mode 100644 index 000000000..939312a00 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/eh1.C @@ -0,0 +1,63 @@ +// { dg-do run } +// { dg-options "-O" } +// PRMS Id: 10776 + +extern "C" int printf (const char *, ...); + +class Foo +{ + public: + Foo(int n) : n_(n) { } + int f() { return n_; } + + int badTest(); + int goodTest(); + + private: + + int n_; +}; + +int Foo::badTest() +{ + try { + throw int(99); + } + + catch (int &i) { + n_ = 16; + } + + return n_; + // On the sparc, the return will use a ld [%l0],%i0 instruction. + // However %l0 was clobbered at the end of the catch block. It was + // used to do an indirect call. +} + + +int Foo::goodTest() +{ + int n; + + try { + throw int(99); + } + + catch (int &i) { + n = 16; + } + + return n_; + // The return will use a ld [%l2],%i0 instruction. Since %l2 + // contains the "this" pointer this works. +} + +int main() +{ + Foo foo(5); + foo.goodTest(); + foo.badTest(); + + // the badTest will have failed + printf ("PASS\n"); +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/enum-clash.C b/gcc/testsuite/g++.old-deja/g++.brendan/enum-clash.C new file mode 100644 index 000000000..81341df27 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/enum-clash.C @@ -0,0 +1,6 @@ +// { dg-do assemble } +// { dg-options "-pedantic-errors" } +// GROUPS passed arm +enum color {red, yellow, green=20, blue}; +color c = 1; // this should be an error// { dg-error "" } .* +int i = yellow; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/enum1.C b/gcc/testsuite/g++.old-deja/g++.brendan/enum1.C new file mode 100644 index 000000000..12b9a5f46 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/enum1.C @@ -0,0 +1,14 @@ +// { dg-do assemble } +// GROUPS passed enums +class foo { +public: + enum bar { baz = 1, bat = 7 }; +}; + +class derv : public foo { }; + +int main() +{ + foo::bar x = foo::baz; + derv::bar y = derv::bat; +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/enum10.C b/gcc/testsuite/g++.old-deja/g++.brendan/enum10.C new file mode 100644 index 000000000..97d5d8e34 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/enum10.C @@ -0,0 +1,21 @@ +// { dg-do assemble } +// GROUPS passed enums +class Type +{ + public: + + enum name + { + A + }; +}; + +class A +{ +}; + +class B: public A +{ + public: + B(); +}; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/enum11.C b/gcc/testsuite/g++.old-deja/g++.brendan/enum11.C new file mode 100644 index 000000000..009333a18 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/enum11.C @@ -0,0 +1,16 @@ +// { dg-do assemble } +// GROUPS passed enums +class X +{ + enum + { + oneMask = 0x0000FFFF, + twoMask = 0x000F0000, + thiMask = 0xFFF00000, // { dg-error "comma at end" } + }; + unsigned int foo; + +public: + X (int) : foo (oneMask | twoMask ) {} // No warning + X () : foo (oneMask | twoMask | thiMask) {} // Warning +}; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/enum12.C b/gcc/testsuite/g++.old-deja/g++.brendan/enum12.C new file mode 100644 index 000000000..fab57032a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/enum12.C @@ -0,0 +1,12 @@ +// { dg-do assemble } +// GROUPS passed enums +enum Bool { False, True }; + +enum Bool object; + +struct S +{ + Bool field:1; + + void copy_enum_bit_field () const { object = field; } +}; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/enum13.C b/gcc/testsuite/g++.old-deja/g++.brendan/enum13.C new file mode 100644 index 000000000..0d06ff1cf --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/enum13.C @@ -0,0 +1,15 @@ +// { dg-do assemble } +// GROUPS passed enums +enum COLOR { red, green, blue }; + +struct S { + COLOR color:2; +}; + +COLOR color; +S object; + +void fubar () +{ + color = object.color; +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/enum14.C b/gcc/testsuite/g++.old-deja/g++.brendan/enum14.C new file mode 100644 index 000000000..e18284458 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/enum14.C @@ -0,0 +1,4 @@ +// { dg-do assemble } +// { dg-options "-fshort-enums" } +// GROUPS passed enums + enum E { A = 0x80000000 }; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/enum2.C b/gcc/testsuite/g++.old-deja/g++.brendan/enum2.C new file mode 100644 index 000000000..b6178517b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/enum2.C @@ -0,0 +1,19 @@ +// { dg-do assemble } +// GROUPS passed enums +class foo { +public: + enum bar { baz = 1, bat = 7 }; +}; + +class foo2 { +public: + enum bar2 { baz2 = 1, bat2 = 7 }; +}; + +class derv : public foo, public foo2 { }; + +int main() +{ + foo::bar x = foo::baz; + derv::bar2 y = derv::bat2; +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/enum3.C b/gcc/testsuite/g++.old-deja/g++.brendan/enum3.C new file mode 100644 index 000000000..f11c0509f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/enum3.C @@ -0,0 +1,15 @@ +// { dg-do assemble } +// GROUPS passed enums +enum foo +{ + x = 0 +}; + +enum bar +{ + // this used to say `x' wasn't a constant, because build_enumerator + // was getting the value of x wrapped around a NOP_EXPR. It now + // strips them off before working on it, so we shouldn't get any + // errors for this. + y = (x + 0x0000) +}; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/enum4.C b/gcc/testsuite/g++.old-deja/g++.brendan/enum4.C new file mode 100644 index 000000000..ca954e1a4 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/enum4.C @@ -0,0 +1,10 @@ +// { dg-do assemble } +// GROUPS passed enums +class X { +public: + enum { a }; +}; + +enum { b = 1 }; +enum ok { y = b }; +enum notok { z = X::a }; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/enum5.C b/gcc/testsuite/g++.old-deja/g++.brendan/enum5.C new file mode 100644 index 000000000..75917d745 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/enum5.C @@ -0,0 +1,10 @@ +// { dg-do assemble } +// { dg-options "-pedantic-errors" } +// GROUPS passed enums +enum Thing { FIRST, SECOND } ; + +int main() +{ + Thing x = FIRST ; + x = 27 ; // this line should be a type error.// { dg-error "" } .* +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/enum6.C b/gcc/testsuite/g++.old-deja/g++.brendan/enum6.C new file mode 100644 index 000000000..29908b81d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/enum6.C @@ -0,0 +1,16 @@ +// { dg-do assemble } +// GROUPS passed enums +class X { + private: + enum E1 {a1, b1}; // { dg-error "" } private + public: + enum E2 {a2, b2}; + }; + +void h(X* p) { + X::E2 e2; + int x2 = X::a2; + + X::E1 e1; // { dg-error "" } within this context + int x1 = X::a1; // { dg-error "" } within this context + } diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/enum7.C b/gcc/testsuite/g++.old-deja/g++.brendan/enum7.C new file mode 100644 index 000000000..980c8ea80 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/enum7.C @@ -0,0 +1,7 @@ +// { dg-do assemble } +// GROUPS passed enums +enum color { red, green, blue, orange, brown }; + +struct s { + enum color field:2; // { dg-warning "too small" } +}; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/enum8.C b/gcc/testsuite/g++.old-deja/g++.brendan/enum8.C new file mode 100644 index 000000000..ecf6fbf4e --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/enum8.C @@ -0,0 +1,25 @@ +// { dg-do assemble } +// GROUPS passed enums +class foo1 +{ + public: + enum foo1_enum + { + ENUM1, + ENUM2, // { dg-error "comma at end" } + }; +}; + + +class foo2 +{ + private: + enum foo1::foo1_enum Enum; +}; + + +class foo3 +{ + private: + foo1::foo1_enum Enum; +}; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/enum9.C b/gcc/testsuite/g++.old-deja/g++.brendan/enum9.C new file mode 100644 index 000000000..88ecc7328 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/enum9.C @@ -0,0 +1,15 @@ +// { dg-do assemble } +// GROUPS passed enums +enum fig { + figgy, + pudding, // { dg-error "comma at end" } +}; + +class X { +public: + static fig (*open)(void *thing, const char *filename); + static fig (*parse)(void *thing); +}; + +enum fig (*X::open)(void *thing, const char *filename) = 0; +fig (*X::parse)(void *thing) = 0; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/err-msg1.C b/gcc/testsuite/g++.old-deja/g++.brendan/err-msg1.C new file mode 100644 index 000000000..2e13bfa17 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/err-msg1.C @@ -0,0 +1,6 @@ +// { dg-do assemble } +// GROUPS passed error-messages +class A { }; + +int i = A::_ter;// { dg-error "" } ._ter.* +int j = A::term;// { dg-error "" } .term.* diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/err-msg10.C b/gcc/testsuite/g++.old-deja/g++.brendan/err-msg10.C new file mode 100644 index 000000000..f5b8abf6e --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/err-msg10.C @@ -0,0 +1,6 @@ +// { dg-do assemble } +// GROUPS passed error-messages +class foo { +public: + virtual static int f () = 0;// { dg-error "" } member `f' cannot be declared both virtual and static.* +}; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/err-msg11.C b/gcc/testsuite/g++.old-deja/g++.brendan/err-msg11.C new file mode 100644 index 000000000..abfe0e127 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/err-msg11.C @@ -0,0 +1,3 @@ +// { dg-do assemble } +// GROUPS passed error-messages +void foo (mutable int x);// { dg-error "" } non-member `x' cannot be declared `mutable'.* diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/err-msg12.C b/gcc/testsuite/g++.old-deja/g++.brendan/err-msg12.C new file mode 100644 index 000000000..e9bd5a643 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/err-msg12.C @@ -0,0 +1,6 @@ +// { dg-do assemble } +// GROUPS passed error-messages +class foo { +public: + friend mutable int x ();// { dg-error "" } non-object member `x' cannot be declared `mutable' +}; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/err-msg2.C b/gcc/testsuite/g++.old-deja/g++.brendan/err-msg2.C new file mode 100644 index 000000000..e2f8d9902 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/err-msg2.C @@ -0,0 +1,8 @@ +// { dg-do assemble } +// GROUPS passed error-messages + +typedef void (*pfv)(double, double); +extern "C" { + typedef void (*pfv)(double, double); // { dg-error "" "" { xfail *-*-* } } conflicting linkage +} + diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/err-msg3.C b/gcc/testsuite/g++.old-deja/g++.brendan/err-msg3.C new file mode 100644 index 000000000..724c6f5c3 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/err-msg3.C @@ -0,0 +1,20 @@ +// { dg-do assemble } +// GROUPS passed error-messages +#include <fstream> +#include <iomanip> + +// This error should not appear: +// bug.C: In method `test::test(const class test &)': +// bug.C:8: field `' not in immediate context + +class test{ +public: + int flags; + test() {} + }; + +int main() + +{ +return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/err-msg4.C b/gcc/testsuite/g++.old-deja/g++.brendan/err-msg4.C new file mode 100644 index 000000000..2f4bc4210 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/err-msg4.C @@ -0,0 +1,10 @@ +// { dg-do assemble } +// GROUPS passed error-messages +class X { +public: + static int x;// { dg-error "" } previous.* + static int y;// { dg-error "" } previous.* +}; + +unsigned X::x;// { dg-error "" } conflict.* +unsigned X::y;// { dg-error "" } conflict.* diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/err-msg5.C b/gcc/testsuite/g++.old-deja/g++.brendan/err-msg5.C new file mode 100644 index 000000000..1837e2fc7 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/err-msg5.C @@ -0,0 +1,4 @@ +// { dg-do assemble } +// GROUPS passed error-messages +class foo {}; +~foo () {}// { dg-error "" } destructors must be member functions.* diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/err-msg6.C b/gcc/testsuite/g++.old-deja/g++.brendan/err-msg6.C new file mode 100644 index 000000000..f30856b51 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/err-msg6.C @@ -0,0 +1,7 @@ +// { dg-do assemble } +// GROUPS passed error-messages +class foo { +public: + ~bar () {}// { dg-error "" } destructor `bar' must match class name `foo'.* +}; + diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/err-msg7.C b/gcc/testsuite/g++.old-deja/g++.brendan/err-msg7.C new file mode 100644 index 000000000..0dbb3231d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/err-msg7.C @@ -0,0 +1,6 @@ +// { dg-do assemble } +// GROUPS passed error-messages +class foo { +public: + volatile int () {}// { dg-error "" } +}; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/err-msg8.C b/gcc/testsuite/g++.old-deja/g++.brendan/err-msg8.C new file mode 100644 index 000000000..dcc2028ff --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/err-msg8.C @@ -0,0 +1,3 @@ +// { dg-do assemble } +// GROUPS passed error-messages +operator int ; int j; // { dg-error "" } declaration of `operator int' as non-function.* diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/err-msg9.C b/gcc/testsuite/g++.old-deja/g++.brendan/err-msg9.C new file mode 100644 index 000000000..0dd7f09c0 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/err-msg9.C @@ -0,0 +1,6 @@ +// { dg-do assemble } +// GROUPS passed error-messages +class foo { +public: + int ~foo ();// { dg-error "" } return type specification for destructor invalid.* +}; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/explicit1.C b/gcc/testsuite/g++.old-deja/g++.brendan/explicit1.C new file mode 100644 index 000000000..2be91d4ca --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/explicit1.C @@ -0,0 +1,5 @@ +// { dg-do assemble } +// $7.1.2 disallows explicit on anything but declarations of +// constructors ... including friends. +class foo { public: foo(); }; +class bar { public: friend explicit foo::foo(); }; // { dg-error "" } explicit friend diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/friend1.C b/gcc/testsuite/g++.old-deja/g++.brendan/friend1.C new file mode 100644 index 000000000..4d9262811 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/friend1.C @@ -0,0 +1,19 @@ +// { dg-do assemble } +// GROUPS passed friends +class A +{ +private: + A () {} + +friend struct B; +}; + +class B +{ +public: + A a; +}; + +B b; + +int main () {} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/friend2.C b/gcc/testsuite/g++.old-deja/g++.brendan/friend2.C new file mode 100644 index 000000000..13d8221d1 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/friend2.C @@ -0,0 +1,15 @@ +// { dg-do assemble } +// GROUPS passed friends +class X { + int a; +friend void friend_set (X*, int); +}; + +void friend_set (X *p, int i) { p->a = i; } + +void f() +{ + X obj; + friend_set (&obj, 10); +} + diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/friend3.C b/gcc/testsuite/g++.old-deja/g++.brendan/friend3.C new file mode 100644 index 000000000..ecd85b44b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/friend3.C @@ -0,0 +1,28 @@ +// { dg-do assemble } +// GROUPS passed friends +class B { + + friend class A; + + enum { + bEnum = 1, // { dg-error "comma at end" } + }; + + int bArray[ bEnum ]; + +public: + void bFunction(int arg[ bEnum ]); +}; + + +class A { + int aMember; + +public: + void aFunction(int a[B::bEnum]) + { + B b; + b.bArray[ B::bEnum ] = aMember; + } +}; + diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/friend4.C b/gcc/testsuite/g++.old-deja/g++.brendan/friend4.C new file mode 100644 index 000000000..4d436e5c9 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/friend4.C @@ -0,0 +1,6 @@ +// { dg-do assemble } +// GROUPS passed friends +// do_friend should complain that foo was declared as a friend of +// A before A was defined +struct A; // { dg-error "forward" } +struct B { friend A::foo (); };// { dg-error "" } .* diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/groff1.C b/gcc/testsuite/g++.old-deja/g++.brendan/groff1.C new file mode 100644 index 000000000..0f26863c7 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/groff1.C @@ -0,0 +1,34 @@ +// { dg-do run } +// GROUPS passed groff +/* This should compile properly with the new overloading scheme. */ + +extern "C" int printf (const char *, ...); +extern "C" void exit (int); + +int win = 0; + +class symbol +{ +public: + symbol(const char *p, int how = 0) {} + symbol() {} +}; + +class dictionary +{ +public: + void lookup(symbol s, void *v=0) { win = 1; } + void lookup(const char *) {} +}; + +int main() +{ + char buf[2048]; + dictionary exceptions; + unsigned char *tem = new unsigned char[19 + 1]; + + exceptions.lookup (symbol (buf), tem); + + printf (win ? "PASS\n" : "FAIL\n"); + exit (! win); +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/init1.C b/gcc/testsuite/g++.old-deja/g++.brendan/init1.C new file mode 100644 index 000000000..113f12c66 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/init1.C @@ -0,0 +1,11 @@ +// { dg-do assemble } +// GROUPS passed initialization + class Thing{ + private: + int x,y; + public: + Thing (int v, int q) { x = v; q = y; } + void doit(int); + }; + + Thing t(18,19); diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/init10.C b/gcc/testsuite/g++.old-deja/g++.brendan/init10.C new file mode 100644 index 000000000..0080420bd --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/init10.C @@ -0,0 +1,3 @@ +// { dg-do assemble } +// GROUPS passed initialization +struct S { int :0; } a; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/init11.C b/gcc/testsuite/g++.old-deja/g++.brendan/init11.C new file mode 100644 index 000000000..0d3e511ae --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/init11.C @@ -0,0 +1,9 @@ +// { dg-do assemble } +// GROUPS passed initialization +struct String { + char * string; + String(const char* st); +}; + +extern char array []; +static String sub = array; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/init12.C b/gcc/testsuite/g++.old-deja/g++.brendan/init12.C new file mode 100644 index 000000000..2e3578b1a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/init12.C @@ -0,0 +1,9 @@ +// { dg-do assemble } +// GROUPS passed array-bindings +char * bob(); + +int main() +{ + char a[1][2]; + a[0] = bob();// { dg-error "" } .* +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/init13.C b/gcc/testsuite/g++.old-deja/g++.brendan/init13.C new file mode 100644 index 000000000..82d175b57 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/init13.C @@ -0,0 +1,7 @@ +// { dg-do assemble } +// GROUPS passed initialization +struct A { + operator int (); +}; + +int i = A(); diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/init2.C b/gcc/testsuite/g++.old-deja/g++.brendan/init2.C new file mode 100644 index 000000000..8f4c2d4d2 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/init2.C @@ -0,0 +1,5 @@ +// { dg-do assemble } +// GROUPS passed initialization +// this should give an error in require_instantiated_type about not +// being allowed to have an initializer list in an argument list. +int f(int a = {1});// { dg-error "" } .* diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/init3.C b/gcc/testsuite/g++.old-deja/g++.brendan/init3.C new file mode 100644 index 000000000..751297eb3 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/init3.C @@ -0,0 +1,39 @@ +// { dg-do run } +// GROUPS passed initialization +// p2766: Make sure that members are initialized in order of declaration +// in the class, not in order of specification in the mem-initializer list. + +extern "C" int printf (const char *, ...); +extern "C" void exit (int); + +int count = 0; + +void die () { printf ("FAIL\n"); exit (1); } + +class bar1 { +public: + bar1 (int) { if (count != 0) die (); count = 1; } +}; + +class bar2 +{ +public: + bar2 (int) { if (count != 1) die (); count = 2; } +}; + +class foo +{ +public: + bar1 a; + bar2 b; + foo (int, int); +}; + +// bar1 should get built before bar2 +foo::foo (int x, int y) : b(x), a(y) {} + +int main() +{ + foo f (1, 2); + printf ("PASS\n"); +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/init4.C b/gcc/testsuite/g++.old-deja/g++.brendan/init4.C new file mode 100644 index 000000000..aa2bfb658 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/init4.C @@ -0,0 +1,5 @@ +// { dg-do assemble } +// GROUPS passed initialization +struct CharList { int i; }; + +const CharList& terminals = { 1 }; // { dg-error "initializer lists" } c++0x diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/init5.C b/gcc/testsuite/g++.old-deja/g++.brendan/init5.C new file mode 100644 index 000000000..016e733cd --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/init5.C @@ -0,0 +1,6 @@ +// { dg-do assemble } +// GROUPS passed initialization +int main( int argc, char**argv, char** envp ){ + char* domain = argv[1]; + domain = domain? (char*)"component" : domain; +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/init6.C b/gcc/testsuite/g++.old-deja/g++.brendan/init6.C new file mode 100644 index 000000000..ed8c0ade2 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/init6.C @@ -0,0 +1,15 @@ +// { dg-do assemble } +// GROUPS passed initialization +class Tag { +public: + Tag(int i):value(i){} + int value; +}; + +extern const Tag myTag; +extern const Tag myTag=9; + +// The compiler should not issue an error on this line; expand_static_init +// should be checking that there's no initializer for this line, and thus +// doesn't need to produce an error. +extern const Tag myTag; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/init7.C b/gcc/testsuite/g++.old-deja/g++.brendan/init7.C new file mode 100644 index 000000000..efbf5c8cb --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/init7.C @@ -0,0 +1,16 @@ +// { dg-do assemble } +// GROUPS passed initialization +struct myChoiceList +{ + int bla; + int blubb; + int brummbrumm; +}; + +extern const myChoiceList foo; + +extern const myChoiceList foo = {1,1,1}; + +// finish_decl should have an exclusion so an error is not produced +// for this line. +extern const myChoiceList foo; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/init8.C b/gcc/testsuite/g++.old-deja/g++.brendan/init8.C new file mode 100644 index 000000000..bd49ce2ee --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/init8.C @@ -0,0 +1,16 @@ +// { dg-do assemble } +// GROUPS passed initialization +class A +{ +public: + A(const A & a) : i_member(a.i_member) + { + } + A(const int & i) : i_member(i) + { + } + union + { + int i_member; + }; +}; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/init9.C b/gcc/testsuite/g++.old-deja/g++.brendan/init9.C new file mode 100644 index 000000000..e22821022 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/init9.C @@ -0,0 +1,11 @@ +// { dg-do assemble } +// GROUPS passed initialization +int FALSE = 0; +class X { +public: + static int FALSE; +}; + +// The compiler should NOT complain about redeclaration of the global +// `FALSE' with this declaration...grokvardecl shouldn't be doing that. +int X::FALSE = 0; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/label1.C b/gcc/testsuite/g++.old-deja/g++.brendan/label1.C new file mode 100644 index 000000000..9cdc57d44 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/label1.C @@ -0,0 +1,4 @@ +// { dg-do assemble } +// GROUPS passed labels +// it should only give 1 error, about using an undefined label +int main(void) { goto dummy; }// { dg-error "" } .* diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/label2.C b/gcc/testsuite/g++.old-deja/g++.brendan/label2.C new file mode 100644 index 000000000..6d2af3262 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/label2.C @@ -0,0 +1,14 @@ +// { dg-do assemble } +// GROUPS passed labels + +extern "C" void abort(); + +class X { +public: + X(); +}; +void foo () +{ +X: ::abort(); + goto X; +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/line1.C b/gcc/testsuite/g++.old-deja/g++.brendan/line1.C new file mode 100644 index 000000000..b14ed8efa --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/line1.C @@ -0,0 +1,4 @@ +// { dg-do assemble } +// GROUPS passed error-messages +typedef struct s S;// { dg-error "" } previous.* +struct S { int member:1; }; // the lineno for this should be 2, not 0// { dg-error "" } conflicting types.* diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/misc1.C b/gcc/testsuite/g++.old-deja/g++.brendan/misc1.C new file mode 100644 index 000000000..70763619f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/misc1.C @@ -0,0 +1,6 @@ +// { dg-do assemble } +// GROUPS passed miscellaneous-bugs +int main( int argc, char**argv, char** envp ){ + char* domain = argv[1]; + domain = domain? (char*)"component" : domain; +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/misc10.C b/gcc/testsuite/g++.old-deja/g++.brendan/misc10.C new file mode 100644 index 000000000..f132d1e08 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/misc10.C @@ -0,0 +1,6 @@ +// { dg-do assemble } +// GROUPS passed miscellaneous +// The compiler shouldn't give a `invalid operands to binary +' for this +// case. +enum flag { OFF, ON }; +enum BOOL { FALSE = (enum flag) 0, TRUE }; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/misc11.C b/gcc/testsuite/g++.old-deja/g++.brendan/misc11.C new file mode 100644 index 000000000..9f401cf1e --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/misc11.C @@ -0,0 +1,20 @@ +// { dg-do assemble } +// GROUPS passed miscellaneous +// This should not complain about A::f being abstract. +struct A +{ + virtual int f() = 0; +}; + +struct B : virtual A +{ + virtual int f() { return 1; } + virtual int g() = 0; +}; + +struct C: B +{ + int g() { return 2; } +}; + +C c; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/misc14.C b/gcc/testsuite/g++.old-deja/g++.brendan/misc14.C new file mode 100644 index 000000000..09242a46f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/misc14.C @@ -0,0 +1,13 @@ +// { dg-do assemble } +// GROUPS passed miscellaneous-bugs +class X { +public: + enum e { + New // { dg-error "conflicts with previous" } + , // { dg-error "comma at end" } + }; + + static int New(int); // { dg-error "declaration of" } +}; + +int main() {} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/misc15.C b/gcc/testsuite/g++.old-deja/g++.brendan/misc15.C new file mode 100644 index 000000000..2c5f1ae03 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/misc15.C @@ -0,0 +1,13 @@ +// { dg-do assemble } +// GROUPS passed miscellaneous-bugs + +struct A { + int aa; +}; +struct B : public A { +}; +struct C : public A { +}; +struct D : public C, public B { + void fun() { C::aa = 10; } +}; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/misc16.C b/gcc/testsuite/g++.old-deja/g++.brendan/misc16.C new file mode 100644 index 000000000..bc19edc2d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/misc16.C @@ -0,0 +1,19 @@ +// { dg-do assemble } +// GROUPS passed miscellaneous-bugs +// Using a typedef causes a compiler error +typedef unsigned int Uint32; + +// Using a define so that there isn't a typedef works OK. +//#define Uint32 unsigned int + +Uint32 func0(Uint32, Uint32) +{ + return 0; +} + +Uint32 func1(Uint32, Uint32) +{ + return 1; +} + +Uint32 (*mf[])(Uint32, Uint32) = {func0, func1}; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/misc17.C b/gcc/testsuite/g++.old-deja/g++.brendan/misc17.C new file mode 100644 index 000000000..405266415 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/misc17.C @@ -0,0 +1,36 @@ +// { dg-do assemble } +// GROUPS passed miscellaneous-bugs +typedef int va_list; +class ostream; +class String { +public: +operator const char *() const; +}; +class FwtErrorManager { +public: + FwtErrorManager(ostream& err, const char *program); +public: + void form(const char *format, ...); +protected: + const String _program; +private: + FwtErrorManager(const FwtErrorManager&); + void operator=(const FwtErrorManager&); +}; +class FwtProgram: public FwtErrorManager { +public: + FwtProgram(); +}; +class FwtArgOptions { }; +class FwtStdProgram: public FwtProgram, public FwtArgOptions { +public: + FwtStdProgram(); + void usage_if_not_complete(); +}; +void +FwtStdProgram::usage_if_not_complete() +{ + FwtStdProgram& thisp = *this; + thisp.form("%s: error, there were unrecognized options", + (char *) FwtErrorManager::_program);// { dg-error "" } .* +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/misc2.C b/gcc/testsuite/g++.old-deja/g++.brendan/misc2.C new file mode 100644 index 000000000..4e217d82b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/misc2.C @@ -0,0 +1,11 @@ +// { dg-do assemble } +// GROUPS passed miscellaneous-bugs +// Should be fixed by: +// Sun Jun 13 12:55:22 1993 Brendan Kehoe (brendan@lisa.cygnus.com) +// +// * cp-decl.c (grokvardecl): Don't complain about duplicate +// definitions of `extern "C"' declarations (parallelize it with how +// regular `extern' decls are handled). + +extern "C" double _MaXdOuB, _MiNdOuB; +extern "C" double _MaXdOuB, _MiNdOuB; // no error should be emitted for this diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/misc3.C b/gcc/testsuite/g++.old-deja/g++.brendan/misc3.C new file mode 100644 index 000000000..c2a116519 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/misc3.C @@ -0,0 +1,12 @@ +// { dg-do assemble } +// GROUPS passed miscellaneous-bugs +// The compiler should not error about taking the addr of main in this example. +class fred { +private: + void main () { + } +public: + fred ( ) { + &fred::main; + } +}; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/misc4.C b/gcc/testsuite/g++.old-deja/g++.brendan/misc4.C new file mode 100644 index 000000000..d9df9561d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/misc4.C @@ -0,0 +1,10 @@ +// { dg-do assemble } +// GROUPS passed miscellaneous +// This should not emit an error about A::~A() being redefined; we +// should check that it is a pure virtual. +class A { +public: + virtual ~A() = 0; +}; + +A::~A() {} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/misc5.C b/gcc/testsuite/g++.old-deja/g++.brendan/misc5.C new file mode 100644 index 000000000..35642abd5 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/misc5.C @@ -0,0 +1,7 @@ +// { dg-do assemble } +// GROUPS passed miscellaneous +class A { + static A aa[2]; +}; + +A A::aa[2]; // should be completely legal diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/misc6.C b/gcc/testsuite/g++.old-deja/g++.brendan/misc6.C new file mode 100644 index 000000000..93b241b9e --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/misc6.C @@ -0,0 +1,9 @@ +// { dg-do assemble } +// GROUPS passed miscellaneous +// test that use of `inline' is forbidden when it should be +inline int i;// { dg-error "" } .* +struct c { inline int i; };// { dg-error "" } .* +int foo (inline int i);// { dg-error "" } .* +inline class c; // { dg-error "'inline' can only be specified for functions" } inline +inline typedef int t; // { dg-error "" } inline +class d { inline friend class c; }; // { dg-error "'inline' can only be specified for functions" } inline diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/misc7.C b/gcc/testsuite/g++.old-deja/g++.brendan/misc7.C new file mode 100644 index 000000000..af61f92e3 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/misc7.C @@ -0,0 +1,16 @@ +// { dg-do run } +// GROUPS passed miscellaneous +extern "C" int printf (const char *, ...); + +int main() +{ + int i = 0; + // Make sure build_unary_op correctly computes this. + int *pi = &(++i); + *pi = 4; + + if (i != 4) + { printf ("FAIL\n"); return 1; } + else + printf ("PASS\n"); +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/misc8.C b/gcc/testsuite/g++.old-deja/g++.brendan/misc8.C new file mode 100644 index 000000000..f06393c93 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/misc8.C @@ -0,0 +1,18 @@ +// { dg-do assemble } +// GROUPS passed miscellaneous +// used to say invalid lvalue in `&\' +class foo { + int a; + public: + foo(int a); +}; + +foo::foo(int a) +{ + foo::a=a; +} + +int main() +{ +foo obj(4); +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/misc9.C b/gcc/testsuite/g++.old-deja/g++.brendan/misc9.C new file mode 100644 index 000000000..0ec12cb30 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/misc9.C @@ -0,0 +1,28 @@ +// { dg-do assemble } +// GROUPS passed miscellaneous +//The program listed below produces the following error during compilation: +// % g++ bug17.cc +// bug17.cc: In method `class Y& Y::operator = (const class Y&)': +// bug17.cc:18: invalid use of non-lvalue array + +class X { +public: + X& operator=(const X&) { return *this; } +}; + +struct S { + char c[10]; + X x; +}; + +class Y { + S s; +public: + const S& f() const { return s; } + + Y& operator=(const Y& _Y) { + s = _Y.s; // this line compiles + s = _Y.f(); // this line does not compile + return *this; + } +}; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/mutable1.C b/gcc/testsuite/g++.old-deja/g++.brendan/mutable1.C new file mode 100644 index 000000000..7840ac8d9 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/mutable1.C @@ -0,0 +1,6 @@ +// { dg-do assemble } +// GROUPS passed mutable +class foo; +class bar { + mutable foo const *foobar; +}; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/nest1.C b/gcc/testsuite/g++.old-deja/g++.brendan/nest1.C new file mode 100644 index 000000000..842b2f692 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/nest1.C @@ -0,0 +1,15 @@ +// { dg-do assemble } +// GROUPS passed nested-classes +int x; +class enclose { +public: + int x; // { dg-error "non-static" } + + class inner { + public: + void f (int i) { + x = i;// { dg-error "" } .* + } + }; +}; + diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/nest10.C b/gcc/testsuite/g++.old-deja/g++.brendan/nest10.C new file mode 100644 index 000000000..17db4f0a1 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/nest10.C @@ -0,0 +1,30 @@ +// { dg-do assemble } +// GROUPS passed nested-classes +class A + { + public: + class B + { + public: + int f (); + void g (int); + private: + int b; + }; + }; + +int A::B::f () + { + int val=b; + return val; + } + +void A::B::g (int val) + { + b = val; + } + + +int main () + { + } diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/nest11.C b/gcc/testsuite/g++.old-deja/g++.brendan/nest11.C new file mode 100644 index 000000000..0c6d475de --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/nest11.C @@ -0,0 +1,21 @@ +// { dg-do assemble } +// GROUPS passed nested-classes +class A { + int x; + + struct B { + int x; + }; + struct C; + friend struct C; + struct C { + int bug (A::B &y); + }; +}; + +int +A::C::bug (A::B &y) +{ + return y.x; +} + diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/nest12.C b/gcc/testsuite/g++.old-deja/g++.brendan/nest12.C new file mode 100644 index 000000000..42727290f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/nest12.C @@ -0,0 +1,21 @@ +// { dg-do assemble } +// GROUPS passed nested-classes +struct enclose { + class nested; + nested *nptr; + class nested { + int x; + }; + void f(); +}; + +void enclose::f() +{ + nptr = new enclose::nested; +} + +void g() +{ + enclose obj; + obj.nptr = new enclose::nested; +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/nest13.C b/gcc/testsuite/g++.old-deja/g++.brendan/nest13.C new file mode 100644 index 000000000..d9a8b6e7e --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/nest13.C @@ -0,0 +1,20 @@ +// { dg-do assemble } +// GROUPS passed nested-classes +// The bug here is that wer'e getting a message about inner not +// being a basetype itself. I think it's because it's being +// compared as the "inner" we knew about when it was forward-declared, +// versus the "inner" we know about when it *has* been defined. + +class temp +{ +public: + struct inner; + inner *trump() + { + return (tt); + } + struct inner + { + int ll; + }*tt; +}; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/nest15.C b/gcc/testsuite/g++.old-deja/g++.brendan/nest15.C new file mode 100644 index 000000000..5d3a0b476 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/nest15.C @@ -0,0 +1,37 @@ +// { dg-do assemble } +// GROUPS passed nested-classes +class BDDHeap { +public: + BDDHeap(); + BDDHeap(const BDDHeap&); + + class Page { + public: + int i; + }; + struct Pointer { + Page *page; + unsigned index; + + Pointer(); + Pointer(const BDDHeap& heap); + }; + + struct Half { + struct { + Page *top; + Page **tail; + } inuse; + + Half(); + }; + + Half half[2]; + unsigned halfspace; +}; + +inline +BDDHeap::Pointer::Pointer(const BDDHeap& heap): +page(heap.half[heap.halfspace].inuse.top), +index(0) +{ } diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/nest16.C b/gcc/testsuite/g++.old-deja/g++.brendan/nest16.C new file mode 100644 index 000000000..72c0078be --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/nest16.C @@ -0,0 +1,41 @@ +// { dg-do assemble } +// GROUPS passed nested-classes +class BDDHeap { +public: + BDDHeap(); + BDDHeap(const BDDHeap&); + + class Page { + public: + int i; + }; + struct Pointer { + Page *page; + unsigned index; + + Pointer(); + Pointer(const BDDHeap& heap); + }; + + struct Half { + struct { + Page *top; + Page **tail; + } inuse; + + Half(); + }; + + Half half[2]; + unsigned halfspace; +}; + +inline +BDDHeap::Pointer::Pointer(const BDDHeap& heap): +page(0), +index(0) +{ + Page *x = heap.half[heap.halfspace].inuse.top; + page = x; +} + diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/nest17.C b/gcc/testsuite/g++.old-deja/g++.brendan/nest17.C new file mode 100644 index 000000000..94b8fbdc2 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/nest17.C @@ -0,0 +1,12 @@ +// { dg-do assemble } +// GROUPS passed nested-classes +class T { +public: + typedef int I; + class Y {int y;}; + typedef Y Z; +}; + +T::I i; +T::Y y; +T::Z z; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/nest18.C b/gcc/testsuite/g++.old-deja/g++.brendan/nest18.C new file mode 100644 index 000000000..e62382781 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/nest18.C @@ -0,0 +1,31 @@ +// { dg-do assemble } +// GROUPS passed nested-classes +// This is the first line of file ||t2.C||. + +// This code demonstrates what appears to be a bug with nested types. +// In C++, nested typedefs are not supposed to be visible outside +// their class scopes but they apparently are in gcc 2.4.5. This code +// compiles fine in AT&T cfront 3.0.1, but will not compile with gcc. + +// If this class does not precede String, then the code will compile. + +class Another { +public: + typedef int Length; +}; + +// If String does not define typedef int Length, then the code will +// compile. + +class String { +public: + typedef int Length; // remove this and it will compile fine + + int foo(Length length) const; +}; + +int String::foo(Length length) const { + return length; +} + +// File ||t2.C|| ends here. diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/nest19.C b/gcc/testsuite/g++.old-deja/g++.brendan/nest19.C new file mode 100644 index 000000000..01ae3d002 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/nest19.C @@ -0,0 +1,40 @@ +// { dg-do assemble } +// GROUPS passed nested-classes +// This is the first line of file ||t3.C||. + +// This code demonstrates a variation of the same problem with nested +// types. In C++, nested typedefs are not supposed to be visible +// outside their class scopes but they apparently are in gcc 2.4.5. +// This code compiles fine in AT&T cfront 3.0.1, but gcc rejects it +// with the messages given below. + +// If this class does not precede Expr, then the code will compile. + +class Another { +public: + typedef int Boolean; + enum { FALSE, TRUE }; +}; + +// If Expr does not define typedef int Boolean, then the code will +// compile. + +class Expr { +public: + typedef int Boolean; + enum { FALSE, TRUE }; + void foo(); + void call_something_with(Boolean); +}; + +// t3.C: In method `void Expr::foo ()': +// t3.C:36: uninitialized const `Boolean' +// t3.C:36: parse error before `=' +// t3.C:37: `argument' undeclared (first use this function) +// t3.C:37: (Each undeclared identifier is reported only once +// t3.C:37: for each function it appears in.) + +void Expr::foo() { + const Boolean argument = TRUE; + call_something_with(argument); +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/nest2.C b/gcc/testsuite/g++.old-deja/g++.brendan/nest2.C new file mode 100644 index 000000000..dc61625ec --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/nest2.C @@ -0,0 +1,18 @@ +// { dg-do assemble } +// GROUPS passed nested-classes +class A { +protected: + class B { + public: + ~B(); + private: + float _datum; + }; +private: + B *_b; +}; + +A::B::~B() +{ + _datum = 8.0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/nest20.C b/gcc/testsuite/g++.old-deja/g++.brendan/nest20.C new file mode 100644 index 000000000..1b2c9419a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/nest20.C @@ -0,0 +1,30 @@ +// { dg-do assemble } +// GROUPS passed nested-classes +// This is the first line of file ||t5.C||. + +// This code initializing an unnamed union inside a class appears to +// be legal C++ input and compiles fine with AT&T cfront 3.0.1, but +// gcc 2.4.5 complains about multiple initializations of the same +// member. + +class Expr { +public: + enum Type { undefined, slong, ulong, ldouble }; + Expr(); + Expr(Type type, const Expr* initializer); +private: + Type type_; + union { + long slong_; + unsigned long ulong_; + long double ldouble_; + }; +}; + +// Construct an undefined expression. + +Expr::Expr() + : + type_(undefined), + slong_(-1) +{} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/nest21.C b/gcc/testsuite/g++.old-deja/g++.brendan/nest21.C new file mode 100644 index 000000000..62ddab156 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/nest21.C @@ -0,0 +1,97 @@ +// { dg-do run } +// GROUPS passed nested-classes +#include <iostream> +#include <cstdio> +#include <cstring> + +static char output[1024]; + +class BDDRetrace { +public: + class Dump { + public: + virtual Dump& operator<<(char c) = 0; + virtual Dump& operator<<(int i) = 0; + virtual Dump& operator<<(double r) = 0; + }; + + class Dump1: public Dump { + public: + Dump& operator<<(char c); + Dump& operator<<(int i); + Dump& operator<<(double r); + }; +}; + +class Dump2: public BDDRetrace::Dump { +public: + BDDRetrace::Dump& operator<<(char c); + BDDRetrace::Dump& operator<<(int i); + BDDRetrace::Dump& operator<<(double r); +}; + +BDDRetrace::Dump& +BDDRetrace::Dump1::operator<<(char c) +{ char tempout[1024]; + std::sprintf(tempout, "%s%s%c", output, "1-", c); + std::strcpy(output, tempout); + return *this; +} + +BDDRetrace::Dump& +BDDRetrace::Dump1::operator<<(int i) +{ char tempout[1024]; + std::sprintf (tempout, "%s%s%d", output, "1-", i); + std::strcpy (output, tempout); + return *this; } + +BDDRetrace::Dump& +BDDRetrace::Dump1::operator<<(double r) +{ char tempout[1024]; + std::sprintf (tempout, "%s%s%1.0f", output, "1-", r); + std::strcpy (output, tempout); + return *this; } + +BDDRetrace::Dump& +Dump2::operator<<(char c) +{ char tempout[1024]; + std::sprintf (tempout, "%s%s%c", output, "2-", c); + std::strcpy (output, tempout); + return *this; } + +BDDRetrace::Dump& +Dump2::operator<<(int i) +{ char tempout[1024]; + std::sprintf (tempout, "%s%s%d", output, "2-", i); + std::strcpy (output, tempout); + return *this; } + +BDDRetrace::Dump& +Dump2::operator<<(double r) +{ char tempout[1024]; + std::sprintf (tempout, "%s%s%1.0f", output, "2-", r); + std::strcpy (output, tempout); + return *this; } + +int main() +{ + BDDRetrace::Dump1 d1; + Dump2 d2; + + std::sprintf (output, " "); + + d1 << 'a'; + d1 << 1; + d1 << 1.0; + + d2 << 'a'; + d2 << 1; + d2 << 1.0; + + if (std::strcmp (output, " 1-a1-11-12-a2-12-1") == 0) + std::printf ("PASS\n"); + else + { std::printf ("FAIL\n"); return 1; } + + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/nest22.C b/gcc/testsuite/g++.old-deja/g++.brendan/nest22.C new file mode 100644 index 000000000..dfbc03818 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/nest22.C @@ -0,0 +1,7 @@ +// { dg-do assemble } +// GROUPS passed nested-classes +class foo { +public: + typedef int bar; + foo::bar fb; // this line causes a syntax error! +}; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/nest23.C b/gcc/testsuite/g++.old-deja/g++.brendan/nest23.C new file mode 100644 index 000000000..c62ba9fef --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/nest23.C @@ -0,0 +1,15 @@ +// { dg-do assemble } +// GROUPS passed nested-classes +class CS { +public: + class PS { + }; +}; + +class NCS: public CS { +public: + class S: public PS { + }; +}; + +int i; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/nest24.C b/gcc/testsuite/g++.old-deja/g++.brendan/nest24.C new file mode 100644 index 000000000..31ab87588 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/nest24.C @@ -0,0 +1,14 @@ +// { dg-do assemble } +// GROUPS passed nested-classes +struct A { + A (){} +}; + +void foo () +{ + struct B {}; + + struct S : B { + A a; + }; +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/nest3.C b/gcc/testsuite/g++.old-deja/g++.brendan/nest3.C new file mode 100644 index 000000000..0f405eb05 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/nest3.C @@ -0,0 +1,12 @@ +// { dg-do assemble } +// GROUPS passed nested-classes +class X { +public: + struct M2 { int m; }; + M2 g(int); +}; + + +X::M2 X::g(int i) { X::M2 m2; return m2; } + +int main() { } diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/nest4.C b/gcc/testsuite/g++.old-deja/g++.brendan/nest4.C new file mode 100644 index 000000000..f7af04df9 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/nest4.C @@ -0,0 +1,9 @@ +// { dg-do assemble } +// { dg-options "-pedantic-errors" } +// GROUPS passed nested-classes +class vec { + class blah { }; + + ::vec::blah satan( 0);// { dg-error "" } .* + blah herman( 0);// { dg-error "" } .* +}; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/new-array.C b/gcc/testsuite/g++.old-deja/g++.brendan/new-array.C new file mode 100644 index 000000000..5737c99bc --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/new-array.C @@ -0,0 +1,18 @@ +// { dg-do assemble } +// GROUPS passed operator-new +typedef struct { + int a; +} AStruct; + +void MakeBug() { + AStruct *job; + + // This used to crash, it should now give error(s). + job = new AStruct[];// { dg-error "" } .* + + job = new AStruct; +} + +int main () { + MakeBug(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/new1.C b/gcc/testsuite/g++.old-deja/g++.brendan/new1.C new file mode 100644 index 000000000..42efbc172 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/new1.C @@ -0,0 +1,5 @@ +// { dg-do assemble } +// GROUPS passed operator-new +typedef __SIZE_TYPE__ size_t; +struct x { int a; void * operator new (size_t, void *); }; +struct x * f(void *p) { return new (p) x; } diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/new2.C b/gcc/testsuite/g++.old-deja/g++.brendan/new2.C new file mode 100644 index 000000000..2fd55c764 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/new2.C @@ -0,0 +1,68 @@ +// { dg-do run } +// GROUPS passed operator-new +// Check that if there is a user defined class-specific operator +// new for a given class, that operator is invoked when a new +// object of the class is requested, regardless of whether or not +// there is also a constructor for the given class, and regardless +// of whether or not the constructor for the given class is defined +// before or after the new operator is even declared. + +extern "C" int printf (const char *, ...); + +typedef __SIZE_TYPE__ size_t; + +struct base { + int i; + + base () + { + i = 7; + } + + void * operator new (size_t size); + void operator delete (void*); +}; + +class derived : public base { + int j; +}; + +int new_call_count = 0; +int expected_size = 0; +int errors = 0; + +int main () +{ + base* base_ptr; + derived* derived_ptr; + + expected_size = sizeof (int); + base_ptr = new base; + expected_size = 2 * sizeof (int); + derived_ptr = new derived (); + + if ((new_call_count != 2) || (errors != 0)) + { printf ("FAIL\n"); return 1; } + else + printf ("PASS\n"); + + return 0; +} + +int allocation_space[100]; +int* allocation_ptr = allocation_space; + +void base::operator delete (void* p) +{ +} + +void *base::operator new (size_t size) +{ + int* return_value = allocation_ptr; + + new_call_count++; + if (size != expected_size) + errors++; + allocation_ptr += (size + sizeof(int) - 1) / sizeof(int); + return (void*) return_value; +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/new3.C b/gcc/testsuite/g++.old-deja/g++.brendan/new3.C new file mode 100644 index 000000000..791d00bac --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/new3.C @@ -0,0 +1,43 @@ +// This test fails on VxWorks in kernel mode because it depends on the +// library version of "::operator new[]" calling the "::operator new" +// defined in this module. This doesn't work because the library version +// of "::operator new[]" is built into the kernel itself; library relocations +// are resolved when the kernel is linked. +// { dg-do run { xfail { powerpc-ibm-aix* || vxworks_kernel } } } +// { dg-options "-flat_namespace" { target *-*-darwin[67]* } } +// GROUPS passed operator-new +#include <stdio.h> +#include <stdlib.h> +#include <new> + +int pass = 0; + +void *operator new(size_t sz) throw (std::bad_alloc) { + + void *p; + + pass = 1; + p = malloc(sz); + return p; +} + +class A { +public: + A() {} + ~A() {} + + int a; + int b; +}; + + +int main() +{ + A *bb = new A[10]; + delete [] bb; + + if (pass) + printf ("PASS\n"); + else + { printf ("FAIL\n"); return 1; } +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/ns1.C b/gcc/testsuite/g++.old-deja/g++.brendan/ns1.C new file mode 100644 index 000000000..5b6ea3861 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/ns1.C @@ -0,0 +1,18 @@ +// { dg-do assemble } +// GROUPS passed old-abort +struct B +{ + void f(char); + void g(char); +}; + +class C +{ + int g(); +}; + +class D2 : public B +{ + using B::f; // ok: B is a base of D2 + using C::g; // { dg-error "not a base type" } +}; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/operators1.C b/gcc/testsuite/g++.old-deja/g++.brendan/operators1.C new file mode 100644 index 000000000..b1499bf1e --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/operators1.C @@ -0,0 +1,14 @@ +// { dg-do assemble } +// GROUPS passed operators +struct A { + int x; +}; + +int operator()(A x,float y) { // MUST be a member function// { dg-error "" } .* + return 1; +} + +int main() { + A x; + x(1.0); // { dg-error "" } no match for call +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/operators2.C b/gcc/testsuite/g++.old-deja/g++.brendan/operators2.C new file mode 100644 index 000000000..7ca114e75 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/operators2.C @@ -0,0 +1,4 @@ +// { dg-do assemble } +// GROUPS passed operators +class X { }; +void operator[](X& a, X& b) {} // MUST be a member function// { dg-error "" } .* diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/operators3.C b/gcc/testsuite/g++.old-deja/g++.brendan/operators3.C new file mode 100644 index 000000000..20bece7c6 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/operators3.C @@ -0,0 +1,4 @@ +// { dg-do assemble } +// GROUPS passed operators +class X { }; +void operator->(X& a, X& b) {} // MUST be a member function// { dg-error "" } .* diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/operators4.C b/gcc/testsuite/g++.old-deja/g++.brendan/operators4.C new file mode 100644 index 000000000..6408815cd --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/operators4.C @@ -0,0 +1,124 @@ +// { dg-do assemble } +// { dg-options "" } + +// GROUPS passed operators +// Check that the & operator, when applied to a global function +// or member function returns a proper value as long as the context +// in which the result of & is used requires a pointer to a specific +// unambigous (function-pointer) type. +// +// This test fails (in test5()) when compiled with g++ 1.34.1. + +extern "C" int printf (const char *, ...); + +int function (char c); +int function (float f); + +class base { + int filler; +public: + int method (char); + int method (float); +}; + +void* vp; + +typedef int (*ptr_to_func_of_char)(char); +typedef int (*ptr_to_func_of_float)(float); +typedef int (base::*ptr_to_method_of_char)(char); +typedef int (base::*ptr_to_method_of_float)(float); + +int test2 (void*); +int test3 (void*); +int test4 (void*); +int test5 (void*); + +base* base_ptr; + +int fail () +{ + printf ("FAIL\n"); + return 1; +} + +int main () +{ + base_ptr = new base; + + ptr_to_func_of_char p0 = &function; + vp = (void*) p0; + if (test2 (vp)) + return fail (); + ptr_to_func_of_float p1 = &function; + vp = (void*) p1; + if (test3 (vp)) + return fail (); + ptr_to_method_of_char p2 = &base::method; + vp = (void*) p2; // { dg-warning "converting" } + if (test4 (vp)) + return fail (); + ptr_to_method_of_float p3 = &base::method; + vp = (void*) p3; // { dg-warning "converting" } + if (test5 (vp)) + return fail (); + + printf ("PASS\n"); + return 0; +} + +int test2 (void* vp) +{ + char ch = 'x'; + + return (((ptr_to_func_of_char)vp)(ch) != 9901); +} + +int test3 (void* vp) +{ + float flt = 9.9; + + return (((ptr_to_func_of_float)vp)(flt) != 9902); +} + +int test4 (void* vp) +{ + char ch = 'x'; + ptr_to_method_of_char p = (ptr_to_method_of_char) vp; // { dg-error "invalid cast" } bad type conversion + + return ((base_ptr->*p)(ch) != 9904); +} + +int test5 (void* vp) +{ + float flt = 9.9; + ptr_to_method_of_float p = (ptr_to_method_of_float) vp; // { dg-error "invalid cast" } bad type conversion + + if ((base_ptr->*p)(flt) != 9905) { + return 1; + } else + return 0; +} + +int function (char c) +{ + c = c; + return 9901; +} + +int function (float f) +{ + f = f; + return 9902; +} + +int base::method (char c) +{ + c = c; + return 9904; +} + +int base::method (float f) +{ + f = f; + return 9905; +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/operators5.C b/gcc/testsuite/g++.old-deja/g++.brendan/operators5.C new file mode 100644 index 000000000..dedec9045 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/operators5.C @@ -0,0 +1,53 @@ +// { dg-do run } +// GROUPS passed operators +// Check that operators may be (directly) recursive. + +extern "C" int printf (const char *, ...); + +struct base { + int i; +}; + +base base_variable; + +base operator+ (const base& left, const base& right) +{ + base ret_val; + + ret_val.i = left.i + right.i; + return ret_val; +} + +base operator- (const base& left, int right) +{ + base ret_val; + + ret_val.i = left.i - right; + return ret_val; +} + +// Define the unary ! operator for class base to be the fibonachi +// operator. + +base operator! (const base& right) +{ + if (right.i < 2) + return right; + else + return ((!(right-1)) + (!(right-2))); +} + +int main () +{ + base k; + + k.i = 15; + k = !k; // fib it! + + if (k.i != 610) + { printf ("FAIL\n"); return 1; } + else + printf ("PASS\n"); + + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/operators6.C b/gcc/testsuite/g++.old-deja/g++.brendan/operators6.C new file mode 100644 index 000000000..8ac3df13f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/operators6.C @@ -0,0 +1,11 @@ +// { dg-do assemble } +// GROUPS passed operators +class a { +public: + a* operator->() { return this; } + void p(); +}; + +void a::p() { + operator->(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/operators7.C b/gcc/testsuite/g++.old-deja/g++.brendan/operators7.C new file mode 100644 index 000000000..8ceaf3efa --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/operators7.C @@ -0,0 +1,13 @@ +// { dg-do assemble } +// GROUPS passed operators +class A { + char *p; +public: + operator const char *() const { return p; } +}; + +int foo(const A &a) +{ + return (a != 0); +} + diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/operators8.C b/gcc/testsuite/g++.old-deja/g++.brendan/operators8.C new file mode 100644 index 000000000..728918875 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/operators8.C @@ -0,0 +1,11 @@ +// { dg-do assemble } +// GROUPS passed operators +struct A { + char *p; + operator char *(); +}; + +char foo(A a) +{ + return a[0]; +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/overload1.C b/gcc/testsuite/g++.old-deja/g++.brendan/overload1.C new file mode 100644 index 000000000..1b9415b0e --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/overload1.C @@ -0,0 +1,22 @@ +// { dg-do assemble } +// GROUPS passed overloading +class Foo +{ +public: + int f (void); +}; + +class Bar : public Foo +{ +public: + int f (int); // { dg-message "Bar::f|candidate expects" } +}; + +int main () +{ + Bar b; + + b.f ();// { dg-error "no matching" } + // { dg-message "candidate" "candidate note" { target *-*-* } 19 } + b.f (10); +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/overload10.C b/gcc/testsuite/g++.old-deja/g++.brendan/overload10.C new file mode 100644 index 000000000..6ed0a3c83 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/overload10.C @@ -0,0 +1,25 @@ +// { dg-do assemble } +// GROUPS passed overloading +class Bed { + public: + static void bed_func( + int (*f)(int &, int, int)); +}; +class g_func { +public: + static int save_status; + + // in compute_harshness, we should be using comptypes, not ==, to + // check if this is equivalent to the previous decl; the only + // difference is the default arg + static int rpt_func(int &status, int expand, + int restore_cursor=1 ); +}; + +int main (int argc, + char **argv, + char **envp) +{ + Bed::bed_func(g_func::rpt_func); + return(1); +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/overload11.C b/gcc/testsuite/g++.old-deja/g++.brendan/overload11.C new file mode 100644 index 000000000..0e8df404c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/overload11.C @@ -0,0 +1,11 @@ +// { dg-do assemble } +// GROUPS passed overloading +class foo_int +{ +public: + int & i; + + foo_int (int &j) : i(j) {} + void inc () { i++; } + +}; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/overload2.C b/gcc/testsuite/g++.old-deja/g++.brendan/overload2.C new file mode 100644 index 000000000..0d8ad4833 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/overload2.C @@ -0,0 +1,44 @@ +// { dg-do run } +// GROUPS passed overloading +// Check that calls to the correct overloaded virtual +// functions are generated even where the type of the formal +// arguments for the overloadings are similar or related. + +extern "C" int printf (const char *, ...); + +int proper_method_called = 0; + +struct base { + int member; + virtual void method (char) + { + } + virtual void method (char *) + { + } +}; + +struct derived : public base { + int member; + virtual void method (char) + { + } + virtual void method (char *) + { + proper_method_called++; + } +}; + +char *message; + +int main () +{ + derived derived_object; + + derived_object.method (message); + + if (proper_method_called != 1) + { printf ("FAIL\n"); return 1; } + else + printf ("PASS\n"); +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/overload3.C b/gcc/testsuite/g++.old-deja/g++.brendan/overload3.C new file mode 100644 index 000000000..49f9d6931 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/overload3.C @@ -0,0 +1,27 @@ +// { dg-do assemble } +// GROUPS passed overloading +typedef int rutBoolean; + +class rutBigIntRep +{ +public: + friend rutBoolean operator>(const rutBigIntRep& a, const rutBigIntRep& b); + operator rutBoolean() const; +protected: + enum Kluge {kluge}; + rutBigIntRep(Kluge) {} + rutBigIntRep(); + rutBigIntRep(const rutBigIntRep& value); + rutBigIntRep& operator=(const rutBigIntRep& value); +}; + +rutBoolean operator>(const rutBigIntRep& a, const rutBigIntRep& b) { + // This should not result in a warning. It used to warn about the + // conversion from int to enum while exploring the possibility of + // converting `a' via `operator rutBoolean', then using the + // rutBigIntRep(Kluge) constructor. It later realizes it shouldn't + // do this, but the call to build_type_conversion was ending up with + // a warning in convert. + rutBigIntRep diff(a); + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/overload4.C b/gcc/testsuite/g++.old-deja/g++.brendan/overload4.C new file mode 100644 index 000000000..6206d0b9e --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/overload4.C @@ -0,0 +1,24 @@ +// { dg-do assemble } +// GROUPS passed overloading + typedef void * (*NewObject) (void); + + class B + { + public: + static void WantsNew (NewObject creator); // { dg-message "B::WantsNew|no known conversion" } + }; + + class A + { + public: + static A * NewOne (void); + + static void InitClass (void) + { + B::WantsNew ( (NewObject) A::NewOne ); + // This used to die in convert_harshness_{ansi,old} cuz it + // didn't know what to do about a void type. + B::WantsNew ( A::NewOne );// { dg-error "no matching" } + // { dg-message "candidate" "candidate note" { target *-*-* } 21 } + } + }; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/overload5.C b/gcc/testsuite/g++.old-deja/g++.brendan/overload5.C new file mode 100644 index 000000000..d5c25dbbe --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/overload5.C @@ -0,0 +1,23 @@ +// { dg-do assemble } +// GROUPS passed overloading +class Foo +{ +public: + int operator << (const signed char&); + int operator << (const unsigned char&); + int operator << (const short&); + int operator << (const unsigned short&); + int operator << (const long&); + int operator << (const unsigned long&); +}; + +int main () +{ + Foo fd; + + // We fixed convert_harshness_ansi so it considers the call to + // <<(const signed char&) to be a trivial conversion. It used + // to always make it a standard conversion, which made it conflict + // with <<(const unsigned char &), which is really a std conv. + fd << (signed char) 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/overload6.C b/gcc/testsuite/g++.old-deja/g++.brendan/overload6.C new file mode 100644 index 000000000..1f7fdfa57 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/overload6.C @@ -0,0 +1,24 @@ +// { dg-do assemble } +// GROUPS passed overloading +struct temp_string { + temp_string (const unsigned char); +}; + +class String { + public: + String& operator = (temp_string); + String& operator = (const String&); +}; +class S { + public: + operator temp_string & () const; +}; + +S lbuf; + +static void e_r () +{ + String a; + a = lbuf; + return; +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/overload7.C b/gcc/testsuite/g++.old-deja/g++.brendan/overload7.C new file mode 100644 index 000000000..29a906016 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/overload7.C @@ -0,0 +1,42 @@ +// { dg-do run } +// GROUPS passed overloading +extern "C" int printf (const char *, ...); + +struct NoName { + + int first; + int second; +}; + +class Casted { + + public: + + NoName x; + double y; + + Casted ( int _x , double _y ): y(_y) + { + x.first = _x; + x.second = _x*2; + } + + operator NoName() const { return x; } + operator double() const { return y; } +}; + +int main() +{ + Casted c(10,12.34); + + NoName x; + double y; + + x = c; + y = c; + + if (x.first == 10 && x.second == 20 && y == 12.34) + printf ("PASS\n"); + else + { printf ("FAIL\n"); return 1; } +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/overload8.C b/gcc/testsuite/g++.old-deja/g++.brendan/overload8.C new file mode 100644 index 000000000..bf129b02c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/overload8.C @@ -0,0 +1,9 @@ +// { dg-do assemble } +// GROUPS passed overloading +typedef struct{double re,im;} complex; +class Complex{public:double re,im; + inline void operator=(Complex&X){re=X.re; im=X.im;}}; +void zxcvbnm(int n,...){n=1;} +int main(){complex c; Complex C; +zxcvbnm(1,c); +zxcvbnm(1,C);} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/overload9.C b/gcc/testsuite/g++.old-deja/g++.brendan/overload9.C new file mode 100644 index 000000000..b24a1f647 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/overload9.C @@ -0,0 +1,20 @@ +// { dg-do assemble } +// GROUPS passed overloading +class CLogger // { dg-message "candidate" } +{ +public: + void operator() (int,const char *) {}; // { dg-message "note" } + void operator() (int,const char *, ...) {}; // { dg-message "note" } +} Log; + +class CGLogger : public CLogger // { dg-message "candidate" } +{ +} GLog; + +int main() +{ + Log(1,"Test");// { dg-error "ambiguous" } + Log(1,"Test %d",3); + GLog(1,"Test");// { dg-error "ambiguous" } + GLog(1,"Test %d",3); +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/parse1.C b/gcc/testsuite/g++.old-deja/g++.brendan/parse1.C new file mode 100644 index 000000000..ce8e4cef5 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/parse1.C @@ -0,0 +1,17 @@ +// { dg-do assemble } +// GROUPS passed parsing +class Try { +private: + char s; +public: + // an escaped double-quote should not call consume_string inside + // reinit_parse_for_block + void mf() { s='\"'; } +}; + +int main() +{ + Try x; + x.mf(); +} + diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/parse2.C b/gcc/testsuite/g++.old-deja/g++.brendan/parse2.C new file mode 100644 index 000000000..1b448765b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/parse2.C @@ -0,0 +1,10 @@ +// { dg-do assemble } +// GROUPS passed parsing +class BitString { +public: + int i; +}; + + +typedef BitString BS; +typedef ::BitString cBS; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/parse3.C b/gcc/testsuite/g++.old-deja/g++.brendan/parse3.C new file mode 100644 index 000000000..18bde916f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/parse3.C @@ -0,0 +1,23 @@ +// { dg-do assemble } + +// these are marked as expected errors because they evidence an +// ambiguity in the grammar between expressions and declarations. +// when the parser's been cleaned up or rewritten, these two error +// markers can go away, since they'll no longer occur. + +// Fixed. PR 8545, 2001 01 23 +class A +{ + public: + int high; + unsigned int low; + A operator+(const A in); +}; + +A A::operator+(const A in) +{ + if (high==0) + return A(); // this works + else + return (A()); // this works not +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/parse4.C b/gcc/testsuite/g++.old-deja/g++.brendan/parse4.C new file mode 100644 index 000000000..3f201e857 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/parse4.C @@ -0,0 +1,19 @@ +// { dg-do assemble } + +class B +{ +public: + B( int t ) {} + void f() {} +}; + +int g() { return 0; } // referenced below + +int main() +{ + int try1; + B( try1 ).f(); // no syntax error + B b( g() ); // no syntax error + B( ::g() ).f(); // no syntax error + B( g() ).f(); // no syntax error +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/parse5.C b/gcc/testsuite/g++.old-deja/g++.brendan/parse5.C new file mode 100644 index 000000000..666acf252 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/parse5.C @@ -0,0 +1,21 @@ +// { dg-do assemble } + + +class ptr8 + { +public: + ptr8(unsigned char *string,int len); + }; + +template <unsigned int S> +class buf + { +public: + buf(const ptr8& aRef); + }; + +int main() + { + unsigned char b[3]; + buf<3> b2(ptr8(&b[0],3)); + } diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/parse6.C b/gcc/testsuite/g++.old-deja/g++.brendan/parse6.C new file mode 100644 index 000000000..3d7c51dc7 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/parse6.C @@ -0,0 +1,8 @@ +// { dg-do assemble } + +class A { }; + +int main() { + A a = a; + A b(b); +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/prepost1.C b/gcc/testsuite/g++.old-deja/g++.brendan/prepost1.C new file mode 100644 index 000000000..cfee4f4c4 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/prepost1.C @@ -0,0 +1,15 @@ +// { dg-do assemble } +// GROUPS passed prefix-postfix +class foo { +public: + operator ++ (); // { dg-error "" } no type or storage class +}; + +int main() +{ + foo x; + + // This should fall back to calling operator++(), and be an error with + // the -pedantic flag. + x++;// { dg-error "" } +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/prepost2.C b/gcc/testsuite/g++.old-deja/g++.brendan/prepost2.C new file mode 100644 index 000000000..3156749cf --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/prepost2.C @@ -0,0 +1,10 @@ +// { dg-do assemble } +// GROUPS passed initialization +class foo { +public: + operator ++ (); // { dg-error "" } no type or storage class + operator ++ (int); // { dg-error "" } no type or storage class + operator ++ (char); // illegal// { dg-error "" } .* + operator ++ (short); // illegal// { dg-error "" } .* + operator ++ (long); // illegal// { dg-error "" } .* +}; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/prepost3.C b/gcc/testsuite/g++.old-deja/g++.brendan/prepost3.C new file mode 100644 index 000000000..d11624b2d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/prepost3.C @@ -0,0 +1,7 @@ +// { dg-do assemble } +// GROUPS passed prefix-postfix +class Y { +public: + friend Y operator++ (Y&); + friend Y operator++ (Y&, char); // illegal// { dg-error "" } .* +}; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/prepost4.C b/gcc/testsuite/g++.old-deja/g++.brendan/prepost4.C new file mode 100644 index 000000000..1ec6d23bf --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/prepost4.C @@ -0,0 +1,10 @@ +// { dg-do assemble } +// GROUPS passed prefix-postfix +class Y { +public: + friend Y operator++ (Y&); + + // This is legal---it's a good test to make sure that grokfndecl's + // checking of the arguments is sane. + friend Y operator++ (Y&, int); +}; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/ptolemy1.C b/gcc/testsuite/g++.old-deja/g++.brendan/ptolemy1.C new file mode 100644 index 000000000..c5987fce0 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/ptolemy1.C @@ -0,0 +1,23 @@ +// { dg-do assemble } +// GROUPS passed ptolemy-bugs +class Tcl_Interp; + +class PTcl { +public: + PTcl(Tcl_Interp* interp = 0); + ~PTcl(); + int alias(int argc,char** argv); +}; + +typedef int (PTcl::*InterpFuncP)(int,char**); + +struct InterpTableEntry { + const char* name; + InterpFuncP func; +}; + + +static InterpTableEntry funcTable[] = { + { "alias" , &PTcl::alias } , + 0, 0 +}; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/ptolemy2.C b/gcc/testsuite/g++.old-deja/g++.brendan/ptolemy2.C new file mode 100644 index 000000000..669bd7914 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/ptolemy2.C @@ -0,0 +1,69 @@ +// { dg-do run } +// GROUPS passed ptolemy-bugs +#include <iostream> + +class PTcl { +public: + int dispatcher(int which,int argc,char** argv); + // fns in the table + int one(int argc, char** argv); + int two(int argc, char** argv); + int three(int argc, char** argv); +}; + +// An InterpFuncP is a pointer to an PTcl function that takes an argc-argv +// argument list and returns TCL_OK or TCL_ERROR. + +typedef int (PTcl::*InterpFuncP)(int,char**); + +struct InterpTableEntry { + const char* name; + InterpFuncP func; +}; + +// Here is the function table and dispatcher function. +// These macros define entries for the table + +#define quote(x) #x +#define ENTRY(verb) { quote(verb), &PTcl::verb } + +static InterpTableEntry funcTable[] = { + ENTRY(one), + ENTRY(two), + ENTRY(three), + {0, 0} +}; + +int PTcl::dispatcher(int which, int argc, char** argv) { + return (this->*(funcTable[which].func))(argc, argv); +} + +void printargs(char** argv) { +// while (*argv) { +// cout << " " << *argv++; +// } +// cout << "\n"; +} + +int PTcl::one(int, char** argv) { + std::cout << "FAIL\n"; + printargs(argv); + return 1; +} + +int PTcl::two(int, char** argv) { + std::cout << "PASS\n"; + printargs(argv); + return 0; +} + +int PTcl::three(int, char** argv) { + std::cout << "FAIL\n"; + printargs(argv); + return 1; +} + +int main (int argc, char** argv) { + PTcl obj; + return obj.dispatcher(1,argc,argv); +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/ptrmem1.C b/gcc/testsuite/g++.old-deja/g++.brendan/ptrmem1.C new file mode 100644 index 000000000..051448301 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/ptrmem1.C @@ -0,0 +1,21 @@ +// { dg-do assemble } +// GROUPS passed pointers-to-members +class my_class +{ +public: + typedef void func_type (int num); + my_class (int num, func_type* proc); + void dispatch (void); +private: + int _num; + func_type *_proc; +}; + +my_class::my_class (int num, func_type* proc) : _num(num), _proc(proc) +{ +} + +void my_class::dispatch (void) +{ + _proc(_num); +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/ptrmem2.C b/gcc/testsuite/g++.old-deja/g++.brendan/ptrmem2.C new file mode 100644 index 000000000..36145cf01 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/ptrmem2.C @@ -0,0 +1,26 @@ +// { dg-do assemble } +// GROUPS passed pointers-to-members +struct C { + struct N { + int g1(int); + int g2(int); + }; + + typedef int (N::*pmfn)(int); + + int f1(int); + int f2(int); +}; + +int (C::*f)(int) = &C::f1; + +/* + The compiler should not crash on the line below; this change fixes it: + * cp-tree.c (list_hash_lookup_or_cons): Make sure the type doesn't + have TYPE_PTRMEMFUNC_P set before we try to build its + CLASSTYPE_ID_AS_LIST. +*/ + +C::pmfn h = &C::N::g1; + +int (C::N::*g)(int) = &C::N::g2; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/ptrmem3.C b/gcc/testsuite/g++.old-deja/g++.brendan/ptrmem3.C new file mode 100644 index 000000000..4f78039d4 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/ptrmem3.C @@ -0,0 +1,32 @@ +// { dg-do assemble } +// GROUPS passed pointers-to-members +template<class T> class TemplA { + T t; +}; + + +template<class T> class TemplB { +public: + typedef void (T::*TClassMethod)(); + +private: +/* + This line should not crash cuz of the get_decl_list change in this: + * cp-tree.c (list_hash_lookup_or_cons): Make sure the type doesn't + have TYPE_PTRMEMFUNC_P set before we try to build its + CLASSTYPE_ID_AS_LIST. + (get_decl_list): Likewise, when trying to read it. +*/ + TemplA<TClassMethod> Tmethod; +}; + + +class C { + int a; +}; + +int main(int, char**) { + + TemplB<C> test; +} + diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/ptrmem4.C b/gcc/testsuite/g++.old-deja/g++.brendan/ptrmem4.C new file mode 100644 index 000000000..4725fb5c2 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/ptrmem4.C @@ -0,0 +1,16 @@ +// { dg-do assemble } +// GROUPS passed pointers-to-members +class X { + private: + int i; + public: + X(int k) { i=k; } + int operator=(X &a) { return i = a.i; } + int operator=(int ii) { return i = ii; } +}; +int main(void) +{ + int (X::*op1_ptr)(X&); + op1_ptr = &X::operator=; // g++ gives error + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/recurse.C b/gcc/testsuite/g++.old-deja/g++.brendan/recurse.C new file mode 100644 index 000000000..de20a0732 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/recurse.C @@ -0,0 +1,80 @@ +// { dg-do assemble } +// GROUPS passed recursive-aborts +// types +typedef unsigned int DBflag; // for storing user flag value +typedef unsigned long DBoffset; // 32-bit unsigned integer +typedef DBoffset DBsize; // type for storing sizes of objects +typedef unsigned char DBbyte; // 8-bit unsigned char + +class DBlink +{ +protected: + DBbyte link[4]; // hold link in portable MSB first format +public: + DBlink(DBoffset = 0, DBflag = 0); + DBlink &operator=(const DBlink &); + DBlink &operator=(DBoffset); + operator DBoffset(); + operator const DBbyte *() { return link; } + void set_flag() { link[0] |= 0x80; } + void reset_flag() { link[0] &= 0x7f; } + int test_flag() const { return (link[0] & 0x80) != 0; } +}; + +typedef DBlink DBsizerec; // hold data record size in portable format + +// constants +const DBoffset DB_NULL = 0; + +class DBlinkrec +{ +protected: + // offsets are stored with MSB in link[0] + DBlink l; // offset into link file of right child - MSB = red bit + DBlink r; // offset into link file of left child - MSB = delete + DBlink d; // offset into parallel data file - MSB = user flag +public: + DBlinkrec():l(DB_NULL), r(DB_NULL), d(DB_NULL) {} + void make_red() // set link to red + { l.set_flag(); } + void make_black() // set link to black + { l.reset_flag(); } + int is_red() const // indicates whether this is a red link + { return l.test_flag(); } + void set_discard() // set discard flag + { r.set_flag(); } + void reset_discard() // reset discard flag + { r.reset_flag(); } + int is_discarded() const // check discard flag + { return r.test_flag(); } + void set_flag() // set user flag + { d.set_flag(); } + void reset_flag() // reset user flag + { d.reset_flag(); } + int is_flag() const // check user flag + { return d.test_flag(); } + + friend class DataBase; +}; + +class DBpathrec : public DBlinkrec +{ + DBoffset offset; // offset of link record in LNK file +public: + DBpathrec():offset(DB_NULL) { } + DBpathrec(DBoffset off, const DBlinkrec &lr):offset(off), DBlinkrec(lr) {} + operator DBoffset() { return offset; } + DBpathrec &operator=(DBoffset off) { offset = off; return *this; } + DBpathrec &operator=(const DBpathrec &pr) + { offset = pr.offset; (DBlinkrec)*this = (DBlinkrec)pr; return *this; } + + friend class DataBase; +}; + +int main() +{ + DBpathrec a(), b(); + + a = b;// { dg-error "" } non-lvalue in assignment.* +} + diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/redecl1.C b/gcc/testsuite/g++.old-deja/g++.brendan/redecl1.C new file mode 100644 index 000000000..0e01f2b47 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/redecl1.C @@ -0,0 +1,5 @@ +// { dg-do assemble } +// GROUPS passed redeclaration +inline int min(int x, int y) {return x < y ? x : y;} /* 235 */// { dg-error "" } .* +int min(int a, int b); +inline int min(int a, int b) {return (a < b)?a:b;}// { dg-error "" } .* diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/redecl2.C b/gcc/testsuite/g++.old-deja/g++.brendan/redecl2.C new file mode 100644 index 000000000..b654b2465 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/redecl2.C @@ -0,0 +1,52 @@ +// { dg-do run } +// GROUPS passed redeclaration +// Check that if multiple declarations of the same single +// function are present in different places in the same file, +// and if these declarations differ (as allowed) in the number +// of argument defaults provided, that correct values are +// passed at all call points anyway. + +extern "C" int printf (const char *, ...); + +void receiver (int ii, int jj); + +void sender_1 () +{ + receiver (3,7); +} + +void receiver (int ii, int jj = 9); + +void sender_2 () +{ + receiver (5); +} + +int ii_sum = 0; +int jj_sum = 0; + +void sender_3 (); + +int main () +{ + sender_1 (); + sender_2 (); + sender_3 (); + if (ii_sum != 13 || jj_sum != 25) + { printf ("FAIL\n"); return 1; } + else + printf ("PASS\n"); + + return 0; +} + +void receiver (int ii, int jj) +{ + ii_sum += ii; + jj_sum += jj; +} + +void sender_3 () +{ + receiver (5); +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/redecl3.C b/gcc/testsuite/g++.old-deja/g++.brendan/redecl3.C new file mode 100644 index 000000000..1bfd88974 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/redecl3.C @@ -0,0 +1,17 @@ +// { dg-do assemble } +// GROUPS passed redeclaration +class foo +{ +public: + int bar(int a); +}; + + +void bar(int &a); + +int foo::bar(int a) { + int a = 0; // Should this be an error ?// { dg-error "" } declaration.* + + bar(a); + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/reference1.C b/gcc/testsuite/g++.old-deja/g++.brendan/reference1.C new file mode 100644 index 000000000..92ff38d7d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/reference1.C @@ -0,0 +1,54 @@ +// { dg-do run } +// { dg-options "-w" } +// GROUPS passed references +// Check that if a reference is initialized to refer to a value +// which is returned from a function call, the actual call to +// the function is only invoked for the original initialization +// of the reference, and not for each subsequent use of the +// reference. +// +// This test fails with G++ 1.35.0- (pre-release). +// Reported 4/4/89 by Kim Smith + +extern "C" int printf (const char *, ...); + +struct base { + mutable int data_member; + + base () {} + void function_member () const; +}; + +base base_object; + +base base_returning_function (); + +int call_count = 0; + +int main () +{ + const base& base_ref = base_returning_function (); + + base_ref.function_member (); + base_ref.function_member (); + base_ref.data_member = 99; + + if (call_count == 1) + printf ("PASS\n"); + else + { printf ("FAIL\n"); return 1; } + + return 0; +} + +base base_returning_function () +{ + base local_base_object; + + call_count++; + return local_base_object; +} + +void base::function_member () const +{ +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/rtti1.C b/gcc/testsuite/g++.old-deja/g++.brendan/rtti1.C new file mode 100644 index 000000000..f57b9571f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/rtti1.C @@ -0,0 +1,8 @@ +// { dg-do assemble } +// GROUPS passed RTTI +#include <typeinfo> + +struct B { virtual ~B(){} }; +struct D0 : public virtual B { virtual ~D0(){} }; +struct D1 : public virtual D0 { virtual ~D1(){} }; +struct C : public virtual B, public D1 { virtual ~C() { } }; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/scope1.C b/gcc/testsuite/g++.old-deja/g++.brendan/scope1.C new file mode 100644 index 000000000..f54594109 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/scope1.C @@ -0,0 +1,8 @@ +// { dg-do assemble } +// GROUPS passed scoping +int f (int i) { + if (i) + for (int j = i; j; j--) + ; + return j; // error: j should only be in scope inside the body of `for'// { dg-error "" } .* +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/scope2.C b/gcc/testsuite/g++.old-deja/g++.brendan/scope2.C new file mode 100644 index 000000000..1d211aac4 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/scope2.C @@ -0,0 +1,29 @@ +// { dg-do assemble } +// GROUPS passed scoping +class A +{ + public: + A() {} + ~A() {} + virtual void f() {} +}; + +class B : public A +{ + public: + B() {} + ~B() {} + virtual void f() {} +}; + + +B GLOBAL_B; + +B& foo() {return GLOBAL_B;} + +int main() +{ + // build_scoped_method_call and build_scoped_ref should know how + // to deal with a reference for this + foo().A::f(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/scope3.C b/gcc/testsuite/g++.old-deja/g++.brendan/scope3.C new file mode 100644 index 000000000..3ff7f54ad --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/scope3.C @@ -0,0 +1,25 @@ +// { dg-do assemble } +// GROUPS passed scoping +// This is fixed when NEW_CLASS_SCOPING is on. + +template<class T> +class ArrayG { +public: + ArrayG(); +protected: + const unsigned INITIAL; + T* array; +}; + +template<class T> +ArrayG<T>::ArrayG(): +array(new T[INITIAL]) +{ } + +struct X { + struct Correspondence { + int i; + }; + + void fill(ArrayG<Correspondence>& a); +}; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/scope4.C b/gcc/testsuite/g++.old-deja/g++.brendan/scope4.C new file mode 100644 index 000000000..2729ca6e6 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/scope4.C @@ -0,0 +1,31 @@ +// { dg-do assemble } +// GROUPS passed scoping +class BitString { +public: + int i; + int length() const; +}; + +typedef BitString BS; + +class V { +public: + class BitString { + public: + static int x(const ::BitString& value); + static int y(const class ::BitString& value); // should be parsed ok + static int z(const BS& value); + }; +}; + +int +V::BitString::x(const ::BitString& value) +{ return value.length(); } + +int +V::BitString::y(const class ::BitString& value) // should be parsed ok +{ return value.length(); } + +int +V::BitString::z(const BS& value) +{ return value.length(); } diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/scope5.C b/gcc/testsuite/g++.old-deja/g++.brendan/scope5.C new file mode 100644 index 000000000..1b6345f1d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/scope5.C @@ -0,0 +1,21 @@ +// { dg-do assemble } +// GROUPS passed scoping +class Integer { +public: + int i; +}; + +class Type { + enum Klasse { ENUM, INTEGER }; + + class Description { + public: + + }; + + class Integer: public Description { + public: + ::Integer low; + ::Integer high; + }; +}; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/shadow1.C b/gcc/testsuite/g++.old-deja/g++.brendan/shadow1.C new file mode 100644 index 000000000..c133dea54 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/shadow1.C @@ -0,0 +1,8 @@ +// { dg-do assemble } +// GROUPS passed errors +void f( int a) { + int a; // this should be an error now// { dg-error "" } .* + { + int a; + } +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/sizeof1.C b/gcc/testsuite/g++.old-deja/g++.brendan/sizeof1.C new file mode 100644 index 000000000..bc2f18168 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/sizeof1.C @@ -0,0 +1,15 @@ +// { dg-do assemble } +// { dg-options "-pedantic-errors" } +// GROUPS passed sizeof +// ARM $5.3.2 + +void f() { } + +int +main() +{ + // sizeof may not be applied to a function + int i = sizeof( f);// { dg-error "" } .* + + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/sizeof2.C b/gcc/testsuite/g++.old-deja/g++.brendan/sizeof2.C new file mode 100644 index 000000000..355bee746 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/sizeof2.C @@ -0,0 +1,18 @@ +// { dg-do assemble } +// { dg-options "-pedantic-errors" } +// GROUPS passed sizeof +// ARM $5.3.2 + +void f() { } + +struct foo { int bit : 1; }; + +int +main() +{ + // sizeof may not be applied to a bit-field + foo f; + int i = sizeof (f.bit);// { dg-error "" } .* + + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/sizeof3.C b/gcc/testsuite/g++.old-deja/g++.brendan/sizeof3.C new file mode 100644 index 000000000..3596a1eeb --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/sizeof3.C @@ -0,0 +1,15 @@ +// { dg-do assemble } +// { dg-options "-pedantic-errors" } +// GROUPS passed sizeof +// ARM $5.3.2 + +class bar; + +int +main() +{ + // sizeof may not be applied to an undefined class + int k = sizeof (bar);// { dg-error "" } .* + + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/sizeof4.C b/gcc/testsuite/g++.old-deja/g++.brendan/sizeof4.C new file mode 100644 index 000000000..3ac0a8e2e --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/sizeof4.C @@ -0,0 +1,13 @@ +// { dg-do assemble } +// { dg-options "-pedantic-errors" } +// GROUPS passed sizeof +// ARM $5.3.2 + +int +main() +{ + // sizeof may not be applied to the type void + int l = sizeof (void);// { dg-error "" } .* + + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/sizeof5.C b/gcc/testsuite/g++.old-deja/g++.brendan/sizeof5.C new file mode 100644 index 000000000..551f408cf --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/sizeof5.C @@ -0,0 +1,18 @@ +// { dg-do run } +// GROUPS passed sizeof +// ARM $5.3.2 + +extern "C" int printf (const char *, ...); + +class foo {}; + +int +main () +{ + // The size of any class or class object is larger than zero. + int i = sizeof (foo); + if (i > 0) + printf ("PASS\n"); + else + { printf ("FAIL\n"); return 1; } +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/sorry1.C b/gcc/testsuite/g++.old-deja/g++.brendan/sorry1.C new file mode 100644 index 000000000..7a77801f5 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/sorry1.C @@ -0,0 +1,36 @@ +// { dg-do assemble } +// GROUPS passed old-sorry +class a { +public: + int* foo(); +}; + +a aa; +a* ap; + +class b { +public: + int ok(int* p =aa.foo()); + + // dump_init should know what to do with this NON_LVALUE_EXPR + int f(int* p =ap->foo()); +}; + + int +b::ok(int *p) +{ + return 0; +} + + int +b::f(int *p) +{ + return 0; +} + void +bar() +{ + b b; + b.ok(); + b.f(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/static1.C b/gcc/testsuite/g++.old-deja/g++.brendan/static1.C new file mode 100644 index 000000000..cb8392377 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/static1.C @@ -0,0 +1,4 @@ +// { dg-do assemble } +// GROUPS passed static +class A { public: int a; };// { dg-error "" } .* +void foo7 () { A::a = 3; }// { dg-error "" } .* diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/static2.C b/gcc/testsuite/g++.old-deja/g++.brendan/static2.C new file mode 100644 index 000000000..099d92210 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/static2.C @@ -0,0 +1,19 @@ +// { dg-do assemble } +// GROUPS passed static +class A +{ + public: + void member(void) + { + } + + static void staticMember() + { + member (); // illegal, no object for calling non-static method// { dg-error "" } .* + } +}; + +int main() +{ + A::staticMember(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/static3.C b/gcc/testsuite/g++.old-deja/g++.brendan/static3.C new file mode 100644 index 000000000..c0ee01178 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/static3.C @@ -0,0 +1,15 @@ +// { dg-do assemble } +// GROUPS passed static +class foo{ +public: + static void bar( int i ){ value = i; } + static int value;// { dg-error "" } .* +}; + +const int foo::value = 0; // should be an error.// { dg-error "" } .* + +int main(){ + foo::bar( 1 ); + return 0; +} + diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/synth1.C b/gcc/testsuite/g++.old-deja/g++.brendan/synth1.C new file mode 100644 index 000000000..3a27e63cf --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/synth1.C @@ -0,0 +1,33 @@ +// { dg-do assemble } +// { dg-xfail-if "" { sparc64-*-elf } { "*" } { "" } } +// { dg-options "-pedantic-errors -g -Wall" } +// GROUPS passed synthetics +// Check to make sure that g++ doesn't get freaked out about the use +// of generated methods that it supposedly "can't see". + +class Char { +public: + Char(); + Char(char v); + + // synthetic copy-constructor and operator= +private: + char value; +}; + +class XChar: public Char { +public: + XChar(); + XChar(char v, int serial); + + void operator=(const XChar& other); +private: + int serial; +}; + +void +XChar::operator=(const XChar& other) +{ + Char::operator=(other); + // serial stays the same +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/template1.C b/gcc/testsuite/g++.old-deja/g++.brendan/template1.C new file mode 100644 index 000000000..552f8eeb8 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/template1.C @@ -0,0 +1,17 @@ +// { dg-do assemble } +// GROUPS passed templates +// g++-2.2.1: member functions returning a template type + + +template <class T> struct list { }; + +struct A +{ + list<int> L; + + list<int> get_list(); + +}; + + +list<int> A::get_list() { return L; } diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/template11.C b/gcc/testsuite/g++.old-deja/g++.brendan/template11.C new file mode 100644 index 000000000..bc5724985 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/template11.C @@ -0,0 +1,47 @@ +// { dg-do assemble } +// GROUPS passed templates +template <class Called> +class aCallback +{ +public: + aCallback(Called& obj, int (Called::*met)()); + + int callback(); + +protected: + +private: + // the object to call + Called& object; + + // the method to apply + int (Called::*method)(); + +}; + +template <class Called> +aCallback<Called>::aCallback(Called& obj, + int (Called::*met)()) : +object(obj), +method(met) +{} + +template <class Called> +int aCallback<Called>::callback() +{ + return (object.*method)(); +} + +struct myStruct +{ + int action() {return 24;} +}; + +int main() +{ + myStruct toto; + + aCallback<myStruct> cb(toto, &myStruct::action); + + return cb.callback(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/template12.C b/gcc/testsuite/g++.old-deja/g++.brendan/template12.C new file mode 100644 index 000000000..686db48f5 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/template12.C @@ -0,0 +1,8 @@ +// { dg-do assemble } +// GROUPS passed templates +inline void foo (const int &x) {} + +template <class type> +inline void foo (const type &x) {x.eat_this_and_die();} + +int main (int argc, char **argv) {foo (argc);} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/template13.C b/gcc/testsuite/g++.old-deja/g++.brendan/template13.C new file mode 100644 index 000000000..ea81202c2 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/template13.C @@ -0,0 +1,15 @@ +// { dg-do assemble } +// GROUPS passed templates +template<class T> +class ListS { +public: + class Vix { + public: + Vix(); + }; +}; + +template<class T> +ListS<T>::Vix::Vix() +{ } + diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/template15.C b/gcc/testsuite/g++.old-deja/g++.brendan/template15.C new file mode 100644 index 000000000..366ebfed6 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/template15.C @@ -0,0 +1,19 @@ +// { dg-do assemble } +// GROUPS passed templates +template<class T> class Stack { + public: + Stack (int s = 10); //Comment out "= 10" and it will compile + ~Stack(void); //Omitting "void" doesn't help +}; + +template<class T> Stack<T>::~Stack(void) +{ } + +//If this definition comes before the one for ~Stack, the error message +//about redeclaration of `void Stack<int>::~Stack()' will not occur. +template<class T> Stack<T>::Stack(int s) +{ } + +int main () { + Stack<int> stk(10); +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/template16.C b/gcc/testsuite/g++.old-deja/g++.brendan/template16.C new file mode 100644 index 000000000..d62f6bede --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/template16.C @@ -0,0 +1,10 @@ +// { dg-do assemble } +// GROUPS passed templates +template<class T> class TList { + typedef void (T::*TVOIDFUNT)(); + typedef T* (T::*TTPFUNT)(T*); +}; + +class A; +class B : TList<A> { }; + diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/template17.C b/gcc/testsuite/g++.old-deja/g++.brendan/template17.C new file mode 100644 index 000000000..5f2d45f1c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/template17.C @@ -0,0 +1,15 @@ +// { dg-do assemble } +// GROUPS passed templates +struct Regex { int i; Regex(char *, int); }; +template<class KEY> +class NDAMName { +public: + static const Regex pattern; + static unsigned sequence_number; +}; + +const Regex NDAMName<'L'>::pattern("^[Ll](.*)$", 1);// { dg-error "type/value mismatch" "mismatch" } +// { dg-error "expected a type" "expected" { target *-*-* } 11 } +// { dg-warning "deprecated" "depr" { target *-*-* } 11 } +unsigned NDAMName<'L'>::sequence_number = 0;// { dg-error "type/value mismatch" "mismatch" } +// { dg-error "expected a type" "exp" { target *-*-* } 14 } diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/template18.C b/gcc/testsuite/g++.old-deja/g++.brendan/template18.C new file mode 100644 index 000000000..280db5d3a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/template18.C @@ -0,0 +1,14 @@ +// { dg-do assemble } +// GROUPS passed templates +template<class T> class X; +typedef X<int> IX; + +template<class T> +class X { +public: + T x; +}; + +struct A { + IX c; +}; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/template19.C b/gcc/testsuite/g++.old-deja/g++.brendan/template19.C new file mode 100644 index 000000000..d5215aea7 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/template19.C @@ -0,0 +1,26 @@ +// { dg-do assemble } +// GROUPS passed templates +template <class T> +class Base +{ +public: + Base() { } +}; + +template <class memberType, class keyType> +class Middle : public Base<memberType> +{ +public: + Middle (keyType const & (*ko) (memberType const &)) + { + } +}; + +// EXCHANGE the following lines for this code to work. +//template <class memberType, class keyType> class Middle; +template <class T, class keyType> class Middle; + +struct Test : public Middle <int, int> +{ + Test(); +}; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/template2.C b/gcc/testsuite/g++.old-deja/g++.brendan/template2.C new file mode 100644 index 000000000..cb1d674ea --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/template2.C @@ -0,0 +1,14 @@ +// { dg-do assemble } +// GROUPS passed templates +template <class Q> +class Conc { +public: + static int body(); +}; + +template <class Q> +int Conc<Q>::body() {return 0;} + +int main () { + Conc<int> s2; +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/template20.C b/gcc/testsuite/g++.old-deja/g++.brendan/template20.C new file mode 100644 index 000000000..6b7c40d0e --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/template20.C @@ -0,0 +1,21 @@ +// { dg-do assemble } +// GROUPS passed templates +template <class A, class B> class Map; + +class Foo +{ +public: + static Map<int,int> bar; +}; + +template <class A, class B> +class Map +{ +public : + int find(); +}; + +int main() +{ + int z = Foo::bar.find(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/template21.C b/gcc/testsuite/g++.old-deja/g++.brendan/template21.C new file mode 100644 index 000000000..3bfd0cfc4 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/template21.C @@ -0,0 +1,43 @@ +// { dg-do assemble } +// GROUPS passed templates +template<class T> +class L { +public: + L(); + + T x[30]; + int doit(int i) const; +}; + +#ifdef BUG +template<class T> +int +L<T>::doit(int i) const +{ + return x[i].z; +} +#endif + +class X { +public: + class Y { + public: + Y(); + Y(int); + + int z; + }; + + L<Y> ly; +}; + +#ifndef BUG +template<class T> +int +L<T>::doit(int i) const +{ + return x[i].z; +} +#endif + +static X x; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/template22.C b/gcc/testsuite/g++.old-deja/g++.brendan/template22.C new file mode 100644 index 000000000..4301fad52 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/template22.C @@ -0,0 +1,23 @@ +// { dg-do run } +// GROUPS passed templates +extern "C" int printf (const char *, ...); + +template <class T> +class Foo +{ +public: + void func (int const& i); +}; + +template <class T> +void Foo<T>:: +func (int const& i) +{} + + +int main () +{ + Foo<int const> foo; + printf ("PASS\n"); + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/template23.C b/gcc/testsuite/g++.old-deja/g++.brendan/template23.C new file mode 100644 index 000000000..d366eda5d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/template23.C @@ -0,0 +1,34 @@ +// { dg-do assemble } +// GROUPS passed templates +template <class T> +class T_Base +{}; + +template <class T> +class T_Derived +: public T_Base<T> +{}; + + +class Base +{ +public: + Base (float name); +}; + +class Derived +: public Base +{ +private: + T_Base<int>* data_; // Fix (1): Change date_ from T_Base<int>* to T_Derived<int>* + +public: + Derived (float name); +}; + + +Derived:: +Derived (float name) +: Base(name), + data_(new T_Derived<int>()) +{} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/template24.C b/gcc/testsuite/g++.old-deja/g++.brendan/template24.C new file mode 100644 index 000000000..d7559547f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/template24.C @@ -0,0 +1,21 @@ +// { dg-do run } +// GROUPS passed templates +extern "C" int printf (const char *, ...); + +template <class F> +class Temp +{ + F func_; +public: + Temp (F f) :func_(f) {} +}; + +int func (int h = 1, int z = 2) { return h+z; } + +int main () +{ + Temp<int(*)(int, int)> temp (func); + + printf ("PASS\n"); + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/template25.C b/gcc/testsuite/g++.old-deja/g++.brendan/template25.C new file mode 100644 index 000000000..43f69a55e --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/template25.C @@ -0,0 +1,36 @@ +// { dg-do assemble } +// GROUPS passed templates +template <class T> +class Temp_Base +{}; + +template <class T> +class Temp_Derived +: public Temp_Base<T> +{ +public: + Temp_Derived (int i = 10) {} +}; + + +class Base +{ + float r_; +public: + Base (float r) : r_(r) {} +}; + +class Derived +: public Base +{ +private: + Temp_Base<int>* boo_; +public: + Derived (float); +}; + +Derived:: +Derived (float form) +: Base(form), + boo_(new Temp_Derived<int>) +{} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/template26.C b/gcc/testsuite/g++.old-deja/g++.brendan/template26.C new file mode 100644 index 000000000..3f5de3d7a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/template26.C @@ -0,0 +1,31 @@ +// { dg-do assemble } +// GROUPS passed templates +class V { + public: + V(); + V(int); + }; + +template <int I> class AA: public virtual V { + public: + AA(); + AA(int); + }; + +template <int I> class BB : public virtual V { + public: + BB(); + BB(int); + }; + +template <int I> AA<I>::AA() {} +template <int I> AA<I>::AA(int i): V(i) {} +template <int I> BB<I>::BB() {} +template <int I> BB<I>::BB(int i) {} + +class CC : public AA<1>, public BB<2> { + public: + CC(); + CC(int); + }; + diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/template27.C b/gcc/testsuite/g++.old-deja/g++.brendan/template27.C new file mode 100644 index 000000000..5357f1ca6 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/template27.C @@ -0,0 +1,15 @@ +// { dg-do assemble } +// GROUPS passed templates + template<class K, class V> class MapLS { }; + class String {}; + class X1 { }; + class RefProto { }; + template<class REP> class Ref { }; + + template <> + class MapLS<String, Ref<X1> >: public MapLS<String, RefProto> { + public: + ~MapLS(); + }; + + MapLS<String, Ref<X1> >::~MapLS() { } diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/template28.C b/gcc/testsuite/g++.old-deja/g++.brendan/template28.C new file mode 100644 index 000000000..6c56d4555 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/template28.C @@ -0,0 +1,13 @@ +// { dg-do assemble } +// GROUPS passed templates +class X { + const char *fptr; +public: + X(const char *ptr) { fptr = ptr; } + operator const char*() { return fptr; } +}; + +int main(){ + X x1("1234"); + X x2(x1+1); +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/template29.C b/gcc/testsuite/g++.old-deja/g++.brendan/template29.C new file mode 100644 index 000000000..aee91c237 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/template29.C @@ -0,0 +1,12 @@ +// { dg-do assemble } +// GROUPS passed templates + template <class ElementType> class A + { public: + A(ElementType) {} + ElementType get() const ; + }; + + template <class ElementType> ElementType A<ElementType>::get() const + { return ElementType(0); } + +int main() { const A<short> a(3); } diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/template3.C b/gcc/testsuite/g++.old-deja/g++.brendan/template3.C new file mode 100644 index 000000000..09c857187 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/template3.C @@ -0,0 +1,50 @@ +// { dg-do run } +// GROUPS passed templates +extern "C" int printf (const char *, ...); +extern "C" void exit (int); + +int count = 0; + +void +die (int x) +{ + if (x != ++count) + { + printf ("FAIL\n"); + exit (1); + } +} + +class A { + public: + void f() const { die (-1); } +}; + + +template <class Item> +class B : public A { + public: + void f() const; +}; + +template <class Item> +inline void B<Item>::f() const { die (1); } + +template <class Item> +class C : public A { + public: + void f() const { die (2); } +}; + + +int main() +{ + B<int> b; + C<int> c; + + b.f(); //- bugged, (A::f() called instead of B::f()) + c.f(); //- works fine (C::f() called) + + printf ("PASS\n"); + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/template30.C b/gcc/testsuite/g++.old-deja/g++.brendan/template30.C new file mode 100644 index 000000000..87c95e15a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/template30.C @@ -0,0 +1,17 @@ +// { dg-do assemble } +// GROUPS passed templates + + template<class K, class V> class MapLS { }; + class String {}; + class X1 { }; + class RefProto { }; + template<class REP> class Ref { }; + + template <> + class MapLS<String, Ref<X1> >: public MapLS<String, RefProto> { + public: + ~MapLS(); + }; + + MapLS<String, Ref<X1> >::~MapLS() { } + diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/template31.C b/gcc/testsuite/g++.old-deja/g++.brendan/template31.C new file mode 100644 index 000000000..b13e63851 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/template31.C @@ -0,0 +1,38 @@ +// { dg-do assemble } +// GROUPS passed templates +// PRMS Id: 13218 + +struct C { + int x; + char y; + double z; +}; +C c02; + +template <int* ip> struct A { + int* p; + A() : p(ip) {} +}; + +template <C* cp> struct B { + C* p; + B() : p(cp) {} +}; + +int i00; + +int main(void) +{ + A<&i00> a00; + + extern int i01; + A<&i01> a01; + + B<&c02> b02; + + extern C c03; + B<&c03> b03; +} + +int i01; +C c03; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/template4.C b/gcc/testsuite/g++.old-deja/g++.brendan/template4.C new file mode 100644 index 000000000..61ad1cc6b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/template4.C @@ -0,0 +1,11 @@ +// { dg-do assemble } +// GROUPS passed templates +// This used to be a circularity in chainon. +template <class ARG> struct TMPL { + typedef int ARG::*ARG_data_member_ptr; + typedef void (ARG::*ARG_func_member_ptr) (); +}; + +struct S { }; + +TMPL<S> object; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/template5.C b/gcc/testsuite/g++.old-deja/g++.brendan/template5.C new file mode 100644 index 000000000..1b68043a3 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/template5.C @@ -0,0 +1,48 @@ +// { dg-do assemble } +// GROUPS passed templates +template<class T> +class Vector +{ +public: + Vector(int x); + ~Vector(); + T& operator [] (int i); + +private: + T* v; + int sz; +} ; + +template<class T> +Vector<T>::Vector(int x) +{ + sz = x; + v = new T (sz); +} + +template<class T> +Vector<T>::~Vector() + { delete [] v; } + +template<class T> +T & +Vector<T>::operator [] (int i) + { return v[i]; } + +int +main(int, char **) +{ + Vector<int> intvec(3); + + intvec[0] = 1; + intvec[1] = 2; + intvec[2] = 3; + + for (int i = 0; i < 3; i++) + intvec[i]; + + return 0; +} + + + diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/template6.C b/gcc/testsuite/g++.old-deja/g++.brendan/template6.C new file mode 100644 index 000000000..2cff7e5b4 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/template6.C @@ -0,0 +1,30 @@ +// { dg-do assemble } +// GROUPS passed templates +struct B { +}; + +struct X : B { + ~X (); +}; + +struct Request { + X s; +}; + +template <class ET> class TC { + ET data; +}; + +struct TMem { + + ~TMem() {} + + TC<Request> *req; +}; + +struct FIO { + + void init (); + + FIO () { init(); } +}; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/template7.C b/gcc/testsuite/g++.old-deja/g++.brendan/template7.C new file mode 100644 index 000000000..8fb636e7a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/template7.C @@ -0,0 +1,48 @@ +// { dg-do assemble } +// GROUPS passed templates +template <class ET> +class ChainElem { +public: + + ET data; +}; + +template <class ET> +class Chain { +public: + + ChainElem<ET> *first; + + virtual ~Chain() {} + +}; + +struct B { +}; + +struct X : B { + ~X (); +}; + +struct TBNFexpression { +}; + +struct TCaseLabelPair { +}; + +struct TVariant { + Chain<TCaseLabelPair> CaseLabelList; +}; + +struct TCaseConstruct { + Chain<TBNFexpression> TagFieldPrefixes; + Chain<TVariant> Variants; +}; + +struct Production { + X TypeName; +}; + +struct SimpleSyntax { + Chain<Production> Productions; +}; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/template8.C b/gcc/testsuite/g++.old-deja/g++.brendan/template8.C new file mode 100644 index 000000000..66ba0d8ac --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/template8.C @@ -0,0 +1,20 @@ +// { dg-do assemble } +// GROUPS passed templates +#include <stdio.h> + +// make sure we accept unions for templates +template<int n> +union Double_alignt{ + double for_alignt; + char array[n]; + +}; + +int main(){ + + + Double_alignt<20000> heap; + + printf(" &heap.array[0] = %d, &heap.for_alignt = %d\n", &heap.array[0], &heap.for_alignt); + +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/temporary1.C b/gcc/testsuite/g++.old-deja/g++.brendan/temporary1.C new file mode 100644 index 000000000..f4c2ab380 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/temporary1.C @@ -0,0 +1,13 @@ +// { dg-do assemble } +// GROUPS passed temporaries +#include <stdio.h> + +int main () +{ + int a = 2; + + if (----a == 0) + printf ("a = 0\n"); + + printf ("a = %d\n", a); +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/typedef1.C b/gcc/testsuite/g++.old-deja/g++.brendan/typedef1.C new file mode 100644 index 000000000..3eed3e02f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/typedef1.C @@ -0,0 +1,29 @@ +// { dg-do assemble } + +class baseClassA +{ +public: +private: + class internalClassA + { + public: + private: + typedef int privateType; + + privateType memberA; + }; +}; + +class baseClassB +{ +public: +private: + class internalClassA + { + public: + private: + typedef unsigned int privateType; + + privateType memberB; + }; +}; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/union1.C b/gcc/testsuite/g++.old-deja/g++.brendan/union1.C new file mode 100644 index 000000000..ffc5555d7 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/union1.C @@ -0,0 +1,22 @@ +// { dg-do run } +// GROUPS passed unions +// This is fixed by finish_anon_union doing a string_cst_equal check on +// the DECL_SIZE of the decls, instead of comparing the DECL_SIZE nodes. + +// The compiler currently fails to allocate space for the static union. + + unsigned + hash(const double d) + { + static union { + unsigned asint[2]; + double asdouble; + }; + asdouble = d; + return asint[0] ^ asint[1]; + } + +int main () +{ + hash (3.1415); +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/union2.C b/gcc/testsuite/g++.old-deja/g++.brendan/union2.C new file mode 100644 index 000000000..5d7e9c85c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/union2.C @@ -0,0 +1,13 @@ +// { dg-do assemble } +// GROUPS passed unions +class B; + +struct A { + A(B* x) : i(x) {} + A() : i(0) {} + + union { + B* i; + B* c; + }; +}; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/union3.C b/gcc/testsuite/g++.old-deja/g++.brendan/union3.C new file mode 100644 index 000000000..75ffbc0ae --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/union3.C @@ -0,0 +1,14 @@ +// { dg-do assemble } +// GROUPS passed unions +union alan { +int a; +char *b; +alan(); +}; + +alan mary; + +alan::alan() +{ + a=0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/visibility1.C b/gcc/testsuite/g++.old-deja/g++.brendan/visibility1.C new file mode 100644 index 000000000..cb4003f0a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/visibility1.C @@ -0,0 +1,16 @@ +// { dg-do assemble } +// GROUPS passed visibility +class foo { +protected: + int i; // { dg-error "" } protected +}; + +class bar : public foo { +public: + friend void baz (foo *); +}; + +void baz (foo *f) +{ + f->i = 1; // error: i is protected// { dg-error "" } .* +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/visibility10.C b/gcc/testsuite/g++.old-deja/g++.brendan/visibility10.C new file mode 100644 index 000000000..89d215799 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/visibility10.C @@ -0,0 +1,14 @@ +// { dg-do assemble } +// GROUPS passed visibility +struct base +{ + protected: + void base_func() {}// { dg-error "" } .*is protected.* +}; + +struct derived : public base +{ + protected: + void derived_func(base *ptr) { ptr->base_func(); }// { dg-error "" } within this context +}; + diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/visibility2.C b/gcc/testsuite/g++.old-deja/g++.brendan/visibility2.C new file mode 100644 index 000000000..74021d58d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/visibility2.C @@ -0,0 +1,10 @@ +// { dg-do assemble } +// GROUPS passed visibility +class X { + void g (int); // { dg-error "" } private +public: + void g (double); +}; + +class Y : public X { void f() { g (1); } }; // { dg-error "" } private + diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/visibility3.C b/gcc/testsuite/g++.old-deja/g++.brendan/visibility3.C new file mode 100644 index 000000000..249ae8116 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/visibility3.C @@ -0,0 +1,45 @@ +// { dg-do assemble } +// GROUPS passed visibility +// Used to say: +// manip.cc:17: member `_f' is a private member of class `B<int>' +// manip.cc:17: member `_a' is a private member of class `B<int>' + +class A {}; + +template <class TP> +class B; + +template <class TP> +inline A & +operator<< (A &o, const B<TP> &m); + +template <class TP> +class B +{ + A &(*_f) (A &, TP); + TP _a; +public: + B (A &(*f) (A &, TP), TP a) : _f (f), _a (a) {} + friend A &operator<< <>(A &o, const B<TP> &m); +}; + +template <class TP> +inline A & +operator<< (A &o, const B<TP> &m) +{ + (*m._f) (o, m._a); + return o; +} + +A &setw (A &, int); +B<int> setw (int n) +{ + return B<int> (setw, n); +} + +A x; + +void f () +{ + x << setw (2); +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/visibility4.C b/gcc/testsuite/g++.old-deja/g++.brendan/visibility4.C new file mode 100644 index 000000000..158c161d3 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/visibility4.C @@ -0,0 +1,14 @@ +// { dg-do assemble } +// GROUPS passed visibility +template <class T> +class Feld { +public: + Feld(const Feld&) {} +}; + +class Polynom : private Feld<double> { + Polynom(); + friend Polynom f(const Polynom&); +}; + +Polynom f(const Polynom& p) { return p; } diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/visibility5.C b/gcc/testsuite/g++.old-deja/g++.brendan/visibility5.C new file mode 100644 index 000000000..f43b2501c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/visibility5.C @@ -0,0 +1,8 @@ +// { dg-do assemble } +// GROUPS passed visibility +template<int K> class B; +template<int K> class A {int n; friend class B<K>;}; +template<int K> class B {public: void method(A<K>) const;}; +template<int K> void B<K>::method(A<K> X) const {X.n=0;} +typedef B<2> B2; + diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/visibility6.C b/gcc/testsuite/g++.old-deja/g++.brendan/visibility6.C new file mode 100644 index 000000000..f9ba954ea --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/visibility6.C @@ -0,0 +1,17 @@ +// { dg-do assemble } +// GROUPS passed visibility +class bottom +{ +public: + int b; // { dg-error "" } private +}; +class middle : private bottom +{ +public: + void foo () { b; } +}; +class top : public middle +{ +public: + void bar () { b; }// { dg-error "" } .* +}; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/visibility7.C b/gcc/testsuite/g++.old-deja/g++.brendan/visibility7.C new file mode 100644 index 000000000..f7bf00c1a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/visibility7.C @@ -0,0 +1,15 @@ +// { dg-do assemble } +// GROUPS passed visibility +class X +{ +public: + void fn ();// { dg-error "" } .* +}; +class Y : private X +{}; + +class Unrelated +{ +public: + void foo () { Y y; y.fn (); }// { dg-error "" } .* +}; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/visibility8.C b/gcc/testsuite/g++.old-deja/g++.brendan/visibility8.C new file mode 100644 index 000000000..00f5347ff --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/visibility8.C @@ -0,0 +1,15 @@ +// { dg-do assemble } +// GROUPS passed visibility +// Make sure private inheritance affects the visibility of +// static members used in an inherited context. +class foo +{ +public: + static int y; // { dg-error "" } private +}; +class foo1 : private foo +{ }; +class foo2 : public foo1 +{ public: + void bar () { y; }// { dg-error "" } .* +}; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/visibility9.C b/gcc/testsuite/g++.old-deja/g++.brendan/visibility9.C new file mode 100644 index 000000000..963bc2baf --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/visibility9.C @@ -0,0 +1,16 @@ +// { dg-do assemble } +// GROUPS passed visibility +class A { +public: + void aMethod(void) {};// { dg-error "" } .* +}; + +class AA : A { }; + +class B { +public: + void thisMethod() { + AA ana; + ana.aMethod();// { dg-error "" } .* + } +}; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/vtables1.C b/gcc/testsuite/g++.old-deja/g++.brendan/vtables1.C new file mode 100644 index 000000000..219bb91f7 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/vtables1.C @@ -0,0 +1,43 @@ +// { dg-do run } +// GROUPS passed virtual-tables +// Check that virtual function tables are generated and used +// even for struct's/classes which have no explicit constructors. + +extern "C" int printf (const char *, ...); + +int base_func_member_1_called = 0; +int derived_func_member_1_called = 0; + +struct base { + virtual void func_member_1 () + { + base_func_member_1_called++; + } +}; + +struct derived : public base { + virtual void func_member_1 () + { + derived_func_member_1_called++; + } + + virtual void func_member_2 () + { + } +}; + +base* bp1; +base* bp2; + +int main () +{ + bp1 = new base; + bp2 = new derived; + + bp1->func_member_1 (); + bp2->func_member_1 (); + + printf ("PASS\n"); + + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/warnings1.C b/gcc/testsuite/g++.old-deja/g++.brendan/warnings1.C new file mode 100644 index 000000000..155910021 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/warnings1.C @@ -0,0 +1,7 @@ +// { dg-do assemble } +// { dg-options "-Wctor-dtor-privacy" } +// GROUPS passed warnings +// there should be a warning about foo only defining private methods +class foo { // { dg-warning "private" } + int bar(); +}; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/warnings10.C b/gcc/testsuite/g++.old-deja/g++.brendan/warnings10.C new file mode 100644 index 000000000..ea1e88882 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/warnings10.C @@ -0,0 +1,10 @@ +// { dg-do assemble } +// GROUPS passed warnings +void foo() +{ + int i; + if (1) { + for (int i = 0; i < 10; i++) + ; + } +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/warnings2.C b/gcc/testsuite/g++.old-deja/g++.brendan/warnings2.C new file mode 100644 index 000000000..665c7a425 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/warnings2.C @@ -0,0 +1,7 @@ +// { dg-do assemble } +// GROUPS passed warnings +class K { +public: + void f() { + }; // there should be no warning about this semicolon +}; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/warnings3.C b/gcc/testsuite/g++.old-deja/g++.brendan/warnings3.C new file mode 100644 index 000000000..07381b9ed --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/warnings3.C @@ -0,0 +1,16 @@ +// { dg-do assemble } +// { dg-options "-O2 -Wall" } +// GROUPS passed warnings +class A { +int i; +public: + void funcA(void) { + funcB(); + } + + // The compiler should not emit a warning about not being + // able to inline this function. + void funcB(void) { + i++; + } +}; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/warnings4.C b/gcc/testsuite/g++.old-deja/g++.brendan/warnings4.C new file mode 100644 index 000000000..410ca800c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/warnings4.C @@ -0,0 +1,10 @@ +// { dg-do assemble } +// GROUPS passed warnings +int +main () +{ + register int x; + int * foo = &x; // in C++ it's perfectly legal to do this + + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/warnings5.C b/gcc/testsuite/g++.old-deja/g++.brendan/warnings5.C new file mode 100644 index 000000000..e6341fa87 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/warnings5.C @@ -0,0 +1,10 @@ +// { dg-do assemble } +// GROUPS passed warnings +enum TypeKind { ATK, BTK } ; + +struct Type { + enum TypeKind kind : 8; + void setBTK(); +}; + +void Type::setBTK() { kind = BTK; } diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/warnings6.C b/gcc/testsuite/g++.old-deja/g++.brendan/warnings6.C new file mode 100644 index 000000000..5557f1947 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/warnings6.C @@ -0,0 +1,9 @@ +// { dg-do assemble } +// { dg-options "-O2 -Wall -ansi -pedantic" } +// GROUPS passed warnings +// should not emit this warning about func: +// x.C:2: warning: invalid storage class for function `func' +// +template <class T> inline void func(T) +{ +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/warnings7.C b/gcc/testsuite/g++.old-deja/g++.brendan/warnings7.C new file mode 100644 index 000000000..89d6ecaf5 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/warnings7.C @@ -0,0 +1,21 @@ +// { dg-do assemble } +// { dg-options "-O2 -Wall" } +// GROUPS passed warnings +template<class T> +class X { +public: + void kill(unsigned i) + { vec[i].~T(); } + T *vec; +}; + +class Y { }; + +void +x() +{ + X<int> x; + x.kill(0); + X<Y> y; + y.kill(0); +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/warnings8.C b/gcc/testsuite/g++.old-deja/g++.brendan/warnings8.C new file mode 100644 index 000000000..cdb7c62bb --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/warnings8.C @@ -0,0 +1,7 @@ +// { dg-do assemble } +// { dg-options "-Wall" } +// GROUPS passed warnings +bool foo(unsigned char c) +{ + return (c & 17) != 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/warnings9.C b/gcc/testsuite/g++.old-deja/g++.brendan/warnings9.C new file mode 100644 index 000000000..576f431c9 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/warnings9.C @@ -0,0 +1,7 @@ +// { dg-do assemble } +// { dg-options "-Wall" } +// GROUPS passed warnings +inline int foo() +{ + return 3; +} |