diff options
Diffstat (limited to 'gcc/testsuite/g++.old-deja')
239 files changed, 3729 insertions, 679 deletions
diff --git a/gcc/testsuite/g++.old-deja/g++.abi/bitfields.C b/gcc/testsuite/g++.old-deja/g++.abi/bitfields.C index 75b6571b1dc..57d06b36744 100644 --- a/gcc/testsuite/g++.old-deja/g++.abi/bitfields.C +++ b/gcc/testsuite/g++.old-deja/g++.abi/bitfields.C @@ -55,7 +55,7 @@ check_bits (char *buf, #define CHECK_FIELD(AGGREGATE, FIELD, START_BIT, NUM_BITS, RVAL) \ do { \ AGGREGATE a__; \ - memset (& a__, 0, sizeof (a__)); \ + std::memset (& a__, 0, sizeof (a__)); \ a__.FIELD = -1; \ if (! check_bits ((char *) & a__, sizeof (a__), START_BIT, NUM_BITS)) \ return RVAL; \ diff --git a/gcc/testsuite/g++.old-deja/g++.abi/crash1.C b/gcc/testsuite/g++.old-deja/g++.abi/crash1.C new file mode 100644 index 00000000000..8526818c713 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.abi/crash1.C @@ -0,0 +1,21 @@ +// Build don't link: +// +// Copyright (C) 2001 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 11 Apr 2001 <nathan@codesourcery.com> + +// Bug 1944. We failed to calculate nearly emptiness properly, and +// lost primary too. + +struct A1 {}; +struct A2 {}; + +struct B1 : virtual A1 {}; +struct B2 : virtual A2 {}; + +struct C1 : virtual B2 {}; +struct C2 : virtual B2 {}; + +struct D1 : virtual C1, virtual C2 {}; +struct D2 : virtual C2, virtual B1 {}; + +struct E : virtual D1, virtual D2 {}; diff --git a/gcc/testsuite/g++.old-deja/g++.abi/cxa_vec.C b/gcc/testsuite/g++.old-deja/g++.abi/cxa_vec.C index c08ce75e961..117a760ef31 100644 --- a/gcc/testsuite/g++.old-deja/g++.abi/cxa_vec.C +++ b/gcc/testsuite/g++.old-deja/g++.abi/cxa_vec.C @@ -1,12 +1,12 @@ // Test __cxa_vec routines -// Copyright (C) 2000 Free Software Foundation, Inc. +// Copyright (C) 2000, 2001 Free Software Foundation, Inc. // Contributed by Nathan Sidwell 7 Apr 2000 <nathan@nathan@codesourcery.com> #if defined (__GXX_ABI_VERSION) && __GXX_ABI_VERSION >= 100 #include <cxxabi.h> #include <stdio.h> #include <new> -#include <malloc.h> +#include <stdlib.h> #include <setjmp.h> static int ctor_count = 0; diff --git a/gcc/testsuite/g++.old-deja/g++.abi/empty2.C b/gcc/testsuite/g++.old-deja/g++.abi/empty2.C new file mode 100644 index 00000000000..411651701e3 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.abi/empty2.C @@ -0,0 +1,136 @@ +// Build don't link: + +// Copyright (C) 2001 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 12 Apr 2001 <nathan@codesourcery.com> + +// Check we deal with trailing empty base classes properly + +struct A {}; +struct B1 : A {}; +struct B2 : A {}; +struct B3 : A {}; +struct B4 : A {}; +struct B5 : A {}; +struct B6 : A {}; +struct B7 : A {}; +struct B8 : A {}; + +struct C1 : B1 +{ + virtual void Foo () {}; +}; +struct C2 : B1, B2 +{ + virtual void Foo () {}; +}; +struct C3 : B1, B2, B3 +{ + virtual void Foo () {}; +}; +struct C4 : B1, B2, B3, B4 +{ + virtual void Foo () {}; +}; +struct C5 : B1, B2, B3, B4, B5 +{ + virtual void Foo () {}; +}; +struct C6 : B1, B2, B3, B4, B5, B6 +{ + virtual void Foo () {}; +}; +struct C7 : B1, B2, B3, B4, B5, B6, B7 +{ + virtual void Foo () {}; +}; +struct C8 : B1, B2, B3, B4, B5, B6, B7, B8 +{ + virtual void Foo () {}; +}; + +struct D1 : virtual C1 {}; +struct D2 : virtual C2 {}; +struct D3 : virtual C3 {}; +struct D4 : virtual C4 {}; +struct D5 : virtual C5 {}; +struct D6 : virtual C6 {}; +struct D7 : virtual C7 {}; +struct D8 : virtual C8 {}; + +unsigned const nearly_empty_size = sizeof (D1); + +template <typename Cn, typename Dn> int Check (Dn const &ref) +{ + if ((sizeof (Cn) <= nearly_empty_size) + != (static_cast <void const *> (&ref) + == static_cast <Cn const *> (&ref))) + return 1; + return 0; +} + +template <typename Bn, typename Cn> int Check () +{ + Cn c[2]; + + if (static_cast <A *> (static_cast <B1 *> (&c[1])) + == static_cast <A *> (static_cast <Bn *> (&c[0]))) + return 1; + return 0; +} + + +int main () +{ +#if defined (__GXX_ABI_VERSION) && __GXX_ABI_VERSION >= 100 + if (Check<B1, C1> ()) + return 1; + if (Check<B2, C2> ()) + return 2; + if (Check<B3, C3> ()) + return 3; + if (Check<B4, C4> ()) + return 4; + if (Check<B5, C5> ()) + return 5; + if (Check<B6, C6> ()) + return 6; + if (Check<B7, C7> ()) + return 7; + if (Check<B8, C8> ()) + return 8; + + if (Check<C1> (D1 ())) + return 11; + if (Check<C2> (D2 ())) + return 12; + if (Check<C3> (D3 ())) + return 13; + if (Check<C4> (D4 ())) + return 14; + if (Check<C5> (D5 ())) + return 15; + if (Check<C6> (D6 ())) + return 16; + if (Check<C7> (D7 ())) + return 17; + if (Check<C8> (D8 ())) + return 18; + + if (sizeof (C2) == nearly_empty_size) + return 22; + if (sizeof (C3) == nearly_empty_size) + return 23; + if (sizeof (C4) == nearly_empty_size) + return 24; + if (sizeof (C5) == nearly_empty_size) + return 25; + if (sizeof (C6) == nearly_empty_size) + return 26; + if (sizeof (C7) == nearly_empty_size) + return 27; + if (sizeof (C8) == nearly_empty_size) + return 28; +#endif + return 0; + +} diff --git a/gcc/testsuite/g++.old-deja/g++.abi/empty3.C b/gcc/testsuite/g++.old-deja/g++.abi/empty3.C new file mode 100644 index 00000000000..93e9d9ffdf9 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.abi/empty3.C @@ -0,0 +1,24 @@ +// Build don't link: + +// Copyright (C) 2001 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 12 Apr 2001 <nathan@codesourcery.com> + +// Check we deal with aligning virtual bases after a trailing empty +// base class properly + +struct A {}; +struct B1 : A {}; +struct B2 : A {}; +struct B3 : A {}; + +struct C : B1, B2, virtual B3 {}; + +int main () +{ +#if defined (__GXX_ABI_VERSION) && __GXX_ABI_VERSION >= 100 + C c; + if (((char *)static_cast <B3 *> (&c) - (char *)&c) % __alignof__ (C)) + return 1; +#endif + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.abi/empty4.C b/gcc/testsuite/g++.old-deja/g++.abi/empty4.C new file mode 100644 index 00000000000..0d212cc9438 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.abi/empty4.C @@ -0,0 +1,84 @@ +// Copyright (C) 2001 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 31 Jul 2001 <nathan@codesourcery.com> + +// Bug 3820. We were bit copying empty bases including the +// padding. Which clobbers whatever they overlay. + +struct Empty {}; + +struct Inter : Empty {}; + +int now = 0; + +struct NonPod +{ + int m; + + NonPod () {m = 0x12345678;} + NonPod (int m_) {m = m_;} + NonPod &operator= (NonPod const &src) {now = m; m = src.m;} + NonPod (NonPod const &src) {m = src.m;} +}; + +struct A : Inter +{ + A (int c) {m = c;} + + NonPod m; +}; + +struct B +{ + Inter empty; + NonPod m; + + B (int c) {m = c;} +}; + +struct C : NonPod, Inter +{ + C (int c) : NonPod (c), Inter () {} +}; + +int main () +{ + A a (0x12131415); + + int was = a.m.m; + + a = 0x22232425; + + if (was != now) + return 1; // we copied the empty base which clobbered a.m.m's + // original value. + + A b (0x32333435); + *(Inter *)&a = *(Inter *)&b; + + if (a.m.m != 0x22232425) + return 2; // we copied padding, which clobbered a.m.m + + A b2 (0x32333435); + (Inter &)b2 = Inter (); + if (b2.m.m != 0x32333435) + return 2; // we copied padding, which clobbered b2.m.m + + B c (0x12131415); + was = c.m.m; + c = 0x22232425; + if (was != now) + return 3; + + B d (0x32333435); + c.empty = d.empty; + + if (c.m.m != 0x22232425) + return 4; + + C e (0x32333435); + + if (e.m != 0x32333435) + return 2; // we copied padding + + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.abi/mangle1.C b/gcc/testsuite/g++.old-deja/g++.abi/mangle1.C new file mode 100644 index 00000000000..70f0ccee0be --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.abi/mangle1.C @@ -0,0 +1,7 @@ +// Build don't link: +// Origin: Mark Mitchell <mark@codesourcery.com> + +struct S {}; + +void f (void (S::*)()) {} +void f (void (S::*)() const) {} diff --git a/gcc/testsuite/g++.old-deja/g++.abi/primary3.C b/gcc/testsuite/g++.old-deja/g++.abi/primary3.C index ef245ef789e..fbeb2b70b30 100644 --- a/gcc/testsuite/g++.old-deja/g++.abi/primary3.C +++ b/gcc/testsuite/g++.old-deja/g++.abi/primary3.C @@ -21,14 +21,24 @@ int main () A *apd = &d; B1 *b1pd = &d; B2 *b2pd = &d; + C *cpd = &d; #if __GXX_ABI_VERSION >= 100 if (static_cast <void *> (apc) != static_cast <void *> (b1pc)) return 1; - if (static_cast <void *> (apd) != static_cast <void *> (b1pd)) + if (static_cast <void *> (&c) != static_cast <void *> (b2pc)) return 2; - if (static_cast <void *> (apd) != static_cast <void *> (&d)) + if (static_cast <void *> (b1pc) == static_cast <void *> (b2pc)) return 3; + + if (static_cast <void *> (apd) != static_cast <void *> (b1pd)) + return 11; + if (static_cast <void *> (b2pd) != static_cast <void *> (&d)) + return 12; + if (static_cast <void *> (b2pd) != static_cast <void *> (cpd)) + return 13; + if (static_cast <void *> (b1pd) == static_cast <void *> (b2pd)) + return 14; #endif return 0; } diff --git a/gcc/testsuite/g++.old-deja/g++.abi/ptrmem.C b/gcc/testsuite/g++.old-deja/g++.abi/ptrmem.C index 282fae609b5..38f8177a2a6 100644 --- a/gcc/testsuite/g++.old-deja/g++.abi/ptrmem.C +++ b/gcc/testsuite/g++.old-deja/g++.abi/ptrmem.C @@ -1,6 +1,29 @@ // Special g++ Options: -fno-strict-aliasing // Origin: Mark Mitchell <mark@codesourcery.com> +/* Generally, the lowest bit of the ptr is used to indicate whether a + ptr-to-mem-func points to a virtual or a non-virtual member + function. However, some platforms use all bits to encode a + function pointer. Such platforms use the lowest bit of the delta, + that is shifted left by one bit. */ +#if defined __MN10300__ || defined __arm__ || defined __thumb__ +#define ADJUST_PTRFN(func, virt) ((void (*)())(func)) +#define ADJUST_DELTA(delta, virt) (((delta) << 1) + !!(virt)) +#else +#define ADJUST_PTRFN(func, virt) ((void (*)())((ptrdiff_t)(func) + !!(virt))) +#define ADJUST_DELTA(delta, virt) (delta) +#endif + +/* IA64 uses function descriptors instead of function pointers in its + vtables, which means that we can't meaningfully compare them directly. */ +#if defined __ia64__ +#define CMP_PTRFN(A, B) (*(void **)(A) == *(void **)(B)) +#define VPTE_SIZE (16) +#else +#define CMP_PTRFN(A, B) ((A) == (B)) +#define VPTE_SIZE sizeof(void *) +#endif + #if defined (__GXX_ABI_VERSION) && __GXX_ABI_VERSION >= 100 // Check that pointers-to-member functions are represented correctly. @@ -72,28 +95,28 @@ main () // There should be no adjustment for the `T' version, and an // appropriate adjustment for the `S' version. y = &T::f; - if (yp->ptr != &_ZN1T1fEv) + if (! CMP_PTRFN (yp->ptr, ADJUST_PTRFN (&_ZN1T1fEv, 0))) return 5; - if (yp->adj != 0) + if (yp->adj != ADJUST_DELTA (0, 0)) return 6; x = (sp) y; - if (xp->ptr != &_ZN1T1fEv) + if (! CMP_PTRFN (xp->ptr, ADJUST_PTRFN (&_ZN1T1fEv, 0))) return 7; - if (xp->adj != delta) + if (xp->adj != ADJUST_DELTA (delta, 0)) return 8; // For a virtual function, we should see the vtable offset, plus // one. `T::h' is in the second slot: the vtable pointer points to // the first virtual function. y = &T::h; - if ((ptrdiff_t) yp->ptr != sizeof (void *) + 1) + if (yp->ptr != ADJUST_PTRFN (VPTE_SIZE, 1)) return 9; - if (yp->adj != 0) + if (yp->adj != ADJUST_DELTA (0, 1)) return 10; x = (sp) y; - if ((ptrdiff_t) xp->ptr != sizeof (void *) + 1) + if (xp->ptr != ADJUST_PTRFN (VPTE_SIZE, 1)) return 11; - if (xp->adj != delta) + if (xp->adj != ADJUST_DELTA (delta, 1)) return 12; // Pointers-to-data-members should have the same size and alignment diff --git a/gcc/testsuite/g++.old-deja/g++.abi/vbase2.C b/gcc/testsuite/g++.old-deja/g++.abi/vbase2.C new file mode 100644 index 00000000000..f8877eb545f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.abi/vbase2.C @@ -0,0 +1,27 @@ +// Copyright (C) 2001 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 5 Jun 2001 <nathan@codesourcery.com> + +// Bug 3006. Constructor vtables were wrong. + +struct A +{ + virtual ~A() {} +}; + +class B : public virtual A {}; +class C : public virtual B {}; +class D1 : public virtual C {}; +class D2 : public virtual C {}; +class E + : public virtual D1, + public virtual D2 +{ +}; + + +int +main(int argc, char* argv[]) +{ + new E; + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.abi/vbase3.C b/gcc/testsuite/g++.old-deja/g++.abi/vbase3.C new file mode 100644 index 00000000000..9b0ed1c8778 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.abi/vbase3.C @@ -0,0 +1,26 @@ +// Copyright (C) 2001 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 5 Jun 2001 <nathan@codesourcery.com> + +// Bug 3061. Constructor vtables were wrong. + +class A_base { + public: + virtual void foo() { } +}; +class A_skel : virtual public A_base { }; + +class B_base : virtual public A_base { }; +class B_skel : virtual public B_base, virtual public A_skel { }; + +class C_base : virtual public B_base { }; +class C_skel : virtual public C_base, virtual public B_skel { }; + +class D_base : virtual public C_base { }; +class D_skel : virtual public D_base, virtual public C_skel { }; + +class D_impl : virtual public D_skel { }; + +int main() +{ + D_impl i; +} diff --git a/gcc/testsuite/g++.old-deja/g++.abi/vbase4.C b/gcc/testsuite/g++.old-deja/g++.abi/vbase4.C new file mode 100644 index 00000000000..116d79bec65 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.abi/vbase4.C @@ -0,0 +1,165 @@ +// Copyright (C) 2001 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 9 Jun 2001 <nathan@codesourcery.com> + +// Bug 3089. We ICE'd in construction vtables. + +int failed; + +void fail (int val) +{ + if (!failed) + failed = val; +} + +struct A +{ + virtual ~A(); + A (); + virtual void check (void *whole, void *base); +}; + +A::A () +{ + check (this, this); +} +A::~A () +{ + check (this, this); +} + +void A::check (void *whole, void *base) +{ + if (dynamic_cast <void *> (this) != whole) + fail (1); + else if (this != base) + fail (2); +} + +struct B +{ + virtual ~B (); + B (); + virtual void check (void *whole, void *base); +}; + +B::B () +{ + check (this, this); +} +B::~B () +{ + check (this, this); +} +void B::check (void *whole, void *base) +{ + if (dynamic_cast <void *> (this) != whole) + fail (3); + else if (this != base) + fail (4); +} + +struct C : virtual public B, virtual public A +{ + virtual ~C (); + C (); + virtual void check (void *whole, void *base); +}; +C::C () +{ + check (this, this); +} +C::~C () +{ + check (this, this); +} +void C::check (void *whole, void *base) +{ + if (dynamic_cast <void *> (this) != whole) + fail (5); + else if (this != base) + fail (6); + A::check (whole, static_cast <A *> (this)); + B::check (whole, static_cast <B *> (this)); +} + +struct D : virtual public A +{ + virtual ~D (); + D (); + virtual void check (void *whole, void *base); +}; +D::D () +{ + check (this, this); +} +D::~D () +{ + check (this, this); +} +void D::check (void *whole, void *base) +{ + if (dynamic_cast <void *> (this) != whole) + fail (5); + else if (this != base) + fail (6); + A::check (whole, static_cast <A *> (this)); +} + +struct E : virtual public C, virtual public D +{ + virtual ~E (); + E (); + virtual void check (void *whole, void *base); +}; +E::E () +{ + check (this, this); +} +E::~E () +{ + check (this, this); +} +void E::check (void *whole, void *base) +{ + if (dynamic_cast <void *> (this) != whole) + fail (5); + else if (this != base) + fail (6); + C::check (whole, static_cast <C *> (this)); + D::check (whole, static_cast <D *> (this)); +} + +struct F : virtual public E +{ + virtual ~F (); + F (); + virtual void check (void *whole, void *base); +}; +F::F () +{ + check (this, this); +} +F::~F () +{ + check (this, this); +} +void F::check (void *whole, void *base) +{ + if (dynamic_cast <void *> (this) != whole) + fail (5); + else if (this != base) + fail (6); + E::check (whole, static_cast <F *> (this)); +} + +int main () +{ + A a; + B b; + C c; + D d; + E e; + F f; + + return failed; +} diff --git a/gcc/testsuite/g++.old-deja/g++.abi/vbase5.C b/gcc/testsuite/g++.old-deja/g++.abi/vbase5.C new file mode 100644 index 00000000000..6a3bbfbfb4b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.abi/vbase5.C @@ -0,0 +1,22 @@ +// Build don't link: +// +// Copyright (C) 2001 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 12 Jun 2001 <nathan@codesourcery.com> + +// 3130. A virtual base can have canonical and non-canonical instances +// of its primary. The canonical one should be first in dfs order. + +struct A +{ + virtual ~A (); +}; + +struct B +{ + virtual ~B (); +}; + + +struct C : virtual public A, virtual public B {}; +class D : public virtual C {}; +class E : public virtual C, public virtual D {}; diff --git a/gcc/testsuite/g++.old-deja/g++.abi/vbase6.C b/gcc/testsuite/g++.old-deja/g++.abi/vbase6.C new file mode 100644 index 00000000000..e8b959db32c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.abi/vbase6.C @@ -0,0 +1,22 @@ +// Build don't link: +// +// Copyright (C) 2001 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 12 Jun 2001 <nathan@codesourcery.com> + +// 3131. + +struct A +{ + virtual ~A (); +}; + +struct B +{ + virtual ~B (); +}; + + +struct C : virtual public B {}; +struct D : virtual public A, virtual public C {}; +struct E : public virtual C {}; +struct F : public virtual D, public virtual E {}; diff --git a/gcc/testsuite/g++.old-deja/g++.abi/vbase7.C b/gcc/testsuite/g++.old-deja/g++.abi/vbase7.C new file mode 100644 index 00000000000..5a4a3b5fdba --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.abi/vbase7.C @@ -0,0 +1,40 @@ +// Build don't run +// +// Copyright (C) 2001 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 12 Jun 2001 <nathan@codesourcery.com> + +// 3132. A virtual thunk was missing. + +struct A +{ + int x; + virtual ~A() {} +}; + +struct B +{ + virtual ~B() { } +}; + + +struct C +{ + virtual ~C () {} +}; + + +struct D : public virtual A {}; +struct E : virtual public B, virtual public D {}; +struct F : virtual public C, virtual public E {}; +struct G : public virtual E {}; + +struct H : public virtual F, public virtual G +{ + virtual ~H (); +}; +H::~H() {} + +int main () +{ + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.abi/vbase8-10.C b/gcc/testsuite/g++.old-deja/g++.abi/vbase8-10.C new file mode 100644 index 00000000000..5275af97f47 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.abi/vbase8-10.C @@ -0,0 +1,74 @@ +// Special g++ Options: -w + +// Copyright (C) 2001 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 26 Jul 2001 <nathan@codesourcery.com> + +// Origin stefan@space.twc.de +// Bug 3145 case 10. Horribly complicated class hierarchy + +class C0 +{}; +class C1 + : public C0 +{}; +class C2 + : public C1 + , virtual public C0 +{}; +class C3 + : public C1 + , public C2 + , virtual public C0 +{}; +class C4 + : virtual public C1 + , virtual public C0 + , virtual public C3 + , public C2 +{}; +class C5 + : public C3 + , virtual public C0 + , virtual public C2 +{}; +class C6 + : public C1 + , public C2 + , virtual public C5 + , virtual public C3 + , virtual public C0 +{}; +class C7 + : public C1 + , virtual public C5 + , virtual public C4 + , virtual public C2 + , virtual public C0 + , virtual public C6 +{}; +class C8 + : virtual public C4 + , public C3 + , public C0 + , virtual public C7 + , virtual public C6 +{}; +class C9 + : virtual public C0 + , public C4 + , public C8 + , public C1 + , public C6 +{}; +main() { + C0 c0; + C1 c1; + C2 c2; + C3 c3; + C4 c4; + C5 c5; + C6 c6; + C7 c7; + C8 c8; + C9 c9; +} diff --git a/gcc/testsuite/g++.old-deja/g++.abi/vbase8-21.C b/gcc/testsuite/g++.old-deja/g++.abi/vbase8-21.C new file mode 100644 index 00000000000..91ef335e04d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.abi/vbase8-21.C @@ -0,0 +1,74 @@ +// Special g++ Options: -w + +// Copyright (C) 2001 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 26 Jul 2001 <nathan@codesourcery.com> + +// Origin stefan@space.twc.de +// Bug 3145 case 21. Horribly complicated class hierarchy + +class C0 +{}; +class C1 + : virtual public C0 +{}; +class C2 + : virtual public C1 + , virtual public C0 +{}; +class C3 + : virtual public C2 + , virtual public C1 +{}; +class C4 + : virtual public C2 + , public C0 + , public C1 +{}; +class C5 + : virtual public C0 + , public C2 + , virtual public C1 + , virtual public C3 + , virtual public C4 +{}; +class C6 + : virtual public C1 + , virtual public C3 + , public C0 + , public C2 + , virtual public C4 +{}; +class C7 + : virtual public C5 + , public C2 + , public C6 + , virtual public C0 + , public C3 +{}; +class C8 + : virtual public C5 + , public C7 + , virtual public C0 + , virtual public C2 + , virtual public C6 +{}; +class C9 + : virtual public C2 + , virtual public C4 + , public C1 + , virtual public C0 + , public C7 + , public C5 +{}; +main() { + C0 c0; + C1 c1; + C2 c2; + C3 c3; + C4 c4; + C5 c5; + C6 c6; + C7 c7; + C8 c8; + C9 c9; +} diff --git a/gcc/testsuite/g++.old-deja/g++.abi/vbase8-22.C b/gcc/testsuite/g++.old-deja/g++.abi/vbase8-22.C new file mode 100644 index 00000000000..85c56099161 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.abi/vbase8-22.C @@ -0,0 +1,79 @@ +// Special g++ Options: -w + +// Copyright (C) 2001 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 27 Jul 2001 <nathan@codesourcery.com> + +// Origin stefan@space.twc.de +// Bug 3145 case 22. Horribly complicated class hierarchy + +class C0 +{}; +class C1 + : public C0 +{}; +class C2 + : public C1 + , virtual public C0 +{}; +class C3 + : virtual public C0 + , virtual public C2 + , virtual public C1 +{}; +class C4 + : virtual public C2 + , public C1 + , virtual public C3 + , public C0 +{}; +class C5 + : virtual public C0 + , virtual public C4 + , public C1 + , virtual public C2 + , virtual public C3 +{}; +class C6 + : public C0 + , virtual public C1 + , public C5 + , public C2 + , virtual public C3 + , virtual public C4 +{}; +class C7 + : virtual public C1 + , public C5 + , virtual public C6 + , virtual public C4 + , virtual public C3 + , virtual public C0 +{}; +class C8 + : virtual public C6 + , virtual public C1 + , virtual public C2 + , public C3 + , virtual public C4 +{}; +class C9 + : public C4 + , virtual public C2 + , virtual public C8 + , public C3 + , public C1 + , public C6 + , public C5 +{}; +main() { + C0 c0; + C1 c1; + C2 c2; + C3 c3; + C4 c4; + C5 c5; + C6 c6; + C7 c7; + C8 c8; + C9 c9; +} diff --git a/gcc/testsuite/g++.old-deja/g++.abi/vbase8-5.C b/gcc/testsuite/g++.old-deja/g++.abi/vbase8-5.C new file mode 100644 index 00000000000..ea96e85c2dc --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.abi/vbase8-5.C @@ -0,0 +1,79 @@ +// Special g++ Options: -w + +// Copyright (C) 2001 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 24 Jul 2001 <nathan@codesourcery.com> + +// Origin stefan@space.twc.de +// Bug 3145 case 5. Horribly complicated class hierarchy + +class C0 +{}; +class C1 + : virtual public C0 +{}; +class C2 + : public C0 + , virtual public C1 +{}; +class C3 + : virtual public C0 + , virtual public C2 + , public C1 +{}; +class C4 + : virtual public C0 + , virtual public C2 + , virtual public C1 + , virtual public C3 +{}; +class C5 + : virtual public C3 + , virtual public C2 + , virtual public C0 + , public C4 + , virtual public C1 +{}; +class C6 + : public C0 + , virtual public C3 + , public C4 + , virtual public C5 + , public C1 +{}; +class C7 + : virtual public C3 + , public C5 + , public C2 + , virtual public C4 + , public C6 + , public C0 +{}; +class C8 + : virtual public C2 + , public C5 + , public C7 + , public C1 + , public C0 + , public C4 + , public C3 +{}; +class C9 + : public C3 + , public C2 + , virtual public C6 + , public C8 + , virtual public C7 + , public C5 +{}; +main() { + C0 c0; + C1 c1; + C2 c2; + C3 c3; + C4 c4; + C5 c5; + C6 c6; + C7 c7; + C8 c8; + C9 c9; +} diff --git a/gcc/testsuite/g++.old-deja/g++.abi/vbase8-9.C b/gcc/testsuite/g++.old-deja/g++.abi/vbase8-9.C new file mode 100644 index 00000000000..43bd86a968c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.abi/vbase8-9.C @@ -0,0 +1,76 @@ +// Special g++ Options: -ansi -pedantic-errors -w + +// Copyright (C) 2001 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 14 Jun 2001 <nathan@codesourcery.com> + +// Bug 3145, generated by script provided by stefan@space.twc.de +// This is case number 9 + +class C0 +{}; +class C1 + : public C0 +{}; +class C2 + : public C1 + , public C0 +{}; +class C3 + : virtual public C0 + , public C2 + , virtual public C1 +{}; +class C4 + : virtual public C2 + , public C0 + , virtual public C3 + , public C1 +{}; +class C5 + : public C0 + , public C1 + , public C4 + , virtual public C2 + , public C3 +{}; +class C6 + : public C1 + , public C3 + , virtual public C5 + , virtual public C2 + , public C0 + , virtual public C4 +{}; +class C7 + : virtual public C1 + , virtual public C0 + , public C6 + , virtual public C2 + , public C5 +{}; +class C8 + : virtual public C1 + , virtual public C4 + , public C0 + , virtual public C7 + , virtual public C2 +{}; +class C9 + : virtual public C1 + , virtual public C6 + , public C8 + , virtual public C2 + , public C0 +{}; +int main() { + C0 c0; + C1 c1; + C2 c2; + C3 c3; + C4 c4; + C5 c5; + C6 c6; + C7 c7; + C8 c8; + C9 c9; +} diff --git a/gcc/testsuite/g++.old-deja/g++.abi/vbase9.C b/gcc/testsuite/g++.old-deja/g++.abi/vbase9.C new file mode 100644 index 00000000000..171607c7250 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.abi/vbase9.C @@ -0,0 +1,60 @@ +// Build don't link: + +// Copyright (C) 2001 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 5 Sept 2001 <nathan@codesourcery.com> + +// Bug 3986. Another indirect primary base problem. + +struct Consts +{ +}; + +struct MathLib : + virtual Consts +{ +}; + +struct Parallel : + virtual Consts +{ +}; + +struct Particles : + virtual MathLib, + virtual Parallel +{ +}; + +struct Ring : + virtual Particles +{ +}; + +struct Injection : + virtual Particles, + virtual Ring +{ +}; + +struct LSpaceCharge : + virtual Ring, + virtual Injection +{ +}; + +struct Bump : + virtual Consts +{ +}; + +struct Output : + virtual Injection, + virtual Bump +{ +}; + +struct Plots : + virtual LSpaceCharge, + virtual Output +{ +}; diff --git a/gcc/testsuite/g++.old-deja/g++.abi/vtable2.C b/gcc/testsuite/g++.old-deja/g++.abi/vtable2.C index b719c70a533..9847a15a8b8 100644 --- a/gcc/testsuite/g++.old-deja/g++.abi/vtable2.C +++ b/gcc/testsuite/g++.old-deja/g++.abi/vtable2.C @@ -1,4 +1,5 @@ // Origin: Mark Mitchell <mark@codesourcery.com> +// Special g++ Options: -fno-strict-aliasing #if defined (__GXX_ABI_VERSION) && __GXX_ABI_VERSION >= 100 @@ -126,6 +127,15 @@ void _ZN2S32s3Ev (); void _ZN2S42s1Ev (); } +// IA-64 uses function descriptors not function pointers in its vtables. +#if defined __ia64__ +#define CMP_VPTR(A, B) (*(void **)(A) == *(void **)(B)) +#define INC_VPTR(A) ((A) += 2) +#else +#define CMP_VPTR(A, B) (*(A) == (ptrdiff_t)(B)) +#define INC_VPTR(A) ((A) += 1) +#endif + int main () { S4 s4; @@ -147,10 +157,12 @@ int main () return 4; // Skip the RTTI entry. vtbl++; - if (*vtbl++ != (ptrdiff_t) &_ZN2S32s3Ev) + if (! CMP_VPTR (vtbl, &_ZN2S32s3Ev)) return 5; - if (*vtbl++ != (ptrdiff_t) &_ZN2S42s1Ev) + INC_VPTR (vtbl); + if (! CMP_VPTR (vtbl, &_ZN2S42s1Ev)) return 6; + INC_VPTR (vtbl); // The S1 vbase offset. if (*vtbl++ != 0) return 7; @@ -168,8 +180,8 @@ int main () // Skip the RTTI entry. vtbl++; // Skip the remaining virtual functions -- they are thunks. - vtbl++; - vtbl++; + INC_VPTR (vtbl); + INC_VPTR (vtbl); } #else /* !(defined (__GXX_ABI_VERSION) && __GXX_ABI_VERSION >= 100) */ diff --git a/gcc/testsuite/g++.old-deja/g++.abi/vtable3.h b/gcc/testsuite/g++.old-deja/g++.abi/vtable3.h index 327d346db27..4327b5f5ac4 100644 --- a/gcc/testsuite/g++.old-deja/g++.abi/vtable3.h +++ b/gcc/testsuite/g++.old-deja/g++.abi/vtable3.h @@ -7,11 +7,8 @@ #include <typeinfo> #include <stdio.h> -// XXX. vcall offsets are still broken, remove this define to re-enable -// testing when fixed. -#define NO_VCALL_TEST - int fail; +struct A; template <typename BASE, typename DERIVED> int Test (DERIVED *d, int expect) @@ -19,6 +16,7 @@ int Test (DERIVED *d, int expect) BASE *b = static_cast <BASE *> (d); void *full_b = dynamic_cast <void *> (b); void *full_d = dynamic_cast <void *> (d); + A *ap = static_cast <A *> (b); if (full_b != full_d) { @@ -37,8 +35,8 @@ int Test (DERIVED *d, int expect) typeid (BASE).name (), typeid (DERIVED).name ()); return 1; } -#ifndef NO_VCALL_TEST - b->Baz (static_cast <void *> (b)); + + b->Baz (static_cast <void *> (ap)); int res = b->Foo (static_cast <void *> (d)); @@ -49,7 +47,7 @@ int Test (DERIVED *d, int expect) typeid (BASE).name (), res, expect); return 1; } -#endif + return 0; } diff --git a/gcc/testsuite/g++.old-deja/g++.abi/vthunk1.C b/gcc/testsuite/g++.old-deja/g++.abi/vthunk1.C new file mode 100644 index 00000000000..662050e282a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.abi/vthunk1.C @@ -0,0 +1,45 @@ +// Build don't run: + +// Copyright (C) 2001 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 29 Jul 2001 <nathan@codesourcery.com> + +// Origin snyder@fnal.gov +// Bug 3631. We mis-calculated the non-virtual part of a virtual +// thunk. Leading to a link failure, in this case. + +struct A { virtual ~A () {} }; + +struct B : virtual public A +{ + virtual void destroy() {} +}; + +class C : virtual public B {}; +class D : virtual public C {}; +class E : public virtual A {}; + +struct F : virtual public B, virtual public E +{ + virtual void destroy() = 0; +}; + +struct G : public virtual F +{ + virtual void destroy() {} +}; + +class H : virtual public C, virtual public F {}; +class I : virtual public D, virtual public H {}; +class J : public virtual G, public virtual H {}; + +class K : public virtual I, public virtual J +{ + public: + virtual ~K(); +}; +K::~K() {} + +int main () +{ + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.benjamin/15071.C b/gcc/testsuite/g++.old-deja/g++.benjamin/15071.C index d05ba8c00dd..eaa8eeebd10 100644 --- a/gcc/testsuite/g++.old-deja/g++.benjamin/15071.C +++ b/gcc/testsuite/g++.old-deja/g++.benjamin/15071.C @@ -2,10 +2,10 @@ // g++/15071 // gcc invocation fails to link in libstdc++ -#include <iostream.h> +#include <iostream> int main() { - cout<<"hi"<<endl; + std::cout << "hi" << std::endl; return 0; } diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/copy9.C b/gcc/testsuite/g++.old-deja/g++.brendan/copy9.C index e1cfb426120..edaf99775de 100644 --- a/gcc/testsuite/g++.old-deja/g++.brendan/copy9.C +++ b/gcc/testsuite/g++.old-deja/g++.brendan/copy9.C @@ -1,5 +1,5 @@ // GROUPS passed copy-ctors -#include <iostream.h> +#include <iostream> // token types: from state parser const int T_EOF = 257; @@ -35,10 +35,11 @@ main () { ParseToken b(a); if (b.doubleval == 23.2) - cout << "PASS\n"; + std::cout << "PASS\n"; else { - cout << "FAIL\n"; + std::cout << "FAIL\n"; return 1; } } + diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash15.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash15.C index 56a7e75b9ba..953144ac5ac 100644 --- a/gcc/testsuite/g++.old-deja/g++.brendan/crash15.C +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash15.C @@ -1,22 +1,22 @@ // Build don't link: // GROUPS passed old-abort -#include <iostream.h> +#include <iostream> class A { public: - virtual ~A() {cout << "executed ~A()\n";}; + virtual ~A() {std::cout << "executed ~A()\n";}; }; class B : public A { public: - virtual ~B() {cout << "executed ~B()\n";}; + virtual ~B() {std::cout << "executed ~B()\n";}; }; int main() { - cout << "starting\n"; + std::cout << "starting\n"; B b; b.~A();// ERROR - destructor - cout << "done\n"; + std::cout << "done\n"; }; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash38.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash38.C index eeb70e1c373..5f0cf9bd2c2 100644 --- a/gcc/testsuite/g++.old-deja/g++.brendan/crash38.C +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash38.C @@ -8,7 +8,7 @@ main.cc: Please report this to 'bug-g++@prep.ai.mit.edu' */ -#include <stream.h> +#include <iostream> class INTEGER { int x; @@ -16,7 +16,7 @@ public: typedef int BASE; INTEGER(int y) : x(y) {} INTEGER() {} - void encode() { cout << "Integer encoder";} + void encode() { std::cout << "Integer encoder";} int operator=(int y) { x=y; return x; } operator int() {return x; } }; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash49.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash49.C index 98a580d3cb1..3f2e2256e35 100644 --- a/gcc/testsuite/g++.old-deja/g++.brendan/crash49.C +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash49.C @@ -1,12 +1,12 @@ // Build don't link: // GROUPS passed old-abort -#include<iostream.h> +#include<iostream> const int keys = 10; const int key[keys] = {6, key[1], 2, keys, 1, 7, 6, key[2], key[8]}; void main() { // ERROR - return type for main - for(int i = 0; i < keys;) cout << key[i++] << " "; - endl(cout); + for(int i = 0; i < keys;) std::cout << key[i++] << " "; + std::endl(std::cout); } diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash52.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash52.C index b4daa9de702..e8c51e8be2f 100644 --- a/gcc/testsuite/g++.old-deja/g++.brendan/crash52.C +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash52.C @@ -1,7 +1,7 @@ // Build don't link: // GROUPS passed old-abort // Special g++ Options: -Wreturn-type -#include <iostream.h> +#include <iostream> class A { public: @@ -9,6 +9,6 @@ public: }; A &f(A &a) {// ERROR - new decl.* - cout << "Blah\n"; + std::cout << "Blah\n"; } // ERROR - non-void function diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash62.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash62.C index 77b9fc84763..c86f9e6bb4a 100644 --- a/gcc/testsuite/g++.old-deja/g++.brendan/crash62.C +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash62.C @@ -1,11 +1,11 @@ // Build don't link: // GROUPS passed old-abort -#include <iostream.h> +#include <iostream> void - fubar(ostream* out, const char* string) + fubar(std::ostream* out, const char* s) { - (*out) << string << endl; + (*out) << s << std::endl; return; } @@ -14,8 +14,8 @@ { // Declare a ref and a pointer to the same ostream. // - ostream* out = &cerr; - ostream& die = cerr; + std::ostream* out = &std::cerr; + std::ostream& die = std::cerr; // Valid call to fubar. // diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/cvt1.C b/gcc/testsuite/g++.old-deja/g++.brendan/cvt1.C index 57f3b426108..4574a367254 100644 --- a/gcc/testsuite/g++.old-deja/g++.brendan/cvt1.C +++ b/gcc/testsuite/g++.old-deja/g++.brendan/cvt1.C @@ -1,6 +1,6 @@ // Build don't link: // GROUPS passed conversions -#include <iostream.h> +#include <iostream> class Thing { @@ -39,6 +39,6 @@ main (int argc, char** argv) Group g (Group::THIS_GROUP) ; g += new Thing (Thing::GOOD_THING) ; - cout << "Group type is " << (Group::GroupType) g << endl ; + std::cout << "Group type is " << (Group::GroupType) g << std::endl ; return 0 ; } diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/err-msg3.C b/gcc/testsuite/g++.old-deja/g++.brendan/err-msg3.C index 1d115e6c46a..76a084090ae 100644 --- a/gcc/testsuite/g++.old-deja/g++.brendan/err-msg3.C +++ b/gcc/testsuite/g++.old-deja/g++.brendan/err-msg3.C @@ -1,7 +1,7 @@ // Build don't link: // GROUPS passed error-messages -#include <fstream.h> -#include <iomanip.h> +#include <fstream> +#include <iomanip> // This error should not appear: // bug.C: In method `test::test(const class test &)': diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/misc13.C b/gcc/testsuite/g++.old-deja/g++.brendan/misc13.C deleted file mode 100644 index c2c8bc5601b..00000000000 --- a/gcc/testsuite/g++.old-deja/g++.brendan/misc13.C +++ /dev/null @@ -1,11 +0,0 @@ -// Build don't link: -// GROUPS passed miscellaneous-bugs -// This should only give warnings from duplicate_decls; it should not get -// errors from push_overloaded_decl as well. - -namespace std { -extern "C" -{ - long unsigned int strlen(char*);// ERROR - warning// ERROR - warning.* -} -} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/nest21.C b/gcc/testsuite/g++.old-deja/g++.brendan/nest21.C index cce10c44cbd..03d3f32ad74 100644 --- a/gcc/testsuite/g++.old-deja/g++.brendan/nest21.C +++ b/gcc/testsuite/g++.old-deja/g++.brendan/nest21.C @@ -1,7 +1,7 @@ // GROUPS passed nested-classes -#include <iostream.h> -#include <stdio.h> -#include <string.h> +#include <iostream> +#include <cstdio> +#include <cstring> static char output[1024]; @@ -32,44 +32,44 @@ public: BDDRetrace::Dump& BDDRetrace::Dump1::operator<<(char c) { char tempout[1024]; - sprintf (tempout, "%s%s%c", output, "1-", c); - strcpy (output, tempout); + 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]; - sprintf (tempout, "%s%s%d", output, "1-", i); - strcpy (output, tempout); + 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]; - sprintf (tempout, "%s%s%1.0f", output, "1-", r); - strcpy (output, tempout); + 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]; - sprintf (tempout, "%s%s%c", output, "2-", c); - strcpy (output, tempout); + std::sprintf (tempout, "%s%s%c", output, "2-", c); + std::strcpy (output, tempout); return *this; } BDDRetrace::Dump& Dump2::operator<<(int i) { char tempout[1024]; - sprintf (tempout, "%s%s%d", output, "2-", i); - strcpy (output, tempout); + std::sprintf (tempout, "%s%s%d", output, "2-", i); + std::strcpy (output, tempout); return *this; } BDDRetrace::Dump& Dump2::operator<<(double r) { char tempout[1024]; - sprintf (tempout, "%s%s%1.0f", output, "2-", r); - strcpy (output, tempout); + std::sprintf (tempout, "%s%s%1.0f", output, "2-", r); + std::strcpy (output, tempout); return *this; } int main() @@ -77,7 +77,7 @@ int main() BDDRetrace::Dump1 d1; Dump2 d2; - sprintf (output, " "); + std::sprintf (output, " "); d1 << 'a'; d1 << 1; @@ -87,10 +87,10 @@ int main() d2 << 1; d2 << 1.0; - if (strcmp (output, " 1-a1-11-12-a2-12-1") == 0) - printf ("PASS\n"); + if (std::strcmp (output, " 1-a1-11-12-a2-12-1") == 0) + std::printf ("PASS\n"); else - { printf ("FAIL\n"); return 1; } + { std::printf ("FAIL\n"); return 1; } return 0; } diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/ptolemy2.C b/gcc/testsuite/g++.old-deja/g++.brendan/ptolemy2.C index 4fd7e184323..0d053c2cda7 100644 --- a/gcc/testsuite/g++.old-deja/g++.brendan/ptolemy2.C +++ b/gcc/testsuite/g++.old-deja/g++.brendan/ptolemy2.C @@ -1,5 +1,5 @@ // GROUPS passed ptolemy-bugs -#include <iostream.h> +#include <iostream> class PTcl { public: @@ -45,19 +45,19 @@ void printargs(char** argv) { } int PTcl::one(int, char** argv) { - cout << "FAIL\n"; + std::cout << "FAIL\n"; printargs(argv); return 1; } int PTcl::two(int, char** argv) { - cout << "PASS\n"; + std::cout << "PASS\n"; printargs(argv); return 0; } int PTcl::three(int, char** argv) { - cout << "FAIL\n"; + std::cout << "FAIL\n"; printargs(argv); return 1; } diff --git a/gcc/testsuite/g++.old-deja/g++.eh/catch13.C b/gcc/testsuite/g++.old-deja/g++.eh/catch13.C new file mode 100644 index 00000000000..47a0c90b963 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.eh/catch13.C @@ -0,0 +1,19 @@ +// Copyright (C) 2001 Free Software Foundation, Inc. +// Contributed by Jakub Jelinek 2 May 2001 <jakub@redhat.com> + +// Build don't link: +// Special g++ Options: -O2 + +struct A; + +A *foo(); + +struct A { + A *a() { try { return foo(); } catch (...) {} } + void b(); + void c(); +}; + +void A::b() { + a()->c(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.eh/catch14.C b/gcc/testsuite/g++.old-deja/g++.eh/catch14.C new file mode 100644 index 00000000000..96be4640bad --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.eh/catch14.C @@ -0,0 +1,33 @@ +// Copyright (C) 2001 Free Software Foundation, Inc. +// Contributed by Jakub Jelinek 2 May 2001 <jakub@redhat.com> + +// Build don't link: +// Special g++ Options: -O1 + +void foo(); + +struct A { + A (int x) { }; + ~A() { + try { + foo (); + } catch (...) { } + }; +}; + +struct B; + +B *x; + +struct B { + void a(); + void b(); + static B* c() { + A y = 0; + return x; + }; +}; + +void B::a() { + c()->b(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.eh/crash3.C b/gcc/testsuite/g++.old-deja/g++.eh/crash3.C index b55e1ecf8d6..75287bf80aa 100644 --- a/gcc/testsuite/g++.old-deja/g++.eh/crash3.C +++ b/gcc/testsuite/g++.old-deja/g++.eh/crash3.C @@ -1,6 +1,6 @@ // Build don't link: // Origin: Marc Espie <Marc.Espie@liafa.jussieu.fr> -// Special g++ Options: -fsjlj-exceptions +// Used to use -fsjlj-exceptions, but that isn't an option anymore. extern double f(double a); diff --git a/gcc/testsuite/g++.old-deja/g++.eh/crash5.C b/gcc/testsuite/g++.old-deja/g++.eh/crash5.C new file mode 100644 index 00000000000..ef476bf1d3f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.eh/crash5.C @@ -0,0 +1,12 @@ +// Build don't link: +// Origin: Mark Mitchell <mark@codesourcery.com> + +int i; +int j; + +void +f () +{ + j = j + (i ? 7 : throw 1); +} + diff --git a/gcc/testsuite/g++.old-deja/g++.eh/crash6.C b/gcc/testsuite/g++.old-deja/g++.eh/crash6.C new file mode 100644 index 00000000000..1f5dccedc5e --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.eh/crash6.C @@ -0,0 +1,26 @@ +// Build don't link: +// +// Copyright (C) 2001 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 26 April 2001 <nathan@codesourcery.com> +// Origin: schmid@snake.iap.physik.tu-darmstadt.de + +// Bug 2368. When checking shadowed catchers, we didn't ignore +// template type parms etc, leading to an ICE + +template<class CatchType1, class CatchType2> +void call(int& a) +{ + try + { + + } + catch (CatchType1&) + { + + } + catch (CatchType2&) + { + + } +} + diff --git a/gcc/testsuite/g++.old-deja/g++.eh/new1.C b/gcc/testsuite/g++.old-deja/g++.eh/new1.C index 1671dbbe7de..788a39b2958 100644 --- a/gcc/testsuite/g++.old-deja/g++.eh/new1.C +++ b/gcc/testsuite/g++.old-deja/g++.eh/new1.C @@ -1,8 +1,8 @@ // Test that a throw in foo destroys the A, but does not free the memory. -#include <stddef.h> -#include <stdlib.h> -#include <new.h> +#include <cstddef> +#include <cstdlib> +#include <new> struct A { A(); @@ -34,11 +34,15 @@ void foo (B*) { throw 1; } void* operator new (size_t size) throw (std::bad_alloc) { ++newed; - return (void *) malloc (size); + return (void *) std::malloc (size); } void operator delete (void *p) throw () { --newed; - free (p); + std::free (p); } + + + + diff --git a/gcc/testsuite/g++.old-deja/g++.eh/new2.C b/gcc/testsuite/g++.old-deja/g++.eh/new2.C index ddc8ba82e58..316afffbfc6 100644 --- a/gcc/testsuite/g++.old-deja/g++.eh/new2.C +++ b/gcc/testsuite/g++.old-deja/g++.eh/new2.C @@ -1,8 +1,8 @@ // Test that a throw in B's constructor destroys the A and frees the memory. -#include <stddef.h> -#include <stdlib.h> -#include <new.h> +#include <cstddef> +#include <cstdlib> +#include <new> struct A { A(); @@ -35,7 +35,7 @@ void foo (B*) { } void* operator new (size_t size) throw (std::bad_alloc) { ++newed; - return (void *) malloc (size); + return (void *) std::malloc (size); } void operator delete (void *p) throw () @@ -43,3 +43,4 @@ void operator delete (void *p) throw () --newed; free (p); } + diff --git a/gcc/testsuite/g++.old-deja/g++.eh/spec7.C b/gcc/testsuite/g++.old-deja/g++.eh/spec7.C new file mode 100644 index 00000000000..1945b84aec7 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.eh/spec7.C @@ -0,0 +1,19 @@ +// Test that we allow simple throw specs on pointers. + +void f() throw () { } +void (*pf)() throw () = f; + +struct A +{ + void g() throw () { } + static void (A::*pmf)() throw (); +}; + +void (A::* A::pmf)() = &A::g; + +int main() +{ + pf (); + A a; + (a.*A::pmf)(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.eh/vbase3.C b/gcc/testsuite/g++.old-deja/g++.eh/vbase3.C index 7cffa6c0cb0..364eca61d11 100644 --- a/gcc/testsuite/g++.old-deja/g++.eh/vbase3.C +++ b/gcc/testsuite/g++.old-deja/g++.eh/vbase3.C @@ -1,5 +1,5 @@ // Build don't link: -// Special g++ Options: -fsjlj-exceptions +// Used to use -fsjlj-exceptions, but that isn't an option anymore. // Origin: Donn Terry <donn@interix.com> struct ios { diff --git a/gcc/testsuite/g++.old-deja/g++.ext/anon3.C b/gcc/testsuite/g++.old-deja/g++.ext/anon3.C new file mode 100644 index 00000000000..f4b99036629 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ext/anon3.C @@ -0,0 +1,36 @@ +// Build don't link: + +// Copyright (C) 2001 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 6 Jun 2001 <nathan@codesourcery.com> + +// Bug 2914. New types can be created in a static member +// initializer. These should not be injected into the member's class's +// scope. + +class DoubleSupport +{ + public: + static void toDouble(); + + static const double s_NaN; + static const double s_positiveInfinity; + static const double s_negativeInfinity; + static const double s_positiveZero; + static const double s_negativeZero; + static const unsigned long* s_NaNFirstDWORD; + static const unsigned long* s_NaNSecondDWORD; +}; + +const double DoubleSupport::s_positiveInfinity = +(__extension__ ((union { unsigned char __c[8]; double __d; }) + { __c: { 0, 0, 0, 0, 0, 0, 0xf0, 0x7f } }).__d); + +struct other +{ +}; + + +void +DoubleSupport::toDouble() +{ +} diff --git a/gcc/testsuite/g++.old-deja/g++.ext/arrnew.C b/gcc/testsuite/g++.old-deja/g++.ext/arrnew.C index ef051d265a0..0ecb8777e26 100644 --- a/gcc/testsuite/g++.old-deja/g++.ext/arrnew.C +++ b/gcc/testsuite/g++.old-deja/g++.ext/arrnew.C @@ -2,4 +2,6 @@ // Build don't link: // Special g++ Options: - int *f(){ return new int[1] = { 1 }; } +int *f(){ + return new int[1] = { 1 }; // WARNING - deprecated +} diff --git a/gcc/testsuite/g++.old-deja/g++.ext/attrib5.C b/gcc/testsuite/g++.old-deja/g++.ext/attrib5.C index 62f35e87468..191fede6389 100644 --- a/gcc/testsuite/g++.old-deja/g++.ext/attrib5.C +++ b/gcc/testsuite/g++.old-deja/g++.ext/attrib5.C @@ -1,5 +1,5 @@ // Test that attributes weak and alias coexist. -// excess errors test - XFAIL alpha*-dec-osf* *-*-hms +// excess errors test - XFAIL alpha*-dec-osf* *-*-hms hppa*-*-hpux* extern "C" { void f () __attribute__((weak, alias ("_f"))); diff --git a/gcc/testsuite/g++.old-deja/g++.ext/comint1.C b/gcc/testsuite/g++.old-deja/g++.ext/comint1.C index 1b8b3c81c45..78d99e6c357 100644 --- a/gcc/testsuite/g++.old-deja/g++.ext/comint1.C +++ b/gcc/testsuite/g++.old-deja/g++.ext/comint1.C @@ -1,5 +1,4 @@ // Test that we can use mixins with COM classes. -// Special g++ Options: -fvtable-thunks struct A { diff --git a/gcc/testsuite/g++.old-deja/g++.ext/initp1.C b/gcc/testsuite/g++.old-deja/g++.ext/initp1.C deleted file mode 100644 index 0e4c02c3c0d..00000000000 --- a/gcc/testsuite/g++.old-deja/g++.ext/initp1.C +++ /dev/null @@ -1,91 +0,0 @@ -// Test for proper handling of the init_priority attribute. -// Contributed by Hugo Tyson <hmt@cygnus.co.uk> -// excess errors test - XFAIL mips*-sgi-irix* - -class Two { -private: - int i, j, k; -public: - static int count; - Two( int ii, int jj ) { i = ii; j = jj; k = count++; }; - Two( void ) { i = 0; j = 0; k = count++; }; - int eye( void ) { return i; }; - int jay( void ) { return j; }; - int kay( void ) { return k; }; -}; - -extern Two foo; -extern Two goo; -extern Two coo[]; -extern Two koo[]; - -Two foo( 5, 6 ) __attribute__((init_priority(1005))); - -Two goo __attribute__((init_priority(1007))) = Two( 7, 8 ); - -Two doo[ 3 ]; - -Two hoo[ 3 ] = { - Two( 11, 12 ), - Two( 13, 14 ), - Two( 15, 16 ) -}; - -Two coo[ 3 ] __attribute__((init_priority(1000))); - -Two koo[ 3 ] __attribute__((init_priority(1000))) = { - Two( 21, 22 ), - Two( 23, 24 ), - Two( 25, 26 ) -}; - -Two xoo[ 3 ] __attribute__((init_priority(1100))); - -Two zoo[ 3 ] __attribute__((init_priority(1100))) = { - Two( 31, 32 ), - Two( 33, 34 ), - Two( 35, 36 ) -}; - -int Two::count; - -int x = 0; - -#define X( n ) \ - do { if ( x & (1 << (n)) ) return 1; else x |= (1 << (n)); } while (0) - -int main() -{ - - X( coo[0].kay() ); - X( coo[1].kay() ); - X( coo[2].kay() ); - X( koo[0].kay() ); - X( koo[1].kay() ); - X( koo[2].kay() ); - if ( 0x3f != x ) return 1; - - X( foo.kay() ); - if ( 0x7f != x ) return 1; - - X( goo.kay() ); - if ( 0xff != x ) return 1; - - X( xoo[0].kay() ); - X( xoo[1].kay() ); - X( xoo[2].kay() ); - X( zoo[0].kay() ); - X( zoo[1].kay() ); - X( zoo[2].kay() ); - if ( 0x3fff != x ) return 1; - - X( doo[0].kay() ); - X( doo[1].kay() ); - X( doo[2].kay() ); - X( hoo[0].kay() ); - X( hoo[1].kay() ); - X( hoo[2].kay() ); - if ( 0xfffff != x ) return 1; - - return 0; -} diff --git a/gcc/testsuite/g++.old-deja/g++.ext/instantiate1.C b/gcc/testsuite/g++.old-deja/g++.ext/instantiate1.C index 8d5457f5944..8e0fbe073fd 100644 --- a/gcc/testsuite/g++.old-deja/g++.ext/instantiate1.C +++ b/gcc/testsuite/g++.old-deja/g++.ext/instantiate1.C @@ -13,12 +13,22 @@ template <class T> struct A { template <class T> void A<T>::f () { } extern template struct A<int>; +// These functions must be defined in a single line, so that, even if +// constants or pointers are placed in the code section (for example, +// on the SH), we still get the same line numbers. + +void test_f_int () { f(42); } // ERROR - not instantiated + +void test_A_int_f () { A<int> a; a.f (); } // ERROR - not instantiated + +void test_f_double () { f (2.0); } // gets bogus error + +void test_A_double_f () { A<double> b; b.f (); } // gets bogus error + int main () { - f (42); // ERROR - not instantiated - A<int> a; - a.f (); // ERROR - not instantiated - f (2.0); // gets bogus error - A<double> b; - b.f (); // gets bogus error + test_f_int (); + test_A_int_f (); + test_f_double (); + test_A_double_f (); } diff --git a/gcc/testsuite/g++.old-deja/g++.ext/instantiate2.C b/gcc/testsuite/g++.old-deja/g++.ext/instantiate2.C index 0b3dc24ea4c..805233248b2 100644 --- a/gcc/testsuite/g++.old-deja/g++.ext/instantiate2.C +++ b/gcc/testsuite/g++.old-deja/g++.ext/instantiate2.C @@ -10,10 +10,18 @@ template <class T> struct A { template <class T> T A<T>::t = 0; static template struct A<int>; +// These functions must be defined in a single line, so that, even if +// constants or pointers are placed in the code section (for example, +// on the SH), we still get the same line numbers. + +void test_int() { A<int>::t = 42; } // gets bogus error + +void test_char() { A<char>::t = 42; } // ERROR - not instantiated XFAIL *-*-irix* *-*-hpux* +// Irix's default linker does not produce line numbers so XFAIL it. +// Similarly for HP's linker + int main () { - A<int>::t = 42; // gets bogus error - A<char>::t = 42; // ERROR - not instantiated XFAIL mips*-*-* - // Irix's default linker does not - // produce line numbers so XFAIL it. + test_int (); + test_char (); } diff --git a/gcc/testsuite/g++.old-deja/g++.ext/instantiate3.C b/gcc/testsuite/g++.old-deja/g++.ext/instantiate3.C index 92ad16dfd45..18d5a579c88 100644 --- a/gcc/testsuite/g++.old-deja/g++.ext/instantiate3.C +++ b/gcc/testsuite/g++.old-deja/g++.ext/instantiate3.C @@ -10,9 +10,10 @@ template <class T> struct A { inline template struct A<int>; A<int> a; // gets bogus error -A<char> b; // ERROR - not instantiated XFAIL mips*-*-* +A<char> b; // ERROR - not instantiated XFAIL mips*-*-* *-*-hpux* // Irix's default linker does not // produce line numbers so XFAIL it. + // Similarly for HPUX. int main () { diff --git a/gcc/testsuite/g++.old-deja/g++.ext/overload1.C b/gcc/testsuite/g++.old-deja/g++.ext/overload1.C new file mode 100644 index 00000000000..d99e04fecb8 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ext/overload1.C @@ -0,0 +1,20 @@ +// Build don't link: +// Special g++ Options: -fpermissive + +// Copyright (C) 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 28 Feb 2001 <nathan@codesourcery.com> + +// Make sure we warn about our overload extension about picking the +// one with the least worse conversion + +struct X +{ + X (int); +}; +void Foo (int, float, bool); +void Foo (float, int, X); + +void Baz () +{ + Foo (1, 1, 0); // WARNING - least worse +} diff --git a/gcc/testsuite/g++.old-deja/g++.ext/realpt1.C b/gcc/testsuite/g++.old-deja/g++.ext/realpt1.C index 7e8ea9164bc..0bfc6408692 100644 --- a/gcc/testsuite/g++.old-deja/g++.ext/realpt1.C +++ b/gcc/testsuite/g++.old-deja/g++.ext/realpt1.C @@ -2,17 +2,17 @@ // Special g++ Options: // Origin: Mark Mitchell <mark@codesourcery.com> -template <double d> +template <double d> // WARNING - deprecated struct S; -template <double d, double e> -void f (S<d>*, S<e>*, S<d + e>*); +template <double d, double e> // WARNING - deprecated +void f (S<d>*, S<e>*, S<d + e>*); // WARNING - deprecated void g () { - S<2.0>* s1; - S<3.7>* s2; - S<5.7>* s3; + S<2.0>* s1; // WARNING - deprecated + S<3.7>* s2; // WARNING - deprecated + S<5.7>* s3; // WARNING - deprecated f (s1, s2, s3); } diff --git a/gcc/testsuite/g++.old-deja/g++.jason/2371.C b/gcc/testsuite/g++.old-deja/g++.jason/2371.C index 5e45071e6ea..a982d4042e4 100644 --- a/gcc/testsuite/g++.old-deja/g++.jason/2371.C +++ b/gcc/testsuite/g++.old-deja/g++.jason/2371.C @@ -7,12 +7,12 @@ // Wendell Baker, Berkeley CAD Group, 1993 (wbaker@ic.Berkeley.EDU) // - #pragma implementation "ListS.h" #pragma implementation "SetLS.h" -#include <stdlib.h> -#include <iostream.h> +#include <cstdlib> +#include <iostream> +using namespace std; # 1 "../../templates/SetLS.h" 1 // -*- C++ -*- diff --git a/gcc/testsuite/g++.old-deja/g++.jason/template24.C b/gcc/testsuite/g++.old-deja/g++.jason/template24.C index 120b717eddd..3315d182c42 100644 --- a/gcc/testsuite/g++.old-deja/g++.jason/template24.C +++ b/gcc/testsuite/g++.old-deja/g++.jason/template24.C @@ -1,6 +1,6 @@ // Bug: g++ doesn't find the conversion from ostream_withassign to ostream. -#include <iostream.h> +#include <iostream> template <class T> struct A { @@ -8,7 +8,7 @@ struct A { }; template <class T> -ostream & operator<< (ostream & os, A<T> & a) +std::ostream & operator<< (std::ostream & os, A<T> & a) { os << a.t; return os; @@ -17,5 +17,6 @@ ostream & operator<< (ostream & os, A<T> & a) int main () { A<int> a = { 1 }; - cout << a << endl; + std::cout << a << std::endl; } + diff --git a/gcc/testsuite/g++.old-deja/g++.jason/template31.C b/gcc/testsuite/g++.old-deja/g++.jason/template31.C index 6fc0e4b5eca..15e91fde7f7 100644 --- a/gcc/testsuite/g++.old-deja/g++.jason/template31.C +++ b/gcc/testsuite/g++.old-deja/g++.jason/template31.C @@ -1,6 +1,6 @@ // PRMS Id: 8569 -#include <iostream.h> +#include <iostream> #include <vector> using std::vector; @@ -33,10 +33,15 @@ private: int main(int argc, char**argv) { IncludeIt foo; IncludeIt* bar; - exit(0); + std::exit(0); } template class std::__malloc_alloc_template<0>; #ifndef __USE_MALLOC template class std::__default_alloc_template<false, 0>; #endif + + + + + diff --git a/gcc/testsuite/g++.old-deja/g++.jason/thunk1.C b/gcc/testsuite/g++.old-deja/g++.jason/thunk1.C index 22c0516f1b3..a46d356a6c0 100644 --- a/gcc/testsuite/g++.old-deja/g++.jason/thunk1.C +++ b/gcc/testsuite/g++.old-deja/g++.jason/thunk1.C @@ -1,5 +1,4 @@ // Test that non-variadic function calls using thunks work right. -// Special g++ Options: -fvtable-thunks struct A { void* p; @@ -38,7 +37,7 @@ void* test(MMixin& anExample) return anExample.MixinFunc(1,A(0)).p; } -main () +int main () { CExample c; diff --git a/gcc/testsuite/g++.old-deja/g++.jason/thunk2.C b/gcc/testsuite/g++.old-deja/g++.jason/thunk2.C index 73bb0ff33b1..3df566a68cc 100644 --- a/gcc/testsuite/g++.old-deja/g++.jason/thunk2.C +++ b/gcc/testsuite/g++.old-deja/g++.jason/thunk2.C @@ -1,6 +1,6 @@ // Test that non-variadic function calls using thunks and PIC work right. // Skip if not native -// Special g++ Options: -fvtable-thunks -fPIC +// Special g++ Options: -fPIC // excess errors test - XFAIL m68k-motorola-sysv m88k-motorola-sysv3 struct A { diff --git a/gcc/testsuite/g++.old-deja/g++.jason/thunk3.C b/gcc/testsuite/g++.old-deja/g++.jason/thunk3.C index 79c0bd96e3a..8833348230d 100644 --- a/gcc/testsuite/g++.old-deja/g++.jason/thunk3.C +++ b/gcc/testsuite/g++.old-deja/g++.jason/thunk3.C @@ -2,7 +2,6 @@ // Note that this will break on any target that uses the generic thunk // support, because it doesn't support variadic functions. -// Special g++ Options: -fvtable-thunks // excess errors test - XFAIL mips*-*-* rs6000-*-* powerpc-*-eabi m68k-*-coff m68k-motorola-sysv m88k-motorola-sysv3 mn10300-*-* mn10200-*-* v850-*-* sh-*-* h8*-*-* #include <stdarg.h> @@ -50,7 +49,7 @@ void* test(MMixin& anExample) return anExample.MixinFunc(1,2,3,4,5,6,7,8,9).p; } -main () +int main () { CExample c; diff --git a/gcc/testsuite/g++.old-deja/g++.jason/typeid1.C b/gcc/testsuite/g++.old-deja/g++.jason/typeid1.C index f6cd45bc664..0f44cb75ed1 100644 --- a/gcc/testsuite/g++.old-deja/g++.jason/typeid1.C +++ b/gcc/testsuite/g++.old-deja/g++.jason/typeid1.C @@ -1,11 +1,11 @@ #include <typeinfo> -#include <iostream.h> +#include <iostream> struct foo { double f(int); }; int main() { double f (int); const std::type_info &r = typeid (f); - cout << typeid(f).name() << endl; - cout << typeid(foo::f).name() << endl; + std::cout << typeid(f).name() << std::endl; + std::cout << typeid(foo::f).name() << std::endl; } diff --git a/gcc/testsuite/g++.old-deja/g++.law/arg1.C b/gcc/testsuite/g++.old-deja/g++.law/arg1.C index 1712f932f13..e017ea0e12a 100644 --- a/gcc/testsuite/g++.old-deja/g++.law/arg1.C +++ b/gcc/testsuite/g++.old-deja/g++.law/arg1.C @@ -5,18 +5,18 @@ // From: kondo@akane.mech.ibaraki.ac.jp // Date: Fri, 04 Sep 92 17:41:05 JST -#include <iostream.h> +#include <iostream> // check the order of declarations class A { public: - void f(double* p) { cout << "A(double*)\n"; } // ERROR - candidate - void f(int* p) { cout << "A(int*)\n"; } // ERROR - candidate + void f(double* p) { std::cout << "A(double*)\n"; } // ERROR - candidate + void f(int* p) { std::cout << "A(int*)\n"; } // ERROR - candidate }; class B { public: - void f(int* p) { cout << "B(int*)\n"; } // ERROR - candidate - void f(double* p) { cout << "B(double*)\n"; } // ERROR - candidate + void f(int* p) { std::cout << "B(int*)\n"; } // ERROR - candidate + void f(double* p) { std::cout << "B(double*)\n"; } // ERROR - candidate }; int main() @@ -27,3 +27,4 @@ int main() a.f(0);// ERROR - .* b.f(0);// ERROR - .* } + diff --git a/gcc/testsuite/g++.old-deja/g++.law/arg8.C b/gcc/testsuite/g++.old-deja/g++.law/arg8.C index 802471bae47..5f7360d5e49 100644 --- a/gcc/testsuite/g++.old-deja/g++.law/arg8.C +++ b/gcc/testsuite/g++.old-deja/g++.law/arg8.C @@ -6,22 +6,22 @@ // Date: Thu, 8 Jul 93 11:47:28 MDT -#include <iostream.h> -#include <stdio.h> +#include <iostream> +#include <cstdio> // With this declaration the program will not link. -template <class Type> ostream & save(ostream & os, Type T); +template <class Type> std::ostream & save(std::ostream & os, Type T); - template <class Type> ostream & -save(ostream & os, Type T) { + template <class Type> std::ostream & +save(std::ostream & os, Type T) { return os << T; } // save int main() { int i = 10; - save((ostream &)cout, i) << endl; + save((std::ostream &)std::cout, i) << std::endl; short int s = 5; - save((ostream &)cout, s) << endl; - printf ("PASS\n"); + save((std::ostream &)std::cout, s) << std::endl; + std::printf ("PASS\n"); } // main diff --git a/gcc/testsuite/g++.old-deja/g++.law/arm12.C b/gcc/testsuite/g++.old-deja/g++.law/arm12.C index 89e2a4d2c82..49d39d5a4db 100644 --- a/gcc/testsuite/g++.old-deja/g++.law/arm12.C +++ b/gcc/testsuite/g++.old-deja/g++.law/arm12.C @@ -5,7 +5,7 @@ // Subject: Bad access control with private constructor and derivation // Date: Fri, 28 May 1993 12:39:57 -0400 (EDT) -#include <iostream.h> +#include <iostream> class X { @@ -24,17 +24,17 @@ public: X::X() {// ERROR - .* - cout << "X::X()" << endl; + std::cout << "X::X()" << std::endl; } void X::f() { - cout << "X::f()" << endl; + std::cout << "X::f()" << std::endl; } Y::Y() {// ERROR - within this - cout << "Y::Y()" << endl; + std::cout << "Y::Y()" << std::endl; } @@ -45,3 +45,5 @@ int main() } + + diff --git a/gcc/testsuite/g++.old-deja/g++.law/arm9.C b/gcc/testsuite/g++.old-deja/g++.law/arm9.C index 35658b17cbc..7e79fdcdc56 100644 --- a/gcc/testsuite/g++.old-deja/g++.law/arm9.C +++ b/gcc/testsuite/g++.old-deja/g++.law/arm9.C @@ -1,6 +1,6 @@ // Build don't link: // GROUPS passed ARM-compliance -#include <iostream.h> +#include <iostream> enum f1 { F1 }; @@ -13,13 +13,13 @@ class A { public: void set (f1 f); }; -void A::set (f1 f) { cout << "called A f1\n";} +void A::set (f1 f) { std::cout << "called A f1\n";} class B : public A { public: void set (f2 f); }; -void B::set (f2 f) { cout << "called B\n";} // ERROR - candidate +void B::set (f2 f) { std::cout << "called B\n";} // ERROR - candidate int main() { B b; @@ -31,3 +31,8 @@ int main() { // belong to different scopes. Thus B::set() should have // hidden (completely) the A::set() function. } + + + + + diff --git a/gcc/testsuite/g++.old-deja/g++.law/bad-error7.C b/gcc/testsuite/g++.old-deja/g++.law/bad-error7.C index 434921dd72d..05b3033b1cf 100644 --- a/gcc/testsuite/g++.old-deja/g++.law/bad-error7.C +++ b/gcc/testsuite/g++.old-deja/g++.law/bad-error7.C @@ -1,6 +1,6 @@ // Build don't link: // GROUPS passed bad-errors -#include <iostream.h> +#include <iostream> class ParX { @@ -11,7 +11,7 @@ class ParX class X : public ParX { public: - void fn2() { cout << "hi" << endl; } + void fn2() { std::cout << "hi" << std::endl; } }; int main() @@ -22,3 +22,9 @@ int main() (pParX->*p)(); } + + + + + + diff --git a/gcc/testsuite/g++.old-deja/g++.law/builtin1.C b/gcc/testsuite/g++.old-deja/g++.law/builtin1.C index 86a91e7e36f..c285c29fe2e 100644 --- a/gcc/testsuite/g++.old-deja/g++.law/builtin1.C +++ b/gcc/testsuite/g++.old-deja/g++.law/builtin1.C @@ -8,10 +8,9 @@ // the use of __builtin_alloca, and thus ends up being unresolved. // Special g++ Options: -extern "C" void* alloca( __SIZE_TYPE__ ); extern "C" int printf (const char *, ...); void* junk() { - return std::alloca(10); + return __builtin_alloca(10); } main() { printf ("PASS\n");} diff --git a/gcc/testsuite/g++.old-deja/g++.law/code-gen5.C b/gcc/testsuite/g++.old-deja/g++.law/code-gen5.C index 35087c0a51f..ff908758c4f 100644 --- a/gcc/testsuite/g++.old-deja/g++.law/code-gen5.C +++ b/gcc/testsuite/g++.old-deja/g++.law/code-gen5.C @@ -5,12 +5,12 @@ // Subject: An error! // Message-ID: <9311160259.AA03353@pi14.arc.umn.edu> -#include <stdlib.h> -#include <stdio.h> -#include <assert.h> -#include <fstream.h> -#include <iostream.h> -#include <math.h> +#include <cstdlib> +#include <cstdio> +#include <cassert> +#include <fstream> +#include <iostream> +#include <cmath> #define ANSI_C @@ -79,7 +79,7 @@ class Vector double assign( int, double ); - friend ostream& operator<<( ostream&, const Vector& m ); + friend std::ostream& operator<<(std::ostream&, const Vector& m ); private: @@ -142,7 +142,7 @@ operator=( const Vector &A ) double Vector:: operator()( int row ) const { - assert( r ); + assert(r != 0); return *r->vec; } @@ -150,7 +150,7 @@ operator()( int row ) const VecElem Vector:: operator()( int r ) { - assert(r); + assert(r != 0); return VecElem( *this, r ); } @@ -159,13 +159,13 @@ operator()( int r ) double Vector:: assign( int rownum, double d ) { - assert(r); + assert(r != 0); if( rownum > row() || rownum <= 0 ) { - cerr << "Warning: trying to assign out of bounds" << endl; - cerr << "row " << rownum << endl; - cerr << "Vector size " << row() << endl; - abort(); + std::cerr << "Warning: trying to assign out of bounds" << std::endl; + std::cerr << "row " << rownum << std::endl; + std::cerr << "Vector size " << row() << std::endl; + std::abort(); } if( r->count == 1 ) { @@ -232,8 +232,9 @@ VecElem( Vector &vec, int r ) : v(vec), row(r) { if( r < 1 || r > vec.row() ) { - cerr << "Trying to access vector element out of bounds" << endl; - abort(); + std::cerr << "Trying to access vector element out of bounds"; + std::cerr << std::endl; + std::abort(); } } @@ -245,7 +246,7 @@ VecElem( const VecElem &elem ) VecElem:: operator double() { - assert( v.r->vec ); + assert( v.r->vec != 0 ); return *v.r->vec; }; @@ -268,9 +269,9 @@ int main() int i, j; if (makeforms (cen,a,b) != 10) - { printf ("FAIL\n"); return 1; } + { std::printf ("FAIL\n"); return 1; } else - printf ("PASS\n"); + std::printf ("PASS\n"); } @@ -281,3 +282,5 @@ makeforms( Vector cen, Vector **a, Vector **b) return 10; } + + diff --git a/gcc/testsuite/g++.old-deja/g++.law/ctors10.C b/gcc/testsuite/g++.old-deja/g++.law/ctors10.C index 6520087d52f..4cc20e86cb6 100644 --- a/gcc/testsuite/g++.old-deja/g++.law/ctors10.C +++ b/gcc/testsuite/g++.old-deja/g++.law/ctors10.C @@ -6,14 +6,14 @@ // Subject: bug019.cc // Date: Fri, 5 Feb 93 15:51:42 -0800 -#include <iostream.h> +#include <iostream> class Class { - class Err : public ostream + class Err : public std::ostream { public: - Err(void) : ostream(NULL) { } + Err(void) : std::ostream(NULL) { } ~Err(void) { } }; public: @@ -22,3 +22,7 @@ public: private: char x; }; + + + + diff --git a/gcc/testsuite/g++.old-deja/g++.law/ctors12.C b/gcc/testsuite/g++.old-deja/g++.law/ctors12.C index 403bf3fc42b..30d944d4da9 100644 --- a/gcc/testsuite/g++.old-deja/g++.law/ctors12.C +++ b/gcc/testsuite/g++.old-deja/g++.law/ctors12.C @@ -1,7 +1,7 @@ // GROUPS passed constructors -#include <stdio.h> -#include <stdlib.h> -#include <iostream.h> +#include <cstdio> +#include <cstdlib> +#include <iostream> #define MAGIC 7654 @@ -14,9 +14,9 @@ public: complex() { re=im=0; magic=MAGIC; } complex(double d) { re=d; im=0; magic=MAGIC; } complex(double d, double d2) {re=d; im=d2; magic=MAGIC; } - ~complex() {if(magic!=MAGIC) {printf("FAIL\n");exit(1);}} - friend ostream& operator << (ostream& o, const complex& c) - { return o << "(" << c.re << "," << c.im << ")"; } + ~complex() {if(magic!=MAGIC) {std::printf("FAIL\n"); std::exit(1);}} + friend std::ostream& operator << (std::ostream& o, const complex& c) + { return o << "(" << c.re << "," << c.im << ")"; } }; int complex::count=0; diff --git a/gcc/testsuite/g++.old-deja/g++.law/ctors13.C b/gcc/testsuite/g++.old-deja/g++.law/ctors13.C index aef721be7ce..1442b02eb56 100644 --- a/gcc/testsuite/g++.old-deja/g++.law/ctors13.C +++ b/gcc/testsuite/g++.old-deja/g++.law/ctors13.C @@ -1,6 +1,6 @@ // Build don't link: // GROUPS passed constructors -#include <iostream.h> +#include <iostream> class A { A() {} // private constructor// ERROR - .* @@ -9,8 +9,10 @@ class A { int main() { A* a = new A();// ERROR - .* if (a) { - cout << "a != NULL\n"; + std::cout << "a != NULL\n"; } else { - cout << "a == NULL\n"; + std::cout << "a == NULL\n"; } } + + diff --git a/gcc/testsuite/g++.old-deja/g++.law/ctors17.C b/gcc/testsuite/g++.old-deja/g++.law/ctors17.C index 1f5f0b00c6c..5fe1724df78 100644 --- a/gcc/testsuite/g++.old-deja/g++.law/ctors17.C +++ b/gcc/testsuite/g++.old-deja/g++.law/ctors17.C @@ -7,9 +7,9 @@ // Date: Tue, 15 Jun 1993 18:34:14 +0200 (MET DST) -#include <fstream.h> +#include <fstream> -class X : public ifstream { // ERROR - candidate +class X : public std::ifstream { // ERROR - candidate public: X(int a, char *b) {} // ERROR - candidate }; diff --git a/gcc/testsuite/g++.old-deja/g++.law/ctors6.C b/gcc/testsuite/g++.old-deja/g++.law/ctors6.C index a46f4e89bdb..b2d0a197d51 100644 --- a/gcc/testsuite/g++.old-deja/g++.law/ctors6.C +++ b/gcc/testsuite/g++.old-deja/g++.law/ctors6.C @@ -1,8 +1,8 @@ // Build don't link: // GROUPS passed constructors -#include <complex.h> +#include <complex> -double foo(double_complex *a) +double foo(std::complex<double> *a) { return 0.0; } @@ -10,6 +10,6 @@ double foo(double_complex *a) double bar(void) { - double_complex v[10]; + std::complex<double> v[10]; return foo(v); } diff --git a/gcc/testsuite/g++.old-deja/g++.law/cvt16.C b/gcc/testsuite/g++.old-deja/g++.law/cvt16.C index c539c96e536..2d75c4c3106 100644 --- a/gcc/testsuite/g++.old-deja/g++.law/cvt16.C +++ b/gcc/testsuite/g++.old-deja/g++.law/cvt16.C @@ -6,7 +6,7 @@ // Subject: g++ bug // Date: Mon, 12 Apr 93 10:47:01 MDT -#include <iostream.h> +#include <iostream> class B { }; @@ -22,8 +22,9 @@ public: main() { A a(37); //cout << a << endl; - cout << (short)a << endl; + std::cout << (short)a << std::endl; return 0; } // main + diff --git a/gcc/testsuite/g++.old-deja/g++.law/cvt2.C b/gcc/testsuite/g++.old-deja/g++.law/cvt2.C index c37098536e9..7db6b2b566a 100644 --- a/gcc/testsuite/g++.old-deja/g++.law/cvt2.C +++ b/gcc/testsuite/g++.old-deja/g++.law/cvt2.C @@ -1,15 +1,15 @@ // GROUPS passed conversions -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <iostream.h> -#include <fstream.h> +#include <cstdio> +#include <cstdlib> +#include <cstring> +#include <iostream> +#include <fstream> class cvec { public: ~cvec(){ delete s; } - cvec(const char*x) { s = new char[strlen(x)+1]; strcpy(s, x); } - cvec(const cvec& c) { s = new char[strlen(c.s)+1]; strcpy(s, c.s); } + cvec(const char*x) { s = new char[std::strlen(x)+1]; std::strcpy(s, x); } + cvec(const cvec& c) { s = new char[std::strlen(c.s)+1]; std::strcpy(s, c.s); } operator const char*() { return s; } private: char *s; @@ -25,18 +25,17 @@ void A(const char* s) { // s still ok here - ifstream inf(s); - if (strncmp ("aaa", s, 3)) + std::ifstream inf(s); + if (std::strncmp ("aaa", s, 3)) { - printf ("FAIL\n"); - exit (1); + std::printf ("FAIL\n"); + std::exit (1); } else - printf ("PASS\n"); + std::printf ("PASS\n"); } int main() { A(B("aaa")); } - diff --git a/gcc/testsuite/g++.old-deja/g++.law/cvt7.C b/gcc/testsuite/g++.old-deja/g++.law/cvt7.C index fc775c4f079..3327f73c2e1 100644 --- a/gcc/testsuite/g++.old-deja/g++.law/cvt7.C +++ b/gcc/testsuite/g++.old-deja/g++.law/cvt7.C @@ -5,14 +5,13 @@ // Message-Id: <9208250205.AA26351@icsib43.ICSI.Berkeley.EDU> // Subject: implicit int. convs. from member refs. in switch expressions -#include <stream.h> -#include <stdio.h> +#include <cstdio> class A { public: - A(int j) { i = j; } // ERROR - candidate - A(A& a) { i = a.i; } // ERROR - candidate + A(int j) { i = j; } + A(A& a) { i = a.i; } operator int() { return i; } void assign(int v) { i = v; } @@ -38,10 +37,10 @@ B::run() // Replacing above with "switch (int(in))" removes the error. { case 0: - out = 1; // ERROR - no usable copy ctor + out = 1; break; default: - out = 0; // ERROR - no usable copy ctor + out = 0; break; } } @@ -72,3 +71,10 @@ int main() return 0; } + + + + + + + diff --git a/gcc/testsuite/g++.old-deja/g++.law/except5.C b/gcc/testsuite/g++.old-deja/g++.law/except5.C index 623d0d8587f..18174e7fcf5 100644 --- a/gcc/testsuite/g++.old-deja/g++.law/except5.C +++ b/gcc/testsuite/g++.old-deja/g++.law/except5.C @@ -7,7 +7,8 @@ // Subject: exception's bug? // Date: Wed, 10 Nov 1993 11:07:12 -0500 -#include <stream.h> +#include <iostream> + class X { int *a; int sz; @@ -33,7 +34,7 @@ main() for (int i = 0; i < 12; i++) c[i] = 1; } catch (X::range) { - cerr << "invalid range\n"; + std::cerr << "invalid range\n"; } return 0; } diff --git a/gcc/testsuite/g++.old-deja/g++.law/missed-error2.C b/gcc/testsuite/g++.old-deja/g++.law/missed-error2.C index 18a026d1502..2fc1ddf5326 100644 --- a/gcc/testsuite/g++.old-deja/g++.law/missed-error2.C +++ b/gcc/testsuite/g++.old-deja/g++.law/missed-error2.C @@ -6,7 +6,7 @@ // Subject: More on [g++ 2.1 : overloaded function selection incorrect] // Message-ID: <9205212240.AA17934@ndc.com> -#include <iostream.h> +#include <iostream> inline int max(int a, int b) {return a > b ? a : b;}; // ERROR - candidate inline double max(double a, double b) {return a > b ? a : b;}; // ERROR - candidate @@ -21,8 +21,8 @@ int main() { // about the declaration above static void foo(int i, int j, double x, double y) { - cout << "Max(int): " << max(i,j) << " Max(double): " << + std::cout << "Max(int): " << max(i,j) << " Max(double): " << max(x,y) << '\n'; - cout << "Max(int, double): " << max(i, y) << '\n';// ERROR - + std::cout << "Max(int, double): " << max(i, y) << '\n';// ERROR - } diff --git a/gcc/testsuite/g++.old-deja/g++.law/nest3.C b/gcc/testsuite/g++.old-deja/g++.law/nest3.C index eac308e566a..d390bc48582 100644 --- a/gcc/testsuite/g++.old-deja/g++.law/nest3.C +++ b/gcc/testsuite/g++.old-deja/g++.law/nest3.C @@ -1,15 +1,15 @@ // Build don't link: // GROUPS passed nest -#include <iostream.h> +#include <iostream> struct inner { - static void f() { cout << "inner::f()\n";} + static void f() { std::cout << "inner::f()\n";} }; struct outer { struct inner { - static void f() { cout << "outer::inner::f()\n";} + static void f() { std::cout << "outer::inner::f()\n";} }; static void f() { @@ -20,6 +20,6 @@ struct outer { int main() { outer::f(); - cout << endl; + std::cout << std::endl; return 0; } diff --git a/gcc/testsuite/g++.old-deja/g++.law/operators32.C b/gcc/testsuite/g++.old-deja/g++.law/operators32.C index 26e439876a9..daebcefd339 100644 --- a/gcc/testsuite/g++.old-deja/g++.law/operators32.C +++ b/gcc/testsuite/g++.old-deja/g++.law/operators32.C @@ -1,6 +1,6 @@ // Build don't link: // GROUPS passed operators -#include <iostream.h> +#include <iostream> // // frees space allocated for N-D array @@ -43,9 +43,9 @@ long d1 = 3, d2 = 4; class foo { public: -foo() {cout << "foo created" << endl; } +foo() {std::cout << "foo created" << std::endl; } -~foo() {cout << "foo deleted" << endl; } +~foo() {std::cout << "foo deleted" << std::endl; } }; foo **f2; diff --git a/gcc/testsuite/g++.old-deja/g++.law/vbase1.C b/gcc/testsuite/g++.old-deja/g++.law/vbase1.C index 42282d57df8..a013c72901b 100644 --- a/gcc/testsuite/g++.old-deja/g++.law/vbase1.C +++ b/gcc/testsuite/g++.old-deja/g++.law/vbase1.C @@ -7,11 +7,11 @@ // Message-ID: <317f1j$o9c@agate.berkeley.edu> -#include <iostream.h> +#include <iostream> class a { protected: - virtual void foo() { cout << "Class A\n";} + virtual void foo() { std::cout << "Class A\n";} }; class b : public virtual a {}; @@ -26,3 +26,4 @@ int main() { test.bar(); } + diff --git a/gcc/testsuite/g++.old-deja/g++.law/virtual3.C b/gcc/testsuite/g++.old-deja/g++.law/virtual3.C index 0e25a3e70e1..8c30b7689a4 100644 --- a/gcc/testsuite/g++.old-deja/g++.law/virtual3.C +++ b/gcc/testsuite/g++.old-deja/g++.law/virtual3.C @@ -5,12 +5,12 @@ // Date: 4 Nov 1993 22:57:36 -0500 // Message-ID: <9311041820.AA05942@ramjet.multinet.DE> -#include <iostream.h> -#include <strstream.h> +#include <iostream> +#include <sstream> using namespace std; -class BugStream : public ostrstream { +class BugStream : public ostringstream { public: BugStream() {} BugStream& eval(); @@ -26,12 +26,12 @@ BugStream& BugStream::eval() *this << ends; // eval the command and set the status - char* s = str(); + const char* s = str().data(); cerr << s << endl; // reset the stream for the next command clear(ios::goodbit); - rdbuf()->freeze(0); + // rdbuf()->freeze(0); seekp(0); return *this; diff --git a/gcc/testsuite/g++.old-deja/g++.law/visibility1.C b/gcc/testsuite/g++.old-deja/g++.law/visibility1.C index 67f4bcd9919..736c11ab8ad 100644 --- a/gcc/testsuite/g++.old-deja/g++.law/visibility1.C +++ b/gcc/testsuite/g++.old-deja/g++.law/visibility1.C @@ -1,6 +1,6 @@ // Build don't link: // GROUPS passed visibility -#include <iostream.h> +#include <iostream> @@ -8,17 +8,17 @@ class base { //========== void base_priv(char * n) - { cout << "base_priv called from: " << n << "\n"; }; + { std::cout << "base_priv called from: " << n << "\n"; }; protected: void base_prot(char * n) - { cout << "base_prot called from: " << n << "\n"; }; + { std::cout << "base_prot called from: " << n << "\n"; }; public: void base_publ(char * n) - { cout << "base_publ called from: " << n << "\n"; }; + { std::cout << "base_publ called from: " << n << "\n"; }; void test(char * n) { base_publ(n); base_prot(n); base_priv(n); } @@ -57,12 +57,12 @@ int main(int argc, char *argv[]) base b; b.base_publ("base class object"); b.test("member of base class object"); - cout << "\n"; + std::cout << "\n"; derived pd; pd.test("member of derived class object"); derived_friend(); - cout << "\n"; + std::cout << "\n"; } /* main */ diff --git a/gcc/testsuite/g++.old-deja/g++.law/visibility10.C b/gcc/testsuite/g++.old-deja/g++.law/visibility10.C index 14dfa333dea..7f68af05b24 100644 --- a/gcc/testsuite/g++.old-deja/g++.law/visibility10.C +++ b/gcc/testsuite/g++.old-deja/g++.law/visibility10.C @@ -1,12 +1,12 @@ // Build don't link: // GROUPS passed visibility -#include <iostream.h> +#include <iostream> class base { public: - void f1 () { cout << "f1" << endl; }; - void f2 () { cout << "f2" << endl; }; + void f1 () { std::cout << "f1" << std::endl; }; + void f2 () { std::cout << "f2" << std::endl; }; }; class deriv : public base { @@ -19,3 +19,4 @@ int main () d.f2(); } + diff --git a/gcc/testsuite/g++.old-deja/g++.law/visibility13.C b/gcc/testsuite/g++.old-deja/g++.law/visibility13.C index 7f634e20cd8..dbde720d276 100644 --- a/gcc/testsuite/g++.old-deja/g++.law/visibility13.C +++ b/gcc/testsuite/g++.old-deja/g++.law/visibility13.C @@ -6,11 +6,13 @@ // Subject: class, template and their scoping problem // Message-ID: <9307130521.AA18312@oahu.cs.ucla.edu> -#include <iostream.h> -#include <assert.h> +#include <iostream> +#include <cassert> // --------------- Array.h && Array.cc ------------------ +using namespace std; + const int ArraySize = 12; template <class Type> diff --git a/gcc/testsuite/g++.old-deja/g++.law/visibility17.C b/gcc/testsuite/g++.old-deja/g++.law/visibility17.C index fa4d6db69b9..2aa08a09169 100644 --- a/gcc/testsuite/g++.old-deja/g++.law/visibility17.C +++ b/gcc/testsuite/g++.old-deja/g++.law/visibility17.C @@ -5,8 +5,8 @@ // Date: Thu, 05 Aug 1993 17:23:20 -0700 // Subject: Access to private constructor. // Message-ID: <9308060023.AA10283@neptune.caere.com> -#include <iostream.h> -#include <string.h> +#include <iostream> +#include <cstring> class Base { @@ -33,13 +33,13 @@ private: Base::Base() { // ERROR - private - name_ = strcpy(new char[strlen(" ") + 1], " "); + name_ = std::strcpy(new char[std::strlen(" ") + 1], " "); } Base::Base(char* str) { // ERROR - private if(str != NULL) - name_ = strcpy(new char[strlen(str) + 1], str); + name_ = std::strcpy(new char[std::strlen(str) + 1], str); } Derived::Derived(int n, char* str) : Base(str) @@ -59,6 +59,8 @@ int main() // Derived* d = new Derived(10, "test"); Derived* d = new Derived(10); - cerr << d->getNum() << "\t" << d->getName() << endl; + std::cerr << d->getNum() << "\t" << d->getName() << std::endl; } + + diff --git a/gcc/testsuite/g++.old-deja/g++.law/visibility2.C b/gcc/testsuite/g++.old-deja/g++.law/visibility2.C index 5806fc564b7..9d038d46891 100644 --- a/gcc/testsuite/g++.old-deja/g++.law/visibility2.C +++ b/gcc/testsuite/g++.old-deja/g++.law/visibility2.C @@ -1,6 +1,6 @@ // Build don't link: // GROUPS passed visibility -#include <iostream.h> +#include <iostream> @@ -8,17 +8,17 @@ class base { //========== void base_priv(char * n) - { cout << "base_priv called from: " << n << "\n"; }; + { std::cout << "base_priv called from: " << n << "\n"; }; protected: void base_prot(char * n) - { cout << "base_prot called from: " << n << "\n"; }; + { std::cout << "base_prot called from: " << n << "\n"; }; public: void base_publ(char * n) - { cout << "base_publ called from: " << n << "\n"; }; + { std::cout << "base_publ called from: " << n << "\n"; }; void test(char * n) { base_publ(n); base_prot(n); base_priv(n); } @@ -57,12 +57,12 @@ int main(int argc, char *argv[]) base b; b.base_publ("base class object"); b.test("member of base class object"); - cout << "\n"; + std::cout << "\n"; derived pd; pd.test("member of derived class object"); derived_friend(); - cout << "\n"; + std::cout << "\n"; } /* main */ diff --git a/gcc/testsuite/g++.old-deja/g++.law/visibility22.C b/gcc/testsuite/g++.old-deja/g++.law/visibility22.C index a9448c07fee..edfb897d0b7 100644 --- a/gcc/testsuite/g++.old-deja/g++.law/visibility22.C +++ b/gcc/testsuite/g++.old-deja/g++.law/visibility22.C @@ -7,7 +7,7 @@ // Message-ID: <9308121348.aa26256@Paris.ics.uci.edu> // 5.cc -#include <stream.h> +#include <iostream> class A { int x; @@ -23,3 +23,8 @@ protected: public: A::g; }; + + + + + diff --git a/gcc/testsuite/g++.old-deja/g++.law/visibility25.C b/gcc/testsuite/g++.old-deja/g++.law/visibility25.C index 607e25a00ce..96db3936b90 100644 --- a/gcc/testsuite/g++.old-deja/g++.law/visibility25.C +++ b/gcc/testsuite/g++.old-deja/g++.law/visibility25.C @@ -5,7 +5,7 @@ // Date: Wed, 17 Nov 93 21:30:32 EST // Subject: gcc 2.5.3 - can't privately inherit and contain same class // Message-ID: <9311171030.AA00604@mencon> -#include <iostream.h> +#include <iostream> class A { public: @@ -24,3 +24,10 @@ public: private: ::A a; }; + + + + + + + diff --git a/gcc/testsuite/g++.old-deja/g++.law/visibility7.C b/gcc/testsuite/g++.old-deja/g++.law/visibility7.C index 764da35d9db..ec7947c5503 100644 --- a/gcc/testsuite/g++.old-deja/g++.law/visibility7.C +++ b/gcc/testsuite/g++.old-deja/g++.law/visibility7.C @@ -5,7 +5,7 @@ // Date: Wed, 21 Apr 93 09:42:07 +0100 // Subject: /*** BUG REPORT : THE MYTH OF PRIVATE INHERITANCE ***/ // Message-ID: <9304210842.AA01815@life.ai.mit.edu> -#include <iostream.h> +#include <iostream> class A { private: @@ -64,8 +64,10 @@ int main() B* bobject = new B(2, 1); C* cobject = new C(bobject); cobject->setBValue(8); - cout << cobject->getBValue() << endl; + std::cout << cobject->getBValue() << std::endl; delete bobject; delete cobject; } + + diff --git a/gcc/testsuite/g++.old-deja/g++.law/vtable2.C b/gcc/testsuite/g++.old-deja/g++.law/vtable2.C index bbc8074de91..15b31e42908 100644 --- a/gcc/testsuite/g++.old-deja/g++.law/vtable2.C +++ b/gcc/testsuite/g++.old-deja/g++.law/vtable2.C @@ -1,5 +1,4 @@ // Build don't link: -// Special g++ Options: -fvtable-thunks // GROUPS passed vtable struct C1 { diff --git a/gcc/testsuite/g++.old-deja/g++.law/weak.C b/gcc/testsuite/g++.old-deja/g++.law/weak.C index a799d0a0bd1..5937979f301 100644 --- a/gcc/testsuite/g++.old-deja/g++.law/weak.C +++ b/gcc/testsuite/g++.old-deja/g++.law/weak.C @@ -5,16 +5,16 @@ // libc-5.4.xx has __IO_putc in its static C library, which can conflict // with the copy of __IO_putc in the libstdc++ library built by egcs. -#include <iostream.h> -#include <streambuf.h> -#include <stdio.h> +#include <iostream> +#include <streambuf> +#include <cstdio> -istream x (0); +std::istream x (0); main () { x.get(); - putc(0, 0); - fgets(0, 0, 0); + std::putc(0, 0); + std::fgets(0, 0, 0); x.get((char*) 0, 0); } diff --git a/gcc/testsuite/g++.old-deja/g++.mike/eh2.C b/gcc/testsuite/g++.old-deja/g++.mike/eh2.C index 4fc513ff0f5..c92afde4cd4 100644 --- a/gcc/testsuite/g++.old-deja/g++.mike/eh2.C +++ b/gcc/testsuite/g++.old-deja/g++.mike/eh2.C @@ -1,8 +1,8 @@ // Special g++ Options: -fexceptions // excess errors test - XFAIL a29k-*-* sparc64-*-elf arm-*-pe -#include <stdlib.h> -#include <iostream.h> +#include <cstdlib> +#include <iostream> class Vector { private: @@ -57,9 +57,9 @@ f(Vector& v) { try { do_something( v ); } catch (Vector::Range& r) { - cout << "Invalid vector range " << r.value() - << " caught in f()" << endl; - exit(0); + std::cout << "Invalid vector range " << r.value() + << " caught in f()" << std::endl; + std::exit(0); } } @@ -69,3 +69,6 @@ main() { f( v ); return 1; } + + + diff --git a/gcc/testsuite/g++.old-deja/g++.mike/eh33.C b/gcc/testsuite/g++.old-deja/g++.mike/eh33.C index d7c509ecd37..0c383501003 100644 --- a/gcc/testsuite/g++.old-deja/g++.mike/eh33.C +++ b/gcc/testsuite/g++.old-deja/g++.mike/eh33.C @@ -1,5 +1,5 @@ // Special g++ Options: -fexceptions -// excess errors test - XFAIL hppa*-*-* a29k-*-* sparc64-*-elf z8k-*-* arm-*-pe +// excess errors test - XFAIL a29k-*-* sparc64-*-elf z8k-*-* arm-*-pe #include <exception> diff --git a/gcc/testsuite/g++.old-deja/g++.mike/eh50.C b/gcc/testsuite/g++.old-deja/g++.mike/eh50.C index 84ccaddb9a9..f4421ab1824 100644 --- a/gcc/testsuite/g++.old-deja/g++.mike/eh50.C +++ b/gcc/testsuite/g++.old-deja/g++.mike/eh50.C @@ -1,5 +1,5 @@ // Special g++ Options: -fexceptions -// excess errors test - XFAIL hppa*-*-* a29k-*-* sparc64-*-elf z8k-*-* arm-*-pe +// excess errors test - XFAIL a29k-*-* sparc64-*-elf z8k-*-* arm-*-pe #include <exception> diff --git a/gcc/testsuite/g++.old-deja/g++.mike/memoize1.C b/gcc/testsuite/g++.old-deja/g++.mike/memoize1.C index 9b7aadc5081..cc98cfae2fa 100644 --- a/gcc/testsuite/g++.old-deja/g++.mike/memoize1.C +++ b/gcc/testsuite/g++.old-deja/g++.mike/memoize1.C @@ -1,4 +1,4 @@ // Build don't link: // Special g++ Options: -fsave-memoized -#include <iostream.h> +#include <iostream> diff --git a/gcc/testsuite/g++.old-deja/g++.mike/net34.C b/gcc/testsuite/g++.old-deja/g++.mike/net34.C index dada4cd13f0..9cf550c126e 100644 --- a/gcc/testsuite/g++.old-deja/g++.mike/net34.C +++ b/gcc/testsuite/g++.old-deja/g++.mike/net34.C @@ -1,6 +1,6 @@ // Special g++ Options: -#include <iostream.h> +#include <iostream> class foo { public: @@ -25,10 +25,10 @@ class multiple : public bar_1, public bar_2 { public: multiple(int i1, int i2) : bar_1(i1), bar_2(i2) {} void print() { - cout << "bar_1::k -> " << bar_1::k << "\n"; - cout << "bar_2::k -> " << bar_2::k << "\n"; - cout << "bar_1::get_k() -> " << bar_1::get_k() << "\n"; - cout << "bar_2::get_k() -> " << bar_2::get_k() << "\n"; + std::cout << "bar_1::k -> " << bar_1::k << "\n"; + std::cout << "bar_2::k -> " << bar_2::k << "\n"; + std::cout << "bar_1::get_k() -> " << bar_1::get_k() << "\n"; + std::cout << "bar_2::get_k() -> " << bar_2::get_k() << "\n"; } }; @@ -36,3 +36,5 @@ int main() { multiple m(1,2); m.print(); } + + diff --git a/gcc/testsuite/g++.old-deja/g++.mike/net46.C b/gcc/testsuite/g++.old-deja/g++.mike/net46.C index 9a985450a4a..bacee852c85 100644 --- a/gcc/testsuite/g++.old-deja/g++.mike/net46.C +++ b/gcc/testsuite/g++.old-deja/g++.mike/net46.C @@ -1,6 +1,6 @@ -#include <iostream.h> -#include <stdlib.h> -#include <stddef.h> +#include <iostream> +#include <cstdlib> +#include <cstddef> #include <new> int fail = 1; @@ -14,7 +14,7 @@ void *operator new(size_t size) throw (std::bad_alloc) { } int main() { - cout << ""; + std::cout << ""; in_main = 1; new int; return fail; diff --git a/gcc/testsuite/g++.old-deja/g++.mike/net5.C b/gcc/testsuite/g++.old-deja/g++.mike/net5.C deleted file mode 100644 index 665c0ba8188..00000000000 --- a/gcc/testsuite/g++.old-deja/g++.mike/net5.C +++ /dev/null @@ -1,10 +0,0 @@ -// Build don't link: -// Special g++ Options: - -namespace std { -volatile void abort(); // WARNING - mismatch -} - -volatile void oink() { - std::abort() ; -} // gets bogus error - diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p2846.C b/gcc/testsuite/g++.old-deja/g++.mike/p2846.C index b9a44c43c1e..2849491a0b4 100644 --- a/gcc/testsuite/g++.old-deja/g++.mike/p2846.C +++ b/gcc/testsuite/g++.old-deja/g++.mike/p2846.C @@ -6,6 +6,8 @@ extern "C" void exit(int); class A; class B; +int c; + class A { public: @@ -30,6 +32,7 @@ public: virtual ~B(void){} void print(void) const { + ++c; printf("B::print\n"); } @@ -50,6 +53,14 @@ int main () { A titi; A toto = titi.compute(); - printf("PASS\n"); - return 0; + if (c != 1) + { + printf ("FAIL\n"); + return 1; + } + else + { + printf("PASS\n"); + return 0; + } } diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p5469.C b/gcc/testsuite/g++.old-deja/g++.mike/p5469.C index 9e5250e43de..9af20101171 100644 --- a/gcc/testsuite/g++.old-deja/g++.mike/p5469.C +++ b/gcc/testsuite/g++.old-deja/g++.mike/p5469.C @@ -4,7 +4,7 @@ int count; class A { A(); - A(const A&); // ERROR - referenced below + A(const A&); public: A(int) { ++count; } ~A() { --count; } @@ -14,7 +14,7 @@ public: int main() { { A a (1); - if (a == 2 && a == 1) // ERROR - private copy ctor + if (a == 2 && a == 1) ; } return count; diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p5469a.C b/gcc/testsuite/g++.old-deja/g++.mike/p5469a.C index 9cbd2dfe7a8..0783f77dffe 100644 --- a/gcc/testsuite/g++.old-deja/g++.mike/p5469a.C +++ b/gcc/testsuite/g++.old-deja/g++.mike/p5469a.C @@ -4,7 +4,7 @@ int count; class A { A(); - A(const A&); // ERROR - referenced below + A(const A&); public: A(int) { ++count; } ~A() { --count; } @@ -14,7 +14,7 @@ public: int main() { { A a (1); - if (a == 2 || a == 1) // ERROR - private copy ctor + if (a == 2 || a == 1) ; } return count; diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p658.C b/gcc/testsuite/g++.old-deja/g++.mike/p658.C index 842ae8b78d6..b9137fb8ca2 100644 --- a/gcc/testsuite/g++.old-deja/g++.mike/p658.C +++ b/gcc/testsuite/g++.old-deja/g++.mike/p658.C @@ -1,7 +1,7 @@ // prms-id: 658 -#include <ostream.h> -#include <stdlib.h> +#include <iostream> +#include <cstdlib> /* We may not find the libg++ <bool.h>. */ #ifndef FALSE @@ -65,8 +65,8 @@ void Object::OK() const { if (_destructed) { - cerr << "FAILURE - reference was made to a destructed object\n"; - abort(); + std::cerr << "FAILURE - reference was made to a destructed object\n"; + std::abort(); } } @@ -98,3 +98,5 @@ Char::operator char () const { return _c; } + + diff --git a/gcc/testsuite/g++.old-deja/g++.mike/rtti1.C b/gcc/testsuite/g++.old-deja/g++.mike/rtti1.C index e44c5fafdc5..3403abf0999 100644 --- a/gcc/testsuite/g++.old-deja/g++.mike/rtti1.C +++ b/gcc/testsuite/g++.old-deja/g++.mike/rtti1.C @@ -1,4 +1,4 @@ // Build don't link: #include <typeinfo> -#include <iostream.h> +#include <iostream> diff --git a/gcc/testsuite/g++.old-deja/g++.mike/thunk1.C b/gcc/testsuite/g++.old-deja/g++.mike/thunk1.C index 9780c05bc97..fc5e9b54b47 100644 --- a/gcc/testsuite/g++.old-deja/g++.mike/thunk1.C +++ b/gcc/testsuite/g++.old-deja/g++.mike/thunk1.C @@ -1,5 +1,4 @@ // Build don't link: -// Special g++ Options: -fvtable-thunks struct C1 { diff --git a/gcc/testsuite/g++.old-deja/g++.mike/thunk2.C b/gcc/testsuite/g++.old-deja/g++.mike/thunk2.C index 36b9659fa41..20f1379d393 100644 --- a/gcc/testsuite/g++.old-deja/g++.mike/thunk2.C +++ b/gcc/testsuite/g++.old-deja/g++.mike/thunk2.C @@ -1,5 +1,3 @@ -// Special g++ Options: -fvtable-thunks - #include <typeinfo> int state; @@ -26,7 +24,7 @@ A* bar() { return new A; } -main() { +int main() { A *aptr = bar(); aptr->foo(); if (dynamic_cast <void*> (aptr) != aptr) diff --git a/gcc/testsuite/g++.old-deja/g++.mike/thunk3.C b/gcc/testsuite/g++.old-deja/g++.mike/thunk3.C index 3e97aacd6ba..16a5be85da6 100644 --- a/gcc/testsuite/g++.old-deja/g++.mike/thunk3.C +++ b/gcc/testsuite/g++.old-deja/g++.mike/thunk3.C @@ -1,5 +1,3 @@ -// Special g++ Options: -fvtable-thunks - int state; int fail; @@ -24,7 +22,7 @@ A* bar() { return new A; } -main() { +int main() { A *aptr = bar(); aptr->foo(); if (dynamic_cast <void*> (aptr) != aptr) diff --git a/gcc/testsuite/g++.old-deja/g++.ns/ns14.C b/gcc/testsuite/g++.old-deja/g++.ns/ns14.C index 5a3cc701074..4049139eae9 100644 --- a/gcc/testsuite/g++.old-deja/g++.ns/ns14.C +++ b/gcc/testsuite/g++.old-deja/g++.ns/ns14.C @@ -1,4 +1,4 @@ -//Special g++ Options: -fhonor-std + namespace std{ int f(){ return 0; diff --git a/gcc/testsuite/g++.old-deja/g++.ns/template15.C b/gcc/testsuite/g++.old-deja/g++.ns/template15.C new file mode 100644 index 00000000000..ac781305642 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ns/template15.C @@ -0,0 +1,5 @@ +// Build don't link: +// Origin: Mark Mitchell <mark@codesourcery.com> + +namespace X { template <class T> void f () {} } +template void X::f<int> (); diff --git a/gcc/testsuite/g++.old-deja/g++.ns/template17.C b/gcc/testsuite/g++.old-deja/g++.ns/template17.C new file mode 100644 index 00000000000..11f21c921e1 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ns/template17.C @@ -0,0 +1,37 @@ +// Build don't link: +// +// Copyright (C) 2001 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 29 Apr 2001 <nathan@codesourcery.com> + +// Bug 2258. We failed to implement using directives inside template +// functions. This makes us regress now that ::std is real. + +namespace thing +{ + template <typename T> T end2 (T); +} +namespace whatever +{ +} + +template <typename T> void fn (T, T (*)(T)); + +template <class T> void mycout(const T& data) +{ + using namespace thing; + using namespace whatever; + + fn (data, end2); + fn (data, end3); +} + +namespace whatever +{ + template <typename T> T end3 (T); +} + +int main() +{ + double data = 5.0; + mycout(data); +} diff --git a/gcc/testsuite/g++.old-deja/g++.ns/template18.C b/gcc/testsuite/g++.old-deja/g++.ns/template18.C new file mode 100644 index 00000000000..4b3f720e74b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ns/template18.C @@ -0,0 +1,24 @@ +// Build don't run: +// Origin: Andrey Slepuhin <pooh@msu.ru> + +namespace A +{ + int j; + + template <typename val_t> + struct X + { + inline X () + { + extern int j; + i = j; + } + + int i; + }; +} + +int main () +{ + A::X<int> x; +} diff --git a/gcc/testsuite/g++.old-deja/g++.ns/type2.C b/gcc/testsuite/g++.old-deja/g++.ns/type2.C new file mode 100644 index 00000000000..d8407b151b4 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ns/type2.C @@ -0,0 +1,19 @@ +// Build don't link: +// +// Copyright (C) 2001 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 11 April 2001 <nathan@codesourcery.com> +// Origin:stephen.webb@cybersafe.com + +// Bug 2125. TYPE_DECLS never had their DECL_CONTEXT set, which +// confused forward references to classes. + +typedef void T; +namespace A { + class C; + typedef class C C; + typedef int T; + class C + { + T i; // got bogus error, found wrong T + }; +} diff --git a/gcc/testsuite/g++.old-deja/g++.oliva/ChangeLog b/gcc/testsuite/g++.old-deja/g++.oliva/ChangeLog index 73b0aa47c44..4eb36f99d37 100644 --- a/gcc/testsuite/g++.old-deja/g++.oliva/ChangeLog +++ b/gcc/testsuite/g++.old-deja/g++.oliva/ChangeLog @@ -1,3 +1,39 @@ +2002-02-20 Release Manager + + * GCC 3.0.4 Released. + +2002-02-20 Release Manager + + * GCC 3.0.4 Released. + +2001-12-20 Release Manager + + * GCC 3.0.3 Released. + +2001-10-23 Release Manager + + * GCC 3.0.2 Released. + +2001-08-19 Release Manager + + * GCC 3.0.1 Released. + +2001-08-19 Release Manager + + * GCC 3.0.1 Released. + +20010617 Release Manager + + * GCC 3.0 Released. + +2001-05-14 Mark Mitchell <mark@codesourcery.com> + + * delete3.C: XFAIL it. + +2001-02-15 Alexandre Oliva <aoliva@redhat.com> + + * friend1.C: New test. + 2000-05-28 Alexandre Oliva <aoliva@cygnus.com> * expr2.C: New test. diff --git a/gcc/testsuite/g++.old-deja/g++.oliva/delete1.C b/gcc/testsuite/g++.old-deja/g++.oliva/delete1.C index dee7f219f2e..d8ddefec32e 100644 --- a/gcc/testsuite/g++.old-deja/g++.oliva/delete1.C +++ b/gcc/testsuite/g++.old-deja/g++.oliva/delete1.C @@ -1,6 +1,6 @@ // Build don't link: -// Copyright (C) 1999 Free Software Foundation +// Copyright (C) 1999, 2001 Free Software Foundation // by Alexandre Oliva <oliva@dcc.unicamp.br> // simplified from bug report by K. Haley <khaley@bigfoot.com> @@ -21,7 +21,7 @@ struct bar : foo { delete this; // ERROR - delete is private // An implicit invocation of delete is emitted in destructors, but // it should only be checked in virtual destructors - } // gets bogus error - not virtual - XFAIL *-*-* + } // gets bogus error - not virtual } bar_; struct baz : foo { diff --git a/gcc/testsuite/g++.old-deja/g++.oliva/delete3.C b/gcc/testsuite/g++.old-deja/g++.oliva/delete3.C index 44299f2c9b7..1ea2d585e37 100644 --- a/gcc/testsuite/g++.old-deja/g++.oliva/delete3.C +++ b/gcc/testsuite/g++.old-deja/g++.oliva/delete3.C @@ -1,4 +1,4 @@ -// Copyright (C) 1999 Free Software Foundation +// Copyright (C) 1999, 2001 Free Software Foundation // by Alexandre Oliva <oliva@lsd.ic.unicamp.br> @@ -29,8 +29,9 @@ struct Bar : virtual Foo { }; int main() { - delete [] new Bar[2]; + try { + delete [] new Bar[2]; + } catch (...) { + } abort(); } - - diff --git a/gcc/testsuite/g++.old-deja/g++.oliva/friend1.C b/gcc/testsuite/g++.old-deja/g++.oliva/friend1.C new file mode 100644 index 00000000000..aea98e1136e --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.oliva/friend1.C @@ -0,0 +1,12 @@ +// Build don't link: + +// Copyright (C) 2001 Free Software Foundation + +// by Alexandre Oliva <aoliva@redhat.com> + +// We shouldn't warn about bar referring to a non-template in this case. + +template <typename T> +class foo { + friend int bar(int); +}; diff --git a/gcc/testsuite/g++.old-deja/g++.oliva/thunk1.C b/gcc/testsuite/g++.old-deja/g++.oliva/thunk1.C index 225a1f98103..0aa2178da5d 100644 --- a/gcc/testsuite/g++.old-deja/g++.oliva/thunk1.C +++ b/gcc/testsuite/g++.old-deja/g++.oliva/thunk1.C @@ -3,8 +3,6 @@ // by Alexandre Oliva <oliva@dcc.unicamp.br> // based on bug report by Fredrik Öhrström <d92-foh@nada.kth.se> -// Special g++ Options: -fvtable-thunks - #include <cstdlib> using namespace std; diff --git a/gcc/testsuite/g++.old-deja/g++.other/anon8.C b/gcc/testsuite/g++.old-deja/g++.other/anon8.C new file mode 100644 index 00000000000..54d41b788c6 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/anon8.C @@ -0,0 +1,22 @@ +// Build don't link: + +struct B +{ + int a; + B & operator= (const B &); +}; + +struct A +{ + union { + int a; + }; + B b; +}; + +A x; + +void foo (const A &y) +{ + x = y; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/array4.C b/gcc/testsuite/g++.old-deja/g++.other/array4.C new file mode 100644 index 00000000000..9ac745c0dc4 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/array4.C @@ -0,0 +1,10 @@ +// Build don't link: +// We tried to create a temporary of unknown size and crashed. + +extern int a1[]; +extern int a2[]; +int foo(int p) +{ + int x = (p ? a1 : a2)[1]; + return x; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/array5.C b/gcc/testsuite/g++.old-deja/g++.other/array5.C new file mode 100644 index 00000000000..ab076f2af38 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/array5.C @@ -0,0 +1,20 @@ +// Special g++ Options: -O1 + +int count = 0; + +double foo () { + count++; + return 0; +}; + +double bar () { + const double x[1] = { foo() }; + return x[0]; +}; + +int main () +{ + bar(); + if (count != 1) + return 1; +}; diff --git a/gcc/testsuite/g++.old-deja/g++.other/asm2.C b/gcc/testsuite/g++.old-deja/g++.other/asm2.C new file mode 100644 index 00000000000..d37de69329a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/asm2.C @@ -0,0 +1,11 @@ +// Build don't link: +// Skip if not target: i?86-*-* +// Special g++ Options: -O2 + +typedef unsigned long long uint64; +uint64 fstps(void) +{ + uint64 ret; + asm volatile("fstps %0" : "=m" (ret)); + return ret; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/builtins1.C b/gcc/testsuite/g++.old-deja/g++.other/builtins1.C index b6cea1e201f..4a1630b013d 100644 --- a/gcc/testsuite/g++.old-deja/g++.other/builtins1.C +++ b/gcc/testsuite/g++.old-deja/g++.other/builtins1.C @@ -7,27 +7,14 @@ namespace std { extern "C" void abort (void); - extern "C" __SIZE_TYPE__ strlen (const char *); } int main () { using namespace std; - if (strlen ("hello") != 5) - abort (); - if (std::strlen ("hello") != 5) - abort (); if (::__builtin_strlen ("hello") != 5) abort (); return 0; } - -extern "C" -{ - static __SIZE_TYPE__ ::strlen (const char *) - { - std::abort (); - } -} diff --git a/gcc/testsuite/g++.old-deja/g++.other/builtins2.C b/gcc/testsuite/g++.old-deja/g++.other/builtins2.C index 48e53f14343..9c55b762531 100644 --- a/gcc/testsuite/g++.old-deja/g++.other/builtins2.C +++ b/gcc/testsuite/g++.old-deja/g++.other/builtins2.C @@ -7,8 +7,6 @@ namespace std { extern "C" void abort (void); - extern "C" char *strcpy (char *, const char *); - extern "C" int memcmp (const void *, const void *, __SIZE_TYPE__); } int main () @@ -16,25 +14,9 @@ int main () using namespace std; char f[16]; - if (strcpy (f, "hello world") != f - || memcmp (f, "hello world", sizeof ("hello world"))) - abort (); - - if (std::strcpy (f, "bye world") != f - || memcmp (f, "bye world", sizeof ("bye world"))) - abort (); - if (::__builtin_strcpy (f, "hello world") != f - || memcmp (f, "hello world", sizeof ("hello world"))) + || __builtin_memcmp (f, "hello world", sizeof ("hello world"))) abort (); return 0; } - -extern "C" -{ - static char * ::strcpy (char *, const char *) - { - std::abort (); - } -} diff --git a/gcc/testsuite/g++.old-deja/g++.other/builtins3.C b/gcc/testsuite/g++.old-deja/g++.other/builtins3.C index 4a67b28e969..e075d3fdba3 100644 --- a/gcc/testsuite/g++.old-deja/g++.other/builtins3.C +++ b/gcc/testsuite/g++.old-deja/g++.other/builtins3.C @@ -7,7 +7,6 @@ namespace std { extern "C" void abort (void); - extern "C" void *alloca (__SIZE_TYPE__); } int main () @@ -15,14 +14,6 @@ int main () using namespace std; void *foo; - foo = alloca (32); - if (!foo) - abort (); - - foo = std::alloca (32); - if (!foo) - abort (); - foo = ::__builtin_alloca (32); if (!foo) abort (); @@ -30,10 +21,3 @@ int main () return 0; } -extern "C" -{ - static void * ::alloca (__SIZE_TYPE__) - { - std::abort (); - } -} diff --git a/gcc/testsuite/g++.old-deja/g++.other/builtins4.C b/gcc/testsuite/g++.old-deja/g++.other/builtins4.C index 7118910a27f..235bb135752 100644 --- a/gcc/testsuite/g++.old-deja/g++.other/builtins4.C +++ b/gcc/testsuite/g++.old-deja/g++.other/builtins4.C @@ -7,21 +7,12 @@ namespace std { extern "C" void abort (void); - extern "C" int printf (const char *, ...); } int main () { using namespace std; - printf ("hello world\n"); - printf ("\n"); - printf ("%s\n", "hello world"); - printf ("%c", '\n'); - std::printf ("hello world\n"); - std::printf ("\n"); - std::printf ("%s\n", "hello world"); - std::printf ("%c", '\n'); ::__builtin_printf ("hello world\n"); ::__builtin_printf ("\n"); ::__builtin_printf ("%s\n", "hello world"); @@ -30,10 +21,3 @@ int main () return 0; } -extern "C" -{ - static int ::printf (const char *, ...) - { - std::abort (); - } -} diff --git a/gcc/testsuite/g++.old-deja/g++.other/call1.C b/gcc/testsuite/g++.old-deja/g++.other/call1.C index 7341488d949..1cf6d9708ff 100644 --- a/gcc/testsuite/g++.old-deja/g++.other/call1.C +++ b/gcc/testsuite/g++.old-deja/g++.other/call1.C @@ -23,7 +23,7 @@ struct B { }; struct C { - const fptr ≺ + const fptr pr; C (fptr n): pr(n) { } operator const fptr& () { return pr; } diff --git a/gcc/testsuite/g++.old-deja/g++.other/cond7.C b/gcc/testsuite/g++.old-deja/g++.other/cond7.C new file mode 100644 index 00000000000..49fa73ca1f8 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/cond7.C @@ -0,0 +1,26 @@ +// Build don't link: +// +// Copyright (C) 2001 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 24 Jul 2001 <nathan@codesourcery.com> + +// Bug 3416. We left some unchecked overloaded functions lying around. + +struct X +{ + void operator << (int); + void operator << (float); +}; + +void OVL1 (int); +void OVL1 (float); + +void OVL2 (int); +void OVL2 (float); + +X x; + +void foo (bool a) +{ + x << (a ? OVL1 : OVL2); // ERROR - incomplete type + a ? OVL1 : OVL2; // ERROR - incomplete type +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/conv7.C b/gcc/testsuite/g++.old-deja/g++.other/conv7.C new file mode 100644 index 00000000000..0a7e76dfe3f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/conv7.C @@ -0,0 +1,45 @@ +// Build don't link: +// +// Copyright (C) 2001 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 5 May 2001 <nathan@codesourcery.com> + +// Bug 2726. We ICE'd trying to say something about possibly confusing +// conversion overload resolution. + +class foo +{ +}; + +template<class T> +class bar +{ +public: + operator const T&() const ; + operator T&() ; + +}; + + +template<class T, class Ref, class NodePtr, class ListPtr> +class iterator_template +{ +public: + iterator_template(); + Ref operator*() const; + +}; + +struct IdlDeclarator +{ +}; + +typedef bar< IdlDeclarator > IdlDeclarator_bar; +int +yyparse() + +{ + + iterator_template<IdlDeclarator_bar,IdlDeclarator_bar&,foo*,foo*> declIter; + const IdlDeclarator& declarator = *declIter; // WARNING - choosing + return 1; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/copy3.C b/gcc/testsuite/g++.old-deja/g++.other/copy3.C new file mode 100644 index 00000000000..aa2c9058f8f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/copy3.C @@ -0,0 +1,23 @@ +// Build don't run: +// Origin: ericp@mit.edu + +class bar { +}; + +class foo { + foo (const foo &f); + +public: + + foo (bar x) {} + foo () {} + + void test (const foo &f) {} +}; + +int main (void) { + foo f; + bar b; + + f.test (b); +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/crash14.C b/gcc/testsuite/g++.old-deja/g++.other/crash14.C index 85f093d7cc3..f249a67106a 100644 --- a/gcc/testsuite/g++.old-deja/g++.other/crash14.C +++ b/gcc/testsuite/g++.old-deja/g++.other/crash14.C @@ -1,5 +1,4 @@ // Build don't link: -// Special g++ Options: -fnew-abi // Origin: Mark Mitchell <mark@codesourcery.com> struct S diff --git a/gcc/testsuite/g++.old-deja/g++.other/crash18.C b/gcc/testsuite/g++.old-deja/g++.other/crash18.C index ce0f64621c9..2fa185f56f1 100644 --- a/gcc/testsuite/g++.old-deja/g++.other/crash18.C +++ b/gcc/testsuite/g++.old-deja/g++.other/crash18.C @@ -1,7 +1,7 @@ // Build don't link: // Special g++ Options: -fvtable-gc // Origin: Mark Mitchell <mitchell@codesourcery.com> -// excess errors test - XFAIL *-*-coff *-*-aout *-*-hms mips*-sgi-irix* +// excess errors test - XFAIL *-*-* struct S { virtual void f (); diff --git a/gcc/testsuite/g++.old-deja/g++.other/crash27.C b/gcc/testsuite/g++.old-deja/g++.other/crash27.C index 6654bdfb00d..dfbacc80387 100644 --- a/gcc/testsuite/g++.old-deja/g++.other/crash27.C +++ b/gcc/testsuite/g++.old-deja/g++.other/crash27.C @@ -1,8 +1,6 @@ // Build don't link: // Origin: Jakub Jelinek <jakub@redhat.com> -// excess errors test - XFAIL *-*-* - X(Y(long, Type, CLink)); break; default: break; } } } // ERROR - struct A { diff --git a/gcc/testsuite/g++.old-deja/g++.other/crash31.C b/gcc/testsuite/g++.old-deja/g++.other/crash31.C index 32912a0e7cb..9d5cc43178e 100644 --- a/gcc/testsuite/g++.old-deja/g++.other/crash31.C +++ b/gcc/testsuite/g++.old-deja/g++.other/crash31.C @@ -2,10 +2,11 @@ // Origin: Jakub Jelinek <jakub@redhat.com> // crash test - XFAIL *-*-* +// excess errors test - XFAIL *-*-* namespace bar { struct foo { foo(); -}; // ERROR - parse error +}; // ERROR - parse error XFAIL *-*-* diff --git a/gcc/testsuite/g++.old-deja/g++.other/crash40.C b/gcc/testsuite/g++.old-deja/g++.other/crash40.C new file mode 100644 index 00000000000..3af3f731a66 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/crash40.C @@ -0,0 +1,19 @@ +// Build don't link: +// Copyright (C) 2001 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 11 April 2001 <nathan@codesourcery.com> +// Origin: Theo Papadopoulo <Theodore.Papadopoulo@sophia.inria.fr> + +// Bug 1917. We were considering thunks to clones to be clones. and +// hence getting confused. + +struct A { virtual ~A(); }; +struct B { virtual ~B(); }; + +struct C: public A,B {}; + +template <class TYPE> +inline TYPE +sqr(const TYPE& x) { + return 1; +} +int f(const int t) { return sqr(t); } diff --git a/gcc/testsuite/g++.old-deja/g++.other/crash41.C b/gcc/testsuite/g++.old-deja/g++.other/crash41.C new file mode 100644 index 00000000000..70434507f8c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/crash41.C @@ -0,0 +1,13 @@ +// Build don't link: +// +// Copyright (C) 2001 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 8 May 2001 <nathan@codesourcery.com> + +// Bug 2744. We ICE'd on strange characters + +@ // ERROR - parse error +int a; #// ERROR - parse error +## // ERROR - parse error +$ // ERROR - parse error +£ // ERROR - parse error +` // ERROR - parse error diff --git a/gcc/testsuite/g++.old-deja/g++.other/crash42.C b/gcc/testsuite/g++.old-deja/g++.other/crash42.C new file mode 100644 index 00000000000..be316ac6645 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/crash42.C @@ -0,0 +1,17 @@ +// Build don't link: +// Special g++ Options: -g +// +// Copyright (C) 2001 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 25 Jul 2001 <nathan@codesourcery.com> + +// Bug 3152. Using a typedef to declare a function used an unset +// global variable, last_function_parms. + +struct actor +{ + typedef bool (operation)(); + + operation a; + operation b; + operation c; +}; diff --git a/gcc/testsuite/g++.old-deja/g++.other/debug7.C b/gcc/testsuite/g++.old-deja/g++.other/debug7.C new file mode 100644 index 00000000000..f79b00a9cc7 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/debug7.C @@ -0,0 +1,11 @@ +// Build don't run: +// Origin: Loren James Rittle <rittle@latour.rsch.comm.mot.com> +// Special g++ Options: -g -O2 + +namespace std { + const int __stl_chunk_size = 7; +}; + +int main () +{ +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/debug8.C b/gcc/testsuite/g++.old-deja/g++.other/debug8.C new file mode 100644 index 00000000000..2b78be2911f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/debug8.C @@ -0,0 +1,21 @@ +// Build don't link: +// Special g++ Options: -g + +struct X { + const int x[4]; +}; + +struct A { + A(); + A(const A&); +}; + +struct B { + A a; + int b[4]; +}; + +struct C { + A a; + C() { B b=B(); }; +}; diff --git a/gcc/testsuite/g++.old-deja/g++.other/decl9.C b/gcc/testsuite/g++.old-deja/g++.other/decl9.C new file mode 100644 index 00000000000..5ec9a6e4ece --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/decl9.C @@ -0,0 +1,9 @@ +// Build don't link +// Origin: batali@cogsci.ucsd.edu +// Contributed by Gabriel Dos Reis <gdr@codesourcery.com> + +typedef struct { } S; // OK +typedef struct { }; // ERROR - Missing type-name + +typedef union { } U; // OK +typedef union { }; // ERROR - Missing type-name diff --git a/gcc/testsuite/g++.old-deja/g++.other/defarg9.C b/gcc/testsuite/g++.old-deja/g++.other/defarg9.C new file mode 100644 index 00000000000..f3b0a48c361 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/defarg9.C @@ -0,0 +1,52 @@ +// Build don't link: +// +// Copyright (C) 2001 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 24 April 2001 <nathan@codesourcery.com> + +// Bug 2608. A default parameter introduced in the definition of a +// ctor never made it into the clones, leading to later overload +// resolution failures. This is related to bug 2356. + +struct A +{ + A (int, int); +}; + +A::A (int d, int = 0) +{ + if (d) + { + A a (0); + } +} + +void get_width () +{ + A a (1); +} + +struct B : A +{ + B (); +}; +B::B () + :A (1) +{ +} + +struct C : virtual A +{ + C (int, int); +}; +C::C (int, int = 0) + :A (1) +{ +} +struct D: C +{ + D (); +}; +D::D () + :A (0), C (0) +{ +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/delete8.C b/gcc/testsuite/g++.old-deja/g++.other/delete8.C new file mode 100644 index 00000000000..1f884b70b53 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/delete8.C @@ -0,0 +1,39 @@ +// Origin: Mark Mitchell <mark@codesourcery.com> + +#include <stdlib.h> + +struct S { + ~S (); +}; + +bool flag; +S* s1; +S* s2; + +void* operator new (size_t s) +{ + return malloc (s); +} + +void operator delete (void* p) +{ + if (flag && p != s2) + abort (); +} + +S::~S () { + if (this != s2) + abort (); + s1 = 0; +} + +int main () { + s2 = new S; + s1 = s2; + // Turn on the check in `operator delete'. + flag = true; + delete s1; + // Turn it off again so that normal shutdown code works. + flag = false; +} + diff --git a/gcc/testsuite/g++.old-deja/g++.other/eh4.C b/gcc/testsuite/g++.old-deja/g++.other/eh4.C new file mode 100644 index 00000000000..e88a4337db4 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/eh4.C @@ -0,0 +1,12 @@ +// Origin: Jean-Marc Bourguet <bourguet@cadence.com> +// Build don't link: + +class foo { +public: + foo() {}; + void throwMe () { + throw *this; // ERROR - cannot be used in throw-expression + }; + virtual void test () = 0; +}; + diff --git a/gcc/testsuite/g++.old-deja/g++.other/empty1.C b/gcc/testsuite/g++.old-deja/g++.other/empty1.C index 1210327ee17..a876ce84a9f 100644 --- a/gcc/testsuite/g++.old-deja/g++.other/empty1.C +++ b/gcc/testsuite/g++.old-deja/g++.other/empty1.C @@ -1,4 +1,10 @@ // Origin: Mark Mitchell <mark@codesourcery.com> +// This test case checks that the return value optimization works for +// empty classes. + +// xfailed because empty classes clobbering what they overlay as the +// backend treats them as single byte objects. See bug 4222 +// execution test - XFAIL *-*-* extern "C" void abort(); extern "C" int printf (const char *, ...); diff --git a/gcc/testsuite/g++.old-deja/g++.other/empty2.C b/gcc/testsuite/g++.old-deja/g++.other/empty2.C new file mode 100644 index 00000000000..92585b8b03f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/empty2.C @@ -0,0 +1,10 @@ +// Build don't link: +// Origin: Mark Mitchell <mark@codesourcery.com> + +struct E {}; + +void f () { + E e1, e2; + e1 = e2; // We should not warn about this statement, even though no + // code is generated for it. +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/empty3.C b/gcc/testsuite/g++.old-deja/g++.other/empty3.C new file mode 100644 index 00000000000..e6523e7c690 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/empty3.C @@ -0,0 +1,28 @@ +// Copyright (C) 2001 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 3 Sept 2001 <nathan@codesourcery.com> + +// Bug 4203. We were bit copying empty bases including the +// padding. Which clobbers whatever they overlay. + +class EmptyBase0 {}; +class EmptyBase1 : public EmptyBase0 {}; +class Base1 +{ +public: +unsigned int t_; +Base1(unsigned int t) : t_(t) {} +}; + +class PEPE : public Base1, public EmptyBase1 +{ +public: +PEPE(unsigned int t) + : Base1(t), EmptyBase1(EmptyBase1()) {} +}; + +int main() +{ + PEPE pepe(0xff); + + return pepe.t_ != 255; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/enum3.C b/gcc/testsuite/g++.old-deja/g++.other/enum3.C new file mode 100644 index 00000000000..f401613df3a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/enum3.C @@ -0,0 +1,13 @@ +// Origin: Mark Mitchell <mark@codesourcery.com> +// Special g++ Options: -fshort-enums + +enum E { + a = -312 +}; + +E e = a; + +int main () { + if ((int) e != -312) + return 1; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/externC5.C b/gcc/testsuite/g++.old-deja/g++.other/externC5.C new file mode 100644 index 00000000000..aadbc5a46fe --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/externC5.C @@ -0,0 +1,19 @@ +// Build don't link: +// Origin: schmid@snake.iap.physik.tu-darmstadt.de + +extern "C" int rand (void) throw (); + +namespace std +{ +extern "C" int rand(void) throw(); +template <class T> void f(T a) {} +} + +using namespace std; + +int main() +{ + f(rand); + f(std::rand); + f(::rand); +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/fnname1.C b/gcc/testsuite/g++.old-deja/g++.other/fnname1.C new file mode 100644 index 00000000000..8fcf07f08ef --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/fnname1.C @@ -0,0 +1,8 @@ +// Build don't run: +// Origin: Loren James Rittle <rittle@latour.rsch.comm.mot.com> +// Special g++ Options: -g + +int main () +{ + const char *s = __FUNCTION__; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/friend11.C b/gcc/testsuite/g++.old-deja/g++.other/friend11.C new file mode 100644 index 00000000000..b9804c4e617 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/friend11.C @@ -0,0 +1,12 @@ +// Build don't link: +// Origin: robt@flyingpig.com + +class Outer +{ + friend void f1(); + class Inner2; +}; + +class Outer::Inner2 +{ +}; diff --git a/gcc/testsuite/g++.old-deja/g++.other/init16.C b/gcc/testsuite/g++.old-deja/g++.other/init16.C index 8d7c1af3b10..83d5a4eb5c5 100644 --- a/gcc/testsuite/g++.old-deja/g++.other/init16.C +++ b/gcc/testsuite/g++.old-deja/g++.other/init16.C @@ -1,11 +1,28 @@ -// Build don't link: // Origin: Jakub Jelinek <jakub@redhat.com> -// excess errors test - XFAIL *-*-* - -#include <string> +struct bar { + char c; + bar (const char *); + bar (const bar &); +}; struct foo { - string x; + bar x; }; + extern const struct foo y = { "foo" }; + +bar::bar (const bar &ref) +{ + c = ref.c; +} + +bar::bar (const char *p) +{ + c = p[2]; +} + +int main () +{ + return y.x.c != 'o'; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/inline19.C b/gcc/testsuite/g++.old-deja/g++.other/inline19.C index 8770eb326d5..c27aa5305be 100644 --- a/gcc/testsuite/g++.old-deja/g++.other/inline19.C +++ b/gcc/testsuite/g++.old-deja/g++.other/inline19.C @@ -2,7 +2,7 @@ // Origin: Scott Snyder <snyder@fnal.gov> via PR 1733. // Special g++ Options: -O1 // -// crash test - XFAIL *-*-* +// crash test struct TBtItem { diff --git a/gcc/testsuite/g++.old-deja/g++.other/inline20.C b/gcc/testsuite/g++.old-deja/g++.other/inline20.C new file mode 100644 index 00000000000..a4af375f164 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/inline20.C @@ -0,0 +1,58 @@ +// Build don't link: + +struct A { + int a, b, c, d; +}; + +inline void foo (int, A &); + +struct D { +}; + +struct E: public D { + void f (A &y) + { + foo (1, y); + } +}; + +struct F: public D { + void f (A &y) + { + foo (2, y); + } +}; + +E *d; +F *e; + +inline int baz (int y) +{ + A a; + if (y) { + d->f (a); + } else { + e->f (a); + } + return 0; +} + +inline void foo (int y, A &z) +{ + z.a = baz (y); + z.b = baz (y); + z.c = baz (y); + z.d = baz (y); +} + +struct G { + E a; + F b; + void bar (A &); +}; + +void G::bar(A &y) +{ + a.f(y); + b.f(y); +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/inline21.C b/gcc/testsuite/g++.old-deja/g++.other/inline21.C new file mode 100644 index 00000000000..1f3dd0eaa5c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/inline21.C @@ -0,0 +1,39 @@ +// Special g++ Options: -O2 +// Origin: suckfish@ihug.co.nz + +// DECLARATIONS + +struct Record { + Record (int bb) : + b (bb) + { } + int extra; // Having an extra member in record is crucial. + int b; +}; + +struct Container { + Record record; + // The const on the next line is crucial. + Container ( const Record b) : record(b) {} +}; + + +// TEST FOR CORRECT BEHAVIOUR + +int myArray[3]; +int * intp = myArray; + +void use_pair (const Container & c) +{ + *intp++ = c.record.b; +} + +extern "C" int printf (const char *,...); + +int main() +{ + use_pair (Container (1234)); + + if (myArray[0] != 1234) + return 1; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/inline8.C b/gcc/testsuite/g++.old-deja/g++.other/inline8.C index a5b540bcf72..17965d9a90b 100644 --- a/gcc/testsuite/g++.old-deja/g++.other/inline8.C +++ b/gcc/testsuite/g++.old-deja/g++.other/inline8.C @@ -23,23 +23,23 @@ public: NAMES_ITEM::NAMES_ITEM (const NAMES_ITEM& item2) { - size_t length=strlen(item2.name); + size_t length=std::strlen(item2.name); name=new char[length+1]; - memcpy(name,item2.name,length+1); + std::memcpy(name,item2.name,length+1); } NAMES_ITEM::NAMES_ITEM (const char* name2) { - size_t length=strlen(name2); + size_t length=std::strlen(name2); name=new char[length+1]; - memcpy(name,name2,length+1); + std::memcpy(name,name2,length+1); } NAMES_ITEM::~NAMES_ITEM () { - if (strcmp (name, "one") != 0) + if (std::strcmp (name, "one") != 0) abort (); name=0; @@ -47,12 +47,12 @@ NAMES_ITEM::~NAMES_ITEM () bool NAMES_ITEM::operator==(const NAMES_ITEM& n) const { - return (strcmp(name,n.name) == 0); + return (std::strcmp(name,n.name) == 0); } bool operator<(const NAMES_ITEM& n1, const NAMES_ITEM& n2) { - return (strcmp(n1.name,n2.name) < 0); + return (std::strcmp(n1.name,n2.name) < 0); } typedef map<NAMES_ITEM,size_t,less<NAMES_ITEM> > lookup_t; diff --git a/gcc/testsuite/g++.old-deja/g++.other/lex1.C b/gcc/testsuite/g++.old-deja/g++.other/lex1.C new file mode 100644 index 00000000000..b639f05c39a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/lex1.C @@ -0,0 +1,12 @@ +// Build don't link: +// +// Copyright (C) 2001 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 26 April 2001 <nathan@codesourcery.com> + +// Bug 2510. We ICEd when a bogus char was present. + +void foo () +{ + // there is a ctrl-h on the next line + // ERROR - stray char +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/lineno5.C b/gcc/testsuite/g++.old-deja/g++.other/lineno5.C new file mode 100644 index 00000000000..dc779ed894a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/lineno5.C @@ -0,0 +1,19 @@ +// Build don't link: +// +// Copyright (C) 2001 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 25 Jul 2001 <nathan@codesourcery.com> + +// Origin: johanb@DoCS.UU.SE +// Bug 3621. At the end of saved input, we'd set the lineno to +// zero. This would confusing things no end, if there was a subsequent +// error. + +namespace tmp { + typedef int B; + B b; +} + +class A { + public: + int kaka(tmp::B = b); // ERROR - no b in scope +}; diff --git a/gcc/testsuite/g++.old-deja/g++.other/linkage7.C b/gcc/testsuite/g++.old-deja/g++.other/linkage7.C new file mode 100644 index 00000000000..b168e013db1 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/linkage7.C @@ -0,0 +1,14 @@ +// Build don't run: +// Origin: Mark Mitchell <mark@codesourcery.com> + +namespace N { + extern "C" int i; + + void f () { + i = 3; + } +}; + +int i; + +int main () { N::f (); } diff --git a/gcc/testsuite/g++.old-deja/g++.other/lookup22.C b/gcc/testsuite/g++.old-deja/g++.other/lookup22.C new file mode 100644 index 00000000000..c62ce50e129 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/lookup22.C @@ -0,0 +1,13 @@ +// Origin: GerhardTonn@gmx.de +// Build don't link: + +struct super { + union { + int myName; + void* secondMember; + }; +}; + +struct sub : super { + int myName() { return 1; } +}; diff --git a/gcc/testsuite/g++.old-deja/g++.other/lookup23.C b/gcc/testsuite/g++.old-deja/g++.other/lookup23.C new file mode 100644 index 00000000000..9deee9eda45 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/lookup23.C @@ -0,0 +1,13 @@ +// Test for proper handling of type lookup if base class has field with the +// same name as the containing class. +// Build don't link: + +struct a { int a; }; +struct b : a {}; + +b x; + +void foo () +{ + x.a = 22; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/mangle1.C b/gcc/testsuite/g++.old-deja/g++.other/mangle1.C deleted file mode 100644 index 21e7b32d9a0..00000000000 --- a/gcc/testsuite/g++.old-deja/g++.other/mangle1.C +++ /dev/null @@ -1,58 +0,0 @@ -// Test for proper mangling by setting up name clashes. -// Special g++ Options: -fno-squangle - -#if (!defined (__GXX_ABI_VERSION) || __GXX_ABI_VERSION < 100) -#define NAME(OLD, NEW) OLD -#else -#define NAME(OLD, NEW) NEW -#endif /* (!defined (__GXX_ABI_VERSION) || __GXX_ABI_VERSION < 100) */ - -class A { }; -typedef A A2; -typedef int I; -typedef void V; -typedef I I2; - -void f (const A2&, int, const A2&, const A&) { } // ERROR - name clash -int NAME (f__FRC1AiT0T0, _Z1fRK1AiS1_S1_) = 0; // ERROR - name clash - -void f (int, long, int, I) { } // ERROR - name clash -int NAME (f__Filii, _Z1filii) = 0; // ERROR - name clash - -void f (I, float, I, I2) { } // ERROR - name clash -int NAME (f__Fifii, _Z1fifii) = 0; // ERROR - name clash - -void f (void*, float, void*, V*) { } // ERROR - name clash -int NAME (f__FPvfT0T0, _Z1fPvfS_S_) = 0; // ERROR - name clash - -void f (wchar_t) { } // ERROR - name clash -int NAME (f__Fw, _Z1fw) = 0; // ERROR - name clash - -void f(int, A, A2, A) { } // ERROR - name clash -int NAME (f__FiG1AN21, _Z1fi1AS_S_) = 0; // ERROR - name clash - -void f(const A2&, const A2&, const A2&, const A2&, - int&) { } // ERROR - name clash -int NAME (f__FRC1AN30Ri, _Z1fRK1AS1_S1_S1_Ri) = 0; // ERROR - name clash - -void f(const A2&, int, const A2&, const A2&, const A2&, - int&) { } // ERROR - name clash -int NAME (f__FRC1AiT0N20Ri, _Z1fRK1AiS1_S1_S1_Ri) = 0; // ERROR - name clash - -void f(const A2&, int, const A2&, const A2&, const A2&, int&, int&, - int&) { } // ERROR - name clash -int NAME (f__FRC1AiT0N20RiN25, _Z1fRK1AiS1_S1_S1_RiS2_S2_) = 0; // ERROR - name clash - -void f(const A2&, int, const A2&, const A2&, const A2&, int, int, - int) { } // ERROR - name clash -int NAME (f__FRC1AiT0N20iii, _Z1fRK1AiS1_S1_S1_iii) = 0; // ERROR - name clash - -void f(bool, bool) {} // ERROR - name clash -int NAME (f__FbT0, _Z1fbb) = 0; // ERROR - name clash - -int -main () -{ - return 0; -} - diff --git a/gcc/testsuite/g++.old-deja/g++.other/mangle3.C b/gcc/testsuite/g++.old-deja/g++.other/mangle3.C new file mode 100644 index 00000000000..d77a4b548de --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/mangle3.C @@ -0,0 +1,41 @@ +struct foo { + static int bar () + { + int i; + static int baz = 1; + { + static int baz = 2; + i = baz++; + } + { + struct baz { + static int m () + { + static int n; + return n += 10; + } + }; + baz a; + i += a.m (); + } + { + static int baz = 3; + i += baz; + baz += 30; + } + i += baz; + baz += 60; + return i; + } +}; + +int main () +{ + foo x; + + if (x.bar () != 16) + return 1; + if (x.bar() != 117) + return 1; + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/new7.C b/gcc/testsuite/g++.old-deja/g++.other/new7.C new file mode 100644 index 00000000000..35ec0bbac88 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/new7.C @@ -0,0 +1,39 @@ +// Origin: philip_martin@ntlworld.com + +#include <new> + +extern "C" void abort(); + +bool new_flag = false; +bool delete_flag = false; + +struct X { + X() + { + throw 1; + } + void* operator new ( std::size_t n ) throw ( std::bad_alloc ) + { + new_flag = true; + return ::operator new( n ); + } + void operator delete( void* p, std::size_t n ) throw() + { + delete_flag = true; + ::operator delete( p ); + } +}; + +int +main() +{ + try + { + X* x = new X; // gcc 3.0 fails to call operator delete when X::X throws + } + catch ( ... ) + { + } + if ( ! new_flag || ! delete_flag ) + ::abort(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/op2.C b/gcc/testsuite/g++.old-deja/g++.other/op2.C index 70af6ac34a0..4e5528f9583 100644 --- a/gcc/testsuite/g++.old-deja/g++.other/op2.C +++ b/gcc/testsuite/g++.old-deja/g++.other/op2.C @@ -1,4 +1,4 @@ -// Copyright (C) 2000 Free Software Foundation, Inc. +// Copyright (C) 2000, 2001 Free Software Foundation, Inc. // Contributed by Nathan Sidwell 28 Nov 2000 <nathan@codesourcery.com> // Bug 91. We'd not preserve constness looking for a base classes assignment @@ -6,23 +6,23 @@ #include <stdio.h> -int glob = 0; +int value = 0; struct A { A() {} A( A& arg) - { printf ("%s\n", __PRETTY_FUNCTION__); glob = 1;} + { printf ("%s\n", __PRETTY_FUNCTION__); value = 1;} A( const A& arg) - { printf ("%s\n", __PRETTY_FUNCTION__); glob = 2;} + { printf ("%s\n", __PRETTY_FUNCTION__); value = 2;} A& operator=( A& ) - { printf ("%s\n", __PRETTY_FUNCTION__); glob = 3; return *this; } + { printf ("%s\n", __PRETTY_FUNCTION__); value = 3; return *this; } A& operator=( const A& ) - { printf ("%s\n", __PRETTY_FUNCTION__); glob = 4; return *this; } + { printf ("%s\n", __PRETTY_FUNCTION__); value = 4; return *this; } }; struct B : A @@ -32,32 +32,32 @@ struct B : A void foo( A& ) { - printf ("%s\n", __PRETTY_FUNCTION__); glob = 5; + printf ("%s\n", __PRETTY_FUNCTION__); value = 5; } void foo( const A& ) { - printf ("%s\n", __PRETTY_FUNCTION__); glob = 6; + printf ("%s\n", __PRETTY_FUNCTION__); value = 6; } int main() { const A a0; - glob = 0; printf ("A(cA) : "); A a1(a0); if (glob != 2) return 1; - glob = 0; printf ("A(A ) : "); A a2(a1); if (glob != 1) return 2; + value = 0; printf ("A(cA) : "); A a1(a0); if (value != 2) return 1; + value = 0; printf ("A(A ) : "); A a2(a1); if (value != 1) return 2; const B b0; - glob = 0; printf ("B(cB) : "); B b1(b0); if (glob != 2) return 3; - glob = 0; printf ("B(B ) : "); B b2(b1); if (glob != 2) return 4; + value = 0; printf ("B(cB) : "); B b1(b0); if (value != 2) return 3; + value = 0; printf ("B(B ) : "); B b2(b1); if (value != 2) return 4; - glob = 0; printf ("A= cA : "); a1 = a0; if (glob != 4) return 5; - glob = 0; printf ("A= A : "); a1 = a2; if (glob != 3) return 6; - glob = 0; printf ("B= cB : "); b1 = b0; if (glob != 4) return 7; - glob = 0; printf ("B= B : "); b1 = b2; if (glob != 4) return 8; + value = 0; printf ("A= cA : "); a1 = a0; if (value != 4) return 5; + value = 0; printf ("A= A : "); a1 = a2; if (value != 3) return 6; + value = 0; printf ("B= cB : "); b1 = b0; if (value != 4) return 7; + value = 0; printf ("B= B : "); b1 = b2; if (value != 4) return 8; - glob = 0; printf ("foo(cB): "); foo(b0); if (glob != 6) return 9; - glob = 0; printf ("foo(B ): "); foo(b2); if (glob != 5) return 10; + value = 0; printf ("foo(cB): "); foo(b0); if (value != 6) return 9; + value = 0; printf ("foo(B ): "); foo(b2); if (value != 5) return 10; return 0; } diff --git a/gcc/testsuite/g++.old-deja/g++.other/op3.C b/gcc/testsuite/g++.old-deja/g++.other/op3.C index 957b4d32fd3..08833c49104 100644 --- a/gcc/testsuite/g++.old-deja/g++.other/op3.C +++ b/gcc/testsuite/g++.old-deja/g++.other/op3.C @@ -1,4 +1,4 @@ -// Copyright (C) 2000 Free Software Foundation, Inc. +// Copyright (C) 2000, 2001 Free Software Foundation, Inc. // Contributed by Nathan Sidwell 28 Nov 2000 <nathan@codesourcery.com> // Related to bug 91. We'd not preserve constness accessing a member of the @@ -6,23 +6,23 @@ #include <stdio.h> -int glob = 0; +int value = 0; struct A { A() {} A( A& arg) - { printf ("%s\n", __PRETTY_FUNCTION__); glob = 1;} + { printf ("%s\n", __PRETTY_FUNCTION__); value = 1;} A( const A& arg) - { printf ("%s\n", __PRETTY_FUNCTION__); glob = 2;} + { printf ("%s\n", __PRETTY_FUNCTION__); value = 2;} A& operator=( A& ) - { printf ("%s\n", __PRETTY_FUNCTION__); glob = 3; return *this; } + { printf ("%s\n", __PRETTY_FUNCTION__); value = 3; return *this; } A& operator=( const A& ) - { printf ("%s\n", __PRETTY_FUNCTION__); glob = 4; return *this; } + { printf ("%s\n", __PRETTY_FUNCTION__); value = 4; return *this; } }; struct B @@ -33,31 +33,31 @@ struct B void foo( A& ) { - printf ("%s\n", __PRETTY_FUNCTION__); glob = 5; + printf ("%s\n", __PRETTY_FUNCTION__); value = 5; } void foo( const A& ) { - printf ("%s\n", __PRETTY_FUNCTION__); glob = 6; + printf ("%s\n", __PRETTY_FUNCTION__); value = 6; } int main() { const A a0; - glob = 0; printf ("A(cA) : "); A a1(a0); if (glob != 2) return 1; - glob = 0; printf ("A(A ) : "); A a2(a1); if (glob != 1) return 2; + value = 0; printf ("A(cA) : "); A a1(a0); if (value != 2) return 1; + value = 0; printf ("A(A ) : "); A a2(a1); if (value != 1) return 2; const B b0; - glob = 0; printf ("B(cB) : "); B b1(b0); if (glob != 2) return 3; - glob = 0; printf ("B(B ) : "); B b2(b1); if (glob != 2) return 4; + value = 0; printf ("B(cB) : "); B b1(b0); if (value != 2) return 3; + value = 0; printf ("B(B ) : "); B b2(b1); if (value != 2) return 4; - glob = 0; printf ("A= cA : "); a1 = a0; if (glob != 4) return 5; - glob = 0; printf ("A= A : "); a1 = a2; if (glob != 3) return 6; - glob = 0; printf ("B= cB : "); b1 = b0; if (glob != 4) return 7; - glob = 0; printf ("B= B : "); b1 = b2; if (glob != 4) return 8; + value = 0; printf ("A= cA : "); a1 = a0; if (value != 4) return 5; + value = 0; printf ("A= A : "); a1 = a2; if (value != 3) return 6; + value = 0; printf ("B= cB : "); b1 = b0; if (value != 4) return 7; + value = 0; printf ("B= B : "); b1 = b2; if (value != 4) return 8; - glob = 0; printf ("foo(cB): "); foo(b0.a); if (glob != 6) return 9; - glob = 0; printf ("foo(B ): "); foo(b2.a); if (glob != 5) return 10; + value = 0; printf ("foo(cB): "); foo(b0.a); if (value != 6) return 9; + value = 0; printf ("foo(B ): "); foo(b2.a); if (value != 5) return 10; return 0; } diff --git a/gcc/testsuite/g++.old-deja/g++.other/optimize1.C b/gcc/testsuite/g++.old-deja/g++.other/optimize1.C new file mode 100644 index 00000000000..bff78dc3eab --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/optimize1.C @@ -0,0 +1,70 @@ +// Special g++ Options: -O2 +// +// Copyright (C) 2001 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 18 May 2001 <nathan@codesourcery.com> + +// Bug 2781. We forgot to copy addressability information when +// cloning. + +struct B +{ + B(int v1); + void Member (int v1); + static void Static (int v1); +}; + +struct D : B +{ + D (int v1); +}; + +void xswap(int& x1) ; + +int xxx = 0; + +B::B(int v1) +{ + xswap(v1); + xxx = v1; +} + +void B::Member(int v1) +{ + xswap(v1); + xxx = v1; +} + +void B::Static(int v1) +{ + xswap(v1); + xxx = v1; +} + +D::D(int v1) + : B (v1) +{ +} + +void xswap (int& x1) { x1 = 2; } + +int main () +{ + B p (1); + + if (xxx != 2) + return 1; + + D q (1); + if (xxx != 2) + return 2; + + p.Member (1); + if (xxx != 2) + return 3; + + p.Static (1); + if (xxx != 2) + return 4; + + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/optimize2.C b/gcc/testsuite/g++.old-deja/g++.other/optimize2.C new file mode 100644 index 00000000000..8a62b32233f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/optimize2.C @@ -0,0 +1,74 @@ +// Special g++ Options: -O2 +// +// Copyright (C) 2001 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 26 May 2001 <nathan@codesourcery.com> + +// Bug 2823. Inlineing the body of a thunk broke things. But that's +// rarely a sensible thing to do anyway. + +#include <cstdio> +#include <cstdlib> + +int objCount = 0; + +struct Thing +{ + int count; + + Thing (); + Thing (Thing const &src); + + ~Thing (); + +}; + +Thing::Thing () + :count (0) +{ + objCount++; + std::printf ("%p %s\n", (void *)this,__PRETTY_FUNCTION__); +} + +Thing::Thing (Thing const &src) + :count (0) +{ + objCount++; + std::printf ("%p %s\n", (void *)this, __PRETTY_FUNCTION__); +} + +Thing::~Thing () +{ + std::printf ("%p %s\n", (void *)this, __PRETTY_FUNCTION__); + if (count) + std::abort (); + count--; + objCount--; +} + +void x(Thing name) +{ + // destruct name here +} + +class Base +{ + public: + virtual void test(const Thing& s) = 0; +}; + +class Impl : virtual public Base +{ + public: + virtual void test(const Thing& s) + { + x(s); // copy construct temporary + } +}; + +int main() +{ + Impl *impl = new Impl(); + + impl->test( Thing ()); // This will use a thunk + return objCount != 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/optimize3.C b/gcc/testsuite/g++.old-deja/g++.other/optimize3.C new file mode 100644 index 00000000000..737aabb3a7a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/optimize3.C @@ -0,0 +1,38 @@ +// Special g++ Options: -O2 +// +// Copyright (C) 2001 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 29 May 2001 <nathan@codesourcery.com> + +// Bug 2936. We ICE'd on tree inlining a function with an anonymous +// union decl. + +inline const unsigned char *Foo (const char *string) +{ + union + { + const char *p1; + const unsigned char *p2; + }; + p1 = 0; + p2 = 0; + + + p1 = string; + return p2; + +} + +const unsigned char *Baz (const char *string) +{ + return Foo (string); +} + +int main () +{ + const char *string = "s"; + const unsigned char *result; + + result = Baz (string); + return (static_cast <const void *> (result) + != static_cast <const void *> (string)); +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/optimize4.C b/gcc/testsuite/g++.old-deja/g++.other/optimize4.C new file mode 100644 index 00000000000..7082e2cb951 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/optimize4.C @@ -0,0 +1,31 @@ +// Build don't link: +// +// Copyright (C) 2001 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 24 Jul 2001 <nathan@codesourcery.com> + +// Bug 3543. We forgot to resolve an OFFSET_REF + + +struct Writeable { + bool blocking_mode; +}; + + +struct Pipe : Writeable { + void ewrite(); + + void set_write_blocking () + { + if (Writeable::blocking_mode); + } +}; + +void Pipe::ewrite() +{ + set_write_blocking(); +} + +void ewrite(Pipe &p) +{ + p.set_write_blocking(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/overload14.C b/gcc/testsuite/g++.old-deja/g++.other/overload14.C new file mode 100644 index 00000000000..8938ef1d7d4 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/overload14.C @@ -0,0 +1,31 @@ +extern "C" void abort(); + +struct A { + typedef double (&B); + typedef const double (&C); + + A() { } + + operator C () const; + operator B (); +}; + +static const double d = 2.0; +static double e = 3.0; + +A::operator A::C () const +{ + abort (); + return d; +} + +A::operator A::B () +{ + return e; +} + +int main () +{ + (A::C) A (); // WARNING - + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/override1.C b/gcc/testsuite/g++.old-deja/g++.other/override1.C new file mode 100644 index 00000000000..c7f3a4c9c0a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/override1.C @@ -0,0 +1,20 @@ +// Build don't link: +// Origin: Frank Pilhofer <fp@fpx.de> + +struct A { +virtual void f (); +}; + +struct B : virtual public A { +void f (); +}; + +struct C : virtual public A { +void f (); +}; + +struct D : virtual public B, virtual public C { +void f (); +}; + +struct Di : virtual public B, virtual public C, virtual public D {}; diff --git a/gcc/testsuite/g++.old-deja/g++.other/override2.C b/gcc/testsuite/g++.old-deja/g++.other/override2.C new file mode 100644 index 00000000000..6466b7d76ef --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/override2.C @@ -0,0 +1,9 @@ +// Copyright (C) 2001 Free Software Foundation, Inc. +// Contributed by Jason Merrill 14 Jun 2001 <jason@redhat.com> + +// Test for diagnosis of missing final overrider. + +struct A { virtual void f (); }; +struct B1: virtual A { virtual void f (); }; +struct B2: virtual A { virtual void f (); }; +struct C: public B1, public B2 {}; // ERROR - no final overrider diff --git a/gcc/testsuite/g++.old-deja/g++.other/perf1.C b/gcc/testsuite/g++.old-deja/g++.other/perf1.C new file mode 100644 index 00000000000..3f898117511 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/perf1.C @@ -0,0 +1,78 @@ +// Build don't link: + +// Test of severe performance regression from 2.95. This code generates +// a heavily self-referential tree which caused the inliner to take +// O(3**N) time to scan it for function calls. +// Reported by Kelley Cook <kelley.cook@home.com>. PR c++/1687. + +bool in0 ; +bool in1 ; +bool in2 ; +bool in3 ; +bool in4 ; +bool in5 ; +bool in6 ; +bool in7 ; +bool in8 ; +bool in9 ; +bool in10; +bool in11; +bool in12; +bool in13; +bool in14; +bool in15; +bool in16; +bool in17; +bool in18; +bool in19; +bool in20; +bool in21; +bool in22; +bool in23; +bool in24; +bool in25; +bool in26; +bool in27; +bool in28; +bool in29; +bool in30; +bool in31; +unsigned long output; + +void mux(void) +{ + output = + (in0 ? 0x00000001 : 0) | + (in1 ? 0x00000002 : 0) | + (in2 ? 0x00000004 : 0) | + (in3 ? 0x00000008 : 0) | + (in4 ? 0x00000010 : 0) | + (in5 ? 0x00000020 : 0) | + (in6 ? 0x00000040 : 0) | + (in7 ? 0x00000080 : 0) | + (in8 ? 0x00000100 : 0) | + (in9 ? 0x00000200 : 0) | + (in10 ? 0x00000400 : 0) | + (in11 ? 0x00000800 : 0) | + (in12 ? 0x00001000 : 0) | + (in13 ? 0x00002000 : 0) | + (in14 ? 0x00004000 : 0) | + (in15 ? 0x00008000 : 0) | + (in16 ? 0x00010000 : 0) | + (in17 ? 0x00020000 : 0) | + (in18 ? 0x00040000 : 0) | + (in19 ? 0x00080000 : 0) | + (in20 ? 0x00100000 : 0) | + (in21 ? 0x00200000 : 0) | + (in22 ? 0x00400000 : 0) | + (in23 ? 0x00800000 : 0) | + (in24 ? 0x01000000 : 0) | + (in25 ? 0x02000000 : 0) | + (in26 ? 0x04000000 : 0) | + (in27 ? 0x08000000 : 0) | + (in28 ? 0x10000000 : 0) | + (in29 ? 0x20000000 : 0) | + (in30 ? 0x40000000 : 0) | + (in31 ? 0x80000000 : 0) ; +} + diff --git a/gcc/testsuite/g++.old-deja/g++.other/pod1.C b/gcc/testsuite/g++.old-deja/g++.other/pod1.C new file mode 100644 index 00000000000..c6faf0d0b18 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/pod1.C @@ -0,0 +1,21 @@ +// Build don't link: + +// Copyright (C) 2001 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 28 Feb 2001 <nathan@codesourcery.com> + +// DR 148. Now allows pointer to members in POD struct. + +struct X +{ + int X::*m; + int (X::*f) (); +}; + +void Foo (int, ...); + +void Baz () +{ + X x; + + Foo (1, x); +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/ptrmem6.C b/gcc/testsuite/g++.old-deja/g++.other/ptrmem6.C index 3e9db8daec9..53087f825c7 100644 --- a/gcc/testsuite/g++.old-deja/g++.other/ptrmem6.C +++ b/gcc/testsuite/g++.old-deja/g++.other/ptrmem6.C @@ -1,7 +1,7 @@ // Build don't link: // crash test - XFAIL *-*-* -// Copyright (c) 2000 Free Software Foundation. +// Copyright (c) 2000, 2001 Free Software Foundation. // Distilled from a bug report by Eric Ford <eford@princeton.edu> extern double *y; @@ -12,5 +12,5 @@ void SetInitCond(void) { int i; for(i = 2; i < nPoints; ++i) - y[i] = y[nPoints] .* (x[i]-x[1]) / (x[nPoints]-x[1]); // ERROR + y[i] = y[nPoints] .* (x[i]-x[1]) / (x[nPoints]-x[1]); // ERROR - } diff --git a/gcc/testsuite/g++.old-deja/g++.other/ref4.C b/gcc/testsuite/g++.old-deja/g++.other/ref4.C new file mode 100644 index 00000000000..c3535d0d3e0 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/ref4.C @@ -0,0 +1,28 @@ +// Build don't link: + +// Copyright (C) 2001 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 27 Feb 2001 <nathan@codesourcery.com> + +// Bug 2117. A conversion op to reference type created a temporary, even +// when bound to another reference. + +struct Abstract +{ + virtual void Foo () = 0; +}; + +struct Proxy +{ + operator Abstract & (); + Abstract &Convert (); +}; + +void Baz (Abstract &); + +void Foo () +{ + Proxy proxy; + + Baz (proxy); + Baz (proxy.Convert ()); +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/regstack.C b/gcc/testsuite/g++.old-deja/g++.other/regstack.C new file mode 100644 index 00000000000..ea7222156de --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/regstack.C @@ -0,0 +1,31 @@ +// Special g++ Options: -O2 +// Skip if not target: i?86-*-* + +inline double foo (double x) +{ + register double r; + asm volatile ("fsqrt" : "=t" (r) : "0" (x)); + return r; +} + +struct X +{ + ~X() {} +}; + +int b; + +double bar (X x) +{ + if (b) + return 1.0; + return 36.0 * foo (36.0); +} + +int main () +{ + X x; + if (bar (x) != 216.0) + return 1; + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/return1.C b/gcc/testsuite/g++.old-deja/g++.other/return1.C new file mode 100644 index 00000000000..5b998460ab3 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/return1.C @@ -0,0 +1,17 @@ +// Build don't link: +// Special g++ Option: + +struct C { + int f() {return 0;} +}; + +struct D { + C a[1]; + C* g(); +}; + +C* D::g() { + int i = 0; + while (i < 1 && a[i].f() != 1) {} + return undefined_variable; // ERROR - +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/sibcall1.C b/gcc/testsuite/g++.old-deja/g++.other/sibcall1.C index 99a1dc176e4..c6eadaa3dd5 100644 --- a/gcc/testsuite/g++.old-deja/g++.other/sibcall1.C +++ b/gcc/testsuite/g++.old-deja/g++.other/sibcall1.C @@ -1,13 +1,13 @@ // Special g++ Options: -O2 -#include <iostream.h> +#include <iostream> -ostream& foo (char *x, ostream &y) +std::ostream& foo (char *x, std::ostream &y) { return y << "" << x; } int main () { - foo ("", cout); + foo ("", std::cout); } diff --git a/gcc/testsuite/g++.old-deja/g++.other/static8.C b/gcc/testsuite/g++.old-deja/g++.other/static8.C deleted file mode 100644 index 5672d728be8..00000000000 --- a/gcc/testsuite/g++.old-deja/g++.other/static8.C +++ /dev/null @@ -1,13 +0,0 @@ -// Build don't link: -// Special g++ Options: -fno-squangle -// Origin: Mark Mitchell <mark@codesourcery.com> - -#if (!defined (__GXX_ABI_VERSION) || __GXX_ABI_VERSION < 100) -#define NAME(OLD, NEW) OLD -#else -#define NAME(OLD, NEW) NEW -#endif /* (!defined (__GXX_ABI_VERSION) || __GXX_ABI_VERSION < 100) */ - -static unsigned int strlen (const char*) {return 0;} // ERROR - previous declaration - -int NAME (strlen__FPCc, _Z6strlenPKc) = 0; // ERROR - duplicate declaration diff --git a/gcc/testsuite/g++.old-deja/g++.other/std1.C b/gcc/testsuite/g++.old-deja/g++.other/std1.C index 21a232a0879..dc36519d050 100644 --- a/gcc/testsuite/g++.old-deja/g++.other/std1.C +++ b/gcc/testsuite/g++.old-deja/g++.other/std1.C @@ -1,5 +1,4 @@ // Build don't link: -// Special g++ Options: -fhonor-std // Origin: Mark Mitchell <mark@codesourcery.com> extern "C" int memcmp (const void * __s1, diff --git a/gcc/testsuite/g++.old-deja/g++.other/thunk1.C b/gcc/testsuite/g++.old-deja/g++.other/thunk1.C new file mode 100644 index 00000000000..72ca2ce5008 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/thunk1.C @@ -0,0 +1,35 @@ +extern "C" void abort(); + +int ic; + +struct X +{ + X() { ++ic; } + X( const X & ) { ++ic; } + ~X() { if (--ic < 0) abort(); } +}; + +struct V +{ + virtual ~V() {} +}; + +struct A : public virtual V +{ +}; + +struct B : public virtual V +{ + virtual void foo( X ) = 0; +}; + +struct D : public A, public virtual B +{ + virtual void foo( X ) {} +}; + +int main() +{ + B *b = new D; + b->foo( X() ); +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/typeid1.C b/gcc/testsuite/g++.old-deja/g++.other/typeid1.C new file mode 100644 index 00000000000..e50f3c2bf87 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/typeid1.C @@ -0,0 +1,15 @@ +// Build don't link: +// Origin: sk@gluit.de +// Special g++ Options: + +#include <typeinfo> + +int main () +{ + typeid(char*); + + int len = 1; + char carr[len]; + typeid(typeof(carr)); // ERROR - type has variable size + typeid(carr); // ERROR - type has variable size +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/using9.C b/gcc/testsuite/g++.old-deja/g++.other/using9.C new file mode 100644 index 00000000000..1d3d9f2634d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/using9.C @@ -0,0 +1,21 @@ +// Build don't link: +// +// Copyright (C) 2001 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 26 Feb 2001 <nathan@codesourcery.com> + +// Bug 75. using declarations cannot introduce functions which ambiguate +// those in the current namespace, BUT here we're reaccessing the current +// namespace -- the function is not being 'introduced'. + +extern int a(); +struct x {}; + +using ::x; +using ::a; + +extern "C" void foo (); + +namespace { + extern "C" int foo (); + using ::foo; // ERROR - already in use +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/vector1.C b/gcc/testsuite/g++.old-deja/g++.other/vector1.C new file mode 100644 index 00000000000..5ed9a48d561 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/vector1.C @@ -0,0 +1,16 @@ +// Build don't link: +// Origin: Joe Buck <jbuck@welsh-buck.org> + +#include <vector> +using std::vector; + +struct foo { +int a; +}; + +bool operator==(const foo&, const foo&); + +bool veq(const vector<foo>& a, const vector<foo>& b) +{ +return a == b; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/warn5.C b/gcc/testsuite/g++.old-deja/g++.other/warn5.C new file mode 100644 index 00000000000..4c17dc66406 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/warn5.C @@ -0,0 +1,19 @@ +// Special g++ Options: -W +// Build don't link: +// +// Copyright (C) 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 6 Febs 2001 <nathan@codesourcery.com> + +// Bug 1765. We gave bogus warning on default initializer. + +struct X +{ + int i; +}; + +X *foo () +{ + return new X (); // gets bogus warning +} + +X x = {}; // WARNING - missing initializer diff --git a/gcc/testsuite/g++.old-deja/g++.other/warn6.C b/gcc/testsuite/g++.old-deja/g++.other/warn6.C new file mode 100644 index 00000000000..1a54b329789 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/warn6.C @@ -0,0 +1,17 @@ +// Build don't link: +// Special g++ Options: -W -Wall + +// Copyright (C) 2001 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 2 Mar 2001 <nathan@codesourcery.com> + +// Bug 2139. We gave an erronous warning about an unused parm on a +// synthesized function + +struct A +{ + virtual ~A (); +}; +void foo (A const &a) +{ + A a1 = a; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/warn7.C b/gcc/testsuite/g++.old-deja/g++.other/warn7.C new file mode 100644 index 00000000000..a27756a1a9a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/warn7.C @@ -0,0 +1,45 @@ +// Build don't link: +// Special g++ Options: -W -Wall +// +// Copyright (C) 2001 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 26 April 2001 <nathan@codesourcery.com> + +// Bug 2356. Unused parameter information introduced in a ctor +// definition was not propagated to clones, leading to missed or +// unwarranted unused parameter warnings, possibly given twice. + +struct X +{ + X(int i); + void foo (int i); + +}; +void foo (int i); + +X::X(int) +{ +} +void X::foo (int) +{ +} +void foo (int) +{ +} + +struct Y +{ + Y(int); + void bar (int); + +}; +void bar (int); + +Y::Y(int i) +{ // WARNING - unused parameter +} +void Y::bar (int i) +{ // WARNING - unused parameter +} +void bar (int i) +{ // WARNING - unused parameter +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/array7.C b/gcc/testsuite/g++.old-deja/g++.pt/array7.C new file mode 100644 index 00000000000..02e0733b91b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/array7.C @@ -0,0 +1,11 @@ +// Build don't link: +// Origin: Mark Mitchell <mark@codesourcery.com> + +template <typename T> +struct S { + enum E { e = 5 }; + static int i[e]; +}; + +template <typename T> +int S<T>::i[S<T>::e]; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/const2.C b/gcc/testsuite/g++.old-deja/g++.pt/const2.C new file mode 100644 index 00000000000..3c064fe6d4a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/const2.C @@ -0,0 +1,9 @@ +// This test should get a linker error for the reference to A<int>::i. +// An XPASS on this test is really a FAIL. +// excess errors test - XFAIL *-*-* + +template <class T> struct B { static const int i = 3; }; +template <class T> struct A { static const int i = B<T>::i; }; +const int *p = &A<int>::i; + +int main(){} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/crash68.C b/gcc/testsuite/g++.old-deja/g++.pt/crash68.C new file mode 100644 index 00000000000..b856f22a3b0 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/crash68.C @@ -0,0 +1,70 @@ +// Build don't link: +// +// Copyright (C) 2001 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 25 Jul 2001 <nathan@codesourcery.com> + +// Origin: gustavo@geneura.ugr.es +// Bug 3624. Template instantiation of a reference type was not +// converted from reference when doing a call. + +#include <iostream> + +using namespace std; + +template <class A, class B, class C, C& c, bool d> class eo: public A +{ +public: + eo() + { + cout << this->x << " " << this->y << " " + << c(*this) << " " + << ((d)?"true":"false") << endl; + } + +private: + B b; +}; + +struct XY +{ + float x, y; + + XY(): x(1), y(0.1) {} +}; + +float fitness(const XY& a) +{ + return a.x + a.y; +} + +struct fitness2 +{ + float operator()(const XY& a) + { + return a.x - a.y; + } + + float f(const XY& a) + { + return a.x - a.y; + } +}; + +struct fitness3 +{ + float operator()(const XY& a) + { + return a.x / a.y; + } +}; + +fitness2 f2; +fitness3 f3; + +int main() +{ + eo<XY, float, fitness2, f2, true> eo2; + eo<XY, float, fitness3, f3, true> eo3; + + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/deduct5.C b/gcc/testsuite/g++.old-deja/g++.pt/deduct5.C new file mode 100644 index 00000000000..d47a7669295 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/deduct5.C @@ -0,0 +1,33 @@ +// Copyright (C) 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 13 Feb 2001 <nathan@codesourcery.com> + +// Bug 1960. We were not dealing with qualified array types properly. + +#include <stdio.h> + +template <typename T> int Foo (T const *ptr) +{ + static int count = 0; + + printf ("%s\n", __PRETTY_FUNCTION__); + count++; + + return count; +} + +int main () +{ + static int const cs = 1; + static int const ca[1] = {1}; + static int s = 1; + static int a[1] = {1}; + + Foo (&cs); + Foo (&ca); + if (Foo (&s) != 2) + return 1; + if (Foo (&a) != 2) + return 2; + + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/deduct6.C b/gcc/testsuite/g++.old-deja/g++.pt/deduct6.C new file mode 100644 index 00000000000..7fcef4edc4b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/deduct6.C @@ -0,0 +1,24 @@ +// Build don't link: +// Copyright (C) 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 13 Feb 2001 <nathan@codesourcery.com> + +// Bug 1962. We were not dealing with qualified array types properly. + +#include <stdio.h> + +template <typename T, unsigned I> int Baz (T (&obj)[I]) +{ + printf ("%s\n", __PRETTY_FUNCTION__); + return 1; +} + +int main () +{ + static int const ca[1] = {1}; + static int a[1] = {1}; + + Baz (ca); + Baz (a); + + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/deduct7.C b/gcc/testsuite/g++.old-deja/g++.pt/deduct7.C new file mode 100644 index 00000000000..ec51d30878d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/deduct7.C @@ -0,0 +1,14 @@ +// Copyright (C) 2001 Free Software Foundation, Inc. +// Contributed by Jason Merrill 14 Jun 2001 <jason@redhat.com> + +// Test that deduction can add cv-quals to a pointer-to-member type. + +struct A; +int A::* pi; + +template <typename T> void f (const T A::*) {} + +int main () +{ + f (pi); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/friend48.C b/gcc/testsuite/g++.old-deja/g++.pt/friend48.C new file mode 100644 index 00000000000..af0e3caf15c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/friend48.C @@ -0,0 +1,17 @@ +// Build don't link: +// Origin: Mark Mitchell <mark@codesourcery.com> + +template <class T> +class C { + template <class U> + friend class ::C; +}; + +namespace N +{ +template <class T> +class D { + template <class U> + friend class N::D; +}; +}; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/friend49.C b/gcc/testsuite/g++.old-deja/g++.pt/friend49.C new file mode 100644 index 00000000000..3b243f09249 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/friend49.C @@ -0,0 +1,26 @@ +// Build don't link: + +// Copyright (C) 2001 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 5 Jun 2001 <nathan@codesourcery.com> + +// Bug 2929. We were forgetting about template parm scope when +// injecting a friend decl into a class template specialization's +// containing scope. + +template <class Type> class Vec; + +template <> class Vec<double> +{ +public: + Vec (); + Vec<double> & Fn (double); + friend Vec<double> Fn (const Vec<double> &, double); +}; // pop_binding ICE + +template <class _Tp> class Alloc +{ + template <class _Tp1> struct Rebind + { + typedef Alloc<_Tp1> other; + }; +}; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/mangle2.C b/gcc/testsuite/g++.old-deja/g++.pt/mangle2.C new file mode 100644 index 00000000000..a7b95b1a408 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/mangle2.C @@ -0,0 +1,40 @@ +// Build don't link: +// +// Copyright (C) 2001 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 25 April 2001 <nathan@codesourcery.com> +// Origin:pcarlini@unitus.it + +// Bug 2559. We hadn't implemented code to mangle numbers bigger than +// HOST_WIDE_INT. + +template<class T, T min_val, T max_val> +class integer_traits_base +{ +public: +static const bool is_integral = true; +}; + +template<class T> +class integer_traits +{ +public: +static const bool is_integral = false; +}; + +template<> +class integer_traits<long long> +: public integer_traits_base<long long, (-9223372036854775807LL - 1), +9223372036854775807LL> +{ }; + +integer_traits<long long> f; + +template <class T, T value> T foo () +{ + return value; +} + +void x () +{ + foo<long long, -9223372036854775807LL> (); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/memtemp100.C b/gcc/testsuite/g++.old-deja/g++.pt/memtemp100.C new file mode 100644 index 00000000000..c88c3e7a2f5 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/memtemp100.C @@ -0,0 +1,40 @@ +// Build don't link: +// Origin: philippeb@videotron.ca +// Special g++ Options: + +#include <iostream> + +using namespace std; + +template <class T> struct traits +{ + typedef long next; +}; + + +template <class T> +struct c1 +{ + template <class U> + struct c2 + { + c2() + { + cout << __PRETTY_FUNCTION__ << endl; + } + }; +}; + + +template <class T> +void foo() +{ + cout << __PRETTY_FUNCTION__ << endl; + typename c1<typename traits<T>::next>::template c2<void>(); +} + + +int main() +{ + foo<int>(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/memtemp99.C b/gcc/testsuite/g++.old-deja/g++.pt/memtemp99.C new file mode 100644 index 00000000000..2295bea022d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/memtemp99.C @@ -0,0 +1,10 @@ +// Build don't link: +// Origin: bitti@cs.tut.fi + +template<typename T, unsigned int N> +class Vector +{ +public: + template<unsigned int I> + class Vector<T,N>::CommaInit { }; // ERROR - invalid definition +}; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/ptrmem2.C b/gcc/testsuite/g++.old-deja/g++.pt/ptrmem2.C index c6927d19472..1f254e93c31 100644 --- a/gcc/testsuite/g++.old-deja/g++.pt/ptrmem2.C +++ b/gcc/testsuite/g++.old-deja/g++.pt/ptrmem2.C @@ -31,6 +31,11 @@ S* S::g() return this; } +S* S::h() +{ + return this; +} + int main() { S s; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/ref4.C b/gcc/testsuite/g++.old-deja/g++.pt/ref4.C new file mode 100644 index 00000000000..1291dc1ff2d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/ref4.C @@ -0,0 +1,25 @@ +// Build don't link: +// +// Copyright (C) 2001 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 29 Apr 2001 <nathan@codesourcery.com> + +// Bug 2664. We failed to convert_from_reference for non-type +// template parms. + +struct cow { }; + +cow c; + +void func (cow &c) {} +void operator-(cow &c) {} + +template<cow &C> void test() +{ + func(C); //OK + -C; //bogus error +} + +int main() +{ + test<c> (); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/repo4.C b/gcc/testsuite/g++.old-deja/g++.pt/repo4.C new file mode 100644 index 00000000000..6180acbb57e --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/repo4.C @@ -0,0 +1,15 @@ +// Build then link: +// Special g++ Options: -frepo + +template <class T> +struct S { + ~S (); +}; + +template <class T> +S<T>::~S () {} + +int main () +{ + S<int> s; +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/spec40.C b/gcc/testsuite/g++.old-deja/g++.pt/spec40.C new file mode 100644 index 00000000000..2d0ad90088c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/spec40.C @@ -0,0 +1,13 @@ +// Copyright (C) 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 12 Feb 2001 <nathan@codesourcery.com> + +// More from bug 1617. We didn't resolve partial ordering properly. The +// std is rather vague about it anyway, DR 214 talks about this. + +template <typename T> int Foo (T const *) {return 1;} +template <unsigned I> int Foo (char const (&)[I]) {return 2;} + +int main () +{ + return Foo ("a") != 2; +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/static3.C b/gcc/testsuite/g++.old-deja/g++.pt/static3.C index df770dac87d..bfcfbdbe743 100644 --- a/gcc/testsuite/g++.old-deja/g++.pt/static3.C +++ b/gcc/testsuite/g++.old-deja/g++.pt/static3.C @@ -1,6 +1,6 @@ // On targets that don't support weak symbols, we require an explicit // instantiation of arr. -// excess errors test - XFAIL *-*-aout *-*-coff *-*-hpux* alpha*-dec-osf* *-*-hms +// excess errors test - XFAIL *-*-aout *-*-coff *-*-hpux* *-*-hms template<class T> struct A { diff --git a/gcc/testsuite/g++.old-deja/g++.pt/static6.C b/gcc/testsuite/g++.old-deja/g++.pt/static6.C index b433e3efa39..8052dc219a3 100644 --- a/gcc/testsuite/g++.old-deja/g++.pt/static6.C +++ b/gcc/testsuite/g++.old-deja/g++.pt/static6.C @@ -1,5 +1,5 @@ // Build don't run: -// excess errors test - XFAIL *-*-aout *-*-coff *-*-hpux* alpha*-dec-osf* *-*-hms +// excess errors test - XFAIL *-*-aout *-*-coff *-*-hpux* *-*-hms // Simplified from testcase by Erez Louidor Lior <s3824888@techst02.technion.ac.il> diff --git a/gcc/testsuite/g++.old-deja/g++.pt/typename28.C b/gcc/testsuite/g++.old-deja/g++.pt/typename28.C new file mode 100644 index 00000000000..a538c4d946f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/typename28.C @@ -0,0 +1,27 @@ +// Build don't link: +// +// Origin: Jens.Maurer@gmx.net +// Copyright (C) 2001 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 11 Apr 2001 <nathan@codesourcery.com> + +// Bug 1844. We can meet types in cp_tree_equal via a template-id-expr. + +typedef int *Ptr; + +template<class T> struct B +{ + typedef typename T::template X<T> type; + typedef typename T::template X<Ptr> type2; + typedef typename T::template X<int *> type3; + + void foo (type); + void baz (type2); + +}; + +template<class T> void B<T>::foo (type) +{ +} +template<class T> void B<T>::baz (type3) +{ +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/unify8.C b/gcc/testsuite/g++.old-deja/g++.pt/unify8.C index 4e2f392b64b..afe57d1cd14 100644 --- a/gcc/testsuite/g++.old-deja/g++.pt/unify8.C +++ b/gcc/testsuite/g++.old-deja/g++.pt/unify8.C @@ -9,10 +9,12 @@ template <typename T> void Foo (T const **); +template <typename T> void Bar (T const * const *); void Foo (int); // ERROR - candidate void Foo (float); // ERROR - candidate void baz (int **p1) { Foo (p1); // ERROR - no such function + Bar (p1); // OK } diff --git a/gcc/testsuite/g++.old-deja/g++.pt/using1.C b/gcc/testsuite/g++.old-deja/g++.pt/using1.C new file mode 100644 index 00000000000..632fca00a45 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/using1.C @@ -0,0 +1,36 @@ +// Copyright (C) 2001 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 26 Feb 2001 <nathan@codesourcery.com> + +// Bug 1981. using declarations in namespace scope were not remembered. + +namespace A +{ + void swap () {} +}; + +template <class T> void f() +{ + using A::swap; +} + +template void f<float> (); + +int foo (int) { return 0;} + +namespace B +{ + int foo (int) { return 1;} + + template <class T> int baz () + { + using ::foo; + + return foo (1); + } + template int baz<float> (); +}; + +int main () +{ + return B::baz<float> (); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/using2.C b/gcc/testsuite/g++.old-deja/g++.pt/using2.C new file mode 100644 index 00000000000..5d47b7527a6 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/using2.C @@ -0,0 +1,26 @@ +// Build don't link: +// +// Copyright (C) 2001 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 22 May 2001 <nathan@codesourcery.com> + +// Bug 2184. Using decls in templates weren't doing the right thing. + +namespace N { + template <class T> + class vector {}; +} + +void g(const int&) { + using N::vector; + typedef vector<int> V; +} + +template <class J> +void f(const J&) { + using N::vector; + typedef vector<int> V; +} + +int main() { + f(0); +} diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb109.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb109.C index b87be9c1ae9..7a7c56cd34f 100644 --- a/gcc/testsuite/g++.old-deja/g++.robertl/eb109.C +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb109.C @@ -1,8 +1,10 @@ #include<map> -#include<iostream.h> +#include<iostream> #include<vector> #include<string> +using namespace std; + // empty parameter class with a minimal set of operations // if there are no weights for edges necessary struct Empty diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb113.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb113.C index f3c28b9ac65..88d33b148d7 100644 --- a/gcc/testsuite/g++.old-deja/g++.robertl/eb113.C +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb113.C @@ -1,5 +1,5 @@ // Build don't link: -#include <iostream.h> +#include <iostream> class X : public std::streambuf { diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb115.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb115.C index 30eab786f34..fc404d9ae32 100644 --- a/gcc/testsuite/g++.old-deja/g++.robertl/eb115.C +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb115.C @@ -1,9 +1,9 @@ // Special g++ Options: -O -#include <iostream.h> +#include <iostream> #include <typeinfo> int main() { int *i1, *i2; - cerr << (typeid(i1)==typeid(i2)) << endl; + std::cerr << (typeid(i1)==typeid(i2)) << std::endl; } diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb118.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb118.C index 23498c78554..b191ac11717 100644 --- a/gcc/testsuite/g++.old-deja/g++.robertl/eb118.C +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb118.C @@ -1,7 +1,7 @@ // Test for obsolete specialization syntax. Turn off -pedantic. // Special g++ Options: -#include <iostream.h> +#include <iostream> #include <typeinfo> template <typename T> @@ -13,7 +13,7 @@ public: template <typename T> void A<T>::test(){ - cerr << "test for " << typeid(*this).name() << endl; + std::cerr << "test for " << typeid(*this).name() << std::endl; } // Specialization declaration void @@ -22,7 +22,7 @@ A<double>::test(); // Specialization definition void A<double>::test(){ - cerr << "specialization for " << typeid(*this).name() << endl; + std::cerr << "specialization for " << typeid(*this).name() << std::endl; } @@ -35,3 +35,4 @@ main(){ return 0; } + diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb130.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb130.C index 48bbb8f9898..7e9fc59dd7a 100644 --- a/gcc/testsuite/g++.old-deja/g++.robertl/eb130.C +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb130.C @@ -6,6 +6,6 @@ // From: Klaus-Georg Adams <Klaus-Georg.Adams@chemie.uni-karlsruhe.de> -#include <hash_set> +#include <ext/hash_set> std::hash_set<int> foo; diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb133.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb133.C index 788d60388cc..e2b25f6ef08 100644 --- a/gcc/testsuite/g++.old-deja/g++.robertl/eb133.C +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb133.C @@ -1,9 +1,10 @@ // Build don't link: -// Special g++ Options: -fno-honor-std // Gives ICE 109 // From: Klaus-Georg Adams <Klaus-Georg.Adams@chemie.uni-karlsruhe.de> // Reported against EGCS snaps 98/06/28. +using namespace std; + int main() { try { diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb15.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb15.C index 902d4631ac1..f56f3137e64 100644 --- a/gcc/testsuite/g++.old-deja/g++.robertl/eb15.C +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb15.C @@ -1,18 +1,18 @@ // Build don't link: -#include<iostream.h> -#include<stddef.h> +#include<iostream> +#include<cstddef> struct A { A() { - cerr<<"A constructing\n"; + std::cerr<<"A constructing\n"; throw 1; } void *operator new(size_t sz) { - cerr<<"A allocated\n"; + std::cerr<<"A allocated\n"; return ::operator new(sz); } void operator delete (void *p) { - cerr<<"A deleted\n"; + std::cerr<<"A deleted\n"; ::operator delete (p); } }; @@ -23,3 +23,6 @@ int main() { } catch (...) { } } + + + diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb21.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb21.C index f534f4891d7..11b38cdc731 100644 --- a/gcc/testsuite/g++.old-deja/g++.robertl/eb21.C +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb21.C @@ -1,6 +1,6 @@ #include <vector> -#include <strstream.h> +#include <sstream> using namespace std; @@ -16,7 +16,7 @@ std::vector<connection_t> connections; int main() { - ostrstream str; + ostringstream str; connections.insert(connections.end(), connection_t()); diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb24.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb24.C index b1f01043817..7ea7b41205b 100644 --- a/gcc/testsuite/g++.old-deja/g++.robertl/eb24.C +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb24.C @@ -1,5 +1,5 @@ // Build don't link: -#include <iostream.h> +#include <iostream> template < class T > class X @@ -19,5 +19,5 @@ class Y : public X<T> using X<T>::x; - void f () { cout << x << endl; } + void f () { std::cout << x << std::endl; } }; diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb27.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb27.C index 31012bee0d8..3d32f1c0028 100644 --- a/gcc/testsuite/g++.old-deja/g++.robertl/eb27.C +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb27.C @@ -7,7 +7,7 @@ // for the test<T> record_type. This is marked as an expected failure for now, // until we actually fix it. -#include <iostream.h> +#include <iostream> template <class T> class test; template <class T> test<T> operator + (const test<T>& a, const test<T>& b); @@ -22,7 +22,7 @@ class test test (const T& a) { elem = a; }; test<T>& operator += (const test<T>& a) { elem += a.elem; return *this; }; friend test<T> operator + <> (const test<T>&, const test<T>&); - friend ostream& operator << (ostream& os, const test<T>& a) + friend std::ostream& operator << (std::ostream& os, const test<T>& a) { return os << a.elem; }; }; @@ -34,6 +34,8 @@ test<T> operator + (const test<T>& a, const test<T>& b) return c(a); int main() { test<int> x, y; - x += 5; cout << x << endl; - y = x + test<int>(2); cout << y << endl; + x += 5; + std::cout << x << std::endl; + y = x + test<int>(2); + std::cout << y << std::endl; } diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb3.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb3.C index d257043e46a..ccf6027102a 100644 --- a/gcc/testsuite/g++.old-deja/g++.robertl/eb3.C +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb3.C @@ -1,5 +1,5 @@ // Build don't link: -#include <complex.h> +#include <complex> template<class T> class Vec { public: @@ -8,4 +8,4 @@ public: void operator=(const Vec<T> &v) { data = new T; } T *data; }; -template class Vec<complex<double> >; +template class Vec<std::complex<double> >; diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb30.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb30.C index c116ab4cd4d..0d245875284 100644 --- a/gcc/testsuite/g++.old-deja/g++.robertl/eb30.C +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb30.C @@ -1,7 +1,7 @@ // Build don't link: -#include <fstream.h> +#include <fstream> -class bifstream : public ifstream { +class bifstream : public std::ifstream { public: bifstream(); // ~bifstream(); @@ -14,3 +14,6 @@ void load_bin() if (!InFile) return; } + + + diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb31.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb31.C index 1a18af5b4c8..33a12b89ac2 100644 --- a/gcc/testsuite/g++.old-deja/g++.robertl/eb31.C +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb31.C @@ -1,4 +1,4 @@ -#include<iostream.h> +#include<iostream> int main() { try { @@ -15,3 +15,5 @@ int main() { } return 0; } + + diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb33.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb33.C index 3797ab3740f..9664f42e941 100644 --- a/gcc/testsuite/g++.old-deja/g++.robertl/eb33.C +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb33.C @@ -1,11 +1,11 @@ -#include <fstream.h> -#include <stdio.h> +#include <fstream> +#include <cstdio> int main() { - printf("If you see this, you don't have a problem!\n"); + std::printf("If you see this, you don't have a problem!\n"); #ifdef EXPOSE_BUG - ifstream a; + std::ifstream a; #endif } diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb39.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb39.C index 4d194e05010..98bee9c6fcf 100644 --- a/gcc/testsuite/g++.old-deja/g++.robertl/eb39.C +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb39.C @@ -1,10 +1,8 @@ // Build don't link: -#include <ctype.h> -#include <iostream.h> -// #include <streambuf.h> -// #include <libio.h> -#include <strstream.h> -#include <string.h> +#include <cctype> +#include <iostream> +#include <sstream> +#include <cstring> using namespace std; @@ -13,7 +11,8 @@ extern bool foo2 (ostream &out, istream &in); bool foo1 (ostream &out, const char *in) { - strstreambuf sb (in, (int) strlen (in)); + string tmp(in, std::strlen(in)); + stringbuf sb (tmp); istream fmt (&sb); return foo2 (out, fmt); } diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb4.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb4.C index b51d3eafb98..69728967480 100644 --- a/gcc/testsuite/g++.old-deja/g++.robertl/eb4.C +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb4.C @@ -1,6 +1,6 @@ // Error: Internal Compiler Error in GCC 2.7.2 and EGCS 1998/05/28 snapshot. -#include <iostream.h> +#include <iostream> class some_base { @@ -31,7 +31,7 @@ public: class some_derived::func(derived_func_args &a) // ERROR - illegal member syntax { - cout << a.i << ' ' << a.f << endl; + std::cout << a.i << ' ' << a.f << std::endl; } int diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb41.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb41.C index 0bd69e37648..1cc7509314a 100644 --- a/gcc/testsuite/g++.old-deja/g++.robertl/eb41.C +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb41.C @@ -1,8 +1,8 @@ -#include <iostream.h> -#include <iterator.h> +#include <iostream> +#include <iterator> #include <string> -ostream_iterator<std::string> oo(cout); +std::ostream_iterator<std::string> oo(std::cout); int main() { diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb42.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb42.C index 8850f9fa639..22099fd397e 100644 --- a/gcc/testsuite/g++.old-deja/g++.robertl/eb42.C +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb42.C @@ -1,6 +1,6 @@ //Build don't link: -#include <vector.h> -#include <algo.h> +#include <vector> +#include <algorithm> template <class T> class Expr { @@ -14,6 +14,11 @@ inline bool compare(const Expr<T> a, const Expr<T> b){ return true; }; int main() { -vector<int> a(3); -sort( a.begin(), a.end(), compare ); // ERROR - no matching function + std::vector<int> a(3); + std::sort( a.begin(), a.end(), compare ); // ERROR - no matching function } + + + + + diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb44.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb44.C index 04ff13d698f..36042337417 100644 --- a/gcc/testsuite/g++.old-deja/g++.robertl/eb44.C +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb44.C @@ -4,9 +4,11 @@ // Also, the template instantiation does not provide the missing // friend function, the non-template function does -#include <stdio.h> -#include <stdlib.h> -#include <iostream.h> +#include <cstdio> +#include <cstdlib> +#include <iostream> + +using namespace std; template <class T> class Vector diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb46.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb46.C index ad077e38dc3..8d3b3055b8a 100644 --- a/gcc/testsuite/g++.old-deja/g++.robertl/eb46.C +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb46.C @@ -1,4 +1,4 @@ -#include <iostream.h> +#include <iostream> class A1 { friend class B; @@ -22,6 +22,9 @@ int main() A1* a=new A3; B b(a); - if (b.itsA) cout << "cast ok" << endl; else cout << "cast failed" << endl; + if (b.itsA) + std::cout << "cast ok" << std::endl; + else + std::cout << "cast failed" << std::endl; return 0; } diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb54.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb54.C index bcf9968d121..b8ac4035e68 100644 --- a/gcc/testsuite/g++.old-deja/g++.robertl/eb54.C +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb54.C @@ -1,8 +1,9 @@ -#include <iomanip.h> -#include <stdlib.h> +#include <iomanip> +#include <iostream> +#include <cstdlib> int main() { - cout << setbase(3) << endl; - exit (0); + std::cout << std::setbase(3) << std::endl; + std::exit (0); } diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb55.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb55.C index 11f98bba89b..0ab10d5d424 100644 --- a/gcc/testsuite/g++.old-deja/g++.robertl/eb55.C +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb55.C @@ -2,11 +2,11 @@ // Since the constructor is in streambuf.h, additional diagnostics are // produced, which are not really supported in the old-deja framework -#include <strstream.h> +#include <sstream> void t( char* buf ) { - istrstream str = buf; //ERROR - inaccessible copy constructor + std::istrstream str = buf; //ERROR - inaccessible copy constructor } diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb63.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb63.C index 671fe813200..f786e707923 100644 --- a/gcc/testsuite/g++.old-deja/g++.robertl/eb63.C +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb63.C @@ -11,6 +11,6 @@ public: main() { A* a; - a = new A[2] = { A(1,false), A(1,false) } ; + a = new A[2](1,false); } diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb66.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb66.C index d79865f21d9..2ac350e989c 100644 --- a/gcc/testsuite/g++.old-deja/g++.robertl/eb66.C +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb66.C @@ -1,5 +1,5 @@ -#include <assert.h> -#include <iostream.h> +#include <cassert> +#include <iostream> int bar () { diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb73.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb73.C index 75695de92d6..622d3ec9d3f 100644 --- a/gcc/testsuite/g++.old-deja/g++.robertl/eb73.C +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb73.C @@ -1,7 +1,7 @@ // Special g++ Options: -O -Wall // Depletes VM. -#include <iostream.h> +#include <iostream> #include <list> #include <algorithm> using namespace std; diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb77.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb77.C index f5fbb6f2515..3db45cc8007 100644 --- a/gcc/testsuite/g++.old-deja/g++.robertl/eb77.C +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb77.C @@ -1,15 +1,15 @@ -#include <stream.h> -#include <strstream.h> +#include <iostream> +#include <sstream> using namespace std; int main(int, char* []) { - strstream s; + stringstream s; s << "line 1\nline 2\n\nline 4"; - s << ends; + s << std::ends; int nLine = 0; @@ -22,7 +22,7 @@ main(int, char* []) } ++nLine; - cout << nLine << ": " << line << endl; + std::cout << nLine << ": " << line << std::endl; if( nLine > 10 ) { // stop infinite loop break; diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb79.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb79.C index 5691532b99f..453916ed097 100644 --- a/gcc/testsuite/g++.old-deja/g++.robertl/eb79.C +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb79.C @@ -1,5 +1,7 @@ // Makes bogus x86 assembly code. -#include <iostream.h> +#include <iostream> + +using namespace std; template<class T> T max(T a, T b) diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb83.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb83.C index 7121e140078..0f42cf4afa7 100644 --- a/gcc/testsuite/g++.old-deja/g++.robertl/eb83.C +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb83.C @@ -1,7 +1,7 @@ // Skip if not native // Special g++ Options: -fprofile-arcs -ftest-coverage void -swap(int& x, int& y) throw() +test_swap(int& x, int& y) throw() { int tmp = x; x = y; @@ -12,5 +12,5 @@ main() { int i = 5; int j = 7; - swap(i, j); + test_swap(i, j); } diff --git a/gcc/testsuite/g++.old-deja/g++.warn/iomanip.C b/gcc/testsuite/g++.old-deja/g++.warn/iomanip.C index 2fea4edf6af..b7a47faa25a 100644 --- a/gcc/testsuite/g++.old-deja/g++.warn/iomanip.C +++ b/gcc/testsuite/g++.old-deja/g++.warn/iomanip.C @@ -3,10 +3,11 @@ // Special g++ Options: -O -Winline // Build don't link: -#include <iomanip.h> +#include <iomanip> +#include <iostream> void f() { - cout << setw(3); + std::cout << std::setw(3); } diff --git a/gcc/testsuite/g++.old-deja/g++.warn/virt1.C b/gcc/testsuite/g++.old-deja/g++.warn/virt1.C new file mode 100644 index 00000000000..2712adde96c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.warn/virt1.C @@ -0,0 +1,10 @@ +// Special g++ Options: -Woverloaded-virtual +// Build don't link: + +struct A { + virtual void f(); // WARNING - hidden +}; + +struct B: public A { + void f(int); // WARNING - by this +}; |