diff options
author | upstream source tree <ports@midipix.org> | 2015-03-15 20:14:05 -0400 |
---|---|---|
committer | upstream source tree <ports@midipix.org> | 2015-03-15 20:14:05 -0400 |
commit | 554fd8c5195424bdbcabf5de30fdc183aba391bd (patch) | |
tree | 976dc5ab7fddf506dadce60ae936f43f58787092 /gcc/testsuite/g++.old-deja | |
download | cbb-gcc-4.6.4-15d2061ac0796199866debe9ac87130894b0cdd3.tar.bz2 cbb-gcc-4.6.4-15d2061ac0796199866debe9ac87130894b0cdd3.tar.xz |
obtained gcc-4.6.4.tar.bz2 from upstream website;upstream
verified gcc-4.6.4.tar.bz2.sig;
imported gcc-4.6.4 source tree from verified upstream tarball.
downloading a git-generated archive based on the 'upstream' tag
should provide you with a source tree that is binary identical
to the one extracted from the above tarball.
if you have obtained the source via the command 'git clone',
however, do note that line-endings of files in your working
directory might differ from line-endings of the respective
files in the upstream repository.
Diffstat (limited to 'gcc/testsuite/g++.old-deja')
3249 files changed, 87163 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.old-deja/g++.abi/aggregates.C b/gcc/testsuite/g++.old-deja/g++.abi/aggregates.C new file mode 100644 index 000000000..24f430bd6 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.abi/aggregates.C @@ -0,0 +1,126 @@ +// { dg-do run { target i?86-*-linux* x86_64-*-linux* i?86-*-freebsd* } } +// { dg-require-effective-target ilp32 } +// { dg-options "-malign-double" } +// Origin: Alex Samuel <samuel@codesourcery.com> + +/* Test the data layout of C aggregates by checking aggregate size and + alignment and field offsets for compliance with the IA-64 ABI. */ + +template<typename T> +inline unsigned +alignmentof () +{ + struct S + { + char start_; + T object_; + }; + + return (unsigned) & ((S *) 0)->object_; +} + +/* Computes the alignment, in bytes, of TYPE. */ + +#define alignof(type) (alignmentof<type> ()) + +/* Computes the offset of FIELD in AGGREGATE. */ + +#define offsetof(aggregate, field) \ + ((unsigned) (& ((aggregate*) 0)->field)) + + +/* Structs S1, S2, S3, S4, and union U5 are taken from Intel, "IA-64 + Software Conventions and Runtime Architecture Guide", version of + August 1999. */ + +struct S1 +{ + char c; +}; + +struct S2 +{ + char c; + char d; + short s; + int n; +}; + +struct S3 +{ + char c; + short s; +}; + +struct S4 +{ + char c; + double d; + short s; +}; + +union U5 +{ + char c; + short s; + int j; +}; + + + +int +main () +{ + if (sizeof (struct S1) != 1) + return 1; + if (alignof (struct S1) != 1) + return 2; + if (offsetof (struct S1, c) != 0) + return 3; + + if (sizeof (struct S2) != 8) + return 4; + if (alignof (struct S2) != 4) + return 5; + if (offsetof (struct S2, c) != 0) + return 6; + if (offsetof (struct S2, d) != 1) + return 7; + if (offsetof (struct S2, s) != 2) + return 8; + if (offsetof (struct S2, n) != 4) + return 9; + + if (sizeof (struct S3) != 4) + return 10; + if (alignof (struct S3) != 2) + return 11; + if (offsetof (struct S3, c) != 0) + return 12; + if (offsetof (struct S3, s) != 2) + return 13; + + if (sizeof (struct S4) != 24) + return 14; + if (alignof (struct S4) != 8) + return 15; + if (offsetof (struct S4, c) != 0) + return 16; + if (offsetof (struct S4, d) != 8) + return 17; + if (offsetof (struct S4, s) != 16) + return 18; + + if (sizeof (union U5) != 4) + return 19; + if (alignof (union U5) != 4) + return 20; + if (offsetof (union U5, c) != 0) + return 21; + if (offsetof (union U5, s) != 0) + return 22; + if (offsetof (union U5, j) != 0) + return 23; + + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.abi/align.C b/gcc/testsuite/g++.old-deja/g++.abi/align.C new file mode 100644 index 000000000..037add32c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.abi/align.C @@ -0,0 +1,125 @@ +// { dg-do run { target i?86-*-linux* x86_64-*-linux* i?86-*-freebsd* i?86-*-darwin* } } +// { dg-require-effective-target ilp32 } +// { dg-options "-malign-double" } +// Origin: Alex Samuel <samuel@codesourcery.com> + +/* Test the size and alignment of fundamental C types for compliance + with the IA-64 ABI. */ + +template<typename T> +inline unsigned +alignmentof () +{ + struct S + { + char start_; + T object_; + }; + + return (unsigned) & ((S *) 0)->object_; +} + +/* Computes the alignment, in bytes, of TYPE. */ + +#define alignof(type) (alignmentof<type> ()) + +enum A { a }; + +int +main () +{ + if (sizeof (char) != 1) + return 1; + if (alignof (char) != 1) + return 2; + if (sizeof (signed char) != 1) + return 3; + if (alignof (signed char) != 1) + return 4; + if (sizeof (unsigned char) != 1) + return 5; + if (alignof (unsigned char) != 1) + return 6; + if (sizeof (short) != 2) + return 7; + if (alignof (short) != 2) + return 8; + if (sizeof (signed short) != 2) + return 9; + if (alignof (signed short) != 2) + return 10; + if (sizeof (unsigned short) != 2) + return 11; + if (alignof (unsigned short) != 2) + return 12; + if (sizeof (int) != 4) + return 13; + if (alignof (int) != 4) + return 14; + if (sizeof (signed int) != 4) + return 15; + if (alignof (signed int) != 4) + return 16; + if (sizeof (unsigned int) != 4) + return 17; + if (alignof (unsigned int) != 4) + return 18; + if (sizeof (enum A) != 4) + return 19; + if (alignof (enum A) != 4) + return 20; +#ifdef HAVE_IA64_TYPES + if (sizeof (__int64) != 8) + return 21; + if (alignof (__int64) != 8) + return 22; + if (sizeof (signed __int64) != 8) + return 23; + if (alignof (signed ___int64) != 8) + return 24; + if (sizeof (unsigned __int64) != 8) + return 25; + if (alignof (unsigned __int64) != 8) + return 26; + if (sizeof (__int128) != 16) + return 27; + if (alignof (__int128) != 16) + return 28; + if (sizeof (signed __int128) != 16) + return 29; + if (alignof (signed ___int128) != 16) + return 30; + if (sizeof (unsigned __int128) != 16) + return 31; + if (alignof (unsigned ___int128) != 16) + return 32; +#endif /* HAVE_IA64_TYPES */ + if (sizeof (void *) != 4) + return 33; + if (alignof (void *) != 4) + return 34; + if (sizeof (void (*) ()) != 4) + return 35; + if (alignof (void (*) ()) != 4) + return 36; + if (sizeof (float) != 4) + return 37; + if (alignof (float) != 4) + return 38; + if (sizeof (double) != 8) + return 39; + if (alignof (double) != 8) + return 40; +#ifdef HAVE_IA64_TYPES + if (sizeof (__float80) != 16) + return 41; + if (alignof (__float80) != 16) + return 42; + if (sizeof (__float128) != 16) + return 43; + if (alignof (__float128) != 16) + return 44; +#endif /* HAVE_IA64_TYPES */ + + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.abi/arraynew.C b/gcc/testsuite/g++.old-deja/g++.abi/arraynew.C new file mode 100644 index 000000000..ff19c7e37 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.abi/arraynew.C @@ -0,0 +1,152 @@ +// { dg-do run } +// Origin: Mark Mitchell <mark@codesourcery.com> + +#if defined (__GXX_ABI_VERSION) && __GXX_ABI_VERSION >= 100 + +#include <cstdlib> +#include <new> + +void* p; + +void* operator new[](size_t s) throw (std::bad_alloc) +{ + // Record the base of the last array allocated. + p = malloc (s); + return p; +} + +template <typename T> +void check_no_cookie (int i) +{ + void* a = new T[7]; + if (p != a) + exit (i); +} + +template <typename T> +void check_no_placement_cookie (int i) +{ + p = malloc (13 * sizeof (T)); + void* a = new (p) T[13]; + if (p != a) + exit (i); +} + +template <typename T> +void check_cookie (int i) +{ + void* a = new T[11]; + size_t x; + + // Compute the cookie location manually. +#ifdef __ARM_EABI__ + x = 8; +#else + x = __alignof__ (T); + if (x < sizeof (size_t)) + x = sizeof (size_t); +#endif + if ((char *) a - x != (char *) p) + exit (i); + + // Check the cookie value. + size_t *sp = ((size_t *) a) - 1; + if (*sp != 11) + exit (i); + +#ifdef __ARM_EABI__ + sp = ((size_t *) a) - 2; + if (*sp != sizeof (T)) + exit (i); +#endif +} + +template <typename T> +void check_placement_cookie (int i) +{ + p = malloc (sizeof (T) * 11 + 100); + void* a = new (p) T[11]; + size_t x; + + // Compute the cookie location manually. +#ifdef __ARM_EABI__ + x = 8; +#else + x = __alignof__ (T); + if (x < sizeof (size_t)) + x = sizeof (size_t); +#endif + if ((char *) a - x != (char *) p) + exit (i); + + // Check the cookie value. + size_t *sp = ((size_t *) a) - 1; + if (*sp != 11) + exit (i); + +#ifdef __ARM_EABI__ + sp = ((size_t *) a) - 2; + if (*sp != sizeof (T)) + exit (i); +#endif +} + +struct X {}; + +template <typename T> +struct Y { int i; virtual void f () {} }; + +// A class with a non-trivial destructor -- it needs a cookie. +struct Z { ~Z () {} }; +// Likewise, but this class needs a bigger cookie so that the array +// elements are correctly aligned. +struct Z2 { ~Z2 () {} long double d; }; + +struct W1 { void operator delete[] (void *, size_t) {} }; +struct W2 { void operator delete[] (void *) {} + void operator delete[] (void *, size_t) {} }; +struct W3 { void operator delete[] (void *, size_t) {} + void operator delete[] (void *) {} }; +struct W4 : public W1 {}; + +struct V { void *operator new[] (size_t s, void *p) + { return p; } + ~V () {} + }; + +int main () +{ + // There should be no cookies for types with trivial destructors. + check_no_cookie<int> (1); + check_no_cookie<X> (2); + check_no_cookie<Y<double> > (3); + + // There should be no cookies for allocations using global placement + // new. + check_no_placement_cookie<int> (4); + check_no_placement_cookie<X> (5); + check_no_placement_cookie<Z> (6); + + // There should be a cookie when using a non-trivial destructor. + check_cookie<Z> (7); + check_cookie<Z2> (8); + + // There should be a cookie when using the two-argument array delete + // operator. + check_cookie<W1> (9); + check_cookie<W4> (10); + // But not when the one-argument version is also available. + check_no_cookie<W2> (11); + check_no_cookie<W3> (12); + + // There should be a cookie when using a non-global placement new. + check_placement_cookie<V> (13); +} + +#else /* !(defined (__GXX_ABI_VERSION) && __GXX_ABI_VERSION >= 100) */ + +int main () +{ +} + +#endif /* !(defined (__GXX_ABI_VERSION) && __GXX_ABI_VERSION >= 100) */ diff --git a/gcc/testsuite/g++.old-deja/g++.abi/bitfields.C b/gcc/testsuite/g++.old-deja/g++.abi/bitfields.C new file mode 100644 index 000000000..d5c319209 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.abi/bitfields.C @@ -0,0 +1,160 @@ +// { dg-do run { target i?86-*-linux* x86_64-*-linux* i?86-*-freebsd* } } +// { dg-require-effective-target ilp32 } +// { dg-options "-malign-double" } +// Origin: Alex Samuel <samuel@codesourcery.com> + +/* Test the layout of bitfields in C aggretagtes for compliance with + the IA-64 ABI. */ + +#include <cstring> + +template<typename T> +inline unsigned +alignmentof () +{ + struct S + { + char start_; + T object_; + }; + + return (unsigned) & ((S *) 0)->object_; +} + +/* Computes the alignment, in bytes, of TYPE. */ + +#define alignof(type) (alignmentof<type> ()) + +/* Returns true iff all the bits in the range + START_BIT <= bit < START_BIT + NUM_BITS, and only those bits, are + set in the region of memory starting at BUF of LENGTH bytes. */ + +bool +check_bits (char *buf, + unsigned length, + unsigned start_bit, + unsigned num_bits) +{ + for (unsigned bit = 0; bit < 8 * length; ++bit) { + bool is_set = (buf[bit / 8] & (1 << (bit % 8))) != 0; + if (start_bit <= bit && bit < start_bit + num_bits) { + if (! is_set) + return false; + } + else { + if (is_set) + return false; + } + } + return true; +} + +/* Creates a variable of type AGGREGATE, sets FIELD to -1, and + verifies that NUM_BITS bits starting at START_BIT, and no other + bits, are set. If the check fails, returns with value RVAL. */ + +#define CHECK_FIELD(AGGREGATE, FIELD, START_BIT, NUM_BITS, RVAL) \ + do { \ + AGGREGATE a__; \ + std::memset (& a__, 0, sizeof (a__)); \ + a__.FIELD = -1; \ + if (! check_bits ((char *) & a__, sizeof (a__), START_BIT, NUM_BITS)) \ + return RVAL; \ + } while (0); + + + +/* Structs S1, S2, S3, S4, and union U5 are taken from Intel, "IA-64 + Software Conventions and Runtime Architecture Guide", version of + August 1999. */ + +struct S1 +{ + int j : 5; + int k : 6; + int m : 7; +}; + +#ifdef HAVE_IA64_TYPES +struct S2 +{ + short s : 9; + __int64 j : 9; + char c ; + short t : 9; + short u : 9; + char d ; +}; +#endif /* HAVE_IA64_TYPES */ + +struct S3 +{ + char c ; + short s : 8; +}; + +union U4 +{ + char c ; + short s : 8; +}; + +struct S5 +{ + char c ; + int : 0; + char d ; + short : 9; + char e ; + char : 0; +}; + + +int +main () +{ + if (sizeof (struct S1) != 4) + return 1; + if (alignof (struct S1) != 4) + return 2; + CHECK_FIELD (S1, j, 0, 5, 3); + CHECK_FIELD (S1, k, 5, 6, 4); + CHECK_FIELD (S1, m, 11, 7, 5); + +#ifdef HAVE_IA64_TYPES + if (sizeof (struct S2) != 16) + return 6; + if (alignof (struct S2) != 8) + return 7; + CHECK_FIELD (S2, s, 0, 9, 8); + CHECK_FIELD (S2, j, 9, 9, 9); + CHECK_FIELD (S2, c, 24, 8, 10); + CHECK_FIELD (S2, t, 32, 9, 11); + CHECK_FIELD (S2, u, 48, 9, 12); + CHECK_FIELD (S2, d, 64, 8, 13); +#endif /* HAVE_IA64_TYPES */ + + if (sizeof (struct S3) != 2) + return 14; + if (sizeof (struct S3) != 2) + return 15; + CHECK_FIELD (S3, c, 0, 8, 16); + CHECK_FIELD (S3, s, 8, 8, 17); + + if (sizeof (union U4) != 2) + return 18; + if (alignof (union U4) != 2) + return 19; + CHECK_FIELD (U4, c, 0, 8, 20); + CHECK_FIELD (U4, s, 0, 8, 21); + + if (sizeof (struct S5) != 9) + return 22; + if (alignof (struct S5) != 1) + return 23; + CHECK_FIELD (S5, c, 0, 8, 24); + CHECK_FIELD (S5, d, 32, 8, 25); + CHECK_FIELD (S5, e, 64, 8, 26); + + return 0; +} 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 000000000..c5f3d5532 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.abi/crash1.C @@ -0,0 +1,21 @@ +// { dg-do assemble } +// +// 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 new file mode 100644 index 000000000..5370fb898 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.abi/cxa_vec.C @@ -0,0 +1,290 @@ +// This test fails on VxWorks in kernel mode because it depends on the +// library version of "::operator new[]" calling the "::operator new" +// defined in this module. This doesn't work because the library version +// of "::operator new[]" is built into the kernel itself; library relocations +// are resolved when the kernel is linked. +// { dg-do run { xfail { powerpc-ibm-aix* || vxworks_kernel } } } +// { dg-options "-flat_namespace" { target *-*-darwin[67]* } } +// Test __cxa_vec routines +// Copyright (C) 2000, 2005 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 <stdlib.h> +#include <setjmp.h> + +static int ctor_count = 0; +static int dtor_count = 0; +static bool dtor_repeat = false; + +// Allocate enough padding to hold an array cookie. +#ifdef __ARM_EABI__ +#define padding 8 +#else +#define padding (sizeof (std::size_t)) +#endif + +// our pseudo ctors and dtors +static abi::__cxa_cdtor_return_type ctor (void *x) +{ + if (!ctor_count) + throw 1; + ctor_count--; +#ifdef __ARM_EABI__ + return x; +#endif +} + +static abi::__cxa_cdtor_return_type dtor (void *x) +{ + if (!dtor_count) + { + if (!dtor_repeat) + dtor_count--; + throw 1; + } + dtor_count--; +#ifdef __ARM_EABI__ + return x; +#endif +} + +// track new and delete +static int blocks = 0; +void *operator new[] (std::size_t size) throw (std::bad_alloc) +{ + void *ptr = malloc (size); + + if (!ptr) + throw std::bad_alloc (); + blocks++; + return ptr; +} + +void operator delete[] (void *ptr) throw () +{ + if (ptr) + { + free (ptr); + blocks--; + } +} +static jmp_buf jump; + +// allocate and delete an array with no problems +void test0 () +{ + static bool started = false; + + if (!started) + { + started = true; + std::set_terminate (test0); + + ctor_count = dtor_count = 5; + dtor_repeat = false; + blocks = 0; + + try + { + void *ary = abi::__cxa_vec_new (5, 1, padding, ctor, dtor); + abi::__cxa_vec_delete (ary, 1, padding, dtor); + if (ctor_count || dtor_count || blocks) + longjmp (jump, 1); + } + catch (...) + { + longjmp (jump, 2); + } + } + else + { + longjmp (jump, 3); + } + return; +} + +// allocate and delete an array with exception on ctor +void test1 () +{ + static bool started = false; + + if (!started) + { + started = true; + std::set_terminate (test1); + + ctor_count = dtor_count = 5; + dtor_repeat = false; + blocks = 0; + + ctor_count = 4; + try + { + void *ary = abi::__cxa_vec_new (5, 1, padding, ctor, dtor); + longjmp (jump, 1); + } + catch (...) + { + // we expect to get here + if (ctor_count || dtor_count != 1 || blocks) + longjmp (jump, 2); + } + } + else + { + longjmp (jump, 3); + } + return; +} + +// allocate and delete an array with exception on dtor +void test2 () +{ + static bool started = false; + + if (!started) + { + started = true; + std::set_terminate (test2); + ctor_count = dtor_count = 5; + dtor_repeat = false; + blocks = 0; + + dtor_count = 3; + try + { + void *ary = abi::__cxa_vec_new (5, 1, padding, ctor, dtor); + abi::__cxa_vec_delete (ary, 1, padding, dtor); + longjmp (jump, 1); + } + catch (...) + { + // we expect to get here + if (ctor_count || dtor_count != -2u || blocks) + longjmp (jump, 2); + } + } + else + { + longjmp (jump, 3); + } + return; +} + +// allocate an array with double exception on dtor +void test3 () +{ + static bool started = false; + + if (!started) + { + started = true; + std::set_terminate (test3); + + ctor_count = dtor_count = 5; + dtor_repeat = false; + blocks = 0; + + dtor_count = 3; + dtor_repeat = true; + try + { + void *ary = abi::__cxa_vec_new (5, 1, padding, ctor, dtor); + abi::__cxa_vec_delete (ary, 1, padding, dtor); + longjmp (jump, 1); + } + catch (...) + { + // we do not expect to get here + longjmp (jump, 2); + } + } + else + { + // we expect to get here (via terminate) + if (ctor_count || dtor_count || blocks != 1) + longjmp (jump, 3); + longjmp (jump, -1); + } + return; +} + +// allocate an array with exception on ctor and exception in cleanup +void test4 () +{ + static bool started = false; + + if (!started) + { + started = true; + std::set_terminate (test4); + + ctor_count = dtor_count = 5; + dtor_repeat = false; + blocks = 0; + + ctor_count = 3; + dtor_count = 2; + try + { + void *ary = abi::__cxa_vec_new (5, 1, padding, ctor, dtor); + longjmp (jump, 1); + } + catch (...) + { + // we do not expect to get here + longjmp (jump, 2); + } + } + else + { + // we expect to get here (via terminate) + if (ctor_count || dtor_count != -1u || blocks != 1) + longjmp (jump, 3); + longjmp (jump, -1); + } + return; +} + +static void (*tests[])() = +{ + test0, + test1, + test2, + test3, + test4, + NULL +}; + +int main () +{ + int ix; + int n; + int errors = 0; + + for (ix = 0; tests[ix]; ix++) + { + if (n = setjmp (jump)) + { + if (n > 0) + { + printf ("test %d failed %d\n", ix, n); + errors++; + } + } + else + tests[ix] (); + } + return errors; +} + +#else +int main () +{ + return 0; +} +#endif diff --git a/gcc/testsuite/g++.old-deja/g++.abi/empty.C b/gcc/testsuite/g++.old-deja/g++.abi/empty.C new file mode 100644 index 000000000..40aac9e9d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.abi/empty.C @@ -0,0 +1,69 @@ +// { dg-do run } +// { dg-options "-w" } +// Origin: Mark Mitchell <mark@codesourcery.com> + +#if defined (__GXX_ABI_VERSION) && __GXX_ABI_VERSION >= 100 + +struct S0 +{ +}; + +struct S1 : public S0 +{ +}; + +struct S2 : public S1 +{ + char c; +}; + +// In S3, the S1 instance is allocated first at offset zero. The S2 +// instance has to be allocated at a subsequent offset; it's first +// part is also an S1. + +struct S3 : public S1, public S2 +{ +}; + +struct S4 +{ + int i; +}; + +// In S4, in contrast to S3, S2 is allocated first, and S1 can be +// allocated on top of S4. + +struct S5 : public S2, public S1, public S4 +{ +}; + +// The T classes are by-hand layouts that should be equivalent to the +// S classes. + +struct T3 +{ + S1 s1; + S2 s2; +}; + +struct T5 +{ + S2 s2; + S4 s4; +}; + +int main () +{ + if (sizeof (S3) != sizeof (T3)) + return 1; + else if (sizeof (S5) != sizeof (T5)) + return 2; +} + +#else /* !(defined (__GXX_ABI_VERSION) && __GXX_ABI_VERSION >= 100) */ + +int main () +{ +} + +#endif /* !(defined (__GXX_ABI_VERSION) && __GXX_ABI_VERSION >= 100) */ 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 000000000..65d6a4594 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.abi/empty2.C @@ -0,0 +1,136 @@ +// { dg-do assemble } + +// 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 000000000..071431c5c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.abi/empty3.C @@ -0,0 +1,24 @@ +// { dg-do assemble } + +// 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/layout1.C b/gcc/testsuite/g++.old-deja/g++.abi/layout1.C new file mode 100644 index 000000000..23fd891c8 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.abi/layout1.C @@ -0,0 +1,52 @@ +// { dg-do run } +// Origin: Mark Mitchell <mark@codesourcery.com> + +#if defined (__GXX_ABI_VERSION) && __GXX_ABI_VERSION >= 100 + +struct R +{ + virtual void r (); +}; + +struct S +{ + virtual void f (); +}; + +struct T : virtual public S +{ + virtual void g (); +}; + +struct U : public R, virtual public T +{ + virtual void h (); +}; + +struct V : public R, virtual public S, virtual public T +{ + virtual void v (); +}; + +struct U1 +{ + R r; + T t; +}; + +int main () +{ + if (sizeof (U) != sizeof (U1)) + return 1; + if (sizeof (V) != sizeof (U1)) + return 2; +} + +#else /* !(defined (__GXX_ABI_VERSION) && __GXX_ABI_VERSION >= 100) */ + +int main () +{ +} + +#endif /* !(defined (__GXX_ABI_VERSION) && __GXX_ABI_VERSION >= 100) */ + 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 000000000..d738f31b9 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.abi/mangle1.C @@ -0,0 +1,7 @@ +// { dg-do assemble } +// 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/primary.C b/gcc/testsuite/g++.old-deja/g++.abi/primary.C new file mode 100644 index 000000000..692ef3328 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.abi/primary.C @@ -0,0 +1,73 @@ +// { dg-do run } +// Test to see that primary bases are selected correctly. +// Origin: Mark Mitchell <mark@codesourcery.com> + +#if defined (__GXX_ABI_VERSION) && __GXX_ABI_VERSION >= 100 + +// S1 is a nearly-empty base. + +struct S1 +{ + virtual void f () + { + } +}; + +// S2 is a dynamic, but not nearly-empty, base. + +struct S2 +{ + virtual void g () + { + } + + int i; +}; + +// S1 should be the primary base. + +struct T1 : public S1, public S2 +{ +}; + +// S2 should be the primary base. + +struct T2 : public S2, public S1 +{ +}; + +// S2 should be the primary base. + +struct T3 : virtual public S1, public S2 +{ +}; + +// S1 should be the primary base. + +struct T4 : virtual public S1, virtual public S2 +{ +}; + +// Check that Y is the primary base for X. Otherwise, return N. +#define CHECK_PRIMARY_BASE(X, Y, N) \ + { \ + X x; \ + if ((void*) &x != (void *) (Y*) (&x)) \ + return N; \ + } + +int main () +{ + CHECK_PRIMARY_BASE (T1, S1, 1); + CHECK_PRIMARY_BASE (T2, S2, 2); + CHECK_PRIMARY_BASE (T3, S2, 3); + CHECK_PRIMARY_BASE (T4, S1, 4); +} + +#else /* !(defined (__GXX_ABI_VERSION) && __GXX_ABI_VERSION >= 100) */ + +int main () +{ +} + +#endif /* !(defined (__GXX_ABI_VERSION) && __GXX_ABI_VERSION >= 100) */ diff --git a/gcc/testsuite/g++.old-deja/g++.abi/primary2.C b/gcc/testsuite/g++.old-deja/g++.abi/primary2.C new file mode 100644 index 000000000..fd440c0b0 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.abi/primary2.C @@ -0,0 +1,22 @@ +// { dg-do run } +// Copyright (C) 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 4 February 2001 <nathan@codesourcery.com> + +// Check primary bases are chosen correctly. + +struct A {virtual void Foo () {}}; +struct B : virtual A {}; +struct C : virtual B {}; +struct D : virtual B, virtual C {}; + +int main () +{ + D d; + +#if __GXX_ABI_VERSION >= 100 + if (sizeof (D) != sizeof (A)) + return 1; +#endif + + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.abi/primary3.C b/gcc/testsuite/g++.old-deja/g++.abi/primary3.C new file mode 100644 index 000000000..3ebc3ec0d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.abi/primary3.C @@ -0,0 +1,45 @@ +// { dg-do run } +// Copyright (C) 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 4 February 2001 <nathan@codesourcery.com> + +// Check primary bases are chosen correctly. + +struct A {virtual void Foo () {}}; +struct B1 : virtual A {}; +struct B2 : virtual A {}; +struct C : virtual B1, B2 {}; +struct D : virtual C {}; + +int main () +{ + C c; + D d; + + A *apc = &c; + B1 *b1pc = &c; + B2 *b2pc = &c; + + 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 *> (&c) != static_cast <void *> (b2pc)) + return 2; + 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/primary4.C b/gcc/testsuite/g++.old-deja/g++.abi/primary4.C new file mode 100644 index 000000000..3e36c58a3 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.abi/primary4.C @@ -0,0 +1,28 @@ +// { dg-do run } +// Copyright (C) 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 4 February 2001 <nathan@codesourcery.com> + +// Check primary bases are chosen correctly. + +struct A { virtual void Foo () {}}; + +struct B1 : virtual A {}; +struct B2 : virtual A {}; + +struct C : virtual B1 {}; + +struct D : virtual B1, B2, C {}; + +int main () +{ + D d; + A *ap = &d; + C *cp = &d; + +#if __GXX_ABI_VERSION >= 100 + if (static_cast <void *> (ap) != static_cast <void *> (cp)) + return 1; +#endif + + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.abi/primary5.C b/gcc/testsuite/g++.old-deja/g++.abi/primary5.C new file mode 100644 index 000000000..07ea2d7d8 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.abi/primary5.C @@ -0,0 +1,37 @@ +// { dg-do run } +// Copyright (C) 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 4 February 2001 <nathan@codesourcery.com> + +// Check primary bases are chosen correctly. + +struct A1 +{ + virtual void Foo () {} +}; + +struct A : A1 +{ +}; + +struct B : A +{ +}; + +struct C : virtual B +{ +}; + +struct D : virtual B, virtual C +{ +}; + +int main() +{ + D d; +#if __GXX_ABI_VERSION >= 100 + if (sizeof (D) != sizeof (A)) + return 1; +#endif + + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.abi/ptrflags.C b/gcc/testsuite/g++.old-deja/g++.abi/ptrflags.C new file mode 100644 index 000000000..d4bdc212e --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.abi/ptrflags.C @@ -0,0 +1,67 @@ +// { dg-do run } +// Test rtti pointer flags +// Copyright (C) 2000, 2002 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 15 Apr 2000 <nathan@nathan@codesourcery.com> + +#include <typeinfo> + +#if defined (__GXX_ABI_VERSION) && __GXX_ABI_VERSION >= 100 +#include <cxxabi.h> + +struct A {int m;}; +struct B; + +using namespace abi; + +int expect (int flags, std::type_info const &info) +{ + abi::__pbase_type_info const *ptr = + dynamic_cast <abi::__pbase_type_info const *> (&info); + if (!ptr) + return 0; + if (ptr->__flags != flags) + return 0; + return 1; +} + +int main () +{ + if (! expect (0, typeid (A *))) + return 1; + if (! expect (1, typeid (A const *))) + return 2; + if (! expect (2, typeid (A volatile *))) + return 3; + if (! expect (4, typeid (A *__restrict__ *))) + return 4; + if (! expect (0, typeid (int A::*))) + return 5; + if (! expect (0, typeid (int A::**))) + return 6; + + if (! expect (8 | 0, typeid (B *))) + return 11; + if (! expect (8 | 1, typeid (B const *))) + return 12; + if (! expect (8 | 2, typeid (B volatile *))) + return 13; + if (! expect (8 | 4, typeid (B *__restrict__ *))) + return 14; + if (! expect (16 | 0, typeid (int B::*))) + return 15; + if (! expect (8 | 0, typeid (int B::**))) + return 16; + if (! expect (8 | 0, typeid (B A::*))) + return 17; + if (! expect (24, typeid (B B::*))) + return 18; + + return 0; +} + +#else +int main () +{ + return 0; +} +#endif diff --git a/gcc/testsuite/g++.old-deja/g++.abi/ptrmem.C b/gcc/testsuite/g++.old-deja/g++.abi/ptrmem.C new file mode 100644 index 000000000..077fa5084 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.abi/ptrmem.C @@ -0,0 +1,146 @@ +// { dg-do run } +// { dg-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 __SH5__ || defined __arm__ || defined __thumb__ || defined __mips__ +#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. + +#include <cstddef> + +struct S +{ + int i; + int j; +}; + +// Because S does not have a VPTR, it will not be a primary base of T, +// and will therefore end up at a nonzero offset. + +struct T : public S +{ + void f () {} + virtual void g () {} + virtual void h () {} +}; + +// Provide access to the raw function pointers. This is +// mangling-dependent. + +extern "C" void _ZN1T1fEv (); +extern "C" void _ZN1T1gEv (); +extern "C" void _ZN1T1hEv (); + +// This structure is a C representation of a pointer-to-member. + +struct ptrmemfunc +{ + void (*ptr) (); + ptrdiff_t adj; +}; + +typedef int S::*sdp; +typedef void (S::*sp)(); +typedef void (T::*tp)(); + +int +main () +{ + S s; + T t; + sp x; + tp y; + ptrmemfunc *xp = (ptrmemfunc *) &x; + ptrmemfunc *yp = (ptrmemfunc *) &y; + ptrdiff_t delta = ((char *) &t) - ((char*) (S*) (&t)); + + // Pointers-to-function-members should have the same size and + // alignment as the PTRMEMFUNC type. + if (sizeof (sp) != sizeof (ptrmemfunc)) + return 1; + if (__alignof__ (sp) != __alignof__ (ptrmemfunc)) + return 2; + + // The NULL pointer-to-member should have a NULL first PTR field. + x = 0; + if (xp->ptr != 0) + return 3; + y = x; + if (yp->ptr != 0) + return 4; + + // A non-virtual function should have a pointer to the function. + // There should be no adjustment for the `T' version, and an + // appropriate adjustment for the `S' version. + y = &T::f; + if (! CMP_PTRFN (yp->ptr, ADJUST_PTRFN (&_ZN1T1fEv, 0))) + return 5; + if (yp->adj != ADJUST_DELTA (0, 0)) + return 6; + x = (sp) y; + if (! CMP_PTRFN (xp->ptr, ADJUST_PTRFN (&_ZN1T1fEv, 0))) + return 7; + 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 (yp->ptr != ADJUST_PTRFN (VPTE_SIZE, 1)) + return 9; + if (yp->adj != ADJUST_DELTA (0, 1)) + return 10; + x = (sp) y; + if (xp->ptr != ADJUST_PTRFN (VPTE_SIZE, 1)) + return 11; + if (xp->adj != ADJUST_DELTA (delta, 1)) + return 12; + + // Pointers-to-data-members should have the same size and alignment + // as a ptrdiff_t. + if (sizeof (sdp) != sizeof (ptrdiff_t)) + return 13; + if (__alignof__ (sdp) != __alignof__ (ptrdiff_t)) + return 14; + + // The value of a pointer-to-data member should be the offset from + // the start of the structure. + sdp z = &S::j; + if ((char *) &s.j - (char *) &s != *((ptrdiff_t *) &z)) + return 15; + z = 0; + if (*((ptrdiff_t *) &z) != -1) + return 16; +} + +#else /* !(defined (__GXX_ABI_VERSION) && __GXX_ABI_VERSION >= 100) */ + +int main () +{ +} + +#endif /* !(defined (__GXX_ABI_VERSION) && __GXX_ABI_VERSION >= 100) */ diff --git a/gcc/testsuite/g++.old-deja/g++.abi/vbase1.C b/gcc/testsuite/g++.old-deja/g++.abi/vbase1.C new file mode 100644 index 000000000..680bec737 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.abi/vbase1.C @@ -0,0 +1,115 @@ +// { dg-do run } +// Copyright (C) 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 16 Jan 2001 <nathan@codesourcery.com> + +// Bug 1611. Under the new ABI, the vtable can be clobbered during dtoring our +// primary vbase. We mustn't use the vtable after that to locate our vbases. + +#if defined (__GXX_ABI_VERSION) && __GXX_ABI_VERSION >= 100 +#include <stdio.h> +#include <stdlib.h> + +int *ctorVBase = 0; +int *dtorVBase = 0; +int *ctorVDerived = 0; +int *dtorVDerived = 0; +int *ctorB = 0; +int *dtorB = 0; + +struct VBase +{ + int member; + VBase () + { + if (ctorVBase) exit (1); + ctorVBase = &member; + } + virtual ~VBase () + { + if (dtorVBase) exit (2); + dtorVBase = &member; + if (dtorVBase != ctorVBase) exit (3); + } + void Offset () const + { + printf ("VBase\n"); + printf (" VBase::member %d\n", &this->VBase::member - (int *)this); + } +}; + +struct VDerived : virtual VBase +{ + int member; + + VDerived () + { + if (ctorVDerived) exit (4); + ctorVDerived = &member; + } + virtual ~VDerived () + { + if (dtorVDerived) exit (5); + dtorVDerived = &member; + if (dtorVDerived != ctorVDerived) exit (6); + } + void Offset () const + { + printf ("VDerived\n"); + printf (" VBase::member %d\n", &this->VBase::member - (int *)this); + printf (" VDerived::member %d\n", &this->VDerived::member - (int *)this); + } +}; +struct B : virtual VBase +{ + int member; + void Offset () const + { + printf ("B\n"); + printf (" VBase::member %d\n", &this->VBase::member - (int *)this); + printf (" B::member %d\n", &this->B::member - (int *)this); + } +}; +struct MostDerived : B, virtual VDerived +{ + int member; + void Offset () const + { + printf ("MostDerived\n"); + printf (" VBase::member %d\n", &this->VBase::member - (int *)this); + printf (" B::member %d\n", &this->B::member - (int *)this); + printf (" VDerived::member %d\n", &this->VDerived::member - (int *)this); + printf (" MostDerived::member %d\n", &this->MostDerived::member - (int *)this); + } +}; + + +int main () +{ + { + MostDerived dum; + + int *this_ = (int *)&dum; + + if (ctorVBase != &dum.VBase::member) + return 23; + if (ctorVDerived != &dum.VDerived::member) + return 24; + + printf (" VBase::member %d\n", &dum.VBase::member - this_); + printf (" B::member %d\n", &dum.B::member - this_); + printf (" VDerived::member %d\n", &dum.VDerived::member - this_); + printf (" MostDerived::member %d\n", &dum.MostDerived::member - this_); + dum.MostDerived::Offset (); + dum.B::Offset (); + dum.VDerived::Offset (); + dum.VBase::Offset (); + } + return 0; +} +#else /* !(defined (__GXX_ABI_VERSION) && __GXX_ABI_VERSION >= 100) */ + +int main () +{ +} + +#endif /* !(defined (__GXX_ABI_VERSION) && __GXX_ABI_VERSION >= 100) */ 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 000000000..8c2cdfb4a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.abi/vbase2.C @@ -0,0 +1,28 @@ +// { dg-do run } +// 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 000000000..11d49d4a1 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.abi/vbase3.C @@ -0,0 +1,27 @@ +// { dg-do run } +// 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 000000000..8b083947e --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.abi/vbase4.C @@ -0,0 +1,166 @@ +// { dg-do run } +// 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 000000000..4e1b4efbd --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.abi/vbase5.C @@ -0,0 +1,22 @@ +// { dg-do assemble } +// +// 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 000000000..69764936d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.abi/vbase6.C @@ -0,0 +1,22 @@ +// { dg-do assemble } +// +// 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 000000000..a9d5e50a4 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.abi/vbase7.C @@ -0,0 +1,41 @@ +// { dg-do run } +// 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-5.C b/gcc/testsuite/g++.old-deja/g++.abi/vbase8-5.C new file mode 100644 index 000000000..704f91a7a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.abi/vbase8-5.C @@ -0,0 +1,80 @@ +// { dg-do run } +// { dg-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 000000000..bc922e85c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.abi/vbase8-9.C @@ -0,0 +1,77 @@ +// { dg-do run } +// { dg-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/vmihint.C b/gcc/testsuite/g++.old-deja/g++.abi/vmihint.C new file mode 100644 index 000000000..fd9f3766f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.abi/vmihint.C @@ -0,0 +1,71 @@ +// { dg-do run } +// Test rtti hint flags +// Copyright (C) 2000, 2003 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 3 Apr 2000 <nathan@nathan@codesourcery.com> + +#include <typeinfo> + +#if defined (__GXX_ABI_VERSION) && __GXX_ABI_VERSION >= 100 +#include <cxxabi.h> + +struct A {int m;}; +struct A1vA : virtual A {int m;}; +struct A2vA : virtual A {int m;}; +struct A1A : A {int m;}; +struct A2A : A {int m;}; +struct B {int m;}; + +struct C1 : B, virtual A {int m;}; + +struct D1 : A1vA, A2vA {int m;}; + +struct E1 : A1A, A2A {int m;}; + +struct E2 : A1A, A2vA {int m;}; + +struct F1 : A1A, A1vA, A2vA {int m;}; + +struct P1 : protected A {int m;}; + +struct P2 : B, P1 {int m;}; + +using namespace abi; + +int expect (int flags, std::type_info const &info) +{ + abi::__vmi_class_type_info const *ptr = + dynamic_cast <abi::__vmi_class_type_info const *> (&info); + if (!ptr) + return 0; + if (ptr->__flags != flags) + return 0; + return 1; +} + +int main () +{ + if (! expect (0, typeid (C1))) + return 1; + if (! expect (2, typeid (D1))) + return 2; + if (! expect (1, typeid (E1))) + return 3; + if (! expect (1, typeid (E2))) + return 4; + if (! expect (3, typeid (F1))) + return 5; + + if (!expect (0, typeid (P1))) + return 6; + if (!expect (0, typeid (P2))) + return 7; + + return 0; +} + +#else +int main () +{ + return 0; +} +#endif diff --git a/gcc/testsuite/g++.old-deja/g++.abi/vtable.C b/gcc/testsuite/g++.old-deja/g++.abi/vtable.C new file mode 100644 index 000000000..b93710af7 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.abi/vtable.C @@ -0,0 +1,83 @@ +// { dg-do run } +// { dg-options "-fno-strict-aliasing" } +// Test various aspects of vtable layout. +// Origin: Mark Mitchell <mark@codesourcery.com> + +#if defined (__GXX_ABI_VERSION) && __GXX_ABI_VERSION >= 100 + +struct S0 +{ + virtual void h () + { + } + + int k; +}; + + +struct S1 +{ + virtual void f () + { + } + + int i; +}; + +struct S2 : virtual public S0 +{ + virtual void g () + { + } + + int j; +}; + +struct S3 +{ + virtual void k () + { + } + + int l; +}; + +struct S4 : public virtual S1, public S2, public S3 +{ +}; + +inline void* vtable (void *object) +{ + // The vptr is always the first part of the object. + return * (void **) object; +} + +int main () +{ + // The vtable layout order for S4 should consist of S4's primary + // vtable (shared with S2), followed by the vtable for S3 (because + // it is a non-virtual base). Then, these should be followed by the + // the vtables for S1 and S0, which are virtual. + S4 s4; + S0 *s0 = &s4; + S1 *s1 = &s4; + S2 *s2 = &s4; + S3 *s3 = &s4; + + if (vtable (&s4) != vtable (s2)) + return 1; + if (vtable (s2) >= vtable (s3)) + return 2; + if (vtable (s3) >= vtable (s1)) + return 3; + if (vtable (s1) >= vtable (s0)) + return 4; +} + +#else /* !(defined (__GXX_ABI_VERSION) && __GXX_ABI_VERSION >= 100) */ + +int main () +{ +} + +#endif /* !(defined (__GXX_ABI_VERSION) && __GXX_ABI_VERSION >= 100) */ diff --git a/gcc/testsuite/g++.old-deja/g++.abi/vtable2.C b/gcc/testsuite/g++.old-deja/g++.abi/vtable2.C new file mode 100644 index 000000000..b64f0fc25 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.abi/vtable2.C @@ -0,0 +1,213 @@ +// { dg-do run } +// { dg-options "-fno-strict-aliasing" } +// Origin: Mark Mitchell <mark@codesourcery.com> + +#if defined (__GXX_ABI_VERSION) && __GXX_ABI_VERSION >= 100 + +#include <stddef.h> + +struct S0 +{ + virtual void s0 (); +}; + +struct S1 : virtual public S0 +{ + virtual void s1 (); +}; + +struct S2 : virtual public S1 +{ + virtual void s1 (); + virtual void s0 (); +}; + +struct S3 +{ + virtual void s3 (); +}; + +struct S4 : public S3, virtual public S2 +{ + virtual void s1 (); +}; + +void S0::s0 () +{ +} + +void S1::s1 () +{ +} + +void S2::s1 () +{ +} + +void S2::s0 () +{ +} + +void S3::s3 () +{ +} + +void S4::s1 () +{ +} + +/* The vtables should look like: + + S0 primary vtable + + S0 offset to top + S0 RTTI + S0::s0 + + ================= + + S1 primary vtable + + S0::s0 vcall offset + S0 vbase offset + S1 offset to top + S1 RTTI + S0::s0 + S1::s1 + + ================= + + S2 primary vtable + + S2::s1 vcall offset + S1 vbase offset + S2::s0 vcall offset + S0 vbase offset + S2 offset to top + S2 RTTI + S2::s0 + S2::s1 + + ================= + + S3 primary vtable + + S3 offset to top + S3 RTTI + S3::s3 + + ================= + + S4 primary vtable + + vbase offset for S0 + vbase offset for S1 + vbase offset for S2 + S4 offset to top + S4 RTTI + S3::s3 + S4::s1 + + S2-in-S4 secondary vtable + + S1 vbase offset + S4::s1 vcall offset + S0 vbase offset + S2:s0 vcall offset + S2 offset to top + S4 RTTI + S2::s0 + S4::s1 + +*/ + +// These are tricks to allow us to get raw function pointers for +// member functions. +extern "C" { + /* We can use weakref here without dg-require-weak, because we know + the symbols are defined, so we don't actually issue the .weak + directives. */ + static void S3_s3 () __attribute__((__weakref__ ("_ZN2S32s3Ev"))); + static void S4_s1 () __attribute__((__weakref__ ("_ZN2S42s1Ev"))); +} + +// IA-64 uses function descriptors not function pointers in its vtables. +#if defined __ia64__ +#define CMP_VPTR(A, B) (*(void **)(A) == *(void **)(B)) +#ifdef _LP64 +#define INC_VPTR(A) ((A) += 2) +#define INC_VDATA(A,N) ((A) += (N)) +#else +#define INC_VPTR(A) ((A) += 4) +#define INC_VDATA(A,N) ((A) += 2*(N)) +#endif +#else +#define CMP_VPTR(A, B) (*(A) == (ptrdiff_t)(B)) +#define INC_VPTR(A) ((A) += 1) +#define INC_VDATA(A,N) ((A) += (N)) +#endif + +int main () +{ + S4 s4; + ptrdiff_t **vptr; + ptrdiff_t *vtbl; + + // Set vtbl to point at the beginning of S4's primary vtable. + vptr = (ptrdiff_t **) &s4; + vtbl = *vptr; + INC_VDATA (vtbl, -5); + + if (*vtbl != ((char*) (S0*) &s4) - (char*) &s4) + return 1; + INC_VDATA (vtbl, 1); + if (*vtbl != ((char*) (S1*) &s4) - (char*) &s4) + return 2; + INC_VDATA (vtbl, 1); + if (*vtbl != ((char*) (S2*) &s4) - (char*) &s4) + return 3; + INC_VDATA (vtbl, 1); + if (*vtbl != 0) + return 4; + INC_VDATA (vtbl, 1); + // Skip the RTTI entry. + INC_VDATA (vtbl, 1); + if (! CMP_VPTR (vtbl, &S3_s3)) + return 5; + INC_VPTR (vtbl); + if (! CMP_VPTR (vtbl, &S4_s1)) + return 6; + INC_VPTR (vtbl); + // The S1 vbase offset. + if (*vtbl != 0) + return 7; + INC_VDATA (vtbl, 1); + // The S4::s1 vcall offset is negative; once you convert to S2, you + // have to convert to S4 to find the final overrider. + if (*vtbl != ((char*) &s4 - (char*) (S2*) &s4)) + return 8; + INC_VDATA (vtbl, 1); + if (*vtbl != 0) + return 9; + INC_VDATA (vtbl, 1); + if (*vtbl != 0) + return 10; + INC_VDATA (vtbl, 1); + // Now we're at the S2 offset to top entry. + if (*vtbl != ((char*) &s4 - (char*) (S2*) &s4)) + return 11; + INC_VDATA (vtbl, 1); + // Skip the RTTI entry. + INC_VDATA (vtbl, 1); + // Skip the remaining virtual functions -- they are thunks. + INC_VPTR (vtbl); + INC_VPTR (vtbl); +} + +#else /* !(defined (__GXX_ABI_VERSION) && __GXX_ABI_VERSION >= 100) */ + +int main () +{ +} + +#endif /* !(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 new file mode 100644 index 000000000..ef02456f2 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.abi/vtable3.h @@ -0,0 +1,179 @@ +// Copyright (C) 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 4 February 2001 <nathan@codesourcery.com> + +// Check constructor vtables work. This is included from numerous test +// files, which set the #defines necessary to specify the hierarchy. + +#include <typeinfo> +#include <stdio.h> + +int fail; +struct A; + +template <typename BASE, typename DERIVED> +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) + { + fail++; + fprintf (stderr, "base %s and derived %s have different full objects\n", + typeid (BASE).name (), typeid (DERIVED).name ()); + return 1; + } + + DERIVED *dynamic_d = dynamic_cast <DERIVED *> (b); + + if (dynamic_d != d) + { + fail++; + fprintf (stderr, "dynamic_cast from %s to %s failed\n", + typeid (BASE).name (), typeid (DERIVED).name ()); + return 1; + } + + b->Baz (static_cast <void *> (ap)); + + int res = b->Foo (static_cast <void *> (d)); + + if (res != expect) + { + fail++; + fprintf (stderr, "%s::Foo returned %d, expected %d\n", + typeid (BASE).name (), res, expect); + return 1; + } + + return 0; +} + +template <typename T> +int Test (T *self, void *expected, int result) +{ + if (self != expected) + { + fail++; + fprintf (stderr, "%s::Foo wrong this pointer\n", typeid (T).name ()); + } + return result; +} + +struct A { +#ifndef A_EMPTY + int a_m; +#endif + virtual int Foo (void *p) {return Test (this, p, 1);} + virtual int Baz (void *p) {return Test (this, p, 1);} + A (); + ~A (); +}; + +struct B1: virtual A { +#ifndef B1_EMPTY + int b1_m; +#endif + virtual int Foo (void *p) {return Test (this, p, 2);} + B1(); + ~B1(); +}; + +struct B2: virtual A { +#ifndef B2_EMPTY + int b2_m; +#endif + virtual int Foo (void *p) {return Test (this, p, 3);} + B2(); + ~B2(); +}; + +struct Empty {}; + +struct C : C_PARENTS { +#ifndef C_EMPTY + int c_m; +#endif + virtual int Foo (void *p) {return Test (this, p, 4);} + C(); + ~C(); +}; + +A::A () +{ + fprintf (stderr, "%s\n", __PRETTY_FUNCTION__); + Test <A> (this, 1); +} +A::~A () +{ + fprintf (stderr, "%s\n", __PRETTY_FUNCTION__); + Test <A> (this, 1); +} + +B1::B1() +{ + fprintf (stderr, "%s\n", __PRETTY_FUNCTION__); + Test <A> (this, 2); + Test <B1> (this, 2); +} +B1::~B1() +{ + fprintf (stderr, "%s\n", __PRETTY_FUNCTION__); + Test <A> (this, 2); + Test <B1> (this, 2); +} +B2::B2() +{ + fprintf (stderr, "%s\n", __PRETTY_FUNCTION__); + Test <A> (this, 3); + Test <B2> (this, 3); +} +B2::~B2() +{ + fprintf (stderr, "%s\n", __PRETTY_FUNCTION__); + Test <A> (this, 3); + Test <B2> (this, 3); +} +C::C() +{ + fprintf (stderr, "%s\n", __PRETTY_FUNCTION__); + Test <A> (this, 4); + Test <C> (this, 4); +} +C::~C() +{ + fprintf (stderr, "%s\n", __PRETTY_FUNCTION__); + Test <A> (this, 4); + Test <C> (this, 4); +} + +struct D : C {}; +struct D1 : virtual C {}; +struct D2 : virtual A, virtual C {}; + +int main() +{ + { + fprintf (stderr, "C\n"); + C c; + } + { + fprintf (stderr, "D\n"); + D d; + } + { + fprintf (stderr, "D1\n"); + D1 d1; + } + { + fprintf (stderr, "D2\n"); + D2 d2; + } + if (fail) + fprintf (stderr, "There are %d failings\n", fail); + else + fprintf (stderr, "Passed\n"); + return fail ? 1 : 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.abi/vtable3a.C b/gcc/testsuite/g++.old-deja/g++.abi/vtable3a.C new file mode 100644 index 000000000..d2eaa562d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.abi/vtable3a.C @@ -0,0 +1,23 @@ +// { dg-do run } +// { dg-additional-files "vtable3.h" } + +// Copyright (C) 2000, 2003 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 4 February 2001 <nathan@codesourcery.com> + +// Check constructor vtables work. + +#define A_EMPTY +#define B1_EMPTY +#define B2_EMPTY +#define C_EMPTY +#define C_PARENTS B1, B2 + +#include "vtable3.h" + +/* + A = { vptr } + B1, B2 = { A } + C = { B1, B2 } + D = { C } + D1 = { + */ diff --git a/gcc/testsuite/g++.old-deja/g++.abi/vtable3b.C b/gcc/testsuite/g++.old-deja/g++.abi/vtable3b.C new file mode 100644 index 000000000..1a108f8cc --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.abi/vtable3b.C @@ -0,0 +1,14 @@ +// { dg-do run } +// { dg-additional-files "vtable3.h" } + +// Copyright (C) 2000, 2003 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 4 February 2001 <nathan@codesourcery.com> + +// Check constructor vtables work. + +#define B1_EMPTY +#define B2_EMPTY +#define C_EMPTY +#define C_PARENTS B1, B2 + +#include "vtable3.h" diff --git a/gcc/testsuite/g++.old-deja/g++.abi/vtable3c.C b/gcc/testsuite/g++.old-deja/g++.abi/vtable3c.C new file mode 100644 index 000000000..c7b1365b6 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.abi/vtable3c.C @@ -0,0 +1,14 @@ +// { dg-do run } +// { dg-additional-files "vtable3.h" } + +// Copyright (C) 2000, 2003 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 4 February 2001 <nathan@codesourcery.com> + +// Check constructor vtables work. + +#define A_EMPTY +#define B2_EMPTY +#define C_EMPTY +#define C_PARENTS B1, B2 + +#include "vtable3.h" diff --git a/gcc/testsuite/g++.old-deja/g++.abi/vtable3d.C b/gcc/testsuite/g++.old-deja/g++.abi/vtable3d.C new file mode 100644 index 000000000..82edae697 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.abi/vtable3d.C @@ -0,0 +1,14 @@ +// { dg-do run } +// { dg-additional-files "vtable3.h" } + +// Copyright (C) 2000, 2003 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 4 February 2001 <nathan@codesourcery.com> + +// Check constructor vtables work. + +#define A_EMPTY +#define B1_EMPTY +#define C_EMPTY +#define C_PARENTS B1, B2 + +#include "vtable3.h" diff --git a/gcc/testsuite/g++.old-deja/g++.abi/vtable3e.C b/gcc/testsuite/g++.old-deja/g++.abi/vtable3e.C new file mode 100644 index 000000000..e8469cf42 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.abi/vtable3e.C @@ -0,0 +1,14 @@ +// { dg-do run } +// { dg-additional-files "vtable3.h" } + +// Copyright (C) 2000, 2003 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 4 February 2001 <nathan@codesourcery.com> + +// Check constructor vtables work. + +#define A_EMPTY +#define B1_EMPTY +#define B2_EMPTY +#define C_PARENTS B1, B2 + +#include "vtable3.h" diff --git a/gcc/testsuite/g++.old-deja/g++.abi/vtable3f.C b/gcc/testsuite/g++.old-deja/g++.abi/vtable3f.C new file mode 100644 index 000000000..c604af889 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.abi/vtable3f.C @@ -0,0 +1,15 @@ +// { dg-do run } +// { dg-additional-files "vtable3.h" } + +// Copyright (C) 2000, 2003 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 4 February 2001 <nathan@codesourcery.com> + +// Check constructor vtables work. + +#define A_EMPTY +#define B1_EMPTY +#define B2_EMPTY +#define C_EMPTY +#define C_PARENTS B1, virtual B2 + +#include "vtable3.h" diff --git a/gcc/testsuite/g++.old-deja/g++.abi/vtable3g.C b/gcc/testsuite/g++.old-deja/g++.abi/vtable3g.C new file mode 100644 index 000000000..9218f4077 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.abi/vtable3g.C @@ -0,0 +1,15 @@ +// { dg-do run } +// { dg-additional-files "vtable3.h" } + +// Copyright (C) 2000, 2003 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 4 February 2001 <nathan@codesourcery.com> + +// Check constructor vtables work. + +#define A_EMPTY +#define B1_EMPTY +#define B2_EMPTY +#define C_EMPTY +#define C_PARENTS virtual B1, B2 + +#include "vtable3.h" diff --git a/gcc/testsuite/g++.old-deja/g++.abi/vtable3h.C b/gcc/testsuite/g++.old-deja/g++.abi/vtable3h.C new file mode 100644 index 000000000..1a756fe62 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.abi/vtable3h.C @@ -0,0 +1,15 @@ +// { dg-do run } +// { dg-additional-files "vtable3.h" } + +// Copyright (C) 2000, 2003 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 4 February 2001 <nathan@codesourcery.com> + +// Check constructor vtables work. + +#define A_EMPTY +#define B1_EMPTY +#define B2_EMPTY +#define C_EMPTY +#define C_PARENTS virtual B1, virtual B2 + +#include "vtable3.h" diff --git a/gcc/testsuite/g++.old-deja/g++.abi/vtable3i.C b/gcc/testsuite/g++.old-deja/g++.abi/vtable3i.C new file mode 100644 index 000000000..a71087bd4 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.abi/vtable3i.C @@ -0,0 +1,14 @@ +// { dg-do run } +// { dg-additional-files "vtable3.h" } + +// Copyright (C) 2000, 2003 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 4 February 2001 <nathan@codesourcery.com> + +// Check constructor vtables work. + +#define B1_EMPTY +#define B2_EMPTY +#define C_EMPTY +#define C_PARENTS virtual B1, B2 + +#include "vtable3.h" diff --git a/gcc/testsuite/g++.old-deja/g++.abi/vtable3j.C b/gcc/testsuite/g++.old-deja/g++.abi/vtable3j.C new file mode 100644 index 000000000..de4f590de --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.abi/vtable3j.C @@ -0,0 +1,14 @@ +// { dg-do run } +// { dg-additional-files "vtable3.h" } + +// Copyright (C) 2000, 2003 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 4 February 2001 <nathan@codesourcery.com> + +// Check constructor vtables work. + +#define B1_EMPTY +#define B2_EMPTY +#define C_EMPTY +#define C_PARENTS virtual B1, virtual B2 + +#include "vtable3.h" diff --git a/gcc/testsuite/g++.old-deja/g++.benjamin/13478.C b/gcc/testsuite/g++.old-deja/g++.benjamin/13478.C new file mode 100644 index 000000000..e1d52e14b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.benjamin/13478.C @@ -0,0 +1,30 @@ +// { dg-do assemble } +// 981203 bkoz +// g++/13478 + +class A {}; +class AData {}; + +typedef void (A::* hand) (void); + +struct hand_table { + const int data1; + const hand data2; +}; + +class Agent : public A { +public: + enum { first = 1, last }; +protected: + static const hand_table table_1[]; + static const AData table_2; +private: + void foo (void); +}; + +const hand_table Agent::table_1[] = +{ + {0, &Agent::table_2}, + {first, &Agent::foo}, + {last, &(hand)Agent::foo} // { dg-error "" } no match +}; diff --git a/gcc/testsuite/g++.old-deja/g++.benjamin/13523.C b/gcc/testsuite/g++.old-deja/g++.benjamin/13523.C new file mode 100644 index 000000000..d70e04a98 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.benjamin/13523.C @@ -0,0 +1,12 @@ +// { dg-do assemble } +// 981203 bkoz +// g++/13523 + +template<typename T> class latin_america; + +class peru +{ + friend class latin_america<int>; // Particular template class friend works + template<class T> friend class latin_america; // This does not work. +}; + diff --git a/gcc/testsuite/g++.old-deja/g++.benjamin/13908.C b/gcc/testsuite/g++.old-deja/g++.benjamin/13908.C new file mode 100644 index 000000000..d18434eca --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.benjamin/13908.C @@ -0,0 +1,21 @@ +// { dg-do assemble } +// 981203 bkoz +// g++/13908 + +class chile +{ +public: +protected: +private: +}; + +typedef void (chile::* pmf) (); + +void* foo; + +void bar (chile* pobj, pmf pmethod) +{ + //-edg: expected member name + //-g++: taking address of bound pointer-to-member expression + foo = (void*) &(pobj->*pmethod); // { dg-error "invalid use" } +} diff --git a/gcc/testsuite/g++.old-deja/g++.benjamin/14139.C b/gcc/testsuite/g++.old-deja/g++.benjamin/14139.C new file mode 100644 index 000000000..2429538f3 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.benjamin/14139.C @@ -0,0 +1,22 @@ +// { dg-do assemble } +// 981203 bkoz +// g++/14309 +// test for global functions, mf's, and templatized mf's. + +static int fooe_1(void) { return 5; } +static int fooe_2(int x = fooe_1()) { return x; } + +struct antigua { + static int& foo_1(); + static int foo_2(int& x = antigua::foo_1()); + static int foo_3(int x = fooe_2()); +}; + +template <typename T> + struct jamacia { + static int& foo_1(); + static int foo_2(int& x = antigua::foo_1()); + static int foo_3(int x = fooe_2()); + }; + +template class jamacia<int>; diff --git a/gcc/testsuite/g++.old-deja/g++.benjamin/14664-1.C b/gcc/testsuite/g++.old-deja/g++.benjamin/14664-1.C new file mode 100644 index 000000000..9a6e64443 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.benjamin/14664-1.C @@ -0,0 +1,15 @@ +// { dg-do assemble } +// 981203 bkoz +// g++/14664 - test + +char foo[26]; + +void bar() +{ + //-g++: incompatible types in assignment of 'const char[]' to 'char[]' + //-edg: expression must be a modifiable lvalue + foo = "0123456789012345678901234"; // { dg-error "" } // ERROR - +} + + + diff --git a/gcc/testsuite/g++.old-deja/g++.benjamin/14664-2.C b/gcc/testsuite/g++.old-deja/g++.benjamin/14664-2.C new file mode 100644 index 000000000..364f30c4b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.benjamin/14664-2.C @@ -0,0 +1,14 @@ +// { dg-do assemble } +// { dg-options "-fpermissive -w" } +// 981203 bkoz +// g++/14664 + test + +char foo[26]; + +void bar() +{ + foo = "0123456789012345678901234"; // { dg-error "array" } +} + + + diff --git a/gcc/testsuite/g++.old-deja/g++.benjamin/14687.C b/gcc/testsuite/g++.old-deja/g++.benjamin/14687.C new file mode 100644 index 000000000..494f75c56 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.benjamin/14687.C @@ -0,0 +1,53 @@ +// { dg-do run } +// 981203 bkoz +// g++/14687 + +#include <assert.h> +unsigned int gtest; + +// 7.3.3 the using declaration + +// p 3 +struct belieze { + void f(char); + void g(char); + enum E { e }; + union { int x; }; +}; + +struct dominica: belieze { + using belieze::f; + void f(int i) { f('c'); } // calls belieze::f(char) + void g(int i) { g('c'); } // recursively calls dominca::g(int) +}; + + +// p 6 +namespace A { + void f(int i) { gtest = 1; } +} + +using A::f; //f is a synonym for A::f, that is for A::f(int) + +namespace A { + void f(char c) { gtest = 3; } +} + +void foo(void) { + f('a'); //calls f(int), even though A::f(char) exits + assert (gtest = 1); +} + +void bar(void) { + using A::f; //f is a synonm for A::f, that is for A::f(int) and A::f(char) + f('a'); //calls f(char) + assert (gtest = 3); +} + +int main(void) +{ + foo(); + bar(); + + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.benjamin/15054.C b/gcc/testsuite/g++.old-deja/g++.benjamin/15054.C new file mode 100644 index 000000000..4d1c6f207 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.benjamin/15054.C @@ -0,0 +1,10 @@ +// { dg-do assemble } +// { dg-options "-Wno-pointer-arith" } +// 981203 bkoz +// g++/15054 +// note that -pedantic also turns on this warning + +void cuba(void) { + void* p; + p++; +} diff --git a/gcc/testsuite/g++.old-deja/g++.benjamin/15071.C b/gcc/testsuite/g++.old-deja/g++.benjamin/15071.C new file mode 100644 index 000000000..d05f48f50 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.benjamin/15071.C @@ -0,0 +1,12 @@ +// { dg-do run } +// 981203 bkoz +// g++/15071 +// gcc invocation fails to link in libstdc++ + +#include <iostream> + +int main() { + std::cout << "hi" << std::endl; + + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.benjamin/15309-1.C b/gcc/testsuite/g++.old-deja/g++.benjamin/15309-1.C new file mode 100644 index 000000000..aa5530fff --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.benjamin/15309-1.C @@ -0,0 +1,21 @@ +// { dg-do assemble } +// { dg-options "-Wnon-virtual-dtor -Weffc++" } +// 981203 bkoz +// g++/15309 + +class bahamian { +public: + bahamian (); + ~bahamian (); +}; + +class miami : public bahamian // { dg-warning "" } // WARNING - +{ +public: + miami (); + ~miami (); +}; + + + + diff --git a/gcc/testsuite/g++.old-deja/g++.benjamin/15309-2.C b/gcc/testsuite/g++.old-deja/g++.benjamin/15309-2.C new file mode 100644 index 000000000..283179731 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.benjamin/15309-2.C @@ -0,0 +1,10 @@ +// { dg-do assemble } +// { dg-options "-Wnon-virtual-dtor -Weffc++" } +// 981203 bkoz +// g++/15309 + +class bermuda { // { dg-warning "" } // WARNING - +public: + virtual int func1(int); + ~bermuda(); +}; diff --git a/gcc/testsuite/g++.old-deja/g++.benjamin/15756-1.C b/gcc/testsuite/g++.old-deja/g++.benjamin/15756-1.C new file mode 100644 index 000000000..2bef3b0f1 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.benjamin/15756-1.C @@ -0,0 +1,36 @@ +// { dg-do assemble } +// { dg-options "-Wsign-promo" } +// 981203 bkoz +// g++/15756 test1 + +enum e_value { first = 0, next = 30 }; + +struct sanjuan { + sanjuan(int value); + sanjuan(unsigned value); + friend sanjuan operator&(const sanjuan& x, const sanjuan& y); + friend int operator!=(const sanjuan& x, const sanjuan& y); +}; + +extern void mod_enum(e_value*); +extern int a; + +void foo(void) { + e_value mod = first; + mod_enum(&mod); + if (mod != next) + ++a; +} + + + + + + + + + + + + + diff --git a/gcc/testsuite/g++.old-deja/g++.benjamin/15756-2.C b/gcc/testsuite/g++.old-deja/g++.benjamin/15756-2.C new file mode 100644 index 000000000..77c4aca35 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.benjamin/15756-2.C @@ -0,0 +1,50 @@ +// { dg-do assemble } +// { dg-options "-Wsign-promo" } +// 981203 bkoz +// g++/15756 test2 +// this test may only be valid for 32bit targets at present + +#include <limits.h> + +enum e_i { + vali +} +enum_int; + +enum e_ui { +#if INT_MAX == 32767 + valui = 0xF234 +#else + valui = 0xF2345678 +#endif +} +enum_uint; + +int i; +unsigned int ui; + +struct caracas { + caracas(int); + caracas(unsigned int); + void foo(); +}; + +int main () +{ + caracas obj_ei ( enum_int ); // { dg-warning "" } + caracas obj_eui ( enum_uint ); // { dg-warning "" } + caracas obj_i ( i ); + caracas obj_ui ( ui ); + + obj_ei.foo(); + obj_eui.foo(); + obj_i.foo(); + obj_ui.foo(); +} + + + + + + + diff --git a/gcc/testsuite/g++.old-deja/g++.benjamin/15799.C b/gcc/testsuite/g++.old-deja/g++.benjamin/15799.C new file mode 100644 index 000000000..24725c999 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.benjamin/15799.C @@ -0,0 +1,30 @@ +// { dg-do assemble } +// 981203 bkoz +// g++/15799 test1 + +/* +15799.cpp: In function `void foo()': +15799.cpp:21: call of overloaded `sanjose({anonymous enum})' is ambiguous +15799.cpp:13: candidates are: sanjose::sanjose(const sanjose &) <near match> +15799.cpp:14: sanjose::sanjose(unsigned int) +*/ + +typedef char int_8; +typedef unsigned long uint_32; + +class sanjose { +public: + sanjose(); + sanjose(const sanjose&); // { dg-message "note" } + sanjose(int_8 value); // { dg-message "note" } + sanjose(uint_32 value); // { dg-message "note" } +}; + +enum { first, last}; + +void foo(void) { + sanjose obj(first); // { dg-error "ambiguous" } + // { dg-message "candidate" "candidate note" { target *-*-* } 26 } +} + + diff --git a/gcc/testsuite/g++.old-deja/g++.benjamin/15800-1.C b/gcc/testsuite/g++.old-deja/g++.benjamin/15800-1.C new file mode 100644 index 000000000..4f6d878e8 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.benjamin/15800-1.C @@ -0,0 +1,18 @@ +// { dg-do assemble } +// 981203 bkoz +// g++/15800 - test + +struct panama { + panama(); + panama(panama &); + panama& operator=(panama&); // { dg-message "operator=|no known conversion" } +}; + +extern panama dig(); + +void foo() { + panama obj; + obj = dig(); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 15 } +} + diff --git a/gcc/testsuite/g++.old-deja/g++.benjamin/15800-2.C b/gcc/testsuite/g++.old-deja/g++.benjamin/15800-2.C new file mode 100644 index 000000000..6149da6be --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.benjamin/15800-2.C @@ -0,0 +1,18 @@ +// { dg-do assemble } +// 981203 bkoz +// g++/15800 + test + +struct panama { + panama(); + panama(panama &); + panama& operator=(panama&); + panama& getref() { return *this; } +}; + +extern panama dig(); + +void foo() { + panama obj; + obj = dig().getref(); +} + diff --git a/gcc/testsuite/g++.old-deja/g++.benjamin/15822.C b/gcc/testsuite/g++.old-deja/g++.benjamin/15822.C new file mode 100644 index 000000000..ff9b59366 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.benjamin/15822.C @@ -0,0 +1,28 @@ +// { dg-do run } +// 981203 bkoz +// g++/15822 + +#include <assert.h> + +static unsigned int gcount; + +struct playahermosa { + playahermosa() { ++gcount; } + playahermosa(const playahermosa &) { ++gcount; } + ~playahermosa() { --gcount; } +}; + +struct playacoco { + playacoco(const playahermosa& = playahermosa()) { } //create a temporary +}; + +void foo(playacoco *) { } + +int main() +{ + playacoco bar[2]; + foo(bar); + assert (gcount == 0); + + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.benjamin/16077.C b/gcc/testsuite/g++.old-deja/g++.benjamin/16077.C new file mode 100644 index 000000000..9338e8755 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.benjamin/16077.C @@ -0,0 +1,31 @@ +// { dg-do assemble } +// 981203 bkoz +// g++/16077 +// { dg-options "-Wconversion" } + +class nicaragua; +struct colombia { + colombia(); + colombia(const colombia &); + colombia(const nicaragua &); + colombia &operator= (const colombia&); +}; + +struct nicaragua { +public: + nicaragua(); + nicaragua(const nicaragua&); + operator colombia(); +}; + +void peace(const colombia&); + +void foo(nicaragua& b) { + peace(b); // { dg-warning "choosing 'nicaragua::operator" "nic" } + // { dg-warning "conversion" "conv" { target *-*-* } 24 } + // { dg-message "note" "note" { target *-*-* } 24 } +} + + + + diff --git a/gcc/testsuite/g++.old-deja/g++.benjamin/16567.C b/gcc/testsuite/g++.old-deja/g++.benjamin/16567.C new file mode 100644 index 000000000..7b4f68bbe --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.benjamin/16567.C @@ -0,0 +1,44 @@ +// { dg-do assemble } +// 981203 bkoz +// g++/16567 + +typedef bool Bool; +typedef unsigned char Uint8; +typedef unsigned short Uint16; +typedef unsigned int Uint32; + +enum e_ms { third = 3, fourth = 4 }; + +struct bitmask { + Uint8* anon1; + Uint32 anon2; + Uint8 anon3; + Uint8 here: 2; + Uint8 anon4: 2; + Uint8 anon5: 4; +}; + +struct control { + Uint8 foo_1(); +}; + +inline Uint8 foo_2(bitmask* p) { + return p->here; +} + +inline Uint8 control::foo_1() { + return foo_2((bitmask*) this); +} + +void foo(void) { + control obj; + control *fp = &obj; + e_ms result; + + result = (e_ms) fp->foo_1; // { dg-error "" } // ERROR - +} + + + + + diff --git a/gcc/testsuite/g++.old-deja/g++.benjamin/17922.C b/gcc/testsuite/g++.old-deja/g++.benjamin/17922.C new file mode 100644 index 000000000..2fc6204e9 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.benjamin/17922.C @@ -0,0 +1,19 @@ +// { dg-do assemble } +// 981204 bkoz +// g++/17922 + +class base { }; + +struct derived : public base { + derived (const derived&); + derived (const base&); +}; + +class tahiti { +public: + static void mf (derived); +}; + +void foo (const derived aaa) { + tahiti::mf(aaa); +} diff --git a/gcc/testsuite/g++.old-deja/g++.benjamin/17930.C b/gcc/testsuite/g++.old-deja/g++.benjamin/17930.C new file mode 100644 index 000000000..b9b28524f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.benjamin/17930.C @@ -0,0 +1,6 @@ +// { dg-do assemble } +// 981204 bkoz +// g++/17930 + +char const one[] = "test"; +char const two[] = one; // { dg-error "" } // ERROR - diff --git a/gcc/testsuite/g++.old-deja/g++.benjamin/18208.C b/gcc/testsuite/g++.old-deja/g++.benjamin/18208.C new file mode 100644 index 000000000..2e9b7ce7a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.benjamin/18208.C @@ -0,0 +1,25 @@ +// { dg-do assemble } +// 981204 bkoz +// g++/18208 + +typedef unsigned int uint_32; + +class puertorico { +public: + void *f (); +private: + uint_32 member; +}; + +void foo( ) +{ + uint_32 ui; + puertorico obj; + + // Bug using static_cast<> + ui = static_cast<uint_32>(obj); // { dg-error "" } // ERROR - + + // Bug when missing the pair of braces + ui = (uint_32) obj.f; // { dg-error "" } // ERROR - +} + diff --git a/gcc/testsuite/g++.old-deja/g++.benjamin/bool01.C b/gcc/testsuite/g++.old-deja/g++.benjamin/bool01.C new file mode 100644 index 000000000..b9890412d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.benjamin/bool01.C @@ -0,0 +1,80 @@ +// { dg-do run } +//980323 bkoz +//test for bools with inclusive ors + +#include <assert.h> +#include <limits.h> + +void bar ( bool x ) {} +void bars ( short x ) {} + +/* 980326 bkoz this is not initialized and so can have indeterminate value. */ +#if 0 +int orb(){ + bool y; + bar ( y ); + int blob = ( 27 | int (y) ); + return blob; //expect 27 or 0 +} +#endif + +int orbtrue(){ + bool y = true; + bar ( y ); + int blob = ( 27 | int (y) ); + return blob; //expect 27 +} + +int orbfalse(){ + bool y = false; + bar ( y ); + int blob = ( 27 | int (y) ); + return blob; //expect 27 +} + +int orbfalse2(){ + bool y = 0; + bar ( y ); + int blob = ( 27 | int (y) ); + return blob; //expect 27 +} + +int ors(){ + short y = 1; + bars ( y ); + int blob = ( 27 | int (y) ); + return blob; //expect 27 +} + + +#if INT_MAX > 32767 +int orus(){ + unsigned short y = 1; + bars ( y ); + int blob = ( 65539 | int (y) ); + return blob; //expect 65539, will be 3 if done in us type +} +#endif + +int main() { + int tmp; +#if 0 + tmp = orb(); + assert (tmp == 27 || tmp == 0); +#endif + tmp = orbtrue(); + assert (tmp ==27); + tmp = orbfalse(); + assert (tmp ==27); + tmp = orbfalse2(); + assert (tmp ==27); + tmp = ors(); + assert (tmp ==27); +#if INT_MAX > 32767 + tmp = orus(); + assert (tmp == 65539); +#endif + + return 0; +} + diff --git a/gcc/testsuite/g++.old-deja/g++.benjamin/bool02.C b/gcc/testsuite/g++.old-deja/g++.benjamin/bool02.C new file mode 100644 index 000000000..fcdb143a1 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.benjamin/bool02.C @@ -0,0 +1,64 @@ +// { dg-do run } +//980324 bkoz +//test for bool and bitwise ands + +#include <assert.h> + + +void bar ( bool x ) {} +void bars ( short x ) {} + +#if 0 +int andb(){ + bool y; + bar ( y ); + int blob = ( 27 & int (y) ); + return blob; //expect 1 or 0 +} +#endif + +int andbtrue(){ + bool y = true; + bar ( y ); + int blob = ( 27 & int (y) ); + return blob; //expect 1 +} + +int andbfalse(){ + bool y = false; + bar ( y ); + int blob = ( 27 & int (y) ); + return blob; //expect 0 +} + +int andbfalse2(){ + bool y = 0; + bar ( y ); + int blob = ( 27 & int (y) ); + return blob; //expect 0 +} + +int ands(){ + short y = 1; + bars ( y ); + int blob = ( 27 & int (y) ); + return blob; //expect 1 +} + + +int main() { + int tmp; +#if 0 + tmp = andb(); + assert (tmp == 1 || tmp == 0); +#endif + tmp = andbtrue(); + assert (tmp == 1); + tmp = andbfalse(); + assert (tmp == 0); + tmp = andbfalse2(); + assert (tmp == 0); + tmp = ands(); + assert (tmp == 1); + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.benjamin/friend01.C b/gcc/testsuite/g++.old-deja/g++.benjamin/friend01.C new file mode 100644 index 000000000..b203bc56a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.benjamin/friend01.C @@ -0,0 +1,31 @@ +// { dg-do assemble } +//980610 bkoz +// example 1: buggy + +class foo { +public: + class bar; + int func(bar *); + class bar { + int st; + public: + bar(){st=12;} + ~bar(){} + friend int foo::func(bar *); + }; + foo(){} + ~foo(){} +}; + + +int foo::func(bar *obj) { + obj->st++; + return (obj->st); +} + +void test02() { + foo obj_f; + foo::bar obj_b; + + obj_f.func( &obj_b); +} diff --git a/gcc/testsuite/g++.old-deja/g++.benjamin/friend02.C b/gcc/testsuite/g++.old-deja/g++.benjamin/friend02.C new file mode 100644 index 000000000..f6ab601d0 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.benjamin/friend02.C @@ -0,0 +1,31 @@ +// { dg-do assemble } +//980610 bkoz +// example 2: ok + +class bar; +class foo { +public: + int func(bar *); + foo(){} + ~foo(){} +}; + +class bar { + int st; +public: + bar(){st=12;} + ~bar(){} + friend int foo::func(bar *); +}; + +int foo::func(bar *obj) { + obj->st++; + return (obj->st); +} + +void test02() { + foo obj_f; + bar obj_b; + + obj_f.func( &obj_b); +} diff --git a/gcc/testsuite/g++.old-deja/g++.benjamin/p12475.C b/gcc/testsuite/g++.old-deja/g++.benjamin/p12475.C new file mode 100644 index 000000000..d3e121e14 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.benjamin/p12475.C @@ -0,0 +1,14 @@ +// { dg-do assemble } +// prms-id: 12475 + +#include <limits.h> + +#if LONG_MAX == 2147483647 +#define TEST 2147483648 +#elif LONG_MAX == 9223372036854775807 +#define TEST 9223372036854775808 +#else +#error "Unsupported test -- add new constants." +#endif + +enum huh { start =-TEST, next }; // { dg-warning "" } diff --git a/gcc/testsuite/g++.old-deja/g++.benjamin/p13417.C b/gcc/testsuite/g++.old-deja/g++.benjamin/p13417.C new file mode 100644 index 000000000..132b13df2 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.benjamin/p13417.C @@ -0,0 +1,11 @@ +// { dg-do assemble } +// { dg-options "-Wno-deprecated" } +// prms-id: 13417 + +class Foo { +public: + explicit Foo (int){} +}; +Foo f(10); +Foo blat() return f(4){} // { dg-error "" } named return value + diff --git a/gcc/testsuite/g++.old-deja/g++.benjamin/p13721.C b/gcc/testsuite/g++.old-deja/g++.benjamin/p13721.C new file mode 100644 index 000000000..960c3e0dd --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.benjamin/p13721.C @@ -0,0 +1,21 @@ +// { dg-do assemble } +// prms-id: 13721 + +class A +{ + public : + int a; +}; +class B : public A +{ + public : + void cmp(int a, int b) {} + B(int a = 0) + { + cmp(A::a, a); //should not give warning + } +}; +int main(void) +{ + return(1); +} diff --git a/gcc/testsuite/g++.old-deja/g++.benjamin/scope01.C b/gcc/testsuite/g++.old-deja/g++.benjamin/scope01.C new file mode 100644 index 000000000..b67606ac1 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.benjamin/scope01.C @@ -0,0 +1,71 @@ +// { dg-do assemble } +// 980604 bkoz +// 3.4.5 Class member access p 4 +// nested and non-nested calls, no dtors + +struct L { + int ii; + void foo(int a) {++a;} + struct Linner { + int ii_inner; + void foo_inner(int b) {++b;} + }; +}; +class A : public L {}; +class B : public L {}; +class C : public A, public B {}; + + +void foo() { + // straight call + C x; + x.A::ii = 5; + x.A::foo(x.A::ii); + + // 5.1 Primary expressions + // p 8 + // a nested name specifier that names a class, + // optionally followed by the keyword template and then followd by + // the name of a member of either that class or one of its base + // classes is a qualified-id. (3.4.3.1 describes their lookup.) + + // 5.2.5 Class memember access + + // p 3 if E1 has the type 'pointer to class X' then + // E1->E2 == (*(E1)).E32 + // E1 == object-expression + // E2 == id-expression + // thus everything gets converted to the "." notation + + // p 2 + // the id-expression shall name a member of the class + // (object-expression) or of one of its base classes. + + // p4 if E2 is a nested type (of the object-expression), tye + // expression E1.E2 is ill formed. + + // try 1 nested call - ERROR +#if 0 + C x2; + x2.A::L::Linner::ii_inner = 6; //ERROR violates p2, does not name member of C + x2.A::L::Linner::foo_inner(x2.A::L::Linner::ii_inner); +#endif + + //try2: scoped method call -edg +acc +g++ +#if 1 + C::A::Linner x2; + x2.A::Linner::ii_inner = 6; + x2.A::Linner::foo_inner(x2.A::Linner::ii_inner); +#endif + + //try 3: non-scoped method call -edg +acc +g++ +#if 0 + C::A::L::Linner x3; + x3.ii_inner = 6; + x3.foo_inner(x3.ii_inner); +#endif +} + + + + diff --git a/gcc/testsuite/g++.old-deja/g++.benjamin/scope02.C b/gcc/testsuite/g++.old-deja/g++.benjamin/scope02.C new file mode 100644 index 000000000..1ff541b88 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.benjamin/scope02.C @@ -0,0 +1,208 @@ +// { dg-do assemble } +//980529 bkoz +//3.4.5 Class member access via pointer and non-pointer +// non-nested dtor calls + +int counter = 0; + +struct X { + int rank; + X(int init = 64) : rank(init) { } + ~X() { ++counter; } + typedef X classtype; +}; +typedef X globaltype; + +#if 0 +template <typename T> +struct X_tem { + T rank; + X_tem(T init = T(64) ) : rank(init) { } + ~X_tem() { ++counter; } + typedef X_tem classtype_tem; +}; +typedef X_tem<int> globaltype_tem; +#endif + + + + +int main(void) +{ + // 3.4.5 Class member access + // p 2 + // if the id-expression in a class member access is an + // unqualified-id, and the type of the object expression is of class + // type C (or pointer to class type C), the unqualified-id is looked + // up in the scope of class C. If the type of the object-expression + // is of pointer to scalar type, the unqualified-id is looked up in + // the context of the complete postfix-expression. + + // p 3 + // if the unqualitified id is ~type-name, and the type of the object + // expression is of a class type C (or pointer to class type C), the + // type-name is looked up in the context of the entire + // postfix-expression and in the scope of class C. The type-name + // shall refer to a class-name. If type-name is found in both + // contexts, the name shall refer to the same class type. If the + // type of the object expression is of scalar type, the type-name is + // looked up in the complete postfix-expression. + + typedef X localtype; + + // + // 1 non-templatized, pointer, unqualified + // + X x01 ; + X *px = &x01; + px->~X(); + + X x02 (66); + px = &x02; + px->~localtype(); + + X x03 (68); + px = &x03; + px->~classtype(); //-g++ //p3: unqual-id lookup in object and postfix-expr + + X x04 (70); + px = &x04; + px->~globaltype(); + + + // p 1 + // . . . the id-expression is first looked up in the class of the + // object-expression. If the identifier is not found, itis then + // looked up in the context of the entier postfix-expression and + // shall name a class or function template. If the lookup in the + // class of the object-expression finds a template, the name is also + // looked up in teh context of the entier postfix-expression and + // 1 if the name is not found, use the name from the object-expr + // 2 if the name found in postfix-expr != class template, use object-expr + // 3 if name found is class template, name must match object-expr or error + + // p 4 + + // if the id-expr in a class member acess is a qualified-id, the + // id-expression is looked up in both the context of the entire + // postfix-expr and in the scope of the class of the object-expr. If + // the name is found in both contexts, the id-expr shall refer to + // the same entity. + + + // + // 2 non-templatized, pointer, qualified + // + X x05 ; + px = &x05; + px->X::~X(); + + X x06 (66); + px = &x06; + px->X::~localtype(); + + X x07 (68); + px = &x07; + px->X::~classtype(); // -edg + + X x08 (70); + px = &x08; + px->X::~globaltype(); + + X x09 (66); + px = &x09; + px->localtype::~localtype(); + + X x10 (68); + px = &x10; + px->classtype::~classtype(); + + X x11 (70); + px = &x11; + px->globaltype::~globaltype(); + + X x12 (66); + px = &x12; + px->classtype::~localtype(); + + X x13 (68); + px = &x13; + px->globaltype::~localtype(); + + X x14 (70); + px = &x14; + px->localtype::~globaltype(); + + X x15 (70); + px = &x15; + px->classtype::~globaltype(); + + X x16 (70); + px = &x16; + px->localtype::~classtype(); //-edg + + X x17 (70); + px = &x17; + px->globaltype::~classtype(); //-edg + +#if 0 + // + // non-templatized, non-pointer + // + X xo5 ; + xo5.~X(); //unqualified + + localtype xo6 (66); + xo6.~localtype(); + + X xo7 (68); + xo7.~classtype(); + + X xo8 (70); + xo8.~globaltype(); + + + // + // templatized, pointer + // + X_tem<int> xto1 ; + X_tem<int> *pxt = &xto1; + pxt->~X_tem(); //unqualified + + typedef X_tem<int> localtype_tem; + localtype_tem xto2 (66); + pxt = &xto2; + pxt->~localtype_tem(); + + //paragraph 2: unqualitifed id looked up in scope of post-fix expr if object + X_tem<int> xto3 (68); + pxt = &xto3; + pxt->~classtype_tem(); + + X_tem<int> xto4 (70); + pxt = &xto4; + pxt->~globaltype_tem(); + + // + // templatized, non-pointer + // + X_tem<int> xto5 ; + xto5.~X_tem(); //unqualified + + localtype_tem xto6 (66); + xto6.~localtype_tem(); + + X_tem<int> xto7 (68); + xto7.~classtype_tem(); + + X_tem<int> xto8 (70); + xto8.~globaltype_tem(); +#endif + return 0; +} + + + + + + diff --git a/gcc/testsuite/g++.old-deja/g++.benjamin/tem01.C b/gcc/testsuite/g++.old-deja/g++.benjamin/tem01.C new file mode 100644 index 000000000..76c90c4a8 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.benjamin/tem01.C @@ -0,0 +1,136 @@ +// { dg-do assemble } +// prms-id: 13911 + +template<unsigned int N> +class ref_counter { +public: + ref_counter() : p_refcnt(new unsigned int(N)) {} + ref_counter(const ref_counter<N>& x) : p_refcnt(x.p_refcnt) { + ++*p_refcnt; + } + ref_counter& operator=(const ref_counter<N>& rhs) { + ++*rhs.p_refcnt; + decrement(); + p_refcnt = rhs.p_refcnt; + return *this; + } + ~ref_counter() {decrement();} + + bool unique() const {return *p_refcnt == N;} + +private: + unsigned int* p_refcnt; + void decrement() { + if (unique()) delete p_refcnt; + else --*p_refcnt; + } +}; + +template<class T, unsigned int N> +class ref_pointer { +public: + + ref_pointer() : the_p(0) {} + ref_pointer(T* just_newed) : the_p(just_newed) {} + virtual ~ref_pointer() {if (unique()) delete the_p;} +protected: + ref_pointer(T* the_p_arg, ref_counter<N>& ref_count_arg) + : the_p(the_p_arg), ref_count(ref_count_arg) {} + +public: + + ref_pointer& operator=(const ref_pointer&); + ref_pointer& operator=(T*); + operator const T*() const {return the_p;} + T* operator()() {return the_p;} + T* operator()() const {return the_p;} + T& operator*() const {return *the_p;} + friend bool operator==(const ref_pointer<T, N>& lhs, + const ref_pointer<T, N>& rhs) { + return lhs.the_p == rhs.the_p; + } + friend bool operator!=(const ref_pointer<T, N>& lhs, + const ref_pointer<T, N>& rhs) { + return lhs.the_p != rhs.the_p; + } + + + bool unique() const {return ref_count.unique();} + bool isNull() const {return the_p==0;} + +protected: + ref_counter<N>& refCount() {return ref_count;} + +private: + + ref_counter<N> ref_count; + T* the_p; +}; + +template<class T, unsigned int N> +ref_pointer<T, N>& ref_pointer<T, N>::operator=(const ref_pointer<T, N>& rhs) { + if (the_p != rhs.the_p) { + if (unique()) delete the_p; + the_p = rhs.the_p; + ref_count = rhs.ref_count; + } + return *this; +} + + +template<class T, unsigned int N> +ref_pointer<T, N>& ref_pointer<T, N>::operator=(T* just_newed) { + if (unique()) delete the_p; + the_p = just_newed; + ref_count = ref_counter<N>(); + return *this; +} + + + +template<class T> +class CountedObjPtr : public ref_pointer<T, 1> { +public: + CountedObjPtr() {} + CountedObjPtr(T* just_newed) : ref_pointer<T, 1>(just_newed) {} + CountedObjPtr(T* the_p_arg, ref_counter<1>& ref_count_arg) + : ref_pointer<T, 1>(the_p_arg, ref_count_arg) {} + CountedObjPtr<T>& operator=(T* rhs) { + ref_pointer<T, 1>::operator=(rhs); + return *this; + } + CountedObjPtr<T>& operator=(const CountedObjPtr<T>& rhs) { + ref_pointer<T, 1>::operator=(rhs); + return *this; + } + T* operator->() const {return (*this)();} + +}; + + + + + +//instantiating type + +class TSObservable; + +class TSObserver { +public: + + enum TSType { NormalTS, UpYldCrvTS, DownYldCrvTS, ZeroVolTS }; + + virtual ~TSObserver() {} + + virtual void update(TSObservable* theChangedObservable) = 0; + virtual TSType key() const { return myKey; } + virtual TSType& key() { return myKey; } +protected: + TSObserver(TSType myKeyArg) : myKey(myKeyArg) {} + TSType myKey; +}; + + + +//now try to instantiate +template class CountedObjPtr<TSObserver>; diff --git a/gcc/testsuite/g++.old-deja/g++.benjamin/tem02.C b/gcc/testsuite/g++.old-deja/g++.benjamin/tem02.C new file mode 100644 index 000000000..98be669e2 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.benjamin/tem02.C @@ -0,0 +1,54 @@ +// { dg-do assemble } +//980519 bad error from nathan +//$ egcs -fhonor-std -nostdinc -c redef.C +//redef.C:56: redefinition of default argument for `class _Traits' + +template<class _CharT> struct char_traits; +template<class _CharT> struct char_traits { }; +template<> struct char_traits<char>; +template<> struct char_traits<char> { }; + +template<class _CharT, class _Traits = char_traits<_CharT> > class istreambuf_iterator; + + +template<class _CharT, class _Traits> + class istreambuf_iterator +{ + public: + typedef _Traits traits_type; + class _Proxy; + public: + inline istreambuf_iterator() throw(); + inline istreambuf_iterator(const _Proxy& __p) throw(); +}; + + +template <class _CharT, class _Traits> + class istreambuf_iterator<_CharT,_Traits>::_Proxy +{ + public: + _CharT operator*(); + + //bug -g++ w/ decl "redef", no decl no prob. + //ok -edg: no warnings + friend class istreambuf_iterator; // XXX OK? + + //bug -g++ w/ decl "redef", no decl no prob. + //ok -edg: no warnings + //friend class istreambuf_iterator<_CharT,_Traits>; + + //bug -g++ w/ decl "redef", no decl no prob. + //ok -edg: declaration of "_CharT" and "_Traits" hides template parameter + //template <class _CharT, class _Traits> friend class istreambuf_iterator; + + //ok -g++ + //ok -edg + //friend class istreambuf_iterator<_CharT>; + +}; + + + +//explicit instantiation of a nested class +template class istreambuf_iterator<char, char_traits<char> >::_Proxy; + diff --git a/gcc/testsuite/g++.old-deja/g++.benjamin/tem03.C b/gcc/testsuite/g++.old-deja/g++.benjamin/tem03.C new file mode 100644 index 000000000..fb9830e68 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.benjamin/tem03.C @@ -0,0 +1,209 @@ +// { dg-do assemble } +// 980808-980824 bkoz +// template parameter redeclaration bugs + +// 14.1 Template parameters +// p 13 +// The scope of a template-parameter extens from its point of +// declartion until the end of its template. In particular, a +// template-parameter can be used in the declaration of subsequent +// template-parameters and their default arguments. + +// 14.6.1 Locally declared names +// p 4 +// A template-parameter shall not be redeclared within its scope +// (including nested scopes). A template-parameter shall not have the +// sname name as the template name. + + +// 01 +// declared friend template +template <class T4>// { dg-error "" } .* +class Xone { +protected: + T4* next; + T4* prev; + T4 value; +public: + Xone(): next(0), prev(0), value(1999){} + Xone(T4 init): value(init) {} + + // these are ok: + // can also do template-decl and then can ditch the foward-declaration + // template <class T5> friend bool isequal (Xone<T5>& lhs, Xone<T5>& rhs); + // this is not ok: + template <class T4> friend bool isequal (Xone<T4>& lhs, Xone<T4>& rhs);// { dg-error "" } .* +}; + + +// 02 +// nested template class +template <class T6>// { dg-error "" } .* +class Xtwo { +protected: + T6* next; + T6* prev; + T6 value; +public: + Xtwo(): next(0), prev(0), value(1999){} + Xtwo(T6 init): value(init) {} + + template <class T6> class nested {// { dg-error "" } .* + T6 value; + public: + nested(): value( T6(0)) {} + }; +}; + + +// 03 +// member templates +template <class T8>// { dg-error "" } .* +class Xthree { +protected: + T8* next; + T8* prev; + T8 value; +public: + Xthree(): next(0), prev(0), value(1999){} + Xthree(T8 init): value(init) {} + + template <class T8> T8 comp_ge(T8 test) {// { dg-error "" } .* + T8 local_value; + if (local_value > value) + return local_value; + else + return value; + } +}; + + +// 04 +// local names (14.6.1 p 4) +template <class T10, int i> struct Xfour {// { dg-error "" } .* + int T10; // { dg-error "" } .* + void f(){ + char T10; // { dg-error "declaration of 'char T10'" } + } +}; + + +// 05 +// using different tempate-parms for out-of-line defs +template <class T12, int i> struct Xfive { + void f(); +}; + +template <class T13, int i> void Xfive<T13,i>::f() {// { dg-error "" } .* + int T13; // { dg-error "" } .* + int T12; //should be ok +} + + +// 06 +// multiple names at the same level +template <class T14, class T14> class Xsix { // { dg-error "" } .* +private: +public: + void f(); +}; + + +// 07 +// multiple names, one in template parameter one in class-name +template <class T12> class T12; // { dg-error "" } .* + + +// 08 +// with multiple template params, and second (third) one is redeclared +template <class T16, int i, class T161> class Xseven { // { dg-error "" } .* +private: + char T161; // { dg-error "" } .* +public: + template <class U> + friend bool fooy(U u); + + template <class T161> // { dg-error "declaration of 'class T161'" } + friend bool foo(T161 u) + { + Xseven<T161, 5, int> obj; + return (obj.inst == u.inst); + } + +}; + + +// 09 +// check for correct scoping of member templates +template <class T> +struct S1 +{ + template <class U> + void f(U u) + { + S1<U> s2u(u); + s2u.g(); + } + + template <class U> //ok + void f2(U u) + { + S1<U> s2u(u); + s2u.g(); + } + +}; + + +// 10 +// check for non-type parameters, should still be able to redeclare? +// local names (14.6.1 p 4) +template <class T18, int i> class Xten {// { dg-error "" } .* + float i; // { dg-error "" } .* +}; + + +// 11 +// declared friend template, non-type parameters +template <long l>// { dg-error "" } .* +class Xeleven { +public: + template <long l> friend bool isequal (Xeleven<5> lhs, Xeleven<5> rhs); // { dg-error "" } .* +}; + + + +// 12 +// nested template class, non-type parameters +template <long l>// { dg-error "" } .* +class Xtwelve { +public: + template <long l> class nested {// { dg-error "" } . + long value; + public: + nested(): value(0) {} + }; +}; + + +// 13 +// member templates, non-type parameters +template <long l>// { dg-error "" } .* +struct Xthirteen { + template <long l> long comp_ge(long test) {// { dg-error "" } . + long local_value; + if (local_value > value) // { dg-error "" } .* + return local_value; + else + return value; + } +}; + + + + + + + + + diff --git a/gcc/testsuite/g++.old-deja/g++.benjamin/tem04.C b/gcc/testsuite/g++.old-deja/g++.benjamin/tem04.C new file mode 100644 index 000000000..7dd7462c3 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.benjamin/tem04.C @@ -0,0 +1,182 @@ +// { dg-do assemble } +// 980827 bkoz +// template parameter redeclaration bugs, part two: +// template template params and expanded template non-type parms + +// 14.1 Template parameters +// p 13 +// The scope of a template-parameter extens from its point of +// declartion until the end of its template. In particular, a +// template-parameter can be used in the declaration of subsequent +// template-parameters and their default arguments. + +// 14.6.1 Locally declared names +// p 4 +// A template-parameter shall not be redeclared within its scope +// (including nested scopes). A template-parameter shall not have the +// same name as the template name. + +// 14 +// declared friend template (v3, template type parameters) +template <class T4>// { dg-error "" } .* +class Xfourteen { +protected: + T4 value; +public: + Xfourteen(T4 init): value(init) {} + template <template <typename T4> class T5> // { dg-error "" } .* + friend bool isequal (Xfourteen<int>& lhs, Xfourteen<int>& rhs); +}; + + +// 15 +// nested template class (v3, template type parameters) +template <class T6>// { dg-error "" } .* +class Xfifteen { +protected: + T6 value; +public: + Xfifteen(T6 init): value(init) {} + + template <template <typename T6> class T7> class nested {// { dg-error "" } .* + int value; + public: + nested(): value( int(0)) {} + }; +}; + + +// 16 +// member templates (v3, template type parameters) +template <class T8>// { dg-error "" } .* +class Xsixteen { +protected: + T8 value; +public: + Xsixteen(T8 init): value(init) {} + + template <template <typename T8> class T9> int comp_ge(int test) {// { dg-error "" } .* + int local_value; + if (local_value > value) + return local_value; + else + return value; + } +}; + + +// 17 +// declared friend template (v4, template type parameters on the class) +template <typename T9> class tem_base { +public: + T9 value; +}; + +template <typename T10, template <typename T12> class C10> +class Xseventeen { +protected: + C10<T10> value; +public: + Xseventeen(){} + template <typename T12> // ok?? + friend bool isequal (Xseventeen<T10, tem_base>& lhs, + Xseventeen<T10, tem_base>& rhs); +}; + +//template class Xseventeen<int, tem_base>; + + +// 18 +// more template template redecl tests +template <typename T14, template <typename T15> class C12>// { dg-error "" } .* +class Xeighteen { +protected: + C12<T14> value; + int C12; // { dg-error "" } .* +}; + + +// 19 +// more template template redecl tests +template <typename T16, template <typename T17> class C14>// { dg-error "" } .* +class Xnineteen{ +protected: + C14<T16> value; + template <class C14> class nested {// { dg-error "" } .* + T16 value; + public: + nested(): value( T16(0)) {} + }; +}; + + +// 20 +// local names (14.6.1 p 4) part two, variable names as template param +template <class T17, int i> struct Xtwenty { + void f(){ + T17 my_type; //ok + for (int j = 0; j < 5; ++j) + { + T17 my_type; //ok + ++my_type; + } + } +}; + + +// 14.1 Template parameters +// p 4 +// A non-type templat- parameter shall have one of the following +// (optionally cv-qualified) types: +// integral or enumeration type +// pointer to object or pointer to function +// referenct to object or referece to function +// pointer to member + +// 21 +// non-type template parameters v1: enum +enum my_enum {my_A = 45, my_B, my_C}; + +template <my_enum T18> class Xtwentyone {// { dg-error "" } .* + float T18; // { dg-error "" } .* +}; + + +// 22 +// non-type template parameters v1: pointer to object +struct base { + int gcount; + int ret_gcount() {return gcount;} +}; + +template <class T20, base* b> class Xtwentytwo {// { dg-error "" } .* + float b; // { dg-error "" } .* +}; + + +// 23 +// non-type template parameters v2: reference to object +template <class T20, base& b2> class Xtwentythree {// { dg-error "" } .* + float b2; // { dg-error "" } .* +}; + + +// 24 +// non-type template parameters v3: pointer to member +template <class T20, int base::* b3> class Xtwentyfour {// { dg-error "" } .* + float b3; // { dg-error "" } .* +}; + + +// 25 +// non-type template parms that use push_class_level +template <class T22> void f1() {// { dg-error "" } .* + struct foo { + enum T22 { un, du, toi }; // { dg-error "" } .* + }; +} + + + + + diff --git a/gcc/testsuite/g++.old-deja/g++.benjamin/tem05.C b/gcc/testsuite/g++.old-deja/g++.benjamin/tem05.C new file mode 100644 index 000000000..7b6b95538 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.benjamin/tem05.C @@ -0,0 +1,58 @@ +// { dg-do assemble } +// 980924 bkoz +// just a quick test for export, to make sure we are warning for it. +// CHANGE ME when it's supported + + +// 14 Templates +//p 6 +// A namespace-scope declaration or definintion of a non-line function +// template, a non-inline member function template, a non-inline +// member function of a class template or a static data member of a +// class template may be preceeded by the export keyword. If such a +// template is defined in the same translation unit in which it is +// declared as exported, the definition is considered to be +// exported. The first declaration of the template containing the +// export keyword must not follow the definition. (meaning that export +// can't beredeclared as non-export??) + +// 1 +// template definition +export template <class T> // { dg-warning "" } +bool templ_one(T a) { + if (a > 0) + return true; + else + return false; +} + + +// 2 +// static data, mf, mf template +template <class T> +class X_one { + unsigned short id; + T type; +public: + static const bool is_specialized ; + + X_one(const unsigned short& us = 5): id(us), type(T(0)) {} + unsigned short ret_id (); + template <class T2> bool compare_ge(T2 test); +}; + +export template <class T> // { dg-warning "" } +const bool X_one<T>::is_specialized = false; + +export template <class T> // { dg-warning "" } +unsigned short X_one<T>::ret_id() { + return id; +} + +export template <class T2> // { dg-warning "" } +bool compare_ge(T2 test) { + if (test > type) // { dg-error "" } .* + return true; + return false; +} + diff --git a/gcc/testsuite/g++.old-deja/g++.benjamin/tem06.C b/gcc/testsuite/g++.old-deja/g++.benjamin/tem06.C new file mode 100644 index 000000000..3233e0e96 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.benjamin/tem06.C @@ -0,0 +1,52 @@ +// { dg-do run } +// 980945 bkoz +// test for correct operators at link time + +/* +/tmp/cca211431.o: In function `void blah<foo<int> >(foo<int> const &)': +/tmp/cca211431.o(.void gnu.linkonce.t.blah<foo<int> >(foo<int> const &)+0x1e): undefined reference to `void x<int>(int const &)' +*/ + +template<class T> +class foo { +public: + foo () {} + friend void x (const T &) { } +}; + +void x(const int &); + +template<class T> +void blah (const T &) { + T y; + x (4); +} + +int main () { + const foo<int> v; + blah (v); +} + +/* +fno-exceptions -fno-rtti + +1.98r1.o: +00000000 W __t3foo1Zi +00000000 W blah__H1Zt3foo1Zi_RCX01_v +00000000 t gcc2_compiled. +00000000 T main + U x__H1Zi_RCX01_v + +1.egcs.o: +00000000 W __t3foo1Zi +00000000 W blah__H1Zt3foo1Zi_RCX01_v +00000000 t gcc2_compiled. +00000000 T main +00000000 W x__FRCi + + +the reason this goes away at -O is because the U or W function is +elided completely. + +*/ + diff --git a/gcc/testsuite/g++.old-deja/g++.benjamin/tem07.C b/gcc/testsuite/g++.old-deja/g++.benjamin/tem07.C new file mode 100644 index 000000000..2b304b464 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.benjamin/tem07.C @@ -0,0 +1,38 @@ +// { dg-do run } + +template <class T> +class Foo +{ +public: + Foo(const T&); + Foo(const T&, const T&); +}; + +template <class T> +Foo<T>::Foo(const T& t0) +{ +} + +template <class T> +Foo<T>::Foo(const T& t0, const T& t1) +{ +} + +template Foo<int>::Foo(const int& t0); + + +int main (void) { + return 0; +} + + + + + + + + + + + + diff --git a/gcc/testsuite/g++.old-deja/g++.benjamin/typedef01.C b/gcc/testsuite/g++.old-deja/g++.benjamin/typedef01.C new file mode 100644 index 000000000..79a965b16 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.benjamin/typedef01.C @@ -0,0 +1,46 @@ +// { dg-do assemble } +//980205 bkoz + +//7.1.3 the typedef specifier + + +//p1 +typedef int MILES, *KLICKSP; +MILES distance; +extern KLICKSP metricp; + +//p2--can redefine to same type +typedef struct s { /* ... */ } s; +typedef int I; +typedef int I; +typedef I I; + +//p3--cannot redefine to a different type in a given scope +class complex2 { /* ... */ };// { dg-error "" } .* +typedef int complex2;// { dg-error "" } .* +typedef int complex3;// { dg-error "" } .* +class complex3 { /* ... */ };// { dg-error "" } .* + + +//p4 +/* +4 A typedef-name that names a class is a class-name (_class.name_). If + a typedef-name is used + 1) following the class-key in an elaborated-type-specifier + 2) or in the class-head of a class declaration + 3) or is used as the identifier in the declarator for a + constructor or destructor declaration + the program is ill-formed. [Example: +*/ +struct S { + S(); + ~S(); +}; + +typedef struct S T; // { dg-error "previous declaration" } + +S a = T(); // OK +struct T * p; // { dg-error "" } using typedef after struct + +//case01 +typedef bool short;// { dg-error "" } .* diff --git a/gcc/testsuite/g++.old-deja/g++.benjamin/typedef03.C b/gcc/testsuite/g++.old-deja/g++.benjamin/typedef03.C new file mode 100644 index 000000000..f2138402a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.benjamin/typedef03.C @@ -0,0 +1,44 @@ +// { dg-do assemble } +//980526 bkoz +// reduced testcase for 980511 brendan qt bug + + +class QTextStream +{ +public: + QTextStream(); + virtual ~QTextStream(); + + enum { + skipws = 0x0001, + left = 0x0002, + right = 0x0004, + internal = 0x0008, + bin = 0x0010, + oct = 0x0020, + dec = 0x0040, + hex = 0x0080, + showbase = 0x0100, + showpoint = 0x0200, + uppercase = 0x0400, + showpos = 0x0800, + scientific= 0x1000, + fixed = 0x2000 + }; + + static const int basefield; + static const int adjustfield; +}; + +typedef QTextStream QTS; +const int QTS::basefield = (QTS::bin | QTS::dec | QTS::hex) ; +const int QTS::adjustfield = QTS::left | QTS::right | QTS::internal; +#if 0 +#define QTS QTextStream +const int QTS::basefield = (QTS::bin | QTS::dec | QTS::hex) ; +const int QTS::adjustfield = QTS::left | QTS::right | QTS::internal; +#endif + + + + diff --git a/gcc/testsuite/g++.old-deja/g++.benjamin/typeid01.C b/gcc/testsuite/g++.old-deja/g++.benjamin/typeid01.C new file mode 100644 index 000000000..439e22ac3 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.benjamin/typeid01.C @@ -0,0 +1,72 @@ +// { dg-do run } +// 980617 bkoz +// typeid for local types +// typeid bool vs int and enum vs int + +#include <typeinfo> +#ifdef DEBUG_ASSERT +#include <assert.h> +#endif + +// 4: local class in non-main function + +void test1 (void) { + bool class_p = false; + class X2 { + private: + unsigned int counter; + public: + X2 (unsigned int i = 35): counter(i) {} + ~X2(){} + unsigned int ret_counter() {return counter;} + }; + X2 obj_1; + class_p = typeid(X2) == typeid(obj_1); +} + +int main () +{ + // 1: simple +#if 1 + bool enum_p = false; + enum E { A, B, C }; + enum_p = typeid(A) == typeid(E); +#ifdef DEBUG_ASSERT + assert (enum_p); +#endif +#endif + + // 2: complex +#if 0 + bool enum2_p = false; + bool int_p = false; + bool bool_p = false; + enum E2 { A2, B2}; + enum2_p = typeid(A2) == typeid(E2); + int_p = typeid(int) == typeid(E2); + bool_p = typeid(bool) == typeid(E2); +#ifdef DEBUG_ASSERT + assert (enum2_p); + assert (!int_p); + assert (!bool_p); +#endif +#endif + + // 3: local class + bool class_p = false; + class X { + private: + unsigned int counter; + public: + X (unsigned int i = 35): counter(i) {} + ~X(){} + unsigned int ret_counter() {return counter;} + }; + X obj_1; + class_p = typeid(X) == typeid(obj_1); + + // 4: local class in function + test1(); + + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.benjamin/warn01.C b/gcc/testsuite/g++.old-deja/g++.benjamin/warn01.C new file mode 100644 index 000000000..99b23967c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.benjamin/warn01.C @@ -0,0 +1,98 @@ +// { dg-do assemble } +// { dg-options "-Wall -Weffc++" } + +//1 g++/12952 un-named variables in a catch block +//Wall or Wunused should not give warnings here +template <class T> +void f (void) { + try + { + } + + catch( int) + { + } +} + +// +//2 g++/12923 __attribute__((__unused__)) not working for objects +//Weffc++ or Wunused should not report the object as an error +class C { + public: + C(); +}; + +void f (void){ + C x __attribute__ ((__unused__)); + int y __attribute__ ((__unused__)); +} + +// +//3 g++/12982 lock should not give error here, as above +void setLock (); +void clearLock (); + +template <class T> +class test { +public: + class lock + { + public: + lock () { setLock(); } + ~lock () { clearLock(); } + }; + + static void f (void) + { + lock local __attribute__ ((__unused__)); + } + +}; + + +// +//4 g++/12988 neither Mutex nor AutoMutex varibles should give warnings here +//compile with -Weffc++ or -Wunused depending on post or pre 97r1 +class Mutex { +private: + long counter; +public: + virtual long retcntr() {return counter;}; + Mutex(int i = 0): counter(i) {}; + virtual ~Mutex() {}; +} __attribute__ ((__unused__)); + +class AutoMutex: public Mutex{ +private: + long counter2; +public: + long retcntr() {return counter2;}; + AutoMutex(int i = 0): counter2(i) {}; + virtual ~AutoMutex() {}; +} __attribute__ ((__unused__)); + + +template <class T> +int foofunc(T x){ + Mutex sm(2); + AutoMutex m(&sm); + return 0; +} + + +//5 sanity check to make sure other attributes cannot be used +class Mutex2 { +private: + long counter; +public: + virtual long retcntr() {return counter;}; + Mutex2(int i = 0): counter(i) {}; + virtual ~Mutex2() {}; +} __attribute__ ((warn)); // { dg-warning "" } + + + + + + + diff --git a/gcc/testsuite/g++.old-deja/g++.benjamin/warn02.C b/gcc/testsuite/g++.old-deja/g++.benjamin/warn02.C new file mode 100644 index 000000000..248e1ed9f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.benjamin/warn02.C @@ -0,0 +1,54 @@ +// { dg-do assemble } +// { dg-options "-Wredundant-decls" } +// 980413 bkoz +// from g++/15307, tests for -Wredundant-decls +// for friend functions and functions + + +extern int foo(const char *); + +class A +{ + friend int foo(const char *); + int a; +}; + +class B +{ + friend int foo(const char *); + int foo2() {return b;} + int b; +}; + +class C +{ + friend int foo(const char *); + friend int foo(const char *); // { dg-warning "" } + int foo2() {return b;} + int b; +}; + +class D +{ +public: + int foo2() {return b;} // { dg-error "with" } + int foo2() {return b;} // { dg-error "overloaded" } + int b; +}; + +class E +{ +public: + int foo2(); // { dg-error "with" } + int foo2(); // { dg-error "overloaded" } + int b; +}; + +extern int foo3(const char *); // { dg-warning "" } +extern int foo3(const char *); // { dg-warning "" } + + + + + + diff --git a/gcc/testsuite/g++.old-deja/g++.benjamin/warn03.C b/gcc/testsuite/g++.old-deja/g++.benjamin/warn03.C new file mode 100644 index 000000000..46f0fb6e1 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.benjamin/warn03.C @@ -0,0 +1,10 @@ +// { dg-do assemble } +// { dg-options "-Wredundant-decls" } +// 980420 bkoz +// from g++/15307, tests for -Wredundant-decls for decls + +//shouldn't crash +extern unsigned char *foo5[]; +extern unsigned char *foo5[]; + + diff --git a/gcc/testsuite/g++.old-deja/g++.benjamin/warn04.C b/gcc/testsuite/g++.old-deja/g++.benjamin/warn04.C new file mode 100644 index 000000000..8319e989a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.benjamin/warn04.C @@ -0,0 +1,9 @@ +// { dg-do assemble } +// { dg-options "-Wno-non-template-friend" } +// 980903 bkoz +// make sure this option works + + +template<class T> class task { + friend void next_time(); //shouldn't give a warning +}; diff --git a/gcc/testsuite/g++.old-deja/g++.bob/array1.C b/gcc/testsuite/g++.old-deja/g++.bob/array1.C new file mode 100644 index 000000000..dac0420c8 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.bob/array1.C @@ -0,0 +1,6 @@ +// { dg-do assemble } +char *stuff() { + char array[10]; // { dg-warning "" } + + return array; +} diff --git a/gcc/testsuite/g++.old-deja/g++.bob/array2.C b/gcc/testsuite/g++.old-deja/g++.bob/array2.C new file mode 100644 index 000000000..ae044a118 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.bob/array2.C @@ -0,0 +1,4 @@ +// { dg-do assemble } +extern const int a[]; +extern const int a[]; +extern const int a[]; diff --git a/gcc/testsuite/g++.old-deja/g++.bob/case1.C b/gcc/testsuite/g++.old-deja/g++.bob/case1.C new file mode 100644 index 000000000..6fe4f25e3 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.bob/case1.C @@ -0,0 +1,14 @@ +// { dg-do assemble } +// prms-id: 9028 +class Foo; + +int main() +{ + int i=0; + switch (i) + { + case ((Foo *)0): // { dg-error "" } + case ((Foo *)1): // { dg-error "" } + break; + } +} diff --git a/gcc/testsuite/g++.old-deja/g++.bob/cond1.C b/gcc/testsuite/g++.old-deja/g++.bob/cond1.C new file mode 100644 index 000000000..799465424 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.bob/cond1.C @@ -0,0 +1,31 @@ +// { dg-do assemble } +// prms-id: 9866 +class TChar + { +public: + explicit inline TChar(unsigned int aChar); + inline operator unsigned int() const; +private: + unsigned int iChar; + }; +inline TChar::TChar(unsigned int aChar) + : iChar(aChar) + {} +inline TChar::operator unsigned int() const + {return(iChar);} + +class TDes8 + { +public: + inline const unsigned char &operator[](int anIndex) const; + const unsigned char &AtC(int anIndex) const; + }; + +inline const unsigned char &TDes8::operator[](int anIndex) const + {return(AtC(anIndex));} + + +void doExponent(TDes8 &aDigBuf) + { + 2 ? TChar(aDigBuf[2]) : '0'; + } diff --git a/gcc/testsuite/g++.old-deja/g++.bob/delete1.C b/gcc/testsuite/g++.old-deja/g++.bob/delete1.C new file mode 100644 index 000000000..9de2a227a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.bob/delete1.C @@ -0,0 +1,23 @@ +// { dg-do run } +// prms-id: 7330 +#include <stddef.h> +int size = 0; + +struct X { + int x; + void *operator new[](size_t sz) throw() { + size = sz; + return 0; + } + void operator delete[] (void *vp) { ::operator delete(vp); } +}; +int main() +{ + X (*px) [10]; + + px = new X[5][10]; + + delete [] px; + + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.bob/extern_C.C b/gcc/testsuite/g++.old-deja/g++.bob/extern_C.C new file mode 100644 index 000000000..7bbf296e8 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.bob/extern_C.C @@ -0,0 +1,9 @@ +// { dg-do assemble } +extern "C" { + class A { + public: + void a(); + }; +} + +void A::a() {} diff --git a/gcc/testsuite/g++.old-deja/g++.bob/friend1.C b/gcc/testsuite/g++.old-deja/g++.bob/friend1.C new file mode 100644 index 000000000..4bce9d2ea --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.bob/friend1.C @@ -0,0 +1,5 @@ +// { dg-do assemble } +class C { +public: + static friend int f(); // { dg-error "" } +}; diff --git a/gcc/testsuite/g++.old-deja/g++.bob/incomplete-cast1.C b/gcc/testsuite/g++.old-deja/g++.bob/incomplete-cast1.C new file mode 100644 index 000000000..916af694d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.bob/incomplete-cast1.C @@ -0,0 +1,17 @@ +// { dg-do assemble } +// prms-id: 5274 +class VHDLIdentifier; + +class VHDLPackageProtoRep { +public: + int thing(); +private: + virtual VHDLIdentifier &actual_name() ; +}; +extern void form(const char *format, ... ); +int +VHDLPackageProtoRep::thing() +{ + form("package `%s'", (char *)actual_name()); // { dg-error "" } can't convert from incomplete type + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.bob/inherit1.C b/gcc/testsuite/g++.old-deja/g++.bob/inherit1.C new file mode 100644 index 000000000..e75190ba1 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.bob/inherit1.C @@ -0,0 +1,26 @@ +// { dg-do assemble } +class A { +char str[10]; +public: + char* m1 () { return str;} +}; + +class C : public A { +public: +}; + +class B : public A { +public: + char* m1 () { C::m1(); return ""; } // { dg-error "cannot call" } + // { dg-warning "deprecated" "depr" { target *-*-* } 14 } +}; + +int main () { +A a; +B b; +C c; + +a.m1(); +c.m1(); +b.m1(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.bob/inherit2.C b/gcc/testsuite/g++.old-deja/g++.bob/inherit2.C new file mode 100644 index 000000000..6e26ecfa6 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.bob/inherit2.C @@ -0,0 +1,24 @@ +// { dg-do assemble } +#include <stdlib.h> + +class A { +public: + void z(); + A(void) {} +private: + A(const A &) { abort(); } // { dg-error "private" } + const A& operator =(const A &) { abort(); } +}; + +class B : public A { // { dg-error "" } +public: + B(void) {} +}; + +void f(B b) { // { dg-error "initializing" } +} + +void g() { + B h; + f(h); // { dg-message "synthesized|deleted" "synth" } +} diff --git a/gcc/testsuite/g++.old-deja/g++.bob/nested1.C b/gcc/testsuite/g++.old-deja/g++.bob/nested1.C new file mode 100644 index 000000000..37dd2d054 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.bob/nested1.C @@ -0,0 +1,16 @@ +// { dg-do assemble } + +struct A { + struct B { + typedef long T; + int i; + }; +}; +struct C { + struct B { + typedef float T; + int i; + }; +}; + +C::B::T a; diff --git a/gcc/testsuite/g++.old-deja/g++.bob/packed1.C b/gcc/testsuite/g++.old-deja/g++.bob/packed1.C new file mode 100644 index 000000000..91e2d3c26 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.bob/packed1.C @@ -0,0 +1,18 @@ +// { dg-do run } +int +main() { + struct s + { + int a; + short b; + } __attribute__((packed)) t; + + if (sizeof (t) != (sizeof(int)+sizeof(short))) + { + return 1; + } + else + { + return 0; + } +} diff --git a/gcc/testsuite/g++.old-deja/g++.bob/protected1.C b/gcc/testsuite/g++.old-deja/g++.bob/protected1.C new file mode 100644 index 000000000..ed8f77f6d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.bob/protected1.C @@ -0,0 +1,42 @@ +// { dg-do assemble } +class A { +public: + int i; + A(int j) : i(j){} +}; + +class B : protected A { +public: + B(int j) : A(j){} + void f(){ + A k(*this); + } +}; + +class C : protected B { +public: + C(int j) : B(j){} + void f(); + + void g(){ + A k(i); + } +}; + + +class D : public C { +public: + D(int w) : C(i) {} + void j() { A k(*this); } + void h() { i=3; } +}; + +void C::f() { + A k(*this); +} + +B b(3); +int +main() { + A *z = &b; // { dg-error "" } +} diff --git a/gcc/testsuite/g++.old-deja/g++.bob/static1.C b/gcc/testsuite/g++.old-deja/g++.bob/static1.C new file mode 100644 index 000000000..e3ce9e532 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.bob/static1.C @@ -0,0 +1,12 @@ +// { dg-do assemble } +class A { + public: + static int a; +}; + +class B : public A { + public: + static int b; +}; + +int B::a; // { dg-error "" } diff --git a/gcc/testsuite/g++.old-deja/g++.bob/template1.C b/gcc/testsuite/g++.old-deja/g++.bob/template1.C new file mode 100644 index 000000000..be4c95787 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.bob/template1.C @@ -0,0 +1,27 @@ +// { dg-do assemble } +// prms-id: 10038 +template < class Referencee > +class Referencer +{ +public: + Referencer (Referencee const * pReferencee); +}; + +template <class T> +class Array +{ +public: + int addElement (T const & e); + int addElement (); +}; + +class ScenarioGroup; + +class ScenarioSet : public Array< Referencer<ScenarioGroup> > +{ + typedef Array< Referencer<ScenarioGroup> > arrayBase; + void addElement(ScenarioGroup *group) + { + arrayBase::addElement(group); + } +}; diff --git a/gcc/testsuite/g++.old-deja/g++.bob/template2.C b/gcc/testsuite/g++.old-deja/g++.bob/template2.C new file mode 100644 index 000000000..7da9deb29 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.bob/template2.C @@ -0,0 +1,49 @@ +// { dg-do assemble } +// prms-id: 10046 +template <class T> +class Array +{ +public: + T const & operator[] (int i) const; +}; + +class Referenceable {}; + +template < class Referencee > +class Referencer +{ +public: + operator Referencee *() const { return i_referencee; } + +protected: + Referencee* i_referencee; +}; + +class ScenarioGroup {}; + +class ScenarioSpace; + +class ScenarioSet : public Referenceable, + public Array< Referencer<ScenarioGroup> > +{ +public: + ScenarioSet& operator=(ScenarioSet const & s); +}; + +class ScenarioSpace : public Referenceable, + public Array< Referencer<ScenarioSet> > +{ +}; + +class ScenarioSetNameSelector +{ +public: + bool operator () (ScenarioSpace &space) + { + int idx; + i_set = space[idx]; + return false; + } +private: + ScenarioSet *i_set; +}; diff --git a/gcc/testsuite/g++.old-deja/g++.bob/template3.C b/gcc/testsuite/g++.old-deja/g++.bob/template3.C new file mode 100644 index 000000000..c440f47b9 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.bob/template3.C @@ -0,0 +1,49 @@ +// { dg-do assemble } +// prms-id: 9979 + +template < class Referencee > +class Referencer +{ +public: + Referencer() {} +}; + +template <class T> +class List +{ +public: + List() {} +}; + +template<class T, class KEY> +class Dictionary +{ +public: + Dictionary() : i_buckets (new List<T>[1234]) {} + ~Dictionary() { delete [] i_buckets; } + + List<T> * i_buckets; +}; + +class Exchangeable {}; +class ExchangeableHandle {}; + +class ExchangeableList + : public Dictionary<Referencer<Exchangeable>, ExchangeableHandle> +{ +public: + ExchangeableList(int size=0); +}; + +class ObjectExchange +{ +public: + ObjectExchange() {} + + ExchangeableList i_theWatchList; // Instruments being monitored +}; + +int +main() +{ +} diff --git a/gcc/testsuite/g++.old-deja/g++.bob/template4.C b/gcc/testsuite/g++.old-deja/g++.bob/template4.C new file mode 100644 index 000000000..13a150d5e --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.bob/template4.C @@ -0,0 +1,22 @@ +// { dg-do run } +// prms-id: 10166 + +template <class A> +class B { + public: + int f() { + for(int x=0;x<10;x++) { + continue; + return 1; + } + return 0; + } + private: + A w; +}; + +int +main() { + B<int> c; + return c.f(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/README b/gcc/testsuite/g++.old-deja/g++.brendan/README new file mode 100644 index 000000000..93febfb35 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/README @@ -0,0 +1,46 @@ + +abstract - abstract functions +alignof - gcc alignof builtin +ambiguity - diagnosing ambiguities +arm - ARM cases +array-refs - arrays of references +bit-fields - bit fields +chainon - deaths cuz we call chainon() incorrectly +copy - copy constructors +crash - old compiler crashes/aborts +cvt - user-defined conversions +def-fns - default function generation (in add'n to copy) +enum-clash - int vs enum +enum - enumerated types +err-msg - error messages +friend - dealing with friend functions and classes +groff - crashes derived from groff code +init - initialization bugs +label - handling labels +line - line numbers in error messages +misc - miscellaneous tests that didn't fit another category +nest - nested types +new-array - doing new of an array +new - generic operator new bugs +operators - tests for various overloaded operators +parse - parser bugs +prepost - prefix/postfix operator ++/-- +ptolemy - bugs derived from ptolemy +recurse - infinite recursion in the compiler +redecl - handling redeclarations +scope - managing scopes +shadow - shadowing of params, etc +sizeof - ARM compliance w/ sizeof operator +sorry - old "sorry, not implemented" messages +static - handling static data +template - template bugs +union - handling unions +visibility - access control and visibility checking +warnings - warning messages + + +Copyright (C) 1997, 1998 Free Software Foundation, Inc. + +Copying and distribution of this file, with or without modification, +are permitted in any medium without royalty provided the copyright +notice and this notice are preserved. diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/abstract1.C b/gcc/testsuite/g++.old-deja/g++.brendan/abstract1.C new file mode 100644 index 000000000..e37ee2eac --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/abstract1.C @@ -0,0 +1,25 @@ +// { dg-do assemble } +// GROUPS passed abstract-functions +class O +{ +public: + virtual int c()=0; +}; + +class I: public O +{ +}; + +class S: public virtual I +{ +public: + int c(); + virtual int v()=0; +}; + +class D: public S +{ + int v(); +}; + +D *p=new D(); diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/access1.C b/gcc/testsuite/g++.old-deja/g++.brendan/access1.C new file mode 100644 index 000000000..e2e3b2753 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/access1.C @@ -0,0 +1,23 @@ +// { dg-do assemble } +// GROUPS passed access-control +class Base +{ +protected: + virtual void DoSomething() = 0; +}; + +class Fibber : public Base +{ +public: + void DoBP() { + DoSomething(); + } +}; + +class Flat : public virtual Fibber +{ +public: + void DoIt() { + DoSomething(); + } +}; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/alignof.C b/gcc/testsuite/g++.old-deja/g++.brendan/alignof.C new file mode 100644 index 000000000..a79b65286 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/alignof.C @@ -0,0 +1,13 @@ +// { dg-do assemble } +// GROUPS passed extensions +struct bar { int bit : 1; }; + +void foo (int *r, bar t) +{ + // doing alignof on a bit-field should be illegal + __alignof__ (t.bit);// { dg-error "" } .* + + // both of these (a regular ref and an INDIRECT_REF) should work + __alignof__ (r); + __alignof__ (*r); +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/ambiguity1.C b/gcc/testsuite/g++.old-deja/g++.brendan/ambiguity1.C new file mode 100644 index 000000000..4706d7e8a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/ambiguity1.C @@ -0,0 +1,18 @@ +// { dg-do assemble } +// GROUPS passed ambiguity +struct A { + A (int); +}; + +struct B { + B (int); +}; + +void myfunc (const A& t0); // { dg-message "note" } +void myfunc (const B& t0); // { dg-message "note" } + +int main () +{ + myfunc(1); // { dg-error "ambiguous" } + // { dg-message "candidate" "candidate note" { target *-*-* } 16 } +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/anon-union1.C b/gcc/testsuite/g++.old-deja/g++.brendan/anon-union1.C new file mode 100644 index 000000000..3facea984 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/anon-union1.C @@ -0,0 +1,7 @@ +// { dg-do assemble } +// GROUPS passed anonymous-unions +static union { + char* uC; +private: + int uI;// { dg-error "" } .*private member.* +}; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/arm1.C b/gcc/testsuite/g++.old-deja/g++.brendan/arm1.C new file mode 100644 index 000000000..5cd4088a4 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/arm1.C @@ -0,0 +1,11 @@ +// { dg-do assemble } +// { dg-options "-pedantic-errors" } +// GROUPS passed ARM-compliance +// ARM $5.7, it's illegal to do math on a `void*'. + +int +main() +{ + void *p; + ++p;// { dg-error "" } .* +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/arm2.C b/gcc/testsuite/g++.old-deja/g++.brendan/arm2.C new file mode 100644 index 000000000..fb1ee429d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/arm2.C @@ -0,0 +1,19 @@ +// { dg-do assemble } +// GROUPS passed ARM-compliance +// ARM 9.4 ``There cannot be a static and a nonstatic member function +// with the same name and the same argument types.'' +// +// The trick is to make sure it's caught with both orders (static, +// then normal, and vice-versa. + +class X { +public: + int foo(); // { dg-error "with" } + static int foo(); // error: redeclaration// { dg-error "overloaded" } .* +}; + +class Y { +public: + static int foo(); // { dg-error "with" } + int foo(); // error: redeclaration// { dg-error "overloaded" } .* +}; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/arm3.C b/gcc/testsuite/g++.old-deja/g++.brendan/arm3.C new file mode 100644 index 000000000..c636ebb7b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/arm3.C @@ -0,0 +1,9 @@ +// { dg-do assemble } +// GROUPS passed initialization +// ARM $11.4: A function first declared in a friend decl is equivalent +// to an extern decl, so the below is illegal. + +class X { + friend g(); // { dg-error "" } previous declaration +}; +static g() { return 1; }// { dg-error "" } previously declared diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/array-refs.C b/gcc/testsuite/g++.old-deja/g++.brendan/array-refs.C new file mode 100644 index 000000000..b834867de --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/array-refs.C @@ -0,0 +1,6 @@ +// { dg-do assemble } +// GROUPS passed arm +int a, b; + +// declaring an array of references should be illegal +int & v[ 2] = { a, b};// { dg-error "" } .* diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/array1.C b/gcc/testsuite/g++.old-deja/g++.brendan/array1.C new file mode 100644 index 000000000..a58d3363b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/array1.C @@ -0,0 +1,7 @@ +// { dg-do assemble } +// { dg-options "-fconserve-space -fcommon" } +// GROUPS passed array-bindings + +extern "C" int printf (const char *, ...); +char array[~(~((__SIZE_TYPE__)0ul)>>1)|~(((__SIZE_TYPE__)0ul)>>3)]; // { dg-error "" } overflow in array dimension.* +int main () { printf ("PASS\n"); return 0; } diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/asm-extn1.C b/gcc/testsuite/g++.old-deja/g++.brendan/asm-extn1.C new file mode 100644 index 000000000..3c39972ba --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/asm-extn1.C @@ -0,0 +1,13 @@ +// { dg-do assemble { target sparc-sun-* } } +// { dg-options "-S" } +// GROUPS passed asm-extension +// This used to crash because c_expand_asm_keyword didn't know what to +// do with this. The parser rules were changed to accept an expr, instead +// of a stmt. + +extern void traptable(void); + +main() +{ + asm("wr %0,%%tbr" : : "r" (traptable)); +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/bit-fields1.C b/gcc/testsuite/g++.old-deja/g++.brendan/bit-fields1.C new file mode 100644 index 000000000..9ff4c5d86 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/bit-fields1.C @@ -0,0 +1,5 @@ +// { dg-do assemble } +// GROUPS passed bit-fields +struct bar { + int : 2 = 1;// { dg-error "" } .* +}; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/bit-fields2.C b/gcc/testsuite/g++.old-deja/g++.brendan/bit-fields2.C new file mode 100644 index 000000000..394d03501 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/bit-fields2.C @@ -0,0 +1,13 @@ +// { dg-do assemble } +// GROUPS passed bit-fields + struct S { + char c; + int i:8; + } s; + + int main() + { + int &ir = s.i; // { dg-error "" } address of bitfield + int *ip = &s.i; // { dg-error "" } address of bitfield + ir = 10; + } diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/bool1.C b/gcc/testsuite/g++.old-deja/g++.brendan/bool1.C new file mode 100644 index 000000000..86754e324 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/bool1.C @@ -0,0 +1,12 @@ +// { dg-do assemble } +// GROUPS passed boolean +int +main() +{ + typedef char Boolean; // Instrinsic.h + Boolean c = false; + bool b = true; + + if (!c != !b) + ; +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/code-gen1.C b/gcc/testsuite/g++.old-deja/g++.brendan/code-gen1.C new file mode 100644 index 000000000..a8c9aba36 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/code-gen1.C @@ -0,0 +1,41 @@ +// { dg-do run } +// GROUPS passed code-generation +// Check that sub-word sized structs/classes are passed correctly +// if the struct/class has a constructor (i.e. ANY constructor). + +extern "C" int printf (const char *, ...); + +struct base { + unsigned int f1 : 8; + unsigned int f2 : 8; + + base (int ii) + { + } +}; + +base global_base (7); + +int test2 (base formal_base); + +int main () +{ + global_base.f1 = 0x55; + global_base.f2 = 0xee; + + if (test2 (global_base) == 0) + printf ("PASS\n"); + else + { printf ("FAIL\n"); return 1; } + + return 0; +} + +int test2 (base formal_base) +{ + if (formal_base.f1 != global_base.f1) + return -1; + if (formal_base.f2 != global_base.f2) + return -1; + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/code-gen2.C b/gcc/testsuite/g++.old-deja/g++.brendan/code-gen2.C new file mode 100644 index 000000000..730f0f91f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/code-gen2.C @@ -0,0 +1,19 @@ +// { dg-do run } +// GROUPS passed code-generation +// Check that declarations with initializations are executed +// correctly. + +extern "C" int printf (const char *, ...); + +int main () +{ + char buff[40] ; + char *tmp = &buff[0]; // also fails for char *tmp = buff; + + if ((__SIZE_TYPE__) tmp != (__SIZE_TYPE__) &buff[0]) + { printf ("FAIL\n"); return 1; } + else + printf ("PASS\n"); + + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/code-gen3.C b/gcc/testsuite/g++.old-deja/g++.brendan/code-gen3.C new file mode 100644 index 000000000..62f8d7585 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/code-gen3.C @@ -0,0 +1,35 @@ +// { dg-do run } +// GROUPS passed code-generation +// Check that passing things which are not a multiple of +// 4 bytes in size doesn't mess up other subsequent parameters. + +extern "C" int printf (const char *, ...); + +struct base { + int f1 : 8; + int f2 : 8; +}; + +base global_base; + +int val1; + +int test2 (struct base formal_base, int v1); + +int main () +{ + val1 = 0x5e5e; + return test2 (global_base, val1); +} + +int test2 (struct base formal_base, int v1) +{ + formal_base.f1 = formal_base.f2; // prevent warnings + + if (v1 != 0x5e5e) + { printf ("FAIL\n"); return 1; } + else + printf ("PASS\n"); + + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/code-gen4.C b/gcc/testsuite/g++.old-deja/g++.brendan/code-gen4.C new file mode 100644 index 000000000..80b1676cd --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/code-gen4.C @@ -0,0 +1,33 @@ +// { dg-do run } +// { dg-options "-O" } +// GROUPS passed code-generation +// Options: -O +// +// Check that when an int value is assigned to a short int, the proper +// half of the int (i.e. the low order half) ends up in the short. +// +// This fails with 1.32.0 with -O and f1() is inline. +// +// Workaround - declare "f1_arg" as type "short int". + +#include <stdio.h> +#include <stdlib.h> + +short int v2; + +long v1 = 0x11117777; + +inline void f1 (long f1_arg) +{ + v2 = f1_arg; +} + +int main () +{ + f1 (v1); + + if (v2 != 0x00007777) + abort (); + else + printf ("PASS\n"); +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/code-gen6.C b/gcc/testsuite/g++.old-deja/g++.brendan/code-gen6.C new file mode 100644 index 000000000..821038ef6 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/code-gen6.C @@ -0,0 +1,55 @@ +// { dg-do run } +// GROUPS passed code-generation +// Check that type float parameters can be correctly passed to +// methods. + +extern "C" int printf (const char *, ...); + +class tres_floats { + float ff1; + float ff2; + float ff3; +public: + tres_floats (float f1, float f2, float f3); + float get_f1 (); + float get_f2 (); + float get_f3 (); +}; + +float v1 = 1.2345; +float v2 = 3.14159; +float v3 = 0.707; + +int main () +{ + tres_floats tf (v1, v2, v3); + + if ((tf.get_f1() != v1) || (tf.get_f2() != v2) || (tf.get_f3() != v3)) + { printf ("FAIL\n"); return 1; } + else + printf ("PASS\n"); + + return 0; +} + +tres_floats::tres_floats (float f1, float f2, float f3) +{ + ff1 = f1; + ff2 = f2; + ff3 = f3; +} + +float tres_floats::get_f1 () +{ + return ff1; +} + +float tres_floats::get_f2 () +{ + return ff2; +} + +float tres_floats::get_f3 () +{ + return ff3; +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/complex1.C b/gcc/testsuite/g++.old-deja/g++.brendan/complex1.C new file mode 100644 index 000000000..393941f88 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/complex1.C @@ -0,0 +1,29 @@ +// { dg-do run } +// { dg-options "" } + +// This test makes sure that the stuff in lex.c (real_yylex) is +// set up to handle real and imag numbers correctly. This test is against +// a bug where the compiler was not converting the integer `90' to a +// complex number, unless you did `90.0'. Fixed 10/1/1997. + +extern "C" { +int printf (const char *, ...); +void exit (int); +void abort (void); +} + +__complex__ double cd; + +int one = 1; + +int +main() +{ + cd = 1.0+90i; + cd *= one; + + if (__real__ cd != 1 || __imag__ cd != 90) + abort (); + + exit (0); +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/copy1.C b/gcc/testsuite/g++.old-deja/g++.brendan/copy1.C new file mode 100644 index 000000000..670cacd64 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/copy1.C @@ -0,0 +1,22 @@ +// { dg-do run } +// GROUPS passed copy-ctors +extern "C" int printf (const char *, ...); +int count = 0; + +class C { +public: + C (int) { count++; } + operator int () { return 0; } +}; + +int +main () +{ + C c1 (1); + C c2 (c1); + + if (count != 1) + { printf ("FAIL\n"); return 1; } + else + printf ("PASS\n"); +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/copy2.C b/gcc/testsuite/g++.old-deja/g++.brendan/copy2.C new file mode 100644 index 000000000..261e4f50a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/copy2.C @@ -0,0 +1,80 @@ +// { dg-do run } +// GROUPS passed copy-ctors +/* +The old g++ output is + +Item() +Compound() +Pre foo +foo +~Compound() +~Item() +Post foo +~Compound() +~Item() + +The output should be something like (produced from ATT 2.1) + +Item() +Compound() +Pre foo +Item(const Item& i) <------ missing above +foo +~Compound() +~Item() +Post foo +~Compound() +~Item() + +*/ + +extern "C" int printf (const char *, ...); +extern "C" void exit (int); + +int count = 0; + +void +die (int x) +{ + if (x != ++count) + { + printf ("FAIL\n"); + exit (1); + } +} + + +class Item { + public: + Item() { die (1); } + Item(const Item& i) { die (4); } + ~Item() { count++; if (count != 7 && count != 10) die (-1); } +}; + + +class Compound { + Item i; + public: + Compound() { die (2); } + ~Compound() { count++; if (count != 6 && count != 9) die (-1); } +}; + + +void foo(Compound a) +{ + die (5); +} + +int +main() +{ + Compound a; + + die (3); + foo(a); + + die (8); + + printf ("PASS\n"); +} + diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/copy3.C b/gcc/testsuite/g++.old-deja/g++.brendan/copy3.C new file mode 100644 index 000000000..c5675696b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/copy3.C @@ -0,0 +1,59 @@ +// { dg-do run } +// GROUPS passed copy-ctors +/* + +If I compile it with cfront (AT&T C++ Translator 2.00.02 08/25/89) and run it +I get: + + A::A() + A::A(const A&) + B::Bar() + A::~A() + A::~A() + +If I compile it with g++ (gcc version 2.2.2) and run it I get: + + A::A() + B::Bar() + A::~A() + A::~A() + +*/ +extern "C" int printf (const char *, ...); +extern "C" void exit (int); + +int count = 0; + +void +die (int x) +{ + if (x != ++count) + { + printf ("FAIL\n"); + exit (1); + } +} + + +class A { +public: + A() { die (1); } + A(const A&) { die (2); } + ~A() { count++; if (count != 4 && count != 5) die (-1); } +}; + +class B : public A { +public: + void Bar() { die (3); } +}; + +void Foo(B b) { b.Bar(); } + +int +main() +{ + B b; + Foo(b); + + printf ("PASS\n"); +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/copy4.C b/gcc/testsuite/g++.old-deja/g++.brendan/copy4.C new file mode 100644 index 000000000..bbb6c3e20 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/copy4.C @@ -0,0 +1,59 @@ +// { dg-do run } +// GROUPS passed copy-ctors +// Using Cfront 3.0.1 the programm below prints +// +// A() +// A(const A& a) +// ~A() +// A(A& a) <---- !!! +// ~A() +// ~A() +// +// the g++ 2.2.2 (sparc-sun-sunos4.1) generated code prints +// +// A() +// A(const A& a) +// ~A() +// A(const A& a) <---- !!! +// ~A() +// ~A() + +extern "C" int printf (const char *, ...); +extern "C" void exit (int); + +int count = 0; + +void +die (int x) +{ + if (x != ++count) + { + printf ("FAIL\n"); + exit (1); + } +} + +class A { +public: + A() { die (1); } + A(const A& a) { die (2); } + A(A& a) { die (4); } + ~A() { count++; if (count != 3 && count != 5 && count != 6) die (-1); } +}; + +void foo1(const A& a) { + A b = a; +} + +void foo2( A& a) { + A b = a; +} + +int main() { + A a; + + foo1(a); + foo2(a); + + printf ("PASS\n"); +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/copy5.C b/gcc/testsuite/g++.old-deja/g++.brendan/copy5.C new file mode 100644 index 000000000..c91559645 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/copy5.C @@ -0,0 +1,86 @@ +// { dg-do run } +// GROUPS passed copy-ctors +/* +bad: +sibelius402> a.out +a=5 a.virtMember()=30 +BaseClass::Increm --> {i=5, virtMember()=30} +a=7 a.virtMember()=30 +b=7 b.virtMember()=30 +BaseClass::Increm --> {i=7, virtMember()=999} +b=9 b.virtMember()=30 +sibelius403> + + good: + +sibelius406> a.out +a=5 a.virtMember()=30 +BaseClass::Increm --> {i=5, virtMember()=30} +a=7 a.virtMember()=30 +b=7 b.virtMember()=30 +BaseClass::Increm --> {i=7, virtMember()=30} +b=9 b.virtMember()=30 +*/ + +extern "C" int printf (const char *, ...); +extern "C" void exit (int); + +void die () { printf ("FAIL\n"); exit (1); } + +class BaseClass { + + friend int operator != (const BaseClass irv, int x); + + int i; + +public: + + BaseClass( const BaseClass& ir ) : i(ir.i) {} + BaseClass() : i(5) {} + + virtual int virtMember() { return( 999 ); } + + void Increm( int r ); +}; + +void BaseClass::Increm( int r ) +{ + if ((i == 5 && virtMember () == 30) + || (i == 7 && virtMember () == 30)) + i += r; + else + die (); +} + +class DerivedClass : public BaseClass { +public: + int virtMember() { return( 30 ); } +}; + +int operator != (const BaseClass irv, int x) { return irv.i != x; } + +int +main () +{ + DerivedClass a; + + if (a != 5 || a.virtMember () != 30) + die (); + + a.Increm(2); + + if (a != 7 || a.virtMember () != 30) + die (); + + DerivedClass b = a; + + if (b != 7 || a.virtMember () != 30) + die (); + + b.Increm(2); + + if (b != 9 || a.virtMember () != 30) + die (); + + printf ("PASS\n"); +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/copy6.C b/gcc/testsuite/g++.old-deja/g++.brendan/copy6.C new file mode 100644 index 000000000..8e1513190 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/copy6.C @@ -0,0 +1,56 @@ +// { dg-do run } +// GROUPS passed copy-ctors +/* +g++ 2.3.3 will prefer using type conversions over the +implicitly generated copy constructor. This is wrong. +If you explicitly define a copy constructor, it will +use it. However, the implicit copy constructor MUST be +called whenever an explicit one would have been called +also. See below: g++ converts from and back into +unsigned, instead of using the implicit copy constructor: +here is the version: +Reading specs from /usr/lib/gcc-lib/i386-linux/2.3.3/specs +gcc version 2.3.3 + /usr/lib/gcc-lib/i386-linux/2.3.3/cpp -lang-c++ -v -undef -D__GNUC__=2 -D__GNUG__=2 -D__cplusplus -Dunix -Di386 -Dlinux -D__unix__ -D__i386__ -D__linux__ -D__unix -D__i386 -D__linux bug2.cc /usr/tmp/cca02008.i +GNU CPP version 2.3.3 (80386, BSD syntax) + /usr/lib/gcc-lib/i386-linux/2.3.3/cc1plus /usr/tmp/cca02008.i -quiet -dumpbase bug2.cc -version -o /usr/tmp/cca02008.s +GNU C++ version 2.3.3 (80386, BSD syntax) compiled by GNU C version 2.3.3. + as -o /usr/tmp/cca020081.o /usr/tmp/cca02008.s + ld /usr/lib/crt0.o -nojump -L/usr/lib/gcc-lib/i386-linux/2.3.3 /usr/tmp/cca020081.o -lg++ -lgcc -lc -lgcc + +Ok, and here is the output: +test k: constructing from scratch +test l=k: type conversion into unsigned +constructing from unsigned + +*/ + +extern "C" int printf (const char *, ...); +extern "C" void exit (int); + +int count = 0; + +void die () { printf ("FAIL\n"); exit (1); } + +struct test { + test() { if (count != 0) die (); } + + test(unsigned) { + die (); + } + operator unsigned() { + die (); + return 0; + } +}; + +int +main() { + test k; + test l=k; + + printf ("PASS\n"); + + return 0; +} + diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/copy7.C b/gcc/testsuite/g++.old-deja/g++.brendan/copy7.C new file mode 100644 index 000000000..8fbec3384 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/copy7.C @@ -0,0 +1,31 @@ +// { dg-do run } +// GROUPS passed copy-ctors +extern "C" int printf (const char *, ...); +extern "C" void exit (int); + +void die () { printf ("FAIL\n"); exit (1); } + +class B { +public: + B() {} + B(const B &) { printf ("PASS\n"); exit (0); } +private: + int x; +}; + +class A : public B { +public: + A() {} + + A(const B &) { printf ("FAIL\n"); exit (1); } +}; + +int +main() +{ + A a; + A b(a); + + printf ("FAIL\n"); + return 1; +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/copy8.C b/gcc/testsuite/g++.old-deja/g++.brendan/copy8.C new file mode 100644 index 000000000..096052342 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/copy8.C @@ -0,0 +1,68 @@ +// { dg-do run } +// GROUPS passed copy-ctors +/* +This report is for GCC 2.3.3 running on a Sun/4. The bug is that when +a class instance is passed-by-value, GCC does not correctly copy the value. +At the end of this report is an example program that demonstrates the bug. +It should print: + + construct A('x') + copy A('x') + destruct A('x') + destruct A('x') + +and in fact does for IBM's xlC C++. However, for GCC 2.3.3, it fails +to print the second line ["copy A('x')"], which indicates that it failed +to call the copy-constructor for class A when it should have. Below is a +typescript that lists the program, shows how I compiled it, and shows the +incorrect output. +*/ + +extern "C" int printf (const char *, ...); +extern "C" void exit (int); + +int count = 0; + +void +die (int x) +{ + if (x != ++count) + { + printf ("FAIL\n"); + exit (1); + } +} + +class A { // Class with explicit & instrumented copy-constructor and destructor. +public: + const char * id; + A( const char * id1 ) : id(id1) { die (1); } + + // Copy constructor + A( const A& a ) : id(a.id) { die (2); } + + // Destructor + ~A() { count++; if (count != 3 && count != 4) die (-1); } +}; + +class X { // Class without explicit copy-constructor +private: + A a; +public: + X( const char * id ) : a(id) {} +}; + +void Func( X x ) { // Function with call-by-value argument +} + +int +main() { + X x("x"); // Construct instance of x. + + // The next line should call the copy-constructor for X since x is + // being passed by value. For GCC 2.3.3 on a Sun/4, it does not. + Func(x); + + printf ("PASS\n"); + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/copy9.C b/gcc/testsuite/g++.old-deja/g++.brendan/copy9.C new file mode 100644 index 000000000..f05b1943a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/copy9.C @@ -0,0 +1,46 @@ +// { dg-do run } +// GROUPS passed copy-ctors +#include <iostream> + +// token types: from state parser +const int T_EOF = 257; +const int T_ERROR = 258; +const int T_Float = 259; +const int T_Int = 260; +const int T_ID = 261; +const int T_STRING = 262; + +class Complex; +class State; + +// token, from state parser. +class ParseToken { +public: + int tok; + union { + char cval; + const char *sval; + int intval; + double doubleval; + Complex* Complexval; + const State* s; + }; + ParseToken () { tok = 0; intval = 0;} +}; + +int +main () { + ParseToken a; + a.tok = T_Float; + a.doubleval = 23.2; + ParseToken b(a); + + if (b.doubleval == 23.2) + std::cout << "PASS\n"; + else + { + std::cout << "FAIL\n"; + return 1; + } +} + diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash1.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash1.C new file mode 100644 index 000000000..a71867447 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash1.C @@ -0,0 +1,44 @@ +// { dg-do assemble } +// GROUPS passed old-abort +class D_Interval; + +class Date +{ + public: + Date(const D_Interval*,const Date&); +private: + const D_Interval* interval; +}; + +class Time_Interval +{ + public: + Time_Interval(const Date& start,const Date& stop); + const Date& Start() const { return start; } + const Date& Stop() const { return stop; } + private: + Date start; + Date stop; +}; + +class Dated_Data +{ + public: + Dated_Data(const Time_Interval& dates); + virtual ~Dated_Data(); + Time_Interval Dates() const { return dates; } + private: + Time_Interval dates; +}; + +class Raw_Data : public Dated_Data +{ + public: + Raw_Data(const Dated_Data *source,const D_Interval& period); +}; + +Raw_Data::Raw_Data(const Dated_Data *source,const D_Interval& period) + : Dated_Data(Time_Interval(Date(&period,source->Dates().Start()), + Date(&period,source->Dates().Stop()))) +{ +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash10.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash10.C new file mode 100644 index 000000000..78559b339 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash10.C @@ -0,0 +1,28 @@ +// { dg-do assemble } +// GROUPS passed old-abort +class word +{ + unsigned char b1, b2; +public: + word (unsigned int i = 0) { b1 = i & 0xff; b2 = (i & 0xff00) >> 8; } + operator unsigned int () { return (b2 << 8) + b1; } +}; + +class just_another +{ + int foo; + char bar[23]; +}; + +int mumble(word w) +{ + just_another *jap; + unsigned bar; + + bar = w; + + jap = new just_another [w]; + + return 0; +} + diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash11.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash11.C new file mode 100644 index 000000000..eb08ca264 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash11.C @@ -0,0 +1,24 @@ +// { dg-do assemble } +// GROUPS passed old-abort +extern "C" int printf (const char *, ...); + +class A { + int i; // { dg-error "" } private + int j; // { dg-error "" } private + public: + int h; + A() { i=10; j=20; } + virtual void f1() { printf("i=%d j=%d\n",i,j); } + friend virtual void f2() { printf("i=%d j=%d\n",i,j); }// { dg-error "" } virtual.* +}; + +class B : public A { + public: + virtual void f1() { printf("i=%d j=%d\n",i,j); }// { dg-error "" } member.*// ERROR - member.* + friend virtual void f2() { printf("i=%d j=%d\n",i,j); }// { dg-error "" } virtual.*// ERROR - member.*// ERROR - member.* +}; + +int +main() { + A * a = new A; +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash12.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash12.C new file mode 100644 index 000000000..362f1f715 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash12.C @@ -0,0 +1,10 @@ +// { dg-do assemble } +// GROUPS passed old-abort +class X +{ + int i; +public: + X(int j); +} + +X *x = new X[10]();// { dg-error "" } .* diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash13.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash13.C new file mode 100644 index 000000000..c1f0b7dfc --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash13.C @@ -0,0 +1,37 @@ +// { dg-do assemble } +// { dg-options "-Wreturn-type" } +// GROUPS passed old-abort +class gen_op +{ +public: + gen_op ( ); + gen_op (const gen_op &Op1); + ~gen_op ( ); + void operator = (const gen_op &Op1); +}; + + + + +class spin_op +{ +public: + spin_op(); + spin_op(const spin_op& SOp); + ~spin_op(); + void operator= (const spin_op& SOp); + operator gen_op(); +}; + + +spin_op Fe(); + + +gen_op Spul_U_axis() +{ + gen_op U1; + U1 = Fe(); +} // { dg-warning "no return" } reaches end of non-void function + +int +main () {} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash14.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash14.C new file mode 100644 index 000000000..e7920588f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash14.C @@ -0,0 +1,24 @@ +// { dg-do assemble } +// GROUPS passed old-abort +extern "C" int printf (const char *, ...); + + +class cl +{ + int i; +public: + cl(int j = 0) {i = j;} + int get_i() {return i;} + }; + +int +main() +{ + cl ob[3] = {1, 2, 3}; + int i; + + for(i=0; i<3; i++) + printf("%d\n", ob[i].get_i()); + + return 0; + } diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash15.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash15.C new file mode 100644 index 000000000..3c59fa64b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash15.C @@ -0,0 +1,22 @@ +// { dg-do assemble } +// GROUPS passed old-abort +#include <iostream> + +class A { + public: + virtual ~A() {std::cout << "executed ~A()\n";} +}; + +class B : public A { + public: + virtual ~B() {std::cout << "executed ~B()\n";} +}; + +int +main() { + std::cout << "starting\n"; + B b; + b.~A(); + std::cout << "done\n"; +} + diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash16.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash16.C new file mode 100644 index 000000000..674fc4fa6 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash16.C @@ -0,0 +1,14 @@ +// { dg-do compile } +// { dg-options "-fshow-column" } +// GROUPS passed old-abort + +class Graph { // { dg-error "1:new types|1: note: \\(perhaps" } +public: + unsigned char N; + Graph(void) {} // { dg-error "7:'Graph" } +} + +Graph::Graph(void) // { dg-error "18:return type|1: error: redefinition" } +{ N = 10; +} + diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash17.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash17.C new file mode 100644 index 000000000..ecbceabce --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash17.C @@ -0,0 +1,35 @@ +// { dg-do assemble } +// GROUPS passed old-abort +// +// This one creates +// +// gcc2: Internal compiler error: program cc1plus got fatal signal 11 +// +// when compiled with g++. +// The error goes away, if +// 1) int ClassInvariant() is not virtual or +// 2) GnObject has a virtual destructor or +// 3) GnWidget has no virtual destructor or +// 4) GnContracts has a virtual destructor +// + + +class GnContracts { + public: + virtual int ClassInvariant(); +// virtual ~GnContracts(); +}; + +class GnObject : public GnContracts { + public: +// virtual ~GnObject(); +}; + +class GnWidget : public GnObject { + public: + virtual ~GnWidget(); +}; + +class GnOptionGroup : public GnObject, public GnWidget {// { dg-warning "inaccessible" } +}; + diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash18.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash18.C new file mode 100644 index 000000000..119ba4605 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash18.C @@ -0,0 +1,18 @@ +// { dg-do compile } +// GROUPS passed old-abort +typedef int element; +class Pix { +public: + Pix(); + Pix(const Pix&); + + // Friend functions so that v == x works as does x == v works + friend int operator==(void *v, const Pix& x) // { dg-error "previously" } + { return v == index; } // { dg-error "from this location" } + // ??? should be operator!= + friend int operator==(void *v, const Pix& x) // { dg-error "redefinition" } + { return v != index; } +private: +// friend class List<T>; + element *index; // { dg-error "invalid use of non-static data member" } +}; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash2.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash2.C new file mode 100644 index 000000000..50aebdc6d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash2.C @@ -0,0 +1,10 @@ +// { dg-do assemble } +// GROUPS passed old-abort +// The compiler used to crash on this example. + +class x { +public: + x(); + static const x y[23]; +}; +const x x::y[23]; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash20.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash20.C new file mode 100644 index 000000000..93dc58cb1 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash20.C @@ -0,0 +1,14 @@ +// { dg-do assemble } +// GROUPS passed old-abort +#include <complex> +typedef std::complex<double> Complex; + +Complex ComputeVVself() +{ +Complex temp1; +Complex self[3][3]; + + self[1][2] = 100.0; + return self[1][2]; + +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash22.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash22.C new file mode 100644 index 000000000..73831a053 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash22.C @@ -0,0 +1,11 @@ +// { dg-do assemble } +// GROUPS passed old-abort +struct A { + void a1(); + void a2(); +}; + +struct B { + void A::a1(); // this used to die in chainon(), now grokdeclarator should// { dg-error "" } cannot declare.* + void A::a2(); // should be fixed by the 930629 change.// { dg-error "" } cannot declare.* +}; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash23.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash23.C new file mode 100644 index 000000000..250686979 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash23.C @@ -0,0 +1,15 @@ +// { dg-do assemble } +// GROUPS passed old-abort +// This used to die in chainon; it shouldn't any more. + +class A +{ +public: + class B { + public: + void f (); + void g (int); + }; + void B::f () {}// { dg-error "" } .* + void B::g (int val) {}// { dg-error "" } .* +}; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash24.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash24.C new file mode 100644 index 000000000..42d0fabc2 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash24.C @@ -0,0 +1,19 @@ +// { dg-do assemble } +// { dg-options "-O" } +// GROUPS passed old-abort +// gcc puts the array into a register, and then the store_bit_field () code +// in expmed.c gets confused when it tries to store zero past the end of the +// register (because the index is past the array bounds). It ends up calling +// store_split_bit_field, which then aborts, because we don't have a split bit +// field. +// +// Seems easiest to detect this case in the front end, i.e. access outside the +// array bounds, and then force the array to be allocated on the stack instead +// of a register. + +main() +{ + char i[1]; + + i[1] = 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash25.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash25.C new file mode 100644 index 000000000..dece6f7dc --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash25.C @@ -0,0 +1,18 @@ +// { dg-do assemble } +// GROUPS passed old-abort +class memo{ +public: + static int rep; +}; + +class port_head : public memo { +public: + static int rep; + unsigned cap(); +}; + +class buff_head : private port_head { +public: + static int rep; + port_head::cap; +}; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash26.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash26.C new file mode 100644 index 000000000..b89a2fae1 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash26.C @@ -0,0 +1,11 @@ +// { dg-do assemble } +// GROUPS passed old-abort +struct B { + B(); +}; + +class C : virtual public B +{ + public: + C() { } +}; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash27.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash27.C new file mode 100644 index 000000000..7aa0e593b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash27.C @@ -0,0 +1,20 @@ +// { dg-do assemble } +// GROUPS passed old-abort +class First { +public: + First(const First& a); +}; + +class Second { + int i; + First f; +public: + ~Second() {} + Second func(); +}; + +void foo() +{ + extern Second x; + x = x.func(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash28.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash28.C new file mode 100644 index 000000000..dcb2dce5b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash28.C @@ -0,0 +1,12 @@ +// { dg-do assemble } +// GROUPS passed old-abort + class abc + { + public: + void F() { return; } + + private: + typedef int myint; + typedef struct { int b; } mystruct; + typedef union { int c; } myunion; + }; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash29.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash29.C new file mode 100644 index 000000000..38c9d49a1 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash29.C @@ -0,0 +1,20 @@ +// { dg-do assemble } +// GROUPS passed old-abort + +union Value +{ + Value(){} +}; + +struct GlobalAddress // { dg-message "note" } +{ + GlobalAddress(Value *nvar){} // { dg-message "note" } +}; + +int +main() +{ + new GlobalAddress(Value()); // internal error occured here// { dg-error "no matching" } + // { dg-message "candidate" "candidate note" { target *-*-* } 17 } + //new GlobalAddress(new Value()); // This line is correct code +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash3.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash3.C new file mode 100644 index 000000000..c5088f10d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash3.C @@ -0,0 +1,14 @@ +// { dg-do assemble } +// GROUPS passed old-abort +int strcmp(); + +extern "C" { + // dies in common_type, cuz the TREE_TYPE of t2 is 0, so it can't get its + // TYPE_MAIN_VARIANT value. + // <void_type 184510 void permanent VOID + // size <integer_cst 1844e0 type <integer_type 182548 int> constant permanent 0 + // align 1 symtab 0 + // pointer_to_this <pointer_type 1845e0> + +int strcmp(const char*, const char*); +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash30.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash30.C new file mode 100644 index 000000000..937cb1029 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash30.C @@ -0,0 +1,10 @@ +// { dg-do assemble } +// GROUPS passed old-abort +#include <string> + +int +main(void) { + + std::string a[] = {"Hello"}; + +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash31.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash31.C new file mode 100644 index 000000000..83cdf2add --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash31.C @@ -0,0 +1,16 @@ +// { dg-do assemble } +// GROUPS passed old-abort +struct mbuf { + struct mbuf *next; +}; + +void* malloc(int); +struct mbuf * +mbuf_allocate(int size) +{ + struct mbuf *bp; + + bp = (struct mbuf *) malloc( 10 /*(unsigned) (size + sizeof(struct mbuf))*/); + return bp; + +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash32.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash32.C new file mode 100644 index 000000000..955e68c68 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash32.C @@ -0,0 +1,5 @@ +// { dg-do assemble } +// { dg-options "-fshort-enums" } +// GROUPS passed old-abort +enum Bool { FALSE, TRUE }; +Bool foo () { return TRUE; } diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash33.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash33.C new file mode 100644 index 000000000..1f9944826 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash33.C @@ -0,0 +1,7 @@ +// { dg-do assemble } +// GROUPS passed old-abort +extern void foo(void *); +int +main() { + foo((struct bar *)0); +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash34.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash34.C new file mode 100644 index 000000000..6ac1ef0cd --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash34.C @@ -0,0 +1,3 @@ +// { dg-do assemble } +// GROUPS passed old-abort +operator int () {}// { dg-error "" } .*// ERROR - .* diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash35.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash35.C new file mode 100644 index 000000000..93a0aeb9c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash35.C @@ -0,0 +1,20 @@ +// { dg-do assemble } +// GROUPS passed old-abort +const unsigned int ENET_INTERRUPT_MID = 5; + +extern "C" void ENET_RxP(); + +class EnetReceiver + { + public: + friend void ENET_RxP(); + void receiveMessage(); + int *messagePointer; + }; + +void EnetReceiver::receiveMessage() + { + if (*((unsigned int*) messagePointer) == ENET_INTERRUPT_MID) + { + } + } diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash36.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash36.C new file mode 100644 index 000000000..79b3e4602 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash36.C @@ -0,0 +1,7 @@ +// { dg-do assemble } +// GROUPS passed old-abort +struct wait { int w_status; }; +int wait(); +extern "C" int wait(int*); + + diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash37.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash37.C new file mode 100644 index 000000000..0e46c9359 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash37.C @@ -0,0 +1,16 @@ +// { dg-do assemble } +// GROUPS passed old-abort +typedef int _sigset_t; +extern "C" { + extern int sigaction(int signo, const struct sigaction *action_spec_p, struct sigaction *old_action_p); +} +extern "C" { + extern void foo(); +} +class SS { + friend void foo(); +protected: + void goo(); +}; +inline void +SS::goo() { } diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash38.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash38.C new file mode 100644 index 000000000..80ef47180 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash38.C @@ -0,0 +1,43 @@ +// { dg-do assemble } +// GROUPS passed old-abort +/* + I received the following message when using g++ (version 2.3.3): + + main.cc: In method 'Implicit<implicit<INTEGER,2>,3>::Implicit()': + main.cc: Internal compiler error 241. + main.cc: Please report this to 'bug-g++@prep.ai.mit.edu' + */ + +#include <iostream> + +class INTEGER { +int x; +public: + typedef int BASE; + INTEGER(int y) : x(y) {} + INTEGER() {} + void encode() { std::cout << "Integer encoder";} + int operator=(int y) { x=y; return x; } + operator int() {return x; } +}; + +template< class T, int n> class Implicit : public T { + public: + typedef typename T::BASE BASE; + Implicit(BASE value ): T(value) {} + Implicit() : T() {} + int myTag() { return n; } + void encode() { T::encode(); } + BASE operator=(BASE t) { return T::operator=(t); } +}; + +int +main() +{ + Implicit<Implicit<INTEGER, 2> , 3> y; + + y = 10; +} + + + diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash39.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash39.C new file mode 100644 index 000000000..392c0a009 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash39.C @@ -0,0 +1,33 @@ +// { dg-do assemble } +// { dg-options "-w" } +// GROUPS passed old-abort +//#include <GetOpt.h> +#include <stdio.h> + +class GetOpt +{ +private: + static char *nextchar; + enum OrderingEnum { REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER }; + OrderingEnum ordering; + static int first_nonopt; + static int last_nonopt; + void exchange (char **argv); +public: + char *optarg; + int optind; + int opterr; + + int nargc; + char **nargv; + const char *noptstring; + + GetOpt (int argc, char **argv, const char *optstring); + int operator () (void); +}; +//end <GetOpt.h> +#include <string> + +class foo {public: foo () {}}; +class bar {public: bar (const foo& dflt);}; +class baz: public bar {public: baz (): bar (foo ()) {}}; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash4.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash4.C new file mode 100644 index 000000000..34ef2dddb --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash4.C @@ -0,0 +1,6 @@ +// { dg-do assemble } +// GROUPS passed old-abort +typedef struct Thing { + Thing(); + int x; +} Thing; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash40.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash40.C new file mode 100644 index 000000000..e5b174457 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash40.C @@ -0,0 +1,17 @@ +// { dg-do assemble } +// GROUPS passed old-abort +class foo { + +public: + + virtual foo &operator <<(foo &(foo::*)(foo &)); +}; + + +foo &foo::operator<<(foo &(foo::*manip)(foo &)) +{ + + (this->*manip)(*this); + + return *this; +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash41.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash41.C new file mode 100644 index 000000000..188c09ba3 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash41.C @@ -0,0 +1,11 @@ +// { dg-do assemble } +// GROUPS passed old-abort +typedef void (**ppfn)(void); + +int main() { + ppfn fn; + + fn = new (void(*)(void)); + + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash42.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash42.C new file mode 100644 index 000000000..8777ef82c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash42.C @@ -0,0 +1,6 @@ +// { dg-do assemble } +// GROUPS passed old-abort +int fn();// { dg-error "" } ambiguates.* +int x; +int& fn() {// { dg-error "" } new decl.* +return x;} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash43.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash43.C new file mode 100644 index 000000000..8c73d70d0 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash43.C @@ -0,0 +1,25 @@ +// { dg-do assemble } +// { dg-xfail-if "" { sparc64-*-elf } { "*" } { "" } } +// { dg-options "-g" } +// GROUPS passed old-abort +extern "C" { typedef int jmp_buf[12]; } + +enum Error { NO_ERROR }; +class ErrorHandler +{ + ErrorHandler *previous; + static ErrorHandler *error_stack; + jmp_buf error_buffer; +protected: + static void pop() + { + error_stack = error_stack->previous; + } +public: + jmp_buf *push() + { + previous = error_stack; + error_stack = this; + return &error_buffer; + } +}; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash44.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash44.C new file mode 100644 index 000000000..2439daf91 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash44.C @@ -0,0 +1,27 @@ +// { dg-do assemble } +// GROUPS passed old-abort +template <class T> class bug { + +public: + void Foo(const int = 0); + void NotRedeclared(const int); + +private: + T TheItem; +}; + +template <class T> void bug<T>::NotRedeclared(const int) +{ +} + +template <class T> void bug<T>::Foo(const int) +{ +} + +int +main() +{ + bug<char> InstantiatedBug; + + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash45.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash45.C new file mode 100644 index 000000000..b9eb6c7a7 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash45.C @@ -0,0 +1,3 @@ +// { dg-do assemble } +// GROUPS passed old-abort +void foo() { static const char *const v[] = { 0 }; } diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash46.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash46.C new file mode 100644 index 000000000..53cbd1027 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash46.C @@ -0,0 +1,26 @@ +// { dg-do assemble } +// GROUPS passed old-abort +class Rational { +public: + Rational(int v): value(v) + { } + + int value; +}; +typedef Rational __Rational; + +extern int operator>(const Rational&, const Rational&); + +class V { +public: + class Rational { + public: + static int x(const __Rational& value); + }; +}; + +int +V::Rational::x(const __Rational& value) +{ + return value > 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash47.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash47.C new file mode 100644 index 000000000..3afa5fa99 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash47.C @@ -0,0 +1,94 @@ +// { dg-do assemble } +// GROUPS passed old-abort +const int TRUE = 1; +const int FALSE = 0; + +class Rep { +protected: + Rep(): count(0) + { } + Rep(const Rep& other): count(0) + { } + + Rep& operator=(const Rep& other) + { /* DO NOT copy over other.count */ + return *this; } + +public: // TODO - for now + // Because it is to hard to restrict these operations to the descendants + // of Rep<REP> that we haven't named yet. So we just make them public. + void inc() + { count++; } + void dec() + { if (0 == --count) delete this; } +private: + unsigned count; +}; + +template<class REP> +class Ref { +public: + Ref(): rep(0) + { } + Ref(const Ref<REP>& other): rep(other.rep) + { if (rep) rep->inc(); } + ~Ref() + { if (rep) rep->dec(); + rep = 0; } + + Ref<REP>& operator=(const Ref<REP>& other) + { if (rep != other.rep) { + if (rep) rep->dec(); + rep = other.rep; + if (rep) rep->inc(); } + return *this; } + + bool null() const + { return 0 == rep ? TRUE: FALSE; } + bool valid() const + { return 0 != rep ? TRUE: FALSE; } + + REP* operator->() const // should be a valid() reference + { return rep; } + operator REP*() const; // should be a valid() reference + +protected: + REP *rep; + + Ref(REP *r): rep(r) + { if (rep) rep->inc(); } + + Ref<REP>& operator=(REP *r) + { if (rep != r) { + if (rep) rep->dec(); + rep = r; + if (rep) rep->inc(); } + return *this; } +}; + +template<class REP> +Ref<REP>::operator REP*() const // should be a valid() reference +{ return rep; } + +template<class REP> +inline int +operator==(const Ref<REP>& a, const Ref<REP>& b) +{ return (REP *) a == (REP *) b; } + +template<class REP> +inline int +operator!=(const Ref<REP>& a, const Ref<REP>& b) +{ return (REP *) a != (REP *) b; } + +class XRep: public Rep { +public: + int i; +}; + +int +main() +{ + Ref<XRep> y; + + return y != y; +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash48.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash48.C new file mode 100644 index 000000000..fe759406e --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash48.C @@ -0,0 +1,24 @@ +// { dg-do compile } +// GROUPS passed old-abort +class internal { // { dg-message "internal::internal|candidate expects|no known conversion" } + int field; + int anotherfield; +}; + +class bug { // { dg-message "bug::bug|candidate expects" } + internal* numbers; + bug(int size); +}; + +bug::bug(int size) // { dg-message "bug::bug|candidate expects" } +{ + numbers = new internal(size * size);// { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 15 } +} + +int +main() +{ + bug test; // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 22 } +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash49.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash49.C new file mode 100644 index 000000000..e0664da28 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash49.C @@ -0,0 +1,12 @@ +// { dg-do assemble } +// GROUPS passed old-abort +#include<iostream> + +const int keys = 10; +const int key[keys] = {6, key[1], 2, keys, 1, 7, 6, key[2], key[8]}; + +void main() // { dg-error "must return .int" } +{ + for(int i = 0; i < keys;) std::cout << key[i++] << " "; + std::endl(std::cout); +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash5.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash5.C new file mode 100644 index 000000000..6b9696ea6 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash5.C @@ -0,0 +1,105 @@ +// { dg-do assemble } +// GROUPS passed old-abort +// Should have been fixed by: +// +// Sun Jun 13 12:55:22 1993 Brendan Kehoe (brendan@lisa.cygnus.com) +// +// * cp-cvt.c (build_default_binary_type_conversion): Look deeper into +// what ARG1 and ARG2 are if they're POINTER_TYPEs. + +class CountableSet +{ + public: + virtual ~CountableSet() { } +}; + +template<class T> +class FixedSet : virtual public CountableSet +{ + public: + virtual int Get(int, T&) = 0; + virtual ~FixedSet() { } +}; + +class ShrinkableSet +{ + public: + virtual int Remove(int) = 0; +}; + +template<class T> +class PVSet : virtual public FixedSet<T>, virtual public ShrinkableSet +{ + public: + virtual void Append(const T&) = 0; + virtual void operator+=(const T& a) { Append(a); } + virtual ~PVSet() { } +}; + +template<class T> +class MutSet : virtual public FixedSet<T>, virtual public FixedSet<T *> +{ + protected: + typedef T *Tp; + + public: + void Append(const Tp& tp) { Append(*tp); } + + T& Access(int p) + { + Tp tp; + Get(p, tp); + return *tp; + } + virtual ~MutSet() { } +}; + +template <class T> +class SimpleSet : virtual public MutSet<T> +{ + protected: + T *array; + int size; + + virtual void Allocate(int s) + { + array = new T[s]; + } + public: + SimpleSet() + { + size = 0; + array = 0; + } + int Get(int p, T& t) + { + t = array[p-1]; + return 1; + } + int Get(int p, T *& t) + { + t = &array[p-1]; + return 1; + } + inline void Append(const T& a) + { + array[size-1] = a; + } + inline int Remove(int n) { return 0; } +}; + +class Dummy +{ + public: + Dummy() {} +}; + +int +main() +{ + SimpleSet<Dummy *> bs1; + int i, j; + Dummy foo; + + bs1+=&foo;// { dg-error "" } no .* +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash50.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash50.C new file mode 100644 index 000000000..598c029f7 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash50.C @@ -0,0 +1,29 @@ +// { dg-do assemble } +// GROUPS passed old-abort +class B + { +public: + int i; + }; +int operator & (const B &s) { return ( s.i );} + + + + + +class C + { +public: + C &operator = (const C &x) + { + return *this; + } + }; + +C &(C::*DD)(const C &x) = &C::operator=; + +int main() +{ + ⅅ + +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash51.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash51.C new file mode 100644 index 000000000..0c4e0beab --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash51.C @@ -0,0 +1,24 @@ +// { dg-do assemble } +// GROUPS passed old-abort +class obj; + +typedef obj *obj_t; + +class obj { +public: + obj( const obj& o ); +}; + +extern obj nowhere; + +class set: public obj { + unsigned bit_vector; +public: + set( const obj& o ); + set& operator|=( const int q ); +}; + +enum pin_enum { E_F, O_C, O_D, O_S, P_D, P_U, R, T, A, C }; + +set t_q = ( ( ( ( ( ( set( nowhere ) |= E_F ) |= O_C ) |= O_D ) |= O_S ) + |= P_U ) |= P_D ) |= T; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash52.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash52.C new file mode 100644 index 000000000..6db818aa1 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash52.C @@ -0,0 +1,13 @@ +// { dg-do assemble } +// { dg-options "-Wreturn-type" } +// GROUPS passed old-abort +#include <iostream> + +class A { +public: + friend A f(A &a);// { dg-error "ambiguates" } +}; + +A &f(A &a) {// { dg-error "new decl" } + std::cout << "Blah\n"; +} // { dg-warning "no return statement" } diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash53.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash53.C new file mode 100644 index 000000000..127c1d0ff --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash53.C @@ -0,0 +1,24 @@ +// { dg-do assemble } +// GROUPS passed old-abort +class A +{ + public: + class B + { + public: + virtual ~B(); + }; +}; + +template<int I> +class C +{ + public: + class B + : public A::B + { + }; // bug2.cc:18: Internal compiler error 233. + // bug2.cc:18: Please submit a full bug report to `bug-g++@prep.ai.mit.edu'. +}; + +C<0> c; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash54.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash54.C new file mode 100644 index 000000000..4ed66d15a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash54.C @@ -0,0 +1,9 @@ +// { dg-do assemble } +// GROUPS passed old-abort +int main() +{ + int a[100], **p; + + p = &a[50];// { dg-error "" } assignment to.* + +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash55.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash55.C new file mode 100644 index 000000000..829596241 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash55.C @@ -0,0 +1,12 @@ +// { dg-do compile } +// GROUPS passed old-abort + extern int f(int); // { dg-error "ambiguates" } + + int& f(int x) // { dg-error "new declaration" } + { + int local; // { dg-warning "reference to local" } + + local = x+2; + + return local; + } diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash56.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash56.C new file mode 100644 index 000000000..ad652cf93 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash56.C @@ -0,0 +1,391 @@ +// { dg-do assemble } +// { dg-options "" } +// GROUPS passed old-abort + +const bool FALSE = 0; +const bool TRUE = 1; +class ListDProto { +protected: + class link; +public: + ListDProto(); + ListDProto(const ListDProto&); + virtual ~ListDProto(); + void operator=(const ListDProto&); + unsigned length() const; + bool empty() const; + void clear(); + void remove_head(); + void remove_tail(); + class Vix { + public: + Vix(); + friend int operator==(void *v, const Vix& x) + { return v == x.item; } + friend int operator==(const Vix& x, void *v) + { return v == x.item; } + friend int operator!=(void *v, const Vix& x) + { return v != x.item; } + friend int operator!=(const Vix& x, void *v) + { return v != x.item; } + friend int operator==(const Vix& x1, const Vix& x2) + { return x1.owner == x2.owner && x1.item == x2.item; } + friend int operator!=(const Vix& x1, const Vix& x2) + { return x1.owner != x2.owner || x1.item != x2.item; } + bool first; + bool last; + protected: + friend class ListDProto; + Vix(const ListDProto *o, link *i); + const ListDProto *owner; + private: + link *item; + }; + enum Action { NORMAL, REMOVE_CURRENT }; + Vix first() const; + void first(Vix& x) const; + void next(Vix& x) const; + void next(Vix& x, Action a = NORMAL); + Vix last() const; + void last(Vix& x) const; + void prev(Vix& x) const; + void prev(Vix& x, Action a = NORMAL); +protected: + struct link { + link *next; + link *prev; + link(link *n = 0, link *p = 0); + virtual ~link(); + private: + link(const link&); + void operator=(const link&); + }; + unsigned count; + link *list_head; + link *list_tail; + virtual link *copy_item(link *old_item) const = 0; + void prepend(link *item); + void append(link *item); + void prepend(const ListDProto& proto); + void append(const ListDProto& proto); + void remove(link *item); + link *ref(const Vix&) const; +}; +template<class T> +class ListD: public ListDProto { +public: + void prepend(const T& item); + void append(const T& item); + const T& head() const; + T& head(); + void head(T& fill) const; + void remove_head() + { ListDProto::remove_head(); } + void remove_head(T& fill); + const T& tail() const; + T& tail(); + void tail(T& fill) const; + void remove_tail() + { ListDProto::remove_tail(); } + void remove_tail(T& fill); + class Vix: public ListDProto::Vix { + public: + Vix(): ListDProto::Vix() + { } + protected: + friend class ListD<T>; + Vix(const ListDProto::Vix& x): ListDProto::Vix(x) + { } + }; + Vix first() const + { return ListDProto::first(); }; + void first(Vix& x) const + { ListDProto::first(x); }; + void next(Vix& x, ListDProto::Action a = NORMAL) const + { ListDProto::next(x, a); }// { dg-error "" } .*// ERROR - .* + Vix last() const + { return ListDProto::last(); } + void last(Vix& x) const + { return ListDProto::last(x); } + void prev(Vix& x, ListDProto::Action a = NORMAL) const + { return ListDProto::prev(x, a); } +protected: + struct link_item: public ListDProto::link { + T item; + link_item(const T& i): link(0, 0), item(i) + { } + private: + link_item(const link_item&); + void operator=(const link_item&); + }; +public: + T& operator()(const Vix& x) + { link_item *li = (link_item *) ref(x); + return li->item; } + const T& operator()(const Vix& x) const + { link_item *li = (link_item *) ref(x); + return li->item; } +private: + ListDProto::link *copy_item(ListDProto::link *old_item) const; +}; +template<class T> +class SetLD: private ListD<T> { +public: + SetLD(); + SetLD(const ListD<T>&); + void add(const T& item); + void add(const ListD<T>& other); + void add(const SetLD<T>& other); + void remove(const T& item); + bool contains(const T& item) const; + ListD<T>::length; + ListD<T>::empty; + ListD<T>::clear; + typedef typename ListD<T>::Vix Vix; + ListD<T>::first; + ListD<T>::next; + ListD<T>::operator(); + + using ListD<T>::NORMAL; + using ListD<T>::REMOVE_CURRENT; +}; +extern "C" { +extern void __eprintf (const char *, const char *, unsigned, const char *); +} +extern "C" { +extern void __eprintf (const char *, const char *, unsigned, const char *); +} +template<class T> +void +ListD<T>::prepend(const T& item) +{ + link *newl = new link_item(item); + ListDProto::prepend(newl); +} +template<class T> +void +ListD<T>::append(const T& item) +{ + link *newl = new link_item(item); + ListDProto::append(newl); +} +template<class T> +const T& +ListD<T>::head() const +{ + ((void) (( 0 != list_head ) ? 0 : (__eprintf ("%s:%u: failed assertion `%s'\n", "/home/wbaker/work/include/templates/ListD.body.h" , 50 , "0 != list_head" ), 0) )) ; + link_item *h = (link_item *) list_head; + return h->item; +} +template<class T> +T& +ListD<T>::head() +{ + ((void) (( 0 != list_head ) ? 0 : (__eprintf ("%s:%u: failed assertion `%s'\n", "/home/wbaker/work/include/templates/ListD.body.h" , 59 , "0 != list_head" ), 0) )) ; + link_item *h = (link_item *) list_head; + return h->item; +} +template<class T> +void +ListD<T>::head(T& fill) const +{ + ((void) (( 0 != list_head ) ? 0 : (__eprintf ("%s:%u: failed assertion `%s'\n", "/home/wbaker/work/include/templates/ListD.body.h" , 68 , "0 != list_head" ), 0) )) ; + link_item *h = (link_item *) list_head; + fill = h->item; +} +template<class T> +void +ListD<T>::remove_head(T& fill) +{ + head(fill); + remove_head(); +} +template<class T> +const T& +ListD<T>::tail() const +{ + ((void) (( 0 != list_tail ) ? 0 : (__eprintf ("%s:%u: failed assertion `%s'\n", "/home/wbaker/work/include/templates/ListD.body.h" , 85 , "0 != list_tail" ), 0) )) ; + link_item *h = (link_item *) list_tail; + return h->item; +} +template<class T> +T& +ListD<T>::tail() +{ + ((void) (( 0 != list_tail ) ? 0 : (__eprintf ("%s:%u: failed assertion `%s'\n", "/home/wbaker/work/include/templates/ListD.body.h" , 94 , "0 != list_tail" ), 0) )) ; + link_item *h = (link_item *) list_tail; + return h->item; +} +template<class T> +void +ListD<T>::tail(T& fill) const +{ + ((void) (( 0 != list_tail ) ? 0 : (__eprintf ("%s:%u: failed assertion `%s'\n", "/home/wbaker/work/include/templates/ListD.body.h" , 103 , "0 != list_tail" ), 0) )) ; + link_item *h = (link_item *) list_tail; + fill = h->item; +} +template<class T> +void +ListD<T>::remove_tail(T& fill) +{ + ((void) (( 0 != list_tail ) ? 0 : (__eprintf ("%s:%u: failed assertion `%s'\n", "/home/wbaker/work/include/templates/ListD.body.h" , 112 , "0 != list_tail" ), 0) )) ; + link_item *h = (link_item *) list_tail; + fill = h->item; +} +template<class T> +ListDProto::link * +ListD<T>::copy_item(ListDProto::link *old) const +{ + link_item *old_item = (link_item *) old; + link_item *new_item = new link_item(old_item->item); + return new_item; +} +template<class T> +SetLD<T>::SetLD(): +ListD<T>() +{ } +template<class T> +SetLD<T>::SetLD(const ListD<T>& other): +ListD<T>(other) +{ } +template<class T> +void +SetLD<T>::add(const T& item) +{ + if ( ! contains(item) ) + append(item); +} +template<class T> +void +SetLD<T>::add(const ListD<T>& other) +{ + typename ListD<T>::Vix x; + for (first(x); 0 != x; next(x)) + add(other(x)); +} +template<class T> +void +SetLD<T>::add(const SetLD<T>& other) +{ + const ListD<T>& lother = other; + add(lother); +} +template<class T> +void +SetLD<T>::remove(const T& item) +{ + typename ListD<T>::Action a = this->NORMAL; + Vix x; + for (first(x); 0 != x && this->REMOVE_CURRENT != a; next(x, a)) + a = operator()(x) == item ? this->REMOVE_CURRENT: this->NORMAL; // { dg-error "" } .* + // { dg-message "candidate" "candidate note" { target *-*-* } 280 } +} +template<class T> +bool +SetLD<T>::contains(const T& item) const +{ + Vix x; + for (first(x); 0 != x; next(x)) { + if (operator()(x) == item)// { dg-error "" } .* + // { dg-message "candidate" "candidate note" { target *-*-* } 289 } + return TRUE; + } + return FALSE; +} +template<class T> +int +operator==(const SetLD<T>& a, const SetLD<T>& b) // { dg-message "note" } +{ + if (a.length() != b.length()) + return FALSE; + typename SetLD<T>::Vix x; + for (a.first(x); 0 != x; a.next(x)) { + if ( ! b.contains(a(x)) ) + return FALSE; + } + for (b.first(x); 0 != x; b.next(x)) { + if ( ! a.contains(b(x)) ) + return FALSE; + } + return TRUE; +} +template<class T> +int +operator!=(const SetLD<T>& a, const SetLD<T>& b) +{ return ! (a == b); } +template<class T> +int +operator<=(const SetLD<T>& a, const SetLD<T>& b) +{ + if (a.length() > b.length()) + return FALSE; + typename SetLD<T>::Vix x; + for (x=a.first(); 0 != x; a.next(x)) { + if ( ! b.contains(a(x)) ) + return FALSE; + } + return TRUE; +} +template<class T> +int +operator<(const SetLD<T>& a, const SetLD<T>& b) +{ + if (a.length() >= b.length()) + return FALSE; + return a <= b; +} +template<class T> +int +operator>(const SetLD<T>& a, const SetLD<T>& b) +{ return ! (a <= b); } +template<class T> +int +operator>=(const SetLD<T>& a, const SetLD<T>& b) +{ return ! (a < b); } +class String { }; +class IcaseString: public String { }; +template <> class SetLD< IcaseString >: public SetLD< String > { public: SetLD (): SetLD< String >() { }; SetLD (const ::ListD< IcaseString >& other): SetLD< String >() { ::ListD< IcaseString >::Vix x; for (other.first(x); 0 != x; other.next(x)) add(other(x)); }; SetLD (const SetLD & other): SetLD< String >(other) { }; const IcaseString & operator()(const Vix& x) const { return ( IcaseString &) SetLD< String >::operator()(x); } }; typedef SetLD< String > SetLD_String_IcaseString_old_tmp99; typedef SetLD< IcaseString > SetLD_String_IcaseString_new_tmp99; +inline int operator== (const SetLD_String_IcaseString_new_tmp99& a, const SetLD_String_IcaseString_new_tmp99& b) // { dg-message "operator==|no known conversion" } +{ +const SetLD_String_IcaseString_old_tmp99& oa = a; +const SetLD_String_IcaseString_old_tmp99& ob = b; +return operator== (oa, ob); } +inline int operator!= (const SetLD_String_IcaseString_new_tmp99& a, const SetLD_String_IcaseString_new_tmp99& b) +{ +const SetLD_String_IcaseString_old_tmp99& oa = a; +const SetLD_String_IcaseString_old_tmp99& ob = b; +return operator!= (oa, ob); } +inline int operator< (const SetLD_String_IcaseString_new_tmp99& a, const SetLD_String_IcaseString_new_tmp99& b) +{ +const SetLD_String_IcaseString_old_tmp99& oa = a; +const SetLD_String_IcaseString_old_tmp99& ob = b; +return operator< (oa, ob); } +inline int operator<= (const SetLD_String_IcaseString_new_tmp99& a, const SetLD_String_IcaseString_new_tmp99& b) +{ +const SetLD_String_IcaseString_old_tmp99& oa = a; +const SetLD_String_IcaseString_old_tmp99& ob = b; +return operator<= (oa, ob); } +inline int operator> (const SetLD_String_IcaseString_new_tmp99& a, const SetLD_String_IcaseString_new_tmp99& b) +{ +const SetLD_String_IcaseString_old_tmp99& oa = a; +const SetLD_String_IcaseString_old_tmp99& ob = b; +return operator> (oa, ob); } +inline int operator>= (const SetLD_String_IcaseString_new_tmp99& a, const SetLD_String_IcaseString_new_tmp99& b) +{ +const SetLD_String_IcaseString_old_tmp99& oa = a; +const SetLD_String_IcaseString_old_tmp99& ob = b; +return operator>= (oa, ob); } +typedef SetLD<IcaseString> SLDiS; +static void +nop(int i) +{ + SetLD<IcaseString> x, y; + nop(x == y); + nop(x != y); +nop(x < y); +nop(x <= y); +nop(x > y); +nop(x >= y); +} + +template class SetLD<String>; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash57.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash57.C new file mode 100644 index 000000000..b4599fc7e --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash57.C @@ -0,0 +1,13 @@ +// { dg-do assemble } +// GROUPS passed old-abort +class foo { +private: + char buffer[1024]; +public: + foo(); +}; + +int main() +{ + static foo& a = *(new foo); +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash58.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash58.C new file mode 100644 index 000000000..7d5f6597c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash58.C @@ -0,0 +1,10 @@ +// { dg-do assemble } +// GROUPS passed old-abort +class X { +public: +void doit(); +}; + +X::::doit()// { dg-error "" } (syntax|parse) error.* +{ +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash6.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash6.C new file mode 100644 index 000000000..b975237a8 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash6.C @@ -0,0 +1,17 @@ +// { dg-do assemble } +// GROUPS passed old-abort +// Should be fixed by: +// Sun Jun 13 12:55:22 1993 Brendan Kehoe (brendan@lisa.cygnus.com) +// +// * cp-decl.c (start_function): Avoid a null-reference on CTYPE. + +template<int> +class Program { +} ; + +template<> +class Program<0> { +public: + inline friend float EvalNextArg() + { return 1.0 ; } +} ; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash60.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash60.C new file mode 100644 index 000000000..a59d72a7b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash60.C @@ -0,0 +1,12 @@ +// { dg-do assemble } +// GROUPS passed old-abort +class X +{ +public: + X (); + int f[4]; +}; + +// Note that we mistakenly initialize the array data member as if it +// was scalar +X::X () : f (0) {}// { dg-error "" } .* diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash61.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash61.C new file mode 100644 index 000000000..86e347fef --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash61.C @@ -0,0 +1,5 @@ +// { dg-do assemble } +// GROUPS passed old-abort + template <class TP> class sapp { }; + class foo {}; + extern foo& __iomanip_setw (foo&, TP);// { dg-error "" } type spec.* diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash62.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash62.C new file mode 100644 index 000000000..7147c9a8e --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash62.C @@ -0,0 +1,32 @@ +// { dg-do assemble } +// GROUPS passed old-abort +#include <iostream> + + void + fubar(std::ostream* out, const char* s) + { + (*out) << s << std::endl; + return; + } + + int + main() + { + // Declare a ref and a pointer to the same ostream. + // + std::ostream* out = &std::cerr; + std::ostream& die = std::cerr; + + // Valid call to fubar. + // + fubar(out, "First line."); + + // Invalid call to fubar. (1st arg is an ostream&. fubar expects + // ostream*.)This should be a syntax error, but g++ does not catch it. + // Call to this function results in a bus error in fubar when the 1st + // arg is dereferenced. + // + fubar(die, "Second line.");// { dg-error "" } cannot convert .die.* + + return 1; + } diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash63.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash63.C new file mode 100644 index 000000000..89685fcae --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash63.C @@ -0,0 +1,16 @@ +// { dg-do assemble } +// GROUPS passed old-abort +class String + { + public: + String (const char *str); + String (const String&); + }; + +class UnitList + { + public: + UnitList (...); + }; + +UnitList unit_list (String("keV")); // { dg-error "" } cannot pass non-pod diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash64.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash64.C new file mode 100644 index 000000000..3c9869283 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash64.C @@ -0,0 +1,19 @@ +// { dg-do assemble } +// GROUPS passed old-abort +typedef __SIZE_TYPE__ size_t; +typedef void (*RF_Ptr)(void *); + +struct _im_pers_mem_spec { + _im_pers_mem_spec(void ); + _im_pers_mem_spec(auto int of, auto int n); +}; + +struct _type_desc { + _type_desc(const char *, int , RF_Ptr , int , int ,...); +}; + +struct metatype { int base_list; }; + +static _type_desc _type_metatype("metatype", sizeof(metatype), + (RF_Ptr)0, 0, 1, 1, + _im_pers_mem_spec( ((size_t)&((( metatype *)0)-> base_list )) , 1)); diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash65.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash65.C new file mode 100644 index 000000000..1bf6c4b6b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash65.C @@ -0,0 +1,14 @@ +// { dg-do assemble } +// GROUPS passed old-abort +class X { +public: + virtual const char* XY(const void* val) const = 0; +}; + + +class Y : public X { +public: + using X::xy;// { dg-error "" } no memb.* + + using X::z;// { dg-error "" } no memb.* +}; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash66.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash66.C new file mode 100644 index 000000000..321c55130 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash66.C @@ -0,0 +1,137 @@ +// { dg-do assemble } +// { dg-options "-O" } +// GROUPS passed old-abort +typedef unsigned char uchar; +typedef unsigned short ushort; +typedef unsigned long ulong; +extern int swap_endian; +inline ushort +swapshort(ushort value) +{ + value &= 0xffff; + return ((value << 8) | (value >> 8)); +} +struct eshort +{ + ushort data; + operator ushort() { return swap_endian ? swapshort(data) : data;} + eshort(ushort t) { data = swap_endian ? swapshort(t) : t;} + eshort() {} +}; +inline ulong +swaplong(ulong value) +{ + ulong v = (value << 16) | (value >> 16); + return ((v >> 8) & 0x00ff00ff) | ((v << 8) & 0xff00ff00); +} +struct elong +{ + ulong data; + operator ulong() { return swap_endian ? swaplong(data) : data;} + elong(ulong t) { data = swap_endian ? swaplong(t) : t; } + elong() {} +}; +struct digiheader +{ + uchar type[2]; + eshort soft_version; + eshort lo_boot_rev; + eshort hi_boot_rev; + eshort load_segment; + eshort length; + eshort exec_start; + eshort image_offset; + elong startup_code[2]; + elong checksum; +}; +extern void uncompress(uchar* buf, ulong len); +extern ulong compress(char* filename, uchar* buffer, ulong); +struct filehdr +{ + eshort f_magic; + eshort f_nscns; + elong f_timdat; + elong f_symptr; + elong f_nsyms; + eshort f_opthdr; + eshort f_flags; +}; +struct aouthdr +{ + eshort magic; + eshort vstamp; + elong tsize; + elong dsize; + elong bsize; + elong entry; + elong text_start; + elong data_start; + elong bss_start; + elong gprmask; + elong cprmask[4]; + elong gp_value; +}; +struct scnhdr +{ + char s_name[8]; + elong s_paddr; + elong s_vaddr; + elong s_size; + elong s_scnptr; + elong s_relptr; + elong s_lnnoptr; + eshort s_nreloc; + eshort s_nlnno; + elong s_flags; +}; +int file_little_endian; +int host_little_endian; +int swap_endian; +int docheck; +int expand; +ulong memsize; +ulong compression_quality; +char *compressfile; +int debug_level; +extern "C" int getopt (int, char**, const char*); +int +main(int argc, char** argv) +{ + uchar checksum; + uchar docrc; + ulong len; + ulong maxlen; + int i; + int c; + int magic; + int tsize; + int dsize; + int quality; + char dummy; + uchar* code; + uchar* buf; + char* ap; + digiheader *dh; + compression_quality = 10000; + docheck = 0; + while ((c = getopt(argc, argv, "Ccdf:k:q:x:")) != -1) + { + switch (c) + { + default: + goto usage; + } + } + if ((expand && (docheck || compressfile || quality)) || + (quality && !compressfile)) + { + usage: + return(2); + } + if (compressfile) + { + dh->image_offset = len; + + len += compress(compressfile, code + len, maxlen - len); + } +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash67.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash67.C new file mode 100644 index 000000000..da7cec475 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash67.C @@ -0,0 +1,3 @@ +// { dg-do assemble } +// GROUPS passed old-abort +#pragma comment(exestr, "@(#) errno.h 10.2 92/03/26 ") diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash68.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash68.C new file mode 100644 index 000000000..82da9f8b9 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash68.C @@ -0,0 +1,28 @@ +// { dg-do assemble } +// { dg-options "-w -O" } +// GROUPS passed old-abort +class RWDlist +{ +public: + RWDlist& operator=(const RWDlist&); +}; +class DataItemRWGDlist : public RWDlist {}; + +class Base {}; +class DataItemList : public Base +{ + private: + DataItemRWGDlist m_diList; +}; + +class StatementGroup +{ + public: + DataItemList dataItemList; + StatementGroup(const StatementGroup&); +}; + +StatementGroup::StatementGroup(const StatementGroup& sg) +{ + dataItemList = sg.dataItemList; +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash7.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash7.C new file mode 100644 index 000000000..44339ea2c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash7.C @@ -0,0 +1,48 @@ +// { dg-do assemble } +// GROUPS passed templates + +template<class T> +class Vector +{ + int sz; + T *v; +public: + Vector (int s) : sz (s) { v = new T[sz]; } + ~Vector () { delete[] v; } + T &operator[] (int i) { return v[i]; } + int size () { return sz; } +}; + +template<class T>// { dg-error "" } previous definition of T +struct Comparator +{ + typedef T T;// { dg-error "" } use of template type T in typedef to T + static int lessthan (T &a, T &b) { return a < b; } +}; + +template<class Comp> +struct Sort +{ + static void sort (Vector<Comp::T> &);// { dg-error "" } use of bad T +}; + +template<class Comp> +void Sort<Comp>::sort (Vector<Comp::T> &v)// { dg-error "" } use of bad T +{ + int n = v.size (); + + for (int i = 0; i < n - 1; i++) + for (int j = n - 1; i < j; j--) + if (Comp::lessthan (v[j], v[j - 1])) + { + typename Comp::T temp = v[j]; + v[j] = v[j - 1]; + v[j - 1] = temp; + } +} + +void +f (Vector<int> &vi) +{ + Sort<Comparator<int> >::sort (vi); // { dg-error "'sort' is not a member of 'Sort<Comparator<int> >'" } +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash8.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash8.C new file mode 100644 index 000000000..487208328 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash8.C @@ -0,0 +1,12 @@ +// { dg-do compile } +// GROUPS passed old-abort +template<int a, int b> +class Elvis // { dg-error "class Elvis" } +{ +} ; + +template<int a> +class Elvis<0> // { dg-error "wrong number of template arguments" } +{ + int geta() { return a ; } +} ; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash9.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash9.C new file mode 100644 index 000000000..004e84212 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash9.C @@ -0,0 +1,24 @@ +// { dg-do assemble } +// GROUPS passed old-abort +class A {}; + +class SimQuery +{ +public: + SimQuery(); + ~SimQuery(); + int SetMeshFile(char name[]); +protected: + A& scaling; + A* mesh; +}; + +SimQuery::SimQuery():scaling(A) {}// { dg-error "" } .* + +SimQuery::~SimQuery() {} + +int SimQuery::SetMeshFile(char name[]) +{ + mesh = new C;// { dg-error "" } .* + return 0; // needed to avoid warning of reaching end of non-void fn +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/ctors1.C b/gcc/testsuite/g++.old-deja/g++.brendan/ctors1.C new file mode 100644 index 000000000..1b0bfd90b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/ctors1.C @@ -0,0 +1,28 @@ +// { dg-do run } +// GROUPS passed constructors +// Check that global level object constructors get called. + +extern "C" int printf (const char *, ...); + +struct base { + int f1; + int f2; + base (int arg1, int arg2); +}; + + +base global_base(0x55, 0xff); + +int main () +{ + if ((global_base.f1 != 0x55) || (global_base.f2 != 0xff)) + { printf ("FAIL\n"); return 1; } + else + printf ("PASS\n"); +} + +base::base(int arg1, int arg2) +{ + f1 = arg1; + f2 = arg2; +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/ctors2.C b/gcc/testsuite/g++.old-deja/g++.brendan/ctors2.C new file mode 100644 index 000000000..c30ab7010 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/ctors2.C @@ -0,0 +1,29 @@ +// { dg-do run } +// GROUPS passed constructors +// Check that sub-words sized class members are correctly set +// by constructors. + +extern "C" int printf (const char *, ...); + +struct base { + int f1 : 8; + int f2 : 8; + base (int arg1, int arg2); +}; + + +base global_base(0x55, 0x7e); + +int main () +{ + if ((global_base.f1 != 0x55) || (global_base.f2 != 0x7e)) + { printf ("FAIL\n"); return 1; } + else + printf ("PASS\n"); +} + +base::base(int arg1, int arg2) +{ + f1 = arg1; + f2 = arg2; +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/ctors3.C b/gcc/testsuite/g++.old-deja/g++.brendan/ctors3.C new file mode 100644 index 000000000..cbfe9d699 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/ctors3.C @@ -0,0 +1,17 @@ +// { dg-do assemble } +// GROUPS passed constructors +class A; + +class B { +public: + B(); +static A sa; +}; + +class A { +public: + A(int i); +}; + +A B::sa(1); + diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/cvt1.C b/gcc/testsuite/g++.old-deja/g++.brendan/cvt1.C new file mode 100644 index 000000000..1327f5ace --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/cvt1.C @@ -0,0 +1,44 @@ +// { dg-do assemble } +// GROUPS passed conversions +#include <iostream> + +class Thing +{ +public: + typedef enum { GOOD_THING, BAD_THING, } ThingType ; // { dg-error "" } comma + Thing (ThingType type) : thingType (type) { } + ~Thing () { } +private: + ThingType thingType ; +} ; + +class Group +{ +public: + typedef enum { THIS_GROUP, THAT_GROUP, } GroupType ; // { dg-error "" } comma + Group (GroupType type) : groupType (type), groupCount (0) { } + ~Group () { } + void append (Thing* const &entry) { groupCount ++ ; } + operator GroupType () const { return groupType ; } + operator int () const { return groupCount ; } // remove this and problem gone + +private: + int groupCount ; + GroupType groupType ; +} ; + +inline Group& operator += (Group& g, Thing* const t) +{ + g.append (t) ; + return g ; // complaint is here +} + +int +main (int argc, char** argv) +{ + Group g (Group::THIS_GROUP) ; + + g += new Thing (Thing::GOOD_THING) ; + std::cout << "Group type is " << (Group::GroupType) g << std::endl ; + return 0 ; +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/cvt2.C b/gcc/testsuite/g++.old-deja/g++.brendan/cvt2.C new file mode 100644 index 000000000..acb173c6e --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/cvt2.C @@ -0,0 +1,9 @@ +// { dg-do assemble } +// GROUPS passed conversions +void f(const short & s) { } + + int +main() { + f(0); + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/cvt3.C b/gcc/testsuite/g++.old-deja/g++.brendan/cvt3.C new file mode 100644 index 000000000..8be5d6ed3 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/cvt3.C @@ -0,0 +1,49 @@ +// { dg-do assemble } +// GROUPS passed conversions +class GttObject {}; +class GctObject: virtual public GttObject {}; +class NDAMObject: virtual public GttObject, virtual public GctObject {}; +class GctHashObject: virtual public GctObject {}; + +class GctRef: virtual public GctHashObject +{ public: operator void*() const; }; + +class NDAMAssemblerObject: virtual public NDAMObject {}; +class GctReferenceObject: virtual public GctHashObject {}; +class NDAMValue: virtual public NDAMAssemblerObject, public GctReferenceObject {}; + +class nnyacc; +class NDAMValueRef : virtual public NDAMObject, public GctRef +{ + NDAMValue *operator->() const; + operator NDAMValue *() const; +friend class nnyacc; +}; + +typedef void* Pix; +class NDAMValueRefSLList +{ +public: + NDAMValueRefSLList(); + NDAMValueRefSLList(const NDAMValueRefSLList& a); + ~NDAMValueRefSLList(); + NDAMValueRef& operator () (Pix p) const; +}; + +struct bar +{ + NDAMValueRefSLList *valueList; +}; + +class nnyacc +{ +public: + static void assign(void*& lval, void*& rval); // { dg-message "nnyacc::assign|no known conversion" } +}; + +void +foo (bar yylval, bar *yyvsp) +{ + nnyacc::assign(yylval.valueList, yyvsp[0].valueList);// { dg-error "no matching" } + // { dg-message "candidate" "candidate note" { target *-*-* } 47 } +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/cvt4.C b/gcc/testsuite/g++.old-deja/g++.brendan/cvt4.C new file mode 100644 index 000000000..6d62209a2 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/cvt4.C @@ -0,0 +1,27 @@ +// { dg-do assemble } +// GROUPS passed conversions +class A {}; + +template <class TP> +class B +{ + A &(*_f) (A &, TP); + TP _a; +public: + B (A &(*f) (A &, TP), TP a) : _f (f), _a (a) {} + friend A &operator<< (A &o, const B<TP> &m) + { (*m._f) (o, m._a); return o; } +}; + +A &setw (A &, int); +B<int> setw (int n) +{ + return B<int> (setw, n); +} + +A x; + +void f () +{ + x << setw (2); +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/cvt5.C b/gcc/testsuite/g++.old-deja/g++.brendan/cvt5.C new file mode 100644 index 000000000..a5f8d84b4 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/cvt5.C @@ -0,0 +1,27 @@ +// { dg-do assemble } +// GROUPS passed conversions +typedef unsigned long Array[3]; + +void sample(const unsigned long (&an_array)[3]); + +class Sample + { + public: + void simple(const Array &an_array); + static void sample(const Array &an_array); + }; + +class A + { + public: + Array array; + }; + + Sample s; + + void simple(const A &a) + { + s.simple(a.array); + sample(a.array); + Sample::sample(a.array); + } diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/def-args1.C b/gcc/testsuite/g++.old-deja/g++.brendan/def-args1.C new file mode 100644 index 000000000..c0cc071a4 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/def-args1.C @@ -0,0 +1,9 @@ +// { dg-do assemble } +// PRMS Id: 10860 +class Beige +{ +public: + static int yellow(); + void white(int green = yellow()); + void aqua(int green = Beige::yellow()); +}; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/def-fns1.C b/gcc/testsuite/g++.old-deja/g++.brendan/def-fns1.C new file mode 100644 index 000000000..8730536d0 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/def-fns1.C @@ -0,0 +1,22 @@ +// { dg-do assemble } +// GROUPS passed default-functions +class dictionary { +public: + dictionary (int); +}; + +class symbol { +public: + symbol (); +}; + +// a default ctor should not be generated for hyphenation_language, +// since a ctor has already been declared; if one is generated, there +// will be an error about not enough args to the ctor for dictionary, +// since dictionary only defines a ctor taking an int (it ALSO should +// not get a default ctor) +struct hyphenation_language { + symbol name; + dictionary exceptions; + hyphenation_language(symbol nm) : name(nm), exceptions(501) {} +}; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/delete1.C b/gcc/testsuite/g++.old-deja/g++.brendan/delete1.C new file mode 100644 index 000000000..8528b1c65 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/delete1.C @@ -0,0 +1,15 @@ +// { dg-do assemble } +// { dg-options "-pedantic-errors" } +// GROUPS passed operator-delete +/* ARM $5.3.4 */ +void f(char *p, char *q[], const char *r, const char *s[]) +{ + delete 0; /* illegal: non-pointer */// { dg-error "" } .*expected pointer.* + delete (char*)0; /* no effect */ + delete p; + delete[] q; + delete[4] q; /* ANSI forbids size arg */// { dg-error "" } anachronistic .* + delete r; /* no longer illegal: const */ + delete[] s; + delete[4] s; /* ANSI forbids size arg */// { dg-error "" } anachronistic.* +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/delete2.C b/gcc/testsuite/g++.old-deja/g++.brendan/delete2.C new file mode 100644 index 000000000..a91700343 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/delete2.C @@ -0,0 +1,26 @@ +// { dg-do run } +// GROUPS passed operator-delete +// Check that using the delete operator with a null pointer +// is allowed (as called for by The Book, pg. 259) + +extern "C" int printf (const char *, ...); + +struct base { + int member; +}; + +base* bp; + +void test () +{ + delete bp; +} + +int main () +{ + bp = (base *) 0; + test (); + + printf ("PASS\n"); + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/dtors1.C b/gcc/testsuite/g++.old-deja/g++.brendan/dtors1.C new file mode 100644 index 000000000..cb5aa280e --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/dtors1.C @@ -0,0 +1,57 @@ +// { dg-do run } +// GROUPS passed destructors +// Check that when an object of a derived class is (implicitly) +// destructed (on exit from the block in which it is declared) +// that the destructor for the base class also gets executed. +// +// (also check that this execution doesn't seg-fault) + +extern "C" int printf (const char *, ...); + +int derived_destructed; +int base_destructed; + +struct base { + int base_data_member; + + base() + { + base_data_member = 0x5e5e; + } + ~base() + { + base_destructed = 0x781f; + } +}; + +struct derived : public base { + int derived_data_member; + + derived() + { + derived_data_member = 0xe5e5; + } + ~derived() + { + derived_destructed = 0xf178; + } +}; + + +void test2 (); + +int main () +{ + test2 (); + if ((base_destructed != 0x781f) || (derived_destructed != 0xf178)) + { printf ("FAIL\n"); return 1; } + else + printf ("PASS\n"); +} + +void test2 () +{ + derived derived_object; + + derived_object.derived_data_member = 99; +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/dtors2.C b/gcc/testsuite/g++.old-deja/g++.brendan/dtors2.C new file mode 100644 index 000000000..924bf4a0b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/dtors2.C @@ -0,0 +1,75 @@ +// { dg-do run } +// GROUPS passed destructors +// Check that virtual destructors work correctly. Specifically, +// check that when you destruct an object of a derived class for +// which the base class had an explicitly declared virtual destructor +// no infinite recursion occurs. +// +// Bug description: +// The generated g++ code apparently calls the base class destructor via +// the virtual table, rather than directly. This, of course, results in the +// infinite recursion. + +extern "C" int printf (const char *, ...); + +int errors = 0; + +struct base { + int member; + base(); + virtual ~base(); +}; + +base::base() +{ +} + +base::~base() +{ +} + +struct derived : public base +{ + int member; + derived(); + ~derived(); +}; + +derived::derived() : base() +{ +} + +int derived_destructor_calls = 0; + +extern void exit (int); + +derived::~derived() +{ + if (++derived_destructor_calls > 2) + errors++; +} + +void test (); + +int main () +{ + test (); + + if (errors) + { printf ("FAIL\n"); return 1; } + else + printf ("PASS\n"); + + return 0; +} + +base* bp; + +void test() +{ + derived a; + + a.member = 99; + bp = new derived; + delete bp; +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/dtors3.C b/gcc/testsuite/g++.old-deja/g++.brendan/dtors3.C new file mode 100644 index 000000000..053bb0dae --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/dtors3.C @@ -0,0 +1,67 @@ +// { dg-do run } +// GROUPS passed destructors +// Check that member and base classes get properly destructed +// when an object of a derived class is destructed via a pointer +// to it which only has a "compile-time" type of "pointer-to-base". +// +// Note that in order for this test to work properly, the destructor +// for the base class should be explicitly declared to be virtual. + +extern "C" int printf (const char *, ...); + +int member_destructor_calls = 0; +int middle_destructor_calls = 0; + +struct member_type { + int data_member; + member_type () {} + ~member_type (); +}; + +struct base { + int data_member; + base () {} + virtual ~base (); +}; + +struct middle : public base { + member_type member1; + member_type member2; + middle () {} + ~middle (); // should be implicitly virtual +}; + +struct derived : public middle { + member_type member1; + member_type member2; + //~derived () {} +}; + +int main () +{ + base* bp = new derived; + delete bp; + derived *dp = new derived; + delete dp; + + if ((member_destructor_calls != 8) || (middle_destructor_calls != 2)) + { printf ("FAIL\n"); return 1; } + else + printf ("PASS\n"); + + return 0; +} + +member_type::~member_type () +{ + member_destructor_calls++; +} + +base::~base () +{ +} + +middle::~middle () +{ + middle_destructor_calls++; +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/eh1.C b/gcc/testsuite/g++.old-deja/g++.brendan/eh1.C new file mode 100644 index 000000000..939312a00 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/eh1.C @@ -0,0 +1,63 @@ +// { dg-do run } +// { dg-options "-O" } +// PRMS Id: 10776 + +extern "C" int printf (const char *, ...); + +class Foo +{ + public: + Foo(int n) : n_(n) { } + int f() { return n_; } + + int badTest(); + int goodTest(); + + private: + + int n_; +}; + +int Foo::badTest() +{ + try { + throw int(99); + } + + catch (int &i) { + n_ = 16; + } + + return n_; + // On the sparc, the return will use a ld [%l0],%i0 instruction. + // However %l0 was clobbered at the end of the catch block. It was + // used to do an indirect call. +} + + +int Foo::goodTest() +{ + int n; + + try { + throw int(99); + } + + catch (int &i) { + n = 16; + } + + return n_; + // The return will use a ld [%l2],%i0 instruction. Since %l2 + // contains the "this" pointer this works. +} + +int main() +{ + Foo foo(5); + foo.goodTest(); + foo.badTest(); + + // the badTest will have failed + printf ("PASS\n"); +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/enum-clash.C b/gcc/testsuite/g++.old-deja/g++.brendan/enum-clash.C new file mode 100644 index 000000000..81341df27 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/enum-clash.C @@ -0,0 +1,6 @@ +// { dg-do assemble } +// { dg-options "-pedantic-errors" } +// GROUPS passed arm +enum color {red, yellow, green=20, blue}; +color c = 1; // this should be an error// { dg-error "" } .* +int i = yellow; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/enum1.C b/gcc/testsuite/g++.old-deja/g++.brendan/enum1.C new file mode 100644 index 000000000..12b9a5f46 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/enum1.C @@ -0,0 +1,14 @@ +// { dg-do assemble } +// GROUPS passed enums +class foo { +public: + enum bar { baz = 1, bat = 7 }; +}; + +class derv : public foo { }; + +int main() +{ + foo::bar x = foo::baz; + derv::bar y = derv::bat; +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/enum10.C b/gcc/testsuite/g++.old-deja/g++.brendan/enum10.C new file mode 100644 index 000000000..97d5d8e34 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/enum10.C @@ -0,0 +1,21 @@ +// { dg-do assemble } +// GROUPS passed enums +class Type +{ + public: + + enum name + { + A + }; +}; + +class A +{ +}; + +class B: public A +{ + public: + B(); +}; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/enum11.C b/gcc/testsuite/g++.old-deja/g++.brendan/enum11.C new file mode 100644 index 000000000..009333a18 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/enum11.C @@ -0,0 +1,16 @@ +// { dg-do assemble } +// GROUPS passed enums +class X +{ + enum + { + oneMask = 0x0000FFFF, + twoMask = 0x000F0000, + thiMask = 0xFFF00000, // { dg-error "comma at end" } + }; + unsigned int foo; + +public: + X (int) : foo (oneMask | twoMask ) {} // No warning + X () : foo (oneMask | twoMask | thiMask) {} // Warning +}; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/enum12.C b/gcc/testsuite/g++.old-deja/g++.brendan/enum12.C new file mode 100644 index 000000000..fab57032a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/enum12.C @@ -0,0 +1,12 @@ +// { dg-do assemble } +// GROUPS passed enums +enum Bool { False, True }; + +enum Bool object; + +struct S +{ + Bool field:1; + + void copy_enum_bit_field () const { object = field; } +}; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/enum13.C b/gcc/testsuite/g++.old-deja/g++.brendan/enum13.C new file mode 100644 index 000000000..0d06ff1cf --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/enum13.C @@ -0,0 +1,15 @@ +// { dg-do assemble } +// GROUPS passed enums +enum COLOR { red, green, blue }; + +struct S { + COLOR color:2; +}; + +COLOR color; +S object; + +void fubar () +{ + color = object.color; +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/enum14.C b/gcc/testsuite/g++.old-deja/g++.brendan/enum14.C new file mode 100644 index 000000000..e18284458 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/enum14.C @@ -0,0 +1,4 @@ +// { dg-do assemble } +// { dg-options "-fshort-enums" } +// GROUPS passed enums + enum E { A = 0x80000000 }; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/enum2.C b/gcc/testsuite/g++.old-deja/g++.brendan/enum2.C new file mode 100644 index 000000000..b6178517b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/enum2.C @@ -0,0 +1,19 @@ +// { dg-do assemble } +// GROUPS passed enums +class foo { +public: + enum bar { baz = 1, bat = 7 }; +}; + +class foo2 { +public: + enum bar2 { baz2 = 1, bat2 = 7 }; +}; + +class derv : public foo, public foo2 { }; + +int main() +{ + foo::bar x = foo::baz; + derv::bar2 y = derv::bat2; +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/enum3.C b/gcc/testsuite/g++.old-deja/g++.brendan/enum3.C new file mode 100644 index 000000000..f11c0509f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/enum3.C @@ -0,0 +1,15 @@ +// { dg-do assemble } +// GROUPS passed enums +enum foo +{ + x = 0 +}; + +enum bar +{ + // this used to say `x' wasn't a constant, because build_enumerator + // was getting the value of x wrapped around a NOP_EXPR. It now + // strips them off before working on it, so we shouldn't get any + // errors for this. + y = (x + 0x0000) +}; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/enum4.C b/gcc/testsuite/g++.old-deja/g++.brendan/enum4.C new file mode 100644 index 000000000..ca954e1a4 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/enum4.C @@ -0,0 +1,10 @@ +// { dg-do assemble } +// GROUPS passed enums +class X { +public: + enum { a }; +}; + +enum { b = 1 }; +enum ok { y = b }; +enum notok { z = X::a }; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/enum5.C b/gcc/testsuite/g++.old-deja/g++.brendan/enum5.C new file mode 100644 index 000000000..75917d745 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/enum5.C @@ -0,0 +1,10 @@ +// { dg-do assemble } +// { dg-options "-pedantic-errors" } +// GROUPS passed enums +enum Thing { FIRST, SECOND } ; + +int main() +{ + Thing x = FIRST ; + x = 27 ; // this line should be a type error.// { dg-error "" } .* +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/enum6.C b/gcc/testsuite/g++.old-deja/g++.brendan/enum6.C new file mode 100644 index 000000000..29908b81d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/enum6.C @@ -0,0 +1,16 @@ +// { dg-do assemble } +// GROUPS passed enums +class X { + private: + enum E1 {a1, b1}; // { dg-error "" } private + public: + enum E2 {a2, b2}; + }; + +void h(X* p) { + X::E2 e2; + int x2 = X::a2; + + X::E1 e1; // { dg-error "" } within this context + int x1 = X::a1; // { dg-error "" } within this context + } diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/enum7.C b/gcc/testsuite/g++.old-deja/g++.brendan/enum7.C new file mode 100644 index 000000000..980c8ea80 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/enum7.C @@ -0,0 +1,7 @@ +// { dg-do assemble } +// GROUPS passed enums +enum color { red, green, blue, orange, brown }; + +struct s { + enum color field:2; // { dg-warning "too small" } +}; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/enum8.C b/gcc/testsuite/g++.old-deja/g++.brendan/enum8.C new file mode 100644 index 000000000..ecf6fbf4e --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/enum8.C @@ -0,0 +1,25 @@ +// { dg-do assemble } +// GROUPS passed enums +class foo1 +{ + public: + enum foo1_enum + { + ENUM1, + ENUM2, // { dg-error "comma at end" } + }; +}; + + +class foo2 +{ + private: + enum foo1::foo1_enum Enum; +}; + + +class foo3 +{ + private: + foo1::foo1_enum Enum; +}; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/enum9.C b/gcc/testsuite/g++.old-deja/g++.brendan/enum9.C new file mode 100644 index 000000000..88ecc7328 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/enum9.C @@ -0,0 +1,15 @@ +// { dg-do assemble } +// GROUPS passed enums +enum fig { + figgy, + pudding, // { dg-error "comma at end" } +}; + +class X { +public: + static fig (*open)(void *thing, const char *filename); + static fig (*parse)(void *thing); +}; + +enum fig (*X::open)(void *thing, const char *filename) = 0; +fig (*X::parse)(void *thing) = 0; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/err-msg1.C b/gcc/testsuite/g++.old-deja/g++.brendan/err-msg1.C new file mode 100644 index 000000000..2e13bfa17 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/err-msg1.C @@ -0,0 +1,6 @@ +// { dg-do assemble } +// GROUPS passed error-messages +class A { }; + +int i = A::_ter;// { dg-error "" } ._ter.* +int j = A::term;// { dg-error "" } .term.* diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/err-msg10.C b/gcc/testsuite/g++.old-deja/g++.brendan/err-msg10.C new file mode 100644 index 000000000..f5b8abf6e --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/err-msg10.C @@ -0,0 +1,6 @@ +// { dg-do assemble } +// GROUPS passed error-messages +class foo { +public: + virtual static int f () = 0;// { dg-error "" } member `f' cannot be declared both virtual and static.* +}; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/err-msg11.C b/gcc/testsuite/g++.old-deja/g++.brendan/err-msg11.C new file mode 100644 index 000000000..abfe0e127 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/err-msg11.C @@ -0,0 +1,3 @@ +// { dg-do assemble } +// GROUPS passed error-messages +void foo (mutable int x);// { dg-error "" } non-member `x' cannot be declared `mutable'.* diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/err-msg12.C b/gcc/testsuite/g++.old-deja/g++.brendan/err-msg12.C new file mode 100644 index 000000000..e9bd5a643 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/err-msg12.C @@ -0,0 +1,6 @@ +// { dg-do assemble } +// GROUPS passed error-messages +class foo { +public: + friend mutable int x ();// { dg-error "" } non-object member `x' cannot be declared `mutable' +}; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/err-msg2.C b/gcc/testsuite/g++.old-deja/g++.brendan/err-msg2.C new file mode 100644 index 000000000..e2f8d9902 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/err-msg2.C @@ -0,0 +1,8 @@ +// { dg-do assemble } +// GROUPS passed error-messages + +typedef void (*pfv)(double, double); +extern "C" { + typedef void (*pfv)(double, double); // { dg-error "" "" { xfail *-*-* } } conflicting linkage +} + diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/err-msg3.C b/gcc/testsuite/g++.old-deja/g++.brendan/err-msg3.C new file mode 100644 index 000000000..724c6f5c3 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/err-msg3.C @@ -0,0 +1,20 @@ +// { dg-do assemble } +// GROUPS passed error-messages +#include <fstream> +#include <iomanip> + +// This error should not appear: +// bug.C: In method `test::test(const class test &)': +// bug.C:8: field `' not in immediate context + +class test{ +public: + int flags; + test() {} + }; + +int main() + +{ +return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/err-msg4.C b/gcc/testsuite/g++.old-deja/g++.brendan/err-msg4.C new file mode 100644 index 000000000..2f4bc4210 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/err-msg4.C @@ -0,0 +1,10 @@ +// { dg-do assemble } +// GROUPS passed error-messages +class X { +public: + static int x;// { dg-error "" } previous.* + static int y;// { dg-error "" } previous.* +}; + +unsigned X::x;// { dg-error "" } conflict.* +unsigned X::y;// { dg-error "" } conflict.* diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/err-msg5.C b/gcc/testsuite/g++.old-deja/g++.brendan/err-msg5.C new file mode 100644 index 000000000..1837e2fc7 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/err-msg5.C @@ -0,0 +1,4 @@ +// { dg-do assemble } +// GROUPS passed error-messages +class foo {}; +~foo () {}// { dg-error "" } destructors must be member functions.* diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/err-msg6.C b/gcc/testsuite/g++.old-deja/g++.brendan/err-msg6.C new file mode 100644 index 000000000..f30856b51 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/err-msg6.C @@ -0,0 +1,7 @@ +// { dg-do assemble } +// GROUPS passed error-messages +class foo { +public: + ~bar () {}// { dg-error "" } destructor `bar' must match class name `foo'.* +}; + diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/err-msg7.C b/gcc/testsuite/g++.old-deja/g++.brendan/err-msg7.C new file mode 100644 index 000000000..0dbb3231d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/err-msg7.C @@ -0,0 +1,6 @@ +// { dg-do assemble } +// GROUPS passed error-messages +class foo { +public: + volatile int () {}// { dg-error "" } +}; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/err-msg8.C b/gcc/testsuite/g++.old-deja/g++.brendan/err-msg8.C new file mode 100644 index 000000000..dcc2028ff --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/err-msg8.C @@ -0,0 +1,3 @@ +// { dg-do assemble } +// GROUPS passed error-messages +operator int ; int j; // { dg-error "" } declaration of `operator int' as non-function.* diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/err-msg9.C b/gcc/testsuite/g++.old-deja/g++.brendan/err-msg9.C new file mode 100644 index 000000000..0dd7f09c0 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/err-msg9.C @@ -0,0 +1,6 @@ +// { dg-do assemble } +// GROUPS passed error-messages +class foo { +public: + int ~foo ();// { dg-error "" } return type specification for destructor invalid.* +}; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/explicit1.C b/gcc/testsuite/g++.old-deja/g++.brendan/explicit1.C new file mode 100644 index 000000000..2be91d4ca --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/explicit1.C @@ -0,0 +1,5 @@ +// { dg-do assemble } +// $7.1.2 disallows explicit on anything but declarations of +// constructors ... including friends. +class foo { public: foo(); }; +class bar { public: friend explicit foo::foo(); }; // { dg-error "" } explicit friend diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/friend1.C b/gcc/testsuite/g++.old-deja/g++.brendan/friend1.C new file mode 100644 index 000000000..4d9262811 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/friend1.C @@ -0,0 +1,19 @@ +// { dg-do assemble } +// GROUPS passed friends +class A +{ +private: + A () {} + +friend struct B; +}; + +class B +{ +public: + A a; +}; + +B b; + +int main () {} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/friend2.C b/gcc/testsuite/g++.old-deja/g++.brendan/friend2.C new file mode 100644 index 000000000..13d8221d1 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/friend2.C @@ -0,0 +1,15 @@ +// { dg-do assemble } +// GROUPS passed friends +class X { + int a; +friend void friend_set (X*, int); +}; + +void friend_set (X *p, int i) { p->a = i; } + +void f() +{ + X obj; + friend_set (&obj, 10); +} + diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/friend3.C b/gcc/testsuite/g++.old-deja/g++.brendan/friend3.C new file mode 100644 index 000000000..ecd85b44b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/friend3.C @@ -0,0 +1,28 @@ +// { dg-do assemble } +// GROUPS passed friends +class B { + + friend class A; + + enum { + bEnum = 1, // { dg-error "comma at end" } + }; + + int bArray[ bEnum ]; + +public: + void bFunction(int arg[ bEnum ]); +}; + + +class A { + int aMember; + +public: + void aFunction(int a[B::bEnum]) + { + B b; + b.bArray[ B::bEnum ] = aMember; + } +}; + diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/friend4.C b/gcc/testsuite/g++.old-deja/g++.brendan/friend4.C new file mode 100644 index 000000000..4d436e5c9 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/friend4.C @@ -0,0 +1,6 @@ +// { dg-do assemble } +// GROUPS passed friends +// do_friend should complain that foo was declared as a friend of +// A before A was defined +struct A; // { dg-error "forward" } +struct B { friend A::foo (); };// { dg-error "" } .* diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/groff1.C b/gcc/testsuite/g++.old-deja/g++.brendan/groff1.C new file mode 100644 index 000000000..0f26863c7 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/groff1.C @@ -0,0 +1,34 @@ +// { dg-do run } +// GROUPS passed groff +/* This should compile properly with the new overloading scheme. */ + +extern "C" int printf (const char *, ...); +extern "C" void exit (int); + +int win = 0; + +class symbol +{ +public: + symbol(const char *p, int how = 0) {} + symbol() {} +}; + +class dictionary +{ +public: + void lookup(symbol s, void *v=0) { win = 1; } + void lookup(const char *) {} +}; + +int main() +{ + char buf[2048]; + dictionary exceptions; + unsigned char *tem = new unsigned char[19 + 1]; + + exceptions.lookup (symbol (buf), tem); + + printf (win ? "PASS\n" : "FAIL\n"); + exit (! win); +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/init1.C b/gcc/testsuite/g++.old-deja/g++.brendan/init1.C new file mode 100644 index 000000000..113f12c66 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/init1.C @@ -0,0 +1,11 @@ +// { dg-do assemble } +// GROUPS passed initialization + class Thing{ + private: + int x,y; + public: + Thing (int v, int q) { x = v; q = y; } + void doit(int); + }; + + Thing t(18,19); diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/init10.C b/gcc/testsuite/g++.old-deja/g++.brendan/init10.C new file mode 100644 index 000000000..0080420bd --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/init10.C @@ -0,0 +1,3 @@ +// { dg-do assemble } +// GROUPS passed initialization +struct S { int :0; } a; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/init11.C b/gcc/testsuite/g++.old-deja/g++.brendan/init11.C new file mode 100644 index 000000000..0d3e511ae --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/init11.C @@ -0,0 +1,9 @@ +// { dg-do assemble } +// GROUPS passed initialization +struct String { + char * string; + String(const char* st); +}; + +extern char array []; +static String sub = array; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/init12.C b/gcc/testsuite/g++.old-deja/g++.brendan/init12.C new file mode 100644 index 000000000..2e3578b1a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/init12.C @@ -0,0 +1,9 @@ +// { dg-do assemble } +// GROUPS passed array-bindings +char * bob(); + +int main() +{ + char a[1][2]; + a[0] = bob();// { dg-error "" } .* +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/init13.C b/gcc/testsuite/g++.old-deja/g++.brendan/init13.C new file mode 100644 index 000000000..82d175b57 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/init13.C @@ -0,0 +1,7 @@ +// { dg-do assemble } +// GROUPS passed initialization +struct A { + operator int (); +}; + +int i = A(); diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/init2.C b/gcc/testsuite/g++.old-deja/g++.brendan/init2.C new file mode 100644 index 000000000..8f4c2d4d2 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/init2.C @@ -0,0 +1,5 @@ +// { dg-do assemble } +// GROUPS passed initialization +// this should give an error in require_instantiated_type about not +// being allowed to have an initializer list in an argument list. +int f(int a = {1});// { dg-error "" } .* diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/init3.C b/gcc/testsuite/g++.old-deja/g++.brendan/init3.C new file mode 100644 index 000000000..751297eb3 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/init3.C @@ -0,0 +1,39 @@ +// { dg-do run } +// GROUPS passed initialization +// p2766: Make sure that members are initialized in order of declaration +// in the class, not in order of specification in the mem-initializer list. + +extern "C" int printf (const char *, ...); +extern "C" void exit (int); + +int count = 0; + +void die () { printf ("FAIL\n"); exit (1); } + +class bar1 { +public: + bar1 (int) { if (count != 0) die (); count = 1; } +}; + +class bar2 +{ +public: + bar2 (int) { if (count != 1) die (); count = 2; } +}; + +class foo +{ +public: + bar1 a; + bar2 b; + foo (int, int); +}; + +// bar1 should get built before bar2 +foo::foo (int x, int y) : b(x), a(y) {} + +int main() +{ + foo f (1, 2); + printf ("PASS\n"); +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/init4.C b/gcc/testsuite/g++.old-deja/g++.brendan/init4.C new file mode 100644 index 000000000..aa2bfb658 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/init4.C @@ -0,0 +1,5 @@ +// { dg-do assemble } +// GROUPS passed initialization +struct CharList { int i; }; + +const CharList& terminals = { 1 }; // { dg-error "initializer lists" } c++0x diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/init5.C b/gcc/testsuite/g++.old-deja/g++.brendan/init5.C new file mode 100644 index 000000000..016e733cd --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/init5.C @@ -0,0 +1,6 @@ +// { dg-do assemble } +// GROUPS passed initialization +int main( int argc, char**argv, char** envp ){ + char* domain = argv[1]; + domain = domain? (char*)"component" : domain; +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/init6.C b/gcc/testsuite/g++.old-deja/g++.brendan/init6.C new file mode 100644 index 000000000..ed8c0ade2 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/init6.C @@ -0,0 +1,15 @@ +// { dg-do assemble } +// GROUPS passed initialization +class Tag { +public: + Tag(int i):value(i){} + int value; +}; + +extern const Tag myTag; +extern const Tag myTag=9; + +// The compiler should not issue an error on this line; expand_static_init +// should be checking that there's no initializer for this line, and thus +// doesn't need to produce an error. +extern const Tag myTag; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/init7.C b/gcc/testsuite/g++.old-deja/g++.brendan/init7.C new file mode 100644 index 000000000..efbf5c8cb --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/init7.C @@ -0,0 +1,16 @@ +// { dg-do assemble } +// GROUPS passed initialization +struct myChoiceList +{ + int bla; + int blubb; + int brummbrumm; +}; + +extern const myChoiceList foo; + +extern const myChoiceList foo = {1,1,1}; + +// finish_decl should have an exclusion so an error is not produced +// for this line. +extern const myChoiceList foo; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/init8.C b/gcc/testsuite/g++.old-deja/g++.brendan/init8.C new file mode 100644 index 000000000..bd49ce2ee --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/init8.C @@ -0,0 +1,16 @@ +// { dg-do assemble } +// GROUPS passed initialization +class A +{ +public: + A(const A & a) : i_member(a.i_member) + { + } + A(const int & i) : i_member(i) + { + } + union + { + int i_member; + }; +}; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/init9.C b/gcc/testsuite/g++.old-deja/g++.brendan/init9.C new file mode 100644 index 000000000..e22821022 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/init9.C @@ -0,0 +1,11 @@ +// { dg-do assemble } +// GROUPS passed initialization +int FALSE = 0; +class X { +public: + static int FALSE; +}; + +// The compiler should NOT complain about redeclaration of the global +// `FALSE' with this declaration...grokvardecl shouldn't be doing that. +int X::FALSE = 0; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/label1.C b/gcc/testsuite/g++.old-deja/g++.brendan/label1.C new file mode 100644 index 000000000..9cdc57d44 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/label1.C @@ -0,0 +1,4 @@ +// { dg-do assemble } +// GROUPS passed labels +// it should only give 1 error, about using an undefined label +int main(void) { goto dummy; }// { dg-error "" } .* diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/label2.C b/gcc/testsuite/g++.old-deja/g++.brendan/label2.C new file mode 100644 index 000000000..6d2af3262 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/label2.C @@ -0,0 +1,14 @@ +// { dg-do assemble } +// GROUPS passed labels + +extern "C" void abort(); + +class X { +public: + X(); +}; +void foo () +{ +X: ::abort(); + goto X; +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/line1.C b/gcc/testsuite/g++.old-deja/g++.brendan/line1.C new file mode 100644 index 000000000..b14ed8efa --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/line1.C @@ -0,0 +1,4 @@ +// { dg-do assemble } +// GROUPS passed error-messages +typedef struct s S;// { dg-error "" } previous.* +struct S { int member:1; }; // the lineno for this should be 2, not 0// { dg-error "" } conflicting types.* diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/misc1.C b/gcc/testsuite/g++.old-deja/g++.brendan/misc1.C new file mode 100644 index 000000000..70763619f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/misc1.C @@ -0,0 +1,6 @@ +// { dg-do assemble } +// GROUPS passed miscellaneous-bugs +int main( int argc, char**argv, char** envp ){ + char* domain = argv[1]; + domain = domain? (char*)"component" : domain; +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/misc10.C b/gcc/testsuite/g++.old-deja/g++.brendan/misc10.C new file mode 100644 index 000000000..f132d1e08 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/misc10.C @@ -0,0 +1,6 @@ +// { dg-do assemble } +// GROUPS passed miscellaneous +// The compiler shouldn't give a `invalid operands to binary +' for this +// case. +enum flag { OFF, ON }; +enum BOOL { FALSE = (enum flag) 0, TRUE }; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/misc11.C b/gcc/testsuite/g++.old-deja/g++.brendan/misc11.C new file mode 100644 index 000000000..9f401cf1e --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/misc11.C @@ -0,0 +1,20 @@ +// { dg-do assemble } +// GROUPS passed miscellaneous +// This should not complain about A::f being abstract. +struct A +{ + virtual int f() = 0; +}; + +struct B : virtual A +{ + virtual int f() { return 1; } + virtual int g() = 0; +}; + +struct C: B +{ + int g() { return 2; } +}; + +C c; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/misc14.C b/gcc/testsuite/g++.old-deja/g++.brendan/misc14.C new file mode 100644 index 000000000..09242a46f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/misc14.C @@ -0,0 +1,13 @@ +// { dg-do assemble } +// GROUPS passed miscellaneous-bugs +class X { +public: + enum e { + New // { dg-error "conflicts with previous" } + , // { dg-error "comma at end" } + }; + + static int New(int); // { dg-error "declaration of" } +}; + +int main() {} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/misc15.C b/gcc/testsuite/g++.old-deja/g++.brendan/misc15.C new file mode 100644 index 000000000..2c5f1ae03 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/misc15.C @@ -0,0 +1,13 @@ +// { dg-do assemble } +// GROUPS passed miscellaneous-bugs + +struct A { + int aa; +}; +struct B : public A { +}; +struct C : public A { +}; +struct D : public C, public B { + void fun() { C::aa = 10; } +}; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/misc16.C b/gcc/testsuite/g++.old-deja/g++.brendan/misc16.C new file mode 100644 index 000000000..bc19edc2d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/misc16.C @@ -0,0 +1,19 @@ +// { dg-do assemble } +// GROUPS passed miscellaneous-bugs +// Using a typedef causes a compiler error +typedef unsigned int Uint32; + +// Using a define so that there isn't a typedef works OK. +//#define Uint32 unsigned int + +Uint32 func0(Uint32, Uint32) +{ + return 0; +} + +Uint32 func1(Uint32, Uint32) +{ + return 1; +} + +Uint32 (*mf[])(Uint32, Uint32) = {func0, func1}; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/misc17.C b/gcc/testsuite/g++.old-deja/g++.brendan/misc17.C new file mode 100644 index 000000000..405266415 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/misc17.C @@ -0,0 +1,36 @@ +// { dg-do assemble } +// GROUPS passed miscellaneous-bugs +typedef int va_list; +class ostream; +class String { +public: +operator const char *() const; +}; +class FwtErrorManager { +public: + FwtErrorManager(ostream& err, const char *program); +public: + void form(const char *format, ...); +protected: + const String _program; +private: + FwtErrorManager(const FwtErrorManager&); + void operator=(const FwtErrorManager&); +}; +class FwtProgram: public FwtErrorManager { +public: + FwtProgram(); +}; +class FwtArgOptions { }; +class FwtStdProgram: public FwtProgram, public FwtArgOptions { +public: + FwtStdProgram(); + void usage_if_not_complete(); +}; +void +FwtStdProgram::usage_if_not_complete() +{ + FwtStdProgram& thisp = *this; + thisp.form("%s: error, there were unrecognized options", + (char *) FwtErrorManager::_program);// { dg-error "" } .* +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/misc2.C b/gcc/testsuite/g++.old-deja/g++.brendan/misc2.C new file mode 100644 index 000000000..4e217d82b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/misc2.C @@ -0,0 +1,11 @@ +// { dg-do assemble } +// GROUPS passed miscellaneous-bugs +// Should be fixed by: +// Sun Jun 13 12:55:22 1993 Brendan Kehoe (brendan@lisa.cygnus.com) +// +// * cp-decl.c (grokvardecl): Don't complain about duplicate +// definitions of `extern "C"' declarations (parallelize it with how +// regular `extern' decls are handled). + +extern "C" double _MaXdOuB, _MiNdOuB; +extern "C" double _MaXdOuB, _MiNdOuB; // no error should be emitted for this diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/misc3.C b/gcc/testsuite/g++.old-deja/g++.brendan/misc3.C new file mode 100644 index 000000000..c2a116519 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/misc3.C @@ -0,0 +1,12 @@ +// { dg-do assemble } +// GROUPS passed miscellaneous-bugs +// The compiler should not error about taking the addr of main in this example. +class fred { +private: + void main () { + } +public: + fred ( ) { + &fred::main; + } +}; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/misc4.C b/gcc/testsuite/g++.old-deja/g++.brendan/misc4.C new file mode 100644 index 000000000..d9df9561d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/misc4.C @@ -0,0 +1,10 @@ +// { dg-do assemble } +// GROUPS passed miscellaneous +// This should not emit an error about A::~A() being redefined; we +// should check that it is a pure virtual. +class A { +public: + virtual ~A() = 0; +}; + +A::~A() {} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/misc5.C b/gcc/testsuite/g++.old-deja/g++.brendan/misc5.C new file mode 100644 index 000000000..35642abd5 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/misc5.C @@ -0,0 +1,7 @@ +// { dg-do assemble } +// GROUPS passed miscellaneous +class A { + static A aa[2]; +}; + +A A::aa[2]; // should be completely legal diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/misc6.C b/gcc/testsuite/g++.old-deja/g++.brendan/misc6.C new file mode 100644 index 000000000..93b241b9e --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/misc6.C @@ -0,0 +1,9 @@ +// { dg-do assemble } +// GROUPS passed miscellaneous +// test that use of `inline' is forbidden when it should be +inline int i;// { dg-error "" } .* +struct c { inline int i; };// { dg-error "" } .* +int foo (inline int i);// { dg-error "" } .* +inline class c; // { dg-error "'inline' can only be specified for functions" } inline +inline typedef int t; // { dg-error "" } inline +class d { inline friend class c; }; // { dg-error "'inline' can only be specified for functions" } inline diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/misc7.C b/gcc/testsuite/g++.old-deja/g++.brendan/misc7.C new file mode 100644 index 000000000..af61f92e3 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/misc7.C @@ -0,0 +1,16 @@ +// { dg-do run } +// GROUPS passed miscellaneous +extern "C" int printf (const char *, ...); + +int main() +{ + int i = 0; + // Make sure build_unary_op correctly computes this. + int *pi = &(++i); + *pi = 4; + + if (i != 4) + { printf ("FAIL\n"); return 1; } + else + printf ("PASS\n"); +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/misc8.C b/gcc/testsuite/g++.old-deja/g++.brendan/misc8.C new file mode 100644 index 000000000..f06393c93 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/misc8.C @@ -0,0 +1,18 @@ +// { dg-do assemble } +// GROUPS passed miscellaneous +// used to say invalid lvalue in `&\' +class foo { + int a; + public: + foo(int a); +}; + +foo::foo(int a) +{ + foo::a=a; +} + +int main() +{ +foo obj(4); +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/misc9.C b/gcc/testsuite/g++.old-deja/g++.brendan/misc9.C new file mode 100644 index 000000000..0ec12cb30 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/misc9.C @@ -0,0 +1,28 @@ +// { dg-do assemble } +// GROUPS passed miscellaneous +//The program listed below produces the following error during compilation: +// % g++ bug17.cc +// bug17.cc: In method `class Y& Y::operator = (const class Y&)': +// bug17.cc:18: invalid use of non-lvalue array + +class X { +public: + X& operator=(const X&) { return *this; } +}; + +struct S { + char c[10]; + X x; +}; + +class Y { + S s; +public: + const S& f() const { return s; } + + Y& operator=(const Y& _Y) { + s = _Y.s; // this line compiles + s = _Y.f(); // this line does not compile + return *this; + } +}; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/mutable1.C b/gcc/testsuite/g++.old-deja/g++.brendan/mutable1.C new file mode 100644 index 000000000..7840ac8d9 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/mutable1.C @@ -0,0 +1,6 @@ +// { dg-do assemble } +// GROUPS passed mutable +class foo; +class bar { + mutable foo const *foobar; +}; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/nest1.C b/gcc/testsuite/g++.old-deja/g++.brendan/nest1.C new file mode 100644 index 000000000..842b2f692 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/nest1.C @@ -0,0 +1,15 @@ +// { dg-do assemble } +// GROUPS passed nested-classes +int x; +class enclose { +public: + int x; // { dg-error "non-static" } + + class inner { + public: + void f (int i) { + x = i;// { dg-error "" } .* + } + }; +}; + diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/nest10.C b/gcc/testsuite/g++.old-deja/g++.brendan/nest10.C new file mode 100644 index 000000000..17db4f0a1 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/nest10.C @@ -0,0 +1,30 @@ +// { dg-do assemble } +// GROUPS passed nested-classes +class A + { + public: + class B + { + public: + int f (); + void g (int); + private: + int b; + }; + }; + +int A::B::f () + { + int val=b; + return val; + } + +void A::B::g (int val) + { + b = val; + } + + +int main () + { + } diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/nest11.C b/gcc/testsuite/g++.old-deja/g++.brendan/nest11.C new file mode 100644 index 000000000..0c6d475de --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/nest11.C @@ -0,0 +1,21 @@ +// { dg-do assemble } +// GROUPS passed nested-classes +class A { + int x; + + struct B { + int x; + }; + struct C; + friend struct C; + struct C { + int bug (A::B &y); + }; +}; + +int +A::C::bug (A::B &y) +{ + return y.x; +} + diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/nest12.C b/gcc/testsuite/g++.old-deja/g++.brendan/nest12.C new file mode 100644 index 000000000..42727290f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/nest12.C @@ -0,0 +1,21 @@ +// { dg-do assemble } +// GROUPS passed nested-classes +struct enclose { + class nested; + nested *nptr; + class nested { + int x; + }; + void f(); +}; + +void enclose::f() +{ + nptr = new enclose::nested; +} + +void g() +{ + enclose obj; + obj.nptr = new enclose::nested; +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/nest13.C b/gcc/testsuite/g++.old-deja/g++.brendan/nest13.C new file mode 100644 index 000000000..d9a8b6e7e --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/nest13.C @@ -0,0 +1,20 @@ +// { dg-do assemble } +// GROUPS passed nested-classes +// The bug here is that wer'e getting a message about inner not +// being a basetype itself. I think it's because it's being +// compared as the "inner" we knew about when it was forward-declared, +// versus the "inner" we know about when it *has* been defined. + +class temp +{ +public: + struct inner; + inner *trump() + { + return (tt); + } + struct inner + { + int ll; + }*tt; +}; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/nest15.C b/gcc/testsuite/g++.old-deja/g++.brendan/nest15.C new file mode 100644 index 000000000..5d3a0b476 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/nest15.C @@ -0,0 +1,37 @@ +// { dg-do assemble } +// GROUPS passed nested-classes +class BDDHeap { +public: + BDDHeap(); + BDDHeap(const BDDHeap&); + + class Page { + public: + int i; + }; + struct Pointer { + Page *page; + unsigned index; + + Pointer(); + Pointer(const BDDHeap& heap); + }; + + struct Half { + struct { + Page *top; + Page **tail; + } inuse; + + Half(); + }; + + Half half[2]; + unsigned halfspace; +}; + +inline +BDDHeap::Pointer::Pointer(const BDDHeap& heap): +page(heap.half[heap.halfspace].inuse.top), +index(0) +{ } diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/nest16.C b/gcc/testsuite/g++.old-deja/g++.brendan/nest16.C new file mode 100644 index 000000000..72c0078be --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/nest16.C @@ -0,0 +1,41 @@ +// { dg-do assemble } +// GROUPS passed nested-classes +class BDDHeap { +public: + BDDHeap(); + BDDHeap(const BDDHeap&); + + class Page { + public: + int i; + }; + struct Pointer { + Page *page; + unsigned index; + + Pointer(); + Pointer(const BDDHeap& heap); + }; + + struct Half { + struct { + Page *top; + Page **tail; + } inuse; + + Half(); + }; + + Half half[2]; + unsigned halfspace; +}; + +inline +BDDHeap::Pointer::Pointer(const BDDHeap& heap): +page(0), +index(0) +{ + Page *x = heap.half[heap.halfspace].inuse.top; + page = x; +} + diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/nest17.C b/gcc/testsuite/g++.old-deja/g++.brendan/nest17.C new file mode 100644 index 000000000..94b8fbdc2 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/nest17.C @@ -0,0 +1,12 @@ +// { dg-do assemble } +// GROUPS passed nested-classes +class T { +public: + typedef int I; + class Y {int y;}; + typedef Y Z; +}; + +T::I i; +T::Y y; +T::Z z; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/nest18.C b/gcc/testsuite/g++.old-deja/g++.brendan/nest18.C new file mode 100644 index 000000000..e62382781 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/nest18.C @@ -0,0 +1,31 @@ +// { dg-do assemble } +// GROUPS passed nested-classes +// This is the first line of file ||t2.C||. + +// This code demonstrates what appears to be a bug with nested types. +// In C++, nested typedefs are not supposed to be visible outside +// their class scopes but they apparently are in gcc 2.4.5. This code +// compiles fine in AT&T cfront 3.0.1, but will not compile with gcc. + +// If this class does not precede String, then the code will compile. + +class Another { +public: + typedef int Length; +}; + +// If String does not define typedef int Length, then the code will +// compile. + +class String { +public: + typedef int Length; // remove this and it will compile fine + + int foo(Length length) const; +}; + +int String::foo(Length length) const { + return length; +} + +// File ||t2.C|| ends here. diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/nest19.C b/gcc/testsuite/g++.old-deja/g++.brendan/nest19.C new file mode 100644 index 000000000..01ae3d002 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/nest19.C @@ -0,0 +1,40 @@ +// { dg-do assemble } +// GROUPS passed nested-classes +// This is the first line of file ||t3.C||. + +// This code demonstrates a variation of the same problem with nested +// types. In C++, nested typedefs are not supposed to be visible +// outside their class scopes but they apparently are in gcc 2.4.5. +// This code compiles fine in AT&T cfront 3.0.1, but gcc rejects it +// with the messages given below. + +// If this class does not precede Expr, then the code will compile. + +class Another { +public: + typedef int Boolean; + enum { FALSE, TRUE }; +}; + +// If Expr does not define typedef int Boolean, then the code will +// compile. + +class Expr { +public: + typedef int Boolean; + enum { FALSE, TRUE }; + void foo(); + void call_something_with(Boolean); +}; + +// t3.C: In method `void Expr::foo ()': +// t3.C:36: uninitialized const `Boolean' +// t3.C:36: parse error before `=' +// t3.C:37: `argument' undeclared (first use this function) +// t3.C:37: (Each undeclared identifier is reported only once +// t3.C:37: for each function it appears in.) + +void Expr::foo() { + const Boolean argument = TRUE; + call_something_with(argument); +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/nest2.C b/gcc/testsuite/g++.old-deja/g++.brendan/nest2.C new file mode 100644 index 000000000..dc61625ec --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/nest2.C @@ -0,0 +1,18 @@ +// { dg-do assemble } +// GROUPS passed nested-classes +class A { +protected: + class B { + public: + ~B(); + private: + float _datum; + }; +private: + B *_b; +}; + +A::B::~B() +{ + _datum = 8.0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/nest20.C b/gcc/testsuite/g++.old-deja/g++.brendan/nest20.C new file mode 100644 index 000000000..1b2c9419a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/nest20.C @@ -0,0 +1,30 @@ +// { dg-do assemble } +// GROUPS passed nested-classes +// This is the first line of file ||t5.C||. + +// This code initializing an unnamed union inside a class appears to +// be legal C++ input and compiles fine with AT&T cfront 3.0.1, but +// gcc 2.4.5 complains about multiple initializations of the same +// member. + +class Expr { +public: + enum Type { undefined, slong, ulong, ldouble }; + Expr(); + Expr(Type type, const Expr* initializer); +private: + Type type_; + union { + long slong_; + unsigned long ulong_; + long double ldouble_; + }; +}; + +// Construct an undefined expression. + +Expr::Expr() + : + type_(undefined), + slong_(-1) +{} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/nest21.C b/gcc/testsuite/g++.old-deja/g++.brendan/nest21.C new file mode 100644 index 000000000..62ddab156 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/nest21.C @@ -0,0 +1,97 @@ +// { dg-do run } +// GROUPS passed nested-classes +#include <iostream> +#include <cstdio> +#include <cstring> + +static char output[1024]; + +class BDDRetrace { +public: + class Dump { + public: + virtual Dump& operator<<(char c) = 0; + virtual Dump& operator<<(int i) = 0; + virtual Dump& operator<<(double r) = 0; + }; + + class Dump1: public Dump { + public: + Dump& operator<<(char c); + Dump& operator<<(int i); + Dump& operator<<(double r); + }; +}; + +class Dump2: public BDDRetrace::Dump { +public: + BDDRetrace::Dump& operator<<(char c); + BDDRetrace::Dump& operator<<(int i); + BDDRetrace::Dump& operator<<(double r); +}; + +BDDRetrace::Dump& +BDDRetrace::Dump1::operator<<(char c) +{ char tempout[1024]; + std::sprintf(tempout, "%s%s%c", output, "1-", c); + std::strcpy(output, tempout); + return *this; +} + +BDDRetrace::Dump& +BDDRetrace::Dump1::operator<<(int i) +{ char tempout[1024]; + std::sprintf (tempout, "%s%s%d", output, "1-", i); + std::strcpy (output, tempout); + return *this; } + +BDDRetrace::Dump& +BDDRetrace::Dump1::operator<<(double r) +{ char tempout[1024]; + std::sprintf (tempout, "%s%s%1.0f", output, "1-", r); + std::strcpy (output, tempout); + return *this; } + +BDDRetrace::Dump& +Dump2::operator<<(char c) +{ char tempout[1024]; + std::sprintf (tempout, "%s%s%c", output, "2-", c); + std::strcpy (output, tempout); + return *this; } + +BDDRetrace::Dump& +Dump2::operator<<(int i) +{ char tempout[1024]; + std::sprintf (tempout, "%s%s%d", output, "2-", i); + std::strcpy (output, tempout); + return *this; } + +BDDRetrace::Dump& +Dump2::operator<<(double r) +{ char tempout[1024]; + std::sprintf (tempout, "%s%s%1.0f", output, "2-", r); + std::strcpy (output, tempout); + return *this; } + +int main() +{ + BDDRetrace::Dump1 d1; + Dump2 d2; + + std::sprintf (output, " "); + + d1 << 'a'; + d1 << 1; + d1 << 1.0; + + d2 << 'a'; + d2 << 1; + d2 << 1.0; + + if (std::strcmp (output, " 1-a1-11-12-a2-12-1") == 0) + std::printf ("PASS\n"); + else + { std::printf ("FAIL\n"); return 1; } + + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/nest22.C b/gcc/testsuite/g++.old-deja/g++.brendan/nest22.C new file mode 100644 index 000000000..dfbc03818 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/nest22.C @@ -0,0 +1,7 @@ +// { dg-do assemble } +// GROUPS passed nested-classes +class foo { +public: + typedef int bar; + foo::bar fb; // this line causes a syntax error! +}; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/nest23.C b/gcc/testsuite/g++.old-deja/g++.brendan/nest23.C new file mode 100644 index 000000000..c62ba9fef --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/nest23.C @@ -0,0 +1,15 @@ +// { dg-do assemble } +// GROUPS passed nested-classes +class CS { +public: + class PS { + }; +}; + +class NCS: public CS { +public: + class S: public PS { + }; +}; + +int i; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/nest24.C b/gcc/testsuite/g++.old-deja/g++.brendan/nest24.C new file mode 100644 index 000000000..31ab87588 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/nest24.C @@ -0,0 +1,14 @@ +// { dg-do assemble } +// GROUPS passed nested-classes +struct A { + A (){} +}; + +void foo () +{ + struct B {}; + + struct S : B { + A a; + }; +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/nest3.C b/gcc/testsuite/g++.old-deja/g++.brendan/nest3.C new file mode 100644 index 000000000..0f405eb05 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/nest3.C @@ -0,0 +1,12 @@ +// { dg-do assemble } +// GROUPS passed nested-classes +class X { +public: + struct M2 { int m; }; + M2 g(int); +}; + + +X::M2 X::g(int i) { X::M2 m2; return m2; } + +int main() { } diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/nest4.C b/gcc/testsuite/g++.old-deja/g++.brendan/nest4.C new file mode 100644 index 000000000..f7af04df9 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/nest4.C @@ -0,0 +1,9 @@ +// { dg-do assemble } +// { dg-options "-pedantic-errors" } +// GROUPS passed nested-classes +class vec { + class blah { }; + + ::vec::blah satan( 0);// { dg-error "" } .* + blah herman( 0);// { dg-error "" } .* +}; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/new-array.C b/gcc/testsuite/g++.old-deja/g++.brendan/new-array.C new file mode 100644 index 000000000..5737c99bc --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/new-array.C @@ -0,0 +1,18 @@ +// { dg-do assemble } +// GROUPS passed operator-new +typedef struct { + int a; +} AStruct; + +void MakeBug() { + AStruct *job; + + // This used to crash, it should now give error(s). + job = new AStruct[];// { dg-error "" } .* + + job = new AStruct; +} + +int main () { + MakeBug(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/new1.C b/gcc/testsuite/g++.old-deja/g++.brendan/new1.C new file mode 100644 index 000000000..42efbc172 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/new1.C @@ -0,0 +1,5 @@ +// { dg-do assemble } +// GROUPS passed operator-new +typedef __SIZE_TYPE__ size_t; +struct x { int a; void * operator new (size_t, void *); }; +struct x * f(void *p) { return new (p) x; } diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/new2.C b/gcc/testsuite/g++.old-deja/g++.brendan/new2.C new file mode 100644 index 000000000..2fd55c764 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/new2.C @@ -0,0 +1,68 @@ +// { dg-do run } +// GROUPS passed operator-new +// Check that if there is a user defined class-specific operator +// new for a given class, that operator is invoked when a new +// object of the class is requested, regardless of whether or not +// there is also a constructor for the given class, and regardless +// of whether or not the constructor for the given class is defined +// before or after the new operator is even declared. + +extern "C" int printf (const char *, ...); + +typedef __SIZE_TYPE__ size_t; + +struct base { + int i; + + base () + { + i = 7; + } + + void * operator new (size_t size); + void operator delete (void*); +}; + +class derived : public base { + int j; +}; + +int new_call_count = 0; +int expected_size = 0; +int errors = 0; + +int main () +{ + base* base_ptr; + derived* derived_ptr; + + expected_size = sizeof (int); + base_ptr = new base; + expected_size = 2 * sizeof (int); + derived_ptr = new derived (); + + if ((new_call_count != 2) || (errors != 0)) + { printf ("FAIL\n"); return 1; } + else + printf ("PASS\n"); + + return 0; +} + +int allocation_space[100]; +int* allocation_ptr = allocation_space; + +void base::operator delete (void* p) +{ +} + +void *base::operator new (size_t size) +{ + int* return_value = allocation_ptr; + + new_call_count++; + if (size != expected_size) + errors++; + allocation_ptr += (size + sizeof(int) - 1) / sizeof(int); + return (void*) return_value; +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/new3.C b/gcc/testsuite/g++.old-deja/g++.brendan/new3.C new file mode 100644 index 000000000..791d00bac --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/new3.C @@ -0,0 +1,43 @@ +// This test fails on VxWorks in kernel mode because it depends on the +// library version of "::operator new[]" calling the "::operator new" +// defined in this module. This doesn't work because the library version +// of "::operator new[]" is built into the kernel itself; library relocations +// are resolved when the kernel is linked. +// { dg-do run { xfail { powerpc-ibm-aix* || vxworks_kernel } } } +// { dg-options "-flat_namespace" { target *-*-darwin[67]* } } +// GROUPS passed operator-new +#include <stdio.h> +#include <stdlib.h> +#include <new> + +int pass = 0; + +void *operator new(size_t sz) throw (std::bad_alloc) { + + void *p; + + pass = 1; + p = malloc(sz); + return p; +} + +class A { +public: + A() {} + ~A() {} + + int a; + int b; +}; + + +int main() +{ + A *bb = new A[10]; + delete [] bb; + + if (pass) + printf ("PASS\n"); + else + { printf ("FAIL\n"); return 1; } +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/ns1.C b/gcc/testsuite/g++.old-deja/g++.brendan/ns1.C new file mode 100644 index 000000000..5b6ea3861 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/ns1.C @@ -0,0 +1,18 @@ +// { dg-do assemble } +// GROUPS passed old-abort +struct B +{ + void f(char); + void g(char); +}; + +class C +{ + int g(); +}; + +class D2 : public B +{ + using B::f; // ok: B is a base of D2 + using C::g; // { dg-error "not a base type" } +}; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/operators1.C b/gcc/testsuite/g++.old-deja/g++.brendan/operators1.C new file mode 100644 index 000000000..b1499bf1e --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/operators1.C @@ -0,0 +1,14 @@ +// { dg-do assemble } +// GROUPS passed operators +struct A { + int x; +}; + +int operator()(A x,float y) { // MUST be a member function// { dg-error "" } .* + return 1; +} + +int main() { + A x; + x(1.0); // { dg-error "" } no match for call +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/operators2.C b/gcc/testsuite/g++.old-deja/g++.brendan/operators2.C new file mode 100644 index 000000000..7ca114e75 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/operators2.C @@ -0,0 +1,4 @@ +// { dg-do assemble } +// GROUPS passed operators +class X { }; +void operator[](X& a, X& b) {} // MUST be a member function// { dg-error "" } .* diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/operators3.C b/gcc/testsuite/g++.old-deja/g++.brendan/operators3.C new file mode 100644 index 000000000..20bece7c6 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/operators3.C @@ -0,0 +1,4 @@ +// { dg-do assemble } +// GROUPS passed operators +class X { }; +void operator->(X& a, X& b) {} // MUST be a member function// { dg-error "" } .* diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/operators4.C b/gcc/testsuite/g++.old-deja/g++.brendan/operators4.C new file mode 100644 index 000000000..6408815cd --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/operators4.C @@ -0,0 +1,124 @@ +// { dg-do assemble } +// { dg-options "" } + +// GROUPS passed operators +// Check that the & operator, when applied to a global function +// or member function returns a proper value as long as the context +// in which the result of & is used requires a pointer to a specific +// unambigous (function-pointer) type. +// +// This test fails (in test5()) when compiled with g++ 1.34.1. + +extern "C" int printf (const char *, ...); + +int function (char c); +int function (float f); + +class base { + int filler; +public: + int method (char); + int method (float); +}; + +void* vp; + +typedef int (*ptr_to_func_of_char)(char); +typedef int (*ptr_to_func_of_float)(float); +typedef int (base::*ptr_to_method_of_char)(char); +typedef int (base::*ptr_to_method_of_float)(float); + +int test2 (void*); +int test3 (void*); +int test4 (void*); +int test5 (void*); + +base* base_ptr; + +int fail () +{ + printf ("FAIL\n"); + return 1; +} + +int main () +{ + base_ptr = new base; + + ptr_to_func_of_char p0 = &function; + vp = (void*) p0; + if (test2 (vp)) + return fail (); + ptr_to_func_of_float p1 = &function; + vp = (void*) p1; + if (test3 (vp)) + return fail (); + ptr_to_method_of_char p2 = &base::method; + vp = (void*) p2; // { dg-warning "converting" } + if (test4 (vp)) + return fail (); + ptr_to_method_of_float p3 = &base::method; + vp = (void*) p3; // { dg-warning "converting" } + if (test5 (vp)) + return fail (); + + printf ("PASS\n"); + return 0; +} + +int test2 (void* vp) +{ + char ch = 'x'; + + return (((ptr_to_func_of_char)vp)(ch) != 9901); +} + +int test3 (void* vp) +{ + float flt = 9.9; + + return (((ptr_to_func_of_float)vp)(flt) != 9902); +} + +int test4 (void* vp) +{ + char ch = 'x'; + ptr_to_method_of_char p = (ptr_to_method_of_char) vp; // { dg-error "invalid cast" } bad type conversion + + return ((base_ptr->*p)(ch) != 9904); +} + +int test5 (void* vp) +{ + float flt = 9.9; + ptr_to_method_of_float p = (ptr_to_method_of_float) vp; // { dg-error "invalid cast" } bad type conversion + + if ((base_ptr->*p)(flt) != 9905) { + return 1; + } else + return 0; +} + +int function (char c) +{ + c = c; + return 9901; +} + +int function (float f) +{ + f = f; + return 9902; +} + +int base::method (char c) +{ + c = c; + return 9904; +} + +int base::method (float f) +{ + f = f; + return 9905; +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/operators5.C b/gcc/testsuite/g++.old-deja/g++.brendan/operators5.C new file mode 100644 index 000000000..dedec9045 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/operators5.C @@ -0,0 +1,53 @@ +// { dg-do run } +// GROUPS passed operators +// Check that operators may be (directly) recursive. + +extern "C" int printf (const char *, ...); + +struct base { + int i; +}; + +base base_variable; + +base operator+ (const base& left, const base& right) +{ + base ret_val; + + ret_val.i = left.i + right.i; + return ret_val; +} + +base operator- (const base& left, int right) +{ + base ret_val; + + ret_val.i = left.i - right; + return ret_val; +} + +// Define the unary ! operator for class base to be the fibonachi +// operator. + +base operator! (const base& right) +{ + if (right.i < 2) + return right; + else + return ((!(right-1)) + (!(right-2))); +} + +int main () +{ + base k; + + k.i = 15; + k = !k; // fib it! + + if (k.i != 610) + { printf ("FAIL\n"); return 1; } + else + printf ("PASS\n"); + + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/operators6.C b/gcc/testsuite/g++.old-deja/g++.brendan/operators6.C new file mode 100644 index 000000000..8ac3df13f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/operators6.C @@ -0,0 +1,11 @@ +// { dg-do assemble } +// GROUPS passed operators +class a { +public: + a* operator->() { return this; } + void p(); +}; + +void a::p() { + operator->(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/operators7.C b/gcc/testsuite/g++.old-deja/g++.brendan/operators7.C new file mode 100644 index 000000000..8ceaf3efa --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/operators7.C @@ -0,0 +1,13 @@ +// { dg-do assemble } +// GROUPS passed operators +class A { + char *p; +public: + operator const char *() const { return p; } +}; + +int foo(const A &a) +{ + return (a != 0); +} + diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/operators8.C b/gcc/testsuite/g++.old-deja/g++.brendan/operators8.C new file mode 100644 index 000000000..728918875 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/operators8.C @@ -0,0 +1,11 @@ +// { dg-do assemble } +// GROUPS passed operators +struct A { + char *p; + operator char *(); +}; + +char foo(A a) +{ + return a[0]; +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/overload1.C b/gcc/testsuite/g++.old-deja/g++.brendan/overload1.C new file mode 100644 index 000000000..1b9415b0e --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/overload1.C @@ -0,0 +1,22 @@ +// { dg-do assemble } +// GROUPS passed overloading +class Foo +{ +public: + int f (void); +}; + +class Bar : public Foo +{ +public: + int f (int); // { dg-message "Bar::f|candidate expects" } +}; + +int main () +{ + Bar b; + + b.f ();// { dg-error "no matching" } + // { dg-message "candidate" "candidate note" { target *-*-* } 19 } + b.f (10); +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/overload10.C b/gcc/testsuite/g++.old-deja/g++.brendan/overload10.C new file mode 100644 index 000000000..6ed0a3c83 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/overload10.C @@ -0,0 +1,25 @@ +// { dg-do assemble } +// GROUPS passed overloading +class Bed { + public: + static void bed_func( + int (*f)(int &, int, int)); +}; +class g_func { +public: + static int save_status; + + // in compute_harshness, we should be using comptypes, not ==, to + // check if this is equivalent to the previous decl; the only + // difference is the default arg + static int rpt_func(int &status, int expand, + int restore_cursor=1 ); +}; + +int main (int argc, + char **argv, + char **envp) +{ + Bed::bed_func(g_func::rpt_func); + return(1); +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/overload11.C b/gcc/testsuite/g++.old-deja/g++.brendan/overload11.C new file mode 100644 index 000000000..0e8df404c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/overload11.C @@ -0,0 +1,11 @@ +// { dg-do assemble } +// GROUPS passed overloading +class foo_int +{ +public: + int & i; + + foo_int (int &j) : i(j) {} + void inc () { i++; } + +}; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/overload2.C b/gcc/testsuite/g++.old-deja/g++.brendan/overload2.C new file mode 100644 index 000000000..0d8ad4833 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/overload2.C @@ -0,0 +1,44 @@ +// { dg-do run } +// GROUPS passed overloading +// Check that calls to the correct overloaded virtual +// functions are generated even where the type of the formal +// arguments for the overloadings are similar or related. + +extern "C" int printf (const char *, ...); + +int proper_method_called = 0; + +struct base { + int member; + virtual void method (char) + { + } + virtual void method (char *) + { + } +}; + +struct derived : public base { + int member; + virtual void method (char) + { + } + virtual void method (char *) + { + proper_method_called++; + } +}; + +char *message; + +int main () +{ + derived derived_object; + + derived_object.method (message); + + if (proper_method_called != 1) + { printf ("FAIL\n"); return 1; } + else + printf ("PASS\n"); +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/overload3.C b/gcc/testsuite/g++.old-deja/g++.brendan/overload3.C new file mode 100644 index 000000000..49f9d6931 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/overload3.C @@ -0,0 +1,27 @@ +// { dg-do assemble } +// GROUPS passed overloading +typedef int rutBoolean; + +class rutBigIntRep +{ +public: + friend rutBoolean operator>(const rutBigIntRep& a, const rutBigIntRep& b); + operator rutBoolean() const; +protected: + enum Kluge {kluge}; + rutBigIntRep(Kluge) {} + rutBigIntRep(); + rutBigIntRep(const rutBigIntRep& value); + rutBigIntRep& operator=(const rutBigIntRep& value); +}; + +rutBoolean operator>(const rutBigIntRep& a, const rutBigIntRep& b) { + // This should not result in a warning. It used to warn about the + // conversion from int to enum while exploring the possibility of + // converting `a' via `operator rutBoolean', then using the + // rutBigIntRep(Kluge) constructor. It later realizes it shouldn't + // do this, but the call to build_type_conversion was ending up with + // a warning in convert. + rutBigIntRep diff(a); + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/overload4.C b/gcc/testsuite/g++.old-deja/g++.brendan/overload4.C new file mode 100644 index 000000000..6206d0b9e --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/overload4.C @@ -0,0 +1,24 @@ +// { dg-do assemble } +// GROUPS passed overloading + typedef void * (*NewObject) (void); + + class B + { + public: + static void WantsNew (NewObject creator); // { dg-message "B::WantsNew|no known conversion" } + }; + + class A + { + public: + static A * NewOne (void); + + static void InitClass (void) + { + B::WantsNew ( (NewObject) A::NewOne ); + // This used to die in convert_harshness_{ansi,old} cuz it + // didn't know what to do about a void type. + B::WantsNew ( A::NewOne );// { dg-error "no matching" } + // { dg-message "candidate" "candidate note" { target *-*-* } 21 } + } + }; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/overload5.C b/gcc/testsuite/g++.old-deja/g++.brendan/overload5.C new file mode 100644 index 000000000..d5c25dbbe --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/overload5.C @@ -0,0 +1,23 @@ +// { dg-do assemble } +// GROUPS passed overloading +class Foo +{ +public: + int operator << (const signed char&); + int operator << (const unsigned char&); + int operator << (const short&); + int operator << (const unsigned short&); + int operator << (const long&); + int operator << (const unsigned long&); +}; + +int main () +{ + Foo fd; + + // We fixed convert_harshness_ansi so it considers the call to + // <<(const signed char&) to be a trivial conversion. It used + // to always make it a standard conversion, which made it conflict + // with <<(const unsigned char &), which is really a std conv. + fd << (signed char) 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/overload6.C b/gcc/testsuite/g++.old-deja/g++.brendan/overload6.C new file mode 100644 index 000000000..1f7fdfa57 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/overload6.C @@ -0,0 +1,24 @@ +// { dg-do assemble } +// GROUPS passed overloading +struct temp_string { + temp_string (const unsigned char); +}; + +class String { + public: + String& operator = (temp_string); + String& operator = (const String&); +}; +class S { + public: + operator temp_string & () const; +}; + +S lbuf; + +static void e_r () +{ + String a; + a = lbuf; + return; +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/overload7.C b/gcc/testsuite/g++.old-deja/g++.brendan/overload7.C new file mode 100644 index 000000000..29a906016 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/overload7.C @@ -0,0 +1,42 @@ +// { dg-do run } +// GROUPS passed overloading +extern "C" int printf (const char *, ...); + +struct NoName { + + int first; + int second; +}; + +class Casted { + + public: + + NoName x; + double y; + + Casted ( int _x , double _y ): y(_y) + { + x.first = _x; + x.second = _x*2; + } + + operator NoName() const { return x; } + operator double() const { return y; } +}; + +int main() +{ + Casted c(10,12.34); + + NoName x; + double y; + + x = c; + y = c; + + if (x.first == 10 && x.second == 20 && y == 12.34) + printf ("PASS\n"); + else + { printf ("FAIL\n"); return 1; } +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/overload8.C b/gcc/testsuite/g++.old-deja/g++.brendan/overload8.C new file mode 100644 index 000000000..bf129b02c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/overload8.C @@ -0,0 +1,9 @@ +// { dg-do assemble } +// GROUPS passed overloading +typedef struct{double re,im;} complex; +class Complex{public:double re,im; + inline void operator=(Complex&X){re=X.re; im=X.im;}}; +void zxcvbnm(int n,...){n=1;} +int main(){complex c; Complex C; +zxcvbnm(1,c); +zxcvbnm(1,C);} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/overload9.C b/gcc/testsuite/g++.old-deja/g++.brendan/overload9.C new file mode 100644 index 000000000..b24a1f647 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/overload9.C @@ -0,0 +1,20 @@ +// { dg-do assemble } +// GROUPS passed overloading +class CLogger // { dg-message "candidate" } +{ +public: + void operator() (int,const char *) {}; // { dg-message "note" } + void operator() (int,const char *, ...) {}; // { dg-message "note" } +} Log; + +class CGLogger : public CLogger // { dg-message "candidate" } +{ +} GLog; + +int main() +{ + Log(1,"Test");// { dg-error "ambiguous" } + Log(1,"Test %d",3); + GLog(1,"Test");// { dg-error "ambiguous" } + GLog(1,"Test %d",3); +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/parse1.C b/gcc/testsuite/g++.old-deja/g++.brendan/parse1.C new file mode 100644 index 000000000..ce8e4cef5 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/parse1.C @@ -0,0 +1,17 @@ +// { dg-do assemble } +// GROUPS passed parsing +class Try { +private: + char s; +public: + // an escaped double-quote should not call consume_string inside + // reinit_parse_for_block + void mf() { s='\"'; } +}; + +int main() +{ + Try x; + x.mf(); +} + diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/parse2.C b/gcc/testsuite/g++.old-deja/g++.brendan/parse2.C new file mode 100644 index 000000000..1b448765b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/parse2.C @@ -0,0 +1,10 @@ +// { dg-do assemble } +// GROUPS passed parsing +class BitString { +public: + int i; +}; + + +typedef BitString BS; +typedef ::BitString cBS; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/parse3.C b/gcc/testsuite/g++.old-deja/g++.brendan/parse3.C new file mode 100644 index 000000000..18bde916f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/parse3.C @@ -0,0 +1,23 @@ +// { dg-do assemble } + +// these are marked as expected errors because they evidence an +// ambiguity in the grammar between expressions and declarations. +// when the parser's been cleaned up or rewritten, these two error +// markers can go away, since they'll no longer occur. + +// Fixed. PR 8545, 2001 01 23 +class A +{ + public: + int high; + unsigned int low; + A operator+(const A in); +}; + +A A::operator+(const A in) +{ + if (high==0) + return A(); // this works + else + return (A()); // this works not +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/parse4.C b/gcc/testsuite/g++.old-deja/g++.brendan/parse4.C new file mode 100644 index 000000000..3f201e857 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/parse4.C @@ -0,0 +1,19 @@ +// { dg-do assemble } + +class B +{ +public: + B( int t ) {} + void f() {} +}; + +int g() { return 0; } // referenced below + +int main() +{ + int try1; + B( try1 ).f(); // no syntax error + B b( g() ); // no syntax error + B( ::g() ).f(); // no syntax error + B( g() ).f(); // no syntax error +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/parse5.C b/gcc/testsuite/g++.old-deja/g++.brendan/parse5.C new file mode 100644 index 000000000..666acf252 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/parse5.C @@ -0,0 +1,21 @@ +// { dg-do assemble } + + +class ptr8 + { +public: + ptr8(unsigned char *string,int len); + }; + +template <unsigned int S> +class buf + { +public: + buf(const ptr8& aRef); + }; + +int main() + { + unsigned char b[3]; + buf<3> b2(ptr8(&b[0],3)); + } diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/parse6.C b/gcc/testsuite/g++.old-deja/g++.brendan/parse6.C new file mode 100644 index 000000000..3d7c51dc7 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/parse6.C @@ -0,0 +1,8 @@ +// { dg-do assemble } + +class A { }; + +int main() { + A a = a; + A b(b); +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/prepost1.C b/gcc/testsuite/g++.old-deja/g++.brendan/prepost1.C new file mode 100644 index 000000000..cfee4f4c4 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/prepost1.C @@ -0,0 +1,15 @@ +// { dg-do assemble } +// GROUPS passed prefix-postfix +class foo { +public: + operator ++ (); // { dg-error "" } no type or storage class +}; + +int main() +{ + foo x; + + // This should fall back to calling operator++(), and be an error with + // the -pedantic flag. + x++;// { dg-error "" } +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/prepost2.C b/gcc/testsuite/g++.old-deja/g++.brendan/prepost2.C new file mode 100644 index 000000000..3156749cf --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/prepost2.C @@ -0,0 +1,10 @@ +// { dg-do assemble } +// GROUPS passed initialization +class foo { +public: + operator ++ (); // { dg-error "" } no type or storage class + operator ++ (int); // { dg-error "" } no type or storage class + operator ++ (char); // illegal// { dg-error "" } .* + operator ++ (short); // illegal// { dg-error "" } .* + operator ++ (long); // illegal// { dg-error "" } .* +}; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/prepost3.C b/gcc/testsuite/g++.old-deja/g++.brendan/prepost3.C new file mode 100644 index 000000000..d11624b2d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/prepost3.C @@ -0,0 +1,7 @@ +// { dg-do assemble } +// GROUPS passed prefix-postfix +class Y { +public: + friend Y operator++ (Y&); + friend Y operator++ (Y&, char); // illegal// { dg-error "" } .* +}; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/prepost4.C b/gcc/testsuite/g++.old-deja/g++.brendan/prepost4.C new file mode 100644 index 000000000..1ec6d23bf --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/prepost4.C @@ -0,0 +1,10 @@ +// { dg-do assemble } +// GROUPS passed prefix-postfix +class Y { +public: + friend Y operator++ (Y&); + + // This is legal---it's a good test to make sure that grokfndecl's + // checking of the arguments is sane. + friend Y operator++ (Y&, int); +}; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/ptolemy1.C b/gcc/testsuite/g++.old-deja/g++.brendan/ptolemy1.C new file mode 100644 index 000000000..c5987fce0 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/ptolemy1.C @@ -0,0 +1,23 @@ +// { dg-do assemble } +// GROUPS passed ptolemy-bugs +class Tcl_Interp; + +class PTcl { +public: + PTcl(Tcl_Interp* interp = 0); + ~PTcl(); + int alias(int argc,char** argv); +}; + +typedef int (PTcl::*InterpFuncP)(int,char**); + +struct InterpTableEntry { + const char* name; + InterpFuncP func; +}; + + +static InterpTableEntry funcTable[] = { + { "alias" , &PTcl::alias } , + 0, 0 +}; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/ptolemy2.C b/gcc/testsuite/g++.old-deja/g++.brendan/ptolemy2.C new file mode 100644 index 000000000..669bd7914 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/ptolemy2.C @@ -0,0 +1,69 @@ +// { dg-do run } +// GROUPS passed ptolemy-bugs +#include <iostream> + +class PTcl { +public: + int dispatcher(int which,int argc,char** argv); + // fns in the table + int one(int argc, char** argv); + int two(int argc, char** argv); + int three(int argc, char** argv); +}; + +// An InterpFuncP is a pointer to an PTcl function that takes an argc-argv +// argument list and returns TCL_OK or TCL_ERROR. + +typedef int (PTcl::*InterpFuncP)(int,char**); + +struct InterpTableEntry { + const char* name; + InterpFuncP func; +}; + +// Here is the function table and dispatcher function. +// These macros define entries for the table + +#define quote(x) #x +#define ENTRY(verb) { quote(verb), &PTcl::verb } + +static InterpTableEntry funcTable[] = { + ENTRY(one), + ENTRY(two), + ENTRY(three), + {0, 0} +}; + +int PTcl::dispatcher(int which, int argc, char** argv) { + return (this->*(funcTable[which].func))(argc, argv); +} + +void printargs(char** argv) { +// while (*argv) { +// cout << " " << *argv++; +// } +// cout << "\n"; +} + +int PTcl::one(int, char** argv) { + std::cout << "FAIL\n"; + printargs(argv); + return 1; +} + +int PTcl::two(int, char** argv) { + std::cout << "PASS\n"; + printargs(argv); + return 0; +} + +int PTcl::three(int, char** argv) { + std::cout << "FAIL\n"; + printargs(argv); + return 1; +} + +int main (int argc, char** argv) { + PTcl obj; + return obj.dispatcher(1,argc,argv); +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/ptrmem1.C b/gcc/testsuite/g++.old-deja/g++.brendan/ptrmem1.C new file mode 100644 index 000000000..051448301 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/ptrmem1.C @@ -0,0 +1,21 @@ +// { dg-do assemble } +// GROUPS passed pointers-to-members +class my_class +{ +public: + typedef void func_type (int num); + my_class (int num, func_type* proc); + void dispatch (void); +private: + int _num; + func_type *_proc; +}; + +my_class::my_class (int num, func_type* proc) : _num(num), _proc(proc) +{ +} + +void my_class::dispatch (void) +{ + _proc(_num); +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/ptrmem2.C b/gcc/testsuite/g++.old-deja/g++.brendan/ptrmem2.C new file mode 100644 index 000000000..36145cf01 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/ptrmem2.C @@ -0,0 +1,26 @@ +// { dg-do assemble } +// GROUPS passed pointers-to-members +struct C { + struct N { + int g1(int); + int g2(int); + }; + + typedef int (N::*pmfn)(int); + + int f1(int); + int f2(int); +}; + +int (C::*f)(int) = &C::f1; + +/* + The compiler should not crash on the line below; this change fixes it: + * cp-tree.c (list_hash_lookup_or_cons): Make sure the type doesn't + have TYPE_PTRMEMFUNC_P set before we try to build its + CLASSTYPE_ID_AS_LIST. +*/ + +C::pmfn h = &C::N::g1; + +int (C::N::*g)(int) = &C::N::g2; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/ptrmem3.C b/gcc/testsuite/g++.old-deja/g++.brendan/ptrmem3.C new file mode 100644 index 000000000..4f78039d4 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/ptrmem3.C @@ -0,0 +1,32 @@ +// { dg-do assemble } +// GROUPS passed pointers-to-members +template<class T> class TemplA { + T t; +}; + + +template<class T> class TemplB { +public: + typedef void (T::*TClassMethod)(); + +private: +/* + This line should not crash cuz of the get_decl_list change in this: + * cp-tree.c (list_hash_lookup_or_cons): Make sure the type doesn't + have TYPE_PTRMEMFUNC_P set before we try to build its + CLASSTYPE_ID_AS_LIST. + (get_decl_list): Likewise, when trying to read it. +*/ + TemplA<TClassMethod> Tmethod; +}; + + +class C { + int a; +}; + +int main(int, char**) { + + TemplB<C> test; +} + diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/ptrmem4.C b/gcc/testsuite/g++.old-deja/g++.brendan/ptrmem4.C new file mode 100644 index 000000000..4725fb5c2 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/ptrmem4.C @@ -0,0 +1,16 @@ +// { dg-do assemble } +// GROUPS passed pointers-to-members +class X { + private: + int i; + public: + X(int k) { i=k; } + int operator=(X &a) { return i = a.i; } + int operator=(int ii) { return i = ii; } +}; +int main(void) +{ + int (X::*op1_ptr)(X&); + op1_ptr = &X::operator=; // g++ gives error + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/recurse.C b/gcc/testsuite/g++.old-deja/g++.brendan/recurse.C new file mode 100644 index 000000000..de20a0732 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/recurse.C @@ -0,0 +1,80 @@ +// { dg-do assemble } +// GROUPS passed recursive-aborts +// types +typedef unsigned int DBflag; // for storing user flag value +typedef unsigned long DBoffset; // 32-bit unsigned integer +typedef DBoffset DBsize; // type for storing sizes of objects +typedef unsigned char DBbyte; // 8-bit unsigned char + +class DBlink +{ +protected: + DBbyte link[4]; // hold link in portable MSB first format +public: + DBlink(DBoffset = 0, DBflag = 0); + DBlink &operator=(const DBlink &); + DBlink &operator=(DBoffset); + operator DBoffset(); + operator const DBbyte *() { return link; } + void set_flag() { link[0] |= 0x80; } + void reset_flag() { link[0] &= 0x7f; } + int test_flag() const { return (link[0] & 0x80) != 0; } +}; + +typedef DBlink DBsizerec; // hold data record size in portable format + +// constants +const DBoffset DB_NULL = 0; + +class DBlinkrec +{ +protected: + // offsets are stored with MSB in link[0] + DBlink l; // offset into link file of right child - MSB = red bit + DBlink r; // offset into link file of left child - MSB = delete + DBlink d; // offset into parallel data file - MSB = user flag +public: + DBlinkrec():l(DB_NULL), r(DB_NULL), d(DB_NULL) {} + void make_red() // set link to red + { l.set_flag(); } + void make_black() // set link to black + { l.reset_flag(); } + int is_red() const // indicates whether this is a red link + { return l.test_flag(); } + void set_discard() // set discard flag + { r.set_flag(); } + void reset_discard() // reset discard flag + { r.reset_flag(); } + int is_discarded() const // check discard flag + { return r.test_flag(); } + void set_flag() // set user flag + { d.set_flag(); } + void reset_flag() // reset user flag + { d.reset_flag(); } + int is_flag() const // check user flag + { return d.test_flag(); } + + friend class DataBase; +}; + +class DBpathrec : public DBlinkrec +{ + DBoffset offset; // offset of link record in LNK file +public: + DBpathrec():offset(DB_NULL) { } + DBpathrec(DBoffset off, const DBlinkrec &lr):offset(off), DBlinkrec(lr) {} + operator DBoffset() { return offset; } + DBpathrec &operator=(DBoffset off) { offset = off; return *this; } + DBpathrec &operator=(const DBpathrec &pr) + { offset = pr.offset; (DBlinkrec)*this = (DBlinkrec)pr; return *this; } + + friend class DataBase; +}; + +int main() +{ + DBpathrec a(), b(); + + a = b;// { dg-error "" } non-lvalue in assignment.* +} + diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/redecl1.C b/gcc/testsuite/g++.old-deja/g++.brendan/redecl1.C new file mode 100644 index 000000000..0e01f2b47 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/redecl1.C @@ -0,0 +1,5 @@ +// { dg-do assemble } +// GROUPS passed redeclaration +inline int min(int x, int y) {return x < y ? x : y;} /* 235 */// { dg-error "" } .* +int min(int a, int b); +inline int min(int a, int b) {return (a < b)?a:b;}// { dg-error "" } .* diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/redecl2.C b/gcc/testsuite/g++.old-deja/g++.brendan/redecl2.C new file mode 100644 index 000000000..b654b2465 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/redecl2.C @@ -0,0 +1,52 @@ +// { dg-do run } +// GROUPS passed redeclaration +// Check that if multiple declarations of the same single +// function are present in different places in the same file, +// and if these declarations differ (as allowed) in the number +// of argument defaults provided, that correct values are +// passed at all call points anyway. + +extern "C" int printf (const char *, ...); + +void receiver (int ii, int jj); + +void sender_1 () +{ + receiver (3,7); +} + +void receiver (int ii, int jj = 9); + +void sender_2 () +{ + receiver (5); +} + +int ii_sum = 0; +int jj_sum = 0; + +void sender_3 (); + +int main () +{ + sender_1 (); + sender_2 (); + sender_3 (); + if (ii_sum != 13 || jj_sum != 25) + { printf ("FAIL\n"); return 1; } + else + printf ("PASS\n"); + + return 0; +} + +void receiver (int ii, int jj) +{ + ii_sum += ii; + jj_sum += jj; +} + +void sender_3 () +{ + receiver (5); +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/redecl3.C b/gcc/testsuite/g++.old-deja/g++.brendan/redecl3.C new file mode 100644 index 000000000..1bfd88974 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/redecl3.C @@ -0,0 +1,17 @@ +// { dg-do assemble } +// GROUPS passed redeclaration +class foo +{ +public: + int bar(int a); +}; + + +void bar(int &a); + +int foo::bar(int a) { + int a = 0; // Should this be an error ?// { dg-error "" } declaration.* + + bar(a); + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/reference1.C b/gcc/testsuite/g++.old-deja/g++.brendan/reference1.C new file mode 100644 index 000000000..92ff38d7d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/reference1.C @@ -0,0 +1,54 @@ +// { dg-do run } +// { dg-options "-w" } +// GROUPS passed references +// Check that if a reference is initialized to refer to a value +// which is returned from a function call, the actual call to +// the function is only invoked for the original initialization +// of the reference, and not for each subsequent use of the +// reference. +// +// This test fails with G++ 1.35.0- (pre-release). +// Reported 4/4/89 by Kim Smith + +extern "C" int printf (const char *, ...); + +struct base { + mutable int data_member; + + base () {} + void function_member () const; +}; + +base base_object; + +base base_returning_function (); + +int call_count = 0; + +int main () +{ + const base& base_ref = base_returning_function (); + + base_ref.function_member (); + base_ref.function_member (); + base_ref.data_member = 99; + + if (call_count == 1) + printf ("PASS\n"); + else + { printf ("FAIL\n"); return 1; } + + return 0; +} + +base base_returning_function () +{ + base local_base_object; + + call_count++; + return local_base_object; +} + +void base::function_member () const +{ +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/rtti1.C b/gcc/testsuite/g++.old-deja/g++.brendan/rtti1.C new file mode 100644 index 000000000..f57b9571f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/rtti1.C @@ -0,0 +1,8 @@ +// { dg-do assemble } +// GROUPS passed RTTI +#include <typeinfo> + +struct B { virtual ~B(){} }; +struct D0 : public virtual B { virtual ~D0(){} }; +struct D1 : public virtual D0 { virtual ~D1(){} }; +struct C : public virtual B, public D1 { virtual ~C() { } }; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/scope1.C b/gcc/testsuite/g++.old-deja/g++.brendan/scope1.C new file mode 100644 index 000000000..f54594109 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/scope1.C @@ -0,0 +1,8 @@ +// { dg-do assemble } +// GROUPS passed scoping +int f (int i) { + if (i) + for (int j = i; j; j--) + ; + return j; // error: j should only be in scope inside the body of `for'// { dg-error "" } .* +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/scope2.C b/gcc/testsuite/g++.old-deja/g++.brendan/scope2.C new file mode 100644 index 000000000..1d211aac4 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/scope2.C @@ -0,0 +1,29 @@ +// { dg-do assemble } +// GROUPS passed scoping +class A +{ + public: + A() {} + ~A() {} + virtual void f() {} +}; + +class B : public A +{ + public: + B() {} + ~B() {} + virtual void f() {} +}; + + +B GLOBAL_B; + +B& foo() {return GLOBAL_B;} + +int main() +{ + // build_scoped_method_call and build_scoped_ref should know how + // to deal with a reference for this + foo().A::f(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/scope3.C b/gcc/testsuite/g++.old-deja/g++.brendan/scope3.C new file mode 100644 index 000000000..3ff7f54ad --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/scope3.C @@ -0,0 +1,25 @@ +// { dg-do assemble } +// GROUPS passed scoping +// This is fixed when NEW_CLASS_SCOPING is on. + +template<class T> +class ArrayG { +public: + ArrayG(); +protected: + const unsigned INITIAL; + T* array; +}; + +template<class T> +ArrayG<T>::ArrayG(): +array(new T[INITIAL]) +{ } + +struct X { + struct Correspondence { + int i; + }; + + void fill(ArrayG<Correspondence>& a); +}; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/scope4.C b/gcc/testsuite/g++.old-deja/g++.brendan/scope4.C new file mode 100644 index 000000000..2729ca6e6 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/scope4.C @@ -0,0 +1,31 @@ +// { dg-do assemble } +// GROUPS passed scoping +class BitString { +public: + int i; + int length() const; +}; + +typedef BitString BS; + +class V { +public: + class BitString { + public: + static int x(const ::BitString& value); + static int y(const class ::BitString& value); // should be parsed ok + static int z(const BS& value); + }; +}; + +int +V::BitString::x(const ::BitString& value) +{ return value.length(); } + +int +V::BitString::y(const class ::BitString& value) // should be parsed ok +{ return value.length(); } + +int +V::BitString::z(const BS& value) +{ return value.length(); } diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/scope5.C b/gcc/testsuite/g++.old-deja/g++.brendan/scope5.C new file mode 100644 index 000000000..1b6345f1d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/scope5.C @@ -0,0 +1,21 @@ +// { dg-do assemble } +// GROUPS passed scoping +class Integer { +public: + int i; +}; + +class Type { + enum Klasse { ENUM, INTEGER }; + + class Description { + public: + + }; + + class Integer: public Description { + public: + ::Integer low; + ::Integer high; + }; +}; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/shadow1.C b/gcc/testsuite/g++.old-deja/g++.brendan/shadow1.C new file mode 100644 index 000000000..c133dea54 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/shadow1.C @@ -0,0 +1,8 @@ +// { dg-do assemble } +// GROUPS passed errors +void f( int a) { + int a; // this should be an error now// { dg-error "" } .* + { + int a; + } +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/sizeof1.C b/gcc/testsuite/g++.old-deja/g++.brendan/sizeof1.C new file mode 100644 index 000000000..bc2f18168 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/sizeof1.C @@ -0,0 +1,15 @@ +// { dg-do assemble } +// { dg-options "-pedantic-errors" } +// GROUPS passed sizeof +// ARM $5.3.2 + +void f() { } + +int +main() +{ + // sizeof may not be applied to a function + int i = sizeof( f);// { dg-error "" } .* + + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/sizeof2.C b/gcc/testsuite/g++.old-deja/g++.brendan/sizeof2.C new file mode 100644 index 000000000..355bee746 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/sizeof2.C @@ -0,0 +1,18 @@ +// { dg-do assemble } +// { dg-options "-pedantic-errors" } +// GROUPS passed sizeof +// ARM $5.3.2 + +void f() { } + +struct foo { int bit : 1; }; + +int +main() +{ + // sizeof may not be applied to a bit-field + foo f; + int i = sizeof (f.bit);// { dg-error "" } .* + + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/sizeof3.C b/gcc/testsuite/g++.old-deja/g++.brendan/sizeof3.C new file mode 100644 index 000000000..3596a1eeb --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/sizeof3.C @@ -0,0 +1,15 @@ +// { dg-do assemble } +// { dg-options "-pedantic-errors" } +// GROUPS passed sizeof +// ARM $5.3.2 + +class bar; + +int +main() +{ + // sizeof may not be applied to an undefined class + int k = sizeof (bar);// { dg-error "" } .* + + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/sizeof4.C b/gcc/testsuite/g++.old-deja/g++.brendan/sizeof4.C new file mode 100644 index 000000000..3ac0a8e2e --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/sizeof4.C @@ -0,0 +1,13 @@ +// { dg-do assemble } +// { dg-options "-pedantic-errors" } +// GROUPS passed sizeof +// ARM $5.3.2 + +int +main() +{ + // sizeof may not be applied to the type void + int l = sizeof (void);// { dg-error "" } .* + + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/sizeof5.C b/gcc/testsuite/g++.old-deja/g++.brendan/sizeof5.C new file mode 100644 index 000000000..551f408cf --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/sizeof5.C @@ -0,0 +1,18 @@ +// { dg-do run } +// GROUPS passed sizeof +// ARM $5.3.2 + +extern "C" int printf (const char *, ...); + +class foo {}; + +int +main () +{ + // The size of any class or class object is larger than zero. + int i = sizeof (foo); + if (i > 0) + printf ("PASS\n"); + else + { printf ("FAIL\n"); return 1; } +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/sorry1.C b/gcc/testsuite/g++.old-deja/g++.brendan/sorry1.C new file mode 100644 index 000000000..7a77801f5 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/sorry1.C @@ -0,0 +1,36 @@ +// { dg-do assemble } +// GROUPS passed old-sorry +class a { +public: + int* foo(); +}; + +a aa; +a* ap; + +class b { +public: + int ok(int* p =aa.foo()); + + // dump_init should know what to do with this NON_LVALUE_EXPR + int f(int* p =ap->foo()); +}; + + int +b::ok(int *p) +{ + return 0; +} + + int +b::f(int *p) +{ + return 0; +} + void +bar() +{ + b b; + b.ok(); + b.f(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/static1.C b/gcc/testsuite/g++.old-deja/g++.brendan/static1.C new file mode 100644 index 000000000..cb8392377 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/static1.C @@ -0,0 +1,4 @@ +// { dg-do assemble } +// GROUPS passed static +class A { public: int a; };// { dg-error "" } .* +void foo7 () { A::a = 3; }// { dg-error "" } .* diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/static2.C b/gcc/testsuite/g++.old-deja/g++.brendan/static2.C new file mode 100644 index 000000000..099d92210 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/static2.C @@ -0,0 +1,19 @@ +// { dg-do assemble } +// GROUPS passed static +class A +{ + public: + void member(void) + { + } + + static void staticMember() + { + member (); // illegal, no object for calling non-static method// { dg-error "" } .* + } +}; + +int main() +{ + A::staticMember(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/static3.C b/gcc/testsuite/g++.old-deja/g++.brendan/static3.C new file mode 100644 index 000000000..c0ee01178 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/static3.C @@ -0,0 +1,15 @@ +// { dg-do assemble } +// GROUPS passed static +class foo{ +public: + static void bar( int i ){ value = i; } + static int value;// { dg-error "" } .* +}; + +const int foo::value = 0; // should be an error.// { dg-error "" } .* + +int main(){ + foo::bar( 1 ); + return 0; +} + diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/synth1.C b/gcc/testsuite/g++.old-deja/g++.brendan/synth1.C new file mode 100644 index 000000000..3a27e63cf --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/synth1.C @@ -0,0 +1,33 @@ +// { dg-do assemble } +// { dg-xfail-if "" { sparc64-*-elf } { "*" } { "" } } +// { dg-options "-pedantic-errors -g -Wall" } +// GROUPS passed synthetics +// Check to make sure that g++ doesn't get freaked out about the use +// of generated methods that it supposedly "can't see". + +class Char { +public: + Char(); + Char(char v); + + // synthetic copy-constructor and operator= +private: + char value; +}; + +class XChar: public Char { +public: + XChar(); + XChar(char v, int serial); + + void operator=(const XChar& other); +private: + int serial; +}; + +void +XChar::operator=(const XChar& other) +{ + Char::operator=(other); + // serial stays the same +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/template1.C b/gcc/testsuite/g++.old-deja/g++.brendan/template1.C new file mode 100644 index 000000000..552f8eeb8 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/template1.C @@ -0,0 +1,17 @@ +// { dg-do assemble } +// GROUPS passed templates +// g++-2.2.1: member functions returning a template type + + +template <class T> struct list { }; + +struct A +{ + list<int> L; + + list<int> get_list(); + +}; + + +list<int> A::get_list() { return L; } diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/template11.C b/gcc/testsuite/g++.old-deja/g++.brendan/template11.C new file mode 100644 index 000000000..bc5724985 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/template11.C @@ -0,0 +1,47 @@ +// { dg-do assemble } +// GROUPS passed templates +template <class Called> +class aCallback +{ +public: + aCallback(Called& obj, int (Called::*met)()); + + int callback(); + +protected: + +private: + // the object to call + Called& object; + + // the method to apply + int (Called::*method)(); + +}; + +template <class Called> +aCallback<Called>::aCallback(Called& obj, + int (Called::*met)()) : +object(obj), +method(met) +{} + +template <class Called> +int aCallback<Called>::callback() +{ + return (object.*method)(); +} + +struct myStruct +{ + int action() {return 24;} +}; + +int main() +{ + myStruct toto; + + aCallback<myStruct> cb(toto, &myStruct::action); + + return cb.callback(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/template12.C b/gcc/testsuite/g++.old-deja/g++.brendan/template12.C new file mode 100644 index 000000000..686db48f5 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/template12.C @@ -0,0 +1,8 @@ +// { dg-do assemble } +// GROUPS passed templates +inline void foo (const int &x) {} + +template <class type> +inline void foo (const type &x) {x.eat_this_and_die();} + +int main (int argc, char **argv) {foo (argc);} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/template13.C b/gcc/testsuite/g++.old-deja/g++.brendan/template13.C new file mode 100644 index 000000000..ea81202c2 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/template13.C @@ -0,0 +1,15 @@ +// { dg-do assemble } +// GROUPS passed templates +template<class T> +class ListS { +public: + class Vix { + public: + Vix(); + }; +}; + +template<class T> +ListS<T>::Vix::Vix() +{ } + diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/template15.C b/gcc/testsuite/g++.old-deja/g++.brendan/template15.C new file mode 100644 index 000000000..366ebfed6 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/template15.C @@ -0,0 +1,19 @@ +// { dg-do assemble } +// GROUPS passed templates +template<class T> class Stack { + public: + Stack (int s = 10); //Comment out "= 10" and it will compile + ~Stack(void); //Omitting "void" doesn't help +}; + +template<class T> Stack<T>::~Stack(void) +{ } + +//If this definition comes before the one for ~Stack, the error message +//about redeclaration of `void Stack<int>::~Stack()' will not occur. +template<class T> Stack<T>::Stack(int s) +{ } + +int main () { + Stack<int> stk(10); +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/template16.C b/gcc/testsuite/g++.old-deja/g++.brendan/template16.C new file mode 100644 index 000000000..d62f6bede --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/template16.C @@ -0,0 +1,10 @@ +// { dg-do assemble } +// GROUPS passed templates +template<class T> class TList { + typedef void (T::*TVOIDFUNT)(); + typedef T* (T::*TTPFUNT)(T*); +}; + +class A; +class B : TList<A> { }; + diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/template17.C b/gcc/testsuite/g++.old-deja/g++.brendan/template17.C new file mode 100644 index 000000000..5f2d45f1c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/template17.C @@ -0,0 +1,15 @@ +// { dg-do assemble } +// GROUPS passed templates +struct Regex { int i; Regex(char *, int); }; +template<class KEY> +class NDAMName { +public: + static const Regex pattern; + static unsigned sequence_number; +}; + +const Regex NDAMName<'L'>::pattern("^[Ll](.*)$", 1);// { dg-error "type/value mismatch" "mismatch" } +// { dg-error "expected a type" "expected" { target *-*-* } 11 } +// { dg-warning "deprecated" "depr" { target *-*-* } 11 } +unsigned NDAMName<'L'>::sequence_number = 0;// { dg-error "type/value mismatch" "mismatch" } +// { dg-error "expected a type" "exp" { target *-*-* } 14 } diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/template18.C b/gcc/testsuite/g++.old-deja/g++.brendan/template18.C new file mode 100644 index 000000000..280db5d3a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/template18.C @@ -0,0 +1,14 @@ +// { dg-do assemble } +// GROUPS passed templates +template<class T> class X; +typedef X<int> IX; + +template<class T> +class X { +public: + T x; +}; + +struct A { + IX c; +}; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/template19.C b/gcc/testsuite/g++.old-deja/g++.brendan/template19.C new file mode 100644 index 000000000..d5215aea7 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/template19.C @@ -0,0 +1,26 @@ +// { dg-do assemble } +// GROUPS passed templates +template <class T> +class Base +{ +public: + Base() { } +}; + +template <class memberType, class keyType> +class Middle : public Base<memberType> +{ +public: + Middle (keyType const & (*ko) (memberType const &)) + { + } +}; + +// EXCHANGE the following lines for this code to work. +//template <class memberType, class keyType> class Middle; +template <class T, class keyType> class Middle; + +struct Test : public Middle <int, int> +{ + Test(); +}; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/template2.C b/gcc/testsuite/g++.old-deja/g++.brendan/template2.C new file mode 100644 index 000000000..cb1d674ea --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/template2.C @@ -0,0 +1,14 @@ +// { dg-do assemble } +// GROUPS passed templates +template <class Q> +class Conc { +public: + static int body(); +}; + +template <class Q> +int Conc<Q>::body() {return 0;} + +int main () { + Conc<int> s2; +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/template20.C b/gcc/testsuite/g++.old-deja/g++.brendan/template20.C new file mode 100644 index 000000000..6b7c40d0e --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/template20.C @@ -0,0 +1,21 @@ +// { dg-do assemble } +// GROUPS passed templates +template <class A, class B> class Map; + +class Foo +{ +public: + static Map<int,int> bar; +}; + +template <class A, class B> +class Map +{ +public : + int find(); +}; + +int main() +{ + int z = Foo::bar.find(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/template21.C b/gcc/testsuite/g++.old-deja/g++.brendan/template21.C new file mode 100644 index 000000000..3bfd0cfc4 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/template21.C @@ -0,0 +1,43 @@ +// { dg-do assemble } +// GROUPS passed templates +template<class T> +class L { +public: + L(); + + T x[30]; + int doit(int i) const; +}; + +#ifdef BUG +template<class T> +int +L<T>::doit(int i) const +{ + return x[i].z; +} +#endif + +class X { +public: + class Y { + public: + Y(); + Y(int); + + int z; + }; + + L<Y> ly; +}; + +#ifndef BUG +template<class T> +int +L<T>::doit(int i) const +{ + return x[i].z; +} +#endif + +static X x; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/template22.C b/gcc/testsuite/g++.old-deja/g++.brendan/template22.C new file mode 100644 index 000000000..4301fad52 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/template22.C @@ -0,0 +1,23 @@ +// { dg-do run } +// GROUPS passed templates +extern "C" int printf (const char *, ...); + +template <class T> +class Foo +{ +public: + void func (int const& i); +}; + +template <class T> +void Foo<T>:: +func (int const& i) +{} + + +int main () +{ + Foo<int const> foo; + printf ("PASS\n"); + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/template23.C b/gcc/testsuite/g++.old-deja/g++.brendan/template23.C new file mode 100644 index 000000000..d366eda5d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/template23.C @@ -0,0 +1,34 @@ +// { dg-do assemble } +// GROUPS passed templates +template <class T> +class T_Base +{}; + +template <class T> +class T_Derived +: public T_Base<T> +{}; + + +class Base +{ +public: + Base (float name); +}; + +class Derived +: public Base +{ +private: + T_Base<int>* data_; // Fix (1): Change date_ from T_Base<int>* to T_Derived<int>* + +public: + Derived (float name); +}; + + +Derived:: +Derived (float name) +: Base(name), + data_(new T_Derived<int>()) +{} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/template24.C b/gcc/testsuite/g++.old-deja/g++.brendan/template24.C new file mode 100644 index 000000000..d7559547f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/template24.C @@ -0,0 +1,21 @@ +// { dg-do run } +// GROUPS passed templates +extern "C" int printf (const char *, ...); + +template <class F> +class Temp +{ + F func_; +public: + Temp (F f) :func_(f) {} +}; + +int func (int h = 1, int z = 2) { return h+z; } + +int main () +{ + Temp<int(*)(int, int)> temp (func); + + printf ("PASS\n"); + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/template25.C b/gcc/testsuite/g++.old-deja/g++.brendan/template25.C new file mode 100644 index 000000000..43f69a55e --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/template25.C @@ -0,0 +1,36 @@ +// { dg-do assemble } +// GROUPS passed templates +template <class T> +class Temp_Base +{}; + +template <class T> +class Temp_Derived +: public Temp_Base<T> +{ +public: + Temp_Derived (int i = 10) {} +}; + + +class Base +{ + float r_; +public: + Base (float r) : r_(r) {} +}; + +class Derived +: public Base +{ +private: + Temp_Base<int>* boo_; +public: + Derived (float); +}; + +Derived:: +Derived (float form) +: Base(form), + boo_(new Temp_Derived<int>) +{} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/template26.C b/gcc/testsuite/g++.old-deja/g++.brendan/template26.C new file mode 100644 index 000000000..3f5de3d7a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/template26.C @@ -0,0 +1,31 @@ +// { dg-do assemble } +// GROUPS passed templates +class V { + public: + V(); + V(int); + }; + +template <int I> class AA: public virtual V { + public: + AA(); + AA(int); + }; + +template <int I> class BB : public virtual V { + public: + BB(); + BB(int); + }; + +template <int I> AA<I>::AA() {} +template <int I> AA<I>::AA(int i): V(i) {} +template <int I> BB<I>::BB() {} +template <int I> BB<I>::BB(int i) {} + +class CC : public AA<1>, public BB<2> { + public: + CC(); + CC(int); + }; + diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/template27.C b/gcc/testsuite/g++.old-deja/g++.brendan/template27.C new file mode 100644 index 000000000..5357f1ca6 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/template27.C @@ -0,0 +1,15 @@ +// { dg-do assemble } +// GROUPS passed templates + template<class K, class V> class MapLS { }; + class String {}; + class X1 { }; + class RefProto { }; + template<class REP> class Ref { }; + + template <> + class MapLS<String, Ref<X1> >: public MapLS<String, RefProto> { + public: + ~MapLS(); + }; + + MapLS<String, Ref<X1> >::~MapLS() { } diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/template28.C b/gcc/testsuite/g++.old-deja/g++.brendan/template28.C new file mode 100644 index 000000000..6c56d4555 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/template28.C @@ -0,0 +1,13 @@ +// { dg-do assemble } +// GROUPS passed templates +class X { + const char *fptr; +public: + X(const char *ptr) { fptr = ptr; } + operator const char*() { return fptr; } +}; + +int main(){ + X x1("1234"); + X x2(x1+1); +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/template29.C b/gcc/testsuite/g++.old-deja/g++.brendan/template29.C new file mode 100644 index 000000000..aee91c237 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/template29.C @@ -0,0 +1,12 @@ +// { dg-do assemble } +// GROUPS passed templates + template <class ElementType> class A + { public: + A(ElementType) {} + ElementType get() const ; + }; + + template <class ElementType> ElementType A<ElementType>::get() const + { return ElementType(0); } + +int main() { const A<short> a(3); } diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/template3.C b/gcc/testsuite/g++.old-deja/g++.brendan/template3.C new file mode 100644 index 000000000..09c857187 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/template3.C @@ -0,0 +1,50 @@ +// { dg-do run } +// GROUPS passed templates +extern "C" int printf (const char *, ...); +extern "C" void exit (int); + +int count = 0; + +void +die (int x) +{ + if (x != ++count) + { + printf ("FAIL\n"); + exit (1); + } +} + +class A { + public: + void f() const { die (-1); } +}; + + +template <class Item> +class B : public A { + public: + void f() const; +}; + +template <class Item> +inline void B<Item>::f() const { die (1); } + +template <class Item> +class C : public A { + public: + void f() const { die (2); } +}; + + +int main() +{ + B<int> b; + C<int> c; + + b.f(); //- bugged, (A::f() called instead of B::f()) + c.f(); //- works fine (C::f() called) + + printf ("PASS\n"); + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/template30.C b/gcc/testsuite/g++.old-deja/g++.brendan/template30.C new file mode 100644 index 000000000..87c95e15a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/template30.C @@ -0,0 +1,17 @@ +// { dg-do assemble } +// GROUPS passed templates + + template<class K, class V> class MapLS { }; + class String {}; + class X1 { }; + class RefProto { }; + template<class REP> class Ref { }; + + template <> + class MapLS<String, Ref<X1> >: public MapLS<String, RefProto> { + public: + ~MapLS(); + }; + + MapLS<String, Ref<X1> >::~MapLS() { } + diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/template31.C b/gcc/testsuite/g++.old-deja/g++.brendan/template31.C new file mode 100644 index 000000000..b13e63851 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/template31.C @@ -0,0 +1,38 @@ +// { dg-do assemble } +// GROUPS passed templates +// PRMS Id: 13218 + +struct C { + int x; + char y; + double z; +}; +C c02; + +template <int* ip> struct A { + int* p; + A() : p(ip) {} +}; + +template <C* cp> struct B { + C* p; + B() : p(cp) {} +}; + +int i00; + +int main(void) +{ + A<&i00> a00; + + extern int i01; + A<&i01> a01; + + B<&c02> b02; + + extern C c03; + B<&c03> b03; +} + +int i01; +C c03; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/template4.C b/gcc/testsuite/g++.old-deja/g++.brendan/template4.C new file mode 100644 index 000000000..61ad1cc6b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/template4.C @@ -0,0 +1,11 @@ +// { dg-do assemble } +// GROUPS passed templates +// This used to be a circularity in chainon. +template <class ARG> struct TMPL { + typedef int ARG::*ARG_data_member_ptr; + typedef void (ARG::*ARG_func_member_ptr) (); +}; + +struct S { }; + +TMPL<S> object; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/template5.C b/gcc/testsuite/g++.old-deja/g++.brendan/template5.C new file mode 100644 index 000000000..1b68043a3 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/template5.C @@ -0,0 +1,48 @@ +// { dg-do assemble } +// GROUPS passed templates +template<class T> +class Vector +{ +public: + Vector(int x); + ~Vector(); + T& operator [] (int i); + +private: + T* v; + int sz; +} ; + +template<class T> +Vector<T>::Vector(int x) +{ + sz = x; + v = new T (sz); +} + +template<class T> +Vector<T>::~Vector() + { delete [] v; } + +template<class T> +T & +Vector<T>::operator [] (int i) + { return v[i]; } + +int +main(int, char **) +{ + Vector<int> intvec(3); + + intvec[0] = 1; + intvec[1] = 2; + intvec[2] = 3; + + for (int i = 0; i < 3; i++) + intvec[i]; + + return 0; +} + + + diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/template6.C b/gcc/testsuite/g++.old-deja/g++.brendan/template6.C new file mode 100644 index 000000000..2cff7e5b4 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/template6.C @@ -0,0 +1,30 @@ +// { dg-do assemble } +// GROUPS passed templates +struct B { +}; + +struct X : B { + ~X (); +}; + +struct Request { + X s; +}; + +template <class ET> class TC { + ET data; +}; + +struct TMem { + + ~TMem() {} + + TC<Request> *req; +}; + +struct FIO { + + void init (); + + FIO () { init(); } +}; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/template7.C b/gcc/testsuite/g++.old-deja/g++.brendan/template7.C new file mode 100644 index 000000000..8fb636e7a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/template7.C @@ -0,0 +1,48 @@ +// { dg-do assemble } +// GROUPS passed templates +template <class ET> +class ChainElem { +public: + + ET data; +}; + +template <class ET> +class Chain { +public: + + ChainElem<ET> *first; + + virtual ~Chain() {} + +}; + +struct B { +}; + +struct X : B { + ~X (); +}; + +struct TBNFexpression { +}; + +struct TCaseLabelPair { +}; + +struct TVariant { + Chain<TCaseLabelPair> CaseLabelList; +}; + +struct TCaseConstruct { + Chain<TBNFexpression> TagFieldPrefixes; + Chain<TVariant> Variants; +}; + +struct Production { + X TypeName; +}; + +struct SimpleSyntax { + Chain<Production> Productions; +}; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/template8.C b/gcc/testsuite/g++.old-deja/g++.brendan/template8.C new file mode 100644 index 000000000..66ba0d8ac --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/template8.C @@ -0,0 +1,20 @@ +// { dg-do assemble } +// GROUPS passed templates +#include <stdio.h> + +// make sure we accept unions for templates +template<int n> +union Double_alignt{ + double for_alignt; + char array[n]; + +}; + +int main(){ + + + Double_alignt<20000> heap; + + printf(" &heap.array[0] = %d, &heap.for_alignt = %d\n", &heap.array[0], &heap.for_alignt); + +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/temporary1.C b/gcc/testsuite/g++.old-deja/g++.brendan/temporary1.C new file mode 100644 index 000000000..f4c2ab380 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/temporary1.C @@ -0,0 +1,13 @@ +// { dg-do assemble } +// GROUPS passed temporaries +#include <stdio.h> + +int main () +{ + int a = 2; + + if (----a == 0) + printf ("a = 0\n"); + + printf ("a = %d\n", a); +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/typedef1.C b/gcc/testsuite/g++.old-deja/g++.brendan/typedef1.C new file mode 100644 index 000000000..3eed3e02f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/typedef1.C @@ -0,0 +1,29 @@ +// { dg-do assemble } + +class baseClassA +{ +public: +private: + class internalClassA + { + public: + private: + typedef int privateType; + + privateType memberA; + }; +}; + +class baseClassB +{ +public: +private: + class internalClassA + { + public: + private: + typedef unsigned int privateType; + + privateType memberB; + }; +}; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/union1.C b/gcc/testsuite/g++.old-deja/g++.brendan/union1.C new file mode 100644 index 000000000..ffc5555d7 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/union1.C @@ -0,0 +1,22 @@ +// { dg-do run } +// GROUPS passed unions +// This is fixed by finish_anon_union doing a string_cst_equal check on +// the DECL_SIZE of the decls, instead of comparing the DECL_SIZE nodes. + +// The compiler currently fails to allocate space for the static union. + + unsigned + hash(const double d) + { + static union { + unsigned asint[2]; + double asdouble; + }; + asdouble = d; + return asint[0] ^ asint[1]; + } + +int main () +{ + hash (3.1415); +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/union2.C b/gcc/testsuite/g++.old-deja/g++.brendan/union2.C new file mode 100644 index 000000000..5d7e9c85c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/union2.C @@ -0,0 +1,13 @@ +// { dg-do assemble } +// GROUPS passed unions +class B; + +struct A { + A(B* x) : i(x) {} + A() : i(0) {} + + union { + B* i; + B* c; + }; +}; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/union3.C b/gcc/testsuite/g++.old-deja/g++.brendan/union3.C new file mode 100644 index 000000000..75ffbc0ae --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/union3.C @@ -0,0 +1,14 @@ +// { dg-do assemble } +// GROUPS passed unions +union alan { +int a; +char *b; +alan(); +}; + +alan mary; + +alan::alan() +{ + a=0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/visibility1.C b/gcc/testsuite/g++.old-deja/g++.brendan/visibility1.C new file mode 100644 index 000000000..cb4003f0a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/visibility1.C @@ -0,0 +1,16 @@ +// { dg-do assemble } +// GROUPS passed visibility +class foo { +protected: + int i; // { dg-error "" } protected +}; + +class bar : public foo { +public: + friend void baz (foo *); +}; + +void baz (foo *f) +{ + f->i = 1; // error: i is protected// { dg-error "" } .* +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/visibility10.C b/gcc/testsuite/g++.old-deja/g++.brendan/visibility10.C new file mode 100644 index 000000000..89d215799 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/visibility10.C @@ -0,0 +1,14 @@ +// { dg-do assemble } +// GROUPS passed visibility +struct base +{ + protected: + void base_func() {}// { dg-error "" } .*is protected.* +}; + +struct derived : public base +{ + protected: + void derived_func(base *ptr) { ptr->base_func(); }// { dg-error "" } within this context +}; + diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/visibility2.C b/gcc/testsuite/g++.old-deja/g++.brendan/visibility2.C new file mode 100644 index 000000000..74021d58d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/visibility2.C @@ -0,0 +1,10 @@ +// { dg-do assemble } +// GROUPS passed visibility +class X { + void g (int); // { dg-error "" } private +public: + void g (double); +}; + +class Y : public X { void f() { g (1); } }; // { dg-error "" } private + diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/visibility3.C b/gcc/testsuite/g++.old-deja/g++.brendan/visibility3.C new file mode 100644 index 000000000..249ae8116 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/visibility3.C @@ -0,0 +1,45 @@ +// { dg-do assemble } +// GROUPS passed visibility +// Used to say: +// manip.cc:17: member `_f' is a private member of class `B<int>' +// manip.cc:17: member `_a' is a private member of class `B<int>' + +class A {}; + +template <class TP> +class B; + +template <class TP> +inline A & +operator<< (A &o, const B<TP> &m); + +template <class TP> +class B +{ + A &(*_f) (A &, TP); + TP _a; +public: + B (A &(*f) (A &, TP), TP a) : _f (f), _a (a) {} + friend A &operator<< <>(A &o, const B<TP> &m); +}; + +template <class TP> +inline A & +operator<< (A &o, const B<TP> &m) +{ + (*m._f) (o, m._a); + return o; +} + +A &setw (A &, int); +B<int> setw (int n) +{ + return B<int> (setw, n); +} + +A x; + +void f () +{ + x << setw (2); +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/visibility4.C b/gcc/testsuite/g++.old-deja/g++.brendan/visibility4.C new file mode 100644 index 000000000..158c161d3 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/visibility4.C @@ -0,0 +1,14 @@ +// { dg-do assemble } +// GROUPS passed visibility +template <class T> +class Feld { +public: + Feld(const Feld&) {} +}; + +class Polynom : private Feld<double> { + Polynom(); + friend Polynom f(const Polynom&); +}; + +Polynom f(const Polynom& p) { return p; } diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/visibility5.C b/gcc/testsuite/g++.old-deja/g++.brendan/visibility5.C new file mode 100644 index 000000000..f43b2501c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/visibility5.C @@ -0,0 +1,8 @@ +// { dg-do assemble } +// GROUPS passed visibility +template<int K> class B; +template<int K> class A {int n; friend class B<K>;}; +template<int K> class B {public: void method(A<K>) const;}; +template<int K> void B<K>::method(A<K> X) const {X.n=0;} +typedef B<2> B2; + diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/visibility6.C b/gcc/testsuite/g++.old-deja/g++.brendan/visibility6.C new file mode 100644 index 000000000..f9ba954ea --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/visibility6.C @@ -0,0 +1,17 @@ +// { dg-do assemble } +// GROUPS passed visibility +class bottom +{ +public: + int b; // { dg-error "" } private +}; +class middle : private bottom +{ +public: + void foo () { b; } +}; +class top : public middle +{ +public: + void bar () { b; }// { dg-error "" } .* +}; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/visibility7.C b/gcc/testsuite/g++.old-deja/g++.brendan/visibility7.C new file mode 100644 index 000000000..f7bf00c1a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/visibility7.C @@ -0,0 +1,15 @@ +// { dg-do assemble } +// GROUPS passed visibility +class X +{ +public: + void fn ();// { dg-error "" } .* +}; +class Y : private X +{}; + +class Unrelated +{ +public: + void foo () { Y y; y.fn (); }// { dg-error "" } .* +}; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/visibility8.C b/gcc/testsuite/g++.old-deja/g++.brendan/visibility8.C new file mode 100644 index 000000000..00f5347ff --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/visibility8.C @@ -0,0 +1,15 @@ +// { dg-do assemble } +// GROUPS passed visibility +// Make sure private inheritance affects the visibility of +// static members used in an inherited context. +class foo +{ +public: + static int y; // { dg-error "" } private +}; +class foo1 : private foo +{ }; +class foo2 : public foo1 +{ public: + void bar () { y; }// { dg-error "" } .* +}; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/visibility9.C b/gcc/testsuite/g++.old-deja/g++.brendan/visibility9.C new file mode 100644 index 000000000..963bc2baf --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/visibility9.C @@ -0,0 +1,16 @@ +// { dg-do assemble } +// GROUPS passed visibility +class A { +public: + void aMethod(void) {};// { dg-error "" } .* +}; + +class AA : A { }; + +class B { +public: + void thisMethod() { + AA ana; + ana.aMethod();// { dg-error "" } .* + } +}; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/vtables1.C b/gcc/testsuite/g++.old-deja/g++.brendan/vtables1.C new file mode 100644 index 000000000..219bb91f7 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/vtables1.C @@ -0,0 +1,43 @@ +// { dg-do run } +// GROUPS passed virtual-tables +// Check that virtual function tables are generated and used +// even for struct's/classes which have no explicit constructors. + +extern "C" int printf (const char *, ...); + +int base_func_member_1_called = 0; +int derived_func_member_1_called = 0; + +struct base { + virtual void func_member_1 () + { + base_func_member_1_called++; + } +}; + +struct derived : public base { + virtual void func_member_1 () + { + derived_func_member_1_called++; + } + + virtual void func_member_2 () + { + } +}; + +base* bp1; +base* bp2; + +int main () +{ + bp1 = new base; + bp2 = new derived; + + bp1->func_member_1 (); + bp2->func_member_1 (); + + printf ("PASS\n"); + + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/warnings1.C b/gcc/testsuite/g++.old-deja/g++.brendan/warnings1.C new file mode 100644 index 000000000..155910021 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/warnings1.C @@ -0,0 +1,7 @@ +// { dg-do assemble } +// { dg-options "-Wctor-dtor-privacy" } +// GROUPS passed warnings +// there should be a warning about foo only defining private methods +class foo { // { dg-warning "private" } + int bar(); +}; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/warnings10.C b/gcc/testsuite/g++.old-deja/g++.brendan/warnings10.C new file mode 100644 index 000000000..ea1e88882 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/warnings10.C @@ -0,0 +1,10 @@ +// { dg-do assemble } +// GROUPS passed warnings +void foo() +{ + int i; + if (1) { + for (int i = 0; i < 10; i++) + ; + } +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/warnings2.C b/gcc/testsuite/g++.old-deja/g++.brendan/warnings2.C new file mode 100644 index 000000000..665c7a425 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/warnings2.C @@ -0,0 +1,7 @@ +// { dg-do assemble } +// GROUPS passed warnings +class K { +public: + void f() { + }; // there should be no warning about this semicolon +}; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/warnings3.C b/gcc/testsuite/g++.old-deja/g++.brendan/warnings3.C new file mode 100644 index 000000000..07381b9ed --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/warnings3.C @@ -0,0 +1,16 @@ +// { dg-do assemble } +// { dg-options "-O2 -Wall" } +// GROUPS passed warnings +class A { +int i; +public: + void funcA(void) { + funcB(); + } + + // The compiler should not emit a warning about not being + // able to inline this function. + void funcB(void) { + i++; + } +}; diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/warnings4.C b/gcc/testsuite/g++.old-deja/g++.brendan/warnings4.C new file mode 100644 index 000000000..410ca800c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/warnings4.C @@ -0,0 +1,10 @@ +// { dg-do assemble } +// GROUPS passed warnings +int +main () +{ + register int x; + int * foo = &x; // in C++ it's perfectly legal to do this + + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/warnings5.C b/gcc/testsuite/g++.old-deja/g++.brendan/warnings5.C new file mode 100644 index 000000000..e6341fa87 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/warnings5.C @@ -0,0 +1,10 @@ +// { dg-do assemble } +// GROUPS passed warnings +enum TypeKind { ATK, BTK } ; + +struct Type { + enum TypeKind kind : 8; + void setBTK(); +}; + +void Type::setBTK() { kind = BTK; } diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/warnings6.C b/gcc/testsuite/g++.old-deja/g++.brendan/warnings6.C new file mode 100644 index 000000000..5557f1947 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/warnings6.C @@ -0,0 +1,9 @@ +// { dg-do assemble } +// { dg-options "-O2 -Wall -ansi -pedantic" } +// GROUPS passed warnings +// should not emit this warning about func: +// x.C:2: warning: invalid storage class for function `func' +// +template <class T> inline void func(T) +{ +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/warnings7.C b/gcc/testsuite/g++.old-deja/g++.brendan/warnings7.C new file mode 100644 index 000000000..89d6ecaf5 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/warnings7.C @@ -0,0 +1,21 @@ +// { dg-do assemble } +// { dg-options "-O2 -Wall" } +// GROUPS passed warnings +template<class T> +class X { +public: + void kill(unsigned i) + { vec[i].~T(); } + T *vec; +}; + +class Y { }; + +void +x() +{ + X<int> x; + x.kill(0); + X<Y> y; + y.kill(0); +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/warnings8.C b/gcc/testsuite/g++.old-deja/g++.brendan/warnings8.C new file mode 100644 index 000000000..cdb7c62bb --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/warnings8.C @@ -0,0 +1,7 @@ +// { dg-do assemble } +// { dg-options "-Wall" } +// GROUPS passed warnings +bool foo(unsigned char c) +{ + return (c & 17) != 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/warnings9.C b/gcc/testsuite/g++.old-deja/g++.brendan/warnings9.C new file mode 100644 index 000000000..576f431c9 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/warnings9.C @@ -0,0 +1,7 @@ +// { dg-do assemble } +// { dg-options "-Wall" } +// GROUPS passed warnings +inline int foo() +{ + return 3; +} diff --git a/gcc/testsuite/g++.old-deja/g++.bugs/891229_02.C b/gcc/testsuite/g++.old-deja/g++.bugs/891229_02.C new file mode 100644 index 000000000..d91987bdf --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.bugs/891229_02.C @@ -0,0 +1,25 @@ +// { dg-do assemble } +// g++ 1.36.1 bug 891229_02 + +// g++ limits the scope of names which are declared as typedef names within +// another type to that other type. + +// This conflicts with the (global) scope given to such names by cfront 2.0. + +// Cfront 2.0 passes this test. + +// Note 2/15/94: The standard has changed; this limiting of scope is correct +// behavior. See 9.9. --jason + +// keywords: typedef, nested types, scope + +struct foo { + foo (); + typedef void (*function_p) (void); +}; + +function_p fp; // { dg-error "" } no such type in scope + +foo::foo () {} + +int main () { return 0; } diff --git a/gcc/testsuite/g++.old-deja/g++.bugs/891230_01.C b/gcc/testsuite/g++.old-deja/g++.bugs/891230_01.C new file mode 100644 index 000000000..769363d58 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.bugs/891230_01.C @@ -0,0 +1,21 @@ +// { dg-do run } +// g++ 1.36.1 bug 891230_01 + +// g++ gives typedefs which are nested within class declarations a scope +// which is local to the class declaration itself. This causes examples +// like the following to get compile-time errors. + +// Cfront 2.0 passes this test. + +// keywords: typedef, nested types, scope + +struct foo { + + typedef foo* foo_p; + void member (foo_p); +}; + +void foo::member (foo_p p) { // { dg-bogus "" } s +} + +int main () { return 0; } diff --git a/gcc/testsuite/g++.old-deja/g++.bugs/900107_01.C b/gcc/testsuite/g++.old-deja/g++.bugs/900107_01.C new file mode 100644 index 000000000..b486fc664 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.bugs/900107_01.C @@ -0,0 +1,38 @@ +// { dg-do run } +// g++ 1.36.1 bug 900107_01 + +// Unlike GCC and Cfront 2.0, the g++ 1.36.1 compiler gives struct, union, +// and class declarations which are nested within blocks file scope. + +// Cfront 2.0 passes this test. + +// keywords: block scope, file scope, nested types, tagged types + +class c1 { int c1_member1; }; +struct s1 { int s1_member1; }; +union u1 { int u1_member1; }; +enum e1 { e1_val1 }; +typedef int t1; + +void foo () +{ + class c1 { // { dg-bogus "" } + int c1_member1; + } c1_local_object_0; + + struct s1 { // { dg-bogus "" } + int s1_member1; + } s1_local_object_0; + + union u1 { // { dg-bogus "" } + int u1_member1; + } u1_local_object_0; + + enum e1 { // OK using g++ or GCC, but mishandled by Cfront 2.0. + e1_value1 + } e1_local_object_0; + + typedef int t1; // OK +} + +int main () { return 0; } diff --git a/gcc/testsuite/g++.old-deja/g++.bugs/900119_01.C b/gcc/testsuite/g++.old-deja/g++.bugs/900119_01.C new file mode 100644 index 000000000..ace4e4b7a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.bugs/900119_01.C @@ -0,0 +1,49 @@ +// { dg-do assemble } +// g++ 1.36.1 bug 900119_01 + +// g++ allows initializers to be included in the declaration of members +// of classes, structs, unions (even when -pedantic is used). + +// This is not allowed by the C++ 2.0 Reference Manual or by Cfront 2.0. + +// keywords: member declaration, member initialization + +// { dg-prune-output "non-static data member initializers" } + +int global_int; + +class class0 { +public: + int class0_member_0 = 99; /* { dg-error "" } */ + static int class0_member_1 = 99; /* { dg-error "" } */ + int &class0_member_2 = global_int; /* { dg-error "" } */ + + class0 () : class0_member_2 (global_int) { } /* { dg-error "" } */ +}; + + +struct struct0 { + int struct0_member_0 = 99; /* { dg-error "" } */ + static int struct0_member_1 = 99; /* { dg-error "" } */ + int &struct0_member_2 = global_int; /* { dg-error "" } */ + + struct0 () : struct0_member_2 (global_int) { } /* { dg-error "" } */ +}; + +// g++ does not allow unions to have more than one member with an initializer + +union union0 { + int union0_member_0 = 99; /* { dg-error "" } */ +}; + +union union1 { + //static int union1_member_0 = 99; /* definitely illegal (9.5) */ +}; + +union union2 { + int &union2_member_0 = global_int; /* { dg-error "" } */ + + union2 () : union2_member_0 (global_int) { } /* { dg-error "" } */ +}; + +int main () { return 0; } diff --git a/gcc/testsuite/g++.old-deja/g++.bugs/900121_01.C b/gcc/testsuite/g++.old-deja/g++.bugs/900121_01.C new file mode 100644 index 000000000..325916358 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.bugs/900121_01.C @@ -0,0 +1,17 @@ +// { dg-do assemble } +// g++ 1.36.1 bug 900121_01 + +// The following file causes g++ 1.36.1 (and 1.36.2) to abort. + +// Cfront 2.0 passes this test. + +// keywords: abort, incomplete types, reference types, formal parameters + +struct s0; // { dg-error "" } forward declaration + +void function (struct s0 &arg1, struct s0 &arg2) +{ + arg1 = arg2; // { dg-error "" } causes abort +} + +int main () { return 0; } diff --git a/gcc/testsuite/g++.old-deja/g++.bugs/900121_02.C b/gcc/testsuite/g++.old-deja/g++.bugs/900121_02.C new file mode 100644 index 000000000..15a6d27f3 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.bugs/900121_02.C @@ -0,0 +1,53 @@ +// { dg-do assemble } +// { dg-prune-output "note" } +// { dg-prune-output "deleted" } + +// g++ 1.36.1 bug 900121_02 + +// Assignment of structs is defined as memberwise assignment, +// however g++ (1.36.2) and Cfront 2.0 differ on the definition +// of assignment for unions. + +// (NOTE: Stroustrup now says that assignment of unions which contain either +// members or sub-members (base classes are not allowed for unions) which +// have non-default assignment operators defined for them will be illegal +// in future.) + +// g++ (1.36.2) on the other hand, accepts this program without errors. + +// keywords: unions, operator=, inheritance, members + +struct s0 { + + int i; + + void operator= (s0 & arg) + { + this->i = arg.i; + } +}; + +struct s1 { + + double d; + + void operator= (s1 & arg) + { + this->d = arg.d; + } +}; + +union u0 { + s0 u0_member_0; // { dg-error "" } + s1 u0_member_1; // { dg-error "" } +}; + +void function () +{ + u0 u0_object_0; + u0 u0_object_1; + + u0_object_0 = u0_object_1; +} + +int main () { return 0; } diff --git a/gcc/testsuite/g++.old-deja/g++.bugs/900121_05.C b/gcc/testsuite/g++.old-deja/g++.bugs/900121_05.C new file mode 100644 index 000000000..62db5b343 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.bugs/900121_05.C @@ -0,0 +1,31 @@ +// { dg-do assemble } +// g++ 1.36.1 bug 900121_05 + +// g++ allows unions to have base types (i.e. to be "derived") and it allows +// other types to have unions as base types. Both cases are illegal. + +// g++ curently does not detect such errors. + +// Cfront 2.0 passes this test. + +// keywords: unions, inheritance + +struct s0 { + int s0_member; +}; + +union u0 : public s0 { /* { dg-error "" } union has base class */ + int u0_member_0; + int u0_member_1; +}; + +union u1 { + int u1_member_0; + int u1_member_1; +}; + +struct s1 : public u1 { /* { dg-error "base type" } */ + int s1_member_0; +}; + +int main () { return 0; } diff --git a/gcc/testsuite/g++.old-deja/g++.bugs/900127_01.C b/gcc/testsuite/g++.old-deja/g++.bugs/900127_01.C new file mode 100644 index 000000000..a066d5848 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.bugs/900127_01.C @@ -0,0 +1,27 @@ +// { dg-do assemble } +// g++ 1.36.1 bug 900127_01 + +// g++ often fails to detect (and issue errors for) ambiguous overload +// situations. In such cases, one of the possibilities is chosen +// (apparently arbitrarily). Errors should be issued instead. + +// Cfront 2.0 passes this test. + +// keywords: function overloading, ambiguity + +void foo (int); +int foo (void); + +typedef int (*f_ptr_t1) (void); +typedef void (*f_ptr_t2) (int); + +void bar (f_ptr_t1); // { dg-message "note" } +void bar (f_ptr_t2); // { dg-message "note" } + +void function () +{ + bar (foo); // { dg-error "ambiguous" } + // { dg-message "candidate" "candidate note" { target *-*-* } 23 } +} + +int main () { return 0; } diff --git a/gcc/testsuite/g++.old-deja/g++.bugs/900127_02.C b/gcc/testsuite/g++.old-deja/g++.bugs/900127_02.C new file mode 100644 index 000000000..0ae23881f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.bugs/900127_02.C @@ -0,0 +1,47 @@ +// { dg-do assemble } +// g++ 1.36.1 bug 900127_02 + +// g++ (mostly) keeps separate name spaces for the declarations of data +// objects and functions. + +// This means that a single name may be declared as both a data object and +// a function within a given scope. + +// This fact allows programmers to write code which is not portable to the +// Cfront translator (which keeps a single namespace for these entities). + +// This can also lead to ambiguity when the & (address-of) operator is used. + +// Cfront 2.0 passes this test. + +// keywords: name spaces, overloading + +int global0; // { dg-error "" } +int global0 (); // { dg-error "" } + +int global1 (); // { dg-error "" } xref for below +int global1; // { dg-error "" } caught + +struct struct_0 { + int class_local (); // { dg-error "" } + int class_local; // { dg-error "" } +}; + +struct struct_1 { + int class_local; // { dg-error "" } + int class_local (); // { dg-error "" } +}; + +void function_0 () +{ + int function_0_local; // { dg-error "" } + extern int function_0_local (); // { dg-error "" } +} + +void function_1 () +{ + int function_1_local (); // { dg-error "" } + extern int function_1_local; // { dg-error "" } +} + +int main () { return 0; } diff --git a/gcc/testsuite/g++.old-deja/g++.bugs/900205_02.C b/gcc/testsuite/g++.old-deja/g++.bugs/900205_02.C new file mode 100644 index 000000000..6275d6aab --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.bugs/900205_02.C @@ -0,0 +1,29 @@ +// { dg-do assemble } +// g++ 1.36.1 bug 900205_02 + +// g++ allows constructors to be defined which do not include +// initializations for reference members of their associated classes. + +// Cfront 2.0 does not allow this. + +// keywords: reference members, constructors, member initialization + +int i; + +class c0 { + int &int_ref; +public: + c0 () /* : int_ref(i) */ { // { dg-error "" } reference needs initializer + } +}; + +class c1 { + int &int_ref; +public: + c1 (); +}; + +c1::c1() /* : int_ref(i) */ { // { dg-error "" } reference needs initializer +} + +int main () { return 0; } diff --git a/gcc/testsuite/g++.old-deja/g++.bugs/900205_03.C b/gcc/testsuite/g++.old-deja/g++.bugs/900205_03.C new file mode 100644 index 000000000..a46052654 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.bugs/900205_03.C @@ -0,0 +1,49 @@ +// { dg-do assemble } +// { dg-options "-Wreturn-type -pedantic-errors" } +// g++ 1.36.1 bug 900205_03 + +// Section 6.6.3 of the cfront 2.0 Reference Manual says "A return statement +// without an expression can be used only in functions that do not return +// a value, that is, a function with the return value type void..." + +// Also in 6.6.3: "Flowing off the end of a function is equivalent to a +// return with no value; this is illegal in a value returning function." + +// In contrast to the manual, g++ does not generate ERRORs for cases of +// "flowing off the end" of non-void functions. + +// keywords: return statements, return type, void return, implicit return + + +struct struct00 { }; + +int global_function_0 () { +} // { dg-warning "no return" } + +struct00 global_function_1 () { +} // { dg-warning "no return" } + +struct struct0 { + + int struct0_member_function_0 () { + } // { dg-warning "no return" } + + struct0 struct0_member_function_1 () { + } // { dg-warning "no return" } +}; + +struct struct1 { + + int struct1_member_function_0 (); + + struct1 struct1_member_function_1 (); + +}; + +int struct1_member_function_0 () { +} // { dg-warning "no return" } + +struct1 struct1::struct1_member_function_1 () { +} // { dg-warning "no return" } + +int main () { return 0; } diff --git a/gcc/testsuite/g++.old-deja/g++.bugs/900205_04.C b/gcc/testsuite/g++.old-deja/g++.bugs/900205_04.C new file mode 100644 index 000000000..3d8625e5c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.bugs/900205_04.C @@ -0,0 +1,32 @@ +// { dg-do assemble } +// g++ 1.36.1 bug 900205_04 + +// g++ allows a class for which an implicit default X::X() constructor must +// be created (implicitly by the compiler) to be derived from another class +// which does not have its own default X::X() constructor. This is illegal. + +// Cfront 2.0 passes this test. + +// keywords: default constructor, inheritance + +// In ISO C++ 1998, such a derived class is not ill-formed, but if the +// implicitly-declared constructor is used, then it is implicitly +// defined and found to be ill-formed. + +struct struct0 { // { dg-message "note" } + int data_member; + + struct0 (int, void *); // suppresses implicit default constructor +}; + +struct0::struct0 (int, void *) // { dg-message "note" } +{ +} + +struct struct0_derived_struct_0 : public struct0 { // { dg-error "no matching|deleted" } + // { dg-message "candidate" "candidate note" { target *-*-* } 26 } +}; + +struct0_derived_struct_0 object; // { dg-message "synthesized|deleted" } + +int main () { return 0; } diff --git a/gcc/testsuite/g++.old-deja/g++.bugs/900207_03.C b/gcc/testsuite/g++.old-deja/g++.bugs/900207_03.C new file mode 100644 index 000000000..8dd5c9f8c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.bugs/900207_03.C @@ -0,0 +1,50 @@ +// { dg-do run } +// g++ 1.36.1 bug 900207_03 + +// g++ fails to allow objects of class or struct types to be initialized +// using "constructor syntax" in cases where an implicitly generated copy +// constructor would be invoked for the initialization, and where there is +// no explicitly specified constructor associated with the type of the +// object being initialized. + +// Note that the type of the error changes depending upon whether or not the +// type being initialized has any virtual functions associated with it. + +// Cfront 2.0 passes this test. + +// keywords: implicit copy constructor, initialization + + +// Check construction for a type without virtual function members. + +struct struct0 { + int data_member; +}; + +struct0 struct0_gbl_object0; +struct0 struct0_gbl_object1 (struct0_gbl_object0); // { dg-bogus "" } + +void struct0_test () +{ + struct0 struct0_lcl_object1 (struct0_gbl_object0); // { dg-bogus "" } +} + +// Check construction for a type with virtual function members. + +struct struct1 { + int data_member; + + virtual void function_member (); +}; + +void struct1::function_member () { } + +struct1 struct1_gbl_object0; +struct1 struct1_gbl_object1 (struct1_gbl_object0); // { dg-bogus "" } + +void struct1_test () +{ + struct1 struct1_lcl_object1 (struct1_gbl_object0); // { dg-bogus "" } +} + +int main () { return 0; } diff --git a/gcc/testsuite/g++.old-deja/g++.bugs/900208_02.C b/gcc/testsuite/g++.old-deja/g++.bugs/900208_02.C new file mode 100644 index 000000000..8e4fdbf27 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.bugs/900208_02.C @@ -0,0 +1,18 @@ +// { dg-do run } +// g++ 1.36.1 bug 900208_02 + +// g++ does not allow a static member of a class/struct/union to be +// declared as an array without an explicit upper bound. + +// Cfront 2.0 passes this test. + +// keywords: static data members, arrays, dimension, array bound + +class class0 { +public: + static int class0_data_member_0[]; // { dg-bogus "" } +}; + +int class0::class0_data_member_0[3] = { 1, 2, 3 }; // { dg-bogus "" } + +int main () { return 0; } diff --git a/gcc/testsuite/g++.old-deja/g++.bugs/900208_03.C b/gcc/testsuite/g++.old-deja/g++.bugs/900208_03.C new file mode 100644 index 000000000..7b7c247d1 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.bugs/900208_03.C @@ -0,0 +1,19 @@ +// { dg-do assemble } +// g++ 1.36.1 bug 900208_03 + +// The Cfront 2.0 reference manual (5.3.3) says "This type must be an +// object type; functions cannot be allocated this way...". + +// g++ fails to detect (at compile time) cases where an attempt is made to +// allocate a function using new. + +// keywords: operator new, function types + +typedef void (func_type) (); + +void global_function_0 () +{ + new func_type; // { dg-error "" } missed by both cfront 2.0 and g++ 1.36.1 +} + +int main () { return 0; } diff --git a/gcc/testsuite/g++.old-deja/g++.bugs/900208_04.C b/gcc/testsuite/g++.old-deja/g++.bugs/900208_04.C new file mode 100644 index 000000000..d01268dfa --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.bugs/900208_04.C @@ -0,0 +1,21 @@ +// { dg-do assemble } +// g++ 1.36.1 bug 900208_04 + +// The Cfront 2.0 reference manual (5.3.3) says "This type must be an +// object type; functions cannot be allocated this way...". + +// g++ fails to detect (at compile time) cases where an attempt is made to +// deallocate a function using delete. + +// Cfront 2.0 passes this test. + +// keywords: operator delete, function types + +typedef void (func_type) (); + +void global_function_1 (func_type *p) +{ + delete p; // { dg-error "" } caught by Cfront 2.0 but not by g++ 1.36.1 +} + +int main () { return 0; } diff --git a/gcc/testsuite/g++.old-deja/g++.bugs/900209_01.C b/gcc/testsuite/g++.old-deja/g++.bugs/900209_01.C new file mode 100644 index 000000000..6d91010ec --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.bugs/900209_01.C @@ -0,0 +1,21 @@ +// { dg-do assemble } +// g++ 1.36.1 bug 900209_01 + +// g++ implicitly casts values whose types are "void*" to other pointer +// types (just as the language rules for C permit). Such implicit +// conversions are not allowed by the Cfront 2.0 Reference Manual +// however. + +// Cfront 2.0 passes this test. + +// keywords: void pointers, type conversions, pointer type conversions + +void * void_pointer_object; +char * char_pointer_object; + +void global_function_0 () +{ + char_pointer_object = void_pointer_object; // { dg-error "" } +} + +int main () { return 0; } diff --git a/gcc/testsuite/g++.old-deja/g++.bugs/900210_01.C b/gcc/testsuite/g++.old-deja/g++.bugs/900210_01.C new file mode 100644 index 000000000..5bbac2cba --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.bugs/900210_01.C @@ -0,0 +1,113 @@ +// { dg-do assemble } +// g++ 1.36.1 bug 900210_01 + +// g++ allows pointer type values to be assigned to variables of integal +// types. According to the C++ Reference Manual, this is illegal. + +// Cfront 2.0 passes this test. + +// keywords: pointer types, integral types, implicit type conversions + +int i; +long l; +short s; +char c; +float f; +double d; +long double ld; +enum E {enum_value_0} e; + +signed int si; +signed long sl; +signed short ss; +signed char sc; + +unsigned int ui; +unsigned long ul; +unsigned short us; +unsigned char uc; + +void* vp; +char* cp; +int* ip; +enum E2 {enum_value_1} * ep; +struct S { int member; } * sp; +void (*fp) (void); + +void global_function () +{ + i = vp; /* { dg-error "" } */ + i = cp; /* { dg-error "" } */ + i = ip; /* { dg-error "" } */ + i = ep; /* { dg-error "" } */ + i = sp; /* { dg-error "" } */ + i = fp; /* { dg-error "" } */ + l = vp; /* { dg-error "" } */ + l = cp; /* { dg-error "" } */ + l = ip; /* { dg-error "" } */ + l = ep; /* { dg-error "" } */ + l = sp; /* { dg-error "" } */ + l = fp; /* { dg-error "" } */ + s = vp; /* { dg-error "" } */ + s = cp; /* { dg-error "" } */ + s = ip; /* { dg-error "" } */ + s = ep; /* { dg-error "" } */ + s = sp; /* { dg-error "" } */ + s = fp; /* { dg-error "" } */ + c = vp; /* { dg-error "" } */ + c = cp; /* { dg-error "" } */ + c = ip; /* { dg-error "" } */ + c = ep; /* { dg-error "" } */ + c = sp; /* { dg-error "" } */ + c = fp; /* { dg-error "" } */ + si = vp; /* { dg-error "" } */ + si = cp; /* { dg-error "" } */ + si = ip; /* { dg-error "" } */ + si = ep; /* { dg-error "" } */ + si = sp; /* { dg-error "" } */ + si = fp; /* { dg-error "" } */ + sl = vp; /* { dg-error "" } */ + sl = cp; /* { dg-error "" } */ + sl = ip; /* { dg-error "" } */ + sl = ep; /* { dg-error "" } */ + sl = sp; /* { dg-error "" } */ + sl = fp; /* { dg-error "" } */ + ss = vp; /* { dg-error "" } */ + ss = cp; /* { dg-error "" } */ + ss = ip; /* { dg-error "" } */ + ss = ep; /* { dg-error "" } */ + ss = sp; /* { dg-error "" } */ + ss = fp; /* { dg-error "" } */ + sc = vp; /* { dg-error "" } */ + sc = cp; /* { dg-error "" } */ + sc = ip; /* { dg-error "" } */ + sc = ep; /* { dg-error "" } */ + sc = sp; /* { dg-error "" } */ + sc = fp; /* { dg-error "" } */ + ui = vp; /* { dg-error "" } */ + ui = cp; /* { dg-error "" } */ + ui = ip; /* { dg-error "" } */ + ui = ep; /* { dg-error "" } */ + ui = sp; /* { dg-error "" } */ + ui = fp; /* { dg-error "" } */ + ul = vp; /* { dg-error "" } */ + ul = cp; /* { dg-error "" } */ + ul = ip; /* { dg-error "" } */ + ul = ep; /* { dg-error "" } */ + ul = sp; /* { dg-error "" } */ + ul = fp; /* { dg-error "" } */ + us = vp; /* { dg-error "" } */ + us = cp; /* { dg-error "" } */ + us = ip; /* { dg-error "" } */ + us = ep; /* { dg-error "" } */ + us = sp; /* { dg-error "" } */ + us = fp; /* { dg-error "" } */ + uc = vp; /* { dg-error "" } */ + uc = cp; /* { dg-error "" } */ + uc = ip; /* { dg-error "" } */ + uc = ep; /* { dg-error "" } */ + uc = sp; /* { dg-error "" } */ + uc = fp; /* { dg-error "" } */ +} + +int main () { return 0; } diff --git a/gcc/testsuite/g++.old-deja/g++.bugs/900210_02.C b/gcc/testsuite/g++.old-deja/g++.bugs/900210_02.C new file mode 100644 index 000000000..b2d38cdbe --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.bugs/900210_02.C @@ -0,0 +1,114 @@ +// { dg-do assemble } +// { dg-options "" } +// g++ 1.36.1 bug 900210_02 + +// g++ allows integral type values to be assigned to variables of pointer +// types. According to the C++ Reference Manual, this is illegal. + +// Cfront 2.0 passes this test. + +// keywords: integral types, pointer types, implicit type conversions +// Special Options: -ansi -pedantic-errors +int i; +long l; +short s; +char c; +float f; +double d; +long double ld; +enum E {enum_value_0} e; + +signed int si; +signed long sl; +signed short ss; +signed char sc; + +unsigned int ui; +unsigned long ul; +unsigned short us; +unsigned char uc; + +void* vp; +char* cp; +int* ip; +enum E2 {enum_value_1} * ep; +struct S { int member; } * sp; +void (*fp) (void); + +void global_function () +{ + vp = i; /* { dg-error "" } */ + vp = l; /* { dg-error "" } */ + vp = s; /* { dg-error "" } */ + vp = c; /* { dg-error "" } */ + vp = si; /* { dg-error "" } */ + vp = sl; /* { dg-error "" } */ + vp = ss; /* { dg-error "" } */ + vp = sc; /* { dg-error "" } */ + vp = ui; /* { dg-error "" } */ + vp = ul; /* { dg-error "" } */ + vp = us; /* { dg-error "" } */ + vp = uc; /* { dg-error "" } */ + cp = i; /* { dg-error "" } */ + cp = l; /* { dg-error "" } */ + cp = s; /* { dg-error "" } */ + cp = c; /* { dg-error "" } */ + cp = si; /* { dg-error "" } */ + cp = sl; /* { dg-error "" } */ + cp = ss; /* { dg-error "" } */ + cp = sc; /* { dg-error "" } */ + cp = ui; /* { dg-error "" } */ + cp = ul; /* { dg-error "" } */ + cp = us; /* { dg-error "" } */ + cp = uc; /* { dg-error "" } */ + ip = i; /* { dg-error "" } */ + ip = l; /* { dg-error "" } */ + ip = s; /* { dg-error "" } */ + ip = c; /* { dg-error "" } */ + ip = si; /* { dg-error "" } */ + ip = sl; /* { dg-error "" } */ + ip = ss; /* { dg-error "" } */ + ip = sc; /* { dg-error "" } */ + ip = ui; /* { dg-error "" } */ + ip = ul; /* { dg-error "" } */ + ip = us; /* { dg-error "" } */ + ip = uc; /* { dg-error "" } */ + ep = i; /* { dg-error "" } */ + ep = l; /* { dg-error "" } */ + ep = s; /* { dg-error "" } */ + ep = c; /* { dg-error "" } */ + ep = si; /* { dg-error "" } */ + ep = sl; /* { dg-error "" } */ + ep = ss; /* { dg-error "" } */ + ep = sc; /* { dg-error "" } */ + ep = ui; /* { dg-error "" } */ + ep = ul; /* { dg-error "" } */ + ep = us; /* { dg-error "" } */ + ep = uc; /* { dg-error "" } */ + sp = i; /* { dg-error "" } */ + sp = l; /* { dg-error "" } */ + sp = s; /* { dg-error "" } */ + sp = c; /* { dg-error "" } */ + sp = si; /* { dg-error "" } */ + sp = sl; /* { dg-error "" } */ + sp = ss; /* { dg-error "" } */ + sp = sc; /* { dg-error "" } */ + sp = ui; /* { dg-error "" } */ + sp = ul; /* { dg-error "" } */ + sp = us; /* { dg-error "" } */ + sp = uc; /* { dg-error "" } */ + fp = i; /* { dg-error "" } */ + fp = l; /* { dg-error "" } */ + fp = s; /* { dg-error "" } */ + fp = c; /* { dg-error "" } */ + fp = si; /* { dg-error "" } */ + fp = sl; /* { dg-error "" } */ + fp = ss; /* { dg-error "" } */ + fp = sc; /* { dg-error "" } */ + fp = ui; /* { dg-error "" } */ + fp = ul; /* { dg-error "" } */ + fp = us; /* { dg-error "" } */ + fp = uc; /* { dg-error "" } */ +} + +int main () { return 0; } diff --git a/gcc/testsuite/g++.old-deja/g++.bugs/900210_03.C b/gcc/testsuite/g++.old-deja/g++.bugs/900210_03.C new file mode 100644 index 000000000..5f9054275 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.bugs/900210_03.C @@ -0,0 +1,27 @@ +// { dg-do assemble } +// g++ 1.36.1 bug 900210_03 + +// g++ allows void* type values to be assigned to variables of other +// pointer types. According to the C++ Reference Manual, this is illegal. + +// Cfront 2.0 passes this test. + +// keywords: void pointers, pointer type conversions, implicit type conversions + +void* vp; +char* cp; +int* ip; +enum E {enum_value_1} * ep; +struct S { int member; } * sp; +void (*fp) (void); + +void global_function () +{ + cp = vp; /* { dg-error "" } */ + ip = vp; /* { dg-error "" } */ + ep = vp; /* { dg-error "" } */ + sp = vp; /* { dg-error "" } */ + fp = vp; /* { dg-error "" } */ +} + +int main () { return 0; } diff --git a/gcc/testsuite/g++.old-deja/g++.bugs/900210_05.C b/gcc/testsuite/g++.old-deja/g++.bugs/900210_05.C new file mode 100644 index 000000000..a14c554bb --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.bugs/900210_05.C @@ -0,0 +1,38 @@ +// { dg-do assemble } +// g++ 1.36.1 bug 900210_05 + +// Section 18.3 of the 2.0 Reference Manual says "An implementation +// providing { anachronistic features } should also provide a way for +// the user to ensure that they do not occur in a source file." + +// The *only* proper way to "ensure" an absence of anachronstic features +// is for C++ language processors to generate errors (rather than just +// warnings) when such features are used. These errors could perhaps be +// triggered by some set of command line options, or by the absence of +// certain command line options. (For g++, the -pedantic and -traditional +// options come to mind.) + +// The use of errors rather than warnings is important because errors +// usually result in nonzero exit status codes for language processors +// and these nonzero exit stati can be automatically checked during +// normal execution of a Makefile. + +// cfront 2.0 provides the +p option which causes errors to be generated for +// all cases of anachronistic usage. + +// g++ generates neither errors nor warnings for such usage, even when the +// -ansi and -pedantic options are used. + +// Cfront 2.0 passes this test. + +// keywords: anachronism, enum types, integral types, implicit type conversions + +enum enum0 { enum_value_0 } enum0_object; +int int0_object; + +void function () +{ + enum0_object = int0_object; /* { dg-error "" } */ +} + +int main () { return 0; } diff --git a/gcc/testsuite/g++.old-deja/g++.bugs/900210_06.C b/gcc/testsuite/g++.old-deja/g++.bugs/900210_06.C new file mode 100644 index 000000000..0475a82c9 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.bugs/900210_06.C @@ -0,0 +1,26 @@ +// { dg-do assemble } +// g++ 1.36.1 bug 900210_06 + +// g++ allows values of pointer-to-const types to be assigned to variables +// of pointer-to-non-const types. + +// Cfront 2.0 disallows such assignments. + +// g++ also allows values of pointer-to-volatile types to be assigned to +// variables of pointer-to-non-volatile types. + +// Cfront 2.0 *would* disallow this (if it only supported "volatile"). + +// keywords: pointer types, implicit type conversions + +const char *ccp; +volatile char *vcp; +char *cp; + +void function () +{ + cp = ccp; /* { dg-error "" } */ + cp = vcp; /* { dg-error "" } */ +} + +int main () { return 0; } diff --git a/gcc/testsuite/g++.old-deja/g++.bugs/900210_07.C b/gcc/testsuite/g++.old-deja/g++.bugs/900210_07.C new file mode 100644 index 000000000..3a2aae961 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.bugs/900210_07.C @@ -0,0 +1,21 @@ +// { dg-do assemble } +// { dg-options "" } +// g++ 1.36.1 bug 900210_07 + +// g++ allows values of pointer-to-signed types to be assigned to variables +// of pointer-to-unsigned types, and vise versa. + +// Cfront 2.0 passes this test. + +// keyowrds: pointer types, implicit type conversions +// Special Options: -ansi -pedantic-errors +signed int *sip; +unsigned int *uip; + +void function () +{ + sip = uip; // { dg-error "" } + uip = sip; // { dg-error "" } +} + +int main () { return 0; } diff --git a/gcc/testsuite/g++.old-deja/g++.bugs/900210_08.C b/gcc/testsuite/g++.old-deja/g++.bugs/900210_08.C new file mode 100644 index 000000000..163757b0c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.bugs/900210_08.C @@ -0,0 +1,19 @@ +// { dg-do assemble } +// g++ 1.36.1 bug 900210_08 + +// g++ allows pointer-to-const values to be implicitly converted to +// void* values. This causes a silent loss of the const qualifier. + +// Cfront 2.0 passes this test. + +// keywords: pointer types, implicit type conversions + +const char *ccp; +void *vp; + +void function () +{ + vp = ccp; /* { dg-error "" } */ +} + +int main () { return 0; } diff --git a/gcc/testsuite/g++.old-deja/g++.bugs/900210_09.C b/gcc/testsuite/g++.old-deja/g++.bugs/900210_09.C new file mode 100644 index 000000000..aabe3d5cc --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.bugs/900210_09.C @@ -0,0 +1,33 @@ +// { dg-do assemble } +// g++ 1.36.1 bug 900210_09 + +// g++ allows pointer to members (both data members and function members) +// to be implicitly converted to void*. + +// Section 4.8 of the Cfront 2.0 Reference Manual disallows such implicit +// conversions. + +// Cfront 2.0 passes this test. + +// keywords: member pointers, void pointers, implicit type conversions + +class class0 { +public: + int class0_data_member_0; + void class0_function_member_0 (); +}; + +int class0::*class0_data_member_pointer; +int (class0::*class0_function_member_pointer) (); + +void *vp; + +void global_function_0 () +{ + vp = class0_data_member_pointer; // { dg-error "" } + vp = class0_function_member_pointer; // { dg-error "" } +} + +int main () { return 0; } + + diff --git a/gcc/testsuite/g++.old-deja/g++.bugs/900210_10.C b/gcc/testsuite/g++.old-deja/g++.bugs/900210_10.C new file mode 100644 index 000000000..b1b106727 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.bugs/900210_10.C @@ -0,0 +1,15 @@ +// { dg-do assemble } +// g++ 1.36.1 bug 900210_10 + +// g++ allows operator[] to be declared as a static member function. +// This is illegal. + +// Cfront 2.0 passes this test. + +// keywords: operator[], static function members + +struct struct0 { + static int operator[] (); /* { dg-error "" } */ +}; + +int main () { return 0; } diff --git a/gcc/testsuite/g++.old-deja/g++.bugs/900211_01.C b/gcc/testsuite/g++.old-deja/g++.bugs/900211_01.C new file mode 100644 index 000000000..3312d3fca --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.bugs/900211_01.C @@ -0,0 +1,16 @@ +// { dg-do assemble } +// g++ 1.36.1 bug 900211_01 + +// g++ issues only warnings for calls to previously undeclared functions, +// however such calls are actually errors. + +// Cfront 2.0 passes this test. + +// keywords: undeclared, functions + +void global_function_0 () +{ + global_function_1 (); /* { dg-error "" } */ +} + +int main () { return 0; } diff --git a/gcc/testsuite/g++.old-deja/g++.bugs/900211_02.C b/gcc/testsuite/g++.old-deja/g++.bugs/900211_02.C new file mode 100644 index 000000000..b9f2def86 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.bugs/900211_02.C @@ -0,0 +1,25 @@ +// { dg-do assemble } +// g++ 1.36.1 bug 900211_02 + +// g++ allows you to explicitly specify the return type for a type conversion +// operator. + +// The Cfront 2.0 Reference Manual (12.3.2) says that this in not allowed. + +// Cfront 2.0 passes this test. + +// keywords: type conversion operators, return type + +struct struct0 { int member_0; }; + +struct0 struct0_object_0; + +struct struct1 { + struct0 operator struct0 (); /* { dg-error "" } */ +}; + +struct0 struct1::operator struct0 () { // { dg-error "" } + return struct0_object_0; +} + +int main () { return 0; } diff --git a/gcc/testsuite/g++.old-deja/g++.bugs/900211_03.C b/gcc/testsuite/g++.old-deja/g++.bugs/900211_03.C new file mode 100644 index 000000000..b6144000f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.bugs/900211_03.C @@ -0,0 +1,15 @@ +// { dg-do assemble } +// g++ 1.36.1 bug 900211_03 + +// The following erroneous code causes g++ to segfault. + +// Cfront 2.0 passes this test. + +// keywords: segfault, operator new, arrays, undeclared, array bound + +void function () +{ + char* new_base = new char[x]; // { dg-error "" } +} + +int main () { return 0; } diff --git a/gcc/testsuite/g++.old-deja/g++.bugs/900211_04.C b/gcc/testsuite/g++.old-deja/g++.bugs/900211_04.C new file mode 100644 index 000000000..504360610 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.bugs/900211_04.C @@ -0,0 +1,28 @@ +// { dg-do assemble } +// g++ 1.36.1 bug 900211_04 + +// g++ fails to flag as errors attempts to compare pointer values against +// (nonzero) integer values; + +// Since implicit conversions of pointer to integers (or vise versa) are +// illegal, these comparisons are also illegal. + +// Cfront 2.0 passes this test. + +// keywords: comparison operators, pointer types, integral types + +int result; +int i; +char *p; + +void function () +{ + result = i == p; /* { dg-error "" } caught by g++ */ + result = i != p; /* { dg-error "" } caught by g++ */ + result = i > p; /* { dg-error "" } missed */ + result = i < p; /* { dg-error "" } missed */ + result = i >= p; /* { dg-error "" } missed */ + result = i <= p; /* { dg-error "" } missed */ +} + +int main () { return 0; } diff --git a/gcc/testsuite/g++.old-deja/g++.bugs/900212_01.C b/gcc/testsuite/g++.old-deja/g++.bugs/900212_01.C new file mode 100644 index 000000000..8c3349f94 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.bugs/900212_01.C @@ -0,0 +1,39 @@ +// { dg-do assemble } +// g++ 1.36.1 bug 900212_01 + +// g++ fails to flag as errors all attempts to add or subtract integer values +// from pointers-to-member values. + +// Some cases are detected however. + +// Cfront 2.0 passes this test. + +// keywords: pointer arithmetic, member pointers + +struct struct0 { +}; + +int struct0::*p0; +int struct0::*p1; + +int (struct0::*fp0) (); +int (struct0::*fp1) (); + +void global_function_0 () +{ + p0 = p1 + 3; // { dg-error "" } + p0 = p1 - 3; // { dg-error "" } + p1++; /* { dg-error "" } caught by g++ */ + ++p1; /* { dg-error "" } caught by g++ */ + p1--; /* { dg-error "" } caught by g++ */ + --p1; /* { dg-error "" } caught by g++ */ + + fp0 = fp1 + 3; // { dg-error "" } + fp0 = fp1 - 3; // { dg-error "" } + fp1++; /* { dg-error "" } */ + ++fp1; /* { dg-error "" } */ + fp1--; /* { dg-error "" } */ + --fp1; /* { dg-error "" } */ +} + +int main () { return 0; } diff --git a/gcc/testsuite/g++.old-deja/g++.bugs/900212_02.C b/gcc/testsuite/g++.old-deja/g++.bugs/900212_02.C new file mode 100644 index 000000000..dbcf96c06 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.bugs/900212_02.C @@ -0,0 +1,28 @@ +// { dg-do assemble } +// g++ 1.36.1 bug 900212_02 + +// g++ fails to flag as errors attempts to take the difference of two values +// of some compatible pointer-to-member type. + +// Cfront 2.0 passes this test. + +// keywords: pointer arithmetic, subtraction, member pointers + +struct struct0 { +}; + +int struct0::*p0; +int struct0::*p1; + +int (struct0::*fp0) (); +int (struct0::*fp1) (); + +int result; + +void global_function_0 () +{ + result = (p0 - p1); // { dg-error "" } + result = (fp0 - fp1); // { dg-error "" } +} + +int main () { return 0; } diff --git a/gcc/testsuite/g++.old-deja/g++.bugs/900212_03.C b/gcc/testsuite/g++.old-deja/g++.bugs/900212_03.C new file mode 100644 index 000000000..d930e65ad --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.bugs/900212_03.C @@ -0,0 +1,34 @@ +// { dg-do run } +// g++ 1.36.1 bug 900212_03 + +// g++ segfaults on any attempt to use the ->* operator. + +// Cfront 2.0 passes this test. + +// keywords: member pointers, operator->* + +struct struct0 { + int data_member; + void function_member (); +}; + +void struct0::function_member () +{ +} + +int i; + +int struct0::*dmp; +void (struct0::*fmp) (); + +struct0 *ptr; + +void global_function_0 () +{ + i = ptr->*dmp; // causes segfault + (ptr->*fmp) (); // causes segfault + // i = ptr->*(&struct0::data_member); // too complicated for cfront + // (ptr->*(&struct0::function_member)) (); // too complicated for cfront +} + +int main () { return 0; } diff --git a/gcc/testsuite/g++.old-deja/g++.bugs/900213_01.C b/gcc/testsuite/g++.old-deja/g++.bugs/900213_01.C new file mode 100644 index 000000000..e7feb9473 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.bugs/900213_01.C @@ -0,0 +1,27 @@ +// { dg-do assemble } +// g++ 1.36.1 bug 900213_01 + +// g++ incorrectly diagnoses the error when an attempt is made to reference +// a non-static data-member without an object indication. + +// Similar attempts to reference non-static function-members are correctly +// diagnosed by g++. + +// Cfront 2.0 passes this test. + +// keywords: non-static members, member pointers, scope resolution + +struct struct0 { + int struct0_data_member_0; /* { dg-error "" } gets error from below */ + int struct0_function_member_0 (); +}; + +int i; + +void global_function_0 () +{ + i = struct0::struct0_data_member_0; /* { dg-error "" } mishandled by g++ */ + //i = struct0::struct0_function_member_0 (); /* gets caught by g++ */ +} + +int main () { return 0; } diff --git a/gcc/testsuite/g++.old-deja/g++.bugs/900213_02.C b/gcc/testsuite/g++.old-deja/g++.bugs/900213_02.C new file mode 100644 index 000000000..9b9ae994d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.bugs/900213_02.C @@ -0,0 +1,22 @@ +// { dg-do assemble } +// g++ 1.36.1 bug 900213_02 + +// The following erroneous code causes g++ to abort. + +// Cfront 2.0 passes this test. + +// keywords: abort, member pointers, operator* + +struct struct0 { + int data_member; +}; + +int i; +int struct0::*dmp; + +void global_function_0 () +{ + i = *dmp; // { dg-error "invalid use of unary '\\\*' on pointer to member" } causes abort +} + +int main () { return 0; } diff --git a/gcc/testsuite/g++.old-deja/g++.bugs/900213_03.C b/gcc/testsuite/g++.old-deja/g++.bugs/900213_03.C new file mode 100644 index 000000000..3c150b8b5 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.bugs/900213_03.C @@ -0,0 +1,28 @@ +// { dg-do assemble } +// g++ 1.36.1 bug 900213_03 + +// g++ fails to detect an error when the address of a "bound" function is +// assigned to a pointer-to-member-function variable. + +// It does however correctly detect a similar errors for data-members. + +// keywords: bound function, operator&, member pointers + +struct struct0 { + int data_member; + int function_member (); +}; + +int i; +int struct0::*dmp; +int (struct0::*fmp) (); + +struct0 *ptr; + +void global_function_0 () +{ + fmp = &ptr->function_member; // { dg-error "" } + //dmp = &ptr->data_member; // caught by g++, missed by cfront +} + +int main () { return 0; } diff --git a/gcc/testsuite/g++.old-deja/g++.bugs/900214_01.C b/gcc/testsuite/g++.old-deja/g++.bugs/900214_01.C new file mode 100644 index 000000000..88cafbfc1 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.bugs/900214_01.C @@ -0,0 +1,23 @@ +// { dg-do assemble } +// g++ 1.36.1 bug 900214_01 + +// g++ allows function members of incomplete types to be declared to be +// friends of other types. + +// Cfront 2.0 passes this test. + +// keywords: friends, incomplete types, function members + +struct A; // { dg-error "" } forward declaration + +struct B { + friend void A::foo(); // { dg-error "" } type A is incomplete +}; + +void A::foo(); /* { dg-error "" } also illegal */ + +struct A { + void foo() {} +}; + +int main () { return 0; } diff --git a/gcc/testsuite/g++.old-deja/g++.bugs/900215_01.C b/gcc/testsuite/g++.old-deja/g++.bugs/900215_01.C new file mode 100644 index 000000000..c79a7035f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.bugs/900215_01.C @@ -0,0 +1,45 @@ +// { dg-do assemble } +// g++ 1.36.1 bug 900215_01 + +// g++ allows the definition of a type conversion operator `operator void' +// for class types, but subsequently fails to generate calls (where needed) +// for such type conversion operators. + +// Cfront 2.0 does generate such calls. + +// The following program exits with status 0 when compiled with Cfront 2.0 +// but exits with status 1 when compiled with g++. + +// Cfront 2.0 passes this test. + +// 4/27/94 (jason): The pre-San Diego working paper prohibits operator +// void, so we can go back to just ignoring void values. + +// keywords: user-defined type conversion operators, void type, explicit casts + +// 8/3/2000 (nathan): The std allows you to define such an op, but +// it will never be called. [class.conv.fct]. Make it an unconditional warning. + +// { dg-options "-Wconversion" } + +struct struct0 { + + operator void (); // { dg-warning "" } operator void +}; + +int exit_status = 1; + +struct0::operator void () +{ + exit_status = 0; +} + +struct struct0 s0_object; + +int test () +{ + (void) s0_object; + return exit_status; +} + +int main () { return test (); } diff --git a/gcc/testsuite/g++.old-deja/g++.bugs/900215_02.C b/gcc/testsuite/g++.old-deja/g++.bugs/900215_02.C new file mode 100644 index 000000000..3309c8863 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.bugs/900215_02.C @@ -0,0 +1,48 @@ +// { dg-do assemble } +// g++ 1.36.1 bug 900215_02 + +// g++ allows global objects (which happen to be pointers to members of some +// class X) to be dereferenced without prefix object specifications within +// member functions of class X. + +// In effect, g++ treats any dereference of a pointer-to-member which appears +// within the context of a member function (and which is not preceeded by +// either ->* or .*) as if it had been implicitly prefixed with this->*. + +// The 2.0 Reference Manual only provides that such implicit prefixing +// takes place for *members* of the containing class, and *not* for +// global objects that happen to have certain types (i.e. pointer-to-member +// of the containing class). + +// Also, cfront 2.0 provides implicit this-> prefixes *only* for *members* +// of the containing class. + +// Cfront 2.0 passes this test. + +// keywords: member pointers, this, dereference, members + +struct struct0 { + int data_member; + void function_member (); +}; + +int struct0::*dmp; +int (struct0::*fmp) (); +int i; + +struct struct1 { + int data_member; + + void function_member (); +}; + +void struct0::function_member () +{ + i = (this->*fmp) (); // perfectly legal - for both cfront and g++ + i = this->*dmp; // perfectly legal - for both cfront and g++ + + i = (*fmp) (); // { dg-error "invalid use of unary '\\\*' on pointer to member" } + i = *dmp; // { dg-error "invalid use of unary '\\\*' on pointer to member" } +} + +int main () { return 0; } diff --git a/gcc/testsuite/g++.old-deja/g++.bugs/900220_01.C b/gcc/testsuite/g++.old-deja/g++.bugs/900220_01.C new file mode 100644 index 000000000..bda259df1 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.bugs/900220_01.C @@ -0,0 +1,37 @@ +// { dg-do run } +// g++ 1.36.1 bug 900220_01 + +// Ref: 12.8 + +// Section 12.8 says: + +// "That is, X::operator=() will be generated only if no assignment +// operation is explicitly declared and an object of class X is actually +// assigned an object of class X (or an object of a class derived from X) +// or if the address of X::operator= is taken. + +// g++ does not allow you to take the address of an implicitly generated +// operator= + +// keywords: operator=, implicit copy operator, operator& + +struct struct0 { + int data_member; +}; + +typedef struct0& (struct0::*member_func_t) (const struct0&); + +member_func_t member_func; + +void global_function_0 (member_func_t member_f) +{ // { dg-bogus "" } ref from below +} + +void global_function_1 () +{ + member_func = &struct0::operator=; // { dg-bogus "" } + + global_function_0 (&struct0::operator=); // { dg-bogus "" } +} + +int main () { return 0; } diff --git a/gcc/testsuite/g++.old-deja/g++.bugs/900220_02.C b/gcc/testsuite/g++.old-deja/g++.bugs/900220_02.C new file mode 100644 index 000000000..48cb8213d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.bugs/900220_02.C @@ -0,0 +1,31 @@ +// { dg-do run } +// g++ 1.36.1 bug 900220_02 + +// g++ treats plain `char' and `unsigned char' as different types, however +// it fails to treat `signed char' as being a different type from plain +// `char' as called for by both the ANSI C standard and the C++ reference +// manual. + +// keywords: plain char type, signed char type, unsigned char type, overloading + +void overloaded (char) { +} + +void overloaded (signed char) { // { dg-bogus "" } +} + +void overloaded (unsigned char) { +} + +void global_function () +{ + char c = 0; + signed char sc = 0; + unsigned char uc = 0; + + overloaded (c); + overloaded (sc); + overloaded (uc); +} + +int main () { return 0; } diff --git a/gcc/testsuite/g++.old-deja/g++.bugs/900220_03.C b/gcc/testsuite/g++.old-deja/g++.bugs/900220_03.C new file mode 100644 index 000000000..7e4aab6f0 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.bugs/900220_03.C @@ -0,0 +1,52 @@ +// { dg-do run } +// g++ 1.36.1 bug 900220_03 + +// g++ does not properly disambiguate calls to overloaded functions +// which are nearly identical except that one take a reference to a +// type `T' object and another takes a reference to a type `const T' +// object. + +// (Note that the volatile stuff is commented out here because cfront +// does not yet grok volatile.) + +// Cfront 2.0 passes this test. + +// keywords: references, overloading, type qualifiers, pointers + +int c_call_count = 0; +int cc_call_count = 0; +//int vc_call_count = 0; + +void overloaded (char&) +{ + c_call_count++; +} + +void overloaded (const char&) +{ + cc_call_count++; +} + +//void overloaded (volatile char&) +//{ +// vc_call_count++; +//} + +int test () +{ + char c = 0; + const char cc = 0; + //volatile char vc = 0; + + char& cr = c; + const char& ccr = cc; + //volatile char& vcr = vc; + + overloaded (c); // OK + overloaded (cc); // { dg-bogus "" } + //overloaded (vc); // OK + + return (c_call_count != 1 || cc_call_count != 1 /* || vc_call_count != 1 */); +} + +int main () { return test (); } diff --git a/gcc/testsuite/g++.old-deja/g++.bugs/900221_01.C b/gcc/testsuite/g++.old-deja/g++.bugs/900221_01.C new file mode 100644 index 000000000..7a31fbb96 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.bugs/900221_01.C @@ -0,0 +1,22 @@ +// { dg-do assemble } +// g++ 1.36.1 bug 900221_01 + +// Ref: 3.2 +// +// Section 3.2 of the C++ 2.0 Reference Manual says: +// +// "Names of formal arguments for a function are treated as if they +// were declared in the outermost block of that function" +// +// g++ does not enforce this treatment. + +// Cfront 2.0 passes this test. + +// keywords: scope, formal parameters + +void function (int arg1) +{ + int arg1; // { dg-error "" } redeclaration of arg1 +} + +int main () { return 0; } diff --git a/gcc/testsuite/g++.old-deja/g++.bugs/900227_01.C b/gcc/testsuite/g++.old-deja/g++.bugs/900227_01.C new file mode 100644 index 000000000..b441eff65 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.bugs/900227_01.C @@ -0,0 +1,39 @@ +// { dg-do assemble } +// { dg-options "" } +// g++ 1.37.1 bug 900227_01 + +// g++ allows pointer type values to be converted to integral types which are +// not actually large enough to hold the converted values. + +// Section 3.3.4 of the ANSI C standard says: + +// A pointer may be converted to an integral type. The size of the +// integer required and the results are implementation defined. If +// the space provided is not long enough, the behavior is undefined. + +// I believe that the only proper thing to do in such cases is to generate +// errors. After all, if the converted value gets truncated, it is not +// likely to be useful after that. + +// Furthermore, as the following example demonstrates, allowing pointers +// to be converted to integral types which are not of sufficient size to +// completely hold the converted values may cause additional troubles. + +// I tried the following code on 5 different machines and it failed on +// all five (unless I also use the GNU assembler and the GNU linker). Three +// of the five (Sun3, Sun4, and Symmetry) got link-time errors about byte +// offset overflows. The other two (368/SystemV and AViiON) got assembly +// time errors about relocatable names used in "constant" expressions. + +// keywords: casts, pointer types, integral types + +// Update 2/10/95: The compiler will now compute these expressions at +// runtime. I think this is in the spirit of the GNU compilers (jason). + + +int main (); + +short s = (short) &main; // { dg-error "loses precision" "lose" { xfail h8*-*-* xstormy16-*-* } } +char c = (char) &main; // { dg-error "loses precision" "lose" } + +int main () { return 0; } diff --git a/gcc/testsuite/g++.old-deja/g++.bugs/900321_01.C b/gcc/testsuite/g++.old-deja/g++.bugs/900321_01.C new file mode 100644 index 000000000..6b52783c0 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.bugs/900321_01.C @@ -0,0 +1,30 @@ +// { dg-do assemble } +// g++ 1.37.1 bug 900321_01 + +// cfront flags ERRORs on each of the lines indicated below. g++ does not +// flag either ERRORs or warnings. + +// Although I cannot find where in the current C++ Reference Manual this +// topic is covered, I am sure that these statements should get ERRORs in +// a "strongly typed" language. + +// Cfront 2.0 passes this test. + +// keywords: array types, array bound, pointers + +int (*ptr_to_array_of_ints)[]; +int (*ptr_to_array_of_3_ints) [3]; +int (*ptr_to_array_of_5_ints) [5]; + +void function_0 () +{ + // we miss the first two because typeck.c (comp_array_types) deems + // it okay if one of the sizes is null + ptr_to_array_of_ints = ptr_to_array_of_3_ints; // { dg-error "" } + ptr_to_array_of_3_ints = ptr_to_array_of_ints; // { dg-error "" } + + ptr_to_array_of_3_ints = ptr_to_array_of_5_ints; // { dg-error "" } + ptr_to_array_of_5_ints = ptr_to_array_of_3_ints; // { dg-error "" } +} + +int main () { return 0; } diff --git a/gcc/testsuite/g++.old-deja/g++.bugs/900321_02.C b/gcc/testsuite/g++.old-deja/g++.bugs/900321_02.C new file mode 100644 index 000000000..2d487646f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.bugs/900321_02.C @@ -0,0 +1,28 @@ +// { dg-do run } +// g++ 1.37.1 bug 900321_02 + +// The following program exits with a nonzero status because the constructor +// is not called 3 times as it should be. This program exits with a zero +// status when compiled with cfront 2.0. + +// Cfront 2.0 passes this test. + +// keywords: arrays, initialization, default constructor, operator new + +int call_count = 0; + +struct struct0 { + struct0 (); +}; + +struct0::struct0 () { call_count++; } + +typedef struct0 array[3]; // known dimension + +int test () +{ + new array; + return (call_count != 3); +} + +int main () { return test (); } diff --git a/gcc/testsuite/g++.old-deja/g++.bugs/900321_04.C b/gcc/testsuite/g++.old-deja/g++.bugs/900321_04.C new file mode 100644 index 000000000..72c063e42 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.bugs/900321_04.C @@ -0,0 +1,17 @@ +// { dg-do run } +// g++ 1.37.1 bug 900321_04 + +// The following code causes g++ to segfault. + +// Cfront 2.0 passes this test. + +// keywords: segfault, object declaration, pointer, array, incomplete type + +struct incomplete; + +void function () +{ + struct incomplete (*ptr)[]; // causes segfault +} + +int main () { return 0; } diff --git a/gcc/testsuite/g++.old-deja/g++.bugs/900321_05.C b/gcc/testsuite/g++.old-deja/g++.bugs/900321_05.C new file mode 100644 index 000000000..eb08d1a56 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.bugs/900321_05.C @@ -0,0 +1,21 @@ +// { dg-do run } +// g++ 1.37.1 bug 900321_05 + +// The following code is legal as far as the ANSI C standard, GCC, and +// cfront are concerned, however g++ issues errors for the lines indicated. + +// Cfront 2.0 passes this test. + +// keywords: operator[], pointers, index + +char c; +char *cp; +int i; + +void function () +{ + c = 3["abcdef"]; // { dg-bogus "" } + c = i[cp]; // { dg-bogus "" } +} + +int main () { return 0; } diff --git a/gcc/testsuite/g++.old-deja/g++.bugs/900322_01.C b/gcc/testsuite/g++.old-deja/g++.bugs/900322_01.C new file mode 100644 index 000000000..bd3296ae2 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.bugs/900322_01.C @@ -0,0 +1,62 @@ +// { dg-do assemble } +// g++ 1.37.1 bug 900322_01 + +// ** Old, obsolete commentary: +// ************************************************************************** +// The ANSI C standard, in section 3.1.2.5 (first paragraph) differentiates +// types into three disjoint sets, i.e object types, function types, and +// incomplete types. + +// Also in 3.1.2.5 (page 24) the standard says that the element type of +// an array type is an object type. + +// Later in that same section the standard also notes that array types with +// unknown size are considered incomplete types (page 25). (Struct & union +// types which have only been "forward declared" are also incomplete types.) + +// Some experts infer this to mean that it is not legal to specify or to +// construct an array *type* whose element type is an incomplete type. + +// This interpretation suggests that the statements indicated below contain +// errors. + +// g++ fails to flag all of the indicated statements with errors (even when +// the -pedantic option is used). +// ************************************************************************** + +// The above commentary is wrong. (jason 1998/11/13) +// In fact, the lines marked OK are well-formed; the prohibition is only +// against forming array types with multiple unknown bounds. This prohibition +// is found in 8.3.4 [dcl.array]. + +// It is also ill-formed to create an object of incomplete type. + +// keywords: incomplete types, arrays, element types + +extern int extern_two_d [] []; // { dg-error "" } invalid declaration +int tenative_two_d [] []; // { dg-error "" } caught by g++ +static int static_two_d [] []; // { dg-error "" } caught by g++ + +int (*pointer_to_two_d)[][]; // { dg-error "" } invalid declaration + +void function_0 (int arg [] []) { // { dg-error "" } invalid declaration +} + +typedef int int_one_d_type []; +typedef int_one_d_type int_two_d_type[];// { dg-error "" } invalid declaration + +struct s; + +extern struct s extern_s_array [10]; // OK +struct s tenative_s_array [10]; // { dg-error "" } object with incomplete type +static struct s static_s_array [10]; // { dg-error "" } object with incomplete type + +struct s (*pointer_to_s_array) []; // OK + +void function_1 (struct s arg []) { // OK +} + +typedef struct s s_type; +typedef s_type s_one_d_type [10]; // OK + +int main () { return 0; } diff --git a/gcc/testsuite/g++.old-deja/g++.bugs/900324_02.C b/gcc/testsuite/g++.old-deja/g++.bugs/900324_02.C new file mode 100644 index 000000000..b77cc0375 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.bugs/900324_02.C @@ -0,0 +1,19 @@ +// { dg-do assemble } +// g++ 1.37.1 bug 900324_02 + +// The following erroreous code causes g++ to segfault. + +// Cfront 2.0 passes this test. + +// keywords: segfault, function pointer, conditional operator ?: + +void function_0 (int i) { } + +void (*fp)(void); + +void function_1 () +{ + fp = 1 ? function_0 : fp; // { dg-error "conditional expression|invalid conversion" } +} + +int main () { return 0; } diff --git a/gcc/testsuite/g++.old-deja/g++.bugs/900324_03.C b/gcc/testsuite/g++.old-deja/g++.bugs/900324_03.C new file mode 100644 index 000000000..8c9989dbd --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.bugs/900324_03.C @@ -0,0 +1,22 @@ +// { dg-do run } +// g++ 1.37.1 bug 900324_03 + +// g++ is unable to correctly parse declarations of non-global function-pointer +// variables and/or function-pointer formal parameters. + +// Cfront 2.0 passes this test. + +// keywords: syntax, function pointers, block local, formal + +void (*p0)(); // OK + +void function_0 () +{ + void (*p1)(); // { dg-bogus "" } s +} + +void function_1 (void (*p2)()); // { dg-bogus "" } s + +void (*function_2 ()) (); // OK + +int main () { return 0; } diff --git a/gcc/testsuite/g++.old-deja/g++.bugs/900324_04.C b/gcc/testsuite/g++.old-deja/g++.bugs/900324_04.C new file mode 100644 index 000000000..1d671d156 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.bugs/900324_04.C @@ -0,0 +1,26 @@ +// { dg-do assemble } +// g++ 1.37.1 bug 900324_04 + +// g++ implements an extension which supports the copying of array objects. + +// This extension is not described in the current C++ Reference Manual, and +// it is not implemented by cfront (2.0). + +// g++ should generate errors for the use of this extension when -pedantic +// is used, however it does not. + +// Cfront 2.0 passes this test. + +// keywords: extension, pedantic, arrays, copy + +typedef int int_array[20]; + +int_array ia1; +int_array ia2; + +void function_0 () +{ + ia1 = ia2; // { dg-error "" } gnu extension +} + +int main () { return 0; } diff --git a/gcc/testsuite/g++.old-deja/g++.bugs/900324_05.C b/gcc/testsuite/g++.old-deja/g++.bugs/900324_05.C new file mode 100644 index 000000000..62625b59f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.bugs/900324_05.C @@ -0,0 +1,22 @@ +// { dg-do assemble } +// g++ 1.37.1 bug 900324_05 + +// The following erroneous code causes g++ to segfault. + +// Cfront 2.0 passes this test. + +// keywords: segfault, arrays, references, assignment operator= + +typedef int int_array[]; + +extern int_array int_array_object; + +int_array &left = int_array_object; +int_array &right = int_array_object; + +void function () +{ + left = right; // { dg-error "" } causes segfault +} + +int main () { return 0; } diff --git a/gcc/testsuite/g++.old-deja/g++.bugs/900324_06.C b/gcc/testsuite/g++.old-deja/g++.bugs/900324_06.C new file mode 100644 index 000000000..95eb00074 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.bugs/900324_06.C @@ -0,0 +1,29 @@ +// { dg-do run } +// g++ 1.37.1 bug 900324_06 + +// g++ is unable to use context information (i.e. the required type of the +// expression) to disambiguate a possibly overloaded function name when that +// name is used as either the second or the third operand of a ?: operator. + +// It is also unable to use the fact that the given name is not in fact +// overloaded (and has only one possible interpretation). + +// This results in improper errors being generated. + +// keywords: overloading, function pointers, disambiguation, operator?: + +int i; +void (*p)(); + +void function_0 () +{ +} + +void function_1 () +{ + p = i ? function_0 : 0; // { dg-bogus "" } + p = i ? 0 : function_0; // { dg-bogus "" } + p = i ? function_1 : function_0; // { dg-bogus "" } +} + +int main () { return 0; } diff --git a/gcc/testsuite/g++.old-deja/g++.bugs/900325_01.C b/gcc/testsuite/g++.old-deja/g++.bugs/900325_01.C new file mode 100644 index 000000000..e95a20b61 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.bugs/900325_01.C @@ -0,0 +1,18 @@ +// { dg-do assemble } +// g++ 1.37.1 bug 900325_01 + +// g++ fails to generate errors for attempts to declare a formal argument to +// be of a void type. + +// keywords: formal parameter, void type + +typedef void __void; +typedef __void Void; + +void function0 (void arg1) { // { dg-error "" } missed +} + +void function1 (Void arg1) { // { dg-error "" } missed +} + +int main () { return 0; } diff --git a/gcc/testsuite/g++.old-deja/g++.bugs/900330_01.C b/gcc/testsuite/g++.old-deja/g++.bugs/900330_01.C new file mode 100644 index 000000000..6800499c8 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.bugs/900330_01.C @@ -0,0 +1,53 @@ +// { dg-do assemble } +// g++ 1.37.1 bug 900330_01 +// +// As indicated by the example at the end of the section 3.5.3 of the ANSI +// C standard, when a type qualifier (i.e. "const" or "volatile") is applied +// to an array type, the effect should be as if the element type had been +// qualified with the given qualifier. +// +// This rule applies to C++ also. +// +// In section 7.1.6 of the C++ Reference Manual it says "Each element of a +// const array is const..." +// +// It appears however that when a name already exists for a given array type +// (i.e. a typedef name) and when that name is qualified by a type qualifier, +// (i.e. "const" or "volatile"), gcc & g++ may act as if the qualifier applied +// to the named (array) type rather that to the elements of that type. +// +// The result is that (even with the -ansi and -pedantic options) g++ +// generates no errors or warnings for the lines indicated (even though it +// should). +// +// Due to the incorrect associations, gcc & g++ will also issue inappropriate +// warnings in some cases (as illustrated below). + +// keywords: type qualifiers, arrays + +typedef const int const_int; +typedef const_int array_of_const_int[3]; +array_of_const_int *ptr_to_array_of_consts; + +typedef int array_of_int[3]; +typedef const array_of_int const_array_of_int; +const_array_of_int *ptr_to_const_array; + +void function_0 () +{ + ptr_to_array_of_consts = ptr_to_const_array; /* gets bogus warning */ + ptr_to_const_array = ptr_to_array_of_consts; /* gets bogus warning */ +} + +/* The following example is taken from ANSI 3.5.3 */ + +typedef int A[2][3]; +const A a = {{4, 5, 6}, {7, 8, 9}}; +int *pi; + +void function_1 () +{ + pi = a[0]; // { dg-error "" } a[0] has type "const int *" +} + +int main () { return 0; } diff --git a/gcc/testsuite/g++.old-deja/g++.bugs/900330_02.C b/gcc/testsuite/g++.old-deja/g++.bugs/900330_02.C new file mode 100644 index 000000000..cad19a2c3 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.bugs/900330_02.C @@ -0,0 +1,31 @@ +// { dg-do assemble } +// g++ 1.37.1 bug 900330_02 + +// The C++ Reference Manual says in section 13.1: + +// "Two function declarations of the same name refer to the same function +// if they are in the same scope and have identical argument types. A +// function member of a derived class is *not* in the same scope as a function +// member of the same name in a base class." + +// g++ fails to correctly detect the error indicated. + +// Cfront 2.0 passes this test. + +// keywords: function, member, overloading, hiding + +struct B { + int f(int); +}; + +struct D : public B { + int f(struct B); // { dg-message "D::f|no known conversion" } referred to below +}; + +void h(D* pd) +{ + pd->f(1); // { dg-error "no matching" } D::f(struct B) hides B::f(int) + // { dg-message "candidate" "candidate note" { target *-*-* } 27 } +} + +int main () { return 0; } diff --git a/gcc/testsuite/g++.old-deja/g++.bugs/900331_02.C b/gcc/testsuite/g++.old-deja/g++.bugs/900331_02.C new file mode 100644 index 000000000..f4d69fdca --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.bugs/900331_02.C @@ -0,0 +1,28 @@ +// { dg-do run } +// g++ 1.37.1 bug 900331_02 + +// g++ fails to treat conditional expressions which yield composite type +// (i.e. struct type, union type, or class type) lvalues as if they did +// in fact yield lvalues in all cases. + +// Cfront 2.0 passes this test. + +// keywords: conditional operator?:, lvalues, composite types + +struct struct0 { + int data_member; +}; + +struct0 object0; +struct0 object1; +struct0 object2; + +int i; + +void function0 () +{ + (i ? object0 : object1).data_member = 99; // { dg-bogus "" } + (i ? object0 : object1) = object2; // { dg-bogus "" } +} + +int main () { return 0; } diff --git a/gcc/testsuite/g++.old-deja/g++.bugs/900331_03.C b/gcc/testsuite/g++.old-deja/g++.bugs/900331_03.C new file mode 100644 index 000000000..f59f107e1 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.bugs/900331_03.C @@ -0,0 +1,33 @@ +// { dg-do run } +// { dg-options "" } +// g++ 1.37.1 bug 900331_03 + +// Special Options: -ansi + +// The following code causes g++ to abort. + +// Curiously, the abort does not occur if the -pedantic option is used. + +// Cfront 2.0 passes this test. + +// Keywords: abort, conditional operator?:, lvalues, composite types + +struct struct0 { + int data_member; + + virtual void function_member () {} // contributes to the abort +}; + +struct0 object0; +struct0 object1; +struct0 object2; + +int i; + +void function0 () +{ + object2 = (i ? object0 : object1); // OK + (i ? object0 : object1) = object2; // causes abort +} + +int main () { return 0; } diff --git a/gcc/testsuite/g++.old-deja/g++.bugs/900331_04.C b/gcc/testsuite/g++.old-deja/g++.bugs/900331_04.C new file mode 100644 index 000000000..ddc39182c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.bugs/900331_04.C @@ -0,0 +1,33 @@ +// { dg-do run } +// g++ 1.37.1 bug 900331_04 + +// g++ is unable to correctly parse declarations of formal parameters and +// local objects which have pointer-to-array types or reference-to-array +// types. + +// Cfront 2.0 passes this test. + +// keywords: syntax, arrays, pointers, references, local, formal + +int array[10]; + +int (*global_array_ptr)[10] = &array; +int (&global_array_ref)[10] = array; + +void function0 (int (*formal_array_ptr)[10]) { // { dg-bogus "" } s +} + +void function1 (int (&formal_array_ref)[10]) { // { dg-bogus "" } s +} + +void function2 () +{ + int (*local_array_ptr)[10] = &array; // { dg-bogus "" } s +} + +void function3 () +{ + int (&local_array_ref)[10] = array; // { dg-bogus "" } +} + +int main () { return 0; } diff --git a/gcc/testsuite/g++.old-deja/g++.bugs/900401_01.C b/gcc/testsuite/g++.old-deja/g++.bugs/900401_01.C new file mode 100644 index 000000000..cef7175f7 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.bugs/900401_01.C @@ -0,0 +1,16 @@ +// { dg-do assemble } +// g++ 1.37.1 bug 900401_01 + +// The following erroneous code causes g++ to abort. + +// Cfront 2.0 passes this test. + +// keywords: abort, bit-fields, arrays + +typedef unsigned nibble_array[4]; + +struct whole { + nibble_array nibbles:16; // { dg-error "" } +}; + +int main () { return 0; } diff --git a/gcc/testsuite/g++.old-deja/g++.bugs/900402_01.C b/gcc/testsuite/g++.old-deja/g++.bugs/900402_01.C new file mode 100644 index 000000000..42533861f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.bugs/900402_01.C @@ -0,0 +1,16 @@ +// { dg-do assemble } +// g++ 1.37.1 bug 900402_01 + +// The following erroneous code causes g++ to abort. + +// Cfront 2.0 passes this test. + +// keywords: abort, bit-fields, function types + +typedef void (func_type) (); + +struct s { + func_type f:32; // { dg-error "" } bitified with function type +}; + +int main () { return 0; } diff --git a/gcc/testsuite/g++.old-deja/g++.bugs/900402_02.C b/gcc/testsuite/g++.old-deja/g++.bugs/900402_02.C new file mode 100644 index 000000000..d3cf5ad9a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.bugs/900402_02.C @@ -0,0 +1,22 @@ +// { dg-do assemble } +// g++ 1.37.1 bug 900402_02 + +// g++ fails to correctly flag all attempts to construct an array type +// of zero length as errors. + +// keywords: arrays, array bound, zero length + +typedef int array_type[0]; // { dg-error "zero-size array" } + +int array_object_1[0]; // { dg-error "zero-size array" } + +void function_0 (int formal_array[0]) // { dg-error "zero-size array" } +{ +} + +void function_2 () +{ + int local_object_array_0[0]; // { dg-error "zero-size array" } +} + +int main () { return 0; } diff --git a/gcc/testsuite/g++.old-deja/g++.bugs/900403_01.C b/gcc/testsuite/g++.old-deja/g++.bugs/900403_01.C new file mode 100644 index 000000000..124654fbf --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.bugs/900403_01.C @@ -0,0 +1,20 @@ +// { dg-do assemble } +// g++ 1.37.1 bug 900403_01 + +// g++ allows casts to be treated as lvalues (even when the -pedantic +// option is used). Neither the C++ Reference Manual nor cfront 2.0 +// allow this. (gcc gives warnings for such usage with -pedantic). + +// Cfront 2.0 passes this test. + +// keywords: lvalues, casts + +int i, j; + +void f () +{ + (int) i = j; // { dg-error "" } + ((int) i) = j; // { dg-error "" } +} + +int main () { return 0; } diff --git a/gcc/testsuite/g++.old-deja/g++.bugs/900403_04.C b/gcc/testsuite/g++.old-deja/g++.bugs/900403_04.C new file mode 100644 index 000000000..1435bfad3 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.bugs/900403_04.C @@ -0,0 +1,13 @@ +// { dg-do assemble } +// g++ 1.37.1 bug 900403_04 + +// The following erroneous code causes g++ to abort. + +// keywords: abort, bit-fields, zero length + +struct s { + unsigned int foo:0; // { dg-error "" } This is the real line + unsigned int field; +}; + +int main () { return 0; } diff --git a/gcc/testsuite/g++.old-deja/g++.bugs/900404_01.C b/gcc/testsuite/g++.old-deja/g++.bugs/900404_01.C new file mode 100644 index 000000000..60e81129a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.bugs/900404_01.C @@ -0,0 +1,16 @@ +// { dg-do assemble } +// g++ 1.37.1 bug 900404_01 + +// g++ allows string initializers for known-length character arrays to be +// one character longer (counting the terminating null) than the actual +// length of the array to be initialized. + +// The C++ Reference Manual (section 8.4.2) expressly prohibits this. + +// Cfront 2.0 passes this test. + +// keywords: arrays, initialization, array bounds + +char cv[4] = "asdf"; // { dg-error "" } missed + +int main () { return 0; } diff --git a/gcc/testsuite/g++.old-deja/g++.bugs/900404_02.C b/gcc/testsuite/g++.old-deja/g++.bugs/900404_02.C new file mode 100644 index 000000000..3f87b614b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.bugs/900404_02.C @@ -0,0 +1,25 @@ +// { dg-do assemble } +// g++ 1.37.1 bug 900404_02 + +// g++ fails to treat multicharacter literals as type "int" as required by +// section 2.5.2 of the C++ Reference Manual. + +// The result is that the following program will exit with a nonzero +// exit status. + +// keywords: character literals, multi-character literals, int type + +int exit_status = 0; + +void function0 (int i) // function that should be called +{ + i = i; +} + +void function0 (char c) // function that is actually called +{ + c = c; + exit_status++; +} + +int main () { function0 ('abcd'); return exit_status; } // { dg-warning "" } diff --git a/gcc/testsuite/g++.old-deja/g++.bugs/900404_03.C b/gcc/testsuite/g++.old-deja/g++.bugs/900404_03.C new file mode 100644 index 000000000..7e2829f7b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.bugs/900404_03.C @@ -0,0 +1,29 @@ +// { dg-do assemble } +// g++ 1.37.1 bug 900404_03 + +// g++ fails to be able to properly flag errors for even simple cases of +// ambiguous overload resolution (such as the one shown below). + +// Cfront 2.0 passes this test. + +// keywords: overloading, ambiguity, resolution + +void function0 (int i, char c) // { dg-message "function0" } +{ + i = c; +} + +void function0 (char c, int i) // { dg-message "function0" } +{ + i = c; +} + +char c; + +void test () +{ + function0 (c,c); // { dg-error "ambiguous" } + // { dg-message "candidate" "candidate note" { target *-*-* } 25 } +} + +int main () { return 0; } diff --git a/gcc/testsuite/g++.old-deja/g++.bugs/900404_04.C b/gcc/testsuite/g++.old-deja/g++.bugs/900404_04.C new file mode 100644 index 000000000..04ff66905 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.bugs/900404_04.C @@ -0,0 +1,18 @@ +// { dg-do assemble } +// g++ 1.37.1 bug 900404_04 + +// [dcl.dcl] explains that simple-declarations may omit the +// init-declarator-list only if the decl-specifier-seq declares a +// class, i.e. if it contains a class-specifier, an +// elaborated-type-specifier with class key, or an enum-specifier. The +// declaration below contains neither. + +// g++ fails to flag errors for such usage. + +// keywords: semicolon, vacuous, file scope, declaration + +int i; + +; // { dg-error "extra ';'" } + +int main () { return 0; } diff --git a/gcc/testsuite/g++.old-deja/g++.bugs/900404_07.C b/gcc/testsuite/g++.old-deja/g++.bugs/900404_07.C new file mode 100644 index 000000000..19791bfdb --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.bugs/900404_07.C @@ -0,0 +1,18 @@ +// { dg-do assemble } +// g++ 1.37.1 bug 900404_07 + +// It is illegal to use a cast to attempt to convert an object type +// to a non-scalar type (e.g. an array type). + +// g++ fails to properly flag as errors such illegal uses of array types. + +// keywords: array types, casts, type conversion + +typedef int array_type[10]; + +array_type *ap; + +void foo () +{ + int i = *((array_type) *ap); /* { dg-error "" } missed */ +} diff --git a/gcc/testsuite/g++.old-deja/g++.bugs/900405_01.C b/gcc/testsuite/g++.old-deja/g++.bugs/900405_01.C new file mode 100644 index 000000000..25686f800 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.bugs/900405_01.C @@ -0,0 +1,20 @@ +// { dg-do assemble } +// g++ 1.37.1 bug 900405_01 + +// The C++ Reference Manual says (in section 5.4) "Types may not be defined +// in casts." + +// g++ fails to flag errors for cases where an attempt is made to define +// a struct, class, union, or enum type within a cast. + +// keywords: casts, type definitions, tagged types + +void f () +{ + (enum e { red, green } *) 0; // { dg-error "" } type defined in cast + (struct s { int member; } *) 0; // { dg-error "" } type defined in cast + (union u { int member; } * ) 0; // { dg-error "" } type defined in cast + (class c { int member; } *) 0; // { dg-error "" } type defined in cast +} + +int main () { return 0; } diff --git a/gcc/testsuite/g++.old-deja/g++.bugs/900406_01.C b/gcc/testsuite/g++.old-deja/g++.bugs/900406_01.C new file mode 100644 index 000000000..f99f73d72 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.bugs/900406_01.C @@ -0,0 +1,20 @@ +// { dg-do assemble } +// g++ 1.37.1 bug 900406_01 + +// The following code causes g++ to segfault. + +// cfront 2.0 passes this test. + +// keywords: segfault, operator new, array types, array bounds + +void function0 () +{ + new int[]; // { dg-error "" } causes segfault +} + +void function1 () +{ + new int (*)[]; // { dg-error "" } no size specified +} + +int main () { return 0; } diff --git a/gcc/testsuite/g++.old-deja/g++.bugs/900406_02.C b/gcc/testsuite/g++.old-deja/g++.bugs/900406_02.C new file mode 100644 index 000000000..bcbffeb55 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.bugs/900406_02.C @@ -0,0 +1,26 @@ +// { dg-do run } +// g++ bug 900406_02 + +// g++ fails to correctly parse some type specifications within casts. + +// This results in incorrect errors being issued. + +// These errors are not issued for identical code by either cfront or +// by gcc. + +// cfront 2.0 passes this test. + +// keywords: syntax, array types, casts + +int (*ipp)[]; +int (**ippp)[]; + +int function () +{ + ipp = (int (*)[]) 0; // OK + ippp = (int (**)[]) 0; // { dg-bogus "" } (syntax) + return 0; +} + +int main () { return 0; } + diff --git a/gcc/testsuite/g++.old-deja/g++.bugs/900407_01.C b/gcc/testsuite/g++.old-deja/g++.bugs/900407_01.C new file mode 100644 index 000000000..e5976d694 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.bugs/900407_01.C @@ -0,0 +1,37 @@ +// { dg-do assemble } +// g++ 1.37.1 bug 900407_01 + +// g++ fails to flag errors for uses of anachronistic features such as the +// invocation of a base class constructor in a ctor-initializer list without +// explicitly giving its name. + +// Errors should probably be issued for such usage unless the -traditional +// option is used. + +// Warnings are however issued. + +// Cfront 2.0 flags such usage as an error when the +p (pure-language) option +// is used. + +// Cfront 2.0 passes this test. + +// keywords: anachronism, inheritance, initialization, mem-initializer + +struct s0 { + int member; + + s0 (); +}; + +s0::s0() { } + +struct s1 : public s0 { + int member; + + s1 (); +}; + +s1::s1() : () { // { dg-error "" } anachronism used +} + +int main () { return 0; } diff --git a/gcc/testsuite/g++.old-deja/g++.bugs/900428_01.C b/gcc/testsuite/g++.old-deja/g++.bugs/900428_01.C new file mode 100644 index 000000000..a806ef070 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.bugs/900428_01.C @@ -0,0 +1,164 @@ +// { dg-do assemble } +// g++ 1.37.1 bug 900428_01 + +// g++ fails to issue error messages for cases where an incomplete type +// object must be evaluated if the value of such an evaluation is not +// actually used in the given context. + +// In the case where such an object is volatile, it is obvious that this +// could be a problem, however I believe that errors should be issued +// for such cases regardless of whether or not such values are volatile +// because the abstract semantics seem to require the evaluation of such +// values whether they are volatile or not. + +// [expr.static.cast/4, stmt.expr/1, expr.comma/1] show that expressions do +// not under go lvalue to rvalue decay, unless the value is actually used. +// This can be surprising when the object is volatile. We interpret a +// dereference of pointer to volatile to be a read. + +// keywords: incomplete types, evaluation, volatile qualifier + +int *ip_fn (); +int &ir_fn (); +volatile int *vip_fn (); +volatile int &vir_fn (); + +void int_test (int i, int *p, volatile int *vp, int &r, volatile int &vr) +{ + int j; + volatile int vj; + + *p; // ok, no warning + (void)*p; // ok, no warning + (void)(i ? j : *p); // ok, no warning + (void)(i ? *p : j); // ok, no warning + (void)((void)1, *p); // ok, no warning + + *vp; // ok, no warning + (void)*vp; // ok, no warning + (void)(i ? vj : *vp); // ok, no warning + (void)(i ? *vp : vj); // ok, no warning + (void)((void)1, *vp); // ok, no warning + + r; // ok, no warning + (void)r; // ok, no warning + (void)(i ? j : r); // ok, no warning + (void)(i ? r : j); // ok, no warning + (void)((void)1, r); // ok, no warning + + vr; // { dg-warning "" } reference not accessed + (void)vr; // { dg-warning "" } reference not accessed + (void)(i ? vj : vr); // { dg-warning "" } reference not accessed + (void)(i ? vr : vj); // { dg-warning "" } reference not accessed + (void)((void)1, vr); // { dg-warning "" } reference not accessed + + *ip_fn (); // ok, no warning + *vip_fn (); // ok, no warning + ir_fn (); // ok, no warning + vir_fn (); // { dg-warning "" } reference not accessed +} + +struct S; +S *sp_fn (); +S &sr_fn (); +volatile S *vsp_fn (); +volatile S &vsr_fn (); + +void incomplete_test (int i, S *p, volatile S *vp, S &r, volatile S &vr) +{ + extern S j; + extern volatile S vj; + + *p; // ok, no warning + (void)*p; // ok, no warning + (void)(i ? j : *p); // ok, no warning + (void)(i ? *p : j); // ok, no warning + (void)((void)1, *p); // ok, no warning + + *vp; // { dg-warning "" } incomplete not accessed + (void)*vp; // { dg-warning "" } incomplete not accessed + (void)(i ? vj : *vp); // { dg-warning "" } incomplete not accessed + (void)(i ? *vp : vj); // { dg-warning "" } incomplete not accessed + (void)((void)1, *vp); // { dg-warning "" } incomplete not accessed + + r; // ok, no warning + (void)r; // ok, no warning + (void)(i ? j : r); // ok, no warning + (void)(i ? r : j); // ok, no warning + (void)((void)1, r); // ok, no warning + + vr; // { dg-warning "" } reference not accessed + (void)vr; // { dg-warning "" } reference not accessed + (void)(i ? vj : vr); // { dg-warning "" } reference not accessed + (void)(i ? vr : vj); // { dg-warning "" } reference not accessed + (void)((void)1, vr); // { dg-warning "" } reference not accessed + + *sp_fn (); // ok, no warning + *vsp_fn (); // { dg-warning "" } incomplete not accessed + sr_fn (); // ok, no warning + vsr_fn (); // { dg-warning "" } reference not accessed +} + +struct T {int m;}; +T *tp_fn (); +T &tr_fn (); +volatile T *vtp_fn (); +volatile T &vtr_fn (); + +void complete_test (int i, T *p, volatile T *vp, T &r, volatile T &vr) +{ + T j; + volatile T vj; + + *p; // ok, no warning + (void)*p; // ok, no warning + (void)(i ? j : *p); // ok, no warning + (void)(i ? *p : j); // ok, no warning + (void)((void)1, *p); // ok, no warning + + *vp; // ok, no warning + (void)*vp; // ok, no warning + (void)(i ? vj : *vp); // ok, no warning + (void)(i ? *vp : vj); // ok, no warning + (void)((void)1, *vp); // ok, no warning + + r; // ok, no warning + (void)r; // ok, no warning + (void)(i ? j : r); // ok, no warning + (void)(i ? r : j); // ok, no warning + (void)((void)1, r); // ok, no warning + + vr; // { dg-warning "" } reference not accessed + (void)vr; // { dg-warning "" } reference not accessed + (void)(i ? vj : vr); // { dg-warning "" } reference not accessed + (void)(i ? vr : vj); // { dg-warning "" } reference not accessed + (void)((void)1, vr); // { dg-warning "" } reference not accessed + + *tp_fn (); // ok, no warning + *vtp_fn (); // ok, no warning + tr_fn (); // ok, no warning + vtr_fn (); // ok, no warning{ dg-warning "" } reference not accessed +} + +void extern_test () +{ + extern S es; + extern volatile S ves; + extern T et; + extern volatile T vet; + + extern S &esr; + extern volatile S &vesr; + extern T &etr; + extern volatile T &vetr; + + es; // ok, no warning + ves; // { dg-warning "" } incomplete not accessed + et; // ok, no warning + vet; // ok, no warning + + esr; // ok, no warning + vesr; // { dg-warning "" } incomplete not accessed + etr; // ok, no warning + vetr; // { dg-warning "" } reference not accessed +} diff --git a/gcc/testsuite/g++.old-deja/g++.bugs/900428_02.C b/gcc/testsuite/g++.old-deja/g++.bugs/900428_02.C new file mode 100644 index 000000000..4846a8113 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.bugs/900428_02.C @@ -0,0 +1,27 @@ +// { dg-do assemble } +// g++ 1.37.1 bug 900428_02 + +// g++ fails to issue either errors or warnings (even with -pedantic) for +// attempts to perform either pre or post increment or decrement operations +// on variables which have either pointer-to-void types or pointer-to-function +// types. + +// cfront 2.0 passes this test. + +// keywords: pointer arithmetic, increment, decrement + +void *vp; +void (*fp) (); + +void test () +{ + vp++; /* { dg-error "" } */ + ++vp; /* { dg-error "" } */ + vp--; /* { dg-error "" } */ + --vp; /* { dg-error "" } */ + + fp++; /* { dg-error "" } */ + ++fp; /* { dg-error "" } */ + fp--; /* { dg-error "" } */ + --fp; /* { dg-error "" } */ +} diff --git a/gcc/testsuite/g++.old-deja/g++.bugs/900428_03.C b/gcc/testsuite/g++.old-deja/g++.bugs/900428_03.C new file mode 100644 index 000000000..d0625c4b4 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.bugs/900428_03.C @@ -0,0 +1,42 @@ +// { dg-do assemble } +// g++ 1.37.1 bug 900428_03 + +// g++ fails to detect cases where a constructor for a derived class invokes +// (either explicitly or implicitly) a private constructor for a base class. + +// cfront 2.0 passes this test. + +// keywords: inheritance, private, accessability, constructors + +struct struct_0 { + int struct_0_data_member; + +private: + struct_0 (int, int); +public: + struct_0 (int); +}; + +struct_0::struct_0 (int i) { } +struct_0::struct_0 (int, int) { } // { dg-error "is private" } + +struct struct_1 : public struct_0 { + + struct_1 (); +}; + +struct_1::struct_1 () : struct_0 (8,9) // { dg-error "within this context" } +{ +} + +struct struct_2 { + struct_0 struct_2_data_member; + + struct_2 (); +}; + +struct_2::struct_2 () : struct_2_data_member (8,9) // { dg-error "within this context" } +{ +} + +int main () { return 0; } diff --git a/gcc/testsuite/g++.old-deja/g++.bugs/900511_01.C b/gcc/testsuite/g++.old-deja/g++.bugs/900511_01.C new file mode 100644 index 000000000..e5dff0e25 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.bugs/900511_01.C @@ -0,0 +1,43 @@ +// { dg-do run } +// g++ 1.37.1 bug 900511_01 + +// g++ fails to properly apply user-defined type conversion operators +// in cases where is it not obvious that the given conversion is +// appropriate for the context (i.e. operator and other operands) +// where the conversion should take place. + +// cfront 2.0 passes this test. + +struct struct_1 { + int member; + + operator int (); +}; + +struct_1::operator int () +{ + return 0; +} + +struct struct_2 { + int member; + + operator float (); +}; + +struct_2::operator float () +{ + return 0.0; +} + +struct_1 struct_1_object; +struct_2 struct_2_object; +double d; + +void test () +{ + d = struct_2_object + struct_1_object; // OK + d = struct_1_object + struct_2_object; // { dg-bogus "" } +} + +int main () { return 0; } diff --git a/gcc/testsuite/g++.old-deja/g++.bugs/900511_02.C b/gcc/testsuite/g++.old-deja/g++.bugs/900511_02.C new file mode 100644 index 000000000..f2f565084 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.bugs/900511_02.C @@ -0,0 +1,22 @@ +// { dg-do assemble } +// g++ 1.37.1 bug 900511_02 + +// g++ does not properly shadow names of types with names of data members +// in cases where the type names in question are used in the context of +// formal parameters lists for member functions. + +// keywords: typedef names, shadowing, scope, formal parameter list + +// cfront 2.0 passes this test. + +enum enum0 { enum0_value_0 }; + +struct struct0 { + int enum0; + void member_function (enum0 e); // { dg-error "" } invalid use of struct-local member +}; + +void class0::member_function (enum0 e) { // { dg-error "" } syntax error +} + +int main () { return 0; } diff --git a/gcc/testsuite/g++.old-deja/g++.bugs/900511_03.C b/gcc/testsuite/g++.old-deja/g++.bugs/900511_03.C new file mode 100644 index 000000000..d01b6aa36 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.bugs/900511_03.C @@ -0,0 +1,20 @@ +// { dg-do assemble } +// g++ 1.37.1 bug 900511_03 + +// g++ does not properly shadow names of types with names of data members +// in cases where the type names in question are used in the context of +// formal parameters lists for member functions. + +// keywords: typedef names, shadowing, scope, formal parameter list + +class class0; + +struct struct1 { + int class0; + void member_function (class0 *); // { dg-error "" } invalid use of struct-local member +}; + +void class1::member_function (class0 *p) { // { dg-error "" } +} + +int main () { return 0; } diff --git a/gcc/testsuite/g++.old-deja/g++.bugs/900514_03.C b/gcc/testsuite/g++.old-deja/g++.bugs/900514_03.C new file mode 100644 index 000000000..30c2603a7 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.bugs/900514_03.C @@ -0,0 +1,117 @@ +// { dg-do assemble } +// g++ 1.37.1 bug 900514_03 + +// g++ fails to flag ERRORs on the following erroneous code. + +// In Section 12.3.2 it says "Defining conversion by both a constructor and +// a conversion function can lead to ambiguities." However in the case below, +// the explicit cast syntax disambiguates the constructor as one which +// invokes the type conversion operator rather than the conversion. + +// NO, IT DOESN'T. It's still ambiguous. --jason 2002-12-03 + +// cfront 2.0 passes this test. + +// keywords: user-defined type conversion operator, constructor + +struct t_0_st_0; + +struct t_0_st_1 { // { dg-error "initializing" } + int member; + + t_0_st_1 (t_0_st_0&);// { dg-message "note" } + t_0_st_1 (); +}; + +struct t_0_st_0 { + int member; + + operator t_0_st_1 ();// { dg-message "note" } +}; + +t_0_st_0 t_0_st_0_obj0; // { dg-message "candidate" } + +void t_0_assignment () +{ + t_0_st_1 t_0_st_1_obj0; + t_0_st_1 t_0_st_1_obj1; + t_0_st_1 t_0_st_1_obj2; + + t_0_st_1_obj0 = t_0_st_0_obj0; // { dg-error "ambiguous" } caught + t_0_st_1_obj1 = t_0_st_1 (t_0_st_0_obj0); +} + +void t_0_local_init () +{ + t_0_st_1 t_0_st_1_obj0 = t_0_st_0_obj0; // { dg-error "ambiguous" } + t_0_st_1 t_0_st_1_obj1 = t_0_st_1 (t_0_st_0_obj0); +} + +struct t_1_st_0; + +struct t_1_st_1 { + int member; + + t_1_st_1 (t_1_st_0&); // { dg-message "note" } + t_1_st_1 (); + void operator= (t_1_st_1&); // { dg-message "operator=|no known conversion" } +}; + +struct t_1_st_0 { + int member; + + operator t_1_st_1 (); // { dg-message "note" } +}; + +t_1_st_0 t_1_st_0_obj0; // { dg-message "candidate" } + +void t_1_assignment () +{ + t_1_st_1 t_1_st_1_obj0; + t_1_st_1 t_1_st_1_obj1; + t_1_st_1 t_1_st_1_obj2; + + t_1_st_1_obj0 = t_1_st_0_obj0; // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 74 } + t_1_st_1_obj1 = t_1_st_1 (t_1_st_0_obj0); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 76 } +} + +void t_1_local_init () +{ + t_1_st_1 t_1_st_1_obj0 = t_1_st_0_obj0; // { dg-error "ambiguous" } + t_1_st_1 t_1_st_1_obj1 = t_1_st_1 (t_1_st_0_obj0); +} + +struct t_2_st_0; + +struct t_2_st_1 { // { dg-error "initializing" } + int member; + + t_2_st_1 (t_2_st_0); // { dg-message "note" } + t_2_st_1 (); +}; + +struct t_2_st_0 { + int member; + + operator t_2_st_1 (); // { dg-message "note" } +}; + +t_2_st_0 t_2_st_0_obj0; // { dg-message "candidate" } + +void t_2_assignment () +{ + t_2_st_1 t_2_st_1_obj0; + t_2_st_1 t_2_st_1_obj1; + t_2_st_1 t_2_st_1_obj2; + + t_2_st_1_obj0 = t_2_st_0_obj0; // { dg-error "ambiguous" } caught + t_2_st_1_obj1 = t_2_st_1 (t_2_st_0_obj0); +} + +void t_2_local_init () +{ + t_2_st_1 t_2_st_1_obj0 = t_2_st_0_obj0; // { dg-error "ambiguous" } + t_2_st_1 t_2_st_1_obj1 = t_2_st_1 (t_2_st_0_obj0); +} diff --git a/gcc/testsuite/g++.old-deja/g++.bugs/900519_01.C b/gcc/testsuite/g++.old-deja/g++.bugs/900519_01.C new file mode 100644 index 000000000..4d2651169 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.bugs/900519_01.C @@ -0,0 +1,17 @@ +// { dg-do assemble } +// g++ 1.37.1 bug 900519_01 + +// g++ fails to flag errors for some attempts to declare or define non-member +// type conversion operators. + +// cfront 2.0 passes this test. + +// keywords: user-defined type conversion operator, non-member + +extern operator int (); // { dg-error "" } + +extern operator int () { // { dg-error "" } + return 0; +} + +int main () { return 0; } diff --git a/gcc/testsuite/g++.old-deja/g++.bugs/900519_02.C b/gcc/testsuite/g++.old-deja/g++.bugs/900519_02.C new file mode 100644 index 000000000..831c4a792 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.bugs/900519_02.C @@ -0,0 +1,33 @@ +// { dg-do assemble } +// g++ 1.37.1 bug 900519_02 + +// The C++ Reference Manual says (in section 8.4.3) "A reference to a plain +// T can only be initialized with a plain T" however g++ allows the +// initialization of plain references with qualified objects in many cases. + +// keywords: references, initialization, type qualifiers + +extern const int cint_obj = 9; +volatile int vint_obj = 9; + +void take_int_ref (int& arg) { } // { dg-error "" } referenced by errors below + +int& global_int_ref0 = cint_obj; // { dg-error "" } +int& global_int_ref1 = vint_obj; // { dg-error "" } + +extern const int& cint_ref; +extern volatile int& vint_ref; + +void test_0 () +{ + int& local_int_ref0 = cint_obj; // { dg-error "" } + int& local_int_ref1 = vint_obj; // { dg-error "" } + + take_int_ref (cint_obj); // { dg-error "" } caught + take_int_ref (vint_obj); // { dg-error "" } + + take_int_ref (cint_ref); // { dg-error "" } + take_int_ref (vint_ref); // { dg-error "" } +} + +int main () { return 0; } diff --git a/gcc/testsuite/g++.old-deja/g++.bugs/900519_03.C b/gcc/testsuite/g++.old-deja/g++.bugs/900519_03.C new file mode 100644 index 000000000..b840ee790 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.bugs/900519_03.C @@ -0,0 +1,48 @@ +// { dg-do assemble } +// g++ 1.37.1 bug 900519_03 + +// The C++ Reference Manual says (in section 8.4.3) "A reference to a +// volatile T can be initialized with a volatile T or a plain T but not a +// const T. A reference to a const T can be initialized with a const T or +// a plain T or something that can be converted into a plain T, but not a +// volatile T." + +// g++ fails to disgnose such errors in most cases. + +// keywords: references, initialization, type qualifiers + +extern const int cint_obj; +extern volatile int vint_obj; + +void take_cint_ref (const int& arg) { } // { dg-error "" } +void take_vint_ref (volatile int& arg) { } // { dg-error "" } + +const int& global_cint_ref2 = vint_obj; // { dg-error "" } + +volatile int& global_vint_ref1 = cint_obj; // { dg-error "" } + +extern const int& extern_cint_ref; +extern volatile int& extern_vint_ref; + +void test_0 () +{ + const int& local_cint_ref2 = vint_obj; // { dg-error "" } + + volatile int& local_vint_ref1 = cint_obj; // { dg-error "" } +} + +void test_1 () +{ + take_cint_ref (vint_obj); // { dg-error "" } + + take_vint_ref (cint_obj); // { dg-error "" } caught +} + +void test_2 () +{ + take_cint_ref (extern_vint_ref); // { dg-error "" } + + take_vint_ref (extern_cint_ref); // { dg-error "" } +} + +int main () { return 0; } diff --git a/gcc/testsuite/g++.old-deja/g++.bugs/900519_04.C b/gcc/testsuite/g++.old-deja/g++.bugs/900519_04.C new file mode 100644 index 000000000..5074c5a4c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.bugs/900519_04.C @@ -0,0 +1,22 @@ +// { dg-do run } +// g++ 1.37.1 bug 900519_04 + +// The following legal code causes g++ to segfault. + +// cfront 2.0 passes this test. + +// keywords: segfault, references, initialization + +int cint_obj = 9; + +void take_cint_ref (int& arg) { } + +int& cint_ref_0 = cint_obj; +int& cint_ref_1 = cint_obj; + +void test_0 () +{ + take_cint_ref (cint_ref_1); // causes segfault +} + +int main () { return 0; } diff --git a/gcc/testsuite/g++.old-deja/g++.bugs/900519_05.C b/gcc/testsuite/g++.old-deja/g++.bugs/900519_05.C new file mode 100644 index 000000000..f7f7ef3a8 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.bugs/900519_05.C @@ -0,0 +1,19 @@ +// { dg-do run } +// g++ 1.37.1 bug 900519_05 + +// g++ fails to allow the use of function-reference types. + +// cfront 2.0 passes this test. + +// keywords: function types, reference types + +typedef void (func_type) (int, int); +typedef func_type& func_ref_type; + +void function (int arg1, int arg2) +{ +} + +func_type& global_func_ref1 = function; + +int main () { return 0; } diff --git a/gcc/testsuite/g++.old-deja/g++.bugs/900519_06.C b/gcc/testsuite/g++.old-deja/g++.bugs/900519_06.C new file mode 100644 index 000000000..601e4aab3 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.bugs/900519_06.C @@ -0,0 +1,23 @@ +// { dg-do assemble } +// g++ 1.37.1 bug 900519_06 + +// g++ allows the type given in an invocation of operator new to be a +// reference type. + +// Since pointers to reference types are illegal, the required return type +// from such an invocation (of operator new) is illegal, and thus (it seems) +// the entire call to new should be treated as being illegal. + +typedef int& int_ref; + +void test (int n) +{ + new int&; // { dg-error "" } missed + new int_ref; // { dg-error "" } missed + new int&[n]; // { dg-error "" } missed + new int_ref[n]; // { dg-error "" } missed + new int&[3]; // { dg-error "" } missed + new int_ref[3]; // { dg-error "" } missed +} + +int main () { return 0; } diff --git a/gcc/testsuite/g++.old-deja/g++.bugs/900519_07.C b/gcc/testsuite/g++.old-deja/g++.bugs/900519_07.C new file mode 100644 index 000000000..650147ef2 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.bugs/900519_07.C @@ -0,0 +1,17 @@ +// { dg-do assemble } +// g++ 1.37.1 bug 900519_07 + +// It is illegal to specify or to use array-of-reference types, yet g++ +// allows them to be specified (in typedef statements and in declarations) +// and to be used (in declarations). + +// keywords: reference types, array types + +int i; +int j; + +typedef int& int_ref; +typedef int_ref int_ref_array_type[2]; // { dg-error "" } missed + +int& int_ref_array_obj0[2] = { i, j }; // { dg-error "" } missed +int_ref int_ref_array_obj1[2] = { i, j }; // { dg-error "" } missed diff --git a/gcc/testsuite/g++.old-deja/g++.bugs/900519_09.C b/gcc/testsuite/g++.old-deja/g++.bugs/900519_09.C new file mode 100644 index 000000000..71c426334 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.bugs/900519_09.C @@ -0,0 +1,30 @@ +// { dg-do assemble } +// g++ 1.37.1 bug 900519_09 + +// g++ allows the allocation of const objects via operator new even when +// these uses of operator new do not include initializations. + +// This is inconsistant within the restrictions placed on the construction +// of class, struct, and union types which have constant members. + +// Since there is no completely valid way of initializing such objects +// after the invocation of new, these cases should all be illegal. + +// keywords: operator new, initialization, const qualifier + +struct struct_0 { + int member; +}; + +typedef const int const_int; +typedef const struct struct_0 const_struct_0; + +void test () +{ + new const int; // { dg-error "" } + new const_int; // { dg-error "" } + new const struct_0; // { dg-error "" } + new const_struct_0; // { dg-error "" } +} + +int main () { return 0; } diff --git a/gcc/testsuite/g++.old-deja/g++.bugs/900519_12.C b/gcc/testsuite/g++.old-deja/g++.bugs/900519_12.C new file mode 100644 index 000000000..e08aba1af --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.bugs/900519_12.C @@ -0,0 +1,12 @@ +// { dg-do assemble } +// g++ 1.37.1 bug 900519_12 + +// The following erroneous code causes g++ to segfault. + +// cfront 2.0 passes this test. + +// keywords: segfault, typedef, pointer type, function type + +typedef eek void (*)(); // { dg-error "" } + +int main () { return 0; } diff --git a/gcc/testsuite/g++.old-deja/g++.bugs/900519_13.C b/gcc/testsuite/g++.old-deja/g++.bugs/900519_13.C new file mode 100644 index 000000000..9d4edc60a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.bugs/900519_13.C @@ -0,0 +1,36 @@ +// { dg-do assemble } +// g++ 1.37.1 bug 900519_13 + +// If multiple inheritance creates a situation in which a given name is +// inherited from more than one base class, and if the inherited declarations +// for the name are for different categories of members (e.g. object members, +// function members, enumeral members), then g++ will (in some cases) fail +// to flag errors when the ambiguous name is used. + +// cfront 2.0 passes this test. + +// keywords: inheritance, ambiguity resolution, members + +struct base_0 { + enum { base_member }; // { dg-error "" } candidate (26, 30) +}; + +struct base_1 { + int base_member; // { dg-error "" } candidate (26, 34) +}; + +struct base_2 { + int base_member (); // { dg-error "" } candidate (30, 34) +}; + +struct derived_0 : public base_0, public base_1 { + void member () { base_member; } // { dg-error "" } +}; + +struct derived_1 : public base_0, public base_2 { + void member () { base_member; } // { dg-error "" } missed +}; + +struct derived_2 : public base_1, public base_2 { + void member () { base_member; } // { dg-error "" } missed +}; diff --git a/gcc/testsuite/g++.old-deja/g++.bugs/900520_02.C b/gcc/testsuite/g++.old-deja/g++.bugs/900520_02.C new file mode 100644 index 000000000..0c8d8a2ba --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.bugs/900520_02.C @@ -0,0 +1,27 @@ +// { dg-do assemble } +// g++ 1.37.1 bug 900520_02 + +// keywords: reference types, initialization, parameter passing + +typedef int b_array[3]; +typedef int u_array[]; + +typedef b_array &b_array_ref; +typedef u_array &u_array_ref; + +void take_b_array_ref (b_array_ref arg) { } // { dg-error "" } passed to here + +extern u_array u_array_gbl_obj; + +u_array_ref u_array_ref_gbl_obj0 = u_array_gbl_obj; + +b_array_ref b_array_ref_gbl_obj0 = u_array_ref_gbl_obj0; // { dg-error "" } invalid declaration + +void test_passing () +{ + take_b_array_ref (u_array_ref_gbl_obj0); // { dg-error "" } invalid call +} + +b_array u_array_gbl_obj; + +int main () { return 0; } diff --git a/gcc/testsuite/g++.old-deja/g++.bugs/900520_03.C b/gcc/testsuite/g++.old-deja/g++.bugs/900520_03.C new file mode 100644 index 000000000..7978e386a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.bugs/900520_03.C @@ -0,0 +1,50 @@ +// { dg-do assemble } +// g++ 1.37.1 bug 900520_03 + +// The C++ Reference Manual says (in section 8.2.4): + +// When an identifier of array type appears in an expression, except +// as the operand of sizeof or & or used to initialize a reference, +// it is converted into a pointer to the first member of the array. + +// One must assume from the verbage, that when the name of a non-const array +// object appears in one of the exempted contexts mentioned in this passage, +// that it is *not* automatically converted into a pointer value, but rather +// that it remains as an array type value, and that it may therefore also +// still be an lvalue, and may be used to initialize references. + +// As the following code demonstrates, g++ does in fact treat the names +// of non-const array objects as valid initializers for reference-to-array +// type object in some (but not all) contexts. + +// The exception is that g++ does not allow names which designate objects +// on incomplete array types to be used as actual parameters in function +// calls where the corresponding formal parameter is of a reference-to-array +// type. + +// g++ does however allow other similar sorts of initializations of non-formal +// reference objects. + +// 5/16/94 (jason): The 1/25/94 WP explicitly states in section 8.3.5 that +// parameter types may not contain pointers or references to arrays of unknown +// bound. g++ is correct. + +// keywords: reference types, array types, initialization, parameter passing + +typedef int u_array[]; +typedef u_array &u_array_ref; + +void take_u_array_ref (u_array_ref arg) { } // { dg-error "" } reference to array of unknown bound in parmtype + +extern u_array u_array_gbl_obj; +u_array_ref u_array_ref_gbl_obj0 = u_array_gbl_obj; // OK + +void test_local_initialization () +{ + u_array_ref u_array_ref_lcl_obj0 = u_array_gbl_obj; // OK +} + +void test_passing () +{ + take_u_array_ref (u_array_gbl_obj); +} diff --git a/gcc/testsuite/g++.old-deja/g++.bugs/900520_04.C b/gcc/testsuite/g++.old-deja/g++.bugs/900520_04.C new file mode 100644 index 000000000..4fce93637 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.bugs/900520_04.C @@ -0,0 +1,41 @@ +// { dg-do run } +// g++ 1.37.1 bug 900520_04 + +// g++ does not yet support the initialization of scalar type objects +// (including built-in arithmetic types, enum types, and pointer types) +// via constructor initialization syntax except within a call to operator +// new. + +// keywords: unimplemented, syntax, initialization, scalar types + +enum e_type { e_value }; + +typedef char *charp; + +charp cp; + +int global_i (1); // { dg-bogus "" } +double global_d (9.9); // { dg-bogus "" } +charp global_cp0 (cp); // { dg-bogus "" } +charp global_cp1 (0); // { dg-bogus "" } +enum e_type global_e (e_value); // { dg-bogus "" } + +void func0 () +{ + int local_i (1); // { dg-bogus "" } + double local_d (9.9); // { dg-bogus "" } + charp local_cp0 (cp); // { dg-bogus "" } + charp local_cp1 (0); // { dg-bogus "" } + enum e_type local_e (e_value); // { dg-bogus "" } +} + +void func1 () +{ + int* ip = new int (1); // { dg-bogus "" } + double* dp = new double (9.9); // { dg-bogus "" } + charp* cpp0 = new charp (cp); // { dg-bogus "" } + charp* cpp1 = new charp (0); // { dg-bogus "" } + enum e_type* ep = new e_type (e_value); // { dg-bogus "" } +} + +int main () { return 0; } diff --git a/gcc/testsuite/g++.old-deja/g++.bugs/900520_05.C b/gcc/testsuite/g++.old-deja/g++.bugs/900520_05.C new file mode 100644 index 000000000..294feee75 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.bugs/900520_05.C @@ -0,0 +1,24 @@ +// { dg-do run } +// g++ 1.37.1 bug 900520_05 + +// The following legal code gets syntax errors from g++. + +// keywords: syntax, unimplemented, operator new, initialization, pointer types + +struct struct_0 { +}; + +char *cp; +static struct_0 *sp; + +void test0 () +{ + new char * (cp); // { dg-bogus "" } +} + +void test1 () +{ + new struct_0 * (sp); // { dg-bogus "" } +} + +int main () { return 0; } diff --git a/gcc/testsuite/g++.old-deja/g++.bugs/900520_06.C b/gcc/testsuite/g++.old-deja/g++.bugs/900520_06.C new file mode 100644 index 000000000..e11123193 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.bugs/900520_06.C @@ -0,0 +1,79 @@ +// { dg-do run } +// g++ 1.37.1 bug 900520_06 + +// When an object of a class type is passed into a formal parameter of the +// same class type (in a function call) the language definition calls for +// this action to be treated like any other form of an initialization of +// an object of the given class type. + +// g++ fails however to invoke the (compiler-supplied) copy constructor for +// the class type when a parameter of the class type is passed as an +// actual parameter. + +// This causes the following program to exit with a nonzero exit status. + +// cfront 2.0 passes this test. + +int base_copy_ctor_called = 0; +int member_copy_ctor_called = 0; + +struct struct_0 { + struct_0 (); + struct_0 (const struct_0&); +}; + +struct_0::struct_0 () +{ +} + +struct_0::struct_0 (const struct_0&) +{ + base_copy_ctor_called++; +} + +struct struct_1 { + struct_1 (); + struct_1 (const struct_1&); +}; + +struct_1::struct_1 () +{ +} + +struct_1::struct_1 (const struct_1&) +{ + member_copy_ctor_called++; +} + +struct struct_2 : public struct_0 { + struct_2 (); + struct_1 struct_1_member; +#ifdef MAKE_COPY_CONSTRUCTOR_EXPLICIT + struct_2 (const struct_2&); +#endif +}; + +struct_2::struct_2 () +{ +} + +#ifdef MAKE_COPY_CONSTRUCTOR_EXPLICIT +struct_2::struct_2 (const struct_2& arg) : + struct_0 ((struct_0&)arg), + struct_1_member (arg.struct_1_member) +{ +} +#endif + +void take_struct_2 (struct_2 arg) +{ +} + +int test () +{ + struct_2 struct_2_object0; + take_struct_2 (struct_2_object0); + return (base_copy_ctor_called != 1 || member_copy_ctor_called != 1); +} + +int main () { return test (); } diff --git a/gcc/testsuite/g++.old-deja/g++.eh/badalloc1.C b/gcc/testsuite/g++.old-deja/g++.eh/badalloc1.C new file mode 100644 index 000000000..cd902fbc3 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.eh/badalloc1.C @@ -0,0 +1,133 @@ +// This fails for VxWorks RTPs because the initialization of +// __cxa_allocate_exception's emergency buffer mutex will +// itself call malloc(), and will fail if there is no more +// memory available. +// { dg-do run { xfail { { xstormy16-*-* *-*-darwin[3-7]* } || vxworks_rtp } } } +// Copyright (C) 2000, 2002, 2003, 2010 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 6 June 2000 <nathan@codesourcery.com> + +// Check we can throw a bad_alloc exception when malloc dies. + +typedef __SIZE_TYPE__ size_t; +extern "C" void abort(); +extern "C" void *memcpy(void *, const void *, size_t); + +// Assume that STACK_SIZE defined implies a system that does not have a +// large data space either, and additionally that we're not linking against +// a shared libstdc++ (which requires quite a bit more initialization space). +#ifdef STACK_SIZE +const int arena_size = 256; +#else +#if defined(__FreeBSD__) || defined(__sun__) || defined(__hpux__) || defined(__osf__) +// FreeBSD, Solaris, HP-UX and Tru64 UNIX with threads require even more +// space at initialization time. FreeBSD 5 now requires over 131072 bytes. +const int arena_size = 262144; +#else +const int arena_size = 32768; +#endif +#endif + +struct object +{ + size_t size __attribute__((aligned)); +}; + +static char arena[arena_size] __attribute__((aligned)); +static size_t pos; + +// So we can force a failure when needed. +static int fail; + +extern "C" void *malloc (size_t size) +{ + object *p = reinterpret_cast<object *>(&arena[pos]); + + if (fail) + return 0; + + p->size = size; + size = (size + __alignof__(object) - 1) & - __alignof__(object); + pos += size + sizeof(object); + + // Verify that we didn't run out of memory before getting initialized. + if (pos > arena_size) + abort (); + + return p + 1; +} + +extern "C" void free (void *) +{ +} + +extern "C" void *realloc (void *p, size_t size) +{ + void *r; + + if (p) + { + object *o = reinterpret_cast<object *>(p) - 1; + size_t old_size = o->size; + + if (old_size >= size) + { + r = p; + o->size = size; + } + else + { + r = malloc (size); + memcpy (r, p, old_size); + free (p); + } + } + else + r = malloc (size); + + return r; +} + +void fn_throw() throw(int) +{ + throw 1; +} + +void fn_rethrow() throw(int) +{ + try{fn_throw();} + catch(int a){ + throw;} +} + +void fn_catchthrow() throw(int) +{ + try{fn_throw();} + catch(int a){ + throw a + 1;} +} + +int main() +{ + /* On some systems (including FreeBSD and Solaris 2.10), + __cxa_get_globals will try to call "malloc" when threads are in + use. Therefore, we throw one exception up front so that + __cxa_get_globals is all set up. Ideally, this would not be + necessary, but it is a well-known idiom, and using this technique + means that we can still validate the fact that exceptions can be + thrown when malloc fails. */ + try{fn_throw();} + catch(int a){} + + fail = 1; + + try{fn_throw();} + catch(int a){} + + try{fn_rethrow();} + catch(int a){} + + try{fn_catchthrow();} + catch(int a){} + + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.eh/catch1.C b/gcc/testsuite/g++.old-deja/g++.eh/catch1.C new file mode 100644 index 000000000..7aa70ac97 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.eh/catch1.C @@ -0,0 +1,18 @@ +// { dg-do assemble } +// +// Copyright (C) 1999 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 6 Jun 1999 <nathan@acm.org> + +// We cannot catch an incomplete type, or ptr to one + +struct A; // { dg-error "" } forward decl + +void fn() +{ + try {} + catch (A *p) {} // { dg-error "" } undefined type + try {} + catch (A p) {} // { dg-error "" } undefined type + try {} + catch (void const *p) {} // ok +} diff --git a/gcc/testsuite/g++.old-deja/g++.eh/catch10.C b/gcc/testsuite/g++.old-deja/g++.eh/catch10.C new file mode 100644 index 000000000..2300a9461 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.eh/catch10.C @@ -0,0 +1,22 @@ +// { dg-do assemble } +// Test that we notice unfortunate handler ordering. + +struct A { }; +struct B: public A { }; +struct C: private A { }; + +void f(); +void g() +{ + try { f(); } + catch (...) { } // { dg-error "" } ... followed by others + catch (A*) { } + + try { f(); } + catch (A*) { } // { dg-warning "" } A* before B* + catch (B*) { } // { dg-warning "" } A* before B* + + try { f(); } + catch (A*) { } + catch (C*) { } // no warning; A is private base +} diff --git a/gcc/testsuite/g++.old-deja/g++.eh/catch11.C b/gcc/testsuite/g++.old-deja/g++.eh/catch11.C new file mode 100644 index 000000000..275a96ac7 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.eh/catch11.C @@ -0,0 +1,64 @@ +// { dg-do run } +// Copyright (C) 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 24 May 2000 <nathan@codesourcery.com> + +// we should be able to catch a base a virtual, provided it is accessible by at +// least one public path +// -- public, << private, == virtual +// E<<B==A +// +--C==A +// +<<D==A + +struct A {}; +struct B : virtual A {}; +struct C : virtual A {}; +struct D : virtual A {}; +struct E : private B, public C, private D {}; + +extern "C" void abort (); + +void fne (E *e) +{ + throw e; +} + +void check(E *e) +{ + int caught; + + caught = 0; + try { fne(e); } + catch(A *p) { caught = 1; if (p != e) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fne(e); } + catch(B *p) { abort ();} + catch(...) { caught = 1; } + if (!caught) abort(); + + caught = 0; + try { fne(e); } + catch(C *p) { caught = 1; if (p != e) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fne(e); } + catch(D *p) { abort ();} + catch(...) { caught = 1; } + if (!caught) abort(); + + return; +} + +int main () +{ + E e; + + check (&e); + check ((E *)0); + + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.eh/catch12.C b/gcc/testsuite/g++.old-deja/g++.eh/catch12.C new file mode 100644 index 000000000..ae3b47cec --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.eh/catch12.C @@ -0,0 +1,64 @@ +// { dg-do run } +// Copyright (C) 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 24 May 2000 <nathan@codesourcery.com> + +// we should be able to catch a base a virtual, provided it is accessible by at +// least one public path +// -- public, << private, == virtual +// E--B<<==A +// +--C--==A +// +--D<<==A + +struct A {}; +struct B : private virtual A {}; +struct C : virtual A {}; +struct D : private virtual A {}; +struct E : public B, public C, public D {}; + +extern "C" void abort (); + +void fne (E *e) +{ + throw e; +} + +void check(E *e) +{ + int caught; + + caught = 0; + try { fne(e); } + catch(A *p) { caught = 1; if (p != e) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fne(e); } + catch(B *p) { caught = 1; if (p != e) abort();} + catch(...) { abort (); } + if (!caught) abort(); + + caught = 0; + try { fne(e); } + catch(C *p) { caught = 1; if (p != e) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fne(e); } + catch(D *p) { caught = 1; if (p != e) abort ();} + catch(...) { abort (); } + if (!caught) abort(); + + return; +} + +int main () +{ + E e; + + check (&e); + check ((E *)0); + + return 0; +} 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 000000000..2e0fdc8e7 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.eh/catch13.C @@ -0,0 +1,19 @@ +// { dg-do assemble } +// { dg-options "-O2" } +// Copyright (C) 2001 Free Software Foundation, Inc. +// Contributed by Jakub Jelinek 2 May 2001 <jakub@redhat.com> + + +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 000000000..7addb8827 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.eh/catch14.C @@ -0,0 +1,33 @@ +// { dg-do assemble } +// { dg-options "-O1" } +// Copyright (C) 2001 Free Software Foundation, Inc. +// Contributed by Jakub Jelinek 2 May 2001 <jakub@redhat.com> + + +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/catch2.C b/gcc/testsuite/g++.old-deja/g++.eh/catch2.C new file mode 100644 index 000000000..3520190a0 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.eh/catch2.C @@ -0,0 +1,11 @@ +// { dg-do assemble } +// Origin: Mike Danylchuk <miked@mpath.com> + +typedef char TCHAR; + +int main() +{ + try {} + catch( TCHAR* Err ) {} +} + diff --git a/gcc/testsuite/g++.old-deja/g++.eh/catch3.C b/gcc/testsuite/g++.old-deja/g++.eh/catch3.C new file mode 100644 index 000000000..2a717b36a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.eh/catch3.C @@ -0,0 +1,117 @@ +// { dg-do run } +// { dg-options "-w" } +// Copyright (C) 1999, 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 29 Aug 1999 <nathan@acm.org> + +// We cannot catch an ambiguous base class. Check with a non-virtual public +// DAG. +// -- public, << private, == virtual + +// D--B--A +// +--C--A + + +struct A { int m; }; +struct B : A { int m; }; +struct C : A { int m; }; +struct D : B, C { int m; }; + +void fna(A *obj) { throw obj; } +void fnb(B *obj) { throw obj; } +void fnc(C *obj) { throw obj; } +void fnd(D *obj) { throw obj; } + +extern "C" void abort(); + +void check(D *d) +{ + int caught; + + // try with whole object + caught = 0; + try { fnd(d); } + catch(A *p) { abort(); } // A is ambiguous + catch(D *p) { caught = 1; if (p != d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnd(d); } + catch(A *p) { abort(); } // A is ambiguous + catch(B *p) { caught = 1; if (p != d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnd(d); } + catch(A *p) { abort(); } // A is ambiguous + catch(C *p) { caught = 1; if (p != d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + // try with an A object + caught = 0; + try { fna((B *)d); } + catch(B *p) { abort(); } // throw type is static type + catch(A *p) { caught = 1; if (p != (B *)d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fna((C *)d); } + catch(C *p) { abort(); } // throw type is static type + catch(A *p) { caught = 1; if (p != (C *)d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + // try with B object + caught = 0; + try { fnb((B *)d); } + catch(A *p) { caught = 1; if (p != (B *)d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnb((B *)d); } + catch(B *p) { caught = 1; if (p != (B *)d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnb((B *)d); } + catch(C *p) { abort(); } + catch(D *p) { abort(); } + catch(...) { caught =1; } + if (!caught) abort(); + + // try with C object + caught = 0; + try { fnc((C *)d); } + catch(A *p) { caught = 1; if (p != (C *)d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnc((C *)d); } + catch(C *p) { caught = 1; if (p != d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnc((C *)d); } + catch(B *p) { abort(); } + catch(D *p) { abort(); } + catch(...) { caught =1; } + if (!caught) abort(); + + return; +} + +int main () +{ + D d; + check (&d); // try with an object + check ((D *)0); // try with no object + + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.eh/catch3p.C b/gcc/testsuite/g++.old-deja/g++.eh/catch3p.C new file mode 100644 index 000000000..c1332b37e --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.eh/catch3p.C @@ -0,0 +1,117 @@ +// { dg-do run } +// { dg-options "-w" } +// Copyright (C) 1999, 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 29 Aug 1999 <nathan@acm.org> + +// We cannot catch an ambiguous base class. Check with a non-virtual +// polymorphic public DAG. +// -- public, << private, == virtual + +// D--B--A +// +--C--A + + +struct A { int m; virtual ~A(){}}; +struct B : A { int m; }; +struct C : A { int m; }; +struct D : B, C { int m; }; + +void fna(A *obj) { throw obj; } +void fnb(B *obj) { throw obj; } +void fnc(C *obj) { throw obj; } +void fnd(D *obj) { throw obj; } + +extern "C" void abort(); + +void check(D *d) +{ + int caught; + + // try with whole object + caught = 0; + try { fnd(d); } + catch(A *p) { abort(); } // A is ambiguous + catch(D *p) { caught = 1; if (p != d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnd(d); } + catch(A *p) { abort(); } // A is ambiguous + catch(B *p) { caught = 1; if (p != d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnd(d); } + catch(A *p) { abort(); } // A is ambiguous + catch(C *p) { caught = 1; if (p != d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + // try with an A object + caught = 0; + try { fna((B *)d); } + catch(B *p) { abort(); } // throw type is static type + catch(A *p) { caught = 1; if (p != (B *)d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fna((C *)d); } + catch(C *p) { abort(); } // throw type is static type + catch(A *p) { caught = 1; if (p != (C *)d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + // try with B object + caught = 0; + try { fnb((B *)d); } + catch(A *p) { caught = 1; if (p != (B *)d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnb((B *)d); } + catch(B *p) { caught = 1; if (p != d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnb((B *)d); } + catch(C *p) { abort(); } + catch(D *p) { abort(); } + catch(...) { caught =1; } + if (!caught) abort(); + + // try with C object + caught = 0; + try { fnc((C *)d); } + catch(A *p) { caught = 1; if (p != (C *)d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnc((C *)d); } + catch(C *p) { caught = 1; if (p != d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnc((C *)d); } + catch(B *p) { abort(); } + catch(D *p) { abort(); } + catch(...) { caught =1; } + if (!caught) abort(); + + return; +} + +int main () +{ + D d; + check (&d); // try with an object + check ((D *)0); // try with no object + + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.eh/catch4.C b/gcc/testsuite/g++.old-deja/g++.eh/catch4.C new file mode 100644 index 000000000..1da91d0ad --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.eh/catch4.C @@ -0,0 +1,114 @@ +// { dg-do run } +// { dg-options "-w" } +// Copyright (C) 1999, 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 29 Aug 1999 <nathan@acm.org> + +// We cannot catch an ambiguous base class. Check with a virtual public +// DAG. +// -- public, << private, == virtual + +// D--B==A +// +--C==A + + +struct A { int m; }; +struct B : virtual A { int m; }; +struct C : virtual A { int m; }; +struct D : B, C { int m; }; + +void fna(A *obj) { throw obj; } +void fnb(B *obj) { throw obj; } +void fnc(C *obj) { throw obj; } +void fnd(D *obj) { throw obj; } + +extern "C" void abort(); + +void check(D *d) +{ + int caught; + + // try with whole object + caught = 0; + try { fnd(d); } + catch(A *p) { caught = 1; if (p != d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnd(d); } + catch(B *p) { caught = 1; if (p != d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnd(d); } + catch(C *p) { caught = 1; if (p != d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + // try with an A object + caught = 0; + try { fna((B *)d); } + catch(B *p) { abort(); } // throw type is static type + catch(A *p) { caught = 1; if (p != d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fna((C *)d); } + catch(C *p) { abort(); } // throw type is static type + catch(A *p) { caught = 1; if (p != d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + // try with B object + caught = 0; + try { fnb((B *)d); } + catch(A *p) { caught = 1; if (p != d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnb((B *)d); } + catch(B *p) { caught = 1; if (p != d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnb((B *)d); } + catch(C *p) { abort(); } + catch(D *p) { abort(); } + catch(...) { caught =1; } + if (!caught) abort(); + + // try with C object + caught = 0; + try { fnc((C *)d); } + catch(A *p) { caught = 1; if (p != d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnc((C *)d); } + catch(C *p) { caught = 1; if (p != d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnc((C *)d); } + catch(B *p) { abort(); } + catch(D *p) { abort(); } + catch(...) { caught =1; } + if (!caught) abort(); + + return; +} + +int main () +{ + D d; + check (&d); // try with an object + check ((D *)0); // try with no object + + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.eh/catch4p.C b/gcc/testsuite/g++.old-deja/g++.eh/catch4p.C new file mode 100644 index 000000000..6700a527a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.eh/catch4p.C @@ -0,0 +1,114 @@ +// { dg-do run } +// { dg-options "-w" } +// Copyright (C) 1999, 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 29 Aug 1999 <nathan@acm.org> + +// We cannot catch an ambiguous base class. Check with a virtual +// polymorphic public DAG. +// -- public, << private, == virtual + +// D--B==A +// +--C==A + + +struct A { int m; virtual ~A(){}}; +struct B : virtual A { int m; }; +struct C : virtual A { int m; }; +struct D : B, C { int m; }; + +void fna(A *obj) { throw obj; } +void fnb(B *obj) { throw obj; } +void fnc(C *obj) { throw obj; } +void fnd(D *obj) { throw obj; } + +extern "C" void abort(); + +void check(D *d) +{ + int caught; + + // try with whole object + caught = 0; + try { fnd(d); } + catch(A *p) { caught = 1; if (p != d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnd(d); } + catch(B *p) { caught = 1; if (p != d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnd(d); } + catch(C *p) { caught = 1; if (p != d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + // try with an A object + caught = 0; + try { fna((B *)d); } + catch(B *p) { abort(); } // throw type is static type + catch(A *p) { caught = 1; if (p != d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fna((C *)d); } + catch(C *p) { abort(); } // throw type is static type + catch(A *p) { caught = 1; if (p != d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + // try with B object + caught = 0; + try { fnb((B *)d); } + catch(A *p) { caught = 1; if (p != d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnb((B *)d); } + catch(B *p) { caught = 1; if (p != d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnb((B *)d); } + catch(C *p) { abort(); } + catch(D *p) { abort(); } + catch(...) { caught =1; } + if (!caught) abort(); + + // try with C object + caught = 0; + try { fnc((C *)d); } + catch(A *p) { caught = 1; if (p != d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnc((C *)d); } + catch(C *p) { caught = 1; if (p != d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnc((C *)d); } + catch(B *p) { abort(); } + catch(D *p) { abort(); } + catch(...) { caught =1; } + if (!caught) abort(); + + return; +} + +int main () +{ + D d; + check (&d); // try with an object + check ((D *)0); // try with no object + + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.eh/catch5.C b/gcc/testsuite/g++.old-deja/g++.eh/catch5.C new file mode 100644 index 000000000..1fae7f504 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.eh/catch5.C @@ -0,0 +1,154 @@ +// { dg-do run } +// { dg-options "-w" } +// Copyright (C) 1999, 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 29 Aug 1999 <nathan@acm.org> + +// We cannot catch an ambiguous base class. +// -- public, << private, == virtual + +// D--B==A +// +--C==A +// +--AA-A + + +struct A { int m; }; +struct B : virtual A { int m; }; +struct C : virtual A { int m; }; +struct AA : A { int m; }; +struct D : B, C, AA { int m; }; + +void fna(A *obj) { throw obj; } +void fnb(B *obj) { throw obj; } +void fnc(C *obj) { throw obj; } +void fnd(D *obj) { throw obj; } +void fnaa(AA *obj) { throw obj; } + +extern "C" void abort(); + +void check(D *d) +{ + int caught; + + // try with whole object + caught = 0; + try { fnd(d); } + catch(A *p) { abort(); } // A is ambiguous + catch(D *p) { caught = 1; if (p != d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnd(d); } + catch(A *p) { abort(); } // A is ambiguous + catch(B *p) { caught = 1; if (p != d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnd(d); } + catch(A *p) { abort(); } // A is ambiguous + catch(C *p) { caught = 1; if (p != d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnd(d); } + catch(A *p) { abort(); } // A is ambiguous + catch(AA *p) { caught = 1; if (p != d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + // try with an A object + caught = 0; + try { fna((B *)d); } + catch(B *p) { abort(); } // throw type is static type + catch(A *p) { caught = 1; if (p != (B *)d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fna((C *)d); } + catch(C *p) { abort(); } // throw type is static type + catch(A *p) { caught = 1; if (p != (C *)d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fna((AA *)d); } + catch(AA *p) { abort(); } // throw type is static type + catch(A *p) { caught = 1; if (p != (AA *)d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + // try with B object + caught = 0; + try { fnb((B *)d); } + catch(A *p) { caught = 1; if (p != (B *)d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnb((B *)d); } + catch(B *p) { caught = 1; if (p != d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnb((B *)d); } + catch(C *p) { abort(); } + catch(D *p) { abort(); } + catch(...) { caught =1; } + if (!caught) abort(); + + // try with C object + caught = 0; + try { fnc((C *)d); } + catch(A *p) { caught = 1; if (p != (C *)d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnc((C *)d); } + catch(C *p) { caught = 1; if (p != d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnc((C *)d); } + catch(B *p) { abort(); } + catch(D *p) { abort(); } + catch(...) { caught =1; } + if (!caught) abort(); + + // try with AA object + caught = 0; + try { fnaa((AA *)d); } + catch(A *p) { caught = 1; if (p != (AA *)d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnaa((AA *)d); } + catch(AA *p) { caught = 1; if (p != d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnaa((AA *)d); } + catch(C *p) { abort(); } + catch(B *p) { abort(); } + catch(D *p) { abort(); } + catch(...) { caught =1; } + if (!caught) abort(); + + return; +} + +int main () +{ + D d; + check (&d); // try with an object + check ((D *)0); // try with no object + + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.eh/catch5p.C b/gcc/testsuite/g++.old-deja/g++.eh/catch5p.C new file mode 100644 index 000000000..8ae8d65b4 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.eh/catch5p.C @@ -0,0 +1,154 @@ +// { dg-do run } +// { dg-options "-w" } +// Copyright (C) 1999, 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 29 Aug 1999 <nathan@acm.org> + +// We cannot catch an ambiguous base class. +// -- public, << private, == virtual + +// D--B==A +// +--C==A +// +--AA-A + + +struct A { int m; virtual ~A(){}}; +struct B : virtual A { int m; }; +struct C : virtual A { int m; }; +struct AA : A { int m; }; +struct D : B, C, AA { int m; }; + +void fna(A *obj) { throw obj; } +void fnb(B *obj) { throw obj; } +void fnc(C *obj) { throw obj; } +void fnd(D *obj) { throw obj; } +void fnaa(AA *obj) { throw obj; } + +extern "C" void abort(); + +void check(D *d) +{ + int caught; + + // try with whole object + caught = 0; + try { fnd(d); } + catch(A *p) { abort(); } // A is ambiguous + catch(D *p) { caught = 1; if (p != d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnd(d); } + catch(A *p) { abort(); } // A is ambiguous + catch(B *p) { caught = 1; if (p != d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnd(d); } + catch(A *p) { abort(); } // A is ambiguous + catch(C *p) { caught = 1; if (p != d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnd(d); } + catch(A *p) { abort(); } // A is ambiguous + catch(AA *p) { caught = 1; if (p != d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + // try with an A object + caught = 0; + try { fna((B *)d); } + catch(B *p) { abort(); } // throw type is static type + catch(A *p) { caught = 1; if (p != (B *)d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fna((C *)d); } + catch(C *p) { abort(); } // throw type is static type + catch(A *p) { caught = 1; if (p != (C *)d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fna((AA *)d); } + catch(AA *p) { abort(); } // throw type is static type + catch(A *p) { caught = 1; if (p != (AA *)d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + // try with B object + caught = 0; + try { fnb((B *)d); } + catch(A *p) { caught = 1; if (p != (B *)d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnb((B *)d); } + catch(B *p) { caught = 1; if (p != d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnb((B *)d); } + catch(C *p) { abort(); } + catch(D *p) { abort(); } + catch(...) { caught =1; } + if (!caught) abort(); + + // try with C object + caught = 0; + try { fnc((C *)d); } + catch(A *p) { caught = 1; if (p != (C *)d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnc((C *)d); } + catch(C *p) { caught = 1; if (p != d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnc((C *)d); } + catch(B *p) { abort(); } + catch(D *p) { abort(); } + catch(...) { caught =1; } + if (!caught) abort(); + + // try with AA object + caught = 0; + try { fnaa((AA *)d); } + catch(A *p) { caught = 1; if (p != (AA *)d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnaa((AA *)d); } + catch(AA *p) { caught = 1; if (p != d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnaa((AA *)d); } + catch(C *p) { abort(); } + catch(B *p) { abort(); } + catch(D *p) { abort(); } + catch(...) { caught =1; } + if (!caught) abort(); + + return; +} + +int main () +{ + D d; + check (&d); // try with an object + check ((D *)0); // try with no object + + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.eh/catch6.C b/gcc/testsuite/g++.old-deja/g++.eh/catch6.C new file mode 100644 index 000000000..d60d43ea9 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.eh/catch6.C @@ -0,0 +1,185 @@ +// { dg-do run } +// { dg-options "-w" } +// Copyright (C) 1999, 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 29 Aug 1999 <nathan@acm.org> + +// We cannot catch an ambiguous base class. +// -- public, << private, == virtual + +// E==D--B==A +// +--C==A +// +--AA-A + + +struct A { int m; }; +struct B : virtual A { int m; }; +struct C : virtual A { int m; }; +struct AA : A { int m; }; +struct D : B, C, AA { int m; }; +struct E : virtual D { int m; }; + +void fna(A *obj) { throw obj; } +void fnb(B *obj) { throw obj; } +void fnc(C *obj) { throw obj; } +void fnd(D *obj) { throw obj; } +void fnaa(AA *obj) { throw obj; } +void fne(E *obj) { throw obj; } + +extern "C" void abort(); + +void check(E *e) +{ + int caught; + + // try with whole object + caught = 0; + try { fne(e); } + catch(A *p) { abort(); } // A is ambiguous + catch(D *p) { caught = 1; if (p != e) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fne(e); } + catch(A *p) { abort(); } // A is ambiguous + catch(B *p) { caught = 1; if (p != e) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fne(e); } + catch(A *p) { abort(); } // A is ambiguous + catch(C *p) { caught = 1; if (p != e) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fne(e); } + catch(A *p) { abort(); } // A is ambiguous + catch(AA *p) { caught = 1; if (p != e) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + // try with D oject + caught = 0; + try { fnd((D *)e); } + catch(A *p) { abort(); } // A is ambiguous + catch(D *p) { caught = 1; if (p != e) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnd((D *)e); } + catch(A *p) { abort(); } // A is ambiguous + catch(B *p) { caught = 1; if (p != e) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnd((D *)e); } + catch(A *p) { abort(); } // A is ambiguous + catch(C *p) { caught = 1; if (p != e) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnd((D *)e); } + catch(A *p) { abort(); } // A is ambiguous + catch(AA *p) { caught = 1; if (p != e) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + // try with an A object + caught = 0; + try { fna((B *)e); } + catch(B *p) { abort(); } // throw type is static type + catch(A *p) { caught = 1; if (p != (B *)e) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fna((C *)e); } + catch(C *p) { abort(); } // throw type is static type + catch(A *p) { caught = 1; if (p != (C *)e) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fna((AA *)e); } + catch(AA *p) { abort(); } // throw type is static type + catch(A *p) { caught = 1; if (p != (AA *)e) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + // try with B object + caught = 0; + try { fnb((B *)e); } + catch(A *p) { caught = 1; if (p != (B *)e) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnb((B *)e); } + catch(B *p) { caught = 1; if (p != e) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnb((B *)e); } + catch(C *p) { abort(); } + catch(D *p) { abort(); } + catch(...) { caught =1; } + if (!caught) abort(); + + // try with C object + caught = 0; + try { fnc((C *)e); } + catch(A *p) { caught = 1; if (p != (C *)e) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnc((C *)e); } + catch(C *p) { caught = 1; if (p != e) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnc((C *)e); } + catch(B *p) { abort(); } + catch(D *p) { abort(); } + catch(...) { caught =1; } + if (!caught) abort(); + + // try with AA object + caught = 0; + try { fnaa((AA *)e); } + catch(A *p) { caught = 1; if (p != (AA *)e) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnaa((AA *)e); } + catch(AA *p) { caught = 1; if (p != e) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnaa((AA *)e); } + catch(C *p) { abort(); } + catch(B *p) { abort(); } + catch(D *p) { abort(); } + catch(...) { caught =1; } + if (!caught) abort(); + + return; +} + +int main () +{ + E e; + check (&e); // try with an object + check ((E *)0); // try with no object + + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.eh/catch6p.C b/gcc/testsuite/g++.old-deja/g++.eh/catch6p.C new file mode 100644 index 000000000..c73ac2c41 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.eh/catch6p.C @@ -0,0 +1,185 @@ +// { dg-do run } +// { dg-options "-w" } +// Copyright (C) 1999, 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 29 Aug 1999 <nathan@acm.org> + +// We cannot catch an ambiguous base class. +// -- public, << private, == virtual + +// E==D--B==A +// +--C==A +// +--AA-A + + +struct A { int m; virtual ~A(){}}; +struct B : virtual A { int m; }; +struct C : virtual A { int m; }; +struct AA : A { int m; }; +struct D : B, C, AA { int m; }; +struct E : virtual D { int m; }; + +void fna(A *obj) { throw obj; } +void fnb(B *obj) { throw obj; } +void fnc(C *obj) { throw obj; } +void fnd(D *obj) { throw obj; } +void fnaa(AA *obj) { throw obj; } +void fne(E *obj) { throw obj; } + +extern "C" void abort(); + +void check(E *e) +{ + int caught; + + // try with whole object + caught = 0; + try { fne(e); } + catch(A *p) { abort(); } // A is ambiguous + catch(D *p) { caught = 1; if (p != e) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fne(e); } + catch(A *p) { abort(); } // A is ambiguous + catch(B *p) { caught = 1; if (p != e) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fne(e); } + catch(A *p) { abort(); } // A is ambiguous + catch(C *p) { caught = 1; if (p != e) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fne(e); } + catch(A *p) { abort(); } // A is ambiguous + catch(AA *p) { caught = 1; if (p != e) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + // try with D oject + caught = 0; + try { fnd((D *)e); } + catch(A *p) { abort(); } // A is ambiguous + catch(D *p) { caught = 1; if (p != e) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnd((D *)e); } + catch(A *p) { abort(); } // A is ambiguous + catch(B *p) { caught = 1; if (p != e) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnd((D *)e); } + catch(A *p) { abort(); } // A is ambiguous + catch(C *p) { caught = 1; if (p != e) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnd((D *)e); } + catch(A *p) { abort(); } // A is ambiguous + catch(AA *p) { caught = 1; if (p != e) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + // try with an A object + caught = 0; + try { fna((B *)e); } + catch(B *p) { abort(); } // throw type is static type + catch(A *p) { caught = 1; if (p != (B *)e) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fna((C *)e); } + catch(C *p) { abort(); } // throw type is static type + catch(A *p) { caught = 1; if (p != (C *)e) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fna((AA *)e); } + catch(AA *p) { abort(); } // throw type is static type + catch(A *p) { caught = 1; if (p != (AA *)e) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + // try with B object + caught = 0; + try { fnb((B *)e); } + catch(A *p) { caught = 1; if (p != (B *)e) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnb((B *)e); } + catch(B *p) { caught = 1; if (p != e) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnb((B *)e); } + catch(C *p) { abort(); } + catch(D *p) { abort(); } + catch(...) { caught =1; } + if (!caught) abort(); + + // try with C object + caught = 0; + try { fnc((C *)e); } + catch(A *p) { caught = 1; if (p != (C *)e) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnc((C *)e); } + catch(C *p) { caught = 1; if (p != e) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnc((C *)e); } + catch(B *p) { abort(); } + catch(D *p) { abort(); } + catch(...) { caught =1; } + if (!caught) abort(); + + // try with AA object + caught = 0; + try { fnaa((AA *)e); } + catch(A *p) { caught = 1; if (p != (AA *)e) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnaa((AA *)e); } + catch(AA *p) { caught = 1; if (p != e) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnaa((AA *)e); } + catch(C *p) { abort(); } + catch(B *p) { abort(); } + catch(D *p) { abort(); } + catch(...) { caught =1; } + if (!caught) abort(); + + return; +} + +int main () +{ + E e; + check (&e); // try with an object + check ((E *)0); // try with no object + + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.eh/catch7.C b/gcc/testsuite/g++.old-deja/g++.eh/catch7.C new file mode 100644 index 000000000..936b67ca7 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.eh/catch7.C @@ -0,0 +1,184 @@ +// { dg-do run } +// { dg-options "-w" } +// Copyright (C) 1999, 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 29 Aug 1999 <nathan@acm.org> + +// We cannot catch an ambiguous base class. +// -- public, << private, == virtual + +// different levels +// F--D--B--A +// +--C--A +// +--E--A + + +struct A { int m; }; +struct B : A { int m; }; +struct C : A { int m; }; +struct D : B, C { int m; }; +struct E : A { int m; }; +struct F : D, E { int m; }; + +void fna(A *obj) { throw obj; } +void fnb(B *obj) { throw obj; } +void fnc(C *obj) { throw obj; } +void fnd(D *obj) { throw obj; } +void fne(E *obj) { throw obj; } +void fnf(F *obj) { throw obj; } + +extern "C" void abort(); + +void check(F *f) +{ + int caught; + + // try with whole object + caught = 0; + try { fnf(f); } + catch(A *p) { abort(); } // A is ambiguous + catch(F *p) { caught = 1; if (p != f) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnf(f); } + catch(A *p) { abort(); } // A is ambiguous + catch(E *p) { caught = 1; if (p != f) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnf(f); } + catch(A *p) { abort(); } // A is ambiguous + catch(D *p) { caught = 1; if (p != f) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnf(f); } + catch(A *p) { abort(); } // A is ambiguous + catch(B *p) { caught = 1; if (p != f) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnf(f); } + catch(A *p) { abort(); } // A is ambiguous + catch(C *p) { caught = 1; if (p != f) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + // try with D object + caught = 0; + try { fnd(f); } + catch(A *p) { abort(); } // A is ambiguous + catch(D *p) { caught = 1; if (p != f) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnd(f); } + catch(A *p) { abort(); } // A is ambiguous + catch(B *p) { caught = 1; if (p != f) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnd(f); } + catch(A *p) { abort(); } // A is ambiguous + catch(C *p) { caught = 1; if (p != f) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + // try with E object + caught = 0; + try { fne(f); } + catch(A *p) { caught = 1; if (p != (E *)f) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fne(f); } + catch(E *p) { caught = 1; if (p != f) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fne(f); } + catch(F *p) { abort(); } + catch(...) { caught = 1; } + if (!caught) abort(); + + // try with an A object + caught = 0; + try { fna((B *)f); } + catch(B *p) { abort(); } // throw type is static type + catch(A *p) { caught = 1; if (p != (B *)f) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fna((C *)f); } + catch(C *p) { abort(); } // throw type is static type + catch(A *p) { caught = 1; if (p != (C *)f) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fna((E *)f); } + catch(E *p) { abort(); } // throw type is static type + catch(A *p) { caught = 1; if (p != (E *)f) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + // try with B object + caught = 0; + try { fnb((B *)f); } + catch(A *p) { caught = 1; if (p != (B *)f) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnb((B *)f); } + catch(B *p) { caught = 1; if (p != f) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnb((B *)f); } + catch(C *p) { abort(); } + catch(D *p) { abort(); } + catch(...) { caught =1; } + if (!caught) abort(); + + // try with C object + caught = 0; + try { fnc((C *)f); } + catch(A *p) { caught = 1; if (p != (C *)f) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnc((C *)f); } + catch(C *p) { caught = 1; if (p != f) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnc((C *)f); } + catch(B *p) { abort(); } + catch(D *p) { abort(); } + catch(...) { caught =1; } + if (!caught) abort(); + + return; +} + +int main () +{ + F f; + check (&f); // try with an object + check ((F *)0); // try with no object + + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.eh/catch7p.C b/gcc/testsuite/g++.old-deja/g++.eh/catch7p.C new file mode 100644 index 000000000..5f15a48fc --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.eh/catch7p.C @@ -0,0 +1,184 @@ +// { dg-do run } +// { dg-options "-w" } +// Copyright (C) 1999, 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 29 Aug 1999 <nathan@acm.org> + +// We cannot catch an ambiguous base class. +// -- public, << private, == virtual + +// different levels +// F--D--B--A +// +--C--A +// +--E--A + + +struct A { int m; virtual ~A(){}}; +struct B : A { int m; }; +struct C : A { int m; }; +struct D : B, C { int m; }; +struct E : A { int m; }; +struct F : D, E { int m; }; + +void fna(A *obj) { throw obj; } +void fnb(B *obj) { throw obj; } +void fnc(C *obj) { throw obj; } +void fnd(D *obj) { throw obj; } +void fne(E *obj) { throw obj; } +void fnf(F *obj) { throw obj; } + +extern "C" void abort(); + +void check(F *f) +{ + int caught; + + // try with whole object + caught = 0; + try { fnf(f); } + catch(A *p) { abort(); } // A is ambiguous + catch(F *p) { caught = 1; if (p != f) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnf(f); } + catch(A *p) { abort(); } // A is ambiguous + catch(E *p) { caught = 1; if (p != f) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnf(f); } + catch(A *p) { abort(); } // A is ambiguous + catch(D *p) { caught = 1; if (p != f) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnf(f); } + catch(A *p) { abort(); } // A is ambiguous + catch(B *p) { caught = 1; if (p != f) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnf(f); } + catch(A *p) { abort(); } // A is ambiguous + catch(C *p) { caught = 1; if (p != f) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + // try with D object + caught = 0; + try { fnd(f); } + catch(A *p) { abort(); } // A is ambiguous + catch(D *p) { caught = 1; if (p != f) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnd(f); } + catch(A *p) { abort(); } // A is ambiguous + catch(B *p) { caught = 1; if (p != f) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnd(f); } + catch(A *p) { abort(); } // A is ambiguous + catch(C *p) { caught = 1; if (p != f) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + // try with E object + caught = 0; + try { fne(f); } + catch(A *p) { caught = 1; if (p != (E *)f) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fne(f); } + catch(E *p) { caught = 1; if (p != f) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fne(f); } + catch(F *p) { abort(); } + catch(...) { caught = 1; } + if (!caught) abort(); + + // try with an A object + caught = 0; + try { fna((B *)f); } + catch(B *p) { abort(); } // throw type is static type + catch(A *p) { caught = 1; if (p != (B *)f) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fna((C *)f); } + catch(C *p) { abort(); } // throw type is static type + catch(A *p) { caught = 1; if (p != (C *)f) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fna((E *)f); } + catch(E *p) { abort(); } // throw type is static type + catch(A *p) { caught = 1; if (p != (E *)f) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + // try with B object + caught = 0; + try { fnb((B *)f); } + catch(A *p) { caught = 1; if (p != (B *)f) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnb((B *)f); } + catch(B *p) { caught = 1; if (p != f) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnb((B *)f); } + catch(C *p) { abort(); } + catch(D *p) { abort(); } + catch(...) { caught =1; } + if (!caught) abort(); + + // try with C object + caught = 0; + try { fnc((C *)f); } + catch(A *p) { caught = 1; if (p != (C *)f) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnc((C *)f); } + catch(C *p) { caught = 1; if (p != f) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnc((C *)f); } + catch(B *p) { abort(); } + catch(D *p) { abort(); } + catch(...) { caught =1; } + if (!caught) abort(); + + return; +} + +int main () +{ + F f; + check (&f); // try with an object + check ((F *)0); // try with no object + + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.eh/catch8.C b/gcc/testsuite/g++.old-deja/g++.eh/catch8.C new file mode 100644 index 000000000..1947c1c02 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.eh/catch8.C @@ -0,0 +1,110 @@ +// { dg-do run } +// { dg-options "-w" } +// Copyright (C) 1999, 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 6 Jun 1999 <nathan@acm.org> + +// We cannot catch an ambiguous base class. +// -- public, << private, == virtual + +// D--B--A +// +--C<<A + + +struct A { int m; }; +struct B : A { int m; }; +struct C : private A { int m; }; +struct D : B, C { int m; }; + +void fna(A *obj) { throw obj; } +void fnb(B *obj) { throw obj; } +void fnc(C *obj) { throw obj; } +void fnd(D *obj) { throw obj; } + +extern "C" void abort(); + +void check(D *d) +{ + int caught; + + // try with whole object + caught = 0; + try { fnd(d); } + catch(A *p) { abort(); } // A is ambiguous + catch(D *p) { caught = 1; if (p != d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnd(d); } + catch(A *p) { abort(); } // A is ambiguous + catch(B *p) { caught = 1; if (p != d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnd(d); } + catch(A *p) { abort(); } // A is ambiguous + catch(C *p) { caught = 1; if (p != d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + // try with an A object + caught = 0; + try { fna((B *)d); } + catch(B *p) { abort(); } // throw type is static type + catch(A *p) { caught = 1; if (p != (B *)d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fna((A *)(C *)d); } + catch(C *p) { abort(); } // throw type is static type + catch(A *p) { caught = 1; if (p != (A *)(C *)d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + // try with B object + caught = 0; + try { fnb((B *)d); } + catch(A *p) { caught = 1; if (p != (B *)d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnb((B *)d); } + catch(B *p) { caught = 1; if (p != d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnb((B *)d); } + catch(C *p) { abort(); } + catch(D *p) { abort(); } + catch(...) { caught =1; } + if (!caught) abort(); + + caught = 0; + try { fnc((C *)d); } + catch(A *p) { abort();} + catch(C *p) { caught = 1; if (p != d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnc((C *)d); } + catch(B *p) { abort(); } + catch(D *p) { abort(); } + catch(...) { caught =1; } + if (!caught) abort(); + + return; +} + +int main () +{ + D d; + check (&d); // try with an object + check ((D *)0); // try with no object + + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.eh/catch8p.C b/gcc/testsuite/g++.old-deja/g++.eh/catch8p.C new file mode 100644 index 000000000..56fafcf98 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.eh/catch8p.C @@ -0,0 +1,111 @@ +// { dg-do run } +// { dg-options "-w" } +// Copyright (C) 1999, 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 6 Jun 1999 <nathan@acm.org> + +// We cannot catch an ambiguous base class. +// -- public, << private, == virtual + +// D--B--A +// +--C<<A + + +struct A { int m; virtual ~A(){}}; +struct B : A { int m; }; +struct C : private A { int m; }; +struct D : B, C { int m; }; + +void fna(A *obj) { throw obj; } +void fnb(B *obj) { throw obj; } +void fnc(C *obj) { throw obj; } +void fnd(D *obj) { throw obj; } + +extern "C" void abort(); + +void check(D *d) +{ + int caught; + + // try with whole object + caught = 0; + try { fnd(d); } + catch(A *p) { abort(); } // A is ambiguous + catch(D *p) { caught = 1; if (p != d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnd(d); } + catch(A *p) { abort(); } // A is ambiguous + catch(B *p) { caught = 1; if (p != d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnd(d); } + catch(A *p) { abort(); } // A is ambiguous + catch(C *p) { caught = 1; if (p != d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + // try with an A object + caught = 0; + try { fna((B *)d); } + catch(B *p) { abort(); } // throw type is static type + catch(A *p) { caught = 1; if (p != (B *)d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fna((A *)(C *)d); } + catch(C *p) { abort(); } // throw type is static type + catch(A *p) { caught = 1; if (p != (A *)(C *)d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + // try with B object + caught = 0; + try { fnb((B *)d); } + catch(A *p) { caught = 1; if (p != (B *)d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnb((B *)d); } + catch(B *p) { caught = 1; if (p != d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnb((B *)d); } + catch(C *p) { abort(); } + catch(D *p) { abort(); } + catch(...) { caught =1; } + if (!caught) abort(); + + // try with C object + caught = 0; + try { fnc((C *)d); } + catch(A *p) { abort();} + catch(C *p) { caught = 1; if (p != d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnc((C *)d); } + catch(B *p) { abort(); } + catch(D *p) { abort(); } + catch(...) { caught =1; } + if (!caught) abort(); + + return; +} + +int main () +{ + D d; + check (&d); // try with an object + check ((D *)0); // try with no object + + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.eh/catch9.C b/gcc/testsuite/g++.old-deja/g++.eh/catch9.C new file mode 100644 index 000000000..f4938a398 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.eh/catch9.C @@ -0,0 +1,117 @@ +// { dg-do run } +// { dg-options "-w" } +// Copyright (C) 1999, 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 29 Aug 1999 <nathan@acm.org> + +// We cannot catch an ambiguous base class. +// -- public, << private, == virtual + +// D==B--A +// +==C--A + + +struct A { int m; }; +struct B : A { int m; }; +struct C : A { int m; }; +struct D : virtual B, virtual C { int m; }; + + +void fna(A *obj) { throw obj; } +void fnb(B *obj) { throw obj; } +void fnc(C *obj) { throw obj; } +void fnd(D *obj) { throw obj; } + +extern "C" void abort(); + +void check(D *d) +{ + int caught; + + // try with whole object + caught = 0; + try { fnd(d); } + catch(A *p) { abort(); } // A is ambiguous + catch(D *p) { caught = 1; if (p != d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnd(d); } + catch(A *p) { abort(); } // A is ambiguous + catch(B *p) { caught = 1; if (p != d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnd(d); } + catch(A *p) { abort(); } // A is ambiguous + catch(C *p) { caught = 1; if (p != d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + // try with an A object + caught = 0; + try { fna((B *)d); } + catch(B *p) { abort(); } // throw type is static type + catch(A *p) { caught = 1; if (p != (B *)d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fna((C *)d); } + catch(C *p) { abort(); } // throw type is static type + catch(A *p) { caught = 1; if (p != (C *)d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + // try with B object + caught = 0; + try { fnb((B *)d); } + catch(A *p) { caught = 1; if (p != (B *)d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnb((B *)d); } + catch(B *p) { caught = 1; if (p != (B *)d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnb((B *)d); } + catch(C *p) { abort(); } + catch(D *p) { abort(); } + catch(...) { caught =1; } + if (!caught) abort(); + + // try with C object + caught = 0; + try { fnc((C *)d); } + catch(A *p) { caught = 1; if (p != (C *)d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnc((C *)d); } + catch(C *p) { caught = 1; if (p != (C *)d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnc((C *)d); } + catch(B *p) { abort(); } + catch(D *p) { abort(); } + catch(...) { caught =1; } + if (!caught) abort(); + + return; +} + +int main () +{ + D d; + check (&d); // try with an object + check ((D *)0); // try with no object + + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.eh/catch9p.C b/gcc/testsuite/g++.old-deja/g++.eh/catch9p.C new file mode 100644 index 000000000..9cec7e7d6 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.eh/catch9p.C @@ -0,0 +1,117 @@ +// { dg-do run } +// { dg-options "-w" } +// Copyright (C) 1999, 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 29 Aug 1999 <nathan@acm.org> + +// We cannot catch an ambiguous base class. +// -- public, << private, == virtual + +// D==B--A +// +==C--A + + +struct A { int m; virtual ~A(){}}; +struct B : A { int m; }; +struct C : A { int m; }; +struct D : virtual B, virtual C { int m; }; + + +void fna(A *obj) { throw obj; } +void fnb(B *obj) { throw obj; } +void fnc(C *obj) { throw obj; } +void fnd(D *obj) { throw obj; } + +extern "C" void abort(); + +void check(D *d) +{ + int caught; + + // try with whole object + caught = 0; + try { fnd(d); } + catch(A *p) { abort(); } // A is ambiguous + catch(D *p) { caught = 1; if (p != d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnd(d); } + catch(A *p) { abort(); } // A is ambiguous + catch(B *p) { caught = 1; if (p != d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnd(d); } + catch(A *p) { abort(); } // A is ambiguous + catch(C *p) { caught = 1; if (p != d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + // try with an A object + caught = 0; + try { fna((B *)d); } + catch(B *p) { abort(); } // throw type is static type + catch(A *p) { caught = 1; if (p != (B *)d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fna((C *)d); } + catch(C *p) { abort(); } // throw type is static type + catch(A *p) { caught = 1; if (p != (C *)d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + // try with B object + caught = 0; + try { fnb((B *)d); } + catch(A *p) { caught = 1; if (p != (B *)d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnb((B *)d); } + catch(B *p) { caught = 1; if (p != d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnb((B *)d); } + catch(C *p) { abort(); } + catch(D *p) { abort(); } + catch(...) { caught =1; } + if (!caught) abort(); + + // try with C object + caught = 0; + try { fnc((C *)d); } + catch(A *p) { caught = 1; if (p != (C *)d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnc((C *)d); } + catch(C *p) { caught = 1; if (p != d) abort();} + catch(...) { abort(); } + if (!caught) abort(); + + caught = 0; + try { fnc((C *)d); } + catch(B *p) { abort(); } + catch(D *p) { abort(); } + catch(...) { caught =1; } + if (!caught) abort(); + + return; +} + +int main () +{ + D d; + check (&d); // try with an object + check ((D *)0); // try with no object + + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.eh/catchptr1.C b/gcc/testsuite/g++.old-deja/g++.eh/catchptr1.C new file mode 100644 index 000000000..2d2467548 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.eh/catchptr1.C @@ -0,0 +1,262 @@ +// { dg-do run } +// Test pointer chain catching +// Copyright (C) 2000, 2002 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 9 Apr 2000 <nathan@nathan@codesourcery.com> + +#include <stdio.h> + +void fn () {} +struct A {void fn () {}}; +static int var = 1; +static const int const_var = 2; + +struct B; +struct C; + +int test0 () +{ + try + { + throw &fn; + } + catch (void *) + { + // should not decay to void * + return 1; + } + catch (...) + { + return 0; + } + return -1; +} + +int test1 () +{ + try + { + throw &A::fn; + } + catch (void *) + { + // should not decay to void * + return 1; + } + catch (...) + { + return 0; + } + return -1; +} + +int test2 () +{ + try + { + throw &var; + } + catch (void *) + { + // should decay to void * + return 0; + } + catch (...) + { + return 1; + } + return -1; +} + +int test3 () +{ + try + { + throw &var; + } + catch (void const *) + { + // should decay to const void * + return 0; + } + catch (...) + { + return 1; + } + return -1; +} + +int test4 () +{ + try + { + throw &const_var; + } + catch (void *) + { + // should not decay to void * + return 1; + } + catch (void const *) + { + // should decay to const void * + return 0; + } + catch (...) + { + return 2; + } + return -1; +} + +int test5 () +{ + try + { + throw (void ***)0; + } + catch (void ***) + { + return 0; + } + catch (...) + { + return 1; + } + return -1; +} + +int test6 () +{ + try + { + throw (void const* const* const*)0; + } + catch (void ***) + { + return 1; + } + catch (void * const* const*) + { + return 2; + } + catch (void const* * const*) + { + return 3; + } + catch (void const* const* *) + { + return 4; + } + catch (void const* const* const *) + { + return 0; + } + catch (...) + { + return 1; + } + return -1; +} + +int test7 () +{ + try + { + throw (void ***)0; + } + catch (void const* const**) + { + return 1; + } + catch (void const** const *) + { + return 2; + } + catch (void * const* const *) + { + return 0; + } + catch (...) + { + return 3; + } + return -1; +} + +int test8 () +{ + try + { + throw (B **)0; + } + catch (C **) + { + return 1; + } + catch (B **) + { + return 0; + } + catch (...) + { + return 2; + } + return -1; +} + +int test9 () +{ + try + { + throw (B **)0; + } + catch (C const *const *) + { + return 1; + } + catch (B const *const *) + { + return 0; + } + catch (...) + { + return 2; + } + return -1; +} + +static int (*tests[])() = +{ + test0, + test1, + test2, + test3, + test4, + + test5, + test6, + test7, + + test8, + test9, + + NULL +}; + +int main () +{ + int ix; + int errors = 0; + + for (ix = 0; tests[ix]; ix++) + { + int n = tests[ix] (); + + if (n) + { + printf ("test %d failed %d\n", ix, n); + errors++; + } + } + return errors; +} diff --git a/gcc/testsuite/g++.old-deja/g++.eh/cleanup1.C b/gcc/testsuite/g++.old-deja/g++.eh/cleanup1.C new file mode 100644 index 000000000..16646438e --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.eh/cleanup1.C @@ -0,0 +1,35 @@ +// { dg-do run } +// Bug: obj gets destroyed twice because the fixups for the return are +// inside its cleanup region. + +extern "C" int printf (const char *, ...); + +int d; + +struct myExc { }; + +struct myExcRaiser { + ~myExcRaiser() { throw myExc(); } +}; + +struct stackObj { + ~stackObj() { ++d; printf ("stackObj::~stackObj()\n"); } +}; + +int test() +{ + myExcRaiser rais; + stackObj obj; + return 0; +} + +int main() +{ + try { + test(); + } + catch (myExc &) { + return d != 1; + } + return 1; +} diff --git a/gcc/testsuite/g++.old-deja/g++.eh/cleanup2.C b/gcc/testsuite/g++.old-deja/g++.eh/cleanup2.C new file mode 100644 index 000000000..9538de961 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.eh/cleanup2.C @@ -0,0 +1,53 @@ +// { dg-do run } +// Copyright (C) 1999 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 21 Nov 1999 <nathan@acm.org> + +// make sure we don't call base dtors, if we failed to call the +// base ctor due to exception throwing + +#include <stdio.h> + +static bool bad = false; + +static int thrower () +{ + printf ("in %s\n", __PRETTY_FUNCTION__); + throw 0; + return 0; +} + +struct X +{ + X (int) throw (int); + ~X () throw (); +}; + +X::X (int) throw (int) + {printf ("in ctor X %s\n", __PRETTY_FUNCTION__); bad = true;} +X::~X () throw () + {printf ("in dtor X %s\n", __PRETTY_FUNCTION__); bad = true;} + +struct X1 {}; +struct Y : X +{ + Y() throw (int); + ~Y() throw (); +}; +Y::Y() throw (int) + : X(thrower ()) // throws, so X::X is never called + {printf ("in ctor Y%s\n", __PRETTY_FUNCTION__); bad = true;} +Y::~Y() throw () + {printf ("in dtor Y%s\n", __PRETTY_FUNCTION__); bad = true;} + +int main () +{ + try + { + Y y; + } + catch (...) + { + printf ("caught\n"); + } + return bad; +} diff --git a/gcc/testsuite/g++.old-deja/g++.eh/cond1.C b/gcc/testsuite/g++.old-deja/g++.eh/cond1.C new file mode 100644 index 000000000..1b2de1d10 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.eh/cond1.C @@ -0,0 +1,31 @@ +// { dg-do assemble } + +// Copyright (C) 1999, 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 11 Apr 1999 <nathan@acm.org> +// Derived from bug report from Gabriel Dos Reis +// <Gabriel.Dos-Reis@cmla.ens-cachan.fr> +// http://gcc.gnu.org/ml/gcc-bugs/1999-03n/msg00888.html + +// conditional exprs have some funny rules when one of the types is void. +// [expr.cond] 5.16, make sure we do the right things +// We implement an extension, allowing one side to be void, check we +// pedantically moan. + +struct X {}; +void fn(int i) +{ + int j; + + j = (i ? throw X() : 1); // ok, int + j = (i ? 1 : throw X()); // ok, int + + (i ? throw X() : throw X()); // ok, void + + (i ? i : j) = 1; // ok, int & + (i ? throw X() : j) = 1; // { dg-error "" } non-lvalue + (i ? j : throw X()) = 1; // { dg-error "" } non-lvalue + (i ? throw X() : throw X()) = 1; // { dg-error "" } void + + (i ? (void)1 : i++); // { dg-error "" } ANSI forbids + (i ? i++ : (void)1); // { dg-error "" } ANSI forbids +} diff --git a/gcc/testsuite/g++.old-deja/g++.eh/crash1.C b/gcc/testsuite/g++.old-deja/g++.eh/crash1.C new file mode 100644 index 000000000..a4440c7bd --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.eh/crash1.C @@ -0,0 +1,22 @@ +// { dg-do assemble } +// { dg-options "-O1 -fno-inline-functions" } + +struct A +{ + ~A (); +}; + +bool foo (); + +int i; +int j; + +A bar () +{ + for (i = 0; i < 1; ++i) + if (j) + { + A tmp; + return tmp; + } +} diff --git a/gcc/testsuite/g++.old-deja/g++.eh/crash2.C b/gcc/testsuite/g++.old-deja/g++.eh/crash2.C new file mode 100644 index 000000000..195b8623c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.eh/crash2.C @@ -0,0 +1,27 @@ +// { dg-do assemble } +// { dg-options "-O" } +// Origin: Thomas Kunert <kunert@physik.tu-dresden.de> + +struct C { + ~C(); +}; + +struct R { + bool empty() const; + C m_; +}; + +struct R1 { + R1( const R& a ); + ~R1 (); + C m_; +}; + +R1 get_empty(); + +R1::R1( const R& a ) : + m_( a.empty() ? get_empty().m_ : C() ) +{} + +void qnorm( const R & r) +{ R1 n( r ); } diff --git a/gcc/testsuite/g++.old-deja/g++.eh/crash3.C b/gcc/testsuite/g++.old-deja/g++.eh/crash3.C new file mode 100644 index 000000000..e0cc42036 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.eh/crash3.C @@ -0,0 +1,16 @@ +// { dg-do assemble } +// Origin: Marc Espie <Marc.Espie@liafa.jussieu.fr> +// Used to use -fsjlj-exceptions, but that isn't an option anymore. + +extern double f(double a); + +void +a() +{ + double e; + double value; + + if (e == 0) + throw 1; + value = f(e); +} diff --git a/gcc/testsuite/g++.old-deja/g++.eh/crash4.C b/gcc/testsuite/g++.old-deja/g++.eh/crash4.C new file mode 100644 index 000000000..e14f03b07 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.eh/crash4.C @@ -0,0 +1,14 @@ +// { dg-do assemble } +// { dg-options "-O2" } +// Origin: Nathan Sidwell <nathan@codesourcery.com> + +struct A +{ + A (int) { } + ~A () { } + int get () const { return 0; } +}; + +void f (const A &s) { + f (s.get ()); +} 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 000000000..eceb22ed1 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.eh/crash5.C @@ -0,0 +1,12 @@ +// { dg-do assemble } +// 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 000000000..7151cbfe3 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.eh/crash6.C @@ -0,0 +1,26 @@ +// { dg-do assemble } +// +// 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/ctor1.C b/gcc/testsuite/g++.old-deja/g++.eh/ctor1.C new file mode 100644 index 000000000..0e7218f0c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.eh/ctor1.C @@ -0,0 +1,18 @@ +// { dg-do assemble } +struct A +{ + A(); // { dg-message "A::A|candidate expects" } candidate + A(A&); // { dg-message "A::A|no known conversion" } referenced below +}; + +int +main () +{ + try + { + throw A(); // { dg-error "no matching" "match" } can't copy + // { dg-message "candidate" "candidate note" { target *-*-* } 13 } +// { dg-error "thrown expression" "expr" { target *-*-* } 13 } + } + catch (...) { } +} diff --git a/gcc/testsuite/g++.old-deja/g++.eh/flow1.C b/gcc/testsuite/g++.old-deja/g++.eh/flow1.C new file mode 100644 index 000000000..d48a896b2 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.eh/flow1.C @@ -0,0 +1,23 @@ +// { dg-do run } +#include <stdio.h> + +int bar () +{ + throw 100; + return 0; +} + +int main () +{ + int i = 0; // this gets deleted after flow analysis + try + { + i = bar (); + } + catch (...) + { + } + + printf ("i = %d\n", i); + return i; +} diff --git a/gcc/testsuite/g++.old-deja/g++.eh/fntry1.C b/gcc/testsuite/g++.old-deja/g++.eh/fntry1.C new file mode 100644 index 000000000..9b14f0111 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.eh/fntry1.C @@ -0,0 +1,32 @@ +// { dg-do run } +// Bug: g++ fails to treat function-try-blocks in ctors specially. +// Submitted by Jason Merrill <jason@cygnus.com> + +int c; +int r; + +struct A { + int i; + A(int j) { i = j; } + ~A() { c += i; } +}; + +struct B: public A { + A a; + B() try : A(1), a(2) + { throw 1; } + catch (...) + { if (c != 3) r |= 1; } +}; + +int main () +{ + try + { B b; } + catch (...) + { c = 0; } + + if (c != 0) r |= 2; + + return r; +} diff --git a/gcc/testsuite/g++.old-deja/g++.eh/ia64-1.C b/gcc/testsuite/g++.old-deja/g++.eh/ia64-1.C new file mode 100644 index 000000000..f8def11d6 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.eh/ia64-1.C @@ -0,0 +1,73 @@ +// { dg-do run } +// { dg-options "-O2" } + +#include <exception> + +using namespace std; + +extern "C" void abort(); + +int i_0, i_1, i_2, i_3, i_4, i_5, i_6, i_7, i_8, i_9; +int j_0, j_1, j_2, j_3, j_4, j_5, j_6, j_7, j_8, j_9; +int k_0, k_1, k_2, k_3, k_4, k_5, k_6, k_7, k_8, k_9; +int l_0, l_1, l_2, l_3, l_4, l_5, l_6, l_7, l_8, l_9; +#define A(x,y,n) register int *x##n = &y##_##n; +#define B(x,y) \ + A(x,y,0) A(x,y,1) A(x,y,2) A(x,y,3) A(x,y,4) \ + A(x,y,5) A(x,y,6) A(x,y,7) A(x,y,8) A(x,y,9) +#define C(x,n) asm volatile ("" : "=r" (x##n) : "0" (x##n)); +#define D(x) \ + C(x,0) C(x,1) C(x,2) C(x,3) C(x,4) \ + C(x,5) C(x,6) C(x,7) C(x,8) C(x,9) +#define E(x,y,n) if (x##n != &y##_##n) abort (); +#define F(x,y) \ + E(x,y,0) E(x,y,1) E(x,y,2) E(x,y,3) E(x,y,4) \ + E(x,y,5) E(x,y,6) E(x,y,7) E(x,y,8) E(x,y,9) + +void bar(long a0, long a1, long a2, long a3, long a4) +{ +} + +void foo(long a0, long a1, long a2, long a3, long a4) +{ + A(p,l,0) A(p,l,1) A(p,l,2) + C(p,0) C(p,1) C(p,2) + bar (0, 1, 2, 3, 4); + if (a0 == 0) + throw exception(); + C(p,0) C(p,1) C(p,2) + E(p,l,0) E(p,l,1) E(p,l,2) +} + +void test(void) +{ + A(p,l,0) A(p,l,1) A(p,l,2) A(p,l,3) A(p,l,4) A(p,l,5) A(p,l,6) + C(p,0) C(p,1) C(p,2) C(p,3) C(p,4) C(p,5) C(p,6) + try { + foo(0, 1, 2, 3, 4); + } catch (exception) {} + C(p,0) C(p,1) C(p,2) C(p,3) C(p,4) C(p,5) C(p,6) + E(p,l,0) E(p,l,1) E(p,l,2) E(p,l,3) E(p,l,4) E(p,l,5) E(p,l,6) +} + +int main() +{ + B(x,i) + B(y,j) + B(z,k) + A(p,l,0) A(p,l,1) A(p,l,2) A(p,l,3) + D(x) + D(y) + D(z) + C(p,0) C(p,1) C(p,2) C(p,3) + test(); + D(x) + D(y) + D(z) + C(p,0) C(p,1) C(p,2) C(p,3) + F(x,i) + F(y,j) + F(z,k) + E(p,l,0) E(p,l,1) E(p,l,2) E(p,l,3) + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.eh/inline1.C b/gcc/testsuite/g++.old-deja/g++.eh/inline1.C new file mode 100644 index 000000000..e35976757 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.eh/inline1.C @@ -0,0 +1,25 @@ +// { dg-do assemble } +// { dg-options "-ansi -pedantic-errors -O2" } +// Copyright (C) 1999 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 29 Nov 1999 <nathan@acm.org> + + +struct Foo +{ + inline ~Foo (); +}; + +inline void Wibble (int) throw () +{ +} + +inline Foo::~Foo () +{ + Wibble (6); +} + +int ExtendFoos () +{ + Foo tmp; + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.eh/inline2.C b/gcc/testsuite/g++.old-deja/g++.eh/inline2.C new file mode 100644 index 000000000..356c85a7c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.eh/inline2.C @@ -0,0 +1,25 @@ +// { dg-do run } +// { dg-options "-O" } +// Test that inlining a destructor with a catch block doesn't confuse the +// enclosing try block. + +struct A { + ~A() + { + try { throw 1; } + catch (...) { } + } +}; + +int main () +{ + try + { + A a; + throw 42; + } + catch (int i) + { + return (i != 42); + } +} diff --git a/gcc/testsuite/g++.old-deja/g++.eh/new1.C b/gcc/testsuite/g++.old-deja/g++.eh/new1.C new file mode 100644 index 000000000..4c52cf40e --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.eh/new1.C @@ -0,0 +1,49 @@ +// { dg-do run } +// Test that a throw in foo destroys the A, but does not free the memory. + +#include <cstddef> +#include <cstdlib> +#include <new> + +struct A { + A(); + ~A(); +}; + +struct B { + B (A); +}; + +void foo (B*); + +int newed, created; + +int main () +{ + try { + foo (new B (A ())); + } catch (...) { } + + return !(newed && !created); +} + +A::A() { created = 1; } +A::~A() { created = 0; } +B::B(A) { } +void foo (B*) { throw 1; } + +void* operator new (size_t size) throw (std::bad_alloc) +{ + ++newed; + return (void *) std::malloc (size); +} + +void operator delete (void *p) throw () +{ + --newed; + 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 new file mode 100644 index 000000000..2d69df0e7 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.eh/new2.C @@ -0,0 +1,47 @@ +// { dg-do run } +// Test that a throw in B's constructor destroys the A and frees the memory. + +#include <cstddef> +#include <cstdlib> +#include <new> + +struct A { + A(); + ~A(); +}; + +struct B { + B (A); +}; + +void foo (B*); + +int newed, created; + +int main () +{ + newed = 0; // The libraries might call new before main starts. + try { + foo (new B (A ())); + } catch (...) { } + + return !(!newed && !created); +} + +A::A() { created = 1; } +A::~A() { created = 0; } +B::B(A) { throw 1; } +void foo (B*) { } + +void* operator new (size_t size) throw (std::bad_alloc) +{ + ++newed; + return (void *) std::malloc (size); +} + +void operator delete (void *p) throw () +{ + --newed; + free (p); +} + diff --git a/gcc/testsuite/g++.old-deja/g++.eh/pdel1.C b/gcc/testsuite/g++.old-deja/g++.eh/pdel1.C new file mode 100644 index 000000000..fd7ecff3c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.eh/pdel1.C @@ -0,0 +1,23 @@ +// { dg-do run } +// Test for calling placement delete. + +#include <new> +#include <stddef.h> + +int r = 1; + +struct A { + A() { throw 1; } + void operator delete (void *p, int, int) { r = 0; ::operator delete (p); } +}; + +void * operator new (size_t size, int, int) { return operator new (size); } + +int main () +{ + try { + A* ap = new (1, 5) A; + } catch (...) { } + + return r; +} diff --git a/gcc/testsuite/g++.old-deja/g++.eh/pdel2.C b/gcc/testsuite/g++.old-deja/g++.eh/pdel2.C new file mode 100644 index 000000000..9bad6eea4 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.eh/pdel2.C @@ -0,0 +1,23 @@ +// { dg-do run } +// Test for not calling mismatched placement delete. + +#include <new> +#include <stddef.h> + +int r = 0; + +struct A { + A() { throw 1; } + void operator delete (void *p, int, long) { r = 1; ::operator delete (p); } +}; + +void * operator new (size_t size, int, int) { return operator new (size); } + +int main () +{ + try { + A* ap = new (1, 5) A; + } catch (...) { } + + return r; +} diff --git a/gcc/testsuite/g++.old-deja/g++.eh/ptr1.C b/gcc/testsuite/g++.old-deja/g++.eh/ptr1.C new file mode 100644 index 000000000..aefe5cc61 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.eh/ptr1.C @@ -0,0 +1,23 @@ +// { dg-do run } +// Bug: catching pointers by reference doesn't work right. + +extern "C" int printf (const char *, ...); + +struct E { + int x; + E(int i) { x = i; } +}; + +int main() +{ + try { + E *p = new E(5); + throw p; + } + + catch (E *&e) { + printf ("address of e is 0x%lx\n", (__SIZE_TYPE__)e); + return !((__SIZE_TYPE__)e != 5 && e->x == 5); + } + return 2; +} diff --git a/gcc/testsuite/g++.old-deja/g++.eh/ptrmem1.C b/gcc/testsuite/g++.old-deja/g++.eh/ptrmem1.C new file mode 100644 index 000000000..299dc4a05 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.eh/ptrmem1.C @@ -0,0 +1,16 @@ +// { dg-do run } +extern "C" void exit (int); +extern "C" void abort (void); +struct A { int i; }; +int main () +{ + try { throw &A::i; } + catch (int A::*p) + { + if (p == &A::i) + exit (0); + else + abort (); + } + abort (); +} diff --git a/gcc/testsuite/g++.old-deja/g++.eh/rethrow1.C b/gcc/testsuite/g++.old-deja/g++.eh/rethrow1.C new file mode 100644 index 000000000..286f1bd25 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.eh/rethrow1.C @@ -0,0 +1,46 @@ +// { dg-do run } +// Testcase for proper handling of rethrow. + +#include <stdio.h> + +int c, d; + +struct A +{ + int i; + A () { i = ++c; printf ("A() %d\n", i); } + A (const A&) { i = ++c; printf ("A(const A&) %d\n", i); } + ~A() { printf ("~A() %d\n", i); ++d; } +}; + +int +main () +{ + try + { + try + { + printf ("Throwing 1...\n"); + throw A(); + } + catch (A) + { + try + { + printf ("Throwing 2...\n"); + throw A(); + } + catch (A) + { + printf ("Throwing 3...\n"); + throw; + } + } + } + catch (A) + { + printf ("Caught.\n"); + } + printf ("c == %d, d == %d\n", c, d); + return c != d; +} diff --git a/gcc/testsuite/g++.old-deja/g++.eh/rethrow2.C b/gcc/testsuite/g++.old-deja/g++.eh/rethrow2.C new file mode 100644 index 000000000..cd2dd7e47 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.eh/rethrow2.C @@ -0,0 +1,46 @@ +// { dg-do run } +// Testcase for proper handling of rethrow. + +#include <stdio.h> + +int c, d; + +struct A +{ + int i; + A () { i = ++c; printf ("A() %d\n", i); } + A (const A&) { i = ++c; printf ("A(const A&) %d\n", i); } + ~A() { printf ("~A() %d\n", i); ++d; } +}; + +int +main () +{ + try + { + try + { + printf ("Throwing 1...\n"); + throw A(); + } + catch (A) + { + try + { + printf ("Throwing 2...\n"); + throw; + } + catch (A) + { + printf ("Throwing 3...\n"); + throw; + } + } + } + catch (A) + { + printf ("Caught.\n"); + } + printf ("c == %d, d == %d\n", c, d); + return c != d; +} diff --git a/gcc/testsuite/g++.old-deja/g++.eh/rethrow3.C b/gcc/testsuite/g++.old-deja/g++.eh/rethrow3.C new file mode 100644 index 000000000..952318b80 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.eh/rethrow3.C @@ -0,0 +1,40 @@ +// { dg-do run } +#include <stdio.h> +#include <stdlib.h> +#include <exception> + +static void +eh_terminate () +{ + printf ("CALLING TERMINATE\n"); + exit (1); +} + +void +eh_test (int level) +{ + try + { + if (level < 2) + eh_test (level + 1); + else + { + printf ("%d: Throwing\n", level); + throw (level); + } + } + catch (int &x) + { + printf ("%d: Got level %d\n", + level, x); + + if (level > 0) + throw; + } +} + +int main () +{ + std::set_terminate (&eh_terminate); + eh_test (0); +} diff --git a/gcc/testsuite/g++.old-deja/g++.eh/rethrow4.C b/gcc/testsuite/g++.old-deja/g++.eh/rethrow4.C new file mode 100644 index 000000000..df54e4931 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.eh/rethrow4.C @@ -0,0 +1,46 @@ +// { dg-do run } +// Testcase for proper handling of rethrow. + +#include <stdio.h> + +int c, d; + +struct A +{ + int i; + A () { i = ++c; printf ("A() %d\n", i); } + A (const A&) { i = ++c; printf ("A(const A&) %d\n", i); } + ~A() { printf ("~A() %d\n", i); ++d; } +}; + +int +main () +{ + try + { + try + { + printf ("Throwing 1...\n"); + throw A(); + } + catch (A) + { + try + { + printf ("Throwing 2...\n"); + throw; + } + catch (A) + { + printf ("Throwing 3...\n"); + throw A(); + } + } + } + catch (A) + { + printf ("Caught.\n"); + } + printf ("c == %d, d == %d\n", c, d); + return c != d; +} diff --git a/gcc/testsuite/g++.old-deja/g++.eh/rethrow5.C b/gcc/testsuite/g++.old-deja/g++.eh/rethrow5.C new file mode 100644 index 000000000..34a56e41f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.eh/rethrow5.C @@ -0,0 +1,45 @@ +// { dg-do run } +// Testcase for proper handling of rethrow. + +#include <stdio.h> + +int c, d; + +struct A +{ + int i; + A () { i = ++c; printf ("A() %d\n", i); } + A (const A&) { i = ++c; printf ("A(const A&) %d\n", i); } + ~A() { printf ("~A() %d\n", i); ++d; } +}; + +int +main () +{ + try + { + try + { + printf ("Throwing 1...\n"); + throw A(); + } + catch (A) + { + try + { + printf ("Throwing 2...\n"); + throw; + } + catch (A) + { + printf ("Falling out...\n"); + } + } + } + catch (A) + { + printf ("Caught.\n"); + } + printf ("c == %d, d == %d\n", c, d); + return c != d; +} diff --git a/gcc/testsuite/g++.old-deja/g++.eh/rethrow6.C b/gcc/testsuite/g++.old-deja/g++.eh/rethrow6.C new file mode 100644 index 000000000..ce9962605 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.eh/rethrow6.C @@ -0,0 +1,76 @@ +// { dg-do run } +// Testcase for proper handling of rethrow. + +#include <stdio.h> + +int c, d; +int wrong; + +struct A +{ + int i; + A () { i = c++; printf ("A() %d\n", i); } + A (const A&) { i = c++; printf ("A(const A&) %d\n", i); } + ~A() { printf ("~A() %d\n", i); ++d; } +}; + +struct B +{ + ~B () { + try + { + printf ("Rethrowing III...\n"); + throw; + } + catch (A& a) + { + printf ("Caught III %d...\n", a.i); + if (a.i != 1) + { + printf ("** rethrew uncaught exception **\n"); + wrong = 1; + } + } + printf ("continuing to unwind II...\n"); + } +}; + +int +main () +{ + { + A a; + + try + { + try + { + printf ("Throwing I...\n"); + throw a; + } + catch (A& a) + { + printf ("Caught I %d...\n", a.i); + try + { + B b; + printf ("Throwing II...\n"); + throw a; + } + catch (A& a) + { + printf ("Caught II %d...\n", a.i); + printf ("Throwing IV...\n"); + throw; + } + } + } + catch (A& a) + { + printf ("Caught IV %d.\n", a.i); + } + } + + printf ("c == %d, d == %d\n", c, d); + return c != d || wrong; +} diff --git a/gcc/testsuite/g++.old-deja/g++.eh/spec1.C b/gcc/testsuite/g++.old-deja/g++.eh/spec1.C new file mode 100644 index 000000000..0ff888369 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.eh/spec1.C @@ -0,0 +1,39 @@ +// { dg-do run } +// Testing exception specifications. +// Test 1: the original exception succeeds. + +#include <stdlib.h> +#include <exception> + +void my_term () { exit (1); } +void my_unexp () { throw 42; } + +void +f () throw (char, int, std::bad_exception) +{ + throw 'a'; +} + +int main () +{ + std::set_terminate (my_term); + std::set_unexpected (my_unexp); + + try + { + f (); + } + catch (char) + { + return 0; + } + catch (int) + { + return 3; + } + catch (std::bad_exception) + { + return 4; + } + return 5; +} diff --git a/gcc/testsuite/g++.old-deja/g++.eh/spec2.C b/gcc/testsuite/g++.old-deja/g++.eh/spec2.C new file mode 100644 index 000000000..5c7a91399 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.eh/spec2.C @@ -0,0 +1,39 @@ +// { dg-do run } +// Testing exception specifications. +// Test 2: the second throw succeeds. + +#include <stdlib.h> +#include <exception> + +void my_term () { exit (1); } +void my_unexp () { throw 42; } + +void +f () throw (int, std::bad_exception) +{ + throw 'a'; +} + +int main () +{ + std::set_terminate (my_term); + std::set_unexpected (my_unexp); + + try + { + f (); + } + catch (char) + { + return 2; + } + catch (int) + { + return 0; + } + catch (std::bad_exception) + { + return 4; + } + return 5; +} diff --git a/gcc/testsuite/g++.old-deja/g++.eh/spec3.C b/gcc/testsuite/g++.old-deja/g++.eh/spec3.C new file mode 100644 index 000000000..6239270ee --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.eh/spec3.C @@ -0,0 +1,39 @@ +// { dg-do run } +// Testing exception specifications. +// Test 3: the bad_exception throw succeeds. + +#include <stdlib.h> +#include <exception> + +void my_term () { exit (1); } +void my_unexp () { throw 42; } + +void +f () throw (std::bad_exception) +{ + throw 'a'; +} + +int main () +{ + std::set_terminate (my_term); + std::set_unexpected (my_unexp); + + try + { + f (); + } + catch (char) + { + return 2; + } + catch (int) + { + return 3; + } + catch (std::bad_exception) + { + return 0; + } + return 5; +} diff --git a/gcc/testsuite/g++.old-deja/g++.eh/spec4.C b/gcc/testsuite/g++.old-deja/g++.eh/spec4.C new file mode 100644 index 000000000..e1f702e20 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.eh/spec4.C @@ -0,0 +1,39 @@ +// { dg-do run } +// Testing exception specifications. +// Test 4: all throws fail, call terminate. + +#include <stdlib.h> +#include <exception> + +void my_term () { exit (0); } +void my_unexp () { throw 42; } + +void +f () throw (short) +{ + throw 'a'; +} + +int main () +{ + std::set_terminate (my_term); + std::set_unexpected (my_unexp); + + try + { + f (); + } + catch (char) + { + return 2; + } + catch (int) + { + return 3; + } + catch (std::bad_exception) + { + return 4; + } + return 5; +} diff --git a/gcc/testsuite/g++.old-deja/g++.eh/spec5.C b/gcc/testsuite/g++.old-deja/g++.eh/spec5.C new file mode 100644 index 000000000..107ba7f19 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.eh/spec5.C @@ -0,0 +1,3 @@ +// { dg-do assemble } + +extern void *f(unsigned int k) throw(); diff --git a/gcc/testsuite/g++.old-deja/g++.eh/spec6.C b/gcc/testsuite/g++.old-deja/g++.eh/spec6.C new file mode 100644 index 000000000..015bbefdf --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.eh/spec6.C @@ -0,0 +1,137 @@ +// { dg-do assemble } + +// Copyright (C) 1999 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 19 Jan 1999 <nathan@acm.org> + +// Determine that throw specifiers are checked correctly. + +// [except.spec] 1, a type in an exception specifier shall not be incomplete, +// or pointer or ref to incomplete +struct X; // { dg-error "" } forward declaration.* +void fn1() throw(X); // { dg-error "" } invalid use of undefined type +void fn2() throw(X *); // { dg-error "" } invalid use of undefined type +void fn3() throw(X &); // { dg-error "" } invalid use of undefined tyoe +void fn4() throw(void); // { dg-error "" } invalid use of void expression +void fn5() throw(void &); // { dg-error "" } invalid type // ERROR - invalid use of void +// except for cv pointer to void +void fn6() throw(void *); // ok -- pointer to void +void fn7() throw(void const *); // ok -- pointer to cv void + +template<class T> void fny() throw(T); // ok (so far) +template<> void fny<int>() throw(int); // ok +template<> void fny<void>() throw(void); // { dg-error "" } invalid use of void + +template<class T> void fnx(T *) throw(T){} // { dg-error "" } invalid use of void expression +void fx() +{ + fnx((int *)0); + fnx((void *)0); // { dg-message "instantiated from here" } +} + +// [except.spec] 2, exception specifiers must be the same set of types (but +// can be reordered) +void baz1() throw(int, char); +void baz1() throw(char, int){} // reordering is ok + +void baz2() throw(int, char); +void baz2() throw(int, char, int){} // duplicates are ignored + +typedef int Int; +void baz3() throw(int, char); +void baz3() throw(Int, char){} // typedefs are the same type ... + +void baz4() throw(int, Int, char); // ... so this is a duplicate +void baz4() throw(Int, char){} + +void fna() throw(int, char); // { dg-error "" } to previous declaration +void fna() throw(int const, char); // { dg-error "" } declaration different exceptions // ERROR - to previous declaration +void fna() throw(int){} // { dg-error "" } declaration different exceptions + +void fnb() throw(int, char); // { dg-error "" } to previous declaration +void fnb() throw(char){} // { dg-error "" } declaration different exceptions + +void fnc() throw(int, char); // { dg-error "" } to previous declaration +void fnc() throw(char, int, float){} // { dg-error "" } declaration different exceptions + +void fnd() throw(); // { dg-error "" } to previous declaration +void fnd() throw(char){} // { dg-error "" } declaration different exceptions + +void fne() throw(char); // { dg-error "" } to previous declaration +void fne() throw(){} // { dg-error "" } declaration different exceptions + +void fnf(); // { dg-error "" } to previous declaration +void fnf() throw(char){} // { dg-error "" } declaration different exceptions + +void fng() throw(char); // { dg-error "" } to previous declaration +void fng(){} // { dg-error "" } declaration different exceptions + +void fnh() throw(int, char); // { dg-error "" } to previous declaration +void fnh() throw(int, float){} // { dg-error "" } declaration different exceptions + +void fni() throw(int, char); // { dg-error "" } to previous declaration +void fni() throw(float, char){} // { dg-error "" } declaration different exceptions + +// [except.spec] 3, virtual function overriders shall throw a subset of the +// overridden function +struct E {}; +struct F : public E {}; +struct F1 : public E {}; +struct G : public F, F1 {}; +struct H : private E {}; +struct A +{ + virtual void foo() throw(); // { dg-error "" } overriding + virtual void baz() throw(double, int); + virtual void bar(); + virtual void qux() throw(E); + virtual void qux(int) throw(E const *); // { dg-error "" } overriding (pedantically) + virtual void quux() throw(F); // { dg-error "" } overriding + virtual void quux(int) throw(F *); // { dg-error "" } overriding + virtual void wibble() throw(E); // { dg-error "" } overriding + virtual void wobble() throw(E *); // { dg-error "" } overriding + virtual void wobble(int) throw(E *); // { dg-error "" } overriding + virtual void wabble(int) throw(E *); + virtual void wubble(int) throw(E *, H *); + virtual ~A() throw(); // { dg-error "" } overriding +}; + +struct B : A +{ + virtual void foo() throw(int); // { dg-error "" } looser throw - A::foo + virtual void baz() throw(double); // ok subset + virtual void bar(int) throw(int); // ok not overriding + virtual void qux() throw(F); // ok subset + virtual void qux(int) throw(F *); // { dg-error "" } looser (pedantically) + virtual void quux() throw(E); // { dg-error "" } looser throw - A::quux() + virtual void quux(int) throw(E *); // { dg-error "" } looser throw - A::quux(int) + virtual void wibble() throw(E *); // { dg-error "" } looser throw - A::wibble + virtual void wobble() throw(G *); // { dg-error "" } looser throw - A::wobble() + virtual void wobble(int) throw(H *); // { dg-error "" } looser throw - A::wobble(int) + virtual void wubble(int) throw(H *); // ok + virtual void wabble(int) throw(F1 *, F *); // ok +}; + +struct A1 +{ + virtual void foo() throw(int); + virtual void bar() throw(); // { dg-error "" } overriding + virtual ~A1() throw(int); +}; + +struct B1 : A +{ +}; + +struct C : A, A1 // { dg-error "" } looser throw - A::~A() +{ + virtual void foo() throw(int); // { dg-error "" } looser throw - A::foo + virtual void bar() throw(int); // { dg-error "" } looser throw - A1::bar +}; + +struct D : A, A1 +{ + virtual ~D() throw(int); // { dg-error "" } looser throw - A::~A() +}; + +// [except.spec] 5, types shall not be defined in exception specifiers +void fn8() throw(struct Z {}); // { dg-error "" } ANSI C++ forbids 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 000000000..2ef88a249 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.eh/spec7.C @@ -0,0 +1,20 @@ +// { dg-do run } +// 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/terminate1.C b/gcc/testsuite/g++.old-deja/g++.eh/terminate1.C new file mode 100644 index 000000000..623fb8400 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.eh/terminate1.C @@ -0,0 +1,27 @@ +// { dg-do run } +// Test that an exception thrown out of the constructor for the catch +// parameter (i.e. "after completing evaluation of the expression to be thrown +// but before the exception is caught") causes us to call terminate. + +#include <exception> +#include <cstdlib> + +void my_terminate () +{ + std::exit (0); +} + +struct A +{ + A () {} + A (const A&) { throw 1; } +}; + +int main (void) +{ + std::set_terminate (my_terminate); + + try { throw A(); } + catch (A) {} + return 1; +} diff --git a/gcc/testsuite/g++.old-deja/g++.eh/terminate2.C b/gcc/testsuite/g++.old-deja/g++.eh/terminate2.C new file mode 100644 index 000000000..3a3115843 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.eh/terminate2.C @@ -0,0 +1,17 @@ +// { dg-do run } +// Test that an unhandled exception causes us to call terminate. + +#include <exception> +#include <cstdlib> + +void my_terminate () +{ + std::exit (0); +} + +int main (void) +{ + std::set_terminate (my_terminate); + throw 1; + return 1; +} diff --git a/gcc/testsuite/g++.old-deja/g++.eh/throw1.C b/gcc/testsuite/g++.old-deja/g++.eh/throw1.C new file mode 100644 index 000000000..e5d234be3 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.eh/throw1.C @@ -0,0 +1,12 @@ +// { dg-do assemble } + +void athrow(const int & e) throw(int) +{ + throw e; +} + +int main(void) +{ + athrow(int()); + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.eh/throw2.C b/gcc/testsuite/g++.old-deja/g++.eh/throw2.C new file mode 100644 index 000000000..63bb029d9 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.eh/throw2.C @@ -0,0 +1,16 @@ +// { dg-do assemble } + +// Submitted by Sebastian Ritterbusch <uabp@rz.uni-karlsruhe.de> + +#define ANY int // a class with a public constructor + +void athrow(const ANY & e) throw(ANY) +{ + throw e; // { dg-bogus "" } discarding const +} + +int main(void) +{ + athrow(ANY()); + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.eh/tmpl1.C b/gcc/testsuite/g++.old-deja/g++.eh/tmpl1.C new file mode 100644 index 000000000..985fcae6b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.eh/tmpl1.C @@ -0,0 +1,16 @@ +// { dg-do run } +template <class T> +void f() throw (T) +{ + throw 7; +} + + +int main() +{ + try { + f<int>(); + } catch (...) { + return 0; + } +} diff --git a/gcc/testsuite/g++.old-deja/g++.eh/tmpl2.C b/gcc/testsuite/g++.old-deja/g++.eh/tmpl2.C new file mode 100644 index 000000000..dd2801d26 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.eh/tmpl2.C @@ -0,0 +1,32 @@ +// { dg-do assemble } +// { dg-options "-O" } + +// Posted by H. J. Lu <hjl@lucon.org> + +template<class T> +class FixSeq +{ +public: + void append(const T&); +}; +class foo +{ +public: + void setupIR(); +}; +typedef FixSeq<foo *> bar; +extern void dummy (foo *); +void * +foobar (bar &x, foo *p) +{ + try + { + p -> setupIR(); + } + catch(...) + { + dummy (p); + } + x.append(p); + return p; +} diff --git a/gcc/testsuite/g++.old-deja/g++.eh/tmpl3.C b/gcc/testsuite/g++.old-deja/g++.eh/tmpl3.C new file mode 100644 index 000000000..0ddf63c98 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.eh/tmpl3.C @@ -0,0 +1,11 @@ +// { dg-do assemble } + +// Posted by Trevor Taylor <ttaylor@powerup.com.au> + +template<class T> struct A { + void X() throw(T); +}; + +template<class T> +inline void A<T>::X() +throw(T) { } diff --git a/gcc/testsuite/g++.old-deja/g++.eh/tmpl4.C b/gcc/testsuite/g++.old-deja/g++.eh/tmpl4.C new file mode 100644 index 000000000..14e455bb6 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.eh/tmpl4.C @@ -0,0 +1,11 @@ +// { dg-do assemble } +// Origin: Mark Mitchell <mark@codesourcery.com> + +template <class T> void test(){ + try { + } + catch(int x){ + } +} + +template void test<int>(); diff --git a/gcc/testsuite/g++.old-deja/g++.eh/tmpl5.C b/gcc/testsuite/g++.old-deja/g++.eh/tmpl5.C new file mode 100644 index 000000000..4f9580bcb --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.eh/tmpl5.C @@ -0,0 +1,13 @@ +// { dg-do assemble } +// Origin: Mark Mitchell <mark@codesourcery.com> + +template <class T = int> +struct S +{ + void f () + { + try { + } catch (int) { + } + } +}; diff --git a/gcc/testsuite/g++.old-deja/g++.eh/tmpl6.C b/gcc/testsuite/g++.old-deja/g++.eh/tmpl6.C new file mode 100644 index 000000000..d79e8ad29 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.eh/tmpl6.C @@ -0,0 +1,18 @@ +// { dg-do assemble } +// Origin: Mark Mitchell <mark@codesourcery.com> + +struct S +{ + int i; +}; + +template <class T> +void f () +{ + try { + } catch (S& s) { + s.i = 3; + } +} + +template void f<int>(); diff --git a/gcc/testsuite/g++.old-deja/g++.eh/unwind1.C b/gcc/testsuite/g++.old-deja/g++.eh/unwind1.C new file mode 100644 index 000000000..076b550f4 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.eh/unwind1.C @@ -0,0 +1,25 @@ +// { dg-do run } +// Test that unwinding properly restores SP. +// Contributed by Jason Merrill <jason@cygnus.com> + +void f (int i) +{ + throw i; +} + +int main () +{ + void *sp1 = __builtin_alloca (0); + + try + { + f (0); + } + catch (int) + { + } + + void *sp2 = __builtin_alloca (0); + + return (sp1 != sp2); +} diff --git a/gcc/testsuite/g++.old-deja/g++.eh/vbase1.C b/gcc/testsuite/g++.old-deja/g++.eh/vbase1.C new file mode 100644 index 000000000..96766d624 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.eh/vbase1.C @@ -0,0 +1,25 @@ +// { dg-do run } +// Origin: Mark Mitchell <mark@codesourcery.com> + +int i; +int j; + +struct B +{ + B() { i = 1; } + ~B() { j = 7; } +}; + +struct D : virtual public B { + D () { throw 3; } +}; + +int main () +{ + try { + D d; + } catch (int) { + if (i != 1 || j != 7) + return 1; + } +} diff --git a/gcc/testsuite/g++.old-deja/g++.eh/vbase2.C b/gcc/testsuite/g++.old-deja/g++.eh/vbase2.C new file mode 100644 index 000000000..eaae9d93a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.eh/vbase2.C @@ -0,0 +1,35 @@ +// { dg-do run } +// Origin: Mark Mitchell <mark@codesourcery.com> + +int i; + +struct A +{ + A () { i++; } + ~A () { i--; } +}; + +struct B : public virtual A +{ + B () { throw 1; } +}; + +struct D: public B, virtual public A +{ +}; + +void f() +{ + D d; +} + +int main () +{ + try { + f(); + } catch (int) { + } + + return i; +} + diff --git a/gcc/testsuite/g++.old-deja/g++.eh/vbase3.C b/gcc/testsuite/g++.old-deja/g++.eh/vbase3.C new file mode 100644 index 000000000..f59b53b34 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.eh/vbase3.C @@ -0,0 +1,13 @@ +// { dg-do assemble } +// Used to use -fsjlj-exceptions, but that isn't an option anymore. +// Origin: Donn Terry <donn@interix.com> + +struct ios { + virtual ~ios(); +}; +struct fstreambase : virtual public ios { + fstreambase(); +}; +fstreambase::fstreambase() +{ +} diff --git a/gcc/testsuite/g++.old-deja/g++.eh/vbase4.C b/gcc/testsuite/g++.old-deja/g++.eh/vbase4.C new file mode 100644 index 000000000..f151ed08d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.eh/vbase4.C @@ -0,0 +1,40 @@ +// { dg-do run } + +// Copyright (C) 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 8 Mar 2000 <nathan@codesourcery.com> + +// Derived from PR#7 + +// We need to destroy the thrown object when exiting the catch +// clause. That needs to destroy the original thrown object, not +// the caught one (which might be a base). + +static int ok = 0; + +struct A +{ + A (){} + virtual ~A () {} +}; + +struct B : virtual A +{ + int value; + B () + :value(10) + {} + ~B() + { + if (value == 10) + ok = 1; + } +}; + +int main() +{ + try { + throw B (); + } catch (A & e) { + } + return !ok; +} diff --git a/gcc/testsuite/g++.old-deja/g++.ext/addrfunc1.C b/gcc/testsuite/g++.old-deja/g++.ext/addrfunc1.C new file mode 100644 index 000000000..3fec371c2 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ext/addrfunc1.C @@ -0,0 +1,18 @@ +// { dg-do assemble } +// { dg-options "-fms-extensions" } +// Test that taking the address of a member function name produces +// a pointer to member function. +// Contributed by Jason Merrill <jason@cygnus.com> + +struct A { }; +int (A::*p)(); + +struct B { + int f () { return 0; } + void g (); +}; + +void B::g () +{ + p = (int (A::*)())&f; +} diff --git a/gcc/testsuite/g++.old-deja/g++.ext/addrfunc2.C b/gcc/testsuite/g++.old-deja/g++.ext/addrfunc2.C new file mode 100644 index 000000000..7314d1632 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ext/addrfunc2.C @@ -0,0 +1,17 @@ +// { dg-do run } +// { dg-options "-fms-extensions" } +// Test for implicit & on methods. +// Contributed by Jason Merrill <jason@cygnus.com>. + +struct A { + void f (int = 0) { } +}; + +int +main () +{ + void (A::*p)(int) = 0; + p = A::f; + if (p != A::f) + return 1; +} diff --git a/gcc/testsuite/g++.old-deja/g++.ext/addrfunc3.C b/gcc/testsuite/g++.old-deja/g++.ext/addrfunc3.C new file mode 100644 index 000000000..16d33186f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ext/addrfunc3.C @@ -0,0 +1,14 @@ +// { dg-do run } +// { dg-options "-fpermissive -w" } +// Test for overload resolution in comparison expressions. +// Contributed by Jason Merrill <jason@cygnus.com>. + +void f (int) { } +void f (); + +int main () { + void (*p)(int); + p = f; + if (p != f) + return 1; +} diff --git a/gcc/testsuite/g++.old-deja/g++.ext/addrfunc4.C b/gcc/testsuite/g++.old-deja/g++.ext/addrfunc4.C new file mode 100644 index 000000000..05312e4e5 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ext/addrfunc4.C @@ -0,0 +1,25 @@ +// { dg-do run } +// { dg-options "-fms-extensions" } +// Test that an object-dependent reference to a member function can be +// used to produce a pointer to member function, as in VC++. +// Contributed by Jason Merrill <jason@cygnus.com> + +struct A +{ + int f(int a) { return 0; } + void f(int a, int b) { } +}; + +typedef int (A::* pmf1)(int); +typedef void (A::* pmf2)(int, int); + +int main() +{ + A a; + pmf1 fn1; + pmf2 fn2; + + fn1 = a.f; + fn1 = (pmf1)a.f; + fn2 = (pmf2)a.f; +} diff --git a/gcc/testsuite/g++.old-deja/g++.ext/anon1.C b/gcc/testsuite/g++.old-deja/g++.ext/anon1.C new file mode 100644 index 000000000..6fc6d2e91 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ext/anon1.C @@ -0,0 +1,15 @@ +// { dg-do run } +// { dg-options "" } + +union U { + struct { int i; int j; }; + int a[2]; +}; + +int main () +{ + U u; + u.i = 42; + u.a[1] = 24; + return u.j != 24 || u.a[0] != 42; +} diff --git a/gcc/testsuite/g++.old-deja/g++.ext/anon2.C b/gcc/testsuite/g++.old-deja/g++.ext/anon2.C new file mode 100644 index 000000000..5bde08db9 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ext/anon2.C @@ -0,0 +1,15 @@ +// { dg-do assemble } +// { dg-options "" } +// { dg-prune-output "note" } + +struct S +{ + S (); +}; + +union U { + struct { + S s; // { dg-error "" } struct with constructor in union + }; +}; + 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 000000000..44c03c7fa --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ext/anon3.C @@ -0,0 +1,36 @@ +// { dg-do assemble } + +// 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/array1.C b/gcc/testsuite/g++.old-deja/g++.ext/array1.C new file mode 100644 index 000000000..a297c73b8 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ext/array1.C @@ -0,0 +1,23 @@ +// { dg-do assemble } +// { dg-options "" } +// Testcase for assignment of non-array to array (assigns the same value to +// each member) +// Special Options: + +typedef struct {} ct2d_rigid, ct2d_rigid_a[1]; +class ccInspection +{ +protected: + ct2d_rigid_a _dev2phys; +}; +class ccBgaInspection : public ccInspection +{ +public: + void reinspect (unsigned long diagFlags); +}; +void +ccBgaInspection::reinspect (unsigned long diag_flags) +{ + ct2d_rigid physTdev; + _dev2phys = physTdev; // { dg-error "" } +} diff --git a/gcc/testsuite/g++.old-deja/g++.ext/array2.C b/gcc/testsuite/g++.old-deja/g++.ext/array2.C new file mode 100644 index 000000000..88482fe19 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ext/array2.C @@ -0,0 +1,13 @@ +// { dg-do assemble } +// { dg-options "-w" } +// This testcase used to cause a crash on the Alpha. + +struct A { + int i; + ~A() { } +}; + +A f (int n) +{ + A a[n]; +} diff --git a/gcc/testsuite/g++.old-deja/g++.ext/array3.C b/gcc/testsuite/g++.old-deja/g++.ext/array3.C new file mode 100644 index 000000000..b60b407c8 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ext/array3.C @@ -0,0 +1,10 @@ +// { dg-do assemble } +// { dg-options "" } +// Origin: Mark Mitchell <mark@codesourcery.com> + +void *vp; + +void f () +{ + int i = (*((int (*)[i]) vp))[0]; +} diff --git a/gcc/testsuite/g++.old-deja/g++.ext/array4.C b/gcc/testsuite/g++.old-deja/g++.ext/array4.C new file mode 100644 index 000000000..f0a90d842 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ext/array4.C @@ -0,0 +1,31 @@ +// { dg-do assemble } +// { dg-options "" } + + +// Copyright (C) 2000 Free Software Foundation, Inc. +// Contributed by Mark Mitchell 19 Mar 2000 <mark@codesourcery.com> +// Nathan Sidwell 19 Mar 2000 <nathan@codesourcery.com> + +// [nathan] We have a zero sized array extension, and (unfortunately) allow it +// to be the sole member of a struct (rather than the trailing member of a +// non-empty struct as C99 is/will allow). Such a type will have a size of +// zero, but is not incomplete. + +struct A +{ + int m[0]; +}; + +void foo () +{ + A a; +} + +template <class T> +struct S +{ + int x[0]; +}; + +template struct S<int>; + diff --git a/gcc/testsuite/g++.old-deja/g++.ext/arrnew.C b/gcc/testsuite/g++.old-deja/g++.ext/arrnew.C new file mode 100644 index 000000000..ea3f42014 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ext/arrnew.C @@ -0,0 +1,8 @@ +// { dg-do assemble } +// { dg-options "" } +// PRMS Id: 4992 + +int *f(){ + return new int[1] = { 1 }; // { dg-error "lvalue" "err" } + // { dg-warning "extended init" "warn" { target *-*-* } 6 } +} diff --git a/gcc/testsuite/g++.old-deja/g++.ext/arrnew2.C b/gcc/testsuite/g++.old-deja/g++.ext/arrnew2.C new file mode 100644 index 000000000..93d15d08d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ext/arrnew2.C @@ -0,0 +1,8 @@ +// { dg-do run { xfail *-*-* } } +// { dg-options "-w -fpermissive" } + +int *foo = new int[1](42); // { dg-bogus "" } +int main () +{ + return foo[0] != 42; +} diff --git a/gcc/testsuite/g++.old-deja/g++.ext/asmspec1.C b/gcc/testsuite/g++.old-deja/g++.ext/asmspec1.C new file mode 100644 index 000000000..97d4b8e6b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ext/asmspec1.C @@ -0,0 +1,7 @@ +// { dg-do assemble { target i?86-*-* x86_64-*-* } } +// Origin: Anthony Green <green@cygnus.com> + +void foo () +{ + register const char *h asm("%esi") = "hey"; +} diff --git a/gcc/testsuite/g++.old-deja/g++.ext/attrib1.C b/gcc/testsuite/g++.old-deja/g++.ext/attrib1.C new file mode 100644 index 000000000..e87979166 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ext/attrib1.C @@ -0,0 +1,11 @@ +// { dg-do assemble { target i?86-*-* x86_64-*-* } } +// { dg-require-effective-target ilp32 } +// Test for using prefix attributes in a parameter decl. +// Contributed by Jason Merrill <jason@cygnus.com> + +#define _stdcall __attribute__ ((__stdcall__)) + +typedef void (_stdcall* pfn)(); + +void f (void (_stdcall*) ()); +void f (void (_stdcall* pfn)()); diff --git a/gcc/testsuite/g++.old-deja/g++.ext/attrib2.C b/gcc/testsuite/g++.old-deja/g++.ext/attrib2.C new file mode 100644 index 000000000..09b2bf2e6 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ext/attrib2.C @@ -0,0 +1,16 @@ +// { dg-do run { target i?86-*-* x86_64-*-* } } +// { dg-require-effective-target ilp32 } +// Test that stdcall doesn't prevent us from using op delete. +// Contributed by Jason Merrill <jason@cygnus.com> + +struct A { + void operator delete (void *) __attribute__ ((stdcall)); +}; + +void A::operator delete (void *) { } + +int main() +{ + A* ap = new A; + delete ap; +} diff --git a/gcc/testsuite/g++.old-deja/g++.ext/attrib3.C b/gcc/testsuite/g++.old-deja/g++.ext/attrib3.C new file mode 100644 index 000000000..7d9c70e3b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ext/attrib3.C @@ -0,0 +1,21 @@ +// { dg-do run { target i?86-*-* x86_64-*-* } } +// { dg-require-effective-target ilp32 } +// Test for proper handling of attributes in template instantiation. +// Contributed by Jason Merrill <jason@cygnus.com> + +template <class T> +struct A { + static void f () __attribute__ ((stdcall)); +}; + +template <class T> void +A<T>::f () { } + +void g (void (__attribute__ ((stdcall)) *p)()) { } +void g (int); + +int +main () +{ + g (&A<int>::f); +} diff --git a/gcc/testsuite/g++.old-deja/g++.ext/attrib4.C b/gcc/testsuite/g++.old-deja/g++.ext/attrib4.C new file mode 100644 index 000000000..5c2f03e4b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ext/attrib4.C @@ -0,0 +1,24 @@ +// { dg-do assemble } +// { dg-options "-Wformat" } +// Test that attributes are really applied to function declarations under +// various conditions. +// Contributed by Jason Merrill (jason@cygnus.com) + +#define PF __attribute__ ((format (printf, 1, 2))) + +struct A { + static PF void f (const char *, ...); + static PF void g (const char *, ...) { } + static void test (); +}; + +void PF h (const char *, ...); +void PF k (const char *, ...) { } + +void A::test () +{ + f ("%f", 42); // { dg-warning "argument 2" } + g ("%f", 42); // { dg-warning "argument 2" } + h ("%f", 42); // { dg-warning "argument 2" } + k ("%f", 42); // { dg-warning "argument 2" } +} diff --git a/gcc/testsuite/g++.old-deja/g++.ext/attrib5.C b/gcc/testsuite/g++.old-deja/g++.ext/attrib5.C new file mode 100644 index 000000000..fcc3c6167 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ext/attrib5.C @@ -0,0 +1,14 @@ +// { dg-do run { xfail alpha*-dec-osf* i?86-pc-cygwin } } +// Test that attributes weak and alias coexist. +// { dg-require-weak "" } +// { dg-require-alias "" } + +extern "C" { + void _f () { } + void f () __attribute__((weak, alias ("_f"))); +} + +int main () +{ + f (); +} diff --git a/gcc/testsuite/g++.old-deja/g++.ext/attrib6.C b/gcc/testsuite/g++.old-deja/g++.ext/attrib6.C new file mode 100644 index 000000000..5c12f0a70 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ext/attrib6.C @@ -0,0 +1,6 @@ +// { dg-do assemble } +// Test that postfix attributes only apply to a single declared object. +// (decl_attributes used to chain them onto the end of the prefix attributes, +// which caused them to apply to other declarations as well.) +// Origin: Joseph Myers <jsm28@cam.ac.uk>. +void __attribute__((__noreturn__)) foo (const char *, ...) __attribute__((__format__(__printf__, 1, 2))), bar (void); diff --git a/gcc/testsuite/g++.old-deja/g++.ext/bound1.C b/gcc/testsuite/g++.old-deja/g++.ext/bound1.C new file mode 100644 index 000000000..5812f4afa --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ext/bound1.C @@ -0,0 +1,29 @@ +// { dg-do assemble } +// { dg-options "-Wno-pmf-conversions" } +// Testcase for cast of bound pointer to member function. + +struct A { + int f (); +}; + +typedef int (*fptr)(A *); +typedef void* vptr; +typedef int (A::*pmf)(); + +void foo (A* ap, pmf fp, int A::* ip) +{ + fptr p; + vptr q; + A a; + + p = (fptr)(ap->*fp); + p = (fptr)(ap->*fp); + p = (fptr)(ap->*(&A::f)); + p = (fptr)(a.*fp); + p = (fptr)(a.*(&A::f)); + + q = (vptr)(ap->*fp); + q = (vptr)(ap->*(&A::f)); + q = (vptr)(a.*fp); + q = (vptr)(a.*(&A::f)); +} diff --git a/gcc/testsuite/g++.old-deja/g++.ext/constructor.C b/gcc/testsuite/g++.old-deja/g++.ext/constructor.C new file mode 100644 index 000000000..a7995bbfe --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ext/constructor.C @@ -0,0 +1,20 @@ +// { dg-do run } +// { dg-options "" } +// Testcase for constructor expressions (GNU extension) + +struct Any { + int *type; + int *addr; +}; + +int i, j; + +main () { + struct Any *ap = (struct Any *) + __builtin_alloca (sizeof(struct Any)); + *ap = ((struct Any){ &i, &j }) ; + + if (ap->type != &i || ap->addr != &j) + return 1; + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.ext/default.C b/gcc/testsuite/g++.old-deja/g++.ext/default.C new file mode 100644 index 000000000..9f4395e77 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ext/default.C @@ -0,0 +1,27 @@ +// { dg-do assemble } +// PRMS Id: 5353 +// This may be an extension, but it's a very common one... + +extern "C" int printf (const char *, ...); + +class A { +public: + static A*func (int = 3); + static A*(*ptr)(int = 4); // { dg-error "" } .* +}; + +A*(*A::ptr)(int) = &A::func; + +int main() +{ + A foo; + + A::ptr(); // { dg-error "" } .* + A::ptr(47); +} + +A*A::func(int i) +{ + printf("I = %d\n",i); + return (A*)0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.ext/delvoid.C b/gcc/testsuite/g++.old-deja/g++.ext/delvoid.C new file mode 100644 index 000000000..60f114b31 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ext/delvoid.C @@ -0,0 +1,12 @@ +// { dg-do run } +// { dg-options "-w" } +// Jason Merrill <jason@redhat.com> +// Test for deleting a void pointer, which the standard says is undefined, +// but which is used by several free C++ programs. + +void *p; + +int main () +{ + delete [] p; +} diff --git a/gcc/testsuite/g++.old-deja/g++.ext/jump1.C b/gcc/testsuite/g++.old-deja/g++.ext/jump1.C new file mode 100644 index 000000000..d5dcebca2 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ext/jump1.C @@ -0,0 +1,17 @@ +// { dg-do run } +// { dg-options "-fpermissive -w" } +// Test that we can jump over the declaration of a non-POD object. +// Contributed by Jason Merrill <jason@cygnus.com> + +struct A { }; +union U { + void (A::*p)(); +}; + +int main() +{ + goto foo; + U u; + foo: + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.ext/label1.C b/gcc/testsuite/g++.old-deja/g++.ext/label1.C new file mode 100644 index 000000000..8bf82ce7a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ext/label1.C @@ -0,0 +1,28 @@ +// { dg-do run } +// { dg-options "" } +// Origin: Mark Mitchell <mark@codesourcery.com> + +int main () +{ + int i = 0; + int j = 0; + int k = 0; + + l: + if (j) + return 0; + ({ + __label__ l; + k = 0; + l: + if (++k <= 2) + goto l; + ++i;}); + if (i > 1 || k != 3) + return 1; + else + { + j = 1; + goto l; + } +} diff --git a/gcc/testsuite/g++.old-deja/g++.ext/label2.C b/gcc/testsuite/g++.old-deja/g++.ext/label2.C new file mode 100644 index 000000000..1ba67d096 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ext/label2.C @@ -0,0 +1,35 @@ +// { dg-do run } +// { dg-options "" } +// Origin: Mark Mitchell <mark@codesourcery.com> + +template <class T> +int f () +{ + int i = 0; + int j = 0; + int k = 0; + + l: + if (j) + return 0; + ({ + __label__ l; + k = 0; + l: + if (++k <= 2) + goto l; + ++i;}); + if (i > 1 || k != 3) + return 1; + else + { + j = 1; + goto l; + } +} + +int main () +{ + return f<double>(); +} + diff --git a/gcc/testsuite/g++.old-deja/g++.ext/memconst.C b/gcc/testsuite/g++.old-deja/g++.ext/memconst.C new file mode 100644 index 000000000..7dd2df736 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ext/memconst.C @@ -0,0 +1,25 @@ +// { dg-do assemble } +// { dg-options "" } +// From: Ove.Ewerlid@syscon.uu.se (Ove Ewerlid) +// Subject: ss-940630:cc1plus: internal error +// Date: Sat, 2 Jul 1994 05:07:20 +0200 + +class qwerty { +public: + qwerty (const unsigned short userkey[8]); + ~qwerty (); +}; + +class foo { +private: + static const unsigned char * const dummy_key = (unsigned char*)"ThisIs a dummy!"; // { dg-error "" } + +public: + void bar (); +}; + +void +foo::bar () +{ + qwerty QWERTY ((unsigned short*)dummy_key); // { dg-error "" } +} diff --git a/gcc/testsuite/g++.old-deja/g++.ext/namedret1.C b/gcc/testsuite/g++.old-deja/g++.ext/namedret1.C new file mode 100644 index 000000000..29955fb52 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ext/namedret1.C @@ -0,0 +1,13 @@ +// { dg-do assemble } +// { dg-options "-Wno-deprecated" } + +int f(int x) return y(x) { } // { dg-error "" } + +extern "C" void abort (); + +int main() +{ + if (f(1) != 1 || f(2) != 2 || f(3) != 3) + abort (); + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.ext/namedret2.C b/gcc/testsuite/g++.old-deja/g++.ext/namedret2.C new file mode 100644 index 000000000..339fc11e2 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ext/namedret2.C @@ -0,0 +1,20 @@ +// { dg-do assemble { target alpha*-*-* } } +// { dg-options "-Wno-deprecated" } + +// This test verifies that return type promotion is working correctly. +// The Alpha ABI specifies that 32-bit return values have bit 31 propagated, +// i.e. the value is sign-extended even if the unpromoted type is unsigned. + +unsigned int f(unsigned int x) return y(x) { } // { dg-error "" } + +extern "C" void abort (); + +int main() +{ + typedef long (*long_func)(long); + long_func g = reinterpret_cast<long_func>(f); + + if (g(-1L) != -1L) + abort (); + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.ext/namedret3.C b/gcc/testsuite/g++.old-deja/g++.ext/namedret3.C new file mode 100644 index 000000000..7a0e0d594 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ext/namedret3.C @@ -0,0 +1,31 @@ +// { dg-do assemble } +// { dg-options "-Wno-deprecated" } + +extern "C" void abort(); + +int f2(int *x) +{ + *x = 1; + return 2; +} + +int f1() return x // { dg-error "" } +{ + f2(&x); // { dg-error "" } +} + +void g() +{ + int scratch[100]; + int i; + for (i = 0; i < 100; ++i) + scratch[i] = 0; +} + +int main() +{ + g(); + if (f1() != 1) + abort (); + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.ext/noweak1.C b/gcc/testsuite/g++.old-deja/g++.ext/noweak1.C new file mode 100644 index 000000000..7d73cba7a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ext/noweak1.C @@ -0,0 +1,17 @@ +// { dg-do run } +// { dg-options "-fno-weak" } +// Test that -fno-weak doesn't break explicit instantiation of static data. + +template <class T> struct A +{ + static int i; +}; + +template <class T> int A<T>::i = 42; + +template class A<int>; + +int main () +{ + return (A<int>::i != 42); +} diff --git a/gcc/testsuite/g++.old-deja/g++.ext/null1.C b/gcc/testsuite/g++.old-deja/g++.ext/null1.C new file mode 100644 index 000000000..6bbfe7e47 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ext/null1.C @@ -0,0 +1,9 @@ +// { dg-do run } +// Test for overloading with g++ NULL. + +void f (int *) { } +void f (char, char); +int main () +{ + f (__null); +} 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 000000000..f7c8018ec --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ext/overload1.C @@ -0,0 +1,20 @@ +// { dg-do assemble } +// { dg-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); // { dg-message "candidate" } +void Foo (float, int, X); // { dg-message "candidate" } + +void Baz () +{ + Foo (1, 1, 0); // { dg-warning "worst" } +} diff --git a/gcc/testsuite/g++.old-deja/g++.ext/pretty.C b/gcc/testsuite/g++.old-deja/g++.ext/pretty.C new file mode 100644 index 000000000..7a0029b23 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ext/pretty.C @@ -0,0 +1,42 @@ +// { dg-do assemble } +// Test for PRETTY_FUNCTION + +class SV; + +class SVTable // : public Debug +{ + // It is an array to pointer to a SV. + SV ** array; + + // This is the size of array. + int maxCount; + + // This is the current element count. + int count; + + void fatal_error (const char *f, ...); + +public: + SVTable (int size, const char *d); + SVTable (); + SVTable (const SVTable &); + ~SVTable () {} + +}; + + +SVTable::SVTable (int size, const char *d) + : maxCount (size), count (0)// , Debug (d) +{ + if (size < 0) + { + fatal_error ("%s: Invalid size: %d\n", __PRETTY_FUNCTION__, size); + } + + array = (SV **) new SV * [size]; + + if (array == 0) + { + fatal_error ("%s: Failed to allocate array\n", __PRETTY_FUNCTION__); + } +} diff --git a/gcc/testsuite/g++.old-deja/g++.ext/pretty2.C b/gcc/testsuite/g++.old-deja/g++.ext/pretty2.C new file mode 100644 index 000000000..26d4d71cd --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ext/pretty2.C @@ -0,0 +1,85 @@ +// { dg-do run } +// Copyright (C) 1999, 2000, 2003 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 21 Nov 1999 <nathan@acm.org> + +// make sure __FUNCTION__ and __PRETTY_FUNCTION__ work in member functions + +#include <stdio.h> +#include <string.h> + +static bool bad = false; + +struct X +{ + X (); + ~X (); + void fn (); + operator int (); +}; + +X::X () +{ + char const *function = __FUNCTION__; + char const *pretty = __PRETTY_FUNCTION__; + + printf ("ctor\n"); + printf ("__FUNCTION__ %s\n", function); + printf ("__PRETTY_FUNCTION__ %s\n", pretty); + + if (strcmp (function, "X")) + bad = true; + if (strcmp (pretty, "X::X()")) + bad = true; +} +X::~X () +{ + char const *function = __FUNCTION__; + char const *pretty = __PRETTY_FUNCTION__; + + printf ("dtor\n"); + printf ("__FUNCTION__ %s\n", function); + printf ("__PRETTY_FUNCTION__ %s\n", pretty); + + if (strcmp (function, "~X")) + bad = true; + if (strcmp (pretty, "X::~X()")) + bad = true; +} +void X::fn () +{ + char const *function = __FUNCTION__; + char const *pretty = __PRETTY_FUNCTION__; + + printf ("member fn\n"); + printf ("__FUNCTION__ %s\n", function); + printf ("__PRETTY_FUNCTION__ %s\n", pretty); + + if (strcmp (function, "fn")) + bad = true; + if (strcmp (pretty, "void X::fn()")) + bad = true; +} +X::operator int () +{ + char const *function = __FUNCTION__; + char const *pretty = __PRETTY_FUNCTION__; + + printf ("conversion\n"); + printf ("__FUNCTION__ %s\n", function); + printf ("__PRETTY_FUNCTION__ %s\n", pretty); + + if (strcmp (pretty, "X::operator int()")) + bad = true; + return 0; +} + +int main () +{ + { + X x; + + x.fn (); + (void)int (x); + } + return bad; +} diff --git a/gcc/testsuite/g++.old-deja/g++.ext/pretty3.C b/gcc/testsuite/g++.old-deja/g++.ext/pretty3.C new file mode 100644 index 000000000..6348ae1ee --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ext/pretty3.C @@ -0,0 +1,47 @@ +// { dg-do run } +// Copyright (C) 1999 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 21 Nov 1999 <nathan@acm.org> + +// make sure __FUNCTION__ and __PRETTY_FUNCTION__ work in templates + +#include <stdio.h> +#include <string.h> + +static bool bad = false; + +template<class T> void f1 (T) +{ + char const *function = __FUNCTION__; + char const *pretty = __PRETTY_FUNCTION__; + + printf ("generic\n"); + printf ("__FUNCTION__ %s\n", function); + printf ("__PRETTY_FUNCTION__ %s\n", pretty); + + if (strcmp (function, "f1")) + bad = true; + if (strcmp (pretty, "void f1(T) [with T = float]")) // only for float instantiation + bad = true; +} + +template<> void f1<int> (int) +{ + char const *function = __FUNCTION__; + char const *pretty = __PRETTY_FUNCTION__; + + printf ("specialized\n"); + printf ("__FUNCTION__ %s\n", function); + printf ("__PRETTY_FUNCTION__ %s\n", pretty); + + if (strcmp (function, "f1<int>")) + bad = true; + if (strcmp (pretty, "void f1(T) [with T = int]")) + bad = true; +} + +int main () +{ + f1(0); // f1<int> + f1(0.0f); // f1<float> + return bad; +} diff --git a/gcc/testsuite/g++.old-deja/g++.ext/pretty4.C b/gcc/testsuite/g++.old-deja/g++.ext/pretty4.C new file mode 100644 index 000000000..9017d5671 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ext/pretty4.C @@ -0,0 +1,85 @@ +// { dg-do run } +// Copyright (C) 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 3 Mar 2000 <nathan@codesourcery.com> + +// __PRETTY_FUNCTION__, __FUNCTION__ and __function__ should have the +// type char const [X], where X is the right value for that particular function + +static void const *strings[4]; +static void const *tpls[4]; +static unsigned pos = 0; +static int fail; +static void const *ptr = 0; + +void unover (char const (*)[5]) {} +void foo (char const (*)[5]) {} +void foo (void *) {fail = 1;} +void foo (void const *) {fail = 1;} +void baz (char const (&)[5]) {} + +template<unsigned I> void PV (char const (&objRef)[I]) +{ + strings[pos] = objRef; + tpls[pos] = __PRETTY_FUNCTION__; + pos++; +} + +void fn () +{ + PV (__FUNCTION__); + PV (__func__); + PV (__PRETTY_FUNCTION__); + PV ("wibble"); +} + +void baz () +{ + ptr = __FUNCTION__; + // there should be no string const merging + if (ptr == "baz") + fail = 1; + // but all uses should be the same. + if (ptr != __FUNCTION__) + fail = 1; +} +int baz (int) +{ + return ptr == __FUNCTION__; +} + +int main () +{ + // make sure we actually emit the VAR_DECL when needed, and things have the + // expected type. + foo (&__FUNCTION__); + baz (__FUNCTION__); + unover (&__FUNCTION__); + if (fail) + return 1; + + // __FUNCTION__ should be unique across functions with the same base name + // (it's a local static, _not_ a string). + baz (); + if (fail) + return 1; + if (baz (1)) + return 1; + fn (); + + // Check the names of fn. They should all be distinct strings (though two + // will have the same value). + if (strings[0] == strings[1]) + return 1; + if (strings[0] == strings[2]) + return 1; + if (strings[1] == strings[2]) + return 1; + + // check the names of the template functions so invoked + if (tpls[0] != tpls[1]) + return 1; + if (tpls[0] == tpls[2]) + return 1; + + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.ext/restrict1.C b/gcc/testsuite/g++.old-deja/g++.ext/restrict1.C new file mode 100644 index 000000000..0904eb690 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ext/restrict1.C @@ -0,0 +1,60 @@ +// { dg-do assemble } + +// Copyright (C) 1999 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 14 Nov 1999 <nathan@acm.org> +// Test our restrict object pointer extension + +struct A +{ + void f1() __restrict__; + void g1(int *__restrict__); + void f2() __restrict__; + void g2(int *__restrict__); + void f3(); + void g3(int *); + void f4(); + void g4(int *); +}; + +void A::f1 () __restrict__ {} +void A::g1 (int *__restrict__) {} + +void A::f2 () {} +void A::g2 (int *) {} + +void A::f3 () __restrict__ {} +void A::g3 (int *__restrict__) {} + +void A::f4 () {} +void A::g4 (int *) {} + +template <class T> struct X +{ + void f1() __restrict__; + void g1(int *__restrict__); + void f2() __restrict__; + void g2(int *__restrict__); + void f3(); + void g3(int *); + void f4(); + void g4(int *); +}; + +template <class T> void X<T>::f1 () __restrict__ {} +template <class T> void X<T>::g1 (int *__restrict__) {} +template <class T> void X<T>::f2 () {} +template <class T> void X<T>::g2 (int *) {} +template <class T> void X<T>::f3 () __restrict__ {} +template <class T> void X<T>::g3 (int *__restrict__) {} +template <class T> void X<T>::f4 () {} +template <class T> void X<T>::g4 (int *) {} + +void fn () +{ + X<int> g; + + g.f1 (); + g.f2 (); + g.f3 (); + g.f4 (); +} diff --git a/gcc/testsuite/g++.old-deja/g++.ext/return1.C b/gcc/testsuite/g++.old-deja/g++.ext/return1.C new file mode 100644 index 000000000..f6bbc4da2 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ext/return1.C @@ -0,0 +1,20 @@ +// { dg-do assemble } +// { dg-options "-Wno-deprecated" } +// Test that the named return value extension works when passed as a reference. +// Origin: Jason Merrill <jason@redhat.com> + +void f (int &i) +{ + i = 42; +} + +int g () return r // { dg-error "" } named return value +{ + f (r); // { dg-error "" } undeclared +} + +int main () +{ + int i = g (); + return (i != 42); +} diff --git a/gcc/testsuite/g++.old-deja/g++.ext/stmtexpr1.C b/gcc/testsuite/g++.old-deja/g++.ext/stmtexpr1.C new file mode 100644 index 000000000..a746fc36e --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ext/stmtexpr1.C @@ -0,0 +1,8 @@ +// { dg-do assemble } +// { dg-options "" } +// Origin: Mark Mitchell <mark@codesourcery.com> + +void f () +{ + int i = ({ l: 3; }); +} diff --git a/gcc/testsuite/g++.old-deja/g++.ext/syshdr1.C b/gcc/testsuite/g++.old-deja/g++.ext/syshdr1.C new file mode 100644 index 000000000..09e64bff6 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ext/syshdr1.C @@ -0,0 +1,11 @@ +// { dg-do assemble } +// { dg-options "" } +// Test that we don't complain about trying to define bool or wchar_t in a +// system header. + + +# 1 "syshdr1.C" +# 1 "syshdr1.h" 1 3 +typedef int bool; +typedef int wchar_t; +# 2 "syshdr1.C" 2 diff --git a/gcc/testsuite/g++.old-deja/g++.ext/typename1.C b/gcc/testsuite/g++.old-deja/g++.ext/typename1.C new file mode 100644 index 000000000..2efeba93d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ext/typename1.C @@ -0,0 +1,31 @@ +// { dg-do run } +// Bug: g++ forgets about the instantiation of class1 when looking up +// class11_value, and tries to look things up in class1<class2>. + +template<class ItIsInt> +struct class1 { + struct class11 { + typedef ItIsInt class11_value; + }; +}; + +template<class ItIsClass2> +struct class3 { + int f(); +}; + +template<class ItIsClass2> +int class3<ItIsClass2>::f() +{ + return typename class1<typename ItIsClass2::class2_value>::class11::class11_value(10); +} + +struct class2 { + typedef int class2_value; +}; + +int main() +{ + class3<class2> the_class3; + the_class3.f(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.ext/typeof1.C b/gcc/testsuite/g++.old-deja/g++.ext/typeof1.C new file mode 100644 index 000000000..892150445 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ext/typeof1.C @@ -0,0 +1,17 @@ +// { dg-do assemble } + +struct inttest { + int elem[1]; +}; + +template <class T> +void F(T x) +{ + typedef __typeof (x.elem[0]) dummy; + dummy i = 1; +} + +int main() { + inttest x; + F(x); +} diff --git a/gcc/testsuite/g++.old-deja/g++.ext/typeof2.C b/gcc/testsuite/g++.old-deja/g++.ext/typeof2.C new file mode 100644 index 000000000..008ecf6da --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ext/typeof2.C @@ -0,0 +1,8 @@ +// { dg-do assemble } +// Origin: Mark Mitchell <mark@codesourcery.com> + +struct S +{ + int i; + __typeof( S::i ) f (); +}; diff --git a/gcc/testsuite/g++.old-deja/g++.gb/README b/gcc/testsuite/g++.old-deja/g++.gb/README new file mode 100644 index 000000000..c61e450de --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.gb/README @@ -0,0 +1,20 @@ +These are my C++ signature and class-scoping tests. + +In changing my signature tests to DejaGnu style, I reduced the number +of tests from 40 to 25. They should still test the same features, +though. All of these tests are run. I don't have any tests yet to +check correct reporting of errors/warnings. + +The class scoping tests were in part derived from Vince Russo's +Renaissance operating system and in part written by myself in helping +Niklas Hallqvist test his rewrite of the scoping code. I had shared +some of these tests with Niklas, others were included in bug reports I +had sent to {g++,gcc}@cygnus.com. It is, therefore, possible that +these tests duplicate tests in other directories. + +All files in this directory, including this file, are Copyright +FSF 1995, 2007 and fall under the GPL version 3 or later. + +Gerald Baumgartner +gb@cs.purdue.edu +March 1, 1995 diff --git a/gcc/testsuite/g++.old-deja/g++.gb/scope01.C b/gcc/testsuite/g++.old-deja/g++.gb/scope01.C new file mode 100644 index 000000000..eb2b951b3 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.gb/scope01.C @@ -0,0 +1,4 @@ +// { dg-do assemble } +// GROUPS passed gb scope +struct c { typedef int t; }; +struct d { typedef char t; }; diff --git a/gcc/testsuite/g++.old-deja/g++.gb/scope02.C b/gcc/testsuite/g++.old-deja/g++.gb/scope02.C new file mode 100644 index 000000000..fbcd3a3f0 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.gb/scope02.C @@ -0,0 +1,10 @@ +// { dg-do assemble } +// GROUPS passed gb scope +struct c { + typedef int t; + struct d { + void foo (t &); + }; +}; + +void c::d::foo (t & x) { } diff --git a/gcc/testsuite/g++.old-deja/g++.gb/scope03.C b/gcc/testsuite/g++.old-deja/g++.gb/scope03.C new file mode 100644 index 000000000..701ff5c2a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.gb/scope03.C @@ -0,0 +1,10 @@ +// { dg-do assemble } +// GROUPS passed gb scope +struct c { + class t { }; + struct d { + void foo (t &); + }; +}; + +void c::d::foo (t & x) { } diff --git a/gcc/testsuite/g++.old-deja/g++.gb/scope04.C b/gcc/testsuite/g++.old-deja/g++.gb/scope04.C new file mode 100644 index 000000000..29e0dffea --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.gb/scope04.C @@ -0,0 +1,15 @@ +// { dg-do assemble } +// GROUPS passed gb scope +struct a { + struct c { + struct d { + static int foo (int); + }; + }; + + struct b { + int foo (int x) { return c::d::foo (x); } + }; +}; + +int a::c::d::foo (int) { return 0; } diff --git a/gcc/testsuite/g++.old-deja/g++.gb/scope05.C b/gcc/testsuite/g++.old-deja/g++.gb/scope05.C new file mode 100644 index 000000000..4c1fd0ea7 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.gb/scope05.C @@ -0,0 +1,12 @@ +// { dg-do assemble } +// GROUPS passed gb scope +struct C { + void foo (int); + void foo (char); + + struct D { + void foo (); + }; +}; + +void C::D::foo () { } diff --git a/gcc/testsuite/g++.old-deja/g++.gb/scope06.C b/gcc/testsuite/g++.old-deja/g++.gb/scope06.C new file mode 100644 index 000000000..cbcc4fde1 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.gb/scope06.C @@ -0,0 +1,16 @@ +// { dg-do assemble } +// { dg-prune-output "non-static data member initializers" } +// GROUPS passed gb scope +struct C { + struct D { + int x; + void foo (); + }; + const int Ok = 0; // { dg-error "" } initialization forbidden +}; + +void C::D::foo () +{ + // { dg-prune-output "from this location" } + x = Ok; +} diff --git a/gcc/testsuite/g++.old-deja/g++.gb/scope07.C b/gcc/testsuite/g++.old-deja/g++.gb/scope07.C new file mode 100644 index 000000000..a0de26980 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.gb/scope07.C @@ -0,0 +1,11 @@ +// { dg-do assemble } +// GROUPS passed gb scope +struct D { + friend class A; + friend class B; + friend class C; + + void foo (); +}; + +void D::foo () { } diff --git a/gcc/testsuite/g++.old-deja/g++.gb/scope08.C b/gcc/testsuite/g++.old-deja/g++.gb/scope08.C new file mode 100644 index 000000000..4f7c1d384 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.gb/scope08.C @@ -0,0 +1,14 @@ +// { dg-do assemble } +// GROUPS passed gb scope +template <class X> class C { +public: + int f (X ob) { return 0; } + int g (X ob) { return f (ob); } +}; + +class D { +public: + class E { public: E (); }; + + C <E> x; +}; diff --git a/gcc/testsuite/g++.old-deja/g++.gb/scope09.C b/gcc/testsuite/g++.old-deja/g++.gb/scope09.C new file mode 100644 index 000000000..8f7d5391b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.gb/scope09.C @@ -0,0 +1,16 @@ +// { dg-do assemble } +// GROUPS passed gb scope +class enclose { + int e; +protected: + class nested { + int n; + }; +}; + +class derived : public enclose { +protected: + class nested_derived : public nested { + int nd; + }; +}; diff --git a/gcc/testsuite/g++.old-deja/g++.gb/scope10.C b/gcc/testsuite/g++.old-deja/g++.gb/scope10.C new file mode 100644 index 000000000..ad19f96a1 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.gb/scope10.C @@ -0,0 +1,9 @@ +// { dg-do assemble } +// GROUPS passed gb scope +void Foo (void) +{ + class C { + public: + virtual int foo (void) { return 0; } + }; +} diff --git a/gcc/testsuite/g++.old-deja/g++.gb/scope11.C b/gcc/testsuite/g++.old-deja/g++.gb/scope11.C new file mode 100644 index 000000000..45f540f9d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.gb/scope11.C @@ -0,0 +1,28 @@ +// { dg-do assemble } +// GROUPS passed gb scope +template<class T, int N> class fixed_array { +public: + T _array[N]; +}; + +class Hash { +public: + Hash (int); +}; + +typedef fixed_array<char, 4> ipAddress_t; + +class IPAddress { +protected: + long _i; +public: + IPAddress (ipAddress_t ip) { } + IPAddress () { } + IPAddress netMask () { return *this; } + operator Hash (); +}; + +IPAddress::operator Hash () +{ + return Hash (_i); +} diff --git a/gcc/testsuite/g++.old-deja/g++.gb/scope12.C b/gcc/testsuite/g++.old-deja/g++.gb/scope12.C new file mode 100644 index 000000000..664e79118 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.gb/scope12.C @@ -0,0 +1,35 @@ +// { dg-do assemble } +// GROUPS passed gb scope +template<class T, int N> class FixedArray_t { +public: + T _array[N]; + + FixedArray_t () { } +}; + +typedef FixedArray_t<unsigned char, 4> IPAddress_t; + +class IPAddress { +public: + IPAddress (IPAddress_t ip) { } + + operator IPAddress_t () + { + IPAddress_t rv; + return rv; + } + + IPAddress () { } +}; + +class DatagramHeader { +public: + IPAddress _src; + + void setHeader (IPAddress); +}; + +void +DatagramHeader::setHeader (IPAddress) +{ +} diff --git a/gcc/testsuite/g++.old-deja/g++.gb/scope13.C b/gcc/testsuite/g++.old-deja/g++.gb/scope13.C new file mode 100644 index 000000000..5c625b9c2 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.gb/scope13.C @@ -0,0 +1,11 @@ +// { dg-do assemble } +// GROUPS passed gb scope +class X { +public: +}; + +class Y { +public: + void X(); + ::X X(int); +}; diff --git a/gcc/testsuite/g++.old-deja/g++.jason/2371.C b/gcc/testsuite/g++.old-deja/g++.jason/2371.C new file mode 100644 index 000000000..c4263d6a4 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/2371.C @@ -0,0 +1,551 @@ +// { dg-do run } +// { dg-options "" } +# 1 "SetLS.cc" +// GROUPS passed templates nested-classes +// +// The SetLS template test +// +// Wendell Baker, Berkeley CAD Group, 1993 (wbaker@ic.Berkeley.EDU) +// + +#pragma implementation "ListS.h" +#pragma implementation "SetLS.h" + +#include <cstdlib> +#include <iostream> +using namespace std; + +# 1 "../../templates/SetLS.h" 1 +// -*- C++ -*- + + + +// +// A Set Template - implemented with an ListS +// +// Wendell Baker, Berkeley CAD Group, 1993 (wbaker@ic.Berkeley.EDU) +// + + + + + +#pragma interface + + + + + +#define XTRUE true +#define XFALSE false + +# 37 "../../templates/SetLS.h" + + +# 1 "../../templates/ListS.h" 1 +// -*- C++ -*- + + + +// +// A List Template - providing a singly linked capability +// +// Wendell Baker, Berkeley CAD Group, 1993 (wbaker@ic.Berkeley.EDU) +// + + + + + +#pragma interface + + + + + + +# 1 "/projects/gnu-cygnus/gnu-cygnus-14/mips/lib/gcc-lib/decstation/cygnus-reno-1/g++-include/bool.h" 1 3 +// Defining XTRUE and XFALSE is usually a Bad Idea, +// because you will probably be inconsistent with anyone +// else who had the same clever idea. +// Therefore: DON'T USE THIS FILE. + + + + + + + + + +# 23 "../../templates/ListS.h" 2 + +# 37 "../../templates/ListS.h" + + + +// g++ reno-1 is not yet capable of creating templates with nested +// classes which instantiate the template arguments. +template<class T> +struct ListS_link { + T item; + ListS_link<T> *next; + + ListS_link(const T& i, ListS_link<T> *n = 0): item(i), next(n) + { } +}; + + +// +// For now, errors are raised by ::abort() because exceptions +// are not well implemented in cxx or at all in CC 3.0.1 +// +template<class T> +class ListS { +public: + ListS(); + ListS(const ListS<T>&); + ~ListS(); + + void operator=(const ListS<T>&); + + unsigned length() const + { return count; } + + void prepend(const T& item); + void append(const T& item); + void clear(); + + const T& head() const + { ensure_1(); + return head_link->item; } + T& head() + { ensure_1(); + return head_link->item; } + void head(T& fill) const + { ensure_1(); + fill = head_link->item; } + void remove_head() + { remove_head_filling(0); } + void remove_head(T& fill) + { remove_head_filling(&fill); } + + const T& tail() const + { ensure_1(); + return tail_link->item; } + T& tail() + { ensure_1(); + return tail_link->item; } + void tail(T& fill) const + { ensure_1(); + fill = tail_link->item; } + + class Vix { + public: + Vix(): owner(0), index(0) + { } + + // These are friend functions so that v == x is the same as x == v + friend int operator==(void *v, const Vix& x) + { return v == x.index; } + friend int operator==(const Vix& x, void *v) + { return v == x.index; } + friend int operator!=(void *v, const Vix& x) + { return v != x.index; } + friend int operator!=(const Vix& x, void *v) + { return v != x.index; } + friend int operator==(const Vix& x1, const Vix& x2) + { return x1.owner == x2.owner && x1.index == x2.index; } + friend int operator!=(const Vix& x1, const Vix& x2) + { return x1.owner != x2.owner || x1.index != x2.index; } + private: + friend class ListS<T>; + + + Vix(const ListS<T> *o, ListS_link<T> *i): owner(o), index(i) + { } + + + + + + const ListS<T> *owner; + + ListS_link<T> *index; + + + + }; + + Vix first() const + { return Vix(this, head_link); } + void next(Vix& x) const + { check(x); + if (x.index != 0) + x.index = x.index->next; } + T& operator()(const Vix& x) + { check(x); + return x.index->item; } + const T& operator()(const Vix& x) const + { check(x); + return x.index->item; } +protected: +# 154 "../../templates/ListS.h" + + + unsigned count; + + ListS_link<T> *head_link; // 0 for a zero-length list + ListS_link<T> *tail_link; // 0 for a zero-length list + + + + + +private: + // fill may be 0 (then don't fill) + void remove_head_filling(T *fill); + + void ensure_1() const + { if (0 == head_link) + ::abort(); } + void check(const Vix& x) const + { if (this != x.owner) + ::abort(); + if (0 == x.index) + ::abort(); } +}; + +template<class T> +ListS<T>::ListS(): +count(0), +head_link(0), +tail_link(0) +{ } + +template<class T> +ListS<T>::ListS(const ListS<T>& other): +count(0), +head_link(0), +tail_link(0) +{ + for (Vix x=other.first(); 0 != x; other.next(x)) + append(other(x)); +} + +template<class T> +ListS<T>::~ListS() +{ + clear(); +} + +template<class T> +void +ListS<T>::operator=(const ListS<T>& other) +{ + clear(); + for (Vix x=other.first(); 0 != x; other.next(x)) + append(other(x)); +} + +template<class T> +void +ListS<T>::prepend(const T& item) +{ + + head_link = new ListS_link<T>(item, head_link); + + + + if (0 == tail_link) + tail_link = head_link; + count++; +} + +template<class T> +void +ListS<T>::append(const T& item) +{ + + ListS_link<T> *new_link = new ListS_link<T>(item); + + + + if (0 == tail_link) { + head_link = new_link; + tail_link = new_link; + } else { + tail_link->next = new_link; + tail_link = tail_link->next; + } + count++; +} + +template<class T> +void +ListS<T>::clear() +{ + + ListS_link<T> *next, *l; + + + + for (l=head_link; 0 != l; l=next) { + next = l->next; + delete l; + } + + count = 0; + head_link = 0; + tail_link = 0; +} + +template<class T> +void +ListS<T>::remove_head_filling(T* fill) +// fill may be 0 in which case don't assign into it +{ + ensure_1(); + + ListS_link<T> *ohead = head_link; + + + + if (0 != fill) + *fill = ohead->item; + head_link = ohead->next; + if (0 == head_link) + tail_link = 0; + count--; + delete ohead; +} + + +# 40 "../../templates/SetLS.h" 2 + + +# 62 "../../templates/SetLS.h" + +template<class T> +class SetLS { +public: + SetLS(); + + void add(const T& item); + // There is no remove(const T& item) for this set + bool contains(const T& item) const; + + unsigned length() const + { return list.length(); } + + void clear() + { list.clear(); } + + class Vix { + public: + Vix(): owner(0), vix() + { } + + // These are friend functions so that v == x is the same as x == v + friend int operator==(void *v, const Vix& x) + { return v == x.vix; } + friend int operator==(const Vix& x, void *v) + { return v == x.vix; } + friend int operator!=(void *v, const Vix& x) + { return v != x.vix; } + friend int operator!=(const Vix& x, void *v) + { return v != x.vix; } + friend int operator==(const Vix& x1, const Vix& x2) + { return x1.owner == x2.owner && x1.vix == x2.vix; } + friend int operator!=(const Vix& x1, const Vix& x2) + { return x1.owner != x2.owner || x1.vix != x2.vix; } + private: + friend class SetLS<T>; + + Vix(const SetLS<T> *o, const typename ListS<T>::Vix& x): owner(o), vix(x) + { } + + const SetLS<T> *owner; + typename ListS<T>::Vix vix; + }; + friend class Vix; + + Vix first() const + { return Vix(this, list.first()); } + void next(Vix& x) const + { check(x); + list.next(x.vix); } + const T& operator()(const Vix& x) const + { check(x); + return list(x.vix); } + // There is item no remove(const Vix&) for this set +protected: + ListS<T> list; + +private: + void check(const Vix& x) const + { if (this != x.owner) + ::abort(); } +}; + + +template<class T> +SetLS<T>::SetLS(): + + + +list() + +{ } + +template<class T> +void +SetLS<T>::add(const T& item) +{ + if ( ! contains(item) ) { + + + + list.append(item); + + } +} + +template<class T> +bool +SetLS<T>::contains(const T& item) const +{ + for (Vix x=first(); 0 != x; next(x)) { + if (operator()(x) == item) + return XTRUE; + } + return XFALSE; +} + + +# 17 "SetLS.cc" 2 + + + +// In (most versions of) g++ 2.X, this use of typedefs has the effect +// of causing the instantiation of the templates, thereby testing the +// templates + +class test { +public: + test(): value(0) + { } + test(int v): value(v) + { } + + void print(ostream& out) const + { out << value; } + + friend int operator==(const test& a, const test& b); +private: + int value; +}; + +int +operator==(const test& a, const test& b) +{ + return a.value == b.value; +} + +ostream& +operator<<(ostream& o, const test& t) +{ + t.print(o); + return o; +} + +typedef SetLS<test> SLS; + +static ostream& +operator<<(ostream& o, const SLS& s) +{ + o << "set of " << s.length() << " = {"; + + bool first; + SetLS<test>::Vix x; + for (first=XTRUE, x=s.first(); 0 != x; s.next(x), first=XFALSE) { + if ( ! first ) + o << ','; + o << ' '; + s(x).print(o); + } + o << '}'; + + return o; +} + +SLS gsls; +const SLS gcsls; + +void foo() +{ + const unsigned SIZE = 20; + + // + // SetLS() + // SetLS(const SetLS<T>&) + // + SLS sls; + { + // Fill sls with some interesting values + for (unsigned i=0; i<SIZE; i++) { + test t = i; + sls.add(t); + } + } + + const SLS csls(sls); + + // + // void operator=(const SetLS<T>&); + // + sls = csls; + + // + // bool contains(const T& item) const + // + for (unsigned i=0; i<SIZE; i++) { + test t = i; + + int contains = sls.contains(t); + } + + // + // void clear() + // + sls.clear(); + if (sls.length() != 0) + ::abort(); + + sls = csls; + + // + // Vix first() const + // void next(Vix& x) const + // T& operator()(const Vix& x) + // const T& operator()(const Vix& x) const + // + SetLS<test>::Vix cx; + for (cx=csls.first(); 0 != cx; sls.next(cx)) { + if ( ! sls.contains(csls(cx)) ) + ::abort(); + } + + cout << "gsls:\t" << gsls << '\n'; + cout << "gcsls:\t" << gcsls << '\n'; + cout << "sls:\t" << sls << '\n'; + cout << "csls:\t" << csls << '\n'; +} + +// Dummy function so it'll run +int main() +{ + cout << "PASS" << endl; +} + +template class ListS<test>; diff --git a/gcc/testsuite/g++.old-deja/g++.jason/3523.C b/gcc/testsuite/g++.old-deja/g++.jason/3523.C new file mode 100644 index 000000000..a0ddc9ca1 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/3523.C @@ -0,0 +1,40 @@ +// { dg-do assemble } +// GROUPS passed assignment +class ccUnwind +{ +public: + virtual ~ccUnwind (); // comment out virtual, and void diag changes +}; + +template<class T> +class ccHandle : public ccUnwind // similarly comment out inheritance +{ +public: + ccHandle& operator = (const ccHandle& h); +}; + +class cc_Image; + +class ccImage : public ccHandle<cc_Image> +{ +public: +// reversing the order of the next two lines changes the diagnostic +// printed about the def of ccDisplay::image + ccImage (const ccImage &); + ccImage (const cc_Image &); +}; + +class ccDisplay +{ +public: + ccImage img; +//ccImage image ( ccImage i) {img = i; return img;} +// above line compiles + ccImage image ( ccImage i) { return img = i;} /* this gets void* error */ +}; + + + +// vd.C: In method `class ccImage ccDisplay::image (class ccImage)': +// vd.C:31: bad argument 1 for function `ccImage::ccImage (const class cc_Image&)' (type was void *) +// vd.C:31: in base initialization for class `ccImage' diff --git a/gcc/testsuite/g++.old-deja/g++.jason/access1.C b/gcc/testsuite/g++.old-deja/g++.jason/access1.C new file mode 100644 index 000000000..9d7104105 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/access1.C @@ -0,0 +1,17 @@ +// { dg-do assemble } +// Bug: access declarations are broken. + +class A { +public: + void foo (); +}; + +class B: private A { +public: + A::foo; +}; + +void foo() { + B b; + b.foo (); // { dg-bogus "" } +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/access10.C b/gcc/testsuite/g++.old-deja/g++.jason/access10.C new file mode 100644 index 000000000..a8a2bb9fd --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/access10.C @@ -0,0 +1,14 @@ +// { dg-do assemble } +// PRMS Id: 4839 +// Bug: The initializer of a static member of a class has the same acess +// rights as a member function. g++ doesn't realize that. + +class X +{ + X (int); + static X foo; +public: + void dummy(); +}; + +X X::foo = 9; diff --git a/gcc/testsuite/g++.old-deja/g++.jason/access11.C b/gcc/testsuite/g++.old-deja/g++.jason/access11.C new file mode 100644 index 000000000..dd30e26fa --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/access11.C @@ -0,0 +1,12 @@ +// { dg-do assemble } +// PRMS Id: 4900 +// Bug: g++ doesn't apply access control uniformly to type conversion operators + +struct A { +protected: + operator int * () const; +}; + +struct B : public A { + int * foo () { return A::operator int *(); } +}; diff --git a/gcc/testsuite/g++.old-deja/g++.jason/access12.C b/gcc/testsuite/g++.old-deja/g++.jason/access12.C new file mode 100644 index 000000000..a230069c4 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/access12.C @@ -0,0 +1,16 @@ +// { dg-do assemble } +// PRMS Id: 4694 +// Bug: g++ doesn't realize that A::i refers to a member of `this' in B(). + +class A { +protected: + int i; +}; + +struct B : public A { + B () { A::i = 0; } +}; + +struct C : public B { + C () { B::i = 0; } +}; diff --git a/gcc/testsuite/g++.old-deja/g++.jason/access13.C b/gcc/testsuite/g++.old-deja/g++.jason/access13.C new file mode 100644 index 000000000..a891aeaad --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/access13.C @@ -0,0 +1,15 @@ +// { dg-do assemble } +// PRMS Id: 4955 + +struct A { + protected: + int i; + void f (); +}; + +struct B: public A { + void g () { + this->A::i = 1; // { dg-bogus "" } access control failure + this->A::f(); // { dg-bogus "" } access control failure + } +}; diff --git a/gcc/testsuite/g++.old-deja/g++.jason/access14.C b/gcc/testsuite/g++.old-deja/g++.jason/access14.C new file mode 100644 index 000000000..baebfe4cf --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/access14.C @@ -0,0 +1,10 @@ +// { dg-do assemble } + +template <class T> struct A { T t; }; + +template <class T> class B: private T { + public: + T::t; // { dg-bogus "" } doesn't recognize access decl +}; + +template class B<A<int> >; diff --git a/gcc/testsuite/g++.old-deja/g++.jason/access15.C b/gcc/testsuite/g++.old-deja/g++.jason/access15.C new file mode 100644 index 000000000..d7a30f9ff --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/access15.C @@ -0,0 +1,18 @@ +// { dg-do assemble } +// Bug: g++ complains about Z being a private base when trying to +// initialize B::foo. + +struct Z { + Z(); + Z(int); +}; + +struct A : private Z { }; +struct B : public A +{ + ::Z foo; + B(); + B(const B&); +}; + +B::B() : foo(1) { } // { dg-bogus "" } diff --git a/gcc/testsuite/g++.old-deja/g++.jason/access16.C b/gcc/testsuite/g++.old-deja/g++.jason/access16.C new file mode 100644 index 000000000..4eb499b63 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/access16.C @@ -0,0 +1,20 @@ +// { dg-do assemble } +// Bug: g++ uses the same binfo for the a subobject of c and the a subobject +// of b, so basetype_paths get bashed improperly. + +class a { +protected: + virtual void foo() { } // { dg-bogus "" } +}; + +class b : public virtual a {}; + +class c : public b { +public: + void bar() { b::foo(); } // { dg-bogus "" } +}; + +int main() { + c test; + test.bar(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/access17.C b/gcc/testsuite/g++.old-deja/g++.jason/access17.C new file mode 100644 index 000000000..ec8949d77 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/access17.C @@ -0,0 +1,24 @@ +// { dg-do assemble } +// Make sure definitions of static members have the right access. + +struct A { +protected: + int i; // { dg-error "" } private + int f (); // { dg-error "" } +}; + +struct B: public A { + static int A::*p; + static int (A::*fp)(); +}; + +int A::* B::p = &A::i; // { dg-error "" } +int (A::* B::fp)() = &A::f; // { dg-error "" } + +struct C { + static int A::*p; + static int (A::*fp)(); +}; + +int A::* C::p = &A::i; // { dg-error "" } +int (A::* C::fp)() = &A::f; // { dg-error "" } diff --git a/gcc/testsuite/g++.old-deja/g++.jason/access18.C b/gcc/testsuite/g++.old-deja/g++.jason/access18.C new file mode 100644 index 000000000..900058cab --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/access18.C @@ -0,0 +1,24 @@ +// { dg-do assemble } +// { dg-options "-w" } +// PRMS Id: 5073 +// Bug: g++ doesn't catch access violations in base initializers. + +int r = 0; +class A { + private: + A() { r = 1; } // { dg-error "" } + ~A() {} // { dg-error "" } +}; + +class B : public A { + public: + B(): A() {} // { dg-error "" } + B(const B&) {} // { dg-error "" } + ~B() { } // { dg-error "" } private dtor +}; + +main() +{ + B b; + return r; +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/access2.C b/gcc/testsuite/g++.old-deja/g++.jason/access2.C new file mode 100644 index 000000000..ee5c0eae0 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/access2.C @@ -0,0 +1,11 @@ +// { dg-do assemble } +// Bug: g++ doesn't deal with friends also being derived classes. + +class A { + int i; + friend class B; +}; + +class B : public A { + void f () { i = 1; } +}; diff --git a/gcc/testsuite/g++.old-deja/g++.jason/access20.C b/gcc/testsuite/g++.old-deja/g++.jason/access20.C new file mode 100644 index 000000000..71ca1375f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/access20.C @@ -0,0 +1,39 @@ +// { dg-do assemble } +// PRMS Id: 6662 +// Bug: we crash trying to check the access on anglesSinesCosines. + +#define Double double + +class GCTransform +{ + protected: + struct angle + { + Double phi1 ; + Double phi2 ; + } ; + + struct sineAndCosine + { + Double cosine1 ; + Double cosine2 ; + Double sine1 ; + Double sine2 ; + } ; + + union anglesSinesCosines + { + struct angle a ; + struct sineAndCosine siCo ; + } ; +}; + +class GCTransTransmit : public GCTransform +{ + protected: + + struct GCTransTransmitDataTemp + { + union anglesSinesCosines t ; // causes abort + } ; +} ; diff --git a/gcc/testsuite/g++.old-deja/g++.jason/access21.C b/gcc/testsuite/g++.old-deja/g++.jason/access21.C new file mode 100644 index 000000000..7d876fce9 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/access21.C @@ -0,0 +1,22 @@ +// { dg-do assemble } +// PRMS Id: 6877 + +typedef __SIZE_TYPE__ size_t; +class aa { +public: + aa(); + ~aa(); +private: + int iaa; + void operator delete(void*, size_t); +}; + +class bb { +public: + aa caa; +}; // { dg-bogus "" } calling private delete + +void +f(){ + bb abb; +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/access22.C b/gcc/testsuite/g++.old-deja/g++.jason/access22.C new file mode 100644 index 000000000..efd09e52c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/access22.C @@ -0,0 +1,22 @@ +// { dg-do assemble } +// PRMS Id: 8518 +// Bug: Call to foo is not checked for accessibility + +class A +{ + private: + static void foo() {} // { dg-error "" } + public: + void goo() {} +}; + +struct B : public A +{ + void func() { foo(); } // { dg-error "" } +}; + +int main() +{ + B b; + b.func(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/access23.C b/gcc/testsuite/g++.old-deja/g++.jason/access23.C new file mode 100644 index 000000000..ff2c8e8bc --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/access23.C @@ -0,0 +1,80 @@ +// { dg-do assemble } +// PRMS Id: 9127 +// Bug: members of anonymous unions are not access-controlled. + +#include <stdio.h> + +struct Foo { +public: + union { + long A; + void *pX; + }; + union X { + long A; + void *pX; + } PUB ; + int PUB_A; +protected: + union { + long B; // { dg-error "" } protected + void *pY; // { dg-error "" } protected + } ; + union Y { + long B; + void *pY; + } PRT; // { dg-error "" } protected + int PRT_A; // { dg-error "" } protected +private: + union { + long C; // { dg-error "" } private + void *pZ; // { dg-error "" } private + }; + union Z { + long C; + void *pZ; + } PRV; // { dg-error "" } private + int PRV_A; // { dg-error "" } private +}; + +struct Bar : public Foo { +public: + void DoSomething() { + PUB_A = 0; + Foo::A = 0; + printf("%x\n",pX); + Foo::PUB.A = 0; + printf("%x\n",PUB.pX); + B = 0; + printf("%x\n",Foo::pY); + PRT_A = 0; + PRT.B = 0; + printf("%x\n",Foo::PRT.pY); + PRV_A = 0; // { dg-error "" } + Foo::C = 0; // { dg-error "" } + printf("%x\n",pZ); // { dg-error "" } + Foo::PRV.C = 0; // { dg-error "" } + printf("%x\n",PRV.pZ); // { dg-error "" } + } +}; + +int main() +{ + Foo a; + + a.PUB_A = 0; + a.A = 0; + printf("%x\n",a.pX); + a.PRT_A = 0; // { dg-error "" } + a.B = 0; // { dg-error "" } + printf("%x\n",a.pY); // { dg-error "" } + a.PRV_A = 0; // { dg-error "" } + a.C = 0; // { dg-error "" } + printf("%x\n",a.pZ); // { dg-error "" } + a.PUB.A = 0; + printf("%x\n",a.PUB.pX); + a.PRT.B = 0; // { dg-error "" } + printf("%x\n",a.PRT.pY); // { dg-error "" } + a.PRV.C = 0; // { dg-error "" } + printf("%x\n",a.PRV.pZ); // { dg-error "" } +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/access24.C b/gcc/testsuite/g++.old-deja/g++.jason/access24.C new file mode 100644 index 000000000..e633766ac --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/access24.C @@ -0,0 +1,11 @@ +// { dg-do assemble } +// Bug: forward reference to friend doesn't work in template. + +template <class T> class A { + static int i; + friend struct B; +}; + +struct B { + void f () { A<int>::i = 0; } +}; diff --git a/gcc/testsuite/g++.old-deja/g++.jason/access3.C b/gcc/testsuite/g++.old-deja/g++.jason/access3.C new file mode 100644 index 000000000..c4e1b1880 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/access3.C @@ -0,0 +1,12 @@ +// { dg-do assemble } +// Simple testcase for access control. + +class A { + protected: + void f (); +}; + +class B : public A { + public: + void f () { A::f(); } +}; diff --git a/gcc/testsuite/g++.old-deja/g++.jason/access4.C b/gcc/testsuite/g++.old-deja/g++.jason/access4.C new file mode 100644 index 000000000..fd4eb3719 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/access4.C @@ -0,0 +1,14 @@ +// { dg-do assemble } +// Simple testcase for access control. + +class A { +protected: + static int i; +}; + +class B: public A { }; + +class C: public B { +public: + void g () { B b; b.i; } +}; diff --git a/gcc/testsuite/g++.old-deja/g++.jason/access5.C b/gcc/testsuite/g++.old-deja/g++.jason/access5.C new file mode 100644 index 000000000..03e7d7a45 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/access5.C @@ -0,0 +1,12 @@ +// { dg-do assemble } +// Simple testcase for access control. + +class A { + protected: + void f (); +}; + +class B : public A { }; +class C : public B { + void f () { B::f(); } +}; diff --git a/gcc/testsuite/g++.old-deja/g++.jason/access6.C b/gcc/testsuite/g++.old-deja/g++.jason/access6.C new file mode 100644 index 000000000..f75a44d2d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/access6.C @@ -0,0 +1,12 @@ +// { dg-do assemble } +// Simple testcase for access control. + +class A { + public: + void f (); +}; + +class B: protected A { }; +class C: protected B { + void g() { f (); } +}; diff --git a/gcc/testsuite/g++.old-deja/g++.jason/access7.C b/gcc/testsuite/g++.old-deja/g++.jason/access7.C new file mode 100644 index 000000000..edb4bc978 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/access7.C @@ -0,0 +1,13 @@ +// { dg-do assemble } +// Simple testcase for access control. + +class A { + protected: + static void f (); +}; + +class B: public A {}; +class C: public A {}; +class D: public C, public B { + void g () { A::f(); } // { dg-bogus "" } wrongly ambiguous static member call +}; diff --git a/gcc/testsuite/g++.old-deja/g++.jason/access8.C b/gcc/testsuite/g++.old-deja/g++.jason/access8.C new file mode 100644 index 000000000..0297c106b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/access8.C @@ -0,0 +1,30 @@ +// { dg-do assemble } +// From: smidt@dd.chalmers.se (Peter Smidt) +// Date: 25 Jan 1994 23:41:33 -0500 +// Bug: g++ forgets access decls after the definition. + +class inh { // { dg-error "" } inaccessible + int a; +protected: + void myf(int); +}; + +class mel : private inh { +protected: + int t; + inh::myf; +}; + +class top_t : protected mel { +public: + void myf(int); +}; + +void inh::myf(int i) { + a = i; +} + +void top_t::myf(int i) { + inh::myf(i); // { dg-error "" } cannot convert to inh + mel::myf(i); +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/access9.C b/gcc/testsuite/g++.old-deja/g++.jason/access9.C new file mode 100644 index 000000000..6cc1440bf --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/access9.C @@ -0,0 +1,9 @@ +// { dg-do assemble } +// Bug: g++ doesn't allow const objects to be constructed. + +struct B { B(); }; + +const B foo() +{ + return B(); // { dg-bogus "" } constructing const +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/aggregate.C b/gcc/testsuite/g++.old-deja/g++.jason/aggregate.C new file mode 100644 index 000000000..f739e56d0 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/aggregate.C @@ -0,0 +1,14 @@ +// { dg-do run } +struct A { int i; }; + +int main() +{ + A a1 = { 42 }; + A a2 (a1); + A a3 = { 137 }; + a1 = a3; + + if (a1.i == 137 && a2.i == 42 && a3.i == 137) + return 0; + return 1; +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/ambig1.C b/gcc/testsuite/g++.old-deja/g++.jason/ambig1.C new file mode 100644 index 000000000..9be10eb3a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/ambig1.C @@ -0,0 +1,7 @@ +// { dg-do assemble } +// { dg-options "-pedantic-errors" } +// Testcase for ambiguity between functional cast and abstract declarator. +// This ambiguity accounts for 6 of the r/r conflicts. + +int i = sizeof (int ()); // { dg-error "" } sizeof applied to fn type +int j = sizeof (int () + 1); diff --git a/gcc/testsuite/g++.old-deja/g++.jason/ambig2.C b/gcc/testsuite/g++.old-deja/g++.jason/ambig2.C new file mode 100644 index 000000000..1a6f67f25 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/ambig2.C @@ -0,0 +1,11 @@ +// { dg-do assemble } +// { dg-options "-Wno-pointer-arith" } +// Testcase for ambiguity between cast and parmlist. +// This ambiguity accounts for 1 of the r/r conflicts. +// Do not compile with -pedantic so that the compiler will accept taking +// the sizeof a function type. + +void f(){ + (void)sizeof(int((int)1.2)); + (void)sizeof(int((int))); // { dg-bogus "" } +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/ambig3.C b/gcc/testsuite/g++.old-deja/g++.jason/ambig3.C new file mode 100644 index 000000000..08cf2b7dc --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/ambig3.C @@ -0,0 +1,16 @@ +// { dg-do assemble } +// Testcase for ambiguity between function and variable declaration (8.2). + +struct A { + A (int, int); + int k; +}; + +void f () +{ + int i[2], j; + A a (int (i[1]), j); // { dg-bogus "" } late parsing + A b (int (i[1]), int j); // function + a.k = 0; // { dg-bogus "" } late parsing + b (i, j); +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/anon.C b/gcc/testsuite/g++.old-deja/g++.jason/anon.C new file mode 100644 index 000000000..e970359f8 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/anon.C @@ -0,0 +1,19 @@ +// { dg-do run } +// Bug: g++ has trouble copying anonymous structs. + +typedef struct { int i; } foo; +struct A : public foo { + struct { int i; } x; +}; + +int main () +{ + A a; + a.i = 5; + a.x.i = 42; + A b (a); + a = b; + if (a.i != 5 || a.x.i != 42) + return 1; + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/anon2.C b/gcc/testsuite/g++.old-deja/g++.jason/anon2.C new file mode 100644 index 000000000..2aba55649 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/anon2.C @@ -0,0 +1,7 @@ +// { dg-do assemble } +// g++ should not complain about anonymous bitfields. + +struct A +{ + int : 2; +}; diff --git a/gcc/testsuite/g++.old-deja/g++.jason/anon3.C b/gcc/testsuite/g++.old-deja/g++.jason/anon3.C new file mode 100644 index 000000000..d2964f5aa --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/anon3.C @@ -0,0 +1,25 @@ +// { dg-do assemble } +// Bug: g++ dies. + +class cl { +public: + cl(); + void set(void *, char *, int); +private: + union { + float vf; + struct ff { // { dg-error "" } nested class in anonymous union + void *ptr; + char *name; + int sz; + } *vff; + }; +}; + +void cl::set(void *p, char *n, int sz) +{ + vff = new ff; // This procude an internal compiler error. + vff->ptr = p; + vff->name = n; + vff->sz = sz; +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/anon4.C b/gcc/testsuite/g++.old-deja/g++.jason/anon4.C new file mode 100644 index 000000000..588bf263c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/anon4.C @@ -0,0 +1,14 @@ +// { dg-do assemble } +// { dg-options "-O" } +// PRMS Id: 5371 +// Bug: g++ screws up the alignment of buff and dies. + +main() +{ + union { + double a; + char buff[sizeof(double)]; + }; + + void *p = buff; +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/binding.C b/gcc/testsuite/g++.old-deja/g++.jason/binding.C new file mode 100644 index 000000000..1f297b76d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/binding.C @@ -0,0 +1,12 @@ +// { dg-do assemble } +// Bug: g++ only looks in the current temporary binding level for a name. + +struct T { ~T(); }; + +int main() +{ + foo: + T t; // { dg-error "" } redeclared + bar: + T t; // { dg-error "" } redeclaration +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/binding2.C b/gcc/testsuite/g++.old-deja/g++.jason/binding2.C new file mode 100644 index 000000000..5a7328125 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/binding2.C @@ -0,0 +1,15 @@ +// { dg-do assemble } +// Bug: g++ screws up binding levels in a switch statement with cleanups. + +struct A { + ~A() { } +}; + +int f (int i) +{ + switch (i) { + default: + A a; + } + return 1; +} // causes compiler segfault diff --git a/gcc/testsuite/g++.old-deja/g++.jason/binding3.C b/gcc/testsuite/g++.old-deja/g++.jason/binding3.C new file mode 100644 index 000000000..5ed4bd18c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/binding3.C @@ -0,0 +1,20 @@ +// { dg-do assemble } +// Bug: g++ fails to clear out the IDENTIFIER_CLASS_VALUEs of various names +// after a class definition. + +struct A { + typedef double T; + virtual T f () = 0; +}; + +class B { + B (const B&); + void operator=(const B&); +public: + B (); + typedef void * T; +}; + +struct C : public A { + T f (); // { dg-bogus "" } +}; diff --git a/gcc/testsuite/g++.old-deja/g++.jason/bool.C b/gcc/testsuite/g++.old-deja/g++.jason/bool.C new file mode 100644 index 000000000..5e897bc54 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/bool.C @@ -0,0 +1,46 @@ +// { dg-do assemble } +// Testcase for uses of bool. + +int i,j,k; + +/* Check that types of certain expressions are bool. */ +void f () +{ + i ? j == k : true; + i ? j < k : true; + i ? j && k : true; +} + +/* Check that g++ can find a conversion to bool when one exists. */ +struct A { operator char * (); } a; +struct B { operator int (); } b; +struct C { operator float (); } c; +struct D { operator bool (); } d; +struct E { operator int E::* (); } e; + +void g () +{ + a || true; + b || true; + c || true; // { dg-bogus "" } + d || true; + e || true; +} + +/* Check for support in templates. */ +template <class T> struct F { }; +template class F<bool>; + +template <class T> void f (T, bool) { } +template void f (bool, bool); + +/* Special cases. */ +void h () +{ + /* Used to cause infinite recursion. */ + i&1 || true; + /* Should find conversion path to int. */ + d == true; +} + +bool boo = -1; diff --git a/gcc/testsuite/g++.old-deja/g++.jason/bool2.C b/gcc/testsuite/g++.old-deja/g++.jason/bool2.C new file mode 100644 index 000000000..e77bd8487 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/bool2.C @@ -0,0 +1,15 @@ +// { dg-do run } +// Make sure that bool bitfields promote to int properly. + +struct F { + bool b1 : 1; + bool b2 : 7; +}; + +int main() +{ + F f = { true, true }; + + if (int (f.b1) != 1) + return 1; +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/bool3.C b/gcc/testsuite/g++.old-deja/g++.jason/bool3.C new file mode 100644 index 000000000..4e31003ce --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/bool3.C @@ -0,0 +1,13 @@ +// { dg-do assemble } +// From: panisset@cae.ca (Jean-Francois Panisset) +// Subject: Problem with constant expressions for bitfields +// Date: Mon, 6 Jun 94 14:00:01 EDT + +// Bug: g++ doesn't treat boolean true and false as constant values. + +enum E { e1,e2,e3,e4,e5 }; + +struct X +{ + unsigned int bits : ((e5 > 4) ? 8 : 4); // { dg-bogus "" } constant expression +}; diff --git a/gcc/testsuite/g++.old-deja/g++.jason/bool4.C b/gcc/testsuite/g++.old-deja/g++.jason/bool4.C new file mode 100644 index 000000000..03b670c39 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/bool4.C @@ -0,0 +1,11 @@ +// { dg-do run } +// Test for allowing conversion to bool. + +struct A { }; + +int main () +{ + bool b = (void*)0; + b = (int A::*)0; + b = (int (A::*)())0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/bool5.C b/gcc/testsuite/g++.old-deja/g++.jason/bool5.C new file mode 100644 index 000000000..1d2f5b60b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/bool5.C @@ -0,0 +1,11 @@ +// { dg-do run } +int main () +{ + bool b = false; + int i = b++; + if (i != false || b != true) + return 1; + i = b++; + if (i != true || b != true) + return 1; +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/bool6.C b/gcc/testsuite/g++.old-deja/g++.jason/bool6.C new file mode 100644 index 000000000..30d046961 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/bool6.C @@ -0,0 +1,9 @@ +// { dg-do assemble } +// Bug: The conversion from bool to int gets stripped. + +bool b; + +int main () +{ + return ((!b) != 0); +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/bool7.C b/gcc/testsuite/g++.old-deja/g++.jason/bool7.C new file mode 100644 index 000000000..dd1a6f2a4 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/bool7.C @@ -0,0 +1,29 @@ +// { dg-do assemble } + +struct A +{ + operator bool () const; + operator const void * () const; +}; + +struct B +{ + A a; + int foo1 (); + int foo2 (); +}; + +int +B::foo1 () +{ + return a ? 0 : 1; // ambiguous default type conversion for `operator !=' +} + +int +B::foo2 () +{ + if (a) + return 0; + else + return 1; +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/builtin.C b/gcc/testsuite/g++.old-deja/g++.jason/builtin.C new file mode 100644 index 000000000..e310165c6 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/builtin.C @@ -0,0 +1,10 @@ +// { dg-do assemble } +// { dg-options "-w" } +// Bug: g++ overloads strlen instead of bashing the builtin version. + +extern "C" void strlen (const char *); + +void f () +{ + strlen("Hi"); +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/builtin2.C b/gcc/testsuite/g++.old-deja/g++.jason/builtin2.C new file mode 100644 index 000000000..16e4f4aa8 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/builtin2.C @@ -0,0 +1,8 @@ +// { dg-do assemble } + +static inline void strlen (const char *) { } + +void f () +{ + strlen("Hi"); // { dg-bogus "" } wrongful overload +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/byval.C b/gcc/testsuite/g++.old-deja/g++.jason/byval.C new file mode 100644 index 000000000..e09c6ea66 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/byval.C @@ -0,0 +1,20 @@ +// { dg-do run } +// Bug: a is destroyed in both foo() and main() + +int count; + +struct A { + double a,b; + A(int) { count++; } + A(const A&) { count++; } + ~A() { count--; } +}; + +void foo (A a) +{ } + +int main() +{ + foo (1); + return count; +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/byval2.C b/gcc/testsuite/g++.old-deja/g++.jason/byval2.C new file mode 100644 index 000000000..40bf2a365 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/byval2.C @@ -0,0 +1,23 @@ +// { dg-do assemble } +// From: panisset@cae.ca (Jean-Francois Panisset) +// Subject: 2.6.0 pre-rel, internal error, regression, mips-sgi-irix4 +// Date: Thu, 14 Jul 94 23:34:21 EDT + +class Char +{ +protected: + char rep; +public: + Char (const char ) {} + operator char() const; + void operator -= (const Char ); +}; + +inline Char operator - (const Char a, const Char b) { return Char(0); } +inline char operator == (const Char a, const char b) { return 0; } + +char mystrcmp(Char s[31], Char t[31]) +{ + for (; *s == *t; ++s, ++t) if (*s == '\0') return 0; + return char(*s - *t); +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/byval3.C b/gcc/testsuite/g++.old-deja/g++.jason/byval3.C new file mode 100644 index 000000000..f56fc1243 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/byval3.C @@ -0,0 +1,14 @@ +// { dg-do assemble } +// Test to make sure that value return of classes with cleanups works; it +// has been broken at various times on PCC_STATIC_STRUCT_RETURN targets. + +struct A {}; + +struct R : virtual A { virtual ~R(); }; + +R g(); + +void encode() +{ + g(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/c-inline.C b/gcc/testsuite/g++.old-deja/g++.jason/c-inline.C new file mode 100644 index 000000000..c16fbde7d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/c-inline.C @@ -0,0 +1,11 @@ +// { dg-do assemble } +// Bug: the compiler gets hopelessly confused. + +#line 1 "c-inline.h" +#pragma interface +inline double abs (double) { return 0.0; } +inline short abs (short) { return 0; } +#line 2 "c-inline.C" +extern "C" { + inline int abs (int) { return 0; } // causes segfault - +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/cast1.C b/gcc/testsuite/g++.old-deja/g++.jason/cast1.C new file mode 100644 index 000000000..2bc16f352 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/cast1.C @@ -0,0 +1,8 @@ +// { dg-do assemble } +// Bug: g++ fails to grok functional casts in all situations. + +class A { +public: + typedef int B; + static B foo() { return B(1); } // { dg-bogus "" } +}; diff --git a/gcc/testsuite/g++.old-deja/g++.jason/cast2.C b/gcc/testsuite/g++.old-deja/g++.jason/cast2.C new file mode 100644 index 000000000..bd0fe7923 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/cast2.C @@ -0,0 +1,15 @@ +// { dg-do assemble } +// The compiler tried to build up a double with a NOP_EXPR from +// integer_zero_node, which fails. + +template <class T> +class vector { +public: + vector (int n, const T& value = T()) {} +}; + +void +foo (void) +{ + vector<double> v (10); +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/cast3.C b/gcc/testsuite/g++.old-deja/g++.jason/cast3.C new file mode 100644 index 000000000..fa3474288 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/cast3.C @@ -0,0 +1,16 @@ +// { dg-do assemble } +// PRMS Id: 7088 + +struct string +{ + int length () const; + string (string &); + string (char * = 0); + int operator [] (int); + ~string (); +}; + +void _cook(const string raw, bool for_postscript) +{ + unsigned char c = (unsigned) ((string &)raw)[1]; +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/cleanup.C b/gcc/testsuite/g++.old-deja/g++.jason/cleanup.C new file mode 100644 index 000000000..adf824622 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/cleanup.C @@ -0,0 +1,24 @@ +// { dg-do run } +// Bug: continue over object decl calls destructor but not constructor. + +int c = 0; +int d = 0; +extern "C" int printf(const char *,...); + +class Foo { +public: + Foo(){ c++; } + ~Foo(){ d++; } +}; + +int main() +{ + for(int i=0;i<2;i++){ + continue; + Foo bar; + } + printf ("%d %d\n", c, d); + if (c == d && d == 0) + return 0; + return 1; +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/cleanup2.C b/gcc/testsuite/g++.old-deja/g++.jason/cleanup2.C new file mode 100644 index 000000000..5b933937b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/cleanup2.C @@ -0,0 +1,15 @@ +// { dg-do assemble } +// PRMS Id: 6303 +// Bug: compiler crashes processing the cleanup for arrayOfClass. + +class Klasse { +public: + ~Klasse(); // This dtor MUST be declared to generate the error... +}; + +Klasse varOfClass; + +int main() { + // This MUST be 'const' to generate the error... + const Klasse arrayOfClass[1] = { varOfClass }; // causes abort +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/complete1.C b/gcc/testsuite/g++.old-deja/g++.jason/complete1.C new file mode 100644 index 000000000..d854ffdec --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/complete1.C @@ -0,0 +1,12 @@ +// { dg-do assemble } +// PRMS Id: 4695 +// Bug: g++ wrongly requires A to be complete here. + +struct A; + +void foo(const A &); + +void bar(A *p) +{ + foo(*p); +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/cond.C b/gcc/testsuite/g++.old-deja/g++.jason/cond.C new file mode 100644 index 000000000..d0616e4be --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/cond.C @@ -0,0 +1,58 @@ +// { dg-do assemble } +// GROUPS passed rtti +// Negative testcase for decls in conditions. + +int main() +{ + float i; + + if (int i = 1) // { dg-error "" "" { xfail *-*-* } } , + { + char i; // { dg-error "" "" { xfail *-*-* } } , + char j; + } + else + { + short i; // { dg-error "" "" { xfail *-*-* } } , + char j; + } + + while (int i = 0) // { dg-error "previously" } + { + int i; // { dg-error "redeclaration" } + } + + for (; int i = 0; ) // { dg-error "previously" } + { + int i; // { dg-error "redeclaration" } + } + + switch (int i = 0) // { dg-error "" "" { xfail *-*-* } } + { + default: + int i; // { dg-error "" "" { xfail *-*-* } } + } + + if (struct A { operator int () { return 1; } } *foo = new A) // { dg-error "defined" } + ; + + A bar; // { dg-error "not declared" "decl" } + // { dg-error "expected" "exp" { target *-*-* } 39 } + + if (enum A { one, two, three } foo = one) // { dg-error "defined" "def" } + // { dg-error "not declared" "expected" { target *-*-* } 42 } + ; + + struct B { operator int () { return 2; } }; + + if (struct B * foo = new B) + ; + + if (int f () = 1) // { dg-warning "extern" "extern" } + // { dg-error "is initialized like a variable" "var" { target *-*-* } 51 } + ; + + if (int a[2] = {1, 2}) // { dg-error "extended init" } + ; + +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/cond2.C b/gcc/testsuite/g++.old-deja/g++.jason/cond2.C new file mode 100644 index 000000000..d1ff6a9c7 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/cond2.C @@ -0,0 +1,66 @@ +// { dg-do run } +// Positive testcase for decls in conditions. + +extern "C" int printf(const char *, ...); + +int up = 0; +int down = 0; + +struct T +{ + int i; + T(int j) { i = j; printf("UP\n"); up++; } + T(const T& t) { i = t.i; printf("unwanted copy\n"); } + ~T() { printf ("DOWN\n"); down++; } + operator int () { return i; } +}; + +int main () +{ + int t; + + if (T t = 1) + ; + + printf ("\n"); + + int j = 3; + while (T t = j--) + ; + + printf ("\n"); + + j = 3; + while (1) + { + T t = j--; + if (t) continue; + break; + } + + printf ("\n"); + + j = 3; + for (;T t = j--;) + ; + + printf ("\n"); + + for (int k = 3; T t = k--;) + ; + + printf ("\n"); + + switch (T t = 34) + { + case 34: + ; + } + + printf ("\n"); + + if (up == down && up == 18) + return 0; + else + return 1; +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/condexp.C b/gcc/testsuite/g++.old-deja/g++.jason/condexp.C new file mode 100644 index 000000000..be333657d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/condexp.C @@ -0,0 +1,14 @@ +// { dg-do assemble } +// PRMS id: 5629 + +struct String { const char *x; }; +class Pathname: public String { }; + +String +f(int i) +{ + Pathname p; + String s; + + return i ? p: s; +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/const.C b/gcc/testsuite/g++.old-deja/g++.jason/const.C new file mode 100644 index 000000000..7c497ee99 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/const.C @@ -0,0 +1,17 @@ +// { dg-do run } +// Bug: a ends up in the text segment, so trying to initialize it causes +// a seg fault. + +struct A { + int i; + A(): i(0) {} + A(int j): i(j) {} +}; + +const A a; +const A b(1); + +int main () +{ + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/const2.C b/gcc/testsuite/g++.old-deja/g++.jason/const2.C new file mode 100644 index 000000000..b6aa6d4a7 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/const2.C @@ -0,0 +1,15 @@ +// { dg-do run } +// Example of static member constants + +extern "C" int printf (const char *, ...); + +struct T { + static const char letter = 'a'; // this is the new stuff! + char x[letter]; + void f(); +}; + +void T::f() { printf ("%p", &letter); } +const char T::letter; // still need def after class + +int main() { } diff --git a/gcc/testsuite/g++.old-deja/g++.jason/const3.C b/gcc/testsuite/g++.old-deja/g++.jason/const3.C new file mode 100644 index 000000000..813b398c9 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/const3.C @@ -0,0 +1,11 @@ +// { dg-do run } +// Bug: bar isn't emitted, which causes havoc. + +extern int i; +const int bar = i; +int i = 5; + +int main() +{ + return bar != 5; +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/const4.C b/gcc/testsuite/g++.old-deja/g++.jason/const4.C new file mode 100644 index 000000000..d29c46b74 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/const4.C @@ -0,0 +1,25 @@ +// { dg-do assemble } +// PRMS Id: 8927 +// Bug: complex inheritance interferes with const checking + +class GrandParent { +public: + virtual void DoIt(); +protected: + int A; +}; + +class Parent : virtual public GrandParent { +public: + virtual void DoX() const; +}; + +class Child : public Parent { +public: + void DoX() const; +}; + +void Child::DoX() const +{ + A = 10; // { dg-error "" } assignment to const +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/context.C b/gcc/testsuite/g++.old-deja/g++.jason/context.C new file mode 100644 index 000000000..a4d30bf1f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/context.C @@ -0,0 +1,20 @@ +// { dg-do assemble } +// PRMS Id: 3988 +// Bug: DECL_CONTEXT of A::B gets clobbered in pushdecl when defining A::foo(). + +#pragma implementation "context.h" +#line 1 "context.h" +#pragma interface + +template <class T> +struct A { + inline void foo () { } + class B { }; +}; + +struct C : public A<int> { + void bar (C::B&); +}; +#line 2 "context.C" + +void C::bar (C::B& b) { } diff --git a/gcc/testsuite/g++.old-deja/g++.jason/conversion.C b/gcc/testsuite/g++.old-deja/g++.jason/conversion.C new file mode 100644 index 000000000..4c4b96117 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/conversion.C @@ -0,0 +1,16 @@ +// { dg-do assemble } +// Bug: g++ doesn't find the conversion path from DPtr& to B*. + +class B {}; +class D : public B {}; +class DPtr +{ +public: + operator D*() const; +}; + +void foo (B* bp); +void bar (DPtr& dp) +{ + foo (dp); +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/conversion10.C b/gcc/testsuite/g++.old-deja/g++.jason/conversion10.C new file mode 100644 index 000000000..8cbba413d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/conversion10.C @@ -0,0 +1,19 @@ +// { dg-do assemble } +// PRMS Id: 9019 +// Bug: g++ doesn't find conversion to const char *. + +struct String { + String (); + explicit String (const char *); + operator const char * (); +}; + +int main(int argc, char **argv) +{ + String deflt("no args"); + String useme; + + const char *p = (argv[1]) ? argv[1] : deflt; + + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/conversion11.C b/gcc/testsuite/g++.old-deja/g++.jason/conversion11.C new file mode 100644 index 000000000..6621a27b6 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/conversion11.C @@ -0,0 +1,29 @@ +// { dg-do assemble } +// PRMS Id: 8805 +// Bug: The two-level conversion is not found when calling a global fn. + +class Int { +public: + Int(int A); +}; + +class Ding { +public: + Ding(Int A); +}; + +class Something { +public: + void DoSomething(Ding A); // { dg-message "Something::DoSomething|no known conversion" } referred to +}; + +void DoSomething(Ding A); + +void foo(Something* pX) +{ + DoSomething(1); // { dg-error "could not convert" } + pX->DoSomething(1); // { dg-error "no matching" } + // { dg-message "candidate" "candidate note" { target *-*-* } 25 } + (*pX).DoSomething(1); // { dg-error "no matching" } + // { dg-message "candidate" "candidate note" { target *-*-* } 27 } +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/conversion2.C b/gcc/testsuite/g++.old-deja/g++.jason/conversion2.C new file mode 100644 index 000000000..ebc2bd1eb --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/conversion2.C @@ -0,0 +1,7 @@ +// { dg-do assemble } +// PRMS Id: 3069 + +void f(int&); // { dg-error "" } referenced by error below +void g(const int& i) { + f(i); // { dg-error "" } discarding const +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/conversion3.C b/gcc/testsuite/g++.old-deja/g++.jason/conversion3.C new file mode 100644 index 000000000..6dbd475c6 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/conversion3.C @@ -0,0 +1,8 @@ +// { dg-do assemble } +void qsort (void *, int, int, int (*)(const void *, const void *)); +int f (char *, char *); +void g () +{ + typedef int (*pf)(void *, void *); + qsort(0, 0, 0, pf(f)); // { dg-error "" } adding const to function parms +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/conversion4.C b/gcc/testsuite/g++.old-deja/g++.jason/conversion4.C new file mode 100644 index 000000000..68973a554 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/conversion4.C @@ -0,0 +1,14 @@ +// { dg-do assemble } +struct A { + A (int); +}; +struct B { + operator int () { return 1; } +}; +void f (const A&); +void g() +{ + B b; + f ((A) b); + f (A (b)); // { dg-bogus "" } functional cast treated differently from C style +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/conversion5.C b/gcc/testsuite/g++.old-deja/g++.jason/conversion5.C new file mode 100644 index 000000000..0031084db --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/conversion5.C @@ -0,0 +1,13 @@ +// { dg-do assemble } +// { dg-options "-Wconversion" } +struct A { }; +struct B: public A { + A a; + operator A () { return a; } // { dg-warning "" } never used implicitly +}; +void f (const A&); +void g() +{ + B b; + (A) b; // { dg-bogus "" } trying both constructor and type conversion operator +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/conversion6.C b/gcc/testsuite/g++.old-deja/g++.jason/conversion6.C new file mode 100644 index 000000000..5f5a51a2f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/conversion6.C @@ -0,0 +1,41 @@ +// { dg-do run } +// PRMS Id: g++/6034 + +extern "C" int printf (const char *, ...); + +class Base +{ + char x; +}; + +template <class T> +// remove the public Base inheritance and the problem goes away... +class Container : public Base +{ +public: + + Container(const T& aValue): myValue(aValue) { } + + operator const T&(void) const + { + printf("Container::const T& called\n"); + return myValue; + } + +protected: + + T myValue; +}; + +typedef unsigned short Type; + +typedef Container<Type> TypeContainer; + +int main(void) +{ + TypeContainer myTypeContainer(2); + Type t = myTypeContainer; + + printf ("myType = %d\n", t); + return t != 2; +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/conversion7.C b/gcc/testsuite/g++.old-deja/g++.jason/conversion7.C new file mode 100644 index 000000000..925433ef6 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/conversion7.C @@ -0,0 +1,17 @@ +// { dg-do run } +// Bug: g++ tries to look inside (B*)0 for a virtual base pointer. + +struct A +{ +}; + +struct B : virtual A +{ +}; + +A* a; + +int main() +{ + a = (B*)0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/conversion8.C b/gcc/testsuite/g++.old-deja/g++.jason/conversion8.C new file mode 100644 index 000000000..c23b0dedd --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/conversion8.C @@ -0,0 +1,11 @@ +// { dg-do run } +// PRMS id: 8279 + +int main () +{ + char *const *p = 0; + char **q = 0; + + (void)(p - q); + (void)(q - p); +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/conversion9.C b/gcc/testsuite/g++.old-deja/g++.jason/conversion9.C new file mode 100644 index 000000000..aeda02816 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/conversion9.C @@ -0,0 +1,14 @@ +// { dg-do run } +// PRMS Id: 8475 + +class SomeClass { +public: + operator int & () { + static int x; + return x; + } +} a; + +int main (int, char**) { + return a + 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/crash1.C b/gcc/testsuite/g++.old-deja/g++.jason/crash1.C new file mode 100644 index 000000000..078f349ce --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/crash1.C @@ -0,0 +1,29 @@ +// { dg-do assemble } +// Bug: g++ dies on this input. + +class Sample + { + public: + int operator <<(const char *c); + }; + +extern Sample sample; + +struct Simple + { + int a; + }; + +extern "C" void get_it(); + +class Test + { + private: + void test(); + friend void get_it(); + }; + +void Test::test() + { + sample << "hello"; + } diff --git a/gcc/testsuite/g++.old-deja/g++.jason/crash10.C b/gcc/testsuite/g++.old-deja/g++.jason/crash10.C new file mode 100644 index 000000000..cd9b7b0b2 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/crash10.C @@ -0,0 +1,8 @@ +// { dg-do assemble } +// PRMS Id: 5155 + +struct A { + enum foo { bar }; +}; + +typedef A::foo A::foo; // { dg-error "" } causes compiler segfault diff --git a/gcc/testsuite/g++.old-deja/g++.jason/crash11.C b/gcc/testsuite/g++.old-deja/g++.jason/crash11.C new file mode 100644 index 000000000..1883e175a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/crash11.C @@ -0,0 +1,9 @@ +// { dg-do assemble } +// Bug: g++ crashes on this input. + +struct A { + const char *p; +}; +const char foo[] = "bar"; +const A a = { foo }; +extern const A* ap = &a; //{ dg-warning "'ap' initialized and declared 'extern'" } diff --git a/gcc/testsuite/g++.old-deja/g++.jason/crash12.C b/gcc/testsuite/g++.old-deja/g++.jason/crash12.C new file mode 100644 index 000000000..c3906a8d1 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/crash12.C @@ -0,0 +1,10 @@ +// { dg-do assemble } +// Bug: g++ dies instead of flagging this invalid. + +inline float max(float x, float y) { return (x>y)?x:y; } + +float b(float x, float y, float z) +{ + float f = (y<x)?x:(max<y)?z:y; // { dg-error "" } + return f; +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/crash3.C b/gcc/testsuite/g++.old-deja/g++.jason/crash3.C new file mode 100644 index 000000000..9dcf6368a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/crash3.C @@ -0,0 +1,14 @@ +// { dg-do assemble } +// Bug: g++ tries to generate initialization semantics for a Node from an int, +// and fails. + +struct Node // { dg-message "note" } +{ + Node* child[2]; +}; + +void bug(int i) +{ + Node* q = new Node(i); // { dg-error "no matching" } + // { dg-message "candidate" "candidate note" { target *-*-* } 12 } +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/crash4.C b/gcc/testsuite/g++.old-deja/g++.jason/crash4.C new file mode 100644 index 000000000..00ba0cc06 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/crash4.C @@ -0,0 +1,38 @@ +// { dg-do assemble } +// PRMS Id: 4346 +// Bug: g++ dies on redefinition of cc_Array::repInvariant. + +class ccObjectInfo +{ +public: + virtual const ccObjectInfo& repInvariant (int =0) const; +}; + +template <class T> +class cc_Array : public ccObjectInfo +{ +public: + virtual const ccObjectInfo& repInvariant (int =0) const ; +}; + +template <class T> +const ccObjectInfo& cc_Array<T>::repInvariant(int) const // { dg-error "previously declared" } +{ return *this /* *this is required here */; } + +template <class T> +class ccArray :public ccObjectInfo +{ + ccArray (cc_Array<T>*); +}; + +template <class T> +class ccObjArray : public ccArray<T> +{ + ccObjArray(); +}; + +template <class T> +const ccObjectInfo& cc_Array<T>::repInvariant(int) const // { dg-error "redefinition" } +{ return 0; } + +typedef ccObjArray< double> ccROIRuns; diff --git a/gcc/testsuite/g++.old-deja/g++.jason/crash5.C b/gcc/testsuite/g++.old-deja/g++.jason/crash5.C new file mode 100644 index 000000000..ae9e0e577 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/crash5.C @@ -0,0 +1,4 @@ +// { dg-do assemble } +// Bug: g++ doesn't deal well with abstract declarators used inappropriately. + +void (*)(); // { dg-error "" } diff --git a/gcc/testsuite/g++.old-deja/g++.jason/crash6.C b/gcc/testsuite/g++.old-deja/g++.jason/crash6.C new file mode 100644 index 000000000..274f3386a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/crash6.C @@ -0,0 +1,9 @@ +// { dg-do assemble } +// Bug: g++ dies on the below. + +class A { }; +void f () +{ + A a; + a.~a(); // { dg-error "" } causes segfault +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/crash7.C b/gcc/testsuite/g++.old-deja/g++.jason/crash7.C new file mode 100644 index 000000000..95c7c2fb5 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/crash7.C @@ -0,0 +1,6 @@ +// { dg-do assemble } +// Bug: g++ can't deal. + +typedef unsigned size_t; // { dg-error "" } previous declaration +typedef unsigned long size_t; // { dg-error "" } redefining size_t +void f (size_t); // causes compiler segfault - diff --git a/gcc/testsuite/g++.old-deja/g++.jason/crash8.C b/gcc/testsuite/g++.old-deja/g++.jason/crash8.C new file mode 100644 index 000000000..061652db2 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/crash8.C @@ -0,0 +1,10 @@ +// { dg-do assemble } +struct A { + A(); + A(A); // { dg-error "" } copy ctor must take reference +}; +int main() +{ + A a; + A b(a); // causes compiler segfault +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/crash9.C b/gcc/testsuite/g++.old-deja/g++.jason/crash9.C new file mode 100644 index 000000000..292d3548c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/crash9.C @@ -0,0 +1,29 @@ +// { dg-do assemble } +// PRMS Id: 5085 +// Bug: TYPE_POINTER_TO wasn't set. + +class A { + A(const A &); + void operator=(const A &); +public: + inline A(); +}; + +class B { + A a; +public: + B(); + virtual void f() const; +}; + +class C : public B { }; + +class D : C { +public: + void f() const; +}; + +void D::f() const +{ + C::f(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/ctor1.C b/gcc/testsuite/g++.old-deja/g++.jason/ctor1.C new file mode 100644 index 000000000..739071957 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/ctor1.C @@ -0,0 +1,27 @@ +// { dg-do run } +// PRMS Id: 5584 + +extern "C" +{ + struct xx { + void (*xx)(void); + int x,y; + }; +} + +int r = 1; + +void f(void) +{ + r = 0; +} + +int main() +{ + struct xx p; + + p.xx = f; + p.xx(); + + return r; +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/ctor2.C b/gcc/testsuite/g++.old-deja/g++.jason/ctor2.C new file mode 100644 index 000000000..e396dc064 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/ctor2.C @@ -0,0 +1,16 @@ +// { dg-do assemble } +// Bug: the reference to c in the initializer list doesn't get fixed up. + +struct AP { + AP(unsigned char); +}; + +struct AI : AP { + AI(unsigned char); +}; + +AI::AI(unsigned char c) +: AP(c) +{ + &c; +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/dcast1.C b/gcc/testsuite/g++.old-deja/g++.jason/dcast1.C new file mode 100644 index 000000000..9336cba11 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/dcast1.C @@ -0,0 +1,20 @@ +// { dg-do assemble } +// PRMS Id: 7162 + +struct B { + int i; + B() : i(1) {} +}; + +struct D : B { + int i; + D() : i(2) {} +}; + +void ch() +{ + D od2; + D &rd2 = od2; + + B &rd1 = dynamic_cast<B&>(rd2); +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/dcast2.C b/gcc/testsuite/g++.old-deja/g++.jason/dcast2.C new file mode 100644 index 000000000..62740834a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/dcast2.C @@ -0,0 +1,19 @@ +// { dg-do run } +struct A { virtual void f() { } }; +struct B { virtual void g() { } }; +struct C : public A, public B { }; + +int main () +{ + C* cp = 0; + B* bp = 0; + + if (dynamic_cast <B*> (cp) != 0) + return 1; + + if (dynamic_cast <void *> (bp) != 0) + return 1; + + if (dynamic_cast <C*> (bp) != 0) + return 1; +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/dcast3.C b/gcc/testsuite/g++.old-deja/g++.jason/dcast3.C new file mode 100644 index 000000000..a6179187f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/dcast3.C @@ -0,0 +1,33 @@ +// { dg-do run } +// Testcase for tricky dynamic cast situations. + +struct A { + virtual void f () { } +}; + +struct B : public A { }; +struct C : public B { }; +struct D : public B { }; +struct E : public C, public D { }; + +struct B2 : public virtual A { }; +struct C2 : public B2 { }; +struct D2 : public B2 { }; +struct E2 : public C2, public D2 { }; + +int main () +{ + E e; + E2 e2; + + A* ap = (C*)&e; + + // ap points to base subobject of unique B; succeeds + if (dynamic_cast <B*> (ap) == 0) + return 1; + + ap = (C2*)&e2; + // ap points to base subobject shared by two Bs; fails + if (dynamic_cast <B2*> (ap) != 0) + return 2; +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/default1.C b/gcc/testsuite/g++.old-deja/g++.jason/default1.C new file mode 100644 index 000000000..afbac13bf --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/default1.C @@ -0,0 +1,16 @@ +// { dg-do assemble } +// PRMS Id: 5204 +// Bug: g++ bashes the type of add_sym with the type of add, so calling it +// with one parameter generates an error. + +int add(int const &symbol, + const unsigned char flags=(void*)0); // { dg-error "" } invalid default arg + +int add_sym(int const &symbol, + const unsigned char flags=0); + +int main() +{ + int fname; + add_sym(fname); // Guarantee a symbol exists +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/default2.C b/gcc/testsuite/g++.old-deja/g++.jason/default2.C new file mode 100644 index 000000000..167ac635d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/default2.C @@ -0,0 +1,31 @@ +// { dg-do assemble } +// PRMS Id: 5921 +// Bug: default arguments containing constructor calls persist incorrectly. + +class foo +{ + public: + foo(); + foo(int x); + public: + int iamamember; +}; + +class bar +{ + public: + bar(); + int memberfunction(int i, const char *j, double k, foo foo1 = foo(0)); +}; + +int +pain(bar *bar1) +{ + return bar1->memberfunction(1, "x", 0.0); +} + +int +pain2(bar *bar1) +{ + return bar1->memberfunction(1, "x", 0.0); +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/default3.C b/gcc/testsuite/g++.old-deja/g++.jason/default3.C new file mode 100644 index 000000000..3e4951c8d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/default3.C @@ -0,0 +1,6 @@ +// { dg-do assemble } +// Bug: type_list_equal aborts when it sees lang-specific tree nodes. + +struct A { }; +void f (A a = A()); +void g (A a = A()); diff --git a/gcc/testsuite/g++.old-deja/g++.jason/defctor.C b/gcc/testsuite/g++.old-deja/g++.jason/defctor.C new file mode 100644 index 000000000..76efaa1f0 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/defctor.C @@ -0,0 +1,16 @@ +// { dg-do run } +// Bug: g++ doesn't generate default constructor. + +class A { +public: + int i; +}; + +extern "C" int printf(const char *, ...); + +int main () { + A a; + a.i = 1; + A b (a); + printf("%d\n",b.i); +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/delete1.C b/gcc/testsuite/g++.old-deja/g++.jason/delete1.C new file mode 100644 index 000000000..b170b2db6 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/delete1.C @@ -0,0 +1,6 @@ +// { dg-do assemble } +#include <stddef.h> +struct A { + virtual void operator delete (void *); // { dg-error "" } virtual delete + virtual void * operator new (size_t); // { dg-error "" } virtual new +}; diff --git a/gcc/testsuite/g++.old-deja/g++.jason/delete2.C b/gcc/testsuite/g++.old-deja/g++.jason/delete2.C new file mode 100644 index 000000000..c6230eef1 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/delete2.C @@ -0,0 +1,16 @@ +// { dg-do assemble } +// PRMS Id: 5003 +// Bug: g++ complains about calling the destructor for a const object. + +struct A { +public: + ~A(); +}; + +const A foo (); + +void bar() +{ + A n; + n = foo(); // { dg-bogus "" } deleting const +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/delete3.C b/gcc/testsuite/g++.old-deja/g++.jason/delete3.C new file mode 100644 index 000000000..bde62d968 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/delete3.C @@ -0,0 +1,19 @@ +// { dg-do assemble } +// PRMS Id: 6093 + +class A { +public: + A(); + ~A(); +protected: + void operator delete(void *); // { dg-error "" } protected +}; + +A::~A() +{ +} + +void foo(A *p) +{ + delete p; // { dg-error "" } in this context +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/destruct.C b/gcc/testsuite/g++.old-deja/g++.jason/destruct.C new file mode 100644 index 000000000..b0f2dfe10 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/destruct.C @@ -0,0 +1,34 @@ +// { dg-do assemble } +// Exhaustive test for destructors of simple types. +// PRMS Id: 2744, 3308 + +template <class T> class A { + T q; +public: + ~A() { + q.T::~T(); + q.~T(); + (&q)->T::~T(); + (&q)->~T(); + } +}; + +typedef char * cp; +typedef int I; + +int main () +{ + A<int> a; + A<cp> b; + int i; + cp c; + + i.~I(); + i.I::~I(); + (&i)->~I(); + (&i)->I::~I(); + c.~cp(); + c.cp::~cp(); + (&c)->~cp(); + (&c)->cp::~cp(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/destruct2.C b/gcc/testsuite/g++.old-deja/g++.jason/destruct2.C new file mode 100644 index 000000000..62c8f8fba --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/destruct2.C @@ -0,0 +1,20 @@ +// { dg-do assemble } +// PRMS Id: 4342 +// Bug: g++ does not massage things enough to allow calling ~X(). + +struct X +{ + virtual ~X (); +}; + +struct Y : public X +{}; + +struct Z : public Y, public X // { dg-warning "" } +{}; + +void foo () +{ + Z* f = new Z; + delete f; // { dg-bogus "" } +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/destruct3.C b/gcc/testsuite/g++.old-deja/g++.jason/destruct3.C new file mode 100644 index 000000000..3dc287c74 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/destruct3.C @@ -0,0 +1,45 @@ +// { dg-do assemble } +// { dg-options "-w" } +// PRMS Id: 4342 (second testcase) +// Bug: g++ still can't deal with ambiguous inheritance in destructor calls. + +struct ccUnwind +{ + ccUnwind (); + virtual ~ccUnwind (); +}; + +struct ccPersistent +{ + virtual void bar(); +}; + +struct ccImpExp : public ccPersistent, public ccUnwind +{}; + +struct ccTool : public ccImpExp +{}; + +struct ccScreenTool : public ccTool +{}; + +struct ccVTool : public ccScreenTool +{}; + +struct ccScreenObjRep : public ccUnwind +{}; + +struct ccScreenObj : public ccScreenObjRep +{}; + +struct ccVSTool : public ccImpExp, public ccUnwind +{}; + +struct ccSCCP : public ccVSTool +{}; + +void foo () +{ + ccSCCP* foo = new ccSCCP; + delete foo; +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/destruct4.C b/gcc/testsuite/g++.old-deja/g++.jason/destruct4.C new file mode 100644 index 000000000..4d4800b32 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/destruct4.C @@ -0,0 +1,14 @@ +// { dg-do assemble } +// PRMS Id: 4342 +// Bug: g++ fails to massage ambiguity in calling virtual destructor. + +class A { public: virtual ~A();}; +class B: public A { }; +class C: public A { }; +class D: public B, public C { }; + +void foo () +{ + D* p = new D; + delete p; +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/dot.C b/gcc/testsuite/g++.old-deja/g++.jason/dot.C new file mode 100644 index 000000000..41b8d814f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/dot.C @@ -0,0 +1,20 @@ +// { dg-do assemble } +// PRMS Id: 4143 +// Bug: Pointer is silently dereferenced in method call. + +extern "C" int printf (const char *, ...); + +class Test +{ + char ch; + public: + Test(char c) : ch(c) {} + void Print() { printf("%c", ch); } +}; + +int main() +{ + Test *p = new Test('x'); + + p.Print(); // { dg-error "" } +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/dtor.C b/gcc/testsuite/g++.old-deja/g++.jason/dtor.C new file mode 100644 index 000000000..2dc5f8cd6 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/dtor.C @@ -0,0 +1,14 @@ +// { dg-do assemble } +struct A { + ~A(); +}; + +struct B { + ~B(); +}; + +int main() +{ + A a; + a.~B(); // { dg-error "" } wrong name +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/dtor2.C b/gcc/testsuite/g++.old-deja/g++.jason/dtor2.C new file mode 100644 index 000000000..fa1e0a92b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/dtor2.C @@ -0,0 +1,11 @@ +// { dg-do run } +// PRMS Id: 5163 +// Bug: g++ doesn't accept the explicit destructor call syntax for templates. + +template <class T> struct A { }; +A<int> a; + +int main() +{ + a.~A(); // { dg-bogus "" } +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/dtor3.C b/gcc/testsuite/g++.old-deja/g++.jason/dtor3.C new file mode 100644 index 000000000..8eb887e27 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/dtor3.C @@ -0,0 +1,18 @@ +// { dg-do assemble } +// PRMS Id: 5341 +// Bug: g++ complains about the explicit destructor notation. + +#include <stddef.h> + +void *operator new(size_t Size, void* pThing) { return pThing; } + +template <class T> class Stack { +public: + Stack() { new (Data) T(); } + ~Stack() { ((T*)Data)->~T(); } +private: + char Data[sizeof(T)]; +}; + +Stack<int> a; +Stack<Stack<int> > c; diff --git a/gcc/testsuite/g++.old-deja/g++.jason/dtor4.C b/gcc/testsuite/g++.old-deja/g++.jason/dtor4.C new file mode 100644 index 000000000..25ef1cfe7 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/dtor4.C @@ -0,0 +1,23 @@ +// { dg-do assemble } +// PRMS Id: 5420 +// Bug: g++ gets mixed up calling destructors for references. + +template<class X> +class Z { +public: + char space[100]; + void kill() + { X& x = (X&) space[0]; + x.~X(); } +}; + +class C { int i; }; + +void +f() +{ + Z<int> r; + r.kill(); + Z<C> s; + s.kill(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/dtor5.C b/gcc/testsuite/g++.old-deja/g++.jason/dtor5.C new file mode 100644 index 000000000..3cf1d1cd0 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/dtor5.C @@ -0,0 +1,26 @@ +// { dg-do run } +// PRMS Id: 5286 +// Bug: g++ forgets side-effects of object in call to nonexistent destructor. + +#include <new> + +int r; + +template <class T> struct A { + T *p; + int i; + A() { i = 0; p = (T*) new char[sizeof (T)]; new (p + i++) T; } + ~A() { p[--i].~T(); r = i; } +}; + +int main() +{ + { A<int> a; } + + int* p = (int*) new char[sizeof (int)]; + new (p + r++) int; + typedef int I; + p[--r].~I(); + + return r; +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/enum.C b/gcc/testsuite/g++.old-deja/g++.jason/enum.C new file mode 100644 index 000000000..81b4574d8 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/enum.C @@ -0,0 +1,19 @@ +// { dg-do assemble } +// PRMS Id: 4337 +// Bug: Enums are not looked up to arbitrary depth. + +struct W { + enum A { B }; +}; + +struct X : public W +{}; + +struct Y : public X +{}; + +struct S +{ + X::A a1; + Y::A a2; // { dg-bogus "" } +}; diff --git a/gcc/testsuite/g++.old-deja/g++.jason/enum2.C b/gcc/testsuite/g++.old-deja/g++.jason/enum2.C new file mode 100644 index 000000000..2991af6ca --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/enum2.C @@ -0,0 +1,8 @@ +// { dg-do assemble } + +enum tristate { no = -1, maybe, yes }; + +void foobar () +{ + tristate var = no; // { dg-bogus "" } +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/enum3.C b/gcc/testsuite/g++.old-deja/g++.jason/enum3.C new file mode 100644 index 000000000..04e8f287b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/enum3.C @@ -0,0 +1,19 @@ +// { dg-do assemble } +// { dg-options "-Wall" } + +enum tristate { no = -1, maybe, yes }; + +tristate +tristate_satisfies (register tristate const t1, register tristate const t2) +{ + switch (t1) + { + case no: + return (tristate) -t2; + case maybe: + return yes; + case yes: + return t2; + } + return maybe; +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/enum4.C b/gcc/testsuite/g++.old-deja/g++.jason/enum4.C new file mode 100644 index 000000000..b8b1209d3 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/enum4.C @@ -0,0 +1,10 @@ +// { dg-do assemble } +// { dg-options "-Wall" } + +enum tristate { no = -1, maybe, yes }; + +tristate +definite_tristate (int truth) +{ + return (truth) ? yes : no; +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/enum5.C b/gcc/testsuite/g++.old-deja/g++.jason/enum5.C new file mode 100644 index 000000000..a05d4d346 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/enum5.C @@ -0,0 +1,9 @@ +// { dg-do run } +enum { a = 1 }; + +int main(void) +{ + int l = -1; + + return ! (l < a); // testcase fails if a is unsigned +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/enum6.C b/gcc/testsuite/g++.old-deja/g++.jason/enum6.C new file mode 100644 index 000000000..7be0cd868 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/enum6.C @@ -0,0 +1,27 @@ +// { dg-do run } +// { dg-options "-fshort-enums" } + +// On ARM EABI targets this testcase will cause a warning to be emitted +// whilst EABI attributes are being merged at link time unless +// the --no-enum-size-warning option is passed to the linker. Whilst the +// enum-size attributes should only be emitted if there are values of +// enum type that can escape the compilation unit, gcc cannot currently +// detect this; if this facility is added then this linker option should +// not be needed. arm-*-linux*eabi should be a good approximation to +// those platforms where the EABI supplement defines enum values to be +// 32 bits wide. +// { dg-options "-fshort-enums -Wl,--no-enum-size-warning" { target arm*-*-linux*eabi } } + +#include <limits.h> + +enum A { a1 = 0x7fffffff }; +enum B { b1 = 0x80000000 }; +enum C { c1 = -1, c2 = 0x80000000 }; +enum D { d1 = CHAR_MIN, d2 = CHAR_MAX }; +enum E { e1 = CHAR_MIN, e2 = CHAR_MIN }; + +main() +{ + return (sizeof (A) != 4 || sizeof (B) != 4 || sizeof (C) != 8 + || sizeof (D) != 1 || sizeof (E) != 1); +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/enum7.C b/gcc/testsuite/g++.old-deja/g++.jason/enum7.C new file mode 100644 index 000000000..38720efba --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/enum7.C @@ -0,0 +1,15 @@ +// { dg-do assemble } +// Yet Another testcase for signed/unsigned enums. + +enum A { AA = 0, AB = 1}; +enum B { BA = -1, BB = 1}; + +void set(int a); +void set(long a); + +void +foo() +{ + set(AA); // { dg-bogus "" } why is this ambiguous + set(BA); // when this is not amibguous +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/enum8.C b/gcc/testsuite/g++.old-deja/g++.jason/enum8.C new file mode 100644 index 000000000..9d0d94bf4 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/enum8.C @@ -0,0 +1,21 @@ +// { dg-do run } +// Bug: the switch fails on the Alpha because folding ef - 1 fails. + +enum foo { one=1, thirty=30 }; + +int f (enum foo ef) +{ + switch (ef) + { + case one: + case thirty: + return 0; + default: + return 1; + } +} + +int main () +{ + return f (one); +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/explicit.C b/gcc/testsuite/g++.old-deja/g++.jason/explicit.C new file mode 100644 index 000000000..e227792a0 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/explicit.C @@ -0,0 +1,15 @@ +// { dg-do assemble } +// Testcase for explicit instantiation of templates. + +template <class T> +class A { + T t; +public: + void f () { } +}; + +template class A<int>; + +template <class T> T min (T a, T b) { return (a < b ? a : b); } + +template int min (int, int); diff --git a/gcc/testsuite/g++.old-deja/g++.jason/expr1.C b/gcc/testsuite/g++.old-deja/g++.jason/expr1.C new file mode 100644 index 000000000..701e5a28a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/expr1.C @@ -0,0 +1,12 @@ +// { dg-do assemble } +// Bug: g++ doesn't figure out what to do. + +struct A { + operator char *(); +}; + +char foo(A a) +{ + char c = a[0]; // { dg-bogus "" } + return c; +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/friend.C b/gcc/testsuite/g++.old-deja/g++.jason/friend.C new file mode 100644 index 000000000..9bcc81488 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/friend.C @@ -0,0 +1,20 @@ +// { dg-do run } +// Bug: g++ doesn't keep track of the lexical context of friends properly. + +extern "C" void exit(int); + +struct B; +struct A { + static void f () { exit (1); } +}; + +struct B { + static void f () { exit (0); } + friend void g (B) { f (); } +}; + +int main () +{ + B b; + g (b); +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/friend2.C b/gcc/testsuite/g++.old-deja/g++.jason/friend2.C new file mode 100644 index 000000000..7264bd3b8 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/friend2.C @@ -0,0 +1,21 @@ +// { dg-do assemble } +// PRMS Id: 5189 +// Bug: g++ fails to collapse the several declarations of freefoo, so it isn't +// recognized as a friend. + +extern "C" +void freefoo(void); + +class foo { + friend void freefoo(void); + protected: + static void foomem(); + public: + foo(); + ~foo(); +}; + +void freefoo(void) +{ + foo::foomem(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/groff1.C b/gcc/testsuite/g++.old-deja/g++.jason/groff1.C new file mode 100644 index 000000000..636317956 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/groff1.C @@ -0,0 +1,41 @@ +// { dg-do run } +// PRMS Id: 3744 +// Bug: unswitching a COND_EXPR initializer fails to set SIDE_EFFECTS on the +// result, so expand_expr ignores it. + +extern "C" { + int printf(const char *,...); + void exit(int); +} + +struct A { + int x; + int y; + + A() : x(0), y(0) { } +}; + +struct S { + S() : flags(0) { } + unsigned flags; + A from; + void foo(const A &pos); +}; + +void S::foo(const A &pos) +{ + A a = flags ? from : pos; + printf("%d %d\n", a.x, a.y); + if (a.x != 17 || a.y != 12) + exit (1); +} + +int main() +{ + A pos; + pos.x = 17; + pos.y = 12; + S s; + s.foo(pos); + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/hmc1.C b/gcc/testsuite/g++.old-deja/g++.jason/hmc1.C new file mode 100644 index 000000000..b023125cf --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/hmc1.C @@ -0,0 +1,19 @@ +// { dg-do assemble } +// GROUPS passed templates default-arguments +template <class I> +class Klasse { +public: + void func1(int n=1); + void func2(int d) {} +}; +template <class I> +void Klasse<I>::func1(int n) {} + +//if this is replaced by: +//void Klasse<I>::func1(int n=1) {} +//the code compiles. + +int main() { + Klasse<int> C; + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/incomplete1.C b/gcc/testsuite/g++.old-deja/g++.jason/incomplete1.C new file mode 100644 index 000000000..e43ca711a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/incomplete1.C @@ -0,0 +1,15 @@ +// { dg-do assemble } +// The reference parameter to fred isn't dereferenced properly. + +class Gump {}; +Gump operator & (const Gump x){return x;} + +class B; + +void *sam(int &x) +{return &x;} + +const void *fred(const B& x) +{return &x;} // "&x" causes the compilation error. + +class B {}; diff --git a/gcc/testsuite/g++.old-deja/g++.jason/incomplete2.C b/gcc/testsuite/g++.old-deja/g++.jason/incomplete2.C new file mode 100644 index 000000000..f102220c6 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/incomplete2.C @@ -0,0 +1,7 @@ +// { dg-do assemble } + +struct A { + int foo(A a) { return a.bar(); } + int bar(); + int n; +}; diff --git a/gcc/testsuite/g++.old-deja/g++.jason/init.C b/gcc/testsuite/g++.old-deja/g++.jason/init.C new file mode 100644 index 000000000..6bb60d56c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/init.C @@ -0,0 +1,7 @@ +// { dg-do assemble } +// Bug: g++ uses an empty initializer list for its own devious purpose +// internally, and gets confused if it shows up in the input. + +struct A { int i; }; + +A a = { }; diff --git a/gcc/testsuite/g++.old-deja/g++.jason/init2.C b/gcc/testsuite/g++.old-deja/g++.jason/init2.C new file mode 100644 index 000000000..d1507afac --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/init2.C @@ -0,0 +1,10 @@ +// { dg-do run } +// PRMS Id: 5126 + +extern int i, j; +static const int foo [] = { i, j }; +int i = 5, j = 42; +int main() +{ + return foo[1] != 42; +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/init3.C b/gcc/testsuite/g++.old-deja/g++.jason/init3.C new file mode 100644 index 000000000..38e0e61d3 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/init3.C @@ -0,0 +1,42 @@ +// { dg-do run } +// PRMS Id: 5652 +// Bug: strings does not get initialized. + +#include <string.h> + +class My_string { + char *str; + int len; +public: + My_string(const char* string); + My_string(const My_string &); + ~My_string() { delete str; } + char* char_p() { return str; } +}; + +const My_string strings[4] = { + "first string", + "second string", + "third string", + "fourth string" +}; + +My_string::My_string(const char* string) +{ + len = strlen(string) + 1; + str = new char[len]; + memcpy(str, string, len); +} + +My_string::My_string(const My_string &string) +{ + len = string.len; + str = new char[len]; + memcpy(str, string.str, len); +} + +int main() +{ + My_string str1 = strings[0]; + return strcmp ("first string", str1.char_p ()) != 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/init4.C b/gcc/testsuite/g++.old-deja/g++.jason/init4.C new file mode 100644 index 000000000..2a937d5c4 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/init4.C @@ -0,0 +1,4 @@ +// { dg-do assemble } +struct A { int i; }; + +A a = {{{1}}}; // { dg-error "" } causes abort diff --git a/gcc/testsuite/g++.old-deja/g++.jason/inline.C b/gcc/testsuite/g++.old-deja/g++.jason/inline.C new file mode 100644 index 000000000..d614d541a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/inline.C @@ -0,0 +1,22 @@ +// { dg-do run } +// PRMS Id: 4341 +// Bug: Instantiating a template in the middle of processing the functions +// from another template screws up lineno/input_filename. + +#pragma implementation "C.h" +#line 1 "A.h" +#pragma interface +template <class T> class A {}; +#line 1 "C.h" +#pragma interface +template <class T> class C +{ +public: + C() { A<T> *ap; } + ~C() { } +}; +#line 18 "inline.C" +int main() +{ + C<int> c; +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/inline2.C b/gcc/testsuite/g++.old-deja/g++.jason/inline2.C new file mode 100644 index 000000000..b6198be14 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/inline2.C @@ -0,0 +1,12 @@ +// { dg-do assemble } +// { dg-options "-O" } +// Bug: the lang-specific bits of the decl for g aren't being copied when +// inlining. + +inline void f () { + void g (); +} + +void h() { + f(); // causes compiler segfault - +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/inline3.C b/gcc/testsuite/g++.old-deja/g++.jason/inline3.C new file mode 100644 index 000000000..a314b2029 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/inline3.C @@ -0,0 +1,43 @@ +// { dg-do run } +// { dg-options "-O2" } +// Testcase for order of destruction. + +extern "C" int printf (const char *, ...); +int c; +int r; + +struct B { + B(); + B( B const& ); + ~B(); +}; + +struct A { + A(); + A( A const& ); + ~A(); + operator B (); +}; + +inline A::operator B () { printf( "operator B ()\n"); return B(); } + +A f(); +void g( B const& ); + +int +main() +{ + g( f() ); + return r; +} + +B::B() { printf( "B::B()\n" ); if (++c != 2) r = 1; } +B::B( B const& ) { printf( "B::B( B const& )\n" ); r = 1; } +B::~B() { printf( "B::~B()\n" ); if (--c != 1) r = 1; } + +A::A() { printf( "A::A()\n" ); if (++c != 1) r = 1; } +A::A( A const& ) { printf( "A::A( A const& )\n" ); r = 1; } +A::~A() { printf( "A::~A()\n" ); if (--c != 0) r = 1; } + +A f() { printf( "f()\n"); return A(); } +void g( B const& ) { printf( "g()\n"); } diff --git a/gcc/testsuite/g++.old-deja/g++.jason/jump.C b/gcc/testsuite/g++.old-deja/g++.jason/jump.C new file mode 100644 index 000000000..d720a9288 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/jump.C @@ -0,0 +1,15 @@ +// { dg-do assemble } +// PRMS Id: 6036 + +extern int a; + +int main() { + switch (a) { + case 1: + int v2 = 3; // { dg-error "" } referenced below + case 2: // { dg-error "" } jumping past initializer + if (v2 == 7) + ; + } + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/lex1.C b/gcc/testsuite/g++.old-deja/g++.jason/lex1.C new file mode 100644 index 000000000..f183da1b7 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/lex1.C @@ -0,0 +1,7 @@ +// { dg-do run } +int main() +{ + char c = '\351'; + if (c != '\351') + return 1; +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/lineno.C b/gcc/testsuite/g++.old-deja/g++.jason/lineno.C new file mode 100644 index 000000000..bd5a393e5 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/lineno.C @@ -0,0 +1,6 @@ +// { dg-do assemble } +// Bug; g++ binds a function definition to the line number of a later decl. + +void foo () { } // { dg-error "" } redeclared +void foo (); // { dg-bogus "" } invalid binding +void foo () { } // { dg-error "" } redeclared diff --git a/gcc/testsuite/g++.old-deja/g++.jason/lineno2.C b/gcc/testsuite/g++.old-deja/g++.jason/lineno2.C new file mode 100644 index 000000000..7f3317649 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/lineno2.C @@ -0,0 +1,14 @@ +// { dg-do assemble } +// { dg-options "" } +// GROUPS passed error-reporting +// Bug: # line directive gets ignored immediately after text. +template <class T> class A +{ +public: +# 200 "lineno2.C" +}; + +main() +{ + undef1(); // { dg-error "" "" { target *-*-* } 204 } +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/lineno3.C b/gcc/testsuite/g++.old-deja/g++.jason/lineno3.C new file mode 100644 index 000000000..997267e72 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/lineno3.C @@ -0,0 +1,14 @@ +// { dg-do assemble } +// { dg-options "" } +// GROUPS passed error-reporting +// potential bug: # line directive does not get reproduced in template +// expansion +template <class T> class A +{ +public: +# 200 "lineno3.C" + int foo () { undef1(); } // { dg-error "" "" { target *-*-* } 200 } + // { dg-message "note" "note" { target *-*-* } 200 } +}; + +template class A<int>; diff --git a/gcc/testsuite/g++.old-deja/g++.jason/lineno4.C b/gcc/testsuite/g++.old-deja/g++.jason/lineno4.C new file mode 100644 index 000000000..caa5bc216 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/lineno4.C @@ -0,0 +1,14 @@ +// { dg-do assemble } +// { dg-options "" } +// GROUPS passed error-reporting +// Bug: # line directive in template definition interferes with growing obstack +template <class T> class A +{ +public: + +# 200 "lineno4.C" + int foo () { undef1(); } // { dg-error "" "" { target *-*-* } 200 } + // { dg-message "note" "note" { target *-*-* } 200 } +}; + +template class A<int>; diff --git a/gcc/testsuite/g++.old-deja/g++.jason/lineno5.C b/gcc/testsuite/g++.old-deja/g++.jason/lineno5.C new file mode 100644 index 000000000..f723a222b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/lineno5.C @@ -0,0 +1,10 @@ +// { dg-do assemble } +// GROUPS passed error-reporting +// Bug: incomplete instantiation messes with lineno +template <class T> class A; + +int main() +{ + A<int> *p; + undef1();// { dg-error "" } +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/local.C b/gcc/testsuite/g++.old-deja/g++.jason/local.C new file mode 100644 index 000000000..21fa9f587 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/local.C @@ -0,0 +1,21 @@ +// { dg-do assemble } +// General testcase for local classes. + +int x; +void f () +{ + static int s; + int x; // { dg-error "" } referenced below + extern int q(); + + struct local { + int g() { return x; } // { dg-error "" } automatic variable + int h() { return s; } // { dg-bogus "" } local class + int k() { return ::x; } // OK + int l() { return q(); } // OK + int m(); // OK - not defined + static int foo; // { dg-error "" } static data member of local class + }; +} + +local* p = 0; // { dg-error "" } no such type in scope diff --git a/gcc/testsuite/g++.old-deja/g++.jason/lookup.C b/gcc/testsuite/g++.old-deja/g++.jason/lookup.C new file mode 100644 index 000000000..fe800835f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/lookup.C @@ -0,0 +1,30 @@ +// { dg-do assemble } +// PRMS Id: 4357 +// Bug: g++ forgets to clear out push/popclass cache stuff when instantiating +// templates. + +template <class T> class ccHandle { }; + +class cc_GStack +{ + static cc_GStack* freeList; +}; + +// OK if ccGStack is not derived from ccHandle<something> +class ccGStack : public ccHandle<int> { }; + +struct S { }; + +S* freeList; + +class X +{ +public: + void foo(); +}; + +void X::foo() +{ + S m; + freeList = &m; +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/lookup2.C b/gcc/testsuite/g++.old-deja/g++.jason/lookup2.C new file mode 100644 index 000000000..a5cbccc34 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/lookup2.C @@ -0,0 +1,13 @@ +// { dg-do assemble } + +struct A { + struct B { + B (); + }; +}; +void f (A::B); +void g () +{ + A::B b; + f (b); // { dg-bogus "" } can't find nested constructor +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/lookup3.C b/gcc/testsuite/g++.old-deja/g++.jason/lookup3.C new file mode 100644 index 000000000..ecef53420 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/lookup3.C @@ -0,0 +1,15 @@ +// { dg-do assemble } +// [class.ambig]: A single function, object, type, or enumerator may be +// reached through more than one path through the DAG of base classes. This +// is not an ambiguity. + +struct A { + typedef long T; +}; + +struct B : public A { }; +struct C : public A { }; + +struct D : public C , public B { + void f (T&); // { dg-bogus "" } ambiguous lookup +}; diff --git a/gcc/testsuite/g++.old-deja/g++.jason/loverload.C b/gcc/testsuite/g++.old-deja/g++.jason/loverload.C new file mode 100644 index 000000000..3bffa3899 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/loverload.C @@ -0,0 +1,11 @@ +// { dg-do assemble } +// Bug: g++ can't deal with multi-language overloading. + +extern void foo (int, int); +extern "C" void foo (int); + +void bar () +{ + foo (1); + foo (1, 2); +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/loverload3.C b/gcc/testsuite/g++.old-deja/g++.jason/loverload3.C new file mode 100644 index 000000000..7a765a6d9 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/loverload3.C @@ -0,0 +1,12 @@ +// { dg-do assemble } +// PRMS Id: 2010 +// Bug: g++ doesn't deal with overloads involving C-language fns properly. + +extern "C" double pow (double, double); +inline double pow (double d, int e) { return pow (d, (double) e); } + +void foo () +{ + pow (1.0, 1); + pow (1.0, 1.0); +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/loverload4.C b/gcc/testsuite/g++.old-deja/g++.jason/loverload4.C new file mode 100644 index 000000000..bdac76f4f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/loverload4.C @@ -0,0 +1,8 @@ +// { dg-do assemble } +// Bug: g++ dies on this input. + +inline char abs (char x) { return 0; } + +extern "C" { + inline int abs (int x) { return 1; } +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/lvalue.C b/gcc/testsuite/g++.old-deja/g++.jason/lvalue.C new file mode 100644 index 000000000..643641eec --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/lvalue.C @@ -0,0 +1,22 @@ +// { dg-do assemble } +// Bug: Scoped method calls don't propagate the constness of `this'. +// PRMS Id: 4181 (second testcase) + +class D; + +class Bptr +{ +public: + Bptr& operator=(D*); + const Bptr& operator=(const D*) const; +}; + +class Dptr : public Bptr +{ +public: + const Dptr& operator=(const D* rep) const + { + Bptr::operator=(rep); + return *this; + } +}; diff --git a/gcc/testsuite/g++.old-deja/g++.jason/lvalue2.C b/gcc/testsuite/g++.old-deja/g++.jason/lvalue2.C new file mode 100644 index 000000000..35097f28f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/lvalue2.C @@ -0,0 +1,20 @@ +// { dg-do assemble } +// PRMS Id: 4892 +// Bug: COND_EXPRs, MODIFY_EXPRs and COMPOUND_EXPRs aren't properly recognized +// as lvalues. + +extern int foo; +int& f (int& a, int& b) +{ + return (foo ? a : b); // { dg-bogus "" } +} + +int& g (int& a) +{ + return (a = 0); // { dg-bogus "" } +} + +int& h (int& a, int& b) +{ + return (a = 1, b); // { dg-bogus "" } +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/lvalue3.C b/gcc/testsuite/g++.old-deja/g++.jason/lvalue3.C new file mode 100644 index 000000000..c7f080393 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/lvalue3.C @@ -0,0 +1,9 @@ +// { dg-do assemble } +// Bug: C++ semantics for assignment don't match the backend semantics for +// MODIFY_EXPR. + +void +foo (int j) +{ + (j = 1)++; // causes compiler segfault +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/lvalue4.C b/gcc/testsuite/g++.old-deja/g++.jason/lvalue4.C new file mode 100644 index 000000000..0a2ab2205 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/lvalue4.C @@ -0,0 +1,7 @@ +// { dg-do run } +int main() { + int i = 2; + int *pi = &(++i); + + return i != 3; +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/mangle1.C b/gcc/testsuite/g++.old-deja/g++.jason/mangle1.C new file mode 100644 index 000000000..bcb1c87c6 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/mangle1.C @@ -0,0 +1,23 @@ +// { dg-do assemble } +// Bug: numeric_outputed_need_bar is not cleared properly, adding random '_'s +// to mangled names. + + +template <int seed_length> +class rand1 +{ +public: + rand1 (); +}; + +class codes +{ +public: + rand1<32> * randgen; + codes (int ptr); + +}; + +codes::codes (int ptr) +{ +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/mangle2.C b/gcc/testsuite/g++.old-deja/g++.jason/mangle2.C new file mode 100644 index 000000000..c7957a24d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/mangle2.C @@ -0,0 +1,23 @@ +// { dg-do assemble } +// I guess this was broken once. + +template <class C, int D> class X { }; +typedef X<int, 0> T; + +class Y +{ + public: + ~Y(); +}; + +class Z +{ + public: + void f(T**); +}; + +void Z::f(T** t) +{ } + +Y::~Y() +{ } diff --git a/gcc/testsuite/g++.old-deja/g++.jason/mangle3.C b/gcc/testsuite/g++.old-deja/g++.jason/mangle3.C new file mode 100644 index 000000000..408a23753 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/mangle3.C @@ -0,0 +1,20 @@ +// { dg-do run } +// PRMS Id: 7563 +// Bug: declaration at function scope causes mismangling. + +int main() +{ + char ArrA[1][1][2][3], + ArrB[1][1][2][3]; + + void HitMe(char [1][1][2][3], char [1][1][2][3]); + + HitMe(ArrA, ArrB); + + return 0; +} + +void HitMe(char A[1][1][2][3], char B[1][1][2][3]) +{ + return; +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/member.C b/gcc/testsuite/g++.old-deja/g++.jason/member.C new file mode 100644 index 000000000..1abbdec1f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/member.C @@ -0,0 +1,35 @@ +// { dg-do assemble } +// GROUPS passed member-pointers error-reporting +struct Y +{ + struct X + { + int A; + int Y::X::* foo () { undef1(1); return &Y::X::A; }// { dg-error "" } foo().* + int bar () { return A; } + }; +}; + +int Y::X::* foo () +{ + undef2(1);// { dg-error "" } foo().* + return &Y::X::A; +} + +int Y::X::* (* foo2 ())() +{ + undef3(1);// { dg-error "" } foo().* + return foo; +} + +int (Y::X::* bar2 ()) () +{ + undef4(1);// { dg-error "" } foo\(\).* + return Y::X::bar;// { dg-error "" } foo\(\).* +} + +int Y::X::* (Y::X::* foo3 ())() +{ + undef5(1);// { dg-error "" } foo().* + return Y::X::foo;// { dg-error "" } foo().* +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/method.C b/gcc/testsuite/g++.old-deja/g++.jason/method.C new file mode 100644 index 000000000..2de7b0c7b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/method.C @@ -0,0 +1,12 @@ +// { dg-do assemble } +// Bug: pointer to pointer is treated as plain pointer. +// PRMS Id: 1767 + +class Foo { +public: + void method(); +}; + +void func(Foo ** ppFoo) { + ppFoo->method(); // { dg-error "" } +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/mi.C b/gcc/testsuite/g++.old-deja/g++.jason/mi.C new file mode 100644 index 000000000..40b6992d2 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/mi.C @@ -0,0 +1,17 @@ +// { dg-do run } +int status; + +struct A { virtual void foo () { status = 1; } }; +struct B { }; +struct C : public A, public B { }; +struct D { virtual void baz () { } }; +struct E : public D, public C { void foo () { status = 0; } }; + +int main () +{ + E* ep = new E; + + ep->foo(); + + return status; +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/mutable1.C b/gcc/testsuite/g++.old-deja/g++.jason/mutable1.C new file mode 100644 index 000000000..b6c146ad6 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/mutable1.C @@ -0,0 +1,12 @@ +// { dg-do run } +struct X +{ + X () { } + mutable int x; +}; + +int main () +{ + const X x; + x.x = 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/nested1.C b/gcc/testsuite/g++.old-deja/g++.jason/nested1.C new file mode 100644 index 000000000..90c6ecb37 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/nested1.C @@ -0,0 +1,12 @@ +// { dg-do assemble } +// Bug: g++ can't deal with function-local classes that talk about themselves. + +void foo() { + class Wrapper { + public: + void F (void * Wrapperptr) + { + Wrapper * wrapptr = ( Wrapper *) Wrapperptr; // { dg-bogus "" } + } + }; +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/nested2.C b/gcc/testsuite/g++.old-deja/g++.jason/nested2.C new file mode 100644 index 000000000..af2d92b09 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/nested2.C @@ -0,0 +1,26 @@ +// { dg-do assemble } +// PRMS Id: 3764 (c/h) +// Bug: g++ gets into an infinite loop trying to find the top-level context + +class Menu; +class MenuItem; + +class MenuAction { +public: + virtual void execute (Menu& menu, MenuItem& menuItem) = 0; +protected: + MenuAction () {} +}; + +class Test { + class MenuCBA : public MenuAction { + public: + typedef void (Test::* MenuCBA_Member) (Menu& menu, MenuItem& menuItem); + MenuCBA (Test& instance, MenuCBA_Member member) + : _instance(&instance), _member(member) { } + void execute (Menu& menu, MenuItem& menuItem); + private: + MenuCBA_Member _member; + Test* _instance; + }; +}; diff --git a/gcc/testsuite/g++.old-deja/g++.jason/nested4.C b/gcc/testsuite/g++.old-deja/g++.jason/nested4.C new file mode 100644 index 000000000..02bf354e9 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/nested4.C @@ -0,0 +1,17 @@ +// { dg-do assemble } +// From: quipu@ulrik.uio.no +// Subject: extern "C" nested class +// Date: Fri, 13 Aug 1993 15:33:53 +0200 + +extern "C" { + struct A { + struct B { int j; } *x; + }; +} + +void +foo () { + A a; + struct A::B *b; + b = a.x; // { dg-bogus "" } type `B' is not a base type for type `B' +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/nested5.C b/gcc/testsuite/g++.old-deja/g++.jason/nested5.C new file mode 100644 index 000000000..8d6a5cf69 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/nested5.C @@ -0,0 +1,11 @@ +// { dg-do assemble } + +struct A { + struct B { }; +}; + +struct C : public A { + struct D + : public B // { dg-bogus "" } can't find B + { }; +}; diff --git a/gcc/testsuite/g++.old-deja/g++.jason/nested6.C b/gcc/testsuite/g++.old-deja/g++.jason/nested6.C new file mode 100644 index 000000000..289607838 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/nested6.C @@ -0,0 +1,5 @@ +// { dg-do assemble } +union A { + struct B { }; + A::B b; // { dg-bogus "" } +}; diff --git a/gcc/testsuite/g++.old-deja/g++.jason/nested7.C b/gcc/testsuite/g++.old-deja/g++.jason/nested7.C new file mode 100644 index 000000000..5dc16a977 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/nested7.C @@ -0,0 +1,16 @@ +// { dg-do assemble } +// Testcase for defining nested types separately. + +class remote +{ + class remote_file; +}; + +class remote::remote_file +{ +public: + ~remote_file(); +}; + +remote::remote_file::~remote_file() +{} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/nested8.C b/gcc/testsuite/g++.old-deja/g++.jason/nested8.C new file mode 100644 index 000000000..6c283fab4 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/nested8.C @@ -0,0 +1,8 @@ +// { dg-do assemble } + +struct A { }; +struct B: public A { + struct C { +friend struct B; // { dg-bogus "" } base clause w/o members + }; +}; diff --git a/gcc/testsuite/g++.old-deja/g++.jason/net.C b/gcc/testsuite/g++.old-deja/g++.jason/net.C new file mode 100644 index 000000000..1f5987d47 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/net.C @@ -0,0 +1,10 @@ +// { dg-do assemble } +// Bug: g++ doesn't instantiate function templates in instantiate_type. + +template <class T> void fn (T t) { } +template <class T> struct A { + void (*p)(T); + A() { p = fn; } +}; + +A<int> a; diff --git a/gcc/testsuite/g++.old-deja/g++.jason/net2.C b/gcc/testsuite/g++.old-deja/g++.jason/net2.C new file mode 100644 index 000000000..ffb52d2b7 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/net2.C @@ -0,0 +1,38 @@ +// { dg-do run } +// Test of various ?: problems. + +class D +{ +public: + void a(); + void b(); + D(int i):x(i) {} +private: + int x; +}; + +void D::a() {++x;} +void D::b() {--x;} + + +int aa=1, bb=0; + +int fa() {return 0;} +int fb() {return 2;} + +int main(int argc, char* argv[]) +{ + typedef int* pi; + int* p = (argc == 1)? &aa: &bb; + *p = 0; + + typedef int (*ifptr)(); + ifptr fp = (argc == 1)? fa: fb; + aa = fp(); + + D d(0); + typedef void (D::*dmem)(); + dmem mfp = (argc == 1)? &D::a: &D::b; + (d.*mfp)(); + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/new.C b/gcc/testsuite/g++.old-deja/g++.jason/new.C new file mode 100644 index 000000000..905739b1b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/new.C @@ -0,0 +1,26 @@ +// { dg-do assemble } +// Bug: new doesn't make sure that the count is an integral value. + +#include <new> +extern "C" int printf (const char *, ...); +extern "C" void *malloc (std::size_t); +std::size_t s; + +void * operator new (std::size_t siz) throw (std::bad_alloc) { + if (s == 0) + s = siz; + else + s = (s != siz); + return malloc (siz); +} + +int main() +{ + s = 0; + + float f = 3; + int* b1 = new int[(int)f]; + int* b2 = new int[f]; // { dg-error "" } new requires integral size + + return s; +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/new2.C b/gcc/testsuite/g++.old-deja/g++.jason/new2.C new file mode 100644 index 000000000..75d353da1 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/new2.C @@ -0,0 +1,13 @@ +// { dg-do run } +// { dg-options "-Wno-deprecated -fno-exceptions" } +// PRMS Id: 6267 + +struct A { + int i; + A() { i = 2; } +}; + +main() +{ + A *p = new A (); +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/new3.C b/gcc/testsuite/g++.old-deja/g++.jason/new3.C new file mode 100644 index 000000000..d950259e7 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/new3.C @@ -0,0 +1,38 @@ +// { dg-do run } +// { dg-options "-fcheck-new -pedantic -Wno-long-long" } +// PRMS Id: 6037 + +extern "C" void * malloc (__SIZE_TYPE__); + +int ena = 0; + +struct A { + int i; + A () { i = 2; } + void * operator new (__SIZE_TYPE__ s) + { + if (ena) + return 0; + return malloc (s); + } +}; + +struct B { + int i; + B () { i = 2; } + void * operator new (__SIZE_TYPE__ s) throw() + { + if (ena) + return 0; + return malloc (s); + } +}; + +int main () +{ + ena = 1; + A *ap = new A; + B *bp = new B; + + return ap || bp ; +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/new4.C b/gcc/testsuite/g++.old-deja/g++.jason/new4.C new file mode 100644 index 000000000..770a2a26f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/new4.C @@ -0,0 +1,23 @@ +// { dg-do run } +// { dg-options "-fcheck-new" } + +struct A { + A(): i(42) { } + A(int j): i(j) { } + int i; +}; + +A* ap = new A (1); +A* ap2 = new A[3]; + +main () +{ + if (ap->i != 1 || ap2[0].i != 42 || ap2[1].i != 42 || ap2[2].i != 42) + return 1; + + A* ap = new A (1); + A* ap2 = new A[3]; + + if (ap->i != 1 || ap2[0].i != 42 || ap2[1].i != 42 || ap2[2].i != 42) + return 1; +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/new5.C b/gcc/testsuite/g++.old-deja/g++.jason/new5.C new file mode 100644 index 000000000..195df2d2f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/new5.C @@ -0,0 +1,6 @@ +// { dg-do run } +int main () +{ + const int *p = new const int (0); + delete p; +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/offset1.C b/gcc/testsuite/g++.old-deja/g++.jason/offset1.C new file mode 100644 index 000000000..a918baab8 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/offset1.C @@ -0,0 +1,17 @@ +// { dg-do assemble } +// PRMS Id: 5070 (testcase 1) + +struct foo { + foo(int x = 0) {} + int IsAlive(void) { return 1; } +}; + +struct xx { + int IsOk(int X); + foo a; +}; + +int xx::IsOk(int X) +{ + return ((xx::a).IsAlive()); // { dg-bogus "" } +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/offset2.C b/gcc/testsuite/g++.old-deja/g++.jason/offset2.C new file mode 100644 index 000000000..80e37ad03 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/offset2.C @@ -0,0 +1,24 @@ +// { dg-do run } +// PRMS Id: 5070 (testcase 2) + +int status = 1; + +struct foo { + foo& operator= (const foo&) { status = 0; return *this; } +}; + +struct xx { + foo a; +}; + +struct yy : public xx { + yy(foo& a) { xx::a = a; } +}; + +int main() +{ + foo f; + yy y (f); + + return status; +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/offset3.C b/gcc/testsuite/g++.old-deja/g++.jason/offset3.C new file mode 100644 index 000000000..c419b2e11 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/offset3.C @@ -0,0 +1,22 @@ +// { dg-do assemble } +// PRMS Id: 5070 (bug 2) + +struct A { + void f (); +}; + +struct Ptr { + A* operator->(); +}; + +struct B { + Ptr p; +}; + +struct C: public B { + void g (); +}; + +void C::g() { + B::p->f(); // { dg-bogus "" } +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/offset4.C b/gcc/testsuite/g++.old-deja/g++.jason/offset4.C new file mode 100644 index 000000000..9325cc47c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/offset4.C @@ -0,0 +1,15 @@ +// { dg-do assemble } +// Bug: g++ complains about the use of A::p below. + +struct A { + void *p; +}; + +struct B: public A { + int f () + { + if (A::p) + return 1; + return 0; + } +}; diff --git a/gcc/testsuite/g++.old-deja/g++.jason/opeq.C b/gcc/testsuite/g++.old-deja/g++.jason/opeq.C new file mode 100644 index 000000000..60fc5c1ae --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/opeq.C @@ -0,0 +1,40 @@ +// { dg-do run } +// PRMS Id: 4297 (related to 3525) +// Bug: Generating default op= didn't set TYPE_HAS_ASSIGNMENT, so it wasn't +// found. + +extern "C" int printf (const char *, ...); + +class Y +{ +public: + Y(const char*) {} + Y& operator = (const Y&) { return *this; } +}; + + +class X +{ +public: + X(int v, const char* m) : _v(v), _m (m) {} + X () : _v(0), _m("Unknown") {} + // Defining our own op= here makes things work correctly. + +private: + int _v; + int _m4; + // Adding more members here increases the count on u. + Y _m; +}; + +const X sPassed (1, "Passed"), sFailed (-1, "Failed"); + +int main (int, char**) +{ + X result; + int u = 0; + result = (u++ ? sPassed : sFailed); + if (u == 1) + return 0; + return 1; +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/opeq2.C b/gcc/testsuite/g++.old-deja/g++.jason/opeq2.C new file mode 100644 index 000000000..2d448a23c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/opeq2.C @@ -0,0 +1,26 @@ +// { dg-do assemble } +// Bug: default operator= is not being generated properly. +// PRMS Id: 3525 + +struct ccUnwind +{ + ccUnwind& operator = (const ccUnwind&); +}; + +struct ccEllipseUnit +{ + ccEllipseUnit () {} +}; + +struct ccEllipse : ccUnwind +{ + ccEllipse (); + ccEllipse (const ccEllipseUnit&); + +}; + +void foo () +{ + ccEllipse e; + e = ccEllipseUnit(); // { dg-bogus "" } assignment not defined +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/opeq3.C b/gcc/testsuite/g++.old-deja/g++.jason/opeq3.C new file mode 100644 index 000000000..b4e6e2550 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/opeq3.C @@ -0,0 +1,15 @@ +// { dg-do assemble } +// Bug: g++ generates code for assignment in invalid situations. + +class X { // { dg-error "reference|operator=" } + int& a; +public: + X(int& i): a(i) { } +}; + +void foo () +{ + int one=1, two=2; + X a(one), b(two); + a = b; // { dg-message "synthesized|deleted" } +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/opeq4.C b/gcc/testsuite/g++.old-deja/g++.jason/opeq4.C new file mode 100644 index 000000000..37933f344 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/opeq4.C @@ -0,0 +1,8 @@ +// { dg-do assemble } +// PRMS Id: 4329 +// Bug: default op= gives an warning about casting away volatile. + +struct foo +{ + volatile int bar[2]; +}; diff --git a/gcc/testsuite/g++.old-deja/g++.jason/opeq5.C b/gcc/testsuite/g++.old-deja/g++.jason/opeq5.C new file mode 100644 index 000000000..a2590efcf --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/opeq5.C @@ -0,0 +1,27 @@ +// { dg-do run } +// Testcase for tricky synthesized op= in complex inheritance situation. +// This used to test whether the virtual base was copy-assigned only once. +// That feature is not required by ISO C++, so the test now only checks +// whether the vbase is assigned at all. + +int count = 0; +extern "C" int printf (const char *, ...); + +class A { + public: + A& operator = (const A&) { count++; return *this; } +}; + +class B: virtual private A { }; +class C: virtual public A { }; +class D: public B, public C { }; + +int main() +{ + D a, b; + a = b; + printf ("%d\n",count); + if (count == 0) + return 1; + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/opeq6.C b/gcc/testsuite/g++.old-deja/g++.jason/opeq6.C new file mode 100644 index 000000000..ead4797a3 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/opeq6.C @@ -0,0 +1,24 @@ +// { dg-do assemble } +// Testcase for wrongful generation of operator =. + +class ivResource { +public: + ivResource (); +private: + ivResource & operator =(const ivResource &); +}; + +class ivButtonState : virtual public ivResource { +public: + void operator=(ivButtonState &); +}; + +class ivPrintBS : public ivButtonState { +}; + +void f () +{ + ivPrintBS a, b; + a = b; +} + diff --git a/gcc/testsuite/g++.old-deja/g++.jason/operator.C b/gcc/testsuite/g++.old-deja/g++.jason/operator.C new file mode 100644 index 000000000..780315771 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/operator.C @@ -0,0 +1,32 @@ +// { dg-do assemble } +// { dg-options "" } +// General test for operator overloading permissiveness. + +typedef __SIZE_TYPE__ size_t; + +struct A { + int operator?:(int a, int b); // { dg-error "expected type-specifier" } + static int operator()(int a); // { dg-error "must be a nonstatic member" } + static int operator+(A,A); // { dg-error "either a non-static member" } + int operator+(int a, int b = 1); // { dg-error "either zero or one" } + int operator++(char); // { dg-error "must take 'int'" } + void operator delete (void *); + void operator delete (void *, unsigned long); +}; + +struct B { + void * operator new (size_t, void *); + int operator++(int = 0); + int operator+ (int); + void operator()(); + char * operator[](int); + B * operator->(); +}; + +int operator-(int a, int b); // { dg-error "argument of class or" } + +void * operator new (A a); // { dg-error "first parameter" } +void operator delete (A a); // { dg-error "first parameter" } + +char * operator char * (int); // { dg-error "return type" "ret" } +// { dg-error "nonstatic member function" "mem" { target *-*-* } 31 } diff --git a/gcc/testsuite/g++.old-deja/g++.jason/operator2.C b/gcc/testsuite/g++.old-deja/g++.jason/operator2.C new file mode 100644 index 000000000..892ed3f1d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/operator2.C @@ -0,0 +1,14 @@ +// { dg-do assemble } +// PRMS Id: 6018 + +class string { + char *p; +public: + string(const char* s) ;// { p == s; } + operator const char*() ;// { return s; } +}; + +void f4(string& s) +{ + *s; // implies "s.operator const char*()" +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/opover.C b/gcc/testsuite/g++.old-deja/g++.jason/opover.C new file mode 100644 index 000000000..3ec833e2e --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/opover.C @@ -0,0 +1,15 @@ +// { dg-do assemble } +// Bug: g++ prefers a non-matching operator== over user-defined conversions +// and a default operator==. + +struct A { + operator int (); +}; + +struct B { + friend int operator== (B, int); +}; + +int foo (A& a) { + return a == 1; +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/optimize.C b/gcc/testsuite/g++.old-deja/g++.jason/optimize.C new file mode 100644 index 000000000..4676bef36 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/optimize.C @@ -0,0 +1,42 @@ +// { dg-do assemble } +// { dg-options "-O -pedantic-errors" } +// Bug: g++ claims that control can fall off the end of these functions. +// PRMS Id: 4943 + +struct A { + A(); + A(const A&); + A& operator= (const A&); + ~A(); +}; + +int f () +{ + A a[2]; + return 1; +} // { dg-bogus "" } jump_optimize + +int g () +{ + A a; + return 1; +} // { dg-bogus "" } jump_optimize + +struct B { + B(); + B(const B&); + B& operator= (const B&); + ~B(); +}; + +inline B::~B() +{ + int i = 2; + while (i--) ; +} + +int h () +{ + B b; + return 1; +} // { dg-bogus "" } jump_optimize diff --git a/gcc/testsuite/g++.old-deja/g++.jason/optimize2.C b/gcc/testsuite/g++.old-deja/g++.jason/optimize2.C new file mode 100644 index 000000000..58b3b127f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/optimize2.C @@ -0,0 +1,22 @@ +// { dg-do run } +// { dg-options "-w" } +// Used to crash on the alpha with optimization. + +extern "C" void abort (void); + +struct Fix { + unsigned short l; +}; + +static inline void f (int len) +{ + if (len > 65535) + abort (); +} + +struct Fix a = { 33 }; + +main() +{ + f (a.l); +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/overload.C b/gcc/testsuite/g++.old-deja/g++.jason/overload.C new file mode 100644 index 000000000..6a747ff96 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/overload.C @@ -0,0 +1,20 @@ +// { dg-do assemble } +// GROUPS passed overloading +enum bar {}; + +void operator+ (int, int);// { dg-error "" } .* +void operator+ (bar&, int); + +template <class T> void operator+ (int b, T& t) { return b; } +void operator+ (int, bar&); + +template <class T> class foo +{ +public: + friend void operator+ <> (int, T&); +}; + +class baz; + +class foo<int>; +class foo<baz>; diff --git a/gcc/testsuite/g++.old-deja/g++.jason/overload1.C b/gcc/testsuite/g++.old-deja/g++.jason/overload1.C new file mode 100644 index 000000000..36f9cac46 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/overload1.C @@ -0,0 +1,12 @@ +// { dg-do assemble } +// Bug: g++ thinks there is a conversion from void * to B *. + +struct A { + operator void* (); +}; + +struct B: public A { }; + +void bar (A& a) { + B* bp = (B*)a; // { dg-error "" } +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/overload11.C b/gcc/testsuite/g++.old-deja/g++.jason/overload11.C new file mode 100644 index 000000000..3fe871918 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/overload11.C @@ -0,0 +1,18 @@ +// { dg-do run } +// PRMS Id: 4697 +// Bug: g++ calls the non-const method for a const object. + +class A { +public: + void foo(int &i) const { i = 0; } + void foo(int &i) { i = 1; } +}; + +int main() +{ + A a; + const A& b = a; + int i = 2; + b.foo (i); + return i; +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/overload12.C b/gcc/testsuite/g++.old-deja/g++.jason/overload12.C new file mode 100644 index 000000000..b6ff7e167 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/overload12.C @@ -0,0 +1,16 @@ +// { dg-do run } +// PRMS Id: 4066 +// Bug: g++ doesn't notice the const on reference returns. + +struct B { + int foo() { return 1; } + int foo() const { return 0; } +}; + +B b_; +const B &b () { return b_; } + +int main() +{ + return b().foo(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/overload13.C b/gcc/testsuite/g++.old-deja/g++.jason/overload13.C new file mode 100644 index 000000000..74205c1b0 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/overload13.C @@ -0,0 +1,28 @@ +// { dg-do run } +// Bug: g++ screws up derived->base conversions when calling a global function +// in the presence of matching members in the base. Whew. + +struct xios { + virtual ~xios() { } +}; + +struct xistream: virtual public xios { + int j; + void operator>>(char&); +}; + +struct xfstreambase: virtual public xios { }; + +struct xifstream: public xfstreambase, public xistream { }; + +void operator>>(xistream& i, int j) +{ + i.j = 0; +} + +int main() { + int i; + xifstream ifs; + + ifs >> i; +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/overload14.C b/gcc/testsuite/g++.old-deja/g++.jason/overload14.C new file mode 100644 index 000000000..a4c6cff8a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/overload14.C @@ -0,0 +1,10 @@ +// { dg-do assemble } +// Bug: g++ fails to recognize that the template matches the target type. + +template <class T> void foo (T *, int); + +struct A; +void bar () +{ + void (*p)(A *, int) = &foo; +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/overload15.C b/gcc/testsuite/g++.old-deja/g++.jason/overload15.C new file mode 100644 index 000000000..fdd692b09 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/overload15.C @@ -0,0 +1,10 @@ +// { dg-do assemble } +// Bug: g++ thinks that int->long is a promotion. + +long f (long, long); +double f (double, double); + +void g (double d) +{ + f (d, 0); +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/overload16.C b/gcc/testsuite/g++.old-deja/g++.jason/overload16.C new file mode 100644 index 000000000..fba33eda7 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/overload16.C @@ -0,0 +1,8 @@ +// { dg-do assemble } +void f (int); // { dg-message "note" } +void f (long); // { dg-message "note" } +int main() +{ + f (1 & 0xffffff00UL); // { dg-error "ambiguous" } + // { dg-message "candidate" "candidate note" { target *-*-* } 6 } +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/overload17.C b/gcc/testsuite/g++.old-deja/g++.jason/overload17.C new file mode 100644 index 000000000..df47ed44e --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/overload17.C @@ -0,0 +1,20 @@ +// { dg-do assemble } +// Bug: g++ fails to prefer UDC's alone to UDC's plus standard conversions. + +struct B { }; +struct D: public B { }; +struct DP { + operator D * () const; + operator double () const; +}; + +void f (B *); +void f (D *); +void g (double); +void g (float); + +void h (DP p) +{ + f (p); + g (p); +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/overload18.C b/gcc/testsuite/g++.old-deja/g++.jason/overload18.C new file mode 100644 index 000000000..3fb979915 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/overload18.C @@ -0,0 +1,6 @@ +// { dg-do assemble } +// pushdecl gets confused by this. + +void f (); +void f (int, int); +template <class T> T f (T) { } diff --git a/gcc/testsuite/g++.old-deja/g++.jason/overload19.C b/gcc/testsuite/g++.old-deja/g++.jason/overload19.C new file mode 100644 index 000000000..73404fe9d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/overload19.C @@ -0,0 +1,12 @@ +// { dg-do run } +// PRMS Id: 4689 +// Bug: g++ doesn't notice operators overloaded on enumeral types. + +enum E { A=5, B=32, C=100 }; + +E operator|(E a, E b) { return C; } + +int main() +{ + return (A|B) != C; +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/overload2.C b/gcc/testsuite/g++.old-deja/g++.jason/overload2.C new file mode 100644 index 000000000..631f953cf --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/overload2.C @@ -0,0 +1,12 @@ +// { dg-do assemble } +// Bug: foo and bar are considered to be overloaded (i.e. their +// IDENTIFIER_GLOBAL_VALUES are TREE_LISTs) even though they aren't, +// so ?: thinks it can't resolve the names. + +void foo (); +void bar (); + +void baz () +{ + void (*p)() = 1 ? foo : bar; // { dg-bogus "" } wrongful overloading +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/overload20.C b/gcc/testsuite/g++.old-deja/g++.jason/overload20.C new file mode 100644 index 000000000..f5db6a20f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/overload20.C @@ -0,0 +1,12 @@ +// { dg-do assemble } +// Bug: this code causes an internal compiler error 4. + +void f (char *); +void f (int); +struct A { + void f (); // { dg-error "" } candidate + void f (int); // { dg-error "" } candidate + void g () { + void (*p)(char *) = f; // { dg-error "" } no matching function in scope + } +}; diff --git a/gcc/testsuite/g++.old-deja/g++.jason/overload21.C b/gcc/testsuite/g++.old-deja/g++.jason/overload21.C new file mode 100644 index 000000000..229be93da --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/overload21.C @@ -0,0 +1,13 @@ +// { dg-do assemble } +struct X { + void f (int = 4, char = 'r'); // { dg-error "previous specification" } + void g (int = 4, char = 'r'); // { dg-error "previous specification" } +}; + +void +X::f (int i = 4, char x = 'r') // { dg-error "default argument" } +{ } + +void +X::g (int i = 9, char x = 's') // { dg-error "default argument" } +{ } diff --git a/gcc/testsuite/g++.old-deja/g++.jason/overload22.C b/gcc/testsuite/g++.old-deja/g++.jason/overload22.C new file mode 100644 index 000000000..da0a8a63a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/overload22.C @@ -0,0 +1,17 @@ +// { dg-do assemble } +// PRMS Id: 4574 +// Bug: g++ prefers int to double for float& argument + +inline double abs (double x) { return x;} +inline int abs (int i) { return i; } + +float& fn(float& f) +{ + return f; +} + +void foo() +{ + float f = 23.45; + abs(fn(f)); // gets bogus warning +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/overload23.C b/gcc/testsuite/g++.old-deja/g++.jason/overload23.C new file mode 100644 index 000000000..fe605f037 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/overload23.C @@ -0,0 +1,27 @@ +// { dg-do assemble } +// From: panisset@cae.ca (Jean-Francois Panisset) +// Date: Mon, 6 Jun 94 13:39:25 EDT +// Subject: Problem with operator overloading + + +class ostream { +public: + ostream& operator<<(double n); + ostream& operator<<(float n); +}; + +class X +{ +public: + operator long() const; + operator double() const; +}; +ostream& operator<< (ostream& os, const X& x); + + +int main() +{ + X x; + ostream os; + os << x; // { dg-bogus "" } converting to float +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/overload24.C b/gcc/testsuite/g++.old-deja/g++.jason/overload24.C new file mode 100644 index 000000000..3aee9b360 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/overload24.C @@ -0,0 +1,23 @@ +// { dg-do assemble } +// PRMS Id: 5124 +// Bug: g++ promotes bar to int* too soon and the call to f fails. + +typedef int arr[1]; + +struct A { + void f(void); + void f(arr &); + + void g(void); + void g(int *); + + void h(void); +}; + + +void A::h(void) +{ + arr bar; + f(bar); + g(bar); +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/overload26.C b/gcc/testsuite/g++.old-deja/g++.jason/overload26.C new file mode 100644 index 000000000..681473f26 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/overload26.C @@ -0,0 +1,22 @@ +// { dg-do assemble } +// Bug: g++ tries to build up a mangled name for its ideal match, which +// fails for one call below. + +extern const char foo[]; +extern const char baz[10]; +extern const char *fred; + +struct A { + void f(const char *); +} *a; + +void bing(const char *); +int main () +{ + a->f(foo); // { dg-bogus "" } because foo's size unknown. + a->f(baz); + a->f(fred); + bing(fred); + bing(foo); + bing(baz); +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/overload27.C b/gcc/testsuite/g++.old-deja/g++.jason/overload27.C new file mode 100644 index 000000000..4fd11752d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/overload27.C @@ -0,0 +1,8 @@ +// { dg-do run } +void f(const int &) { } +void f(const float &); + +int main() +{ + f(false); // { dg-bogus "" } +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/overload28.C b/gcc/testsuite/g++.old-deja/g++.jason/overload28.C new file mode 100644 index 000000000..fe0dae103 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/overload28.C @@ -0,0 +1,13 @@ +// { dg-do assemble } +// PRMS Id: 6056 + +struct Foo { + Foo() { } // { dg-message "note" } + Foo(int i = 25) { } // { dg-message "note" } +}; + +int main() +{ + Foo* f1 = new Foo(); // { dg-error "ambiguous" } + // { dg-message "candidate" "candidate note" { target *-*-* } 11 } +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/overload29.C b/gcc/testsuite/g++.old-deja/g++.jason/overload29.C new file mode 100644 index 000000000..abc4418bd --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/overload29.C @@ -0,0 +1,16 @@ +// { dg-do assemble } +// Bug: we get an error trying to build up our ideal candidate. + +class C { + public: + C( const char * ); +}; + + extern const char c1[]; + +void f2( const char * ); + +void f1() { + C *fntp = new C(c1); // Line 10 + f2( c1 ); +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/overload3.C b/gcc/testsuite/g++.old-deja/g++.jason/overload3.C new file mode 100644 index 000000000..3cca3147e --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/overload3.C @@ -0,0 +1,12 @@ +// { dg-do assemble } +// Bug: bar is considered to be overloaded (i.e. its +// IDENTIFIER_GLOBAL_VALUES are TREE_LISTs) even though it isn't, +// so default_conversion thinks it can't resolve the name. + +void foo (); +void bar (); + +void baz () +{ + void (*p)() = 1 ? (void (*)()) &foo : bar; +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/overload30.C b/gcc/testsuite/g++.old-deja/g++.jason/overload30.C new file mode 100644 index 000000000..9f65080eb --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/overload30.C @@ -0,0 +1,17 @@ +// { dg-do assemble } +// PRMS Id: 6412 + +class Foo; + +template <class F> +class Temp +{ + F func_; +public: + Temp (F f) : func_(f) {} +}; + +template <class T> +T* func1 (T* t) { return t; } + +Temp<Foo*(*)(Foo*)> temp2(func1); diff --git a/gcc/testsuite/g++.old-deja/g++.jason/overload31.C b/gcc/testsuite/g++.old-deja/g++.jason/overload31.C new file mode 100644 index 000000000..18dc213a5 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/overload31.C @@ -0,0 +1,24 @@ +// { dg-do assemble } +// PRMS Id: 6568 +// Bug: g++ complains about the ambiguous conversion to bool even though +// we wouldn't end up using it anyway. + +class AString +{ +public: + AString (unsigned len); + operator char *() const; + operator char const *() const; +}; + +void +foo(unsigned t, AString const & handle) +{ +} + +void +foo(AString const & handle, bool includeSpecials) +{ + unsigned t; + foo(t, handle); +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/overload32.C b/gcc/testsuite/g++.old-deja/g++.jason/overload32.C new file mode 100644 index 000000000..1a81ef692 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/overload32.C @@ -0,0 +1,19 @@ +// { dg-do assemble } +// PRMS Id: 7128 + +class B {}; + +class D : public B {}; + +class X { + public: + operator const B & () const; + operator const D & () const; +}; + +void f( const D & ); + +void g( const X & x ) +{ + f( x ); +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/overload33.C b/gcc/testsuite/g++.old-deja/g++.jason/overload33.C new file mode 100644 index 000000000..2cc34c6b2 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/overload33.C @@ -0,0 +1,78 @@ +// { dg-do assemble } +// PRMS ID: 7507 + +/* ------------------------------------------------------------ */ + +class Base0 +{ +public: + Base0() {} + virtual ~Base0() {} +}; + +class Base1 +{ +public: + Base1() {} + virtual ~Base1() {} +}; + +class Derived : public Base0, public Base1 +{ +public: + Derived() {} + virtual ~Derived() {} +}; + +/* ------------------------------------------------------------ */ + +class Dummy +{ + public: + Dummy(Base0 * theBase) {} + ~Dummy() {} +}; + +/* ------------------------------------------------------------ */ + +template<class T> +class ConstSmartPtr +{ + T* myItem; // private + + public: + ConstSmartPtr(T const* theItem); + + operator T const*() const + { return myItem; } + protected: + T* _item() const + { return myItem; } +}; + +template<class T> +class SmartPtr : public ConstSmartPtr<T> +{ + public: + SmartPtr(T* theItem) + : ConstSmartPtr<T>(theItem) {} + + T* item() const + { return this->_item(); } + + operator T*() const + { return this->_item(); } +}; + +/* ------------------------------------------------------------ */ + +void +function() +{ + SmartPtr<Derived> myObj = new Derived(); + + Dummy th1(myObj); // Doesn't work under Cygnus + Dummy th2((Base0 *) myObj); // Doesn't work either +} + +/* ------------------------------------------------------------ */ diff --git a/gcc/testsuite/g++.old-deja/g++.jason/overload34.C b/gcc/testsuite/g++.old-deja/g++.jason/overload34.C new file mode 100644 index 000000000..13c3eedcf --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/overload34.C @@ -0,0 +1,8 @@ +// { dg-do assemble } +// PRMS ID: 8010 + +class X { + int & flag; +public: + void f(){ flag++ ; } +}; diff --git a/gcc/testsuite/g++.old-deja/g++.jason/overload35.C b/gcc/testsuite/g++.old-deja/g++.jason/overload35.C new file mode 100644 index 000000000..7c7db75ca --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/overload35.C @@ -0,0 +1,25 @@ +// { dg-do assemble } +// PRMS Id: 9647 + +class castBug +{ +public: + operator int *(); + operator const int *() const; +}; + +class castBug2 +{ +public: + operator const int *() const; +}; + +void voidfn(void *); + +void test() +{ + castBug b; + castBug2 b2; + voidfn(b); // { dg-bogus "" } + voidfn(b2); // { dg-error "" } discarding const +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/overload36.C b/gcc/testsuite/g++.old-deja/g++.jason/overload36.C new file mode 100644 index 000000000..324d766ea --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/overload36.C @@ -0,0 +1,16 @@ +// { dg-do run } +// Test for subsequence checking in overload resolution. + +class foo { +public: + void operator <<(char *) { } + void operator <<(const char * const &); +}; + +int +main() +{ + char s[20]; + foo f; + f << s; +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/overload4.C b/gcc/testsuite/g++.old-deja/g++.jason/overload4.C new file mode 100644 index 000000000..6a30b435d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/overload4.C @@ -0,0 +1,11 @@ +// { dg-do assemble } +// Testcase for simple overloading resolution. + +void foo (int); +void foo (int, int); + +void bar () +{ + foo (1); + foo (1, 2); +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/overload5.C b/gcc/testsuite/g++.old-deja/g++.jason/overload5.C new file mode 100644 index 000000000..9280c9d5e --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/overload5.C @@ -0,0 +1,5 @@ +// { dg-do assemble } +// Testcase for simple overloading resolution. + +int foo (); // { dg-error "" } +void foo (); // { dg-error "" } disallowed overload diff --git a/gcc/testsuite/g++.old-deja/g++.jason/overload6.C b/gcc/testsuite/g++.old-deja/g++.jason/overload6.C new file mode 100644 index 000000000..765c20d38 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/overload6.C @@ -0,0 +1,15 @@ +// { dg-do assemble } +// Bug: g++ thinks there is a default conversion from void* to B*. +// There isn't. + +struct A { + operator void* (); +}; + +struct B { }; + +void foo (B* bp); + +void bar (A& a) { + foo (a); // { dg-error "" } +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/overload7.C b/gcc/testsuite/g++.old-deja/g++.jason/overload7.C new file mode 100644 index 000000000..2dc3b031a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/overload7.C @@ -0,0 +1,15 @@ +// { dg-do assemble } +// Bug: g++ thinks there is a default conversion from A& to B*. +// There isn't. + +struct A { + operator A* (); +}; + +struct B: public A { }; + +void foo (B* bp); + +void bar (A& a) { + foo (a); // { dg-error "" } +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/overload8.C b/gcc/testsuite/g++.old-deja/g++.jason/overload8.C new file mode 100644 index 000000000..2987ae51a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/overload8.C @@ -0,0 +1,7 @@ +// { dg-do assemble } +// Bug: g++ fails to catch the ambiguity below. + +struct A { + operator int () { return 1; } + operator int &() { return 1; } // { dg-error "" } +}; diff --git a/gcc/testsuite/g++.old-deja/g++.jason/overload9.C b/gcc/testsuite/g++.old-deja/g++.jason/overload9.C new file mode 100644 index 000000000..c6930a2af --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/overload9.C @@ -0,0 +1,39 @@ +// { dg-do assemble } +// PRMS Id: 4257 +// Bug: g++ ignores non-member possibilities (ideal_candidate_ansi bug) + +class ostream +{ +public: +#ifdef EITHER_ONE_A + ostream& operator<<(unsigned long n); + ostream& operator<<(long n); +#else + ostream& operator<<(short n); + ostream& operator<<(unsigned short n); +#endif +}; + +class ccObjectInfo {}; + +ostream& operator << (ostream& out, const ccObjectInfo& obj); + +class ccString : public ccObjectInfo +{ +#ifdef EITHER_ONE_B + operator int () const; +#else + operator long () const; +#endif +}; + +// Should pick this one!! +ostream& operator << (ostream& o, const ccString & s); + +extern ostream cout; + +void f () +{ + ccString foo; + cout << foo; +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/parse1.C b/gcc/testsuite/g++.old-deja/g++.jason/parse1.C new file mode 100644 index 000000000..9d06b0552 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/parse1.C @@ -0,0 +1,8 @@ +// { dg-do assemble } +// Bug: g++ parses the declaration of r as a function declaration. + +void foo (int i) +{ + int &r (i); + r = 1; // { dg-bogus "" } +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/parse10.C b/gcc/testsuite/g++.old-deja/g++.jason/parse10.C new file mode 100644 index 000000000..751928a2b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/parse10.C @@ -0,0 +1,16 @@ +// { dg-do run } +// Testcase for precedence of ?: wrt = + +extern "C" int printf (const char *, ...); + +int main() +{ + int j = 0, k = 0; + 1 ? j : k = 5; // should be parsed 1 ? j : (k = 5) + (void) (1 ? k = 5 : 0); + k = 5 ? 1 : 0; // should be parsed k = (5 ? 1 : 0) + + printf ("%d %d\n", j, k); + + return j == 5 || k == 5; +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/parse11.C b/gcc/testsuite/g++.old-deja/g++.jason/parse11.C new file mode 100644 index 000000000..40864c108 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/parse11.C @@ -0,0 +1,9 @@ +// { dg-do assemble } +// PRMS Id: 6825 + +class aClass +{ + ; // { dg-error "" } missing declaration +private: + ; // { dg-error "" } missing declaration +}; diff --git a/gcc/testsuite/g++.old-deja/g++.jason/parse12.C b/gcc/testsuite/g++.old-deja/g++.jason/parse12.C new file mode 100644 index 000000000..8988cebc8 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/parse12.C @@ -0,0 +1,18 @@ +// { dg-do run } +// PRMS Id: 6821 + +struct A { + int operator()(int i) { return i; } +}; + +struct B { + A* p; + int f () { return (*p)(42); } // { dg-bogus "" } +}; + +int main () +{ + B b = { new A }; + + return b.f () != 42; +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/parse13.C b/gcc/testsuite/g++.old-deja/g++.jason/parse13.C new file mode 100644 index 000000000..e438ee297 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/parse13.C @@ -0,0 +1,8 @@ +// { dg-do assemble } + +struct A { + struct B {}; + struct C; +}; + +struct A :: C : A :: B {}; // { dg-bogus "" } parse error before `:' diff --git a/gcc/testsuite/g++.old-deja/g++.jason/parse14.C b/gcc/testsuite/g++.old-deja/g++.jason/parse14.C new file mode 100644 index 000000000..34b5f8400 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/parse14.C @@ -0,0 +1,12 @@ +// { dg-do assemble } +// Bug: g++ decides that A::foo is introducing a constructor declarator. + +struct A { + typedef bool foo; +}; + +A::foo (*bar) (); + +struct B { + A::foo (*bar) (); +}; diff --git a/gcc/testsuite/g++.old-deja/g++.jason/parse2.C b/gcc/testsuite/g++.old-deja/g++.jason/parse2.C new file mode 100644 index 000000000..e33ffa6f1 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/parse2.C @@ -0,0 +1,6 @@ +// { dg-do assemble } +// Bug: g++ doesn't understand constructor syntax for pointers. + +void f () { + char * p (0); +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/parse3.C b/gcc/testsuite/g++.old-deja/g++.jason/parse3.C new file mode 100644 index 000000000..bed74f47b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/parse3.C @@ -0,0 +1,6 @@ +// { dg-do assemble } +// PRMS Id: 4484 (bug 2) +// Bug: g++ does not grok abstract declarator syntax for method pointers. + +template <class T> class A { }; +void (A<int>::*p)() = (void (A<int>::*)())0; // { dg-bogus "" } abstract declarator failure diff --git a/gcc/testsuite/g++.old-deja/g++.jason/parse4.C b/gcc/testsuite/g++.old-deja/g++.jason/parse4.C new file mode 100644 index 000000000..13722227a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/parse4.C @@ -0,0 +1,7 @@ +// { dg-do assemble } +// Bug: g++ doesn't handle superfluous parentheses when redeclaring a TYPENAME. + +typedef int foo; +class A { + typedef int ((foo)); // { dg-bogus "" } +}; diff --git a/gcc/testsuite/g++.old-deja/g++.jason/parse5.C b/gcc/testsuite/g++.old-deja/g++.jason/parse5.C new file mode 100644 index 000000000..251db3d56 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/parse5.C @@ -0,0 +1,12 @@ +// { dg-do assemble } +// Bug: foo (bar) should be a declaration of a static data member, not a +// function; it's getting caught by the rules for constructors. + +typedef int foo; +typedef int bar; +struct A { + static foo (bar); // { dg-bogus "" } +}; + +int i = A::bar; // { dg-bogus "" } +int (*fp)(bar) = A::foo; // { dg-error "" } diff --git a/gcc/testsuite/g++.old-deja/g++.jason/parse6.C b/gcc/testsuite/g++.old-deja/g++.jason/parse6.C new file mode 100644 index 000000000..ba37f103e --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/parse6.C @@ -0,0 +1,9 @@ +// { dg-do assemble } +// PRMS id: 4653 +// Bug: g++ tries to resolve declarator/expression ambiguities too soon. + +template<class T> struct A { }; + +void f () { + void (A<int>::*pmf) (); // { dg-bogus "" } late binding +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/parse7.C b/gcc/testsuite/g++.old-deja/g++.jason/parse7.C new file mode 100644 index 000000000..40b22877c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/parse7.C @@ -0,0 +1,7 @@ +// { dg-do assemble } +// Bug: g++ tries to parse this as a constructor. + +typedef int foo; +struct A { + foo (*bar)(); +}; diff --git a/gcc/testsuite/g++.old-deja/g++.jason/parse8.C b/gcc/testsuite/g++.old-deja/g++.jason/parse8.C new file mode 100644 index 000000000..a03dd184a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/parse8.C @@ -0,0 +1,2 @@ +// { dg-do assemble } +void foo(const int* const); // { dg-bogus "" } diff --git a/gcc/testsuite/g++.old-deja/g++.jason/parse9.C b/gcc/testsuite/g++.old-deja/g++.jason/parse9.C new file mode 100644 index 000000000..5fa46391f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/parse9.C @@ -0,0 +1,19 @@ +// { dg-do run } +// PRMS Id: 5720 +// Bug: the extra set of parens confuses the expr/declarator disambiguation. + +class Fu +{ + int val; +public: + Fu(int i) : val(i) { } + void print() { } +}; + +int main(int argc, char * argv[]) +{ + int * i = &argc; + + Fu((*i)).print(); // { dg-bogus "" } + Fu((*j)); +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/pmem.C b/gcc/testsuite/g++.old-deja/g++.jason/pmem.C new file mode 100644 index 000000000..90c612263 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/pmem.C @@ -0,0 +1,11 @@ +// { dg-do assemble } +// Bug: g++ parses the declaration of 'char A::* foo' below as a +// declaration of 'char A'. + +class A { }; +typedef int foo; +void f () +{ + char A::* foo; + foo = 0; // { dg-bogus "" } parsing blunder +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/pmem2.C b/gcc/testsuite/g++.old-deja/g++.jason/pmem2.C new file mode 100644 index 000000000..03205345d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/pmem2.C @@ -0,0 +1,44 @@ +// { dg-do run } +template <class Called> +class aCallback +{ +public: + aCallback(Called& obj, int (Called::*met)()); + + int callback(); + +protected: + +private: + Called& object; + + int (Called::*method)(); + +}; + +template <class Called> +aCallback<Called>::aCallback(Called& obj, + int (Called::*met)()) : +object(obj), +method(met) +{} + +template <class Called> +int aCallback<Called>::callback() +{ + return (object.*method)(); +} + +struct myStruct +{ + int action() {return 0;} +}; + +int main() +{ + myStruct toto; + + aCallback<myStruct> cb(toto, &myStruct::action); + + return cb.callback(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/pmem3.C b/gcc/testsuite/g++.old-deja/g++.jason/pmem3.C new file mode 100644 index 000000000..1476266f6 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/pmem3.C @@ -0,0 +1,12 @@ +// { dg-do run } +// Test that comparison of pointers to members does not complain about +// contravariance violation. + +struct A { int i; }; +struct B : public A { int j; int f (); }; +int main () +{ + int A::*apm = &A::i; + int B::*bpm = apm; + return apm != bpm; +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/pmem4.C b/gcc/testsuite/g++.old-deja/g++.jason/pmem4.C new file mode 100644 index 000000000..b05c86d4f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/pmem4.C @@ -0,0 +1,11 @@ +// { dg-do assemble } +struct X {}; +X& X::*PTM_1; // { dg-error "" } pointer to reference member +void X::*PTM_2; // { dg-error "" } pointer to void member + +struct A { + static int& ir; +}; + +int i; +int& A::ir = i; // not an error diff --git a/gcc/testsuite/g++.old-deja/g++.jason/pmf.C b/gcc/testsuite/g++.old-deja/g++.jason/pmf.C new file mode 100644 index 000000000..b601dd9ff --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/pmf.C @@ -0,0 +1,7 @@ +// { dg-do assemble } +// PRMS Id: 4333 +// Bug: g++ can't deal with casts to pointer to member function. + +class A { }; +typedef void (A::* pmf)(); +void foo () { (pmf) 0; } diff --git a/gcc/testsuite/g++.old-deja/g++.jason/pmf2.C b/gcc/testsuite/g++.old-deja/g++.jason/pmf2.C new file mode 100644 index 000000000..30a3aab19 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/pmf2.C @@ -0,0 +1,13 @@ +// { dg-do assemble } +// PRMS Id: 4484 (bug 3) +// Bug: g++ does implicitly take the address of methods passed to fns. + +struct A { + void f (); +}; + +void g (void (A::*)()); + +void h () { + g (A::f); // { dg-error "" } failed conversion to method pointer +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/pmf3.C b/gcc/testsuite/g++.old-deja/g++.jason/pmf3.C new file mode 100644 index 000000000..636ac5d34 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/pmf3.C @@ -0,0 +1,19 @@ +// { dg-do assemble } +// From: enewton@uunet.uu.NET +// Subject: g++ 2.5.8: cannot cast member function pointers +// Date: 27 Jan 1994 01:22:56 -0500 + +struct A { + void f(char); + void g(int); +}; + +typedef void (A::*Ptr)(char); + +void q() { + Ptr p; + + p = (Ptr) &A::f; + p = (Ptr) &A::g; + p = &A::f; +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/pmf4.C b/gcc/testsuite/g++.old-deja/g++.jason/pmf4.C new file mode 100644 index 000000000..709532e8f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/pmf4.C @@ -0,0 +1,9 @@ +// { dg-do assemble } +// PRMS Id: 4484 (bug 5) +// Bug: g++ can't convert between pmf types. + +class A; +typedef void (A::*pmf)(); +typedef void (A::*pmfc)() const; + +pmfc p = (pmfc)(pmf)0; // { dg-bogus "" } pmf conversion diff --git a/gcc/testsuite/g++.old-deja/g++.jason/pmf5.C b/gcc/testsuite/g++.old-deja/g++.jason/pmf5.C new file mode 100644 index 000000000..26fa9432a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/pmf5.C @@ -0,0 +1,19 @@ +// { dg-do assemble } +// { dg-options "" } +// PRMS Id: 4985 + +struct Thing { + int OverloadFn() const; + void FunctionA(char* restOfLine); + void OverloadFn(char* restOfLine); +}; + +struct ThingEntry { + void (Thing::*_handler)(char* restOfLine); +}; + +static ThingEntry KeyWordTable[] = { + &Thing::FunctionA, + Thing::OverloadFn, +}; // { dg-error "assuming" "assuming" } implicit & +// { dg-message "note" "note" { target *-*-* } 18 } diff --git a/gcc/testsuite/g++.old-deja/g++.jason/pmf6.C b/gcc/testsuite/g++.old-deja/g++.jason/pmf6.C new file mode 100644 index 000000000..13c0981f9 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/pmf6.C @@ -0,0 +1,11 @@ +// { dg-do assemble } +// PRMS Id: 5656 +// Bug: g++ tries (which is a bug) and fails (which is a bug) to initialize +// var at runtime. + +struct A +{ + int func(int); + int func() const; +}; +int (A::* var) () const = & A::func; diff --git a/gcc/testsuite/g++.old-deja/g++.jason/pmf7.C b/gcc/testsuite/g++.old-deja/g++.jason/pmf7.C new file mode 100644 index 000000000..760133384 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/pmf7.C @@ -0,0 +1,28 @@ +// { dg-do run } +// PRMS Id: 6486 +// Make sure that no confused handling of COND_EXPRs and SAVE_EXPRs messes +// with the number of calls to foo. + +int c; + +struct A { + void f () {} + virtual void g () {} +}; + +A& foo () +{ + static A a; + ++c; + return a; +} + +int main () +{ + void (A::*p)() = &A::f; + (foo ().*p)(); + p = &A::g; + (foo ().*p)(); + + return 2 - c; +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/pmf8.C b/gcc/testsuite/g++.old-deja/g++.jason/pmf8.C new file mode 100644 index 000000000..35b7d8c43 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/pmf8.C @@ -0,0 +1,30 @@ +// { dg-do run } +// PRMS Id: 6905 + +class Parent { +public: + void DoSomething() { return; } + int i; +}; + +class Child : public Parent { +public: +}; + +class User { +public: + void DoAnyThing(void (Parent::*)(void)) { return; } + void DoAThing(void (Child::*)(void)) { return; } + void DoAThing(int Child::*) { return; } +}; + + +int main() +{ + User a; + + a.DoAnyThing(&Child::DoSomething); + a.DoAThing(&Child::DoSomething); + a.DoAThing(&Parent::DoSomething); + a.DoAThing(&Parent::i); +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/pmf9.C b/gcc/testsuite/g++.old-deja/g++.jason/pmf9.C new file mode 100644 index 000000000..6d86498cf --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/pmf9.C @@ -0,0 +1,57 @@ +// { dg-do assemble } +// PRMS id: g++/13340 + +class rectangle { + +public: + rectangle(); + int overlaps() const; + +}; + +class region +{ + friend class region_impl; + +public: + region(); + typedef int (region::* region_func)() const; + +}; + +class region_impl { + friend class region; + +private: + rectangle content, mbb; + region_impl *link_p; + region_impl(const rectangle &content); + +public: + int iterate(region *region_p, region::region_func what, + const rectangle &clip_rect) const; + int iterate(region *region_p, region::region_func what, + const region_impl &clip_rgn) const; +}; + + +int +region_impl::iterate (region *region_p, region::region_func what, + const rectangle &clip_rect) const +{ + for (const region_impl *p = this; p != 0 && p->mbb.overlaps(); + p = p->link_p) + if (p->content.overlaps()) + if (!(region_p->*what)()) return 0; + return 1; +} + +int +region_impl::iterate (region *region_p, region::region_func what, + const region_impl &clip_rgn) const +{ + for (const region_impl *p = this; p != 0 && p->mbb.overlaps(); + p = p->link_p) + if (!clip_rgn.iterate(region_p, what, p->content)) return 0; + return 1; +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/pmftemp.C b/gcc/testsuite/g++.old-deja/g++.jason/pmftemp.C new file mode 100644 index 000000000..d54fc57ff --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/pmftemp.C @@ -0,0 +1,16 @@ +// { dg-do assemble } +// PRMS Id: 4484 (bug 1) +// Bug: g++ does not support templates involving method pointers. + +struct A { + void f (); +}; + +template <class T> void +f (void (T::*p)()) // { dg-bogus "" } use of template parm as aggregate +{ } + +void g () +{ + f (&A::f); // { dg-bogus "" } templates and method pointers +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/precedence.C b/gcc/testsuite/g++.old-deja/g++.jason/precedence.C new file mode 100644 index 000000000..a11abcdc5 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/precedence.C @@ -0,0 +1,14 @@ +// { dg-do assemble } +// Bug: g++ groups ->* before casts. +// PRMS Id: 4484 (bug 4) + +struct A { }; +struct B : public A { void f (); }; + +void g () +{ + A* ap = new B; + void (B::*p)() = &B::f; + + ((B*)ap->*p)(); // { dg-bogus "" } incorrect precedence +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/redecl1.C b/gcc/testsuite/g++.old-deja/g++.jason/redecl1.C new file mode 100644 index 000000000..6fda9d27a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/redecl1.C @@ -0,0 +1,13 @@ +// { dg-do assemble } +class A +{ +public: + A (const A& ccref); + friend A const re (const A& v1); // { dg-error "ambiguates" } +}; + +A // const +re (const A& ref) // { dg-error "new declaration" } +{ + return A (ref); +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/ref1.C b/gcc/testsuite/g++.old-deja/g++.jason/ref1.C new file mode 100644 index 000000000..5099077dc --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/ref1.C @@ -0,0 +1,8 @@ +// { dg-do assemble } +// Bug: g++ tries to call a constructor for a reference. Doh! + +class B; +struct A { + B & b; + A (B & x) : b (x) { } // { dg-bogus "" } +}; // { dg-bogus "" } diff --git a/gcc/testsuite/g++.old-deja/g++.jason/ref10.C b/gcc/testsuite/g++.old-deja/g++.jason/ref10.C new file mode 100644 index 000000000..4fe6ffdaf --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/ref10.C @@ -0,0 +1,32 @@ +// { dg-do run } +// Test that conversion from D* to B*& works properly. + +extern "C" int printf (const char *, ...); + +struct V { + int a; +}; + +struct B: virtual V { + int b; +}; + +struct D: B { + int c; +}; + +V* gp = 0; + +void foo(V * const &r) { + gp = r; +} + +int bar(V *r) { + return (r != gp); +} + +int main() { + D *p = new D; + foo(p); + return bar(p); +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/ref11.C b/gcc/testsuite/g++.old-deja/g++.jason/ref11.C new file mode 100644 index 000000000..e8f8db25b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/ref11.C @@ -0,0 +1,18 @@ +// { dg-do run } +int main(int argc, char ** argv) { + + int (&var_field_ref)[] = * (int (*)[]) new int [42]; + int (&fix_field_ref)[1] = * (int (*)[1]) new int [42]; + + int static_field[42]; + + int *const &var_field_ptr_ref = var_field_ref; // { dg-bogus "" } + int *const &fix_field_ptr_ref = fix_field_ref; + int *const &static_field_ptr_ref = static_field; + + int * var_field_ptr = var_field_ref; // { dg-bogus "" } + int * fix_field_ptr = fix_field_ref; + int * static_field_ptr = static_field; + + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/ref12.C b/gcc/testsuite/g++.old-deja/g++.jason/ref12.C new file mode 100644 index 000000000..a604055fc --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/ref12.C @@ -0,0 +1,6 @@ +// { dg-do run } +void f (const char *const &) { } +int main () +{ + f ("hi"); +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/ref2.C b/gcc/testsuite/g++.old-deja/g++.jason/ref2.C new file mode 100644 index 000000000..0fd789371 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/ref2.C @@ -0,0 +1,6 @@ +// { dg-do assemble } +// Bug: g++ can't deal with references to arrays. + +typedef float Matrix[4][4]; +Matrix m; +Matrix& f () { return m; } diff --git a/gcc/testsuite/g++.old-deja/g++.jason/ref3.C b/gcc/testsuite/g++.old-deja/g++.jason/ref3.C new file mode 100644 index 000000000..b9923cb85 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/ref3.C @@ -0,0 +1,7 @@ +// { dg-do assemble } +// PRMS Id: ???? + +void f (const int& i) +{ + &(int&)i; // { dg-bogus "" } references ARE lvalues +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/ref4.C b/gcc/testsuite/g++.old-deja/g++.jason/ref4.C new file mode 100644 index 000000000..53461d0d4 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/ref4.C @@ -0,0 +1,4 @@ +// { dg-do assemble } + +void f (); +void (&fr)() = f; diff --git a/gcc/testsuite/g++.old-deja/g++.jason/ref5.C b/gcc/testsuite/g++.old-deja/g++.jason/ref5.C new file mode 100644 index 000000000..3ab344288 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/ref5.C @@ -0,0 +1,10 @@ +// { dg-do assemble } + +int i; +int &const j = i; // { dg-error "" } invalid const +int &const f(); // { dg-error "" } invalid const +void g () +{ + j = 1; + f() = 1; +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/ref6.C b/gcc/testsuite/g++.old-deja/g++.jason/ref6.C new file mode 100644 index 000000000..17848af00 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/ref6.C @@ -0,0 +1,3 @@ +// { dg-do assemble } +const int &f(); +int &a = f(); // { dg-error "" } diff --git a/gcc/testsuite/g++.old-deja/g++.jason/ref7.C b/gcc/testsuite/g++.old-deja/g++.jason/ref7.C new file mode 100644 index 000000000..a7a7f8cd5 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/ref7.C @@ -0,0 +1,22 @@ +// { dg-do run } +// Testcase for the lifetime of a temporary object which is used to +// initialize a reference. + +int destroyed = 0; + +struct A { + A() { } + A(int) { } + ~A() { destroyed++; } +}; + +A a; +A foo () { return a; } + +int main() +{ + const A& ar = foo(); + const A& ar2 = A(); + const A& ar3 = (A)1; + return destroyed; +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/ref8.C b/gcc/testsuite/g++.old-deja/g++.jason/ref8.C new file mode 100644 index 000000000..97dd51acf --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/ref8.C @@ -0,0 +1,18 @@ +// { dg-do run } +// PRMS Id: 5184 +// Bug: cast to C& below does not adjust address + +struct A {}; +struct B { + virtual void foo () {} +}; +struct C : public B, public A {}; + +int main() { + C c; + + A& ar = c; + C& cr = (C&)ar; + + cr.foo(); // this line causes core dump +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/ref9.C b/gcc/testsuite/g++.old-deja/g++.jason/ref9.C new file mode 100644 index 000000000..db4426280 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/ref9.C @@ -0,0 +1,26 @@ +// { dg-do run } +// Bug: g++ re-evaluates the initializer for r before calling f(); since i has +// changed to an invalid index, this breaks. + +class C +{ +public: + void f () { } +}; + +void foo (C * objs[]) +{ + int i = 0; + C & r = * objs[i]; /* make reference to element */ + + i = 666; + r.f (); /* core dumps here */ +} + +int +main () +{ + C * objs[1] = { new C }; + + foo (objs); +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/report.C b/gcc/testsuite/g++.old-deja/g++.jason/report.C new file mode 100644 index 000000000..b595662c2 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/report.C @@ -0,0 +1,77 @@ +// { dg-do assemble } +// { dg-options "-Wreturn-type" } +// GROUPS passed error-reporting + +// DR 295 allows qualification via typedef + +template <char C> +class badoo +{ +}; + +template <int (*F) (int)> +class doowop +{ +}; + +struct A +{ + int a; + ~A () { a = 0; } + operator int () { return a; } +}; + +extern "C" int atoi (const char *); + +int (*fee)(const char *) = atoi; +int (**bar)(const char *) = &fee; + +const char* s = "4"; +const char** sp = &s; +const char*** spp = &sp; + +int foo (int a = (**bar) (s)) +{ + return doowop<foo>::bar; // { dg-error "" } not a member +} + +int foo2 (int (*a)(int) = &foo) +{ + undef4 (1); // { dg-error "" } implicit declaration + return 1; +} + +class X{ + class Y{}; // { dg-error "" } private +}; + +typedef int const * bart (); +//The following is DR295 dependant +typedef bart const * const * bar2; +typedef bart volatile * const * bar2v; + +bar2 baz (X::Y y) // { dg-error "" } in this context +{ + X::Y f; // { dg-error "" } in this context + bar2 wa [5]; + wa[0] = baz(f); + undef2 (1); // { dg-error "" } implicit declaration +} // { dg-warning "no return statement" } + +int ninny () +{ + struct A + { + static int ninny2 () { return badoo<'\001'>::foo; } // { dg-error "" } not a member + }; + + return A::ninny2(); +} + +int darg (char X::*p) +{ + undef3 (1); // { dg-error "" } implicit declaration +} // { dg-warning "no return statement" } + +// { dg-message "warning: control reaches end of non-void function" "" { target *-*-* } 36 } +// { dg-message "warning: control reaches end of non-void function" "" { target *-*-* } 65 } diff --git a/gcc/testsuite/g++.old-deja/g++.jason/return.C b/gcc/testsuite/g++.old-deja/g++.jason/return.C new file mode 100644 index 000000000..af9791c57 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/return.C @@ -0,0 +1,22 @@ +// { dg-do run } +// PRMS Id: 5331 +// Bug: the return value of foo is constructed in a temporary and then +// copied into the return slot. This is not necessary. + +int c = 0; + +struct X { + X(int i) { } + X(X const &XX) { c = 1; } + ~X() { } +}; + +const X foo() { + return X(3); +} + +int main() +{ + foo(); + return c; +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/return2.C b/gcc/testsuite/g++.old-deja/g++.jason/return2.C new file mode 100644 index 000000000..132c07929 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/return2.C @@ -0,0 +1,24 @@ +// { dg-do run } +// PRMS Id: 5368 +// Bug: the X temporary in foo() is not destroyed. + +int c = 0; + +struct X { + X (int) { c++; } + ~X() { c--; } +}; + +struct Y { + Y(const X &) { } +}; + +Y foo() { + return X(3); +} + +int main() +{ + foo(); + return c; +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/return3.C b/gcc/testsuite/g++.old-deja/g++.jason/return3.C new file mode 100644 index 000000000..6627fd169 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/return3.C @@ -0,0 +1,20 @@ +// { dg-do run } +// PRMS id: 10912 + +struct A { + A() { i=10; } + int i; +}; +struct B : public A {}; +B b; + +A f() +{ + return b; +} + +int main () +{ + A a = f (); + return a.i != 10; +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/rfg1.C b/gcc/testsuite/g++.old-deja/g++.jason/rfg1.C new file mode 100644 index 000000000..6ded34353 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/rfg1.C @@ -0,0 +1,13 @@ +// { dg-do assemble } +// Bug: g++ parses the declaration of i as a functional cast. + +void take_int (int arg) { } + +void +test () +{ + int (i); + + i = 0; + take_int (i); +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/rfg10.C b/gcc/testsuite/g++.old-deja/g++.jason/rfg10.C new file mode 100644 index 000000000..f6d5af3a8 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/rfg10.C @@ -0,0 +1,11 @@ +// { dg-do assemble } +// Bug: g++ doesn't notice the overflow in the enum values. + +#include <limits.h> + +enum COLOR +{ + red, + green = ULONG_MAX, + blue // { dg-error "overflow in enumeration" } +}; diff --git a/gcc/testsuite/g++.old-deja/g++.jason/rfg11.C b/gcc/testsuite/g++.old-deja/g++.jason/rfg11.C new file mode 100644 index 000000000..3a3db6620 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/rfg11.C @@ -0,0 +1,2 @@ +// { dg-do assemble } +typedef int int; /* { dg-error "" } trying to redefine int */ diff --git a/gcc/testsuite/g++.old-deja/g++.jason/rfg12.C b/gcc/testsuite/g++.old-deja/g++.jason/rfg12.C new file mode 100644 index 000000000..5548e0f63 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/rfg12.C @@ -0,0 +1,2 @@ +// { dg-do assemble } +int array[3] = { 1, 2, 3, 4 }; /* { dg-error "" } excess initializer elements */ diff --git a/gcc/testsuite/g++.old-deja/g++.jason/rfg13.C b/gcc/testsuite/g++.old-deja/g++.jason/rfg13.C new file mode 100644 index 000000000..ae894d13d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/rfg13.C @@ -0,0 +1,12 @@ +// { dg-do assemble } +// Bug: g++ does overloading on a function-by-function basis. + +void +f () +{ + void (*fp)(void); + { + extern void g (); + } + fp = g; /* { dg-error "" } no 'g' in scope */ +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/rfg14.C b/gcc/testsuite/g++.old-deja/g++.jason/rfg14.C new file mode 100644 index 000000000..85a346afe --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/rfg14.C @@ -0,0 +1,16 @@ +// { dg-do assemble } +void *vp; +int (*ap)[]; +struct S *sp; +union U *up; +int (*fp)(); + +void +test () +{ + vp++; /* { dg-error "" } incrementing void * */ + ap++; /* { dg-error "" } incrementing ptr to incomplete type */ + sp++; /* { dg-error "" } incrementing ptr to incomplete type */ + up++; /* { dg-error "" } incrementing ptr to incomplete type */ + fp++; /* { dg-error "" } incrementing ptr to function */ +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/rfg16.C b/gcc/testsuite/g++.old-deja/g++.jason/rfg16.C new file mode 100644 index 000000000..d42516d4f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/rfg16.C @@ -0,0 +1,5 @@ +// { dg-do assemble } +// Bug: g++ doesn't push parameter decls as they are parsed. + +void (*ptr) (int foo, int array[sizeof(foo)]); +void test2 (int bar, int array[sizeof(bar)]) { } diff --git a/gcc/testsuite/g++.old-deja/g++.jason/rfg17.C b/gcc/testsuite/g++.old-deja/g++.jason/rfg17.C new file mode 100644 index 000000000..a138f9ad9 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/rfg17.C @@ -0,0 +1,16 @@ +// { dg-do assemble } +// The default assignment operator for B uses array assignment, so we can't +// just disallow it... + +struct A { A& operator=(const A&); }; +struct B { A f[20]; }; + +int a1[20], a2[20]; +B b1, b2; + +void +test () +{ + b1 = b2; /* OK */ + a1 = a2; /* { dg-error "" } array assignment */ +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/rfg18.C b/gcc/testsuite/g++.old-deja/g++.jason/rfg18.C new file mode 100644 index 000000000..9c32b1f02 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/rfg18.C @@ -0,0 +1,11 @@ +// { dg-do assemble } +// Any expression may be explicitly converted to type void. + +struct S { int m[10]; } object; +struct S f () { return object; } + +void +test () +{ + (void) f().m; /* OK - cast to void; see constraints in 3.8.1 */ +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/rfg2.C b/gcc/testsuite/g++.old-deja/g++.jason/rfg2.C new file mode 100644 index 000000000..44cb1cb02 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/rfg2.C @@ -0,0 +1,6 @@ +// { dg-do assemble } +// Bug: g++ complains about a class definition containing a const member +// but no constructor; it shouldn't complain at that point, since this is +// valid use. + +struct S { const int member; } object = { 0 }; diff --git a/gcc/testsuite/g++.old-deja/g++.jason/rfg20.C b/gcc/testsuite/g++.old-deja/g++.jason/rfg20.C new file mode 100644 index 000000000..505f7c949 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/rfg20.C @@ -0,0 +1,10 @@ +// { dg-do assemble } + +typedef void func_type (); +func_type *fp; +void *vp; + +void example () +{ + vp != fp; // { dg-error "forbids comparison" } no conversion from pfn to void* +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/rfg21.C b/gcc/testsuite/g++.old-deja/g++.jason/rfg21.C new file mode 100644 index 000000000..cce28e89a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/rfg21.C @@ -0,0 +1,2 @@ +// { dg-do assemble } +char array0[4] = "abcde"; /* { dg-error "" } initializer too long */ diff --git a/gcc/testsuite/g++.old-deja/g++.jason/rfg22.C b/gcc/testsuite/g++.old-deja/g++.jason/rfg22.C new file mode 100644 index 000000000..7fee2ac23 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/rfg22.C @@ -0,0 +1,7 @@ +// { dg-do assemble } +static void f (); // { dg-error "" } used but not defined + +void g () +{ + f (); +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/rfg23.C b/gcc/testsuite/g++.old-deja/g++.jason/rfg23.C new file mode 100644 index 000000000..8bf9f7c56 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/rfg23.C @@ -0,0 +1,3 @@ +// { dg-do assemble } + signed char *ptr2 = "hello"; /* { dg-error "" } changing sign */ +unsigned char *ptr3 = "hello"; /* { dg-error "" } changing sign */ diff --git a/gcc/testsuite/g++.old-deja/g++.jason/rfg24.C b/gcc/testsuite/g++.old-deja/g++.jason/rfg24.C new file mode 100644 index 000000000..1aa05c0a9 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/rfg24.C @@ -0,0 +1,9 @@ +// { dg-do assemble } +typedef int Int; + +Int Int_object_1; + +void test () +{ + ((Int) Int_object_1) = Int_object_1; /* { dg-error "" } not an lvalue*/ +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/rfg25.C b/gcc/testsuite/g++.old-deja/g++.jason/rfg25.C new file mode 100644 index 000000000..713a6918c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/rfg25.C @@ -0,0 +1,2 @@ +// { dg-do assemble } +struct { int :0; }; /* { dg-error "" } anon struct not used to declare objects */ diff --git a/gcc/testsuite/g++.old-deja/g++.jason/rfg26.C b/gcc/testsuite/g++.old-deja/g++.jason/rfg26.C new file mode 100644 index 000000000..2b7e06085 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/rfg26.C @@ -0,0 +1,10 @@ +// { dg-do assemble } +typedef void (FTYPE) (); + +FTYPE f; /* ok */ + +void +test_0 () +{ + (FTYPE) f; /* { dg-error "" } casting to function type */ +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/rfg27.C b/gcc/testsuite/g++.old-deja/g++.jason/rfg27.C new file mode 100644 index 000000000..dd20747ef --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/rfg27.C @@ -0,0 +1,8 @@ +// { dg-do assemble } +// { dg-options "-pedantic-errors" } +// Don't compile this one with -Wno-long-long... + +short volatile short var_0_2; /* { dg-error "" } duplicate short */ +long volatile long var_0_3; /* { dg-error "" } duplicate long */ +signed volatile signed var_0_7; /* { dg-error "" } duplicate signed */ +unsigned volatile unsigned var_0_8; /* { dg-error "" } duplicate unsigned */ diff --git a/gcc/testsuite/g++.old-deja/g++.jason/rfg28.C b/gcc/testsuite/g++.old-deja/g++.jason/rfg28.C new file mode 100644 index 000000000..e910c2408 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/rfg28.C @@ -0,0 +1,10 @@ +// { dg-do assemble } +/* From 01/25/94 working paper (7.1.3): + + If, in a decl-specifier-seq containing the decl-specifier typedef, + there is no type-specifier, or the only type-specifiers are cv- + qualifiers, the typedef declaration is ill-formed. +*/ + +typedef foo; // { dg-error "" } invalid typedef +typedef const bar; // { dg-error "" } invalid typedef diff --git a/gcc/testsuite/g++.old-deja/g++.jason/rfg3.C b/gcc/testsuite/g++.old-deja/g++.jason/rfg3.C new file mode 100644 index 000000000..93f74685c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/rfg3.C @@ -0,0 +1,15 @@ +// { dg-do assemble } +// Bug: g++ remembers the members of OUTER and complains about the second +// definition. + +void +test () +{ + { + struct OUTER { struct INNER { int mbr; } member; }; + } + + { + struct OUTER { struct INNER { int mbr; } member; }; + } +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/rfg4.C b/gcc/testsuite/g++.old-deja/g++.jason/rfg4.C new file mode 100644 index 000000000..fbc3841dd --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/rfg4.C @@ -0,0 +1,13 @@ +// { dg-do assemble } +// { dg-options "-ansi -pedantic-errors -w" } +// Bug: f1 and f2 are treated as overloaded when they aren't. + +int i; +void f1(double) { } +void f2(double) { } + +void +test () +{ + i ? f1 : f2; // { dg-bogus "" } improper overloading +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/rfg5.C b/gcc/testsuite/g++.old-deja/g++.jason/rfg5.C new file mode 100644 index 000000000..11ee9c035 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/rfg5.C @@ -0,0 +1,11 @@ +// { dg-do assemble } +// { dg-options "-ansi -pedantic-errors -w" } +// Bug: func is treated as an overloaded function when it isn't. + +int *func () { return 0; } + +void +test () +{ + *func; // { dg-bogus "" } improper overloading +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/rfg6.C b/gcc/testsuite/g++.old-deja/g++.jason/rfg6.C new file mode 100644 index 000000000..c2bca4554 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/rfg6.C @@ -0,0 +1,4 @@ +// { dg-do assemble } + +const wchar_t *single = L"xyz" ; +const wchar_t *(array[]) = { L"xyz" }; diff --git a/gcc/testsuite/g++.old-deja/g++.jason/rfg7.C b/gcc/testsuite/g++.old-deja/g++.jason/rfg7.C new file mode 100644 index 000000000..db19deeab --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/rfg7.C @@ -0,0 +1,6 @@ +// { dg-do assemble } +// Bug: fixincludes and/or cpp mangle the definition of wchar_t so that this +// doesn't work. + +#include <stdlib.h> +wchar_t array[] = L"xxx"; // { dg-bogus "" } wchar_t diff --git a/gcc/testsuite/g++.old-deja/g++.jason/rfg8.C b/gcc/testsuite/g++.old-deja/g++.jason/rfg8.C new file mode 100644 index 000000000..39ef34cf8 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/rfg8.C @@ -0,0 +1,4 @@ +// { dg-do assemble } +// Bug: g++ is wrongfully pedantic about union initializers. + +union U { int mbr; } array[1] = { 0 }; diff --git a/gcc/testsuite/g++.old-deja/g++.jason/rfg9.C b/gcc/testsuite/g++.old-deja/g++.jason/rfg9.C new file mode 100644 index 000000000..ec15d13e2 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/rfg9.C @@ -0,0 +1,10 @@ +// { dg-do assemble } +int cond; +int i; +int *ip; + +void +test () +{ + cond ? i : ip; /* { dg-error "" } pointer/integer mismatch */ +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/rvalue1.C b/gcc/testsuite/g++.old-deja/g++.jason/rvalue1.C new file mode 100644 index 000000000..277d594b8 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/rvalue1.C @@ -0,0 +1,52 @@ +// { dg-do run } +// PRMS Id: 6000 +// Bug: g++ gets confused trying to build up a reference to a cast. + +class String { +protected: + char *cp; +public: + String(char *incp); + String(const String &constStringRef); + virtual void virtualFn1(void) const {;} +}; + +String::String(char *incp) +{ + cp = incp; +} + +String::String(const String &constStringRef) +{ +// Right here, do an 'info args', and look at the virtual function table +// pointer: typically junk! Calling the function through that table could +// do anything, since we're really leaping off into the void. This example +// goes down with 'SIGBUS', but I've seen 'SIGSEGV' too, and 'SIGILL' is +// possible. + + cp = constStringRef.cp; + constStringRef.virtualFn1(); +} + +void foofun(String string) +{ + ; +} + +class Class1 { +public: + Class1(const String & constStringRef); +}; + +Class1 :: Class1 (const String & constStringRef) +{ +// If instead of calling the function 'foofun()' here, we just assign +// 'constStringRef' to a local variable, then the vptr is typically == 0! + + foofun(String(constStringRef)); +} + +int main(void) +{ + Class1 *class1 = new Class1((char*) "Hi!"); +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/rvalue2.C b/gcc/testsuite/g++.old-deja/g++.jason/rvalue2.C new file mode 100644 index 000000000..77189a5eb --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/rvalue2.C @@ -0,0 +1,18 @@ +// { dg-do run } +// Test for undesired aliasing. + +struct A { + const A * get_this () const { return this; } +}; + +int main () +{ + A a; + int r = 0; + const A& ar1 = (A)a; + if (&ar1 == &a) + r |= 1; + if (A(a).get_this () == &a) + r |= 2; + return r; +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/rvalue3.C b/gcc/testsuite/g++.old-deja/g++.jason/rvalue3.C new file mode 100644 index 000000000..58cdad5d2 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/rvalue3.C @@ -0,0 +1,6 @@ +// { dg-do assemble } +int main () +{ + int i; + int &ir = (int&)(int)i; // { dg-error "" } casting rvalue to reference type +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/scoping.C b/gcc/testsuite/g++.old-deja/g++.jason/scoping.C new file mode 100644 index 000000000..ef1673069 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/scoping.C @@ -0,0 +1,12 @@ +// { dg-do assemble } +// PRMS Id: 3977 +// Bug: A member function is not hidden properly by a later use of its name. + +struct A { + void index (); +}; + +struct B: A { + int index; + B(): index(4) {} +}; diff --git a/gcc/testsuite/g++.old-deja/g++.jason/scoping10.C b/gcc/testsuite/g++.old-deja/g++.jason/scoping10.C new file mode 100644 index 000000000..a1b563297 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/scoping10.C @@ -0,0 +1,16 @@ +// { dg-do assemble } +// Test for scope-based hiding of functions. + +void f (char *); +struct A { + void f (); // { dg-message "A::f|candidate expects" } referred to +}; +struct B : public A { + void g (char *); + void h () { + extern void g (); // { dg-message "" } + f("foo"); // { dg-error "" } hidden + // { dg-message "candidate" "candidate note" { target *-*-* } 12 } + g("foo"); // { dg-error "" } hidden + } +}; diff --git a/gcc/testsuite/g++.old-deja/g++.jason/scoping11.C b/gcc/testsuite/g++.old-deja/g++.jason/scoping11.C new file mode 100644 index 000000000..9a3717d57 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/scoping11.C @@ -0,0 +1,11 @@ +// { dg-do assemble } + +void f (); +void g () +{ + int f; + { + void f (); + f (); // { dg-bogus "" } trying to call integer + } +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/scoping12.C b/gcc/testsuite/g++.old-deja/g++.jason/scoping12.C new file mode 100644 index 000000000..a7834163b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/scoping12.C @@ -0,0 +1,10 @@ +// { dg-do assemble } +void f () +{ + struct A { + friend void g (); // { dg-error "without prior declaration" } + }; +} +void h () { + g (); // { dg-error "" } no g in scope +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/scoping13.C b/gcc/testsuite/g++.old-deja/g++.jason/scoping13.C new file mode 100644 index 000000000..fc90902a3 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/scoping13.C @@ -0,0 +1,10 @@ +// { dg-do assemble } + +struct A { typedef int foo; }; +struct B: public A { + typedef int bar; + struct C { + void g (B::bar); // { dg-bogus "" } nested type failure + void f (B::foo); + }; +}; diff --git a/gcc/testsuite/g++.old-deja/g++.jason/scoping14.C b/gcc/testsuite/g++.old-deja/g++.jason/scoping14.C new file mode 100644 index 000000000..f53f72a60 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/scoping14.C @@ -0,0 +1,8 @@ +// { dg-do assemble } +// [class.scope0]: The scope of a name declared in a class consists +// ... also of all ... default arguments ... in that class .... + +struct A { + void f (int A::* = &A::i); + int i; +}; diff --git a/gcc/testsuite/g++.old-deja/g++.jason/scoping15.C b/gcc/testsuite/g++.old-deja/g++.jason/scoping15.C new file mode 100644 index 000000000..cc34c5f57 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/scoping15.C @@ -0,0 +1,21 @@ +// { dg-do assemble } +// { dg-options "-ffriend-injection" } +// Bug: g++ ignores the :: qualification and dies trying to treat an integer +// variable as a list of functions. + +class DComplex { +public: + friend double imag(const DComplex& a); +}; + +class FComplex { +public: + friend float imag(const FComplex& a); +}; + +void +scnrm2(FComplex cx[]) +{ + int imag; + ::imag( cx[0] ); +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/scoping16.C b/gcc/testsuite/g++.old-deja/g++.jason/scoping16.C new file mode 100644 index 000000000..9b9d915ba --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/scoping16.C @@ -0,0 +1,5 @@ +// { dg-do assemble } +struct A { + int a(); // { dg-error "" } + int a; // { dg-error "" } +}; diff --git a/gcc/testsuite/g++.old-deja/g++.jason/scoping17.C b/gcc/testsuite/g++.old-deja/g++.jason/scoping17.C new file mode 100644 index 000000000..c51dbef68 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/scoping17.C @@ -0,0 +1,9 @@ +// { dg-do run } +// Test that the integer hides the struct in block scope. + +int main () +{ + int A; + struct A { }; + A = 1; +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/scoping2.C b/gcc/testsuite/g++.old-deja/g++.jason/scoping2.C new file mode 100644 index 000000000..637e74b24 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/scoping2.C @@ -0,0 +1,15 @@ +// { dg-do assemble } +// Bug: A function is not hidden properly by a use of its name in an +// inner scope. + +struct A +{ + struct B + { + int f; + B() : f(0) {} + void g() { f = 0; } + }; + void f(); + void f(int); +}; diff --git a/gcc/testsuite/g++.old-deja/g++.jason/scoping3.C b/gcc/testsuite/g++.old-deja/g++.jason/scoping3.C new file mode 100644 index 000000000..31a75cf0a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/scoping3.C @@ -0,0 +1,8 @@ +// { dg-do assemble } +// Bug: g++ does not grok nested types very well. + +class A { + class B; + friend class B; + class B { }; // { dg-bogus "" } +}; diff --git a/gcc/testsuite/g++.old-deja/g++.jason/scoping4.C b/gcc/testsuite/g++.old-deja/g++.jason/scoping4.C new file mode 100644 index 000000000..c32b4a660 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/scoping4.C @@ -0,0 +1,30 @@ +// { dg-do assemble } +// PRMS Id: 4375 +// Bug: g++ fails to keep track of nested typedefs properly. + +class A { +public: + typedef const char * Ptr; + Ptr s; + Ptr get_string(); + A(Ptr string); // { s = string; }; +}; + +class B { +public: + typedef A * Ptr; + Ptr a; + Ptr get_A(); + B(Ptr a_ptr); +}; + +A::A(Ptr string) { // { dg-bogus "" } + s = string; // { dg-bogus "" } +} + +int main() { + A a("testing"); + A *a_ptr; + B b(&a); + a_ptr = b.get_A(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/scoping5.C b/gcc/testsuite/g++.old-deja/g++.jason/scoping5.C new file mode 100644 index 000000000..8c4d7fdde --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/scoping5.C @@ -0,0 +1,6 @@ +// { dg-do assemble } +// Bug: g++ thinks that A defines operator delete, and tries to call it. + +struct A { + ~A () { ::operator delete (0); } +}; diff --git a/gcc/testsuite/g++.old-deja/g++.jason/scoping6.C b/gcc/testsuite/g++.old-deja/g++.jason/scoping6.C new file mode 100644 index 000000000..2f33010fd --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/scoping6.C @@ -0,0 +1,27 @@ +// { dg-do assemble } +// Testcase for all uses of explicit global scope. + +int a, B; + +struct A { }; +int operator+(A&, int); + +struct B { + struct C { + static int a; + static int f () { A a; return ::operator+ (a, ::a); } // { dg-bogus "" } + }; +}; + +int B::C::a = 0; + +struct D : public ::B::C { }; // { dg-bogus "" } + +void f () +{ + int B; + ::B::C b; + + B = ::B::C::a; // { dg-bogus "" } + B = ::B::C::f(); // { dg-bogus "" } +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/scoping7.C b/gcc/testsuite/g++.old-deja/g++.jason/scoping7.C new file mode 100644 index 000000000..41859aa39 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/scoping7.C @@ -0,0 +1,6 @@ +// { dg-do assemble } +// Bug: g++ doesn't flag name collisions between types and non-types as +// errors. It shouldn't for class names, but it should for typedefs. + +int bar; // { dg-error "" } +typedef int bar; // { dg-error "" } diff --git a/gcc/testsuite/g++.old-deja/g++.jason/scoping8.C b/gcc/testsuite/g++.old-deja/g++.jason/scoping8.C new file mode 100644 index 000000000..bb31735f2 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/scoping8.C @@ -0,0 +1,8 @@ +// { dg-do assemble } +// Bug: g++ allows two different meanings of a name in the same scope. + +typedef int foo; // { dg-error "" } +struct A { + A (foo); + int foo (); // { dg-error "" } foo already used in scope +}; diff --git a/gcc/testsuite/g++.old-deja/g++.jason/scoping9.C b/gcc/testsuite/g++.old-deja/g++.jason/scoping9.C new file mode 100644 index 000000000..be991185f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/scoping9.C @@ -0,0 +1,12 @@ +// { dg-do assemble } +// Bug: g++ silently mangles the second 'B' to 'A::B', so the definition is +// lost. + +struct A { + enum B { }; +}; + +struct C: public A { + enum B { }; + void foo (C::B); +}; diff --git a/gcc/testsuite/g++.old-deja/g++.jason/shadow1.C b/gcc/testsuite/g++.old-deja/g++.jason/shadow1.C new file mode 100644 index 000000000..941f80cfc --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/shadow1.C @@ -0,0 +1,16 @@ +// { dg-do assemble } +// { dg-options "-Wshadow" } + +class x { +public: + void fun(); +private: + int foo; +}; + +void x::fun() { } + +main () +{ + float foo; +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/soverload.C b/gcc/testsuite/g++.old-deja/g++.jason/soverload.C new file mode 100644 index 000000000..b29e64936 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/soverload.C @@ -0,0 +1,10 @@ +// { dg-do assemble } +// Bug: dfs_pushdecls doesn't create an overload list for member functions, +// like it claims to. + +struct A +{ + static int foo (int); + static int foo (int, int); + void bar () { foo (1, 2); } // { dg-bogus "" } broken overloading +}; diff --git a/gcc/testsuite/g++.old-deja/g++.jason/special.C b/gcc/testsuite/g++.old-deja/g++.jason/special.C new file mode 100644 index 000000000..29565d548 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/special.C @@ -0,0 +1,7 @@ +// { dg-do assemble } +// Make sure that forward declarations of specializations work... + +template <class T> class A { }; +template <> class A<int>; +A<int> a; // { dg-error "" } incomplete type +template <> class A<int> { }; diff --git a/gcc/testsuite/g++.old-deja/g++.jason/static1.C b/gcc/testsuite/g++.old-deja/g++.jason/static1.C new file mode 100644 index 000000000..2c6f6bd4d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/static1.C @@ -0,0 +1,32 @@ +// { dg-do run } +// PRMS id: 6863 + +extern "C" int printf(const char *, ...); +extern "C" void abort(); + +enum ENUM {E1=0, E2 }; +int d; + +class AAA{ +public: + AAA() {a = new char[10];printf("constructor AAA() called\n");} + AAA(int) {printf("constructor AAA(int) called\n");} + ~AAA(){ printf("destructor ~AAA() called\n"); d = 1; } + operator int () { return 1;} + char *a; + int i; +}; + +struct sentinel { + ~sentinel () { if (d == 0) abort (); } +} s; + +/* forward decl here causes gcc not to execute ct and dt for arr1 */ +extern AAA arr1[]; + +AAA arr1[] = {(int)E1 }; + +int main() +{ + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/synth.C b/gcc/testsuite/g++.old-deja/g++.jason/synth.C new file mode 100644 index 000000000..a57f23ce9 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/synth.C @@ -0,0 +1,13 @@ +// { dg-do assemble } +// Bug: the synthesized copy constructor for A is not found. + +struct A { + // A (const A& a): i(a.i) {} + int i; +}; + +struct B { + A a; + B (const B& b): a(b.a), j(b.j) { } // { dg-bogus "" } + int j; +}; diff --git a/gcc/testsuite/g++.old-deja/g++.jason/synth10.C b/gcc/testsuite/g++.old-deja/g++.jason/synth10.C new file mode 100644 index 000000000..f6181dc7c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/synth10.C @@ -0,0 +1,52 @@ +// { dg-do assemble } +// { dg-options "-O" } +// Bug: Synthesizing methods for the nested class screwed up current_class_decl +// for the outer class. + +class A; +class AH +{ + public: + AH ( A * p = 0 ); + AH ( const AH & from ) + : pointer( from.pointer ) { inc(); } + ~ AH () { dec(); } + private: + A * pointer; + void inc() const; + void dec() const; +}; + +class A +{ + protected: + struct AttrTable + { + struct Row + { + }; + }; + + public: + + class Attributes + { + public: + class iterator + { + public: + iterator() : mo(0), attr(0) {} + iterator& operator++() { ++attr; return *this; } + iterator operator++(int) + { iterator tmp = *this; ++*this; return tmp; } + + private: + AH mo; + const AttrTable::Row* attr; + }; + + Attributes(AH mo) + : mo(mo) {} + AH mo; + }; +}; diff --git a/gcc/testsuite/g++.old-deja/g++.jason/synth2.C b/gcc/testsuite/g++.old-deja/g++.jason/synth2.C new file mode 100644 index 000000000..5e420913f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/synth2.C @@ -0,0 +1,8 @@ +// { dg-do assemble } +// PRMS Id: 4623 +// Bug: g++ tries and fails to synthesize a copy constructor for D. + +class A { }; +class B: public virtual A { }; +class C: public A { }; +class D: public B, public C { }; // { dg-bogus "" } bad synthesis diff --git a/gcc/testsuite/g++.old-deja/g++.jason/synth3.C b/gcc/testsuite/g++.old-deja/g++.jason/synth3.C new file mode 100644 index 000000000..ff304f99e --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/synth3.C @@ -0,0 +1,6 @@ +// { dg-do assemble } +// Testcase for wrongful generation of copy constructor. + +class A { }; +class B: virtual private A { }; +class D: public B { }; // { dg-bogus "" } diff --git a/gcc/testsuite/g++.old-deja/g++.jason/synth4.C b/gcc/testsuite/g++.old-deja/g++.jason/synth4.C new file mode 100644 index 000000000..c35780cc3 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/synth4.C @@ -0,0 +1,15 @@ +// { dg-do assemble } + +struct X { + X(); +}; +typedef void (X::*mfp)(); +struct Y { + Y(); + mfp memfp; +}; +void f() +{ + Y *y1, *y2 ; + *y1 = *y2; // { dg-bogus "" } failed to synthesize op= +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/synth5.C b/gcc/testsuite/g++.old-deja/g++.jason/synth5.C new file mode 100644 index 000000000..f5e73807c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/synth5.C @@ -0,0 +1,15 @@ +// { dg-do run } +// Bug: generated B::operator= tries to call A::operator= + +#pragma implementation +#line 1 "synth5.h" +#pragma interface + +struct A { + virtual A& operator= (const A&) = 0; +}; + +struct B: public A { +}; +#line 5 "synth5.C" +int main() { } diff --git a/gcc/testsuite/g++.old-deja/g++.jason/synth6.C b/gcc/testsuite/g++.old-deja/g++.jason/synth6.C new file mode 100644 index 000000000..01485282e --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/synth6.C @@ -0,0 +1,15 @@ +// { dg-do assemble } +// Bug: g++ tries to generate an op= for DbmItem and fails. + +class RefCount{ +public: + RefCount(); + +private: + RefCount& operator=(const RefCount); +}; + +class DbmItem: public RefCount{ +public: + DbmItem(): RefCount() {} +}; diff --git a/gcc/testsuite/g++.old-deja/g++.jason/synth7.C b/gcc/testsuite/g++.old-deja/g++.jason/synth7.C new file mode 100644 index 000000000..33beb911f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/synth7.C @@ -0,0 +1,12 @@ +// { dg-do run } +// Testcase to make sure that synthesized methods are found when needed. + +struct B { ~B() { } }; +struct A { B b; }; + +int main() +{ + A a, b (a), c = A(); + A& (A::*afp)(const A&) = &A::operator=; + (a.*afp) (b); +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/synth8.C b/gcc/testsuite/g++.old-deja/g++.jason/synth8.C new file mode 100644 index 000000000..29abc2ae6 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/synth8.C @@ -0,0 +1,20 @@ +// { dg-do assemble } +// Bug: the synthesized constructor for A tries to use the mem-initializer +// list for the B constructor. + +struct A +{ + virtual ~A(); +}; + +struct B +{ + B(); + char* x; + A* a; +}; + +B::B() +: x(0), a(new A()) +{ +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/synth9.C b/gcc/testsuite/g++.old-deja/g++.jason/synth9.C new file mode 100644 index 000000000..86b8ddfef --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/synth9.C @@ -0,0 +1,20 @@ +// { dg-do assemble } +// PRMS Id: 6837 +// Bug: anonymous union confuses g++. + +struct my_key { + my_key(const my_key&); + my_key(const char* n); +}; + +struct my_node { + my_node(my_key&); + union { + long cnt; + my_node* next; + }; + my_key a; +}; + +extern my_node n; +my_node a(n); diff --git a/gcc/testsuite/g++.old-deja/g++.jason/tempargs.C b/gcc/testsuite/g++.old-deja/g++.jason/tempargs.C new file mode 100644 index 000000000..5ca92350a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/tempargs.C @@ -0,0 +1,8 @@ +// { dg-do assemble } +// GROUPS passed templates overloading +template<class T> class Vector { }; +template<class T> struct Sort { static void sort (Vector<typename T::foo> &); }; +template<class T> void Sort<T>::sort (Vector<typename T::foo> &) { } +struct whee { typedef int foo; }; + +void f (Vector<int> &vi) { Sort<whee>::sort (vi); } diff --git a/gcc/testsuite/g++.old-deja/g++.jason/tempcons.C b/gcc/testsuite/g++.old-deja/g++.jason/tempcons.C new file mode 100644 index 000000000..a9974dbf7 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/tempcons.C @@ -0,0 +1,8 @@ +// { dg-do assemble } +// Bug: member initializers are allowed where they shouldn't be. + +template <class T> +struct A { + int i; + Blarg () : i(0) { } // { dg-error "" } +}; diff --git a/gcc/testsuite/g++.old-deja/g++.jason/tempdest.C b/gcc/testsuite/g++.old-deja/g++.jason/tempdest.C new file mode 100644 index 000000000..f1940a4db --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/tempdest.C @@ -0,0 +1,20 @@ +// { dg-do assemble } +// GROUPS passed templates destructors +// Example of PR 3308 workaround + +template <class T> +class A +{ + T q; +public: + ~A() { (&q)->T::~T(); } +}; + +typedef unsigned int ui; + +int main() +{ + A<ui> *ap = new A<ui>; + + delete ap; +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/tempinst1.C b/gcc/testsuite/g++.old-deja/g++.jason/tempinst1.C new file mode 100644 index 000000000..966256f37 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/tempinst1.C @@ -0,0 +1,23 @@ +// { dg-do link } +// { dg-options "-g" } +// Bug: g++ fails to instantiate operator<<. + +struct ostream { + ostream& operator<< (const char *) { return *this; }; +}; + +template <class T> class foo; + +template <class T> ostream& operator<< (ostream& ios, foo<T>&obj) {return ios;} + +template <class T> class foo { + friend ostream& operator<<<>(ostream&, foo<T>&); +}; + +int main() +{ + ostream cout; + foo<int> foo_obj; + cout << foo_obj; // causes linker error + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/template1.C b/gcc/testsuite/g++.old-deja/g++.jason/template1.C new file mode 100644 index 000000000..359c8f165 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/template1.C @@ -0,0 +1,20 @@ +// { dg-do assemble } +// PRMS Id: 4688 +// Bug: g++ can't deal with templates instantiated within extern "C". + +class Gnaf { +public: + virtual int invariant (); +}; + +template <class T> class Array : public Gnaf { +public: + virtual int invariant(); +}; + +extern "C" +int foo() +{ + Array<int> toConv; + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/template10.C b/gcc/testsuite/g++.old-deja/g++.jason/template10.C new file mode 100644 index 000000000..196ea34b7 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/template10.C @@ -0,0 +1,31 @@ +// { dg-do assemble } +// Bug: member operator shadows global template in tsubst. + +class ostream; + +template <class TP> class smanip; + +template<class TP> +ostream& operator<<(ostream& o, const smanip<TP>& m); + +template <class TP> class smanip { +public: + friend ostream& operator<< <>(ostream &o, const smanip<TP>&m); +}; + +template<class TP> +ostream& operator<<(ostream& o, const smanip<TP>& m) +{ return o;} + +class X +{ +public: + X operator<<(int); // commenting out this line makes it work! + void print(ostream& os); +}; + +void X::print(ostream& os) +{ + smanip<double> smd; + os << smd; // { dg-bogus "" } +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/template11.C b/gcc/testsuite/g++.old-deja/g++.jason/template11.C new file mode 100644 index 000000000..004361d6c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/template11.C @@ -0,0 +1,16 @@ +// { dg-do run } +// Bug: initializers for static data members of templates don't get run. + +template <class T> struct A { + static T t; +}; + +int foo () { return 1; } + +template <> +int A<int>::t = foo (); + +int main () +{ + return (A<int>::t != 1); +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/template12.C b/gcc/testsuite/g++.old-deja/g++.jason/template12.C new file mode 100644 index 000000000..d26dfbd75 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/template12.C @@ -0,0 +1,14 @@ +// { dg-do assemble } +// Testcase for 'this is a type' syntax. + +struct B { + typedef int A; +}; + +template <class T> struct Y { + void f() { + typename T::A *d; + } +}; + +template class Y<B>; diff --git a/gcc/testsuite/g++.old-deja/g++.jason/template14.C b/gcc/testsuite/g++.old-deja/g++.jason/template14.C new file mode 100644 index 000000000..4576ec3f8 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/template14.C @@ -0,0 +1,17 @@ +// { dg-do run } +// PRMS Id: 4745 +// Bug: g++ gets the constructor and destructor confused because the default +// parm prevents the two constructor types from satisfying ==. + +template <class T> struct A { + A(int = 1); + ~A(); +}; + +template <class T> A<T>::A(int) { } // causes compiler abort +template <class T> A<T>::~A() { } + +int main() +{ + A<int> a; +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/template15.C b/gcc/testsuite/g++.old-deja/g++.jason/template15.C new file mode 100644 index 000000000..b1530201b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/template15.C @@ -0,0 +1,28 @@ +// { dg-do run } +// PRMS Id: 2139 +// Bug: g++ tries to instantiate the template with types on the function +// obstack and fails. + +template<class T> +class X { +public: + X(int) { } + + T x; +}; + +class A { }; + +int main() +{ + int i; + X<int> xi(i); + X<double> xd(i); + + X<int (*)(int, void *)> fp0(i); + X<int (*)(int, char, double)> fp1(i); + X<int (*)(int, double**, void *)> fp2(i); + + X<int (A::*)()> mp0 (i); + X<int A::*> mp1 (i); +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/template16.C b/gcc/testsuite/g++.old-deja/g++.jason/template16.C new file mode 100644 index 000000000..09877a5a6 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/template16.C @@ -0,0 +1,34 @@ +// { dg-do run } +// PRMS Id: 1502 +// Bug: g++ fails to resolve 'gnc' in the call to 'grid'. + +template<class T> class foo { +public: + foo() { } +}; + +template<class T> class bar : public foo<T> { +public: + bar() : foo<T>() {} +}; + +template<class T> class ben : public foo<T> { +public: + ben() : foo<T>() {} + void grid(T (*f)(bar<T>&),bar<T>& x,bar<T>& y,bar<T>& param); +}; + +template<class T> void ben<T>::grid(T (*f)(bar<T>&),bar<T>& x,bar<T>& y,bar<T>& param) { } + +template<class T> T gnc(bar<T>& a) +{ + return 0; +} + +int main() +{ + ben<double> a; + bar<double> x,y,p; + a.grid(gnc,x,y,p); + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/template17.C b/gcc/testsuite/g++.old-deja/g++.jason/template17.C new file mode 100644 index 000000000..2bb36aa9e --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/template17.C @@ -0,0 +1,11 @@ +// { dg-do assemble } +// Caught by Booch Components. +// Bug: g++ tries to instantiate nested enums. + +template <class T> struct A +{ + struct B { }; + enum C { c }; +}; + +template struct A<int>; diff --git a/gcc/testsuite/g++.old-deja/g++.jason/template19.C b/gcc/testsuite/g++.old-deja/g++.jason/template19.C new file mode 100644 index 000000000..0a57742a3 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/template19.C @@ -0,0 +1,10 @@ +// { dg-do run } +// Make sure type deduction isn't confused by top-level cv-quals. +template <class T> T max (const T a, const T b) { return a>b?a:b; } + +int main() +{ + int a = 0, b = 1; + int c = max (a, b); + int d = max ((const int)a, (const int)b); +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/template2.C b/gcc/testsuite/g++.old-deja/g++.jason/template2.C new file mode 100644 index 000000000..07c54f82f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/template2.C @@ -0,0 +1,12 @@ +// { dg-do assemble } +// Bug: instantiation of member templates breaks. + +template <class T> struct A { + static void f (); + void g (); +}; + +template <class T> void A<T>::f () { } +template <class T> void A<T>::g () { } + +A<int> a; diff --git a/gcc/testsuite/g++.old-deja/g++.jason/template20.C b/gcc/testsuite/g++.old-deja/g++.jason/template20.C new file mode 100644 index 000000000..2cbaffb67 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/template20.C @@ -0,0 +1,10 @@ +// { dg-do run } +// Make sure type deduction works for both types of array parameters. +template <class T> void f (T (&a)[2]) { } +template <class T> void g (T a[2]) { } +int main() +{ + int a[2] = { 0, 0 }; + f (a); + g (a); +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/template21.C b/gcc/testsuite/g++.old-deja/g++.jason/template21.C new file mode 100644 index 000000000..86b613136 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/template21.C @@ -0,0 +1,16 @@ +// { dg-do assemble } +// Gosh, this works! + +template<class T> +struct A +{ + struct B + { + void bar(); + }; + struct C { }; +}; + +template<class T> void A<T>::B::bar() { } + +template class A<int>; diff --git a/gcc/testsuite/g++.old-deja/g++.jason/template22.C b/gcc/testsuite/g++.old-deja/g++.jason/template22.C new file mode 100644 index 000000000..f6e81aa36 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/template22.C @@ -0,0 +1,31 @@ +// { dg-do assemble } +// Testcase for proper unification of code involving references. + +template<class T> +struct A +{ + void foo(); +}; + +template<class T> void A<T>::foo() { } + +template class A<int&>; + +const int& f1 (); +int& f2 (); +int f3 (); + +template <class T> void g1 (const T&); +template <class T> void g2 (T&); +template <class T> void g3 (T); + +int main() +{ + g1 (f1 ()); + g1 (f2 ()); + g1 (f3 ()); + g2 (f2 ()); + g3 (f1 ()); + g3 (f2 ()); + g3 (f3 ()); +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/template23.C b/gcc/testsuite/g++.old-deja/g++.jason/template23.C new file mode 100644 index 000000000..f2d997377 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/template23.C @@ -0,0 +1,12 @@ +// { dg-do assemble } +// Testcase for instantiation with cv-qualified type + +template<class T> +struct A +{ + void foo(); +}; + +template<class T> void A<T>::foo() { } + +template class A<const int>; diff --git a/gcc/testsuite/g++.old-deja/g++.jason/template24.C b/gcc/testsuite/g++.old-deja/g++.jason/template24.C new file mode 100644 index 000000000..0efce9ff1 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/template24.C @@ -0,0 +1,23 @@ +// { dg-do run } +// Bug: g++ doesn't find the conversion from ostream_withassign to ostream. + +#include <iostream> + +template <class T> +struct A { + T t; +}; + +template <class T> +std::ostream & operator<< (std::ostream & os, A<T> & a) +{ + os << a.t; + return os; +} + +int main () +{ + A<int> a = { 1 }; + std::cout << a << std::endl; +} + diff --git a/gcc/testsuite/g++.old-deja/g++.jason/template25.C b/gcc/testsuite/g++.old-deja/g++.jason/template25.C new file mode 100644 index 000000000..5e876d995 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/template25.C @@ -0,0 +1,49 @@ +// { dg-do run } +// PRMS Id: 6393 +// Bug: g++ is too lax in considering UPTs to be the same. + +template <class R, class T> +class Bar +{ +public: + R do_bar (T arg); +}; + + +template <class T> +class Foo +{ + T i; + +public: + void do_foo () {} + void do_foo (T const & t) {} + void do_foo (Bar<char, T> const & bar); // {} Put the body here and it works + void do_foo (Bar<T, T> const & bar); // {} Put the body here and it works +}; + +// These definitions don't work + +template <class T> +inline void Foo<T>:: +do_foo (Bar<char, T> const & bar) +{} + +template <class T> +inline void Foo<T>:: +do_foo (Bar<T, T> const & bar) +{} + + +int main () +{ int i; + Bar<char, int> bar1; + Bar<int, int> bar2; + Foo<int> foo; + foo.do_foo(); + foo.do_foo(i); + foo.do_foo(bar1); + foo.do_foo(bar2); + + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/template26.C b/gcc/testsuite/g++.old-deja/g++.jason/template26.C new file mode 100644 index 000000000..e7e3762b7 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/template26.C @@ -0,0 +1,115 @@ +// { dg-do run } +// PRMS Id: 6275 +// Bug: unification fails for call to find_parameter_in_stack. + +#include <stdio.h> +#include <stdlib.h> + +const int max_stack_size = 20; + +template <class T> +class Stack { + private: + T objects[max_stack_size]; + int nobjects; + public: + Stack(): nobjects(0) {} + void push(const T&a) { + if (nobjects >= max_stack_size) { + fprintf(stderr,"Stack: overflow\n"); + abort(); + } + objects[nobjects++] = a; + } + T pop() { + if (!nobjects) { + fprintf(stderr,"Stack: underflow\n"); + abort(); + } + nobjects -= 1; + T result = objects[nobjects]; + return result; + } + T top() const { + if (!nobjects) { + fprintf(stderr,"Stack: underflow\n"); + abort(); + } + return objects[nobjects - 1]; + } + int n() const { return nobjects; } + T operator[](int i) { return objects[i]; } +}; + +template <class T> +class Parameter { + T parameter_; + int is_set_; + int overrides_; + public: + Parameter(): is_set_(0), overrides_(0) {} + void set(const T& a) { parameter_ = a; is_set_ = 1; } + void override(int overrides = 1) { overrides_ = overrides; } + const T& value() const { return parameter_; } + int overrides() const { return overrides_; } + int is_set() const { return is_set_; } +}; + +template <class T1, class T2> +T2 +find_parameter_in_stack(Stack<T1>& stack, Parameter<T2>& (T1::*access)()) +{ + T2 result; + int have_result = 0; + for (int i=stack.n()-1; i>=0; i--) { + if ((stack[i].*access)().is_set()) { + if (!have_result || (stack[i].*access)().overrides()) { + result = (stack[i].*access)().value(); + have_result = 1; + } + } + } + return result; +} + +class A { + private: + Parameter<int> a_; + public: + A() { } + Parameter<int>& a() { return a_; } +}; + +int +main(int, char**) +{ + Stack<A> A_stack; + A a1; + A a2; + a1.a().set(1); + a2.a().set(2); + A_stack.push(a1); + A_stack.push(a2); + + int val = find_parameter_in_stack(A_stack, &A::a); + + printf("val = %d\n", val); + if (val != 2) + return 1; + + A_stack.pop(); + A_stack.pop(); + + a1.a().override(); + + A_stack.push(a1); + A_stack.push(a2); + + val = find_parameter_in_stack(A_stack, &A::a); + + printf("val = %d\n", val); + if (val != 1) + return 1; + + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/template27.C b/gcc/testsuite/g++.old-deja/g++.jason/template27.C new file mode 100644 index 000000000..a440397d7 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/template27.C @@ -0,0 +1,49 @@ +// { dg-do run } +// PRMS Id: 6826 +// Check that unnecessary templates are not instantiated. + +template <class T> +class Test +{ + public: + void doThiss(); + void doThat(); +}; + +template <class T> +void Test<T>::doThiss() +{ + T x; + + x.thiss(); +} + +template <class T> +void Test<T>::doThat() +{ + T x; + + x.that(); +} + +class A +{ + public: + void thiss() {} +}; + +class B +{ + public: + void that() {} +}; + +int main() +{ + Test<A> a; + a.doThiss(); // a.doThat() is not well formed, but then + // it's not used so needn't be instantiated. + + Test<B> b; + b.doThat(); // simillarly b.doThiss(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/template28.C b/gcc/testsuite/g++.old-deja/g++.jason/template28.C new file mode 100644 index 000000000..7359fa12d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/template28.C @@ -0,0 +1,34 @@ +// { dg-do run } +// PRMS Id: 7179 + +template <class T> +class Car{ +public: + Car(); +} ; + +class Wheels{ +public: + Wheels(); +} ; + +class Shop +{ +public: + Shop(); +private: + Car<Wheels> car ; +} ; + +Wheels::Wheels() {} + +Shop::Shop() {} + +int main() +{ + Shop shop ; + return 0 ; +} + +template <class T> +Car<T>::Car() {} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/template29.C b/gcc/testsuite/g++.old-deja/g++.jason/template29.C new file mode 100644 index 000000000..d971ab62d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/template29.C @@ -0,0 +1,19 @@ +// { dg-do assemble } +// PRMS Id: 9500 + +template <int S> +class base + { +public: + inline base(); + }; + +template <class T> +class derived : public base<sizeof(T)> + { +public: + inline derived(); + }; + +template <class T> +inline derived<T>::derived() : base<sizeof(T)>(){} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/template3.C b/gcc/testsuite/g++.old-deja/g++.jason/template3.C new file mode 100644 index 000000000..c26d58584 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/template3.C @@ -0,0 +1,15 @@ +// { dg-do run } +// PRMS Id: 4679 +// Bug: g++ doesn't re-instantiate templates after definition is seen. + +template <class T> struct A; + +A<int> *a; + +template <class T> struct A { T t; }; + +int main() +{ + if (a) + a->t = 1; // { dg-bogus "" } +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/template30.C b/gcc/testsuite/g++.old-deja/g++.jason/template30.C new file mode 100644 index 000000000..9414c06ce --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/template30.C @@ -0,0 +1,15 @@ +// { dg-do assemble } +template <class T, class U> +int func(U, T); // { dg-message "note" } + +template <class T, class U> +int func(T, U) // { dg-message "note" } +{ + return 2; +} + +int main () +{ + func (0, 1); // { dg-error "ambiguous" } + // { dg-message "candidate" "candidate note" { target *-*-* } 13 } +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/template31.C b/gcc/testsuite/g++.old-deja/g++.jason/template31.C new file mode 100644 index 000000000..81d696f2f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/template31.C @@ -0,0 +1,40 @@ +// { dg-do run } +// PRMS Id: 8569 + +#include <iostream> +#include <vector> +#include <cstdlib> + +using std::vector; + +class Component { + int george; + char mabel[128]; +}; +class CopyMe { +public: + CopyMe(){;} +private: + vector<Component> strvec; +}; + +class IncludeIt { +public: + IncludeIt() {} + ~IncludeIt() {} + IncludeIt(const IncludeIt& i) { + myStrvec = i.myStrvec; + } + IncludeIt& operator=(const IncludeIt& i) { + myStrvec = i.myStrvec; + return *this; + } +private: + CopyMe myStrvec; +}; + +int main(int argc, char**argv) { + IncludeIt foo; + IncludeIt* bar; + std::exit(0); +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/template32.C b/gcc/testsuite/g++.old-deja/g++.jason/template32.C new file mode 100644 index 000000000..3bbb6e8c5 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/template32.C @@ -0,0 +1,10 @@ +// { dg-do assemble } +// Bug: Instantiating A<int> screws with class bindings for B + +template <class T> struct A { }; +struct B { + typedef int foo; + void f (); +}; + +void B::f () { A<int> a; foo i; } diff --git a/gcc/testsuite/g++.old-deja/g++.jason/template33.C b/gcc/testsuite/g++.old-deja/g++.jason/template33.C new file mode 100644 index 000000000..af6072fd6 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/template33.C @@ -0,0 +1,17 @@ +// { dg-do assemble } +// Test nested enums in templates. + +template <class T> +class A +{ +public: + enum muni {X, Y}; + + muni e() { return X; } + muni f(); +}; + +template <class T> +typename A<T>::muni A<T>::f() { return X; } + +template class A<int>; diff --git a/gcc/testsuite/g++.old-deja/g++.jason/template34.C b/gcc/testsuite/g++.old-deja/g++.jason/template34.C new file mode 100644 index 000000000..eaeb4641a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/template34.C @@ -0,0 +1,25 @@ +// { dg-do run } +template<class T> +class Set { + public: + typedef int (*Compare)(const T&, const T&); + static Compare cmp1; + static int (*cmp2)(const T&, const T&); +}; + +template<class T> +int gen_cmp(const T& a, const T& b) { + if (a<b) return -1; + else if (a==b) return 0; + else return 1; +} + +template<class T> +typename Set<T>::Compare Set<T>::cmp1 = &gen_cmp; + +template<class T> +int (*Set<T>::cmp2)(const T&, const T&) = &gen_cmp; + +int main() { + Set<int> s; +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/template35.C b/gcc/testsuite/g++.old-deja/g++.jason/template35.C new file mode 100644 index 000000000..d2c1a3c57 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/template35.C @@ -0,0 +1,15 @@ +// { dg-do assemble } +// Bug: instantiation of D() corrupts declaration of basis[]. + +struct B { }; +template <int t> +struct D : public B +{ + D() : B () { } +}; + +B const * basis[] = +{ + new D<0>, + new D<1>, +}; diff --git a/gcc/testsuite/g++.old-deja/g++.jason/template36.C b/gcc/testsuite/g++.old-deja/g++.jason/template36.C new file mode 100644 index 000000000..23cdb00e6 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/template36.C @@ -0,0 +1,57 @@ +// { dg-do run } +// Testcase for implicit 'typename' and resolution of 'typename's in the +// current scope. + +class base1 { +public: + int bar() const + { return 1; } +}; + +class base2 { +public: + int bar() const + { return 0; } +}; + +template<class X> +struct base_trait { + typedef base1 base; +}; + +template<> +struct base_trait<float> { + typedef base2 base; +}; + +template<class T> +class weird : public base_trait<T>::base { +public: + typedef typename base_trait<T>::base base; + + base f (); + int base::* g (); + + int zowee() const + { return this->bar(); } +}; + +template <class T> +typename weird<T>::base weird<T>::f () +{ + return base(); +} + +// The standard does not allow this case; the `typename' keyword may +// not appear in a ptr-operator. +#if 0 +template <class T> +int typename weird<T>::base::* weird<T>::g () +{ return 0; } +#endif + +int main() +{ + weird<float> z; + return z.zowee() || z.f().bar(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/template39.C b/gcc/testsuite/g++.old-deja/g++.jason/template39.C new file mode 100644 index 000000000..51eace366 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/template39.C @@ -0,0 +1,22 @@ +// { dg-do assemble } +// PRMS Id: 10283 + +template <class T> struct B { + static void (*p)(); + static void f (); +}; + +template <class T> +void (*B<T>::p)() = &B<T>::f; + +B<int> b; + +template <int i> struct A { + static const int j = i; + int k[j]; +}; + +A<1> a; + +template <int i> +const int A<i>::j; diff --git a/gcc/testsuite/g++.old-deja/g++.jason/template4.C b/gcc/testsuite/g++.old-deja/g++.jason/template4.C new file mode 100644 index 000000000..de7d3312a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/template4.C @@ -0,0 +1,21 @@ +// { dg-do assemble } +// Bug: g++ tries to instantiate ccList twice, and fails. + +template<class T> class ccHandle{ }; +template <class T> class ccList; +template <class T> class cc_List { +public: + ccList <T> copy (); +}; + +template <class T> class ccList : public ccHandle < cc_List <T> > { +public: + ccList (int); +}; + +template <class T> +ccList <T> cc_List<T>::copy (){} + +int main (int, char **) { + ccList <int> size1(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/template40.C b/gcc/testsuite/g++.old-deja/g++.jason/template40.C new file mode 100644 index 000000000..e56833caa --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/template40.C @@ -0,0 +1,20 @@ +// { dg-do run } +// PRMS id: 11315 +// Bug: g++ doesn't recognize the copy ctor for Array<long>. + +template <class Type> +class Array { +public: + Array(int sz=12) + : ia (new Type[sz]), size(sz) {} + ~Array() { delete[] ia;} + Array(const Array<long>& r) : size(0) {} // just for testing +private: + Type *ia; + int size; +}; + +int main(int argc, char *argv[]) +{ + Array<long> ia; // looping occurs on this line +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/template41.C b/gcc/testsuite/g++.old-deja/g++.jason/template41.C new file mode 100644 index 000000000..a2f667f24 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/template41.C @@ -0,0 +1,34 @@ +// { dg-do run } +// PRMS Id: 11420 +// Bug: Can't handle indirect virtual template base init. + +extern "C" int printf (const char *, ...); + +template<class T> +class Vbase { + public: + Vbase(T i) { printf ("%d\n", i); } +}; + +template<class T> +class D1 : virtual public Vbase<T> { + public: + D1(T i) : Vbase<T>(i) {} +}; + +template<class T> +class D2 : virtual public Vbase<T> { + public: + D2(T i) : Vbase<T>(i) {} +}; + +template<class T> +class Most : public D1<T>, public D2<T> { + public: + Most(T i) : D1<T>(i), D2<T>(i), Vbase<T>(i) {} +}; + +int main () { + Most<int> x(2); + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/template42.C b/gcc/testsuite/g++.old-deja/g++.jason/template42.C new file mode 100644 index 000000000..63122ceb0 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/template42.C @@ -0,0 +1,19 @@ +// { dg-do run } +// Testcase for not evaluating template default args if they are +// never used. + +struct X { + X(int) { } +}; + +template <class T> +struct A { + void f (T t = T()) { } +}; + +int main () +{ + A<X> a; + X x (1); + a.f (x); +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/template43.C b/gcc/testsuite/g++.old-deja/g++.jason/template43.C new file mode 100644 index 000000000..59641de85 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/template43.C @@ -0,0 +1,31 @@ +// { dg-do run } +// Test matching of partial specializations. + +template <int* x, int* y> +class EQUAL { +public: + enum { value = 0 }; +}; +template <int* x> +class EQUAL<x,x> { +public: + enum { value = 1 }; +}; + +int x; +int y; + +int equals_x_x = EQUAL<&x,&x>::value; // expected value: 1 +int equals_x_y = EQUAL<&x,&y>::value; // expected value: 0 +int equals_y_x = EQUAL<&y,&x>::value; // expected value: 0 +int equals_y_y = EQUAL<&y,&y>::value; // expected value: 1 + +int main () +{ + if (equals_x_x == 1 + && equals_x_y == 0 + && equals_y_x == 0 + && equals_y_y == 1) + return 0; + return 1; +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/template44.C b/gcc/testsuite/g++.old-deja/g++.jason/template44.C new file mode 100644 index 000000000..2aea33a5e --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/template44.C @@ -0,0 +1,62 @@ +// { dg-do run } +#include <stdlib.h> +#include <string.h> + +template <class T> +class List { +public: + int len; + T *array; + + int length() const { return( len ); } + + List() : len( 0 ), array( 0 ) {} +}; + +template <class T> +int AlgoStdCompare(const T* a, const T* b) { + if (*a < *b) + return -1; + else + return (*a > *b); // 0 if equal, 1 if greater +} + +int AlgoStdCompare(const char* const* a, const char * const*b) +{ + return strcmp(*a,*b); +} + +template <class T> +void AlgoFixupSort(List< T >* , int, int ) { +} + +template <class T> +void AlgoSort(int (*compare)(const T *, const T *), + void (*fixup)( List<T> *, int first, int last), + List< T >* theList, int first, int last) { + if (last < 0) + last = theList->length()-1; + + qsort(theList->array+first, last-first+1, sizeof(T), + (int (*)(const void *, const void *))compare); + if (fixup) + fixup(theList, first, last); +} + +template <class T> +void AlgoSort(List< T >* theList, int first = 0, int last = -1) { + int (*compare)(const T*, const T*) = AlgoStdCompare; + void (*fixup)( List<T> *, int first, int last) = AlgoFixupSort; + + AlgoSort(compare, fixup, theList, first, last); +} + +int +main() +{ + List<const char *> slist; + AlgoSort( &slist ); + + List<int> ilist; + AlgoSort( &ilist ); +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/template5.C b/gcc/testsuite/g++.old-deja/g++.jason/template5.C new file mode 100644 index 000000000..8401eafa9 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/template5.C @@ -0,0 +1,28 @@ +// { dg-do assemble } +// Bug: g++ fails to compare integer constants properly. + +template <int X, int Y> +struct Matrix { + int base [X] [Y]; +}; + +template <int M,int H,int N> +Matrix<M,N>& Mul(Matrix<M,N>& Q,Matrix<M,H>& A,Matrix<H,N>& B) { + for(int i=0;i<M;i++) { + for(int j=0;j<N;j++) { + Q.base[i][j]=0; + for(int k=0;k<H;k++) { + Q.base[i][j]+=A.base[i][k]*B.base[k][j]; + } + } + } + return Q; +} + +void f () +{ + Matrix<2, 3> q; + Matrix<2, 4> a; + Matrix<4, 3> b; + q = Mul (q, a, b); +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/template6.C b/gcc/testsuite/g++.old-deja/g++.jason/template6.C new file mode 100644 index 000000000..2aec05c81 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/template6.C @@ -0,0 +1,21 @@ +// { dg-do run } +// PRMS Id: 4656 +// Testcase for use of member pointers in template resolution + +template <class T> class A { + public: + A() : a(1) {} + T a; +}; + +template <class T> +int foo (T A<int>::*p) +{ + return 0; +} +int main() +{ + int A<int>::*pm = &A<int>::a; // { dg-bogus "" } failed temp resolution + foo (pm); + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/template7.C b/gcc/testsuite/g++.old-deja/g++.jason/template7.C new file mode 100644 index 000000000..1b563e619 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/template7.C @@ -0,0 +1,9 @@ +// { dg-do assemble } +// PRMS Id: 4826 + +class A; +template <class T> void f(const T&, const T&); + +void g (const A& a, A& b) { + f (a, b); // { dg-bogus "" } failed unification +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/template8.C b/gcc/testsuite/g++.old-deja/g++.jason/template8.C new file mode 100644 index 000000000..07c46ed0a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/template8.C @@ -0,0 +1,10 @@ +// { dg-do assemble } +// PRMS Id: 4827 + +class A; +template <class T> int f (const T&, const A *); + +int g (const int& a) +{ + return f (a, (A *)0); // { dg-bogus "" } failed unification +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/template9.C b/gcc/testsuite/g++.old-deja/g++.jason/template9.C new file mode 100644 index 000000000..7a12ebf4a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/template9.C @@ -0,0 +1,12 @@ +// { dg-do assemble } +// PRMS Id: 4864 +// Bug: g++ can't deal with a guiding declaration which comes before the +// template. + +void f (const int&, const int&); +template <class T> void f (const T&, const T&) { } + +void g (int a) +{ + f (a,a); // { dg-bogus "" } two identical candidates +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/temporary.C b/gcc/testsuite/g++.old-deja/g++.jason/temporary.C new file mode 100644 index 000000000..097507379 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/temporary.C @@ -0,0 +1,20 @@ +// { dg-do run } +// From: bruno@isoft.com.ar (Bruno R. Depascale) +// Subject: No destructor bug +// Date: Mon, 14 Feb 1994 12:49:45 -0300 (Arg) + +// Bug: temporaries created with constructor notation aren't destroyed. + +int count = 0; + +class A { +public: + A() { ++count; } + ~A() { --count; } +}; + +int main() +{ + A(); + return count; +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/temporary2.C b/gcc/testsuite/g++.old-deja/g++.jason/temporary2.C new file mode 100644 index 000000000..da216ae5c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/temporary2.C @@ -0,0 +1,19 @@ +// { dg-do assemble } +class X // Indentation has been done so to see the similarities. +{ +public: + X() {} // { dg-message "note" } referenced below + X(X& x) {x.i=7;} // { dg-message "note" } Both functions modify the + void bar(X& x) {x.i=7;} // { dg-message "note" } reference parameter x. + int i; +}; + +X foo() { X x; return x; } + +int main() +{ + X x(foo()); // { dg-error "no match" } Compiler doesn't warn about temporary reference. + // { dg-message "candidate" "candidate note" { target *-*-* } 15 } + x.bar(foo()); // { dg-error "no match" } The same mistake is warned about in this case. + // { dg-message "candidate" "candidate note" { target *-*-* } 17 } +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/temporary3.C b/gcc/testsuite/g++.old-deja/g++.jason/temporary3.C new file mode 100644 index 000000000..7d96386b7 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/temporary3.C @@ -0,0 +1,27 @@ +// { dg-do run } +// Bug: the temporary returned from f is elided, causing a to be constructed +// twice but only destroyed once. + +extern "C" int printf (const char *, ...); + +int c,d; + +struct A { + A (int) { c++; } + ~A () { d++; } + A (const A&) { c++; } + int i; +}; + +A f () +{ return 1; } + +int main () +{ + { + A a (1); + a = f (); + } + printf ("%d %d\n", c, d); + return c != d; +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/temporary4.C b/gcc/testsuite/g++.old-deja/g++.jason/temporary4.C new file mode 100644 index 000000000..2c8461221 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/temporary4.C @@ -0,0 +1,32 @@ +// { dg-do run } +// Bug: g++ initializes both B::i and B::j before destroying any temps. + +extern "C" int printf (const char *, ...); + +int c = 0; +int d = 0; +int r = 0; + +struct A { + A() { if (c != d) r = 1; ++c; } + A(const A&); // declare so g++ returns A on the stack + ~A() { ++d; } + operator int () { return 0; } +}; + +A foo () +{ + return A(); +} + +struct B { + int i; + int j; + B(): i(foo()), j(foo()) { } +}; + +int main() +{ + B b; + return r; +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/temporary5.C b/gcc/testsuite/g++.old-deja/g++.jason/temporary5.C new file mode 100644 index 000000000..5faad9f8e --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/temporary5.C @@ -0,0 +1,19 @@ +// PRMS Id: 6604 +// Old bug: Scoped constructor call is not properly recognized as a functional cast +// But after DR 147 A::A() is a constructor call, not a functional cast. + +int c; + +struct A { + A() { ++c; } + ~A() { --c; } + operator int () { return 1; } +}; + +int main () +{ + A a; + a.A::A(); // { dg-error "" } + A::A(); // { dg-message "" } + return c; +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/temporary6.C b/gcc/testsuite/g++.old-deja/g++.jason/temporary6.C new file mode 100644 index 000000000..dc660e8fc --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/temporary6.C @@ -0,0 +1,8 @@ +// { dg-do assemble } +// Bug: the temporary from the default parameter to f2 is reused. + +struct A {}; +int f2 (int i, const A& ar = A()); +void f (int i, int j = f2(1)); +void g () { f (1); } +void h () { f (1); } diff --git a/gcc/testsuite/g++.old-deja/g++.jason/temporary7.C b/gcc/testsuite/g++.old-deja/g++.jason/temporary7.C new file mode 100644 index 000000000..9a1b78956 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/temporary7.C @@ -0,0 +1,36 @@ +// { dg-do run } +// PRMS ID: 7304 + +struct V { + int n; + V() : n(0) { } + V(int x) : n(x) { } +}; + +V baz(const V &x) +{ + return x; +} + +int bar(V v1, V v2, V v3) +{ + return v1.n; +} + +struct A { + A(): n(7) { } + int foo(); + V n; +}; + +int A::foo() +{ + V v1, v2; + return bar(n, baz(v1), v2); +} + +int main() +{ + A a; + return (a.foo() != 7); +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/temporary8.C b/gcc/testsuite/g++.old-deja/g++.jason/temporary8.C new file mode 100644 index 000000000..c24256e6b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/temporary8.C @@ -0,0 +1,26 @@ +// { dg-do run } +// Test for proper handling of temporaries in ?: exprs. + +extern "C" int printf (const char *, ...); +int c = 0, d = 0; + +class A { +public: + A() { ++c; } + A(const A&) { ++c; } + ~A() { ++d; } +}; + +A f (const A& a) +{ + return (c ? A() : A()); +} + +int main() +{ + { + f (c ? A() : A()); + } + printf ("%d %d\n", c, d); + return c != d || c != 2; +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/tempover.C b/gcc/testsuite/g++.old-deja/g++.jason/tempover.C new file mode 100644 index 000000000..5f56e4e88 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/tempover.C @@ -0,0 +1,14 @@ +// { dg-do assemble } +// GROUPS passed templates overloading +#define TEMPL template <class T> + +class B {}; + +TEMPL class A : virtual public B { + public: + A(int); +}; + +TEMPL A<T>::A(int){} + +A<double> a(1); diff --git a/gcc/testsuite/g++.old-deja/g++.jason/tempparse.C b/gcc/testsuite/g++.old-deja/g++.jason/tempparse.C new file mode 100644 index 000000000..1756a0c1c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/tempparse.C @@ -0,0 +1,29 @@ +// { dg-do assemble } +/* + PRMS Id: 3631 + Bug is: g++ mangles template class names in a way that it won't accept, + and then tries to feed them to itself. +*/ + +template<class T> +struct A { + A(); +}; + +template<class T> +struct B : A<T> { + B(); +}; // { dg-bogus "" } B<C<char>> + +template<class T> +struct C { + C(); +}; + +template<class T> +struct D { + D(); + B<C<T> > p_f; +}; + +typedef D<char> Dummy; diff --git a/gcc/testsuite/g++.old-deja/g++.jason/tempsub.C b/gcc/testsuite/g++.old-deja/g++.jason/tempsub.C new file mode 100644 index 000000000..2a68add7c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/tempsub.C @@ -0,0 +1,28 @@ +// { dg-do assemble } +// Distillation of crash1.C problem (PR 3633) + +template<class P> +class A +{ + P p; +}; + +template<class Q> +class B +{ + A<Q> a; // bogus error - temp parm name propagating +}; + +template<class R> +class C +{ + B<R> b; +}; + +template<class S> +class D +{ + S s; +}; + +C< D<int> > c; diff --git a/gcc/testsuite/g++.old-deja/g++.jason/this.C b/gcc/testsuite/g++.old-deja/g++.jason/this.C new file mode 100644 index 000000000..17e897851 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/this.C @@ -0,0 +1,16 @@ +// { dg-do assemble } +// PRMS Id: 5190 +// Bug: g++ fails to build up a const reference to `this'. + +class X +{ +public: + void member (); +}; + +void print (const X* const &); + +void X::member () +{ + print (this); +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/thunk1.C b/gcc/testsuite/g++.old-deja/g++.jason/thunk1.C new file mode 100644 index 000000000..7de3c93e7 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/thunk1.C @@ -0,0 +1,47 @@ +// { dg-do run } +// Test that non-variadic function calls using thunks work right. + +struct A { + void* p; + A (void* q): p (q) { } + A (const A& a): p (a.p) { } +}; + +class CBase { +public: + virtual void BaseFunc(); +}; + +class MMixin { +public: + virtual A MixinFunc(int arg, A arg2) = 0; +}; + +class CExample : public CBase, public MMixin { +public: + A MixinFunc(int arg, A arg2); +}; + +void CBase::BaseFunc() +{ +} + +A CExample::MixinFunc(int arg, A arg2) +{ + if (arg != 1 || arg2.p != 0) + return 0; + return this; +} + +void* test(MMixin& anExample) +{ + return anExample.MixinFunc(1,A(0)).p; +} + +int main () +{ + CExample c; + + if (test(c) != &c) + return 1; +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/thunk2.C b/gcc/testsuite/g++.old-deja/g++.jason/thunk2.C new file mode 100644 index 000000000..88e06d876 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/thunk2.C @@ -0,0 +1,49 @@ +// { dg-do run { target fpic } } +// { dg-options "-fPIC" } +// { dg-skip-if "requires unsupported run-time relocation" { spu-*-* } { "*" } { "" } } +// Test that non-variadic function calls using thunks and PIC work right. + +struct A { + void* p; + A (void* q): p (q) { } + A (const A& a): p (a.p) { } +}; + +class CBase { +public: + virtual void BaseFunc(); +}; + +class MMixin { +public: + virtual A MixinFunc(int arg, A arg2) = 0; +}; + +class CExample : public CBase, public MMixin { +public: + A MixinFunc(int arg, A arg2); +}; + +void CBase::BaseFunc() +{ +} + +A CExample::MixinFunc(int arg, A arg2) +{ + if (arg != 1 || arg2.p != 0) + return 0; + return this; +} + +void* test(MMixin& anExample) +{ + return anExample.MixinFunc(1,A(0)).p; +} + +main () +{ + CExample c; + + if (test(c) != &c) + return 1; +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/thunk3.C b/gcc/testsuite/g++.old-deja/g++.jason/thunk3.C new file mode 100644 index 000000000..f0c1187b0 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/thunk3.C @@ -0,0 +1,59 @@ +// { dg-do run } +// { dg-skip-if "fails with generic thunk support" { rs6000-*-* powerpc-*-eabi v850-*-* sh-*-* sh64-*-* h8*-*-* xtensa*-*-* m32r*-*-* lm32-*-* } { "*" } { "" } } +// Test that variadic function calls using thunks work right. +// Note that this will break on any target that uses the generic thunk +// support, because it doesn't support variadic functions. + + +#include <stdarg.h> + +struct A { + void* p; + A (void* q): p (q) { } + A (const A& a): p (a.p) { } +}; + +class CBase { +public: + virtual void BaseFunc(); +}; + +class MMixin { +public: + virtual A MixinFunc(int arg, ...) = 0; +}; + +class CExample : public CBase, public MMixin { +public: + A MixinFunc(int arg, ...); +}; + +void CBase::BaseFunc() +{ +} + +A CExample::MixinFunc(int arg, ...) +{ + va_list ap; + va_start (ap, arg); + + if (arg != 1 || va_arg (ap, int) != 2 || va_arg (ap, int) != 3 + || va_arg (ap, int) != 4 || va_arg (ap, int) != 5 + || va_arg (ap, int) != 6 || va_arg (ap, int) != 7 + || va_arg (ap, int) != 8 || va_arg (ap, int) != 9) + return 0; + return this; +} + +void* test(MMixin& anExample) +{ + return anExample.MixinFunc(1,2,3,4,5,6,7,8,9).p; +} + +int main () +{ + CExample c; + + if (test(c) != &c) + return 1; +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/tredecl.C b/gcc/testsuite/g++.old-deja/g++.jason/tredecl.C new file mode 100644 index 000000000..df800603f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/tredecl.C @@ -0,0 +1,17 @@ +// { dg-do assemble } +// Bug: Foo<Bar> *p semi-instantiates Foo<Bar> in local scope, so +// when Foo<Bar> f tries to instantiate it later, it only finds the partial +// instantiation from before. +// +// No PR; distilled from James Clark's SGML project. +// + +class Bar { }; + +template<class T> class Foo; + +Foo<Bar> *p; + +template<class T> class Foo { }; + +Foo<Bar> f; // { dg-bogus "" } hosed binding levels diff --git a/gcc/testsuite/g++.old-deja/g++.jason/tredecl2.C b/gcc/testsuite/g++.old-deja/g++.jason/tredecl2.C new file mode 100644 index 000000000..6d354781a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/tredecl2.C @@ -0,0 +1,5 @@ +// { dg-do assemble } +// No bug; making sure my fix for tredecl.C doesn't break other cases + +template<class T> struct Foo { Foo<T> * me() { return this; } }; +Foo<int> i; diff --git a/gcc/testsuite/g++.old-deja/g++.jason/tredecl3.C b/gcc/testsuite/g++.old-deja/g++.jason/tredecl3.C new file mode 100644 index 000000000..35c34d7e8 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/tredecl3.C @@ -0,0 +1,11 @@ +// { dg-do assemble } +// PRMS Id: 4679 +// Bug: redeclaration of templates erases the definition. + +template <class T> class Foo { public: void h(); }; +template <class T> class Foo; + +void g() +{ + Foo<int> f; +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/tredecl4.C b/gcc/testsuite/g++.old-deja/g++.jason/tredecl4.C new file mode 100644 index 000000000..0fa6aef5f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/tredecl4.C @@ -0,0 +1,6 @@ +// { dg-do assemble } +// It is illegal to use the name of a class template for anything else, +// including another class template. + +template <class T> class A { }; // { dg-message "previous" } +template <class U, class V> class A { }; // { dg-error "redeclared" } diff --git a/gcc/testsuite/g++.old-deja/g++.jason/trivial.C b/gcc/testsuite/g++.old-deja/g++.jason/trivial.C new file mode 100644 index 000000000..13ef9dc61 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/trivial.C @@ -0,0 +1,71 @@ +// { dg-do assemble } +// PRMS Id: 3665 + +//------------------------------------------------------------- +// Referential declaration within class +// +// Imbeded below is the invocation of the compiler and the error +// message +// +// This compiles successfully with both the xlC and CFRONT compilers +// This was reviewed with Clem Dickey and we agree that it appears to +// be a Cygnus compiler problem. +//------------------------------------------------------------- +/* +$ make bug.reference.o + /usr/p3/bin/i960-vxworks-g++ `getsrc bug.reference.C` -I. -Iinc1 -Iinc2 + -I/vw5.0.3/h -I/vw5.0.3/h/i960 -I/usr/p3/lib/gcc-lib/i960-vxworks/cygnus-2.3.3 +/include -I/usr/p3/lib/gcc-lib/i960-vxworks/cygnus-2.3.3-930417/include -I/usr/p +3/lib/i960-vxworks/include -I/usr/p3/i960-vxworks/include -c -DCPU_FAMILY=I960 +-DCPU=I960CA -mca -mold-align -g3 -O1 -DASSERT_ON -nostdinc -nostdinc++ -MD +./bug.reference.C: In method `class1::class1 (long unsigned int, long unsigned i +nt **&)': +./bug.reference.C:43: cannot convert type `long unsigned int **' +./bug.reference.C:43: to type `long unsigned int *[]&' +make: 1254-004 The error code from the last command is 1. +*/ + +// typedefs +typedef unsigned long u32; +typedef u32 *ul[16]; + +// class defs +class class1 { + u32 var1; + class1(const class1 &); // Copy constructor + class1& operator=(const class1 &); // operator= member function +public: + class1(u32, ul&); + ul &ulref; + ~class1() {} +}; + + +// member function defs +class1::class1(u32 u, ul &l) : var1(u), ulref(l) +{} + +/* =========================================================================== +Note: The following is a "work around" that allows the successful compilation. + + +// typedefs +typedef unsigned long u32; +typedef u32 *ul[16]; + +// class defs +class class1 { + u32 var1; + class1(const class1 &); // Copy constructor + class1& operator=(const class1 &); // operator= member function +public: + class1(u32, ul*); + ul &ulref; + ~class1() {} +}; + + +// member function defs +class1::class1(u32 u, ul *l) : var1(u), ulref(*l) +{} +============================================================================*/ diff --git a/gcc/testsuite/g++.old-deja/g++.jason/typeck.C b/gcc/testsuite/g++.old-deja/g++.jason/typeck.C new file mode 100644 index 000000000..fc5134cb1 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/typeck.C @@ -0,0 +1,19 @@ +// { dg-do assemble } +// Bug: g++ fails to catch incompatibilities in the parameter lists when +// assigning. + +typedef struct S *type_p; +typedef struct S const *ctype_p; + +typedef ctype_p (*PF) (int); + +type_p callee (type_p arg) { return 0; } + +void foobar () +{ + static PF p = callee; // { dg-error "" } + + p = callee; // { dg-error "" } +} + +PF pp = callee; // { dg-error "" } diff --git a/gcc/testsuite/g++.old-deja/g++.jason/typedef.C b/gcc/testsuite/g++.old-deja/g++.jason/typedef.C new file mode 100644 index 000000000..9cbba5bce --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/typedef.C @@ -0,0 +1,10 @@ +// { dg-do assemble } +// PRMS Id: 4687 +// Bug: g++ misinterprets typedefs of function type in class scope. + +typedef int (*F1) (); +struct A { + typedef int F(); + F *fp; + F1 g() { return fp; } // { dg-bogus "" } typing +}; diff --git a/gcc/testsuite/g++.old-deja/g++.jason/typedef2.C b/gcc/testsuite/g++.old-deja/g++.jason/typedef2.C new file mode 100644 index 000000000..63c19bd16 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/typedef2.C @@ -0,0 +1,13 @@ +// { dg-do run } +// PRMS Id: 5367 +// Bug: the nested name of C::func gets hosed. + +struct C { + typedef int func(int *, int *); +}; + +int +main() +{ + C::func *handler; +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/typedef3.C b/gcc/testsuite/g++.old-deja/g++.jason/typedef3.C new file mode 100644 index 000000000..e9186103e --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/typedef3.C @@ -0,0 +1,8 @@ +// { dg-do assemble } +// Test that inheriting from a type typedefed to itself works. + +typedef struct class1 { + class1& operator=(const class1&); +} class1; + +class class2 : public class1 { }; diff --git a/gcc/testsuite/g++.old-deja/g++.jason/typeid1.C b/gcc/testsuite/g++.old-deja/g++.jason/typeid1.C new file mode 100644 index 000000000..ec5156e0c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/typeid1.C @@ -0,0 +1,12 @@ +// { dg-do compile } +#include <typeinfo> +#include <iostream> + +struct foo { double f(int); }; + +int main() { + double f (int); + const std::type_info &r = typeid (f); + std::cout << typeid(f).name() << std::endl; + std::cout << typeid(foo::f).name() << std::endl; /* { dg-error "" } */ +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/typeid2.C b/gcc/testsuite/g++.old-deja/g++.jason/typeid2.C new file mode 100644 index 000000000..7914b677d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/typeid2.C @@ -0,0 +1,31 @@ +// { dg-do run } +// PRMS Id: 11596 + +#include <typeinfo> +extern "C" int printf (const char *, ...); + +class Chicken +{ +public: + int eggs_per_day; +}; + +template <class Bird> +class Flock +{ +public: + Bird * flock_head; + int head_count; + void print_self() { + printf ("A flock of %d %ss\n", head_count, typeid (Bird).name ()); + printf ("A flock of %d %ss\n", head_count, typeid (*flock_head).name ()); + } +}; + +int main() +{ + Flock<Chicken> x; + printf ("%s\n", typeid(x).name()); + x.head_count = 42; + x.print_self(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/union.C b/gcc/testsuite/g++.old-deja/g++.jason/union.C new file mode 100644 index 000000000..21a0b6f7a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/union.C @@ -0,0 +1,11 @@ +// { dg-do assemble } +// Bug: g++ doesn't insert anon union members into class scope. +// Breaks groff. + +struct A { + union { + int i; + }; + + void foo () { i = 1; } // { dg-bogus "" } +}; diff --git a/gcc/testsuite/g++.old-deja/g++.jason/vecdel.C b/gcc/testsuite/g++.old-deja/g++.jason/vecdel.C new file mode 100644 index 000000000..6c6990933 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/vecdel.C @@ -0,0 +1,20 @@ +// { dg-do run } +__SIZE_TYPE__ newsize = 0; +__SIZE_TYPE__ delsize = 0; + +struct A { + int i; + void * operator new [] (__SIZE_TYPE__ i) + { newsize = i; return ::operator new [](i); } + void operator delete [] (void *p, __SIZE_TYPE__ i) + { delsize = i; ::operator delete [](p); } +}; + +int main() +{ + A* ap = new A [2]; + delete [] ap; + if (!newsize || newsize != delsize) + return 1; + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/virtual.C b/gcc/testsuite/g++.old-deja/g++.jason/virtual.C new file mode 100644 index 000000000..34c92d8ba --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/virtual.C @@ -0,0 +1,41 @@ +// { dg-do assemble } +// From: chw@bellcore.com (Charlie Woloszynski,MRE 2J-278,8295228,,27143) +// Newsgroups: gnu.g++.bug +// Subject: gcc-2.5.5 bug in multiple inheritance and pure virtual functions +// Date: 25 Jan 1994 23:41:36 -0500 + +// Bug: g++ fails to notice definitions of abstract virtuals. + +class A +{ +public: + virtual void a1() = 0; + virtual void a2() = 0; +}; + +class B +{ +public: + virtual void b1() = 0; + virtual void b2() = 0; +}; + + +class C: public A, public B +{ +public: + virtual void a2() {} + virtual void b2() {} +}; + +class D : public C +{ +public: + virtual void a1() {} + virtual void b1() {} +}; + +int main() +{ + D d; // { dg-bogus "" } +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/virtual2.C b/gcc/testsuite/g++.old-deja/g++.jason/virtual2.C new file mode 100644 index 000000000..ffdd71c13 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/virtual2.C @@ -0,0 +1,14 @@ +// { dg-do run } +struct A { + virtual A* f () { return this; } +}; + +struct B: public A { + virtual B* f () { return 0; } +}; + +int main () +{ + A* ap = new B; + return (ap->f () != 0); +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/warning1.C b/gcc/testsuite/g++.old-deja/g++.jason/warning1.C new file mode 100644 index 000000000..6fa07ef0c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/warning1.C @@ -0,0 +1,7 @@ +// { dg-do assemble } +// Bug: g++ protests that foo was never defined. + +static void foo (); +static void foo (); +static void foo () { } +void bar () { foo(); } // { dg-bogus "" } diff --git a/gcc/testsuite/g++.old-deja/g++.jason/warning10.C b/gcc/testsuite/g++.old-deja/g++.jason/warning10.C new file mode 100644 index 000000000..d9b8cb9bf --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/warning10.C @@ -0,0 +1,19 @@ +// { dg-do assemble } +// { dg-options "-W -Wall" } +// Don't warn about these comparisons. + +struct A { + unsigned int b : 14; +}; + +int f (int i, unsigned char u, A a, unsigned long ul) +{ + if ((u & 0x10) == 0) + return 1; + if (i == 0U) + return 1; + if (a.b > ul) + return 1; + + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/warning2.C b/gcc/testsuite/g++.old-deja/g++.jason/warning2.C new file mode 100644 index 000000000..6298587e8 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/warning2.C @@ -0,0 +1,14 @@ +// { dg-do assemble } +// g++ ought to warn about casting a base pointer to a derived reference. + +struct A { + virtual void f () = 0; +}; + +struct B: public A { void f () { } }; + +int main() +{ + B* bp; + A& ar = (A&)bp; // { dg-warning "" } +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/warning3.C b/gcc/testsuite/g++.old-deja/g++.jason/warning3.C new file mode 100644 index 000000000..ef4a6eea9 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/warning3.C @@ -0,0 +1,12 @@ +// { dg-do assemble } +// { dg-options "-Wshadow" } +// Bug: overloading of 'A' for template causes bogus shadowing warnings. + +template<class T> +class A +{ + public: + virtual ~A() {} +}; + +template class A<int>; diff --git a/gcc/testsuite/g++.old-deja/g++.jason/warning4.C b/gcc/testsuite/g++.old-deja/g++.jason/warning4.C new file mode 100644 index 000000000..9f50ff2c2 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/warning4.C @@ -0,0 +1,16 @@ +// { dg-do assemble } +// { dg-options "-Woverloaded-virtual" } +// Bug: a virtual function with the same name in an unrelated class will +// cause a bogus overloading warning. + +struct A { + virtual void foo (); +}; + +struct B { + virtual void bar (); +}; + +struct C: public A { + virtual void bar (); +}; diff --git a/gcc/testsuite/g++.old-deja/g++.jason/warning5.C b/gcc/testsuite/g++.old-deja/g++.jason/warning5.C new file mode 100644 index 000000000..006713c03 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/warning5.C @@ -0,0 +1,25 @@ +// { dg-do run } +// { dg-options "-Wall" } +// PRMS Id: 5135 +// Bug: g++ complains that the result of the new expression is not used. + +extern "C" int printf (const char *, ...); +inline void * operator new (__SIZE_TYPE__, void *p) { return p; } + +class foo { +public: + foo() : a(42) {}; + int a; +}; + +int +main() +{ + char buffer[1024]; + + new (buffer) foo; + + foo* pY = (foo *)buffer; + + return pY->a != 42; +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/warning6.C b/gcc/testsuite/g++.old-deja/g++.jason/warning6.C new file mode 100644 index 000000000..08acb7247 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/warning6.C @@ -0,0 +1,7 @@ +// { dg-do assemble } +// { dg-options "-Wunused" } + +struct A { + int i:8; + virtual ~A() {} +}; diff --git a/gcc/testsuite/g++.old-deja/g++.jason/warning7.C b/gcc/testsuite/g++.old-deja/g++.jason/warning7.C new file mode 100644 index 000000000..06eec9b55 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/warning7.C @@ -0,0 +1,6 @@ +// { dg-do assemble } +// { dg-options "-Wunused" } +// PRMS Id: 5481 + +struct A { }; +static A a = A(); diff --git a/gcc/testsuite/g++.old-deja/g++.jason/warning8.C b/gcc/testsuite/g++.old-deja/g++.jason/warning8.C new file mode 100644 index 000000000..b5ff3f3de --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/warning8.C @@ -0,0 +1,17 @@ +// { dg-do assemble } + +struct A { + A(); + ~A(); +}; + +struct B { + B (const A&); + ~B (); +}; + +const B& f () +{ + A a; + return a; // { dg-warning "" } returning reference to temporary +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/warning9.C b/gcc/testsuite/g++.old-deja/g++.jason/warning9.C new file mode 100644 index 000000000..775a37ca3 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/warning9.C @@ -0,0 +1,15 @@ +// { dg-do assemble } +// { dg-options "-Wsynth" } + +struct A { + operator int (); + A& operator= (int); +}; + +int +main() +{ + A a, b; + + a = b; +} diff --git a/gcc/testsuite/g++.old-deja/g++.law/access1.C b/gcc/testsuite/g++.old-deja/g++.law/access1.C new file mode 100644 index 000000000..a38793cd1 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/access1.C @@ -0,0 +1,34 @@ +// { dg-do assemble } +// GROUPS passed access +// access file +// Message-Id: <9211281852.AA24557@cove.cis.ufl.edu> +// From: Robert Forsman <thoth@cove.cis.ufl.edu> +// Subject: method access bug in gcc-2.3.1 on a sparc-sun-sunos4.1.2 +// Date: Sat, 28 Nov 92 13:52:14 EST + +extern "C" { + int atoi(const char*); +} + +struct thingus; + +class foo { +public: + static const foo alpha; + static const foo beta; + +private: + int i; + foo(thingus * s); +public: + foo() {i=0;} +}; + +struct thingus { + int i; +}; + +static thingus blah, blah2; + +const foo foo::alpha(&blah); +const foo foo::beta(&blah2); diff --git a/gcc/testsuite/g++.old-deja/g++.law/access2.C b/gcc/testsuite/g++.old-deja/g++.law/access2.C new file mode 100644 index 000000000..2177748b7 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/access2.C @@ -0,0 +1,20 @@ +// { dg-do assemble } +// GROUPS passed access +// access file +// Message-Id: <9306301534.AA05072@sparc1.cnm.us.es> +// From: juando@cnm.us.es (Juan D. Martin) +// Subject: Compiler lets access to private constructor in template. +// Date: Wed, 30 Jun 93 17:34:10 +0200 + +template <class T> class Foo +{ +private: + friend class Bar; // To avoid warning. + Foo(const T &v) {}; // { dg-error "" } private +}; + + +int main() +{ + Foo<int>(1);// { dg-error "" } +} diff --git a/gcc/testsuite/g++.old-deja/g++.law/access3.C b/gcc/testsuite/g++.old-deja/g++.law/access3.C new file mode 100644 index 000000000..3a6acb922 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/access3.C @@ -0,0 +1,16 @@ +// { dg-do assemble } +// GROUPS passed access +// unsorted.2 file +// Date: Sat, 6 Jun 1992 18:23:03 -0400 +// From: Brendan Kehoe <brendan@cs.widener.edu> +// Message-Id: <199206062223.AA22653@betty.cs.widener.edu> +// Subject: bug with access control to member functions + + class X { + void g (int); // { dg-error "" } is private + public: + void g (double); + }; + + class Y : public X { void f() { g (1); } };// { dg-error "" } + diff --git a/gcc/testsuite/g++.old-deja/g++.law/access4.C b/gcc/testsuite/g++.old-deja/g++.law/access4.C new file mode 100644 index 000000000..174c441d3 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/access4.C @@ -0,0 +1,27 @@ +// { dg-do assemble } +// GROUPS passed access +// (Message bugs/access:3) +// From: jamshid@ses.com (Jamshid Afshar) +// Date: Wed, 2 Mar 94 18:24:22 CST +// Subject: g++ 2.5.5 doesn't warn about inaccessible virtual base ctor +// Message-ID: <9403030024.AA04534@ses.com> + +class ForceLeafSterile { // { dg-error "" } + friend class Sterile; + ForceLeafSterile() {} // { dg-error "" } +}; + +class Sterile : private virtual ForceLeafSterile { +public: + Sterile() {} + Sterile(const char* /*blah*/) {} +}; + +class Illegitimate : public Sterile { +public: + Illegitimate() {} // { dg-error "" } can't access virtual base deflt ctor + Illegitimate(const char* /*blah*/) + : ForceLeafSterile() {} // { dg-error "" } can't access default ctor + Illegitimate(const Illegitimate&) + {} // { dg-error "" } can't access default ctor +}; diff --git a/gcc/testsuite/g++.old-deja/g++.law/access5.C b/gcc/testsuite/g++.old-deja/g++.law/access5.C new file mode 100644 index 000000000..80f848c1d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/access5.C @@ -0,0 +1,24 @@ +// { dg-do assemble } +// GROUPS passed access +// access file +// From: Jeffrey C. Gealow <jgealow@mtl.mit.edu> +// Date: Thu, 18 Feb 93 10:22:23 -0500 +// Subject: nested class access control bug +// Message-ID: <9302181522.AA29209@mtl.mit.edu> + + +class enclose { +public: + class nested_public { int x; }; +protected: + class nested_protected { int x; }; +private: + class nested_private { int x; }; // { dg-error "" } private +}; + +class derived : public enclose { + nested_public obj1; // ok + nested_protected obj2; // ok + nested_private obj3; // error// { dg-error "" } in this context +}; + diff --git a/gcc/testsuite/g++.old-deja/g++.law/arg1.C b/gcc/testsuite/g++.old-deja/g++.law/arg1.C new file mode 100644 index 000000000..3fc42bccc --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/arg1.C @@ -0,0 +1,32 @@ +// { dg-do assemble } +// GROUPS passed arg-matching +// arg-matching file +// Subject: argument matching depending on the def order +// From: kondo@akane.mech.ibaraki.ac.jp +// Date: Fri, 04 Sep 92 17:41:05 JST + +#include <iostream> +// check the order of declarations +class A { +public: + void f(double* p) { std::cout << "A(double*)\n"; } // { dg-message "note" } + void f(int* p) { std::cout << "A(int*)\n"; } // { dg-message "note" } +}; + +class B { +public: + void f(int* p) { std::cout << "B(int*)\n"; } // { dg-message "note" } + void f(double* p) { std::cout << "B(double*)\n"; } // { dg-message "note" } +}; + +int main() +{ + A a; + B b; + + a.f(0);// { dg-error "ambiguous" } + // { dg-message "candidate" "candidate note" { target *-*-* } 27 } + b.f(0);// { dg-error "ambiguous" } + // { dg-message "candidate" "candidate note" { target *-*-* } 29 } +} + diff --git a/gcc/testsuite/g++.old-deja/g++.law/arg10.C b/gcc/testsuite/g++.old-deja/g++.law/arg10.C new file mode 100644 index 000000000..f8360be2c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/arg10.C @@ -0,0 +1,20 @@ +// { dg-do assemble } +// GROUPS passed arg-matching +// arg-matching file +// From: Terry Lee <terry@uivlsisd.csl.uiuc.edu> +// Date: Sat, 14 May 1994 02:46:15 -0500 +// Subject: g++ 2.5.8 template<const void*> bug +// Message-ID: <199405140746.AA03993@uivlsisd.csl.uiuc.edu> + +template<class T> +class A { +public: + void func(const T& val) { } +}; + +int main() +{ + A<const void*> a; + int* ptr = 0; + a.func(ptr); +} diff --git a/gcc/testsuite/g++.old-deja/g++.law/arg11.C b/gcc/testsuite/g++.old-deja/g++.law/arg11.C new file mode 100644 index 000000000..fc9357964 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/arg11.C @@ -0,0 +1,23 @@ +// { dg-do assemble } +// GROUPS passed arg-matching +// From: gustavo@cpqd.br (Gustavo Chaves) +// Date: Wed, 25 May 94 09:38:00 EST +// Subject: problem with user defined conversions in initialization +// Message-ID: <9405251238.AA19815@moon.cpqd.br> + +struct String { String(const char*); }; + +struct Ack { Ack(String); }; + +struct S { void method(Ack); }; // { dg-message "S::method|no known conversion" } referenced below + +void function(Ack); + +int +foo(S *o) +{ // Neither call has a usable constructor for conversions of char[5] to Ack. + function("adsf");// { dg-error "could not convert" } + o->method("adsf");// { dg-error "no matching" } + // { dg-message "candidate" "candidate note" { target *-*-* } 20 } + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.law/arg2.C b/gcc/testsuite/g++.old-deja/g++.law/arg2.C new file mode 100644 index 000000000..8c4e443d3 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/arg2.C @@ -0,0 +1,22 @@ +// { dg-do assemble } +// GROUPS passed arg-matching +// arg-matching file +// Message-Id: <199303032114.AA03574@kolvir.Boulder.ParcPlace.COM> +// From: Warner Losh <imp@boulder.parcplace.com> +// Subject: Overloading bug in g++ 2.3.3 (sparc) compiled by GNU C version 2.3.3 +// Date: Wed, 03 Mar 1993 14:14:02 MST + +class c1 { }; + +typedef void (*fnp)(void *); +typedef void (c1::*memfnp)(void *); +extern void fn1( fnp ); +extern void fn1( c1*, memfnp ); + +void f3(void *) { } + +void fn2() +{ + fn1((fnp) &f3); // Everybody likes this + fn1(&f3); // g++ complains here line 13 +} diff --git a/gcc/testsuite/g++.old-deja/g++.law/arg3.C b/gcc/testsuite/g++.old-deja/g++.law/arg3.C new file mode 100644 index 000000000..bbaf47012 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/arg3.C @@ -0,0 +1,22 @@ +// { dg-do assemble } +// GROUPS passed arg-matching +typedef void* Ptr; + + +void func(int, const Ptr& p); + +template <class T> void func(T, const Ptr& p); + + +Ptr& return_ref(); + + +int main() +{ + char* x; + + func(x,return_ref()); // bug: + // call of func(int, const Ptr&) + // instead of func(char*,const Ptr&) + +} diff --git a/gcc/testsuite/g++.old-deja/g++.law/arg4.C b/gcc/testsuite/g++.old-deja/g++.law/arg4.C new file mode 100644 index 000000000..1cd9fd27c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/arg4.C @@ -0,0 +1,20 @@ +// { dg-do assemble } +// GROUPS passed arg-matching +// arg-matching file +// Message-Id: <14t4tyk@rpi.edu> +// From: jorgej@colossus.cs.rpi.edu (Joaquim Jorge) +// Subject: g++ 2.3.3 Doesn't check function types in initializer lists ? +// Date: Tue, 9 Mar 1993 21:39:08 GMT + +typedef void (*FuncPtr)(int a, float b); +class Amazing { int a; int b; int c; }; + +extern void *Wrong1(char *a, int *b); +extern void *Wrong2(Amazing a, int *b); +extern void *Wrong3(char *a, Amazing *b); +extern void Wrong4(char *a, int *b); +extern Amazing Wrong5(char *a, int *b); + +FuncPtr p = &Wrong5;// { dg-error "" } .* +FuncPtr func_ptr_array[] = { &Wrong1, &Wrong2, &Wrong3, &Wrong4, &Wrong5, 0 };// { dg-error "" } .* + diff --git a/gcc/testsuite/g++.old-deja/g++.law/arg5.C b/gcc/testsuite/g++.old-deja/g++.law/arg5.C new file mode 100644 index 000000000..665c5cd4f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/arg5.C @@ -0,0 +1,16 @@ +// { dg-do assemble } +// GROUPS passed arg-matching +extern double pow(double,int*); + +extern "C" { + extern int printf (const char *, ...); + extern double pow(double, double); +} + +int main() +{ + if (pow (2.0, 3.0) != 8.0) + { printf ("FAIL\n"); return 1; } + else + printf ("PASS\n"); +} diff --git a/gcc/testsuite/g++.old-deja/g++.law/arg6.C b/gcc/testsuite/g++.old-deja/g++.law/arg6.C new file mode 100644 index 000000000..c47c4467c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/arg6.C @@ -0,0 +1,15 @@ +// { dg-do assemble } +// GROUPS passed arg-matching +// arg-matching file +// Message-Id: <9305032310.AA03900@malachite.bbn.com> +// From: Dan Franklin <dan@diamond.bbn.com> +// Subject: overloaded function bug +// Date: Mon, 3 May 93 19:10:10 EDT + + + typedef int (*fnp)(int, void*); + void dispatch_insert(int, int, fnp, void* = 0); + void dispatch_insert(int, int, long*, char*); + typedef void (*InsertFunP)(int, int, fnp, void*); + extern void f(InsertFunP); + void g() { f(dispatch_insert); } diff --git a/gcc/testsuite/g++.old-deja/g++.law/arg7.C b/gcc/testsuite/g++.old-deja/g++.law/arg7.C new file mode 100644 index 000000000..a3ccab92b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/arg7.C @@ -0,0 +1,33 @@ +// { dg-do run } +// GROUPS passed arg-matching +// arg-matching file +// Message-Id: <9305041759.AA04913@malachite.bbn.com> +// From: Dan Franklin <dan@diamond.bbn.com> +// Subject: overloaded function resolved incorrectly +// Date: Tue, 4 May 93 13:59:18 EDT + +#include <stdio.h> + +// Given the following overloaded function definitions + +int ovf(unsigned long, short, short) { printf ("PASS\n"); return 0; } +int ovf( int, short, unsigned long) { printf ("FAIL\n"); return 1; } + +// and the call +// +// ovf(unsigned long, unsigned int, unsigned int) +// +// it seems to me (and to cfront) that this should resolve to ovf #1 above, +// but g++ resolves it to ovf #2. Resolving to ovf #1 requires two conversions +// (unsigned int => short) while resolving to ovf #2 takes two conversions +// (unsigned long => int, unsigned int => short) and a promotion +// (unsigned int => unsigned long). + +int main(int, char**) +{ + unsigned long pixmap = 0; + unsigned int x = 0; + unsigned int y = 0; + + return ovf(pixmap, x, y); +} diff --git a/gcc/testsuite/g++.old-deja/g++.law/arg8.C b/gcc/testsuite/g++.old-deja/g++.law/arg8.C new file mode 100644 index 000000000..1aba05fb2 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/arg8.C @@ -0,0 +1,28 @@ +// { dg-do run } +// GROUPS passed arg-matching +// arg-matching file +// Message-Id: <9307081747.AA14030@tnt> +// From: mclaugh@tnt.acsys.com (Mark A. McLaughlin) +// Subject: g++ bug +// Date: Thu, 8 Jul 93 11:47:28 MDT + + +#include <iostream> +#include <cstdio> + +// With this declaration the program will not link. +template <class Type> std::ostream & save(std::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((std::ostream &)std::cout, i) << std::endl; + short int s = 5; + save((std::ostream &)std::cout, s) << std::endl; + std::printf ("PASS\n"); +} // main diff --git a/gcc/testsuite/g++.old-deja/g++.law/arg9.C b/gcc/testsuite/g++.old-deja/g++.law/arg9.C new file mode 100644 index 000000000..ee352fabf --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/arg9.C @@ -0,0 +1,39 @@ +// { dg-do assemble } +// GROUPS passed arg-matching +// arg-matching file +// Message-Id: <199405132049.QAA06835@elan.cs.UMD.EDU> +// Subject: Bug in g++ 2.4.5 and 2.5.8 +// Date: Fri, 13 May 1994 16:49:22 -0400 +// From: Evan Rosser <ejr@cs.umd.edu> + +#include <assert.h> +#include <stdio.h> +#include <stdlib.h> + +class TupleIterator { +public: + TupleIterator(int *tpl); + int& operator*(); + int live() const; +// The compile fails with "no post-increment operator for type" at "TI++" +// below. +// It succeeds with the same declarations if set_position does not take an int. +// This occurs with G++ 2.4.5 and 2.5.8. +// Sun CC works OK with either case. + void operator++(int); + void set_position(int); +private: +}; + +int main() { + +int t[5]; +t[1] = 1; t[2] = 2;t[3] = 3;t[4] = 4; +TupleIterator TI(t); + + while(TI.live()){ + printf("%d", *TI); + TI++; + } +} + diff --git a/gcc/testsuite/g++.old-deja/g++.law/arm1.C b/gcc/testsuite/g++.old-deja/g++.law/arm1.C new file mode 100644 index 000000000..d74110880 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/arm1.C @@ -0,0 +1,21 @@ +// { dg-do assemble } +// GROUPS passed ARM-compliance +// arm file +// Message-Id: <9211191128.AA14718@us-es.sel.de> +// From: dcb@us-es.sel.de +// Subject: ARM p79 trivial bug +// Date: Thu, 19 Nov 92 12:28:24 +0100 + +extern "C" int printf( const char *, ...); + +int main() +{ + int a = 1 ; + int b = 2 ; + int c = 3 ; + + (a = b) = c ; + printf( " %d %d %d\n", a, b, c); + return 0 ; +} + diff --git a/gcc/testsuite/g++.old-deja/g++.law/arm10.C b/gcc/testsuite/g++.old-deja/g++.law/arm10.C new file mode 100644 index 000000000..b3ca567cb --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/arm10.C @@ -0,0 +1,9 @@ +// { dg-do assemble } +// GROUPS passed ARM-compliance +// arm file +// Message-Id: <1oab2hINN7m@gap.caltech.edu> +// From: tll@cco.caltech.edu (Tal Lewis Lancaster) +// Subject: ARM Page 65 +// Date: 18 Mar 1993 17:21:21 GMT + +int(*p)[10]=new int[20][10]; diff --git a/gcc/testsuite/g++.old-deja/g++.law/arm11.C b/gcc/testsuite/g++.old-deja/g++.law/arm11.C new file mode 100644 index 000000000..da26cad40 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/arm11.C @@ -0,0 +1,15 @@ +// { dg-do assemble } +// GROUPS passed ARM-compliance +// arm file +// Message-Id: <9302181055.AA12522@slsvitt> +// From: dcb@us-es.sel.de (David Binderman 3841) +// Subject: Page 81 of the ARM +// Date: Thu, 18 Feb 93 11:55:15 +0100 + + +int main() { + int x[ 10, 11]; // { dg-error "" } .* + + return 0; +} + diff --git a/gcc/testsuite/g++.old-deja/g++.law/arm12.C b/gcc/testsuite/g++.old-deja/g++.law/arm12.C new file mode 100644 index 000000000..c0332d367 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/arm12.C @@ -0,0 +1,49 @@ +// { dg-do assemble } +// GROUPS passed ARM-compliance +// arm file +// From: belley@cae.ca (Benoit Belley 3218) +// Subject: Bad access control with private constructor and derivation +// Date: Fri, 28 May 1993 12:39:57 -0400 (EDT) + +#include <iostream> + +class X +{ +public: + void f(); + +private: + X(); +}; + +class Y : public X +{ +public: + Y(); +}; + +X::X() // { dg-error "is private" } +{ + std::cout << "X::X()" << std::endl; +} + +void X::f() +{ + std::cout << "X::f()" << std::endl; +} + +Y::Y() // { dg-error "within this context" } +{ + std::cout << "Y::Y()" << std::endl; +} + + +int main() +{ + Y y; + y.f(); +} + + + + diff --git a/gcc/testsuite/g++.old-deja/g++.law/arm13.C b/gcc/testsuite/g++.old-deja/g++.law/arm13.C new file mode 100644 index 000000000..f1393c6e3 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/arm13.C @@ -0,0 +1,16 @@ +// { dg-do run } +// GROUPS passed ARM-compliance +#include <stdio.h> +#include <stdlib.h> + +inline void *operator new(size_t, void *place) { return place; } + +int main() +{ + int* p = (int*) malloc(sizeof(int)); + (void) new (p) int(1); + typedef int I; + p->I::~I(); + free(p); + printf ("PASS\n"); +} diff --git a/gcc/testsuite/g++.old-deja/g++.law/arm14.C b/gcc/testsuite/g++.old-deja/g++.law/arm14.C new file mode 100644 index 000000000..9e51f0e3c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/arm14.C @@ -0,0 +1,24 @@ +// { dg-do assemble } +// GROUPS passed ARM-compliance +// unsorted.2 file +// Message-Id: <BpBu19.GrF@math.waterloo.edu> +// Date: Thu, 4 Jun 1992 15:07:56 GMT +// Subject: access control +// From: gjditchf@plg.waterloo.edu (Glen Ditchfield) + + +class X { + private: + enum E1 {a1, b1}; // { dg-error "" } private + public: + enum E2 {a2, b2}; + }; + +void h(X* p) { + X::E2 e2; + int x2 = X::a2; + + X::E1 e1; // { dg-error "" } within this context + int x1 = X::a1; // { dg-error "" } Should be rejected, and is. + } + diff --git a/gcc/testsuite/g++.old-deja/g++.law/arm15.C b/gcc/testsuite/g++.old-deja/g++.law/arm15.C new file mode 100644 index 000000000..11a3036e0 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/arm15.C @@ -0,0 +1,55 @@ +// { dg-do run } +// GROUPS passed ARM-compliance +// arm file +// From: Johan Bengtsson <jbn@lulea.trab.se> +// Date: Thu, 21 Oct 93 16:10:25 +0100 +// Subject: gcc 2.4.5 initializes base classes in mem-initializer order +// Message-ID: <9310211510.AA14943@holden.lulea.trab.se> + +#include <stdio.h> +#include <stdlib.h> + +int state = 0; + +class A { public: + A() { + if (state == 0) + state = 1; + else { + printf ("FAIL\n"); + exit (1); + } + } +}; + +class B { public: + B() { + if (state == 1) + state = 2; + else { + printf ("FAIL\n"); + exit (1); + } + } +}; + +class AB : public A, public B { public: + AB() : B(), A() { + if (state == 2) + state = 3; + else { + printf ("FAIL\n"); + exit (1); + } + } +}; + +int main() +{ + AB ab; + if (state == 3) + printf("PASS\n"); + else + printf("FAIL\n"); + exit (state != 3); +} diff --git a/gcc/testsuite/g++.old-deja/g++.law/arm16.C b/gcc/testsuite/g++.old-deja/g++.law/arm16.C new file mode 100644 index 000000000..f4b546e57 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/arm16.C @@ -0,0 +1,14 @@ +// { dg-do assemble } +// { dg-options "-ansi -Wall -pedantic" } +// GROUPS passed ARM-compliance +// arm file +// From: Olaf.Weber@cwi.nl +// Date: Fri, 2 Dec 1994 09:14:25 +0100 +// Subject: Omitting & when obtaining a pointer to member function. +// Message-ID: <9412020814.AA00604=olaf@havik.cwi.nl> + +struct C { + void foo(); +}; + +void (C::*pfm)() = C::foo;// { dg-error "" } .* diff --git a/gcc/testsuite/g++.old-deja/g++.law/arm2.C b/gcc/testsuite/g++.old-deja/g++.law/arm2.C new file mode 100644 index 000000000..23284b0a6 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/arm2.C @@ -0,0 +1,16 @@ +// { dg-do assemble } +// GROUPS passed ARM-compliance +// arm file +// Message-Id: <199301260140.AA13734@world.std.com> +// From: gparker@world.std.com (Glenn P Parker) +// Subject: gcc bug +// Date: Mon, 25 Jan 1993 20:40:44 -0500 + +int f() { return 1; } + +int main() +{ + int (&fr)() = f; + + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.law/arm3.C b/gcc/testsuite/g++.old-deja/g++.law/arm3.C new file mode 100644 index 000000000..c3f985a52 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/arm3.C @@ -0,0 +1,20 @@ +// { dg-do assemble } +// GROUPS passed ARM-compliance +// arm file +// Message-Id: <199301260139.AA13555@world.std.com> +// From: gparker@world.std.com (Glenn P Parker) +// Subject: gcc bug +// Date: Mon, 25 Jan 1993 20:39:19 -0500 + +class X { + enum S { blue, pink }; + int S; +public: + void f (enum S arg) ; +}; + +void X::f (enum S arg) +{ + S = arg; // g++ gives error on this line. +} + diff --git a/gcc/testsuite/g++.old-deja/g++.law/arm4.C b/gcc/testsuite/g++.old-deja/g++.law/arm4.C new file mode 100644 index 000000000..bbcf7df23 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/arm4.C @@ -0,0 +1,29 @@ +// { dg-do run } +// GROUPS passed ARM-compliance +// arm file +// Message-Id: <199301272139.AA25489@world.std.com> +// From: kol@world.std.com (Nikolay Yatsenko) +// Subject: g++ bug +// Date: Wed, 27 Jan 1993 16:39:10 -0500 + +extern "C" int printf(const char*,...); +int count = 0; + +struct S { + int i; + S(int b) { + i = b; + count++; } +}; + +int main(void) +{ + double a = 2.0; + + S x(int (a)); + if (count > 0) + { printf ("FAIL\n"); return 1; } + else + printf ("PASS\n"); + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.law/arm5.C b/gcc/testsuite/g++.old-deja/g++.law/arm5.C new file mode 100644 index 000000000..8f038d065 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/arm5.C @@ -0,0 +1,25 @@ +// { dg-do run } +// GROUPS passed ARM-compliance +// arm file +// Message-Id: <9212072127.AA24243@us-es.sel.de> +// From: dcb@us-es.sel.de +// Subject: page 78 of the ARM +// Date: Mon, 7 Dec 92 22:27:09 +0100 + +extern "C" int printf( const char *, ...); + +int & max( int & a, int & b) { + return (a < b) ? b : a; +} + +int main( void) { + int a = 1; + int b = 2; + int & c = max( a, b); + + if (&c == &b) + printf( "PASS\n"); + else + { printf( "FAIL\n"); return 1; } + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.law/arm6.C b/gcc/testsuite/g++.old-deja/g++.law/arm6.C new file mode 100644 index 000000000..a057b1898 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/arm6.C @@ -0,0 +1,23 @@ +// { dg-do assemble } +// GROUPS passed ARM-compliance +// arm file +// Message-Id: <9211231051.AA11287@us-es.sel.de> +// From: dcb@us-es.sel.de +// Subject: ARM page 87 +// Date: Mon, 23 Nov 92 11:51:38 +0100 + + +int main() { + int a; + + switch (a) { + case 1: + int v2 = 3;// { dg-error "" } crosses.* + case 2:// { dg-error "" } jump.* + if (v2 == 7) // error not flagged by 2.3.1 + ; + } + + return 0; +} + diff --git a/gcc/testsuite/g++.old-deja/g++.law/arm7.C b/gcc/testsuite/g++.old-deja/g++.law/arm7.C new file mode 100644 index 000000000..bd1607768 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/arm7.C @@ -0,0 +1,41 @@ +// { dg-do run } +// { dg-options "-w" } +// GROUPS passed ARM-compliance +// arm file (also in cvt file) +// Message-Id: <9303061246.AA09402@gjetost.cs.wisc.edu> +// From: solomon@cs.wisc.edu (Marvin Solomon) +// Subject: Incorrect resolution of conversion path +// Date: Sat, 6 Mar 93 06:46:27 -0600 + + +extern "C" int printf (const char *, ...); + +class Base { +public: + int i; + Base(int ii) : i(ii) {} +}; + +class Derived : public Base { +public: + Derived(int ii) : Base(ii) {} + operator Base&(); +}; + +Derived::operator Base&() { + Base *b = new Base(100*i); + return *b; +} + +int f(Base &b) { + if (b.i == 99) + { printf ("PASS\n"); return 0; } + else + { printf ("FAIL\n"); return 1; } +} + +int main() { + Derived d(99); + return f(d); +} + diff --git a/gcc/testsuite/g++.old-deja/g++.law/arm8.C b/gcc/testsuite/g++.old-deja/g++.law/arm8.C new file mode 100644 index 000000000..8b82af951 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/arm8.C @@ -0,0 +1,16 @@ +// { dg-do assemble } +// GROUPS passed ARM-compliance +// arm file +// Message-Id: <9303161105.AA29336@slsvitt> +// From: dcb@us-es.sel.de (David Binderman 3841) +// Subject: Page 141 of the ARM +// Date: Tue, 16 Mar 93 12:05:24 +0100 + +struct K { + void f( int *p = 0); // { dg-error "" } previous specification +}; + +extern int * q; + +void K::f( int *p = q);// { dg-error "" } .* + diff --git a/gcc/testsuite/g++.old-deja/g++.law/arm9.C b/gcc/testsuite/g++.old-deja/g++.law/arm9.C new file mode 100644 index 000000000..979ef8088 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/arm9.C @@ -0,0 +1,39 @@ +// { dg-do assemble } +// GROUPS passed ARM-compliance +#include <iostream> +enum f1 { + F1 +}; + +enum f2 { + F2 +}; + +class A { +public: + void set (f1 f); +}; +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) { std::cout << "called B\n|no known conversion";} // { dg-message "B::set|no known conversion" } + +int main() { + B b; + b.set(F1); // ARM page 309: should call A.set(f1) and that what g++ does,// { dg-error "match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 26 } + // but 13.1 of ARM clearly states that it should call B::set() + // or generate an error because overloading works only for + // functions within the same scope (first page of chapter 13) + // while member of derived and base classes are considered to + // 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/array1.C b/gcc/testsuite/g++.old-deja/g++.law/array1.C new file mode 100644 index 000000000..304035ffc --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/array1.C @@ -0,0 +1,32 @@ +// { dg-do run } +// GROUPS passed arrays +// array file +// Message-Id: <9204120353.AA06266@cs.rice.edu> +// From: dougm@cs.rice.edu (Doug Moore) +// Subject: constructors not called on new'ed array elements +// Date: Sat, 11 Apr 92 22:53:35 CDT + +#include <stdio.h> + +int i = 0; + +class foo +{ +private: + static foo *array; +public: + foo() + { + i++; + } +}; + +foo* foo::array = new foo [5]; + +int main() +{ + if (i != 5) + { printf ("FAIL\n"); return 1; } + else + printf ("PASS\n"); +} diff --git a/gcc/testsuite/g++.old-deja/g++.law/array2.C b/gcc/testsuite/g++.old-deja/g++.law/array2.C new file mode 100644 index 000000000..0dcddb03c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/array2.C @@ -0,0 +1,10 @@ +// { dg-do assemble } +// GROUPS passed arrays +// array file +// Message-Id: <"nac.no.188:05.10.92.14.37.45"@nac.no> +// From: frode@auticon.no +// Subject: prototype bug ? +// Date: Thu, 5 Nov 92 15:37:34 PST + + extern unsigned char * (*trt_def(int))[][2]; + extern unsigned char * (trt_rplst(unsigned char *(*)[][2])); // { dg-error "" } diff --git a/gcc/testsuite/g++.old-deja/g++.law/bad-error1.C b/gcc/testsuite/g++.old-deja/g++.law/bad-error1.C new file mode 100644 index 000000000..40ee169ed --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/bad-error1.C @@ -0,0 +1,14 @@ +// { dg-do assemble } +// GROUPS passed bad-errors +// bad-error file +// Message-Id: <9301081103.AA29469@jclark.com> +// From: jjc@jclark.com (James Clark) +// Subject: initializer for static class member array +// Date: Fri, 8 Jan 93 11:03:05 GMT + +struct A { + static int v[]; +}; + +int A::v[1] = { 1 }; + diff --git a/gcc/testsuite/g++.old-deja/g++.law/bad-error3.C b/gcc/testsuite/g++.old-deja/g++.law/bad-error3.C new file mode 100644 index 000000000..d653ec54d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/bad-error3.C @@ -0,0 +1,21 @@ +// { dg-do assemble } +// GROUPS passed bad-errors +// bad-error file +// Date: Sun, 31 Jul 1994 11:37:43 +1000 (EST) +// From: Rohan LENARD <rjl@iassf.easams.com.au> +// Subject: g++-2.6.0 gives wrong warning for placement syntax new +// Message-Id: <0iCk1b0000000z0VY0@iassf.easams.com.au> + + +#include <stddef.h> + +void * operator new(size_t, int *); +void * operator new(size_t, void *); + +int *x = 0; +int foo(){ +new (x) int *; +new (&x) int *; +new (x) int *; // This is identical to line 8 !!! +return 1; +} diff --git a/gcc/testsuite/g++.old-deja/g++.law/bad-error4.C b/gcc/testsuite/g++.old-deja/g++.law/bad-error4.C new file mode 100644 index 000000000..74626f713 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/bad-error4.C @@ -0,0 +1,14 @@ +// { dg-do assemble } +// GROUPS passed bad-errors +#include <stddef.h> + +void * operator new(size_t, int *); +void * operator new(size_t, void *); + +int *x = 0; +int foo(){ +new (x) int *; +new (&x) int *; +new (x) int *; // This is identical to line 8 !!! +return 1; +} diff --git a/gcc/testsuite/g++.old-deja/g++.law/bad-error6.C b/gcc/testsuite/g++.old-deja/g++.law/bad-error6.C new file mode 100644 index 000000000..40e2b99eb --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/bad-error6.C @@ -0,0 +1,26 @@ +// { dg-do assemble } +// GROUPS passed bad-errors +typedef __SIZE_TYPE__ size_t; + +class tt { + public: + tt(int); + + private: + void *operator new(size_t a); // Forbid object creation in heap memory. +}; + +void st(const tt&, int); + +void ff(int i, int j) +{ + if( i > 0 ) { + // This work ok. + tt a_tt(i); + st(a_tt, j); + } + else { + // This triggers an error because of private operator new ????. + st(tt(-i), j); + } +} diff --git a/gcc/testsuite/g++.old-deja/g++.law/bad-error7.C b/gcc/testsuite/g++.old-deja/g++.law/bad-error7.C new file mode 100644 index 000000000..4c07d4315 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/bad-error7.C @@ -0,0 +1,30 @@ +// { dg-do assemble } +// GROUPS passed bad-errors +#include <iostream> + +class ParX + { + public: + ParX() {} + }; + +class X : public ParX + { + public: + void fn2() { std::cout << "hi" << std::endl; } + }; + +int main() + { + X x; + ParX* pParX = &x; + void (ParX::*p)() = (void (ParX::*)()) &X::fn2; // line 19 + + (pParX->*p)(); + } + + + + + + diff --git a/gcc/testsuite/g++.old-deja/g++.law/bit-fields1.C b/gcc/testsuite/g++.old-deja/g++.law/bit-fields1.C new file mode 100644 index 000000000..e101d6aa5 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/bit-fields1.C @@ -0,0 +1,9 @@ +// { dg-do assemble } +// GROUPS passed bit-fields +typedef int A; + +struct B +{ + int A : 2; +} ; + diff --git a/gcc/testsuite/g++.old-deja/g++.law/bit-fields2.C b/gcc/testsuite/g++.old-deja/g++.law/bit-fields2.C new file mode 100644 index 000000000..270fc8aab --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/bit-fields2.C @@ -0,0 +1,43 @@ +// { dg-do run } +// GROUPS passed bit-fields +// bitfield file +// Message-Id: <92Oct29.191913est.62@jarvis.csri.toronto.edu> +// From: mdivax1!robinson@ai.mit.edu (Jim Robinson) +// Subject: gcc 2.2.2 C++ bug in handling :0 bit fields +// Date: Thu, 29 Oct 1992 19:18:28 -0500 +// +// Also applies to: +// bitfield file +// From: Jaimie Wilson/MSL <Jaimie_Wilson@msl.isis.org> +// Date: Fri, 28 Jan 1994 06:11:43 -0500 +// Subject: GCC bug report +// +// This test is only meant for targets where EMPTY_FIELD_BOUNDARY is +// defined to no larger than the size of an unsigned int, or where +// PCC_BITFIELD_TYPE_MATTERS is defined. Add skips below for targets that +// do not have that property. +// { dg-skip-if "" { mmix-knuth-mmixware } { "*" } { "" } } + + +#include <stdio.h> +#include <stddef.h> + +struct foo { + char a; + char b; + unsigned int : 0; /* force word alignment */ + char c; +}; + +int +main(int argc, char **argv) +{ + struct foo bar; + + if (offsetof (struct foo, c) > sizeof (unsigned int)) + { printf ("FAIL\n"); return 1; } + else + printf ("PASS\n"); + return 0; +} + diff --git a/gcc/testsuite/g++.old-deja/g++.law/bit-fields3.C b/gcc/testsuite/g++.old-deja/g++.law/bit-fields3.C new file mode 100644 index 000000000..36d040629 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/bit-fields3.C @@ -0,0 +1,7 @@ +// { dg-do assemble } +// GROUPS passed bit-fields + class t { + short :(sizeof(short)-2); + public: + t(); + }; diff --git a/gcc/testsuite/g++.old-deja/g++.law/builtin1.C b/gcc/testsuite/g++.old-deja/g++.law/builtin1.C new file mode 100644 index 000000000..67b71a836 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/builtin1.C @@ -0,0 +1,17 @@ +// { dg-do run } +// { dg-options "" } +// GROUPS passed builtins +// Apparently not in g++ bug snapshot (was originally sent to bug-gcc) +// Message-Id: <m0p74Fh-0002fCC@neal.ctd.comsat.com> +// Date: Tue, 7 Dec 93 10:23 EST +// From: neal@ctd.comsat.com (Neal Becker) +// Subject: builtin_alloca on hpux (gcc-2.5.6) +// We have to avoid using -ansi, which results in a call to alloca instead of +// the use of __builtin_alloca, and thus ends up being unresolved. + +extern "C" int printf (const char *, ...); + +void* junk() { + return __builtin_alloca(10); +} +main() { printf ("PASS\n");} diff --git a/gcc/testsuite/g++.old-deja/g++.law/casts1.C b/gcc/testsuite/g++.old-deja/g++.law/casts1.C new file mode 100644 index 000000000..8ffc0c26d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/casts1.C @@ -0,0 +1,13 @@ +// { dg-do assemble } +// GROUPS passed casts +// casts file +// From: dcb@us-es.sel.de (David Binderman 3841) +// Date: Thu, 18 Feb 93 14:42:48 +0100 +// Subject: Page 67 of the ARM +// Message-ID: <9302181342.AA14050@slsvitt> + +int main() { + (struct T { int b; } *) 0; // { dg-error "" } + + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.law/casts2.C b/gcc/testsuite/g++.old-deja/g++.law/casts2.C new file mode 100644 index 000000000..cba10f280 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/casts2.C @@ -0,0 +1,39 @@ +// { dg-do assemble } +// GROUPS passed casts +class VObject; + +typedef int boolean; + +typedef boolean (VObject::*method)(); +typedef boolean (VObject::*method0)(); +typedef boolean (VObject::*method1)(long); + +#define methodOf(o,m) (method)(&o::m) + + +class VObject { + public: + boolean perform(method ); + boolean perform(method , long); + void affectMethod(method ); + void dummy(){} +}; + + +boolean VObject::perform(method m) +{ + method0 q = (method0)m; + return(this->*q)(); +} + + +boolean VObject::perform(method m, long param) +{ + method1 q = (method1)m; + return(this->*q)(param); + } + +void VObject::affectMethod(method m) +{ + m = methodOf(VObject, dummy); +} diff --git a/gcc/testsuite/g++.old-deja/g++.law/casts3.C b/gcc/testsuite/g++.old-deja/g++.law/casts3.C new file mode 100644 index 000000000..d8ee7daa8 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/casts3.C @@ -0,0 +1,9 @@ +// { dg-do assemble } +// { dg-options "-pedantic-errors" } +// GROUPS passed casts +// casts file +// From: fjh@cs.mu.oz.au +// Message-Id: <9310121939.29641@munta.cs.mu.OZ.AU> +// Subject: should emit diagnostic for `int *p = (void *)0;' +// Date: Wed, 13 Oct 93 5:39:35 EST + int *p = (void *)0;// { dg-error "" } .* diff --git a/gcc/testsuite/g++.old-deja/g++.law/code-gen1.C b/gcc/testsuite/g++.old-deja/g++.law/code-gen1.C new file mode 100644 index 000000000..2c699b451 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/code-gen1.C @@ -0,0 +1,21 @@ +// { dg-do run } +// GROUPS passed code-generation +// code-gen file +// From: Jeffrey C. Gealow <jgealow@mtl.mit.edu> +// Date: Sun, 4 Jul 93 18:57:53 -0400 +// Subject: increment bug (0 + 1 + 1 = 3) +// Message-ID: <9307042257.AA23538@mtl.mit.edu> + +#include <stdio.h> + +int main() +{ + int i = 0; + (++i)++; + if (i == 2) + printf ("PASS\n"); + else + { printf ("FAIL\n"); return 1; } +} + + diff --git a/gcc/testsuite/g++.old-deja/g++.law/code-gen2.C b/gcc/testsuite/g++.old-deja/g++.law/code-gen2.C new file mode 100644 index 000000000..e250cee79 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/code-gen2.C @@ -0,0 +1,35 @@ +// { dg-do run } +// GROUPS passed code-generation +// code-gen file +// From: Gunther Seitz <Gunther.Seitz@regent.e-technik.tu-muenchen.dbp.de> +// Date: Thu, 18 Mar 1993 10:45:29 +0100 +// Message-ID: <93Mar18.104538met.1094@regatta.regent.e-technik.tu-muenchen.de> + + +#include <stdio.h> + +class X { + +public: + double x; + X () { x=3.5; } // Here we go. This assignment fails because + // of X::x being aligned on a doubleword + // boundary, not a quadword one. + }; + + +class A : public virtual X {}; // Only way to produce the +class B : public virtual X {}; // error is to use this +class C : public virtual X {}; // construct of virtual + // base classes. + +class Y : public A, public B, public C {}; + + +int main () +{ + Y y; // To call the constructor + printf ("PASS\n"); + } + + diff --git a/gcc/testsuite/g++.old-deja/g++.law/code-gen4.C b/gcc/testsuite/g++.old-deja/g++.law/code-gen4.C new file mode 100644 index 000000000..362ecc18e --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/code-gen4.C @@ -0,0 +1,31 @@ +// { dg-do run } +// GROUPS passed code-generation +// code-gen file +// From: david.binderman@pmsr.philips.co.uk +// Date: Tue, 17 Aug 93 10:09:38 BST +// Subject: .* broken in 2.4.5 +// Message-ID: <9308170909.AA05509@pmsr.philips.co.uk> + +class A { +public: + char c; +}; + +typedef char A::*PMA; + +PMA pmA = &A::c; + +A oA; + +extern "C" int printf( const char *, ...); + +int main() +{ + oA.c = 'q'; + + if ( (oA .* pmA)) + printf( "PASS\n"); + else + printf(" FAIL\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 new file mode 100644 index 000000000..0a992d0b9 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/code-gen5.C @@ -0,0 +1,287 @@ +// { dg-do run } +// GROUPS passed code-generation +// code-gen file +// From: "David" <norman@pi14.arc.umn.edu> +// Date: Mon, 15 Nov 1993 20:59:14 -0600 (CST) +// Subject: An error! +// Message-ID: <9311160259.AA03353@pi14.arc.umn.edu> + +#include <cstdlib> +#include <cstdio> +#include <cassert> +#include <fstream> +#include <iostream> +#include <cmath> + +#define ANSI_C + +typedef double VEC ; + +class Vector; + +class VectorInt +{ + public: + + /* Nothing public!! Only Vector can use this class */ + + private: + + VectorInt( int ); + VectorInt( int, double *, int = 0 ); + VectorInt( const VectorInt & ); + ~VectorInt(); + + VectorInt *refer(); + void unrefer(); + int count; /* Number of Vector's referring to me */ + + VEC *vec; + + friend class Vector; + friend class VecElem; +}; + +class VecElem +{ + public: + + operator double(); + double operator=( double ); + + private: + + VecElem( Vector &, int ); + VecElem( const VecElem & ); + + Vector &v; + int row; /* Row element refers to */ + + friend class Vector; +}; + +class Vector +{ + public: + + Vector(); // Must be assigned to before used + Vector( VectorInt * ); + Vector( int ); + Vector( int, double *, int beg = 0 ); + Vector( const Vector & ); + Vector &operator=( const Vector & ); + ~Vector() { if(r) r->unrefer(); } + + int row() const { return 19; } + int dim() const { return 10; } + + double operator()( int ) const; + VecElem operator()( int ); + + double assign( int, double ); + + friend std::ostream& operator<<(std::ostream&, const Vector& m ); + + private: + + VectorInt *r; /* Reference to real data */ + + friend class VecElem; + friend class LUDecom; + friend class SVD; +}; + + +Vector:: +Vector() + : r(0) +{} + +Vector:: +Vector( VectorInt *vi ) + : r(vi) +{ + r->refer(); +} + +Vector:: +Vector( int row ) +{ + assert( row > 0 ); + + r = new VectorInt( row ); + + r->refer(); +} + +Vector:: +Vector( int row, double *d, int beg ) +{ + assert( row > 0 ); + + r = new VectorInt( row, d, beg ); + + r->refer(); +} + +Vector:: +Vector( const Vector &A ) + : r( A.r->refer() ) +{} + +Vector& Vector:: +operator=( const Vector &A ) +{ + if( r ) + r->unrefer(); + + r = A.r->refer(); + + return *this; +} + +double Vector:: +operator()( int row ) const +{ + assert(r != 0); + + return *r->vec; +} + +VecElem Vector:: +operator()( int r ) +{ + assert(r != 0); + + return VecElem( *this, r ); +} + + /* assign changes the matrix, it does not create a new one! */ +double Vector:: +assign( int rownum, double d ) +{ + assert(r != 0); + + if( rownum > row() || rownum <= 0 ) { + 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 ) { + /* Don't need to create a new matrix, since we are the only */ + /* one pointing to ours */ + } + else { + VectorInt *vi = new VectorInt( *r ); + r->unrefer(); + r = vi->refer(); + } + + return d; +} + + +VectorInt:: +VectorInt( int sx ) + : vec( new double[sx] ), count(0) +{ } + +VectorInt:: +VectorInt( int sx, double *, int ) + : vec( new double[sx] ), count(0) +{ +} + +VectorInt:: +VectorInt( const VectorInt & ) + : vec( new double[10] ), count(0) +{ +} + +VectorInt * VectorInt:: +refer() +{ + count ++; + return this; + + // cout << "Refering vec" << endl; +} + +void VectorInt:: +unrefer() +{ + count--; + + if( count == 0 ) { + delete this; + } + + // cout << "Unrefering vec" << endl; +} + +VectorInt:: +~VectorInt() +{ + delete vec; + vec = 0; +} + +VecElem:: +VecElem( Vector &vec, int r ) + : v(vec), row(r) +{ + if( r < 1 || r > vec.row() ) { + std::cerr << "Trying to access vector element out of bounds"; + std::cerr << std::endl; + std::abort(); + } +} + +VecElem:: +VecElem( const VecElem &elem ) + : v(elem.v), row(elem.row) +{} + +VecElem:: +operator double() +{ + assert( v.r->vec != 0 ); + return *v.r->vec; +} + +double VecElem:: +operator=( double d ) +{ + return v.assign( row, d ); +} + + + + + +int makeforms( Vector cen, Vector **a, Vector **b ); + +int main() +{ + Vector *a[8], *b[8], disp(3); + Vector cen(3), cen2(3); + int i, j; + + if (makeforms (cen,a,b) != 10) + { std::printf ("FAIL\n"); return 1; } + else + std::printf ("PASS\n"); + + +} + +int +makeforms( Vector cen, Vector **a, Vector **b) +{ + return 10; +} + + + diff --git a/gcc/testsuite/g++.old-deja/g++.law/copy1.C b/gcc/testsuite/g++.old-deja/g++.law/copy1.C new file mode 100644 index 000000000..46e53c785 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/copy1.C @@ -0,0 +1,67 @@ +// { dg-do run } +// GROUPS passed copy-ctors +#include <stdio.h> + +int pass = 0; +class name { + int namestuff; +public: + name() { + namestuff = 111; + } + name(const name& subject); + + name & operator = (const name& right) { + this->namestuff = right.namestuff; + return *this; + } + + ~name() { + ; + } +}; + +name::name(const name& subject) { + pass = 1; +} + +class person { + int personstuff; + name personname; +public: + person() { + ; + personstuff = 222; + } + ~person() { + ; + } + void print() { + ; + } + +}; + +void +test(person argp) +{ + person testp; + + ; + argp.print(); + testp = argp; + argp.print(); + testp.print(); + ; +} + +int main() +{ + person mainp; + test(mainp); + if (pass) + printf ("PASS\n"); + else + { printf ("FAIL\n"); return 1; } +} + diff --git a/gcc/testsuite/g++.old-deja/g++.law/copy2.C b/gcc/testsuite/g++.old-deja/g++.law/copy2.C new file mode 100644 index 000000000..40ed576af --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/copy2.C @@ -0,0 +1,35 @@ +// { dg-do assemble } +// GROUPS passed copy-ctors +// copy file +// From: Vivek Khera <khera@cs.duke.edu> +// Date: Mon, 15 Nov 1993 16:02:18 -0500 +// Subject: g++ 2.5.3 fails to automatically generate default initializer +// Message-ID: <9311152102.AA21248@thneed.cs.duke.edu> + +class String +{ + private: + char a[100]; + int len; + public: + String(); +}; + +String::String() +{ + len = 0; +} + + +struct List +{ + String item[100]; + int num_items; +// List(); // uncomment this line to let compile work +}; + +int +main(int argc, char **argv) +{ + List a; +} diff --git a/gcc/testsuite/g++.old-deja/g++.law/ctors1.C b/gcc/testsuite/g++.old-deja/g++.law/ctors1.C new file mode 100644 index 000000000..85a4be6d0 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/ctors1.C @@ -0,0 +1,20 @@ +// { dg-do assemble } +// GROUPS passed constructors +// ctor file +// From: rac@qedinc.com (Robert Clark) +// Date: Tue, 14 Dec 93 10:45:50 PST +// Subject: bug in g++ 2.5.7 Array of objects +// Message-ID: <9312141845.AA09188@annapurna.qedinc.com> + + +class POOL { +public: + POOL(); +}; + +struct VAL_LIST { + POOL pool[2]; +}; + +VAL_LIST baz; + diff --git a/gcc/testsuite/g++.old-deja/g++.law/ctors10.C b/gcc/testsuite/g++.old-deja/g++.law/ctors10.C new file mode 100644 index 000000000..cbf36cff5 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/ctors10.C @@ -0,0 +1,24 @@ +// { dg-do assemble } +// GROUPS passed constructors +// ctor file +// Message-Id: <9302052351.AA10789@harvey> +// From: greg@qualcomm.com (Greg Noel) +// Subject: bug019.cc +// Date: Fri, 5 Feb 93 15:51:42 -0800 + +#include <iostream> + +class Klasse +{ + class Err : public std::ostream + { + public: + Err(void) : std::ostream(NULL) { } + ~Err(void) { } + }; +public: + //template<class T> Err& operator << (const T x) { return Err() << x; } + Err& operator << (const char *x) { return Err() << x; }// { dg-error "" } .* +private: + char x; +}; diff --git a/gcc/testsuite/g++.old-deja/g++.law/ctors11.C b/gcc/testsuite/g++.old-deja/g++.law/ctors11.C new file mode 100644 index 000000000..c8b59b679 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/ctors11.C @@ -0,0 +1,22 @@ +// { dg-do assemble } +// GROUPS passed constructors +// ctor file +// Message-Id: <9302081631.AA14744@tera.com> +// From: rrh@tera.com (Robert R. Henry) +// Date: Mon, 8 Feb 93 08:31:39 PST +extern "C" int printf (const char *, ...); +class A{ +public: + inline A(int x){printf("constructing A with %d\n", x);} +}; + +class B:public A{ // { dg-message "note" } non-default constructor +private: +public: +}; + +int main() +{ + B(10);// { dg-error "match" } B doesn't have a constructor taking int + // { dg-message "candidate" "candidate note" { target *-*-* } 20 } +} diff --git a/gcc/testsuite/g++.old-deja/g++.law/ctors12.C b/gcc/testsuite/g++.old-deja/g++.law/ctors12.C new file mode 100644 index 000000000..adc5128ea --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/ctors12.C @@ -0,0 +1,34 @@ +// { dg-do run } +// GROUPS passed constructors +#include <cstdio> +#include <cstdlib> +#include <iostream> + +#define MAGIC 7654 + +class complex { + double re; + double im; + int magic; + static int count; +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) {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; + +int main() +{ + complex v[6] = {1, complex(1,2), complex(), 2 }; // ARM Sect. 12.6.1 + int i; // page 289 + + for(i=0; i<6; i++) ; + std::printf ("PASS\n"); + + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.law/ctors13.C b/gcc/testsuite/g++.old-deja/g++.law/ctors13.C new file mode 100644 index 000000000..e092222c2 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/ctors13.C @@ -0,0 +1,18 @@ +// { dg-do assemble } +// GROUPS passed constructors +#include <iostream> + +class A { + A() {} // private constructor// { dg-error "" } .* +}; + +int main() { + A* a = new A();// { dg-error "" } .* + if (a) { + std::cout << "a != NULL\n"; + } else { + std::cout << "a == NULL\n"; + } +} + + diff --git a/gcc/testsuite/g++.old-deja/g++.law/ctors14.C b/gcc/testsuite/g++.old-deja/g++.law/ctors14.C new file mode 100644 index 000000000..544506fc3 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/ctors14.C @@ -0,0 +1,43 @@ +// { dg-do assemble } +// GROUPS passed constructors +// ctor file +// Message-Id: <199301310203.AA22417@oak.ucsc.edu> +// From: "Dean R. E. Long" <dlong@cse.ucsc.edu> +// Subject: problems with default constructors +// Date: Sat, 30 Jan 1993 18:03:32 -0800 + +class A0 { +}; + +class A1 { +public: + A1(void) {} +}; + +class A2 { + A1 a; +}; + +class B0 : public A0 { +public: + B0(void) {} + B0(int) {} + B0(char) : A0() {} + B0(short) : A0() {} +}; + +class B1 : public A1 { +public: +}; + +class B2 : public A2 { +public: + B2(void) : A2() {} + B2(int) : A2() {} +}; + +class C : public B1 { +public: + C(void) : B1() {} + C(int) : B1() {} +}; diff --git a/gcc/testsuite/g++.old-deja/g++.law/ctors15.C b/gcc/testsuite/g++.old-deja/g++.law/ctors15.C new file mode 100644 index 000000000..8e89b30db --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/ctors15.C @@ -0,0 +1,27 @@ +// { dg-do run } +// GROUPS passed constructors +// ctor file +// Message-Id: <9303270404.28207@munta.cs.mu.OZ.AU> +// From: fjh@cs.mu.oz.au +// Subject: bug with new/delete of multidimensional array +// Date: Sat, 27 Mar 93 14:04:52 EST + +#include <stdio.h> +#include <stdlib.h> + +int construct = 0; + +class Element { +public: + Element() { construct++; if (construct > 6) {printf ("FAIL\n"); exit(1);}} + ~Element() { } +}; + +typedef Element array[2]; + +int main() { + array *x; + x = new array[3]; + delete x; + printf ("PASS\n"); +} diff --git a/gcc/testsuite/g++.old-deja/g++.law/ctors16.C b/gcc/testsuite/g++.old-deja/g++.law/ctors16.C new file mode 100644 index 000000000..edb3ebec2 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/ctors16.C @@ -0,0 +1,50 @@ +// { dg-do run } +// GROUPS passed constructors +// ctor file +// Message-Id: <9306021533.AA14347@icepick.jts.com> +// From: roland@jts.com (Roland Knight ) +// Subject: gcc 2.4.1 bug +// Date: Wed, 2 Jun 1993 11:33:34 -0400 + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +char stuff[50]; +char *p = stuff; + +class A { +public: + A() { *p++ = 'A';} +}; + +class B { +public: + B() { *p++ = 'B'; } +}; + +class C : public A, public B { +public: + C() : B(), A() { *p++ = 'C'; } +}; + +class D : public A, public B { +public: + D() : B() { *p++ = 'D'; } +}; + +class E : public A, public B { +public: + E() { *p++ = 'E'; } +}; + + +int main() { + C c; + D d; + E e; + if (strncmp ("ABCABDABE", stuff, 9)) + { printf ("FAIL\n"); return 1; } + else + printf ("PASS\n"); +} diff --git a/gcc/testsuite/g++.old-deja/g++.law/ctors17.C b/gcc/testsuite/g++.old-deja/g++.law/ctors17.C new file mode 100644 index 000000000..071a36008 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/ctors17.C @@ -0,0 +1,24 @@ +// { dg-do assemble } +// GROUPS passed constructors +// ctor file +// Message-Id: <199306151813.gD28471@mail.Germany.EU.net> +// From: stephan@ifconnection.de (Stephan Muehlstrasser) +// Subject: gcc 2.4.3.1: illegal constructor call not rejected +// Date: Tue, 15 Jun 1993 18:34:14 +0200 (MET DST) + +// C++0x mode doesn't print the deleted copy constructor as a candidate. +// { dg-prune-output ":14:" } + +#include <fstream> + +class X : public std::ifstream { + public: + X(int a, const char *b) {} // { dg-message "note" } candidate +}; +int main() +{ + X *y = new X(10, "123"); + // the compiler must reject this constructor call: + X *x = new X("abc");// { dg-error "match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 22 } +} diff --git a/gcc/testsuite/g++.old-deja/g++.law/ctors18.C b/gcc/testsuite/g++.old-deja/g++.law/ctors18.C new file mode 100644 index 000000000..f687e2926 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/ctors18.C @@ -0,0 +1,27 @@ +// { dg-do assemble } +// GROUPS passed constructors +class test1 { +}; + +template<class T> +class GC_PTR { +public: + GC_PTR(T &a) {} +}; + + +void +gotPtrs(GC_PTR<test1> r1) +{ +} + +static void +short_alloc(int n) +{ + test1 here; + GC_PTR<test1> foo = here; // This works fine. + + gotPtrs(here); // Compile error from this + // No constructor named `GC_PTR` in visible scope + // conversion between incompatible aggregate types requested +} diff --git a/gcc/testsuite/g++.old-deja/g++.law/ctors19.C b/gcc/testsuite/g++.old-deja/g++.law/ctors19.C new file mode 100644 index 000000000..9890a59da --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/ctors19.C @@ -0,0 +1,33 @@ +// { dg-do assemble } +// GROUPS passed constructors +// ctor file +// From: mkohtala@vinkku.hut.fi +// Date: Tue, 5 Oct 1993 19:31:16 +0200 +// Message-Id: <199310051731.AA12260@lk-hp-11.hut.fi> +// Subject: Nested class constructor calling bug + +class X +{ + public: + class Y + { + public: + Y(int i) : a(i) {} + int a; + }; + static void f(Y y); +}; + +void X::f(X::Y y) +{ +} + +int +main() +{ + X::Y y = X::Y(1); // Tries to call ctor Y instead of X::Y + X::f(X::Y(2)); // Tries to call Y instead of X::Y + + return 0; +} + diff --git a/gcc/testsuite/g++.old-deja/g++.law/ctors2.C b/gcc/testsuite/g++.old-deja/g++.law/ctors2.C new file mode 100644 index 000000000..21e1b2ad0 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/ctors2.C @@ -0,0 +1,70 @@ +// { dg-do run } +// GROUPS passed constructors +// Message-Id: <m0p8Am6-0002fCC@neal.ctd.comsat.com> +// Date: Fri, 10 Dec 93 11:33 EST +// From: neal@ctd.comsat.com (Neal Becker) +// Subject: serious problems with static constructors + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#define CONST const + +class Sig { + +public: + + enum Type { Byte_t, Word_t, Long_t, Float_t, Double_t, Complex_t, ComplexLong_t, Bad_t }; + +private: + + Type T; + +public: + + static CONST char *ByteMagic, *WordMagic, *LongMagic, + *FloatMagic, *DoubleMagic, *ComplexMagic, *ComplexLongMagic, *BadMagic; + + struct SigTable { + Type T; + CONST char* Magic; + }; + + static CONST SigTable sigTable[]; + +}; + +CONST char +*Sig::ByteMagic = "BYTE", +*Sig::WordMagic = "WORD", +*Sig::LongMagic = "LONG", +*Sig::FloatMagic = "FLOA", +*Sig::DoubleMagic = "DOUB", +*Sig::ComplexMagic = "COMP", +*Sig::ComplexLongMagic = "CMPL", +*Sig::BadMagic = NULL; + + +CONST Sig::SigTable Sig::sigTable[] = { + { Byte_t, ByteMagic }, + { Word_t, WordMagic }, + { Long_t, LongMagic }, + { Float_t, FloatMagic }, + { Double_t, DoubleMagic }, + { Complex_t, ComplexMagic }, + { ComplexLong_t, ComplexLongMagic }, + { Bad_t, BadMagic } +}; + +int main() { + if (strcmp (Sig::sigTable[0].Magic, "BYTE") + || strcmp (Sig::sigTable[1].Magic, "WORD") + || strcmp (Sig::sigTable[2].Magic, "LONG") + || strcmp (Sig::sigTable[3].Magic, "FLOA") + || strcmp (Sig::sigTable[4].Magic, "DOUB") + || strcmp (Sig::sigTable[5].Magic, "COMP")) + { printf ("FAIL\n"); return 1; } + else + printf ("PASS\n"); +} diff --git a/gcc/testsuite/g++.old-deja/g++.law/ctors20.C b/gcc/testsuite/g++.old-deja/g++.law/ctors20.C new file mode 100644 index 000000000..449f10da5 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/ctors20.C @@ -0,0 +1,35 @@ +// { dg-do assemble } +// GROUPS passed constructors +// ctor file +// Message-Id: <9311011758.AA25157@thneed.cs.duke.edu> +// From: Vivek Khera <khera@cs.duke.edu> +// Subject: g++ 2.5.0 fails to automatically generate default initializer +// Date: Mon, 01 Nov 1993 12:58:34 -0500 + +class String +{ + private: + char a[100]; + int len; + public: + String(); +}; + +String::String() +{ + len = 0; +} + + +struct List +{ + String item[100]; + int num_items; +// List(); // uncomment this line to let compile work +}; + +int +main(int argc, char **argv) +{ + List a; +} diff --git a/gcc/testsuite/g++.old-deja/g++.law/ctors21.C b/gcc/testsuite/g++.old-deja/g++.law/ctors21.C new file mode 100644 index 000000000..04cb653b7 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/ctors21.C @@ -0,0 +1,16 @@ +// { dg-do assemble } +// GROUPS passed constructors +// ctor file +// From: mln@tera.com (Mark Niehaus) +// Subject: g++-2.5.2 -- private copy ctor hides public ctor +// Date: Mon, 8 Nov 93 10:14:50 PST + +class A { + A(A&); + public: + A(); +}; + +class B { + A a; +}; diff --git a/gcc/testsuite/g++.old-deja/g++.law/ctors3.C b/gcc/testsuite/g++.old-deja/g++.law/ctors3.C new file mode 100644 index 000000000..523089e73 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/ctors3.C @@ -0,0 +1,29 @@ +// { dg-do assemble } +// GROUPS passed constructors +// ctor file +// Message-Id: <m0oxRi1-0002fPC@nesmith.pactitle.com> +// From: genehi@nesmith.pactitle.com (Gene Hightower) +// Subject: Apparent bug in g++ 2.5.2 +// Date: Wed, 10 Nov 93 18:24 PST + +class One { + public: + One() {} +}; + +template<class T> class Two : public One { +}; + +class Three { +}; + +class Four { + Two<Three> x[1]; +}; + +class Five { + Four y; + + public: + Five() {} +}; diff --git a/gcc/testsuite/g++.old-deja/g++.law/ctors4.C b/gcc/testsuite/g++.old-deja/g++.law/ctors4.C new file mode 100644 index 000000000..25f9c0607 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/ctors4.C @@ -0,0 +1,28 @@ +// { dg-do run } +// { dg-options "-w" } +// GROUPS passed constructors +// ctors file +// Message-Id: <ACHILLES.92Nov25192123@i90s8.ira.uka.de> +// From: Alf-Christian Achilles <achilles@ira.uka.de> +// Subject: g++ 2.3.1 rejects initialization with object of derived class +// Date: 25 Nov 92 19:21:23 + +extern "C" int printf (const char *, ...); + +class A { +public: + virtual void foo() {}; +}; + +class B : public A { +public: + void foo() {}; +}; + +main () +{ + B b; + A a = b; //unjustified error: unexpected argument to constructor `A' + printf ("PASS\n"); +} + diff --git a/gcc/testsuite/g++.old-deja/g++.law/ctors5.C b/gcc/testsuite/g++.old-deja/g++.law/ctors5.C new file mode 100644 index 000000000..1776be949 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/ctors5.C @@ -0,0 +1,37 @@ +// { dg-do assemble } +// { dg-options "-fshow-column" } +// GROUPS passed constructors +// ctors file +// Subject: bug in handling static const object of the enclosing class +// Date: Tue, 1 Sep 92 10:38:44 EDT + +class X // { dg-message "7:X::X|candidate expects" } implicit constructor +{ + private: + int x; + public: + static const X x0; + X( int ); +}; + +class Y // { dg-error "1:new types may not be defined in a return type" "err" } + // { dg-message "1:\\(perhaps a semicolon is missing after the definition of 'Y'\\)" "note" { target *-*-* } 17 } +{ + private: + X xx; + public: + Y(); +} +X::X( int xi ) // { dg-error "14:return type specification for constructor invalid" "err" } +// { dg-message "1:X::X|candidate expects" "match candidate text" { target *-*-* } 25 } +{ + x = xi; +} + +const X X::x0( 0 ); + +Y::Y() // { dg-error "6:no matching function for call to 'X::X\\(\\)'" } +// { dg-message "candidate" "candidate note" { target *-*-* } 33 } +{ + xx = X::x0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.law/ctors6.C b/gcc/testsuite/g++.old-deja/g++.law/ctors6.C new file mode 100644 index 000000000..ee26cb502 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/ctors6.C @@ -0,0 +1,15 @@ +// { dg-do assemble } +// GROUPS passed constructors +#include <complex> + +double foo(std::complex<double> *a) +{ + return 0.0; +} + + +double bar(void) +{ + std::complex<double> v[10]; + return foo(v); +} diff --git a/gcc/testsuite/g++.old-deja/g++.law/ctors7.C b/gcc/testsuite/g++.old-deja/g++.law/ctors7.C new file mode 100644 index 000000000..d2e0ef309 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/ctors7.C @@ -0,0 +1,35 @@ +// { dg-do assemble } +// GROUPS passed constructors +// ctors file +// Message-Id: <3JUL199214462623@envmsa.eas.asu.edu> +// From: peckham@envmsa.eas.asu.edu (Bill) +// Subject: const constructor causes crash +// Date: Fri, 3 Jul 1992 21:46:00 GMT + +class base_t { +public: + virtual const char* name () { return "base_t"; } + + base_t (); + virtual ~base_t (); +}; + +class d1_t : public base_t { +public: + virtual const char* name () { return "d1_t"; } + + // The const keyword on this constructor is an error, but it shouldn't + // cause the compiler to crash. + + d1_t () const;// { dg-error "" } .*const.* + virtual ~d1_t (); +}; + +class d2_t : public base_t { +public: + virtual const char* name () { return "d2_t"; } + + d2_t (int); + virtual ~d2_t (); +}; + diff --git a/gcc/testsuite/g++.old-deja/g++.law/ctors8.C b/gcc/testsuite/g++.old-deja/g++.law/ctors8.C new file mode 100644 index 000000000..0e5fa0a3f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/ctors8.C @@ -0,0 +1,25 @@ +// { dg-do run } +// GROUPS passed constructors +// ctor file +// Message-Id: <199212160609.AA18247@phecda.cs.sfu.ca> +// From: Taj Khattra <khattra@cs.sfu.ca> +// Subject: gcc 2.3.1 global ctor bug ? +// Date: Tue, 15 Dec 92 22:09:37 PST + +#include <stdio.h> + +struct foo { + foo() : index(-1) {} + int index; +}; + +foo *arr = new foo[2]; + +int main() +{ + if (arr[0].index == -1 + && arr[1].index == -1) + printf ("PASS\n"); + else + { printf ("FAIL\n"); return 1; } +} diff --git a/gcc/testsuite/g++.old-deja/g++.law/ctors9.C b/gcc/testsuite/g++.old-deja/g++.law/ctors9.C new file mode 100644 index 000000000..d94495a25 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/ctors9.C @@ -0,0 +1,40 @@ +// { dg-do assemble } +// { dg-options "-pedantic-errors" } +// GROUPS passed constructors +// ctors file +// Message-Id: <9301132030.AA05210@cs.rice.edu> +// From: dougm@cs.rice.edu (Doug Moore) +// Subject: 2.3.3: accepts ctor-less derived class of ctor-ful base class +// Date: Wed, 13 Jan 93 14:30:21 CST +// Note: It gives an error now. But not a very good one. + +struct Foo +{ + Foo(int aa); + int a; + const Foo* operator-> () const {return this;} +}; + +Foo::Foo(int aa) +:a(aa) +{ } + + +struct var_Foo: public Foo // { dg-message "note" } base.*// ERROR - in class.* +{ + var_Foo* operator-> () {return this;} +}; + +int blort(Foo& f) +{ + return f->a; +} + +int main() +{ + var_Foo b(2);// { dg-error "match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 35 } + b->a = 0; + int x = blort(b); + return x; +} diff --git a/gcc/testsuite/g++.old-deja/g++.law/cvt1.C b/gcc/testsuite/g++.old-deja/g++.law/cvt1.C new file mode 100644 index 000000000..e50996e30 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/cvt1.C @@ -0,0 +1,12 @@ +// { dg-do assemble } +// GROUPS passed conversions +// cvt file +// From: dak@pool.informatik.rwth-aachen.de +// Date: Sun, 21 Nov 93 17:40:32 +0100 +// Subject: g++ mixes up array dimensions with new +// Message-ID: <9311211640.AA11787@messua> + +int main() +{ + int (*a)[5] = new int[6][5]; +} diff --git a/gcc/testsuite/g++.old-deja/g++.law/cvt10.C b/gcc/testsuite/g++.old-deja/g++.law/cvt10.C new file mode 100644 index 000000000..0ae9e20b4 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/cvt10.C @@ -0,0 +1,60 @@ +// { dg-do assemble } +// GROUPS passed conversions +// cvt file +// Message-Id: <CC7oHn.B4F@izf.tno.nl> +// From: tom@izfcs.izf.tno.nl (Tom Vijlbrief) +// Subject: g++ 2.4.5 has problems with NON virtual shared base classes +// Date: Mon, 23 Aug 1993 12:10:34 GMT + + +#include <stdio.h> + +#define FAIL + +class Base { +public: + Base() { printf("Base::Base\n"); } + virtual ~Base() { printf("Base::~Base\n"); } + virtual void v() { printf("Base::v\n"); } +}; + +class Base2 { +public: + Base2() { printf("Base2::Base2\n"); } + virtual ~Base2() { printf("Base2::~Base2\n"); } + virtual void v() { printf("Base2::v\n"); } +}; + +class A: public Base { +public: + A() { printf("A::A\n"); } + ~A() { printf("A::~A\n"); } + virtual void va() { printf("A::va\n"); } +}; + +#ifdef FAIL +class B: public Base { +#else +class B: public Base2 { +#endif +public: + B() { printf("B::B\n"); } + ~B() { printf("B::~B\n"); } + virtual void vb() { printf("B::vb\n"); } +}; + +class C: public A, public B { +public: + C() { printf("C::C\n"); } + ~C() { printf("C::~C\n"); } + void va() { printf("C::va\n"); } +}; + + +int main() +{ + C *cp= new C; + cp->va(); + delete cp; +} + diff --git a/gcc/testsuite/g++.old-deja/g++.law/cvt11.C b/gcc/testsuite/g++.old-deja/g++.law/cvt11.C new file mode 100644 index 000000000..53dd1e907 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/cvt11.C @@ -0,0 +1,34 @@ +// { dg-do assemble } +// GROUPS passed conversions +// cvt file +// Date: Tue, 10 Nov 92 11:08:08 PST +// From: rrh@tera.com (Robert R. Henry) +// Message-Id: <9211101908.AA13557@tera.com> +// Subject: type cast of qualified const member breaks g++2.3.1 + +// Ignore extra errors in C++0x mode. +// { dg-prune-output "non-static data member initializers" } +// { dg-prune-output "from this location" } +// { dg-prune-output "uninitialized" } +#include <stdio.h> + +class Thing{ +private: int x; + public: const int N = -1; // { dg-error "" } bad initialization + Thing(int y); +}; + +class Bar{ public: void doit(void); }; + +void Bar::doit(void) +{ + int i, j; + i = Thing::N; + printf("i = %d\n", i); + + j = (int)Thing::N; + printf("i = %d\n", j); +} +Thing::Thing(int y) { x = y; } +int main(){ Bar x; x.doit(); } + diff --git a/gcc/testsuite/g++.old-deja/g++.law/cvt12.C b/gcc/testsuite/g++.old-deja/g++.law/cvt12.C new file mode 100644 index 000000000..d35a996e0 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/cvt12.C @@ -0,0 +1,30 @@ +// { dg-do run } +// GROUPS passed conversions +// cvt file +// Message-Id: <9301071708.AA03432@muresh.et.tudelft.nl> +// From: stravers@muresh.et.tudelft.nl (Paul Stravers) +// Subject: conversion method never called +// Date: Thu, 7 Jan 93 18:08:33 +0100 + +#include <stdio.h> + +class test +{ + double d; + int i; +public: + test(double dd,int ii) {d=dd; i=ii;} // constructor + operator int&() {return i;} // define a conversion from test to int& + int& geti() {return i;} // same thing, but different +}; + +int main() +{ + test t(3.14, 5); // Create an object t of class "test" + int x = (int&)t; // This should call operator int&() but it does not ... + int y = t.geti(); // x and y should both be 5 ... + if (x == 5 && y == 5) + printf ("PASS\n"); + else + { printf ("FAIL\n"); return 1; } +} diff --git a/gcc/testsuite/g++.old-deja/g++.law/cvt13.C b/gcc/testsuite/g++.old-deja/g++.law/cvt13.C new file mode 100644 index 000000000..0dc085ef6 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/cvt13.C @@ -0,0 +1,19 @@ +// { dg-do assemble } +// GROUPS passed conversions +// cvt file +// Message-Id: <ISHAI.93Mar26102509@cs73.technion.ac.il> +// From: ishai@cs.technion.ac.il (& Ben-Aroya) +// Subject: Type conversion problem. +// Date: Fri, 26 Mar 1993 08:25:09 GMT + +typedef int array[10]; + +void f(array &arg) +{ +} + +int main() +{ + array var; + f(var); +} diff --git a/gcc/testsuite/g++.old-deja/g++.law/cvt14.C b/gcc/testsuite/g++.old-deja/g++.law/cvt14.C new file mode 100644 index 000000000..ca9b670b1 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/cvt14.C @@ -0,0 +1,15 @@ +// { dg-do assemble } +// GROUPS passed conversions +// cvt file +// Message-Id: <9303241504.AA25988@spock.orl.mmc.com> +// Subject: internal compiler error +// Date: Wed, 24 Mar 1993 10:04:06 -0500 +// From: "Malcolm C. Strickland" <chucks@orl.mmc.com> + + +int main() + { + double *d; + d = new double(10); + return 1; + } diff --git a/gcc/testsuite/g++.old-deja/g++.law/cvt15.C b/gcc/testsuite/g++.old-deja/g++.law/cvt15.C new file mode 100644 index 000000000..e9ecbfff3 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/cvt15.C @@ -0,0 +1,18 @@ +// { dg-do assemble } +// GROUPS passed conversions +// cvt file +// Message-Id: <9308051530.AA05922@NeoSoft.Com> +// From: daniels@sugar.neosoft.com (Brad Daniels) +// Subject: g++ 2.4.5: Conversion operators to complex types don't work either +// Date: Thu, 5 Aug 93 15:30:04 CDT + +class bar { int x; public: bar() : x(1){} }; + +class foo { + bar a, b; +public: + foo(bar i, bar j) : a(i),b(j) {} + operator const bar() const { return a; } + const bar f() { return *this; } + void g(foo &c) { b = c; } +}; diff --git a/gcc/testsuite/g++.old-deja/g++.law/cvt16.C b/gcc/testsuite/g++.old-deja/g++.law/cvt16.C new file mode 100644 index 000000000..0c821b589 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/cvt16.C @@ -0,0 +1,30 @@ +// { dg-do assemble } +// GROUPS passed conversions +// cvt file +// Message-Id: <9304121647.AA25819@tnt> +// From: mclaugh@tnt.acsys.com (Mark A. McLaughlin) +// Subject: g++ bug +// Date: Mon, 12 Apr 93 10:47:01 MDT + +#include <iostream> + +class B { +}; + +class A : public B { + short s; +public: + A(short _s = 0) { s = _s; } + operator const short &() const { return s; } +}; + + int +main() { + A a(37); + //cout << a << endl; + std::cout << (short)a << std::endl; + + return 0; +} // main + + diff --git a/gcc/testsuite/g++.old-deja/g++.law/cvt17.C b/gcc/testsuite/g++.old-deja/g++.law/cvt17.C new file mode 100644 index 000000000..7567da2eb --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/cvt17.C @@ -0,0 +1,20 @@ +// { dg-do assemble } +// GROUPS passed conversions +// cvt file +// Message-Id: <9305210124.AA02409@kato.cs.brown.edu> +// From: pcm@cs.brown.edu (Peter C. McCluskey) +// Subject: illegal code compiles silently +// Date: Thu, 20 May 93 21:24:22 -0400 + + + +class Point {}; +class Line_Segment{ public: Line_Segment(const Point&){} }; +class Node { public: Point Location(){ Point p; return p; } }; + +int main() +{ + Node** node1; + Line_Segment(node1->Location()); // intended (*node1)// { dg-error "" } .* +} + diff --git a/gcc/testsuite/g++.old-deja/g++.law/cvt18.C b/gcc/testsuite/g++.old-deja/g++.law/cvt18.C new file mode 100644 index 000000000..032399c52 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/cvt18.C @@ -0,0 +1,24 @@ +// { dg-do assemble } +// GROUPS passed conversions +// cvt file +// Message-Id: <9307090042.AA28565@uluru.Stanford.EDU> +// From: interran@uluru.stanford.edu (John Interrante) +// Subject: gcc 2.4.5 on sparc-sun-sunos4.1.2: automatic conversion functions +// Date: Thu, 8 Jul 93 17:42:12 PDT + +class Token { +public: + operator const void*() const; + int operator !=(int code) const; +private: + int code_; +}; + +extern Token next_token(); + +void foo(Token token) { + if (token && token != '{') {} + + const int inside_body = 1; + if (inside_body && (token = next_token())) {} +} diff --git a/gcc/testsuite/g++.old-deja/g++.law/cvt19.C b/gcc/testsuite/g++.old-deja/g++.law/cvt19.C new file mode 100644 index 000000000..d1720ec45 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/cvt19.C @@ -0,0 +1,27 @@ +// { dg-do assemble } +// GROUPS passed conversions +// cvt file +// Message-Id: <1166.9307131600@ace.eng.cam.ac.uk> +// From: ajp@eng.cam.ac.uk +// Date: Tue, 13 Jul 93 17:00:44 BST + + +class B {}; + +class A { + public: + operator const B*() const { + return b; + } + private: + B* b; +}; + + +int main() +{ + A a; + if (a!=0) { + } +} + diff --git a/gcc/testsuite/g++.old-deja/g++.law/cvt2.C b/gcc/testsuite/g++.old-deja/g++.law/cvt2.C new file mode 100644 index 000000000..afe138bd9 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/cvt2.C @@ -0,0 +1,42 @@ +// { dg-do run } +// GROUPS passed conversions +#include <cstdio> +#include <cstdlib> +#include <cstring> +#include <iostream> +#include <fstream> + +class cvec { +public: + ~cvec(){ delete 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; +}; + +cvec +B(const char* a) +{ + return a; +} + +void +A(const char* s) +{ + // s still ok here + std::ifstream inf(s); + if (std::strncmp ("aaa", s, 3)) + { + std::printf ("FAIL\n"); + std::exit (1); + } + else + std::printf ("PASS\n"); +} + +int main() +{ + A(B("aaa")); +} diff --git a/gcc/testsuite/g++.old-deja/g++.law/cvt20.C b/gcc/testsuite/g++.old-deja/g++.law/cvt20.C new file mode 100644 index 000000000..5d699d7f8 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/cvt20.C @@ -0,0 +1,20 @@ +// { dg-do assemble } +// GROUPS passed conversions +// cvt file +// Message-Id: <9307152250.AA24812@volterra> +// From: rst@ai.mit.edu (Robert S. Thau) +// Subject: g++ won't convert char[] to char*& +// Date: Thu, 15 Jul 93 18:50:59 EDT + + +// Compiles fine with Sun CC 2.1 + +void f(char *& x) // { dg-error "passing argument" } +{ + x++; +} + +int main() +{ + f ("foo"); // { dg-error "invalid initialization" } +} diff --git a/gcc/testsuite/g++.old-deja/g++.law/cvt21.C b/gcc/testsuite/g++.old-deja/g++.law/cvt21.C new file mode 100644 index 000000000..65cf5e87a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/cvt21.C @@ -0,0 +1,36 @@ +// { dg-do assemble } +// GROUPS passed conversions +// cvt file +// Message-Id: <9307200528.AA02094@legolas> +// From: Mark Kuzmycz <kuzmycz@deakin.edu.au> +// Subject: int & conversion operator +// Date: Tue, 20 Jul 93 15:28:47 EST + +class Int +{ + public: + Int(void); + Int(int); + Int(const Int&); + + Int* copy(void) const; + + operator int&(); + + Int& operator ++(void); + Int& operator --(void); + + private: + int value; +}; + +int main() +{ + Int data = 2; + Int test; + + test = data * 12; + data += 1; +} + +// UNKNOWN "FAIL" diff --git a/gcc/testsuite/g++.old-deja/g++.law/cvt22.C b/gcc/testsuite/g++.old-deja/g++.law/cvt22.C new file mode 100644 index 000000000..a5ca696ec --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/cvt22.C @@ -0,0 +1,14 @@ +// { dg-do assemble } +// GROUPS passed conversions +// cvt file +// Message-Id: <93Aug2.163542pdt.26892@franklin.parc.xerox.com> +// From: Jesse Hull <jhull@parc.xerox.com> +// Subject: typedef bug +// Date: Mon, 2 Aug 1993 16:35:28 PDT + +typedef int A[10]; + +int main() +{ + int* a1 = new A; +} diff --git a/gcc/testsuite/g++.old-deja/g++.law/cvt23.C b/gcc/testsuite/g++.old-deja/g++.law/cvt23.C new file mode 100644 index 000000000..8fa877abc --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/cvt23.C @@ -0,0 +1,18 @@ +// { dg-do assemble } +// GROUPS passed conversions +// cvt file +// Message-Id: <9308051209.AA15962@NeoSoft.Com> +// From: daniels@sugar.neosoft.com (Brad Daniels) +// Subject: Bug in g++ 2.4.5: Conversion operators to enumerated types don't wor +// Date: Thu, 5 Aug 93 12:09:09 CDT + +enum bar { AAA, BBB }; + +class foo { + bar a, b; +public: + foo(bar i, bar j) : a(i),b(j) {} + operator const bar() const { return a; } + bar f() { return *this; } + void g(foo &c) { b = c; } +}; diff --git a/gcc/testsuite/g++.old-deja/g++.law/cvt3.C b/gcc/testsuite/g++.old-deja/g++.law/cvt3.C new file mode 100644 index 000000000..a020197e2 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/cvt3.C @@ -0,0 +1,16 @@ +// { dg-do assemble } +// GROUPS passed conversions +// cvt file +// Message-Id: <9308122113.AA14119@tnt.acsys.com> +// From: mclaugh@tnt.acsys.com (Mark A. McLaughlin) +// Subject: g++ bug +// Date: Thu, 12 Aug 93 15:13:23 MDT + + +class C { }; + +void f(C) { } + +void g(const C & c) { f(c); } + +void h(const C & c) { f(C(c)); } diff --git a/gcc/testsuite/g++.old-deja/g++.law/cvt4.C b/gcc/testsuite/g++.old-deja/g++.law/cvt4.C new file mode 100644 index 000000000..b66c3d41a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/cvt4.C @@ -0,0 +1,28 @@ +// { dg-do run } +// GROUPS passed conversions +// cvt file +// Message-Id: <9308091213.AA11572@emmy.Mathematik.Uni-Dortmund.DE> +// From: Michael Strauch <strauch@emmy.mathematik.uni-dortmund.de> +// Subject: Bug in GCC 2.4.5 +// Date: Mon, 9 Aug 93 14:13:50 MESZ + +extern "C" int printf (const char *, ...); + +int destruct = 2; + + class Test{ + protected: + long x; + public: + Test(){;} + Test(long l) {x=l;} + ~Test() {if (--destruct == 0) printf ("PASS\n");} + }; + +int main() + { + long i=1; + Test t; + + t=(Test)i; + } diff --git a/gcc/testsuite/g++.old-deja/g++.law/cvt5.C b/gcc/testsuite/g++.old-deja/g++.law/cvt5.C new file mode 100644 index 000000000..8f5decc9b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/cvt5.C @@ -0,0 +1,28 @@ +// { dg-do assemble } +// GROUPS passed conversions +// cvt file +// Message-Id: <1992Jul31.142856.10082@ericsson.se> +// From: jonas@ericsson.se (Jonas Nygren) +// Subject: g++ bug +// Date: Fri, 31 Jul 1992 14:28:56 GMT + +class A {}; +class B : public A {}; + +B b; + +class R{ +public: + R() {} + operator B&() { return b; } +}; + +void f(A&) {} + +int main(){ + R r; + + f(r); // problem to cast to B& and then to A& +} + + diff --git a/gcc/testsuite/g++.old-deja/g++.law/cvt6.C b/gcc/testsuite/g++.old-deja/g++.law/cvt6.C new file mode 100644 index 000000000..0d00b74c9 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/cvt6.C @@ -0,0 +1,28 @@ +// { dg-do assemble } +// GROUPS passed conversions +// cvt file +// Message-Id: <9208261851.AA16997@josquin.media.mit.edu> +// From: bilmes@media.mit.edu +// Subject: gcc (g++) 2.2.2 constructing nested class from external scope +// Date: Wed, 26 Aug 92 14:51:17 -0400 + + +class foo { + + class bar { + int i; + public: + bar(int j) { i = j; } + }; + + bar b; +public: + foo() : b(3) {} + void test(bar lb) { b = lb; } +}; + + +int main() { + foo f; + f.test(34); // line 18 +} diff --git a/gcc/testsuite/g++.old-deja/g++.law/cvt7.C b/gcc/testsuite/g++.old-deja/g++.law/cvt7.C new file mode 100644 index 000000000..e68adf021 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/cvt7.C @@ -0,0 +1,81 @@ +// { dg-do run } +// GROUPS passed conversions +// cvt file +// From: krste@icsi.berkeley.edu (Krste Asanovic) +// Date: Mon, 24 Aug 92 19:05:10 PDT +// Message-Id: <9208250205.AA26351@icsib43.ICSI.Berkeley.EDU> +// Subject: implicit int. convs. from member refs. in switch expressions + +#include <cstdio> + +class A +{ +public: + A(int j) { i = j; } + A(A& a) { i = a.i; } + operator int() { return i; } + + void assign(int v) { i = v; } + int i; +}; + +class B +{ +public: + B(A& inArg) : in(inArg), out(0) {} + + A& in; + A out; + + void run(); +}; + +void +B::run() +{ + // I get a "switch quantity not an integer" error for this statement. + switch (in) + // Replacing above with "switch (int(in))" removes the error. + { + case 0: + out = 1; + break; + default: + out = 0; + break; + } +} + +int main() +{ + A a(1); + + A& ar = a; + + A& ar2 = ar; + + // ....but no errors for this switch statement. + switch (ar2) + { + case 1: + std::printf ("PASS\n"); + break; + default: + { std::printf ("FAIL\n"); return 1; } + } + + B b(a); + a.assign(3); + b.run(); + a.assign(0); + b.run(); + + return 0; +} + + + + + + + diff --git a/gcc/testsuite/g++.old-deja/g++.law/cvt8.C b/gcc/testsuite/g++.old-deja/g++.law/cvt8.C new file mode 100644 index 000000000..5743cba1c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/cvt8.C @@ -0,0 +1,35 @@ +// { dg-do assemble } +// GROUPS passed conversions +// cvt file +// From: solomon@cs.wisc.edu (Marvin Solomon) +// Message-Id: <9209141509.AA23124@gjetost.cs.wisc.edu> +// Subject: g++ 2.2.2 seems to be forgetting a "const" +// Date: Mon, 14 Sep 92 10:09:58 -0500 + +extern "C" int printf (const char *, ...); + +struct A { + int i; +}; + +struct B { + int i; + operator const A&() const; +}; + +B::operator const A&() const { + static A a; + a.i = i; + printf("convert B to A at %x\n", &a); + return a; +} + +void f(A &a) { // { dg-error "" } in passing argument + printf("A at %x is %d\n", &a, a.i); +} + +int main() { + B b; + b.i = 99; + f(b);// { dg-error "" } .* +} diff --git a/gcc/testsuite/g++.old-deja/g++.law/cvt9.C b/gcc/testsuite/g++.old-deja/g++.law/cvt9.C new file mode 100644 index 000000000..48ee20003 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/cvt9.C @@ -0,0 +1,17 @@ +// { dg-do assemble } +// { dg-options "-pedantic-errors" } +// GROUPS passed conversions +// cvt file +// Message-Id: <m0mVSRj-0000cEC@mobius.veritas.com> +// From: joe@veritas.com (Joe Fasano) +// Subject: gcc-2.2.2 bug report +// Date: Thu, 17 Sep 92 13:27 PDT + +typedef int (*widget) (); + +class window { +public: + int Isopen (); +}; + +widget fp = (widget) &window::Isopen; // { dg-error "" } // ERROR - diff --git a/gcc/testsuite/g++.old-deja/g++.law/dossier1.C b/gcc/testsuite/g++.old-deja/g++.law/dossier1.C new file mode 100644 index 000000000..1b1593253 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/dossier1.C @@ -0,0 +1,18 @@ +// { dg-do assemble } +// { dg-options "-frtti" } +// GROUPS passed rtti +// dossier file +// Message-Id: <9212021501.AA02484@olympia.miro.com> +// From: rme@miro.com (Richard M. Emberson) +// Subject: bug +// Date: Wed, 2 Dec 92 07:01:30 PST + +class Vector { + int *p; + int sz; +public: + Vector(int ); + ~Vector(); + + int& operator[](int i); +}; diff --git a/gcc/testsuite/g++.old-deja/g++.law/dtors1.C b/gcc/testsuite/g++.old-deja/g++.law/dtors1.C new file mode 100644 index 000000000..069f1317c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/dtors1.C @@ -0,0 +1,13 @@ +// { dg-do assemble } +// GROUPS passed destructors +// friends file +// From: offline!marc@ai.mit.edu (Marc Duponcheel) (Marc Duponcheel) +// Date: Sat, 6 Feb 93 23:31:22 PST +// Subject: some 2.2.2 bugs +// Message-ID: <9302070731.AA002jw@offline.UUCP> + +void f() +{ + int i; + i.i::~i();// { dg-error "" } .* +} diff --git a/gcc/testsuite/g++.old-deja/g++.law/dtors2.C b/gcc/testsuite/g++.old-deja/g++.law/dtors2.C new file mode 100644 index 000000000..16262842f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/dtors2.C @@ -0,0 +1,41 @@ +// { dg-do run } +// GROUPS passed destructors +#include <stdio.h> + +int destruct = 0; + +class bla { + +public: + + inline bla(const char * jim) { ; } + + inline ~bla() { destruct++; if (destruct == 2) printf ("PASS\n");} +}; + +class ulk { + +public: + + inline ulk() {} + inline ~ulk() {} + + void funk(const bla & bob) { ;} + // ^ interestingly, the code compiles right if + // this & is deleted (and therefore the parameter + // passed as value) +}; + +int main() { + + ulk dumm; + + dumm.funk(bla("laberababa")); // this compiles correctly + + dumm.funk((bla)"laberababa"); // this produces incorrect code - + // the temporary instance of + // the class "bla" is constructed + // but never destructed... + + +} diff --git a/gcc/testsuite/g++.old-deja/g++.law/dtors3.C b/gcc/testsuite/g++.old-deja/g++.law/dtors3.C new file mode 100644 index 000000000..6f18a3e99 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/dtors3.C @@ -0,0 +1,38 @@ +// { dg-do run } +// GROUPS passed destructors +// dtor file +// Message-Id: <9301242117.AA04053@cs.rice.edu> +// From: dougm@cs.rice.edu (Doug Moore) +// Subject: 2.3.3: premature dtor of temp? +// Date: Sun, 24 Jan 93 15:17:07 CST + +#include <stdio.h> +#include <stdlib.h> + +int killed = 0; + +class Foo +{ + int a; +public: + Foo() + :a(0) {;} + ~Foo() { killed++;} + Foo& operator << (int b) + { + a += b; + if (killed) + { + printf ("FAIL\n"); + exit (1); + } + return *this; + } +}; + +int main() +{ + Foo() << 1 << 3 << 5 << 7; + printf ("PASS\n"); +} + diff --git a/gcc/testsuite/g++.old-deja/g++.law/dtors4.C b/gcc/testsuite/g++.old-deja/g++.law/dtors4.C new file mode 100644 index 000000000..5843bfc1a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/dtors4.C @@ -0,0 +1,23 @@ +// { dg-do run } +// GROUPS passed destructors +#include <stdio.h> + +int destruct = 2; + +class a { + public: + char *p; + a(){ ; } + ~a(){ destruct--; if (! destruct) printf ("PASS\n");} +}; + +a test(){ + return a(); +} + +int main(){ + a ai; + + ai = test(); +} + diff --git a/gcc/testsuite/g++.old-deja/g++.law/dtors5.C b/gcc/testsuite/g++.old-deja/g++.law/dtors5.C new file mode 100644 index 000000000..220372ac1 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/dtors5.C @@ -0,0 +1,34 @@ +// { dg-do run } +// GROUPS passed destructors +// dtor file: +// Message-Id: <1992Jun25.181845.18886@leland.Stanford.EDU> +// From: niz@leland.stanford.edu (Jim Nisbet) +// Subject: gcc 2.2.2 -- c++ bug: destructor called twice (example) +// Date: 25 Jun 92 18:18:45 GMT + +#include <stdio.h> + +int things = 0; + +class foo { +public: + foo() { things++; } + foo(const foo&) { things++; } + ~foo() { things--; } + + int i; +}; + +void +sub(foo f) { + ; +} + + +int main() { + sub(foo()); + if (things == 0) + printf ("PASS\n"); + else + { printf ("FAIL\n"); return 1; } +} diff --git a/gcc/testsuite/g++.old-deja/g++.law/enum1.C b/gcc/testsuite/g++.old-deja/g++.law/enum1.C new file mode 100644 index 000000000..7d54c664d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/enum1.C @@ -0,0 +1,14 @@ +// { dg-do assemble } +// GROUPS passed enums +class X { + struct X1; + enum { A= sizeof(X1 *) }; //Causes a problem. + struct X1 { int i; }; + X1 *f(X1 *); +public: + X(void); +}; + +X::X1 *X::f(X1 *x) { + return x; +} diff --git a/gcc/testsuite/g++.old-deja/g++.law/enum2.C b/gcc/testsuite/g++.old-deja/g++.law/enum2.C new file mode 100644 index 000000000..47ad7fb05 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/enum2.C @@ -0,0 +1,27 @@ +// { dg-do assemble } +// { dg-options "-fshort-enums" } +// GROUPS passed enums +// enum file +// From: Jeff Gehlhaar <jbg@qualcomm.com> +// Date: Mon, 4 Jan 1993 09:20:50 -0700 +// Subject: Enum bug, affects library +// Message-ID: <9301041720.AA17340@harvey> + +typedef unsigned long __fmtflags; +class ios { + public: + typedef __fmtflags fmtflags; + enum { skipws=01, left=02, right=04, internal=010, + dec=020, oct=040, hex=0100, + showbase=0200, showpoint=0400, uppercase=01000, showpos=02000, + scientific=04000, fixed=010000, unitbuf=020000, stdio=040000, + dont_close=0x80000000 //Don't delete streambuf on stream destruction + }; + + fmtflags setf (fmtflags, fmtflags); +}; + +// from <iostream.h> +inline ios& dec(ios& i) +{ i.setf(ios::dec, ios::dec|ios::hex|ios::oct); return i; } + diff --git a/gcc/testsuite/g++.old-deja/g++.law/enum3.C b/gcc/testsuite/g++.old-deja/g++.law/enum3.C new file mode 100644 index 000000000..0bf9b168d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/enum3.C @@ -0,0 +1,21 @@ +// { dg-do assemble } +// GROUPS passed enums +// enum file +// From: frode@auticon.no +// Date: Wed, 13 Jan 93 9:24:50 PST +// Subject: enum trouble +// Message-ID: <"nac.no.001:13.00.93.18.40.52"@nac.no> + +typedef enum{on, off} TOGGLE; + +class field { +private: + TOGGLE toggle; +public: + virtual void on(void) { toggle = 3; };// { dg-error "" } .* + virtual void off(void) { toggle = on; };// { dg-error "" } .* +}; + +int main() +{ +} diff --git a/gcc/testsuite/g++.old-deja/g++.law/enum4.C b/gcc/testsuite/g++.old-deja/g++.law/enum4.C new file mode 100644 index 000000000..669506121 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/enum4.C @@ -0,0 +1,30 @@ +// { dg-do assemble } +// GROUPS passed enums +// enum file +// From: dougm@cs.rice.edu (Doug Moore) +// Date: Thu, 18 Mar 93 00:14:57 CST +// Subject: 2.3.3:Inconsistent behavior for enum conversions +// Message-ID: <9303180614.AA12123@cs.rice.edu> + +enum Enum {enumerator1, enumerator2}; + +struct Struct +{ + int i; + int getI(Enum) {return i;} // { dg-message "Struct::getI|no known conversion" } +}; + +int funct (Enum) +{ + return 0; +} + +int main() +{ + Enum e = enumerator1; + Struct s; + int x = funct(e+1);// { dg-error "invalid" } + int y = s.getI(e+1);// { dg-error "match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 27 } + return x+y; +} diff --git a/gcc/testsuite/g++.old-deja/g++.law/enum6.C b/gcc/testsuite/g++.old-deja/g++.law/enum6.C new file mode 100644 index 000000000..c94e49f3d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/enum6.C @@ -0,0 +1,19 @@ +// { dg-do assemble } +// GROUPS passed enums +// enum file +// From: polstra!jdp@uunet.uu.net (John Polstra) +// Date: Mon, 15 Nov 93 12:14 PST +// Subject: GCC 2.5.3 Enum Bitfield Causes Bogus Warning +// Message-ID: <m0ozAJo-0001EgC@seattle.polstra.uucp> + + enum Color { Red, Green, Blue }; + + struct S { + Color c : 8; + } s; + + void foo() + { + s.c = Red; // <== This statement produces the warning message. + } + diff --git a/gcc/testsuite/g++.old-deja/g++.law/enum7.C b/gcc/testsuite/g++.old-deja/g++.law/enum7.C new file mode 100644 index 000000000..1511c79c6 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/enum7.C @@ -0,0 +1,14 @@ +// { dg-do assemble } +// GROUPS passed enums +// friends file +// From: offline!marc@ai.mit.edu (Marc Duponcheel) (Marc Duponcheel) +// Date: Sat, 6 Feb 93 23:31:22 PST +// Subject: some 2.2.2 bugs +// Message-ID: <9302070731.AA002jw@offline.UUCP> + +class X +{ + enum E { A, B }; +static enum E e; +}; +enum X::E X::e = A; diff --git a/gcc/testsuite/g++.old-deja/g++.law/enum9.C b/gcc/testsuite/g++.old-deja/g++.law/enum9.C new file mode 100644 index 000000000..5a74b2f6f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/enum9.C @@ -0,0 +1,27 @@ +// { dg-do run } +// { dg-options "-fshort-enums" } + +// On ARM EABI targets this testcase will cause a warning to be emitted +// whilst EABI attributes are being merged at link time unless +// the --no-enum-size-warning option is passed to the linker. Whilst the +// enum-size attributes should only be emitted if there are values of +// enum type that can escape the compilation unit, gcc cannot currently +// detect this; if this facility is added then this linker option should +// not be needed. arm-*-linux*eabi should be a good approximation to +// those platforms where the EABI supplement defines enum values to be +// 32 bits wide. +// { dg-options "-fshort-enums -Wl,--no-enum-size-warning" { target arm*-*-linux*eabi } } + +// GROUPS passed enums + extern "C" int printf (const char *, ...); + + enum E { A = 0x80000000, B = 0 }; + + main() + { + if (sizeof (E) != 4) + { printf ("FAIL\n"); return 1; } + else + printf ("PASS\n"); + return 0; + } diff --git a/gcc/testsuite/g++.old-deja/g++.law/except1.C b/gcc/testsuite/g++.old-deja/g++.law/except1.C new file mode 100644 index 000000000..9a2123c3e --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/except1.C @@ -0,0 +1,29 @@ +// { dg-do assemble } +// { dg-options "-fexceptions" } +// GROUPS passed exceptions +// except file +// Message-Id: <9207221230.AA08566@life.ai.mit.edu> +// From: EWALLACE@endvmtkl.vnet.ibm.com +// Subject: Bugs +// Date: Wed, 22 Jul 92 08:29:30 EDT + +extern "C" void puts(const char *); + +class foo { +public: + class error {}; + + void cause_error(void) { throw error(); } +}; + +int main(void) +{ + foo f; + try { + f.cause_error(); + } + catch (foo::error) { + puts("Caught it."); + } + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.law/except2.C b/gcc/testsuite/g++.old-deja/g++.law/except2.C new file mode 100644 index 000000000..c16cfb4be --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/except2.C @@ -0,0 +1,13 @@ +// { dg-do assemble } +// { dg-options "-fexceptions -g" } +// GROUPS passed exceptions +// except file +// Message-Id: <9211061330.AA29334@ifad.dk> +// From: erik@ifad.dk (Erik Toubro Nielsen) +// Subject: g++-2.3.1 gets fatal signal with -g and -fhandle-exceptions +// Date: Fri, 6 Nov 92 14:30:33 +0100 + +int main() +{ + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.law/except3.C b/gcc/testsuite/g++.old-deja/g++.law/except3.C new file mode 100644 index 000000000..ec8bb100e --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/except3.C @@ -0,0 +1,50 @@ +// { dg-do assemble } +// { dg-options "-fexceptions" } +// GROUPS passed exceptions +// except file +// Message-Id: <9211301118.AA09810@ss670mp.geco.slb.com> +// From: willoch@ss670mp.oslo.sgp.slb.com (thorbjorn willoch) +// Subject: -fansi-exceptions bug +// Date: Mon, 30 Nov 92 11:18:05 GMT + +extern "C" int printf(const char *, ...); + +class Vector +{ + int* p; + int sz; + public: + Vector(int s) { p = new int[sz=s]; } + ~Vector() {delete [] p; } + int size() {return sz; } + class Range{}; + + + int& operator[](int i); +}; + +int& Vector::operator[](int i) +{ + if(0<=i && i<sz) return p[i]; + throw Range(); +} + +void do_something(Vector& v) +{ + int i = v[v.size()+10]; +} + +main() +{ + Vector v(10); + + try + { + do_something(v); + } + + catch (Vector::Range) + { + printf("Range error exception\n"); + } +} diff --git a/gcc/testsuite/g++.old-deja/g++.law/except4.C b/gcc/testsuite/g++.old-deja/g++.law/except4.C new file mode 100644 index 000000000..95746b10b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/except4.C @@ -0,0 +1,34 @@ +// { dg-do assemble } +// { dg-options "-fexceptions" } +// GROUPS passed exceptions +// except file +// Message-Id: <9307071456.AA05275@davinci.hio.hen.nl> +// From: akkersdi@hio.hen.nl +// Subject: exceptions broken +// Date: Wed, 7 Jul 1993 16:56:52 +0200 (MET DST) + +class ball { +public: int dummy; + ball() : dummy(0) { ; } +}; + +void pitcher() +{ + throw ball(); +} + +void catcher() +{ + try // <=== gcc 2.* fails here + { + pitcher(); + } + catch (ball) { + /* sleepy catcher doing nothing */ ; + } +} + +int main() +{ + catcher(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.law/except5.C b/gcc/testsuite/g++.old-deja/g++.law/except5.C new file mode 100644 index 000000000..a99ad8a48 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/except5.C @@ -0,0 +1,40 @@ +// { dg-do assemble } +// { dg-options "-fexceptions" } +// GROUPS passed exceptions +// except file +// Message-Id: <199311101607.AA11803@hsi86.hsi.com> +// From: Grigory Tsipenyuk <grigory@hsi.com> +// Subject: exception's bug? +// Date: Wed, 10 Nov 1993 11:07:12 -0500 + +#include <iostream> + +class X { + int *a; + int sz; +public: + class range { }; // exception class + X(int s) { a=new int[sz=s]; } + int& operator[](int i); +}; + +int& X::operator[](int i) +{ + if (i < 0 || i >= sz) { + throw range(); + } + return a[i]; +} + +int +main() +{ + X c(10); + try { + for (int i = 0; i < 12; i++) + c[i] = 1; + } catch (X::range) { + std::cerr << "invalid range\n"; + } + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.law/except6.C b/gcc/testsuite/g++.old-deja/g++.law/except6.C new file mode 100644 index 000000000..05f54e60a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/except6.C @@ -0,0 +1,27 @@ +// { dg-do assemble } +// { dg-options "-fexceptions" } +// GROUPS passed exceptions +// except file +// From: GUSTAVO%DRAGON@orion.cpqd.ansp.br +// Date: 15 Dec 1993 09:33:30 +0000 (C) +// Subject: exception handling problem +// Message-ID: <01H6I5GEAF5UPBJ0UV@VENUS.CPQD.ANSP.BR> + +struct Exception + { + int v; + Exception(int i) { v = i; }; + }; + +void inc(int &i) + { + try { + if (i == 0) + throw Exception(i); + else + i++; + } + catch (Exception v) { + i = v.v; + } + } diff --git a/gcc/testsuite/g++.old-deja/g++.law/friend1.C b/gcc/testsuite/g++.old-deja/g++.law/friend1.C new file mode 100644 index 000000000..9cc1d3564 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/friend1.C @@ -0,0 +1,18 @@ +// { dg-do assemble } +// GROUPS passed friends +// friends file +// From: rwave!myersn%rwave.roguewave@cs.orst.edu (Nathan Myers) +// Date: Thu, 17 Dec 92 16:33 PST +// Subject: 2.3.2: friend decl of new confuses constructor +// Message-ID: <m0n2Vec-0000GrC@rwave.roguewave.com> + +#include <stddef.h> +#include <new> +struct Foo { + friend void* operator new(size_t) throw (std::bad_alloc); + friend void operator delete(void*) throw (); + Foo(); + ~Foo(); +}; +Foo::Foo() { } +Foo::~Foo() { } diff --git a/gcc/testsuite/g++.old-deja/g++.law/friend4.C b/gcc/testsuite/g++.old-deja/g++.law/friend4.C new file mode 100644 index 000000000..470e6f6b5 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/friend4.C @@ -0,0 +1,19 @@ +// { dg-do assemble } +// GROUPS passed friends +// friends file +// From: osinski@cs.nyu.edu (Ed Osinski) +// Date: Fri, 05 Jun 92 20:47:37 -0400 +// Subject: parameter name forgotten in certain friends +// Message-ID: <9206060047.AA05594@MURRAY.CS.NYU.EDU> + +class T2; + +class T { + friend void f (int&); +}; + +class T2 { + friend void f (int& i) { // BOGUS - + i = 1; + } +}; diff --git a/gcc/testsuite/g++.old-deja/g++.law/friend5.C b/gcc/testsuite/g++.old-deja/g++.law/friend5.C new file mode 100644 index 000000000..0a55ce4cb --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/friend5.C @@ -0,0 +1,25 @@ +// { dg-do assemble } +// { dg-options "-Wreturn-type" } +// GROUPS passed friends + + extern "C" int good_friend(int); + extern "C" int bad_friend(); + + class assembler { + friend int good_friend(int); + friend int bad_friend(); + void *parts; + }; + + assembler obj; + + int good_friend(int) + { + obj.parts = 0; + } // { dg-warning "non-void" } + + int bad_friend() + { + obj.parts = 0; + } // { dg-warning "non-void" } + diff --git a/gcc/testsuite/g++.old-deja/g++.law/global-init1.C b/gcc/testsuite/g++.old-deja/g++.law/global-init1.C new file mode 100644 index 000000000..ad25edb6b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/global-init1.C @@ -0,0 +1,21 @@ +// { dg-do run } +// GROUPS passed initialization +// global-init file +// Message-Id: <9212021756.AA12639@grumpy.pocs.com> +// From: wp@pocs.com (Wolfgang Polak) +// Subject: Initializers - gcc 2.2.2 (g++), SPARC, SunOS 4.1.1 +// Date: Wed, 2 Dec 92 09:56:01 PST + +#include <stdio.h> +struct S { int a; int c; }; +int i = 3; +S s = {6, i}; +S * the_s () { return &s; } +int main () +{ + S * cls = the_s (); + if (cls->a != 6) + { printf ("FAIL\n"); return 1; } + else + printf ("PASS\n"); +} diff --git a/gcc/testsuite/g++.old-deja/g++.law/incdec1.C b/gcc/testsuite/g++.old-deja/g++.law/incdec1.C new file mode 100644 index 000000000..b1fc4c404 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/incdec1.C @@ -0,0 +1,47 @@ +// { dg-do assemble } +// { dg-options "-w -O3" } +// GROUPS passed incdec +typedef void* Pix; +class ndbArtPtrVec +{ +public: + ndbArtPtrVec (ndbArtPtrVec&); +}; +class intndbArtPtrVecMap +{ +protected: + int count; + ndbArtPtrVec def; + intndbArtPtrVecMap(ndbArtPtrVec& dflt); + virtual ndbArtPtrVec& operator [] (int key) = 0; + virtual void del(int key) = 0; +public: + virtual Pix first() = 0; + virtual void next(Pix& i) = 0; + virtual int& key(Pix i) = 0; + virtual ndbArtPtrVec& contents(Pix i) = 0; +}; +struct intndbArtPtrVecAVLNode +{ + ndbArtPtrVec cont; + intndbArtPtrVecAVLNode(int h, ndbArtPtrVec& c, + intndbArtPtrVecAVLNode* l=0, intndbArtPtrVecAVLNode* r=0); +}; +class intndbArtPtrVecAVLMap : intndbArtPtrVecMap +{ +protected: + intndbArtPtrVecAVLNode* root; +public: + ndbArtPtrVec& operator [] (int key); + intndbArtPtrVecAVLMap(intndbArtPtrVecAVLMap&); +}; +ndbArtPtrVec& intndbArtPtrVecAVLMap::operator [] (int item) +{ + ++count; + root = new intndbArtPtrVecAVLNode(item, def); +} +intndbArtPtrVecAVLMap::intndbArtPtrVecAVLMap(intndbArtPtrVecAVLMap& b) :intndbArtPtrVecMap(b.def) +{ + for (Pix i = b.first(); i != 0; b.next(i)) + (*this)[b.key(i)] = b.contents(i); +} diff --git a/gcc/testsuite/g++.old-deja/g++.law/init1.C b/gcc/testsuite/g++.old-deja/g++.law/init1.C new file mode 100644 index 000000000..1727e387b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/init1.C @@ -0,0 +1,26 @@ +// { dg-do assemble } +// { dg-prune-output "non-static data member initializers" } +// GROUPS passed initialization +class foo { +public: + int data; + foo(int dat) { data = dat; } +}; + +class bar { +public: + foo f[3] = { 1, 2, 3 }; // works: f[0] = 1, f[1] = 2, f[2] = 3 // { dg-error "" } ANSI C++ forbids initialization of member f; +}; + +class bar2 { +public: + foo f[3] = { foo(1), foo(2), foo(3) }; // { dg-error "" } ANSI C++ forbids initialization of member f; + // does not compile -- error: field initializer is not constant +}; + +int main(void) +{ + foo f[3] = { foo(1), foo(2), foo(3) }; + // standard C++ ... and it works too! :) + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.law/init10.C b/gcc/testsuite/g++.old-deja/g++.law/init10.C new file mode 100644 index 000000000..90e3e45d6 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/init10.C @@ -0,0 +1,26 @@ +// { dg-do assemble } +// GROUPS passed initialization +// init file +// From: Ingo Donasch <ingo@specs.de> +// Date: Wed, 16 Jun 93 13:28:55 +01:00 +// Subject: g++-2.4.2 bug report +// Message-ID: <199306161128.AA22079@opamp.specs.de> + +class b; + +class a { +public: + a(const b*); // needs this parameter +}; + +class b { +private: + a three[3]; +public: + b(); +}; + +b::b() : three(this) // { dg-error "array" } +{ +} + diff --git a/gcc/testsuite/g++.old-deja/g++.law/init11.C b/gcc/testsuite/g++.old-deja/g++.law/init11.C new file mode 100644 index 000000000..7ac210f98 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/init11.C @@ -0,0 +1,25 @@ +// { dg-do run } +// GROUPS passed initialization +// init file +// From: hansen@srd.ull.rdc.toshiba.co.jp +// Date: Mon, 13 Dec 93 18:27:51 +0900 +// Subject: g++ Bug +// Message-ID: <9312130927.AA08192@VLCS151.noname> + +#include <stdio.h> + +int X = 7; + +struct foo { + int a,b,c; +}; + +struct foo Ack = {5, X, 3}; + +int main() +{ + if (Ack.a == 5 && Ack.b == 7 && Ack.c == 3) + printf ("PASS\n"); + else + { printf ("FAIL\n"); return 1; } +} diff --git a/gcc/testsuite/g++.old-deja/g++.law/init13.C b/gcc/testsuite/g++.old-deja/g++.law/init13.C new file mode 100644 index 000000000..3a287187a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/init13.C @@ -0,0 +1,20 @@ +// { dg-do run } +// GROUPS passed initialization +// init file +// Message-Id: <9306280834.AA20921@slsvitt.us-es.sel.de> +// From: David Binderman 3841 <dcb@us-es.sel.de> +// Subject: Page 289 of the ARM +// Date: Mon, 28 Jun 93 10:34:37 +0200 + +struct T { + int m; + + T( int g):m(g){} +}; + +// T s1[2][2] = {1,2,3,4}; + +int main() { + T s1[2][2] = {1,2,3,4}; + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.law/init14.C b/gcc/testsuite/g++.old-deja/g++.law/init14.C new file mode 100644 index 000000000..2305fde42 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/init14.C @@ -0,0 +1,27 @@ +// { dg-do run } +// GROUPS passed initialization +// init file +// From: hansen@srd.ull.rdc.toshiba.co.jp +// Message-Id: <9312130927.AA08192@VLCS151.noname> +// Subject: g++ Bug +// Date: Mon, 13 Dec 93 18:27:51 +0900 + +#include <stdio.h> + +int X = 7; + +struct foo { + int a,b,c; +}; + +struct foo Ack = {5, X, 3}; + +int main() +{ + if (Ack.a != 5 + || Ack.b != 7 + || Ack.c != 3) + { printf ("FAIL\n"); return 1; } + else + printf ("PASS\n"); +} diff --git a/gcc/testsuite/g++.old-deja/g++.law/init2.C b/gcc/testsuite/g++.old-deja/g++.law/init2.C new file mode 100644 index 000000000..110959580 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/init2.C @@ -0,0 +1,9 @@ +// { dg-do assemble } +// GROUPS passed initialization +// init file +// From: lupine!segfault!rfg@uunet.UU.NET +// Date: Sun, 27 Sep 92 14:06:22 MDT +// Subject: Bug in g++ (920220) handling reference initializers. +// Message-ID: <15409.717627982@segfault> + +int * const & fiddle = 0; diff --git a/gcc/testsuite/g++.old-deja/g++.law/init3.C b/gcc/testsuite/g++.old-deja/g++.law/init3.C new file mode 100644 index 000000000..92f4ed79d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/init3.C @@ -0,0 +1,12 @@ +// { dg-do assemble } +// GROUPS passed initialization +// init file +// From: thayer@moose.cs.columbia.edu (Charles Thayer) +// Date: Wed, 30 Sep 92 02:38:17 EDT +// Subject: small bug +// Message-ID: <9209300638.AA22334@moose.cs.columbia.edu> + +int main() { +int offset; +char buf[offset]=""; // { dg-error "" } ansi forbids variable arrays +} diff --git a/gcc/testsuite/g++.old-deja/g++.law/init4.C b/gcc/testsuite/g++.old-deja/g++.law/init4.C new file mode 100644 index 000000000..382de3302 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/init4.C @@ -0,0 +1,13 @@ +// { dg-do assemble } +// { dg-options "-pedantic-errors" } +// GROUPS passed initialization +class Time; +class TimeNote; + +class SvTime +{ +public: + static TimeNote *time_events = 0;// { dg-error "" } .* +}; + +SvTime CurrentTime = {0};// { dg-error "" } diff --git a/gcc/testsuite/g++.old-deja/g++.law/init5.C b/gcc/testsuite/g++.old-deja/g++.law/init5.C new file mode 100644 index 000000000..c1d647b1b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/init5.C @@ -0,0 +1,18 @@ +// { dg-do assemble } +// { dg-options "-pedantic-errors" } +// GROUPS passed initialization +// init file +// From: dcb@us-es.sel.de +// Date: Mon, 12 Oct 92 07:51:52 +0100 +// Subject: G++, ARM Page 141 +// Message-ID: <9210120651.AA15257@us-es.sel.de> + +extern int fred( int); + +class X { + public : + void f( int = fred( 0) ) ; // { dg-error "" } previous spec +} ; + +void X::f( int x = fred( 0) ) {// { dg-error "" } .* +} diff --git a/gcc/testsuite/g++.old-deja/g++.law/init6.C b/gcc/testsuite/g++.old-deja/g++.law/init6.C new file mode 100644 index 000000000..861b9252c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/init6.C @@ -0,0 +1,13 @@ +// { dg-do assemble } +// GROUPS passed initialization +class Vector { + double *v; + int size; + +public: + Vector(int n); + ~Vector(); +}; + +exmpl() { Vector x(8)[16]; }// { dg-error "" } .* + diff --git a/gcc/testsuite/g++.old-deja/g++.law/init7.C b/gcc/testsuite/g++.old-deja/g++.law/init7.C new file mode 100644 index 000000000..0b047b85b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/init7.C @@ -0,0 +1,11 @@ +// { dg-do assemble } +// GROUPS passed initialization +class test + { + public: + int x; + int y; + test (int val) { x = val; y = 0;} + }; + +test ar(34)[5];// { dg-error "" } .* diff --git a/gcc/testsuite/g++.old-deja/g++.law/init8.C b/gcc/testsuite/g++.old-deja/g++.law/init8.C new file mode 100644 index 000000000..ba8dde2e8 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/init8.C @@ -0,0 +1,22 @@ +// { dg-do assemble } +// GROUPS passed initialization +// init file +// From: kol@world.std.com (Nikolay Yatsenko) +// Date: Wed, 27 Jan 1993 16:39:13 -0500 +// Subject: g++ bug +// Message-ID: <199301272139.AA25514@world.std.com> + + +const int ic = 1; +void f(int& arg) // { dg-error "passing argument 1" } +{ + if (arg) ; +} +const int& icr = ic; + +int main(void) +{ + f(icr); // { dg-error "invalid initialization" } + + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.law/init9.C b/gcc/testsuite/g++.old-deja/g++.law/init9.C new file mode 100644 index 000000000..7ceb64106 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/init9.C @@ -0,0 +1,36 @@ +// { dg-do run } +// GROUPS passed initialization +// init file +// From: Richard Speed <speed@cs.montana.edu> +// Date: Sun, 6 Jun 1993 15:19:41 -0600 (MDT) +// Subject: excess elements in aggr initzer +// Message-ID: <Pine.3.07.9306061541.A10267-b100000@fubar.cs.montana.edu> + +extern "C" int printf (const char *, ...); + +class samp { + int a; +public: + samp(int n) { a = n; } + int get_a() { return a; } +}; + +int main() { + samp ob[4] [2] = { // Generated Error + 1, 2, + 3, 4, + 5, 6, + 7, 8, + }; + int i; + + if (ob[0][0].get_a() == 1 && ob[0][1].get_a() == 2 + && ob[1][0].get_a() == 3 && ob[1][1].get_a() == 4 + && ob[2][0].get_a() == 5 && ob[2][1].get_a() == 6 + && ob[3][0].get_a() == 7 && ob[3][1].get_a() == 8) + printf ("PASS\n"); + else + { printf ("FAIL\n"); return 1; } + + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.law/inline4.C b/gcc/testsuite/g++.old-deja/g++.law/inline4.C new file mode 100644 index 000000000..8a839ccca --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/inline4.C @@ -0,0 +1,21 @@ +// { dg-do run } +// GROUPS passed inlining +// inline file +// Message-Id: <9306020823.AA14027@joker> +// From: stefan@mpi-sb.mpg.de +// Subject: gcc-2.4.2 template function bug (1) +// Date: Wed, 2 Jun 93 10:23:14 +0200 + +extern "C" int printf (const char *, ...); + +template <class T> inline T func(const T& x) { return x; } + +inline int func(const int& x) { return x; } + + +int main() +{ int x; + func(x); + printf ("PASS\n"); + } + diff --git a/gcc/testsuite/g++.old-deja/g++.law/inline6.C b/gcc/testsuite/g++.old-deja/g++.law/inline6.C new file mode 100644 index 000000000..20f396dd0 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/inline6.C @@ -0,0 +1,17 @@ +// { dg-do assemble } +// GROUPS passed inlining +// inline file +// Message-Id: <199307162240.AA04019@world.std.com> +// From: kol@world.std.com (Nikolay Yatsenko) +// Subject: g++ bug: crash with extern C friend +// Date: Fri, 16 Jul 1993 18:40:48 -0400 + +inline void Ignore(){} + +extern "C" void foo() {} // but without extern C g++ compiles it + +struct A +{ + void f() {Ignore();} + friend void foo (); +}; diff --git a/gcc/testsuite/g++.old-deja/g++.law/inline7.C b/gcc/testsuite/g++.old-deja/g++.law/inline7.C new file mode 100644 index 000000000..c064c98c4 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/inline7.C @@ -0,0 +1,13 @@ +// { dg-do assemble } +// GROUPS passed inlining + template <class Type> +struct A { + typedef int X; + A() {} + virtual ~A() { } +}; + template <class Type> +struct B : public A<Type> { + B() { } +}; +B<int>::X x; diff --git a/gcc/testsuite/g++.old-deja/g++.law/mentor1.C b/gcc/testsuite/g++.old-deja/g++.law/mentor1.C new file mode 100644 index 000000000..4011b1659 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/mentor1.C @@ -0,0 +1,21 @@ +// { dg-do assemble } +// { dg-options "-O" } +// GROUPS passed mentor +struct Word { + struct S1 *p1; +}; +struct S1 { + Word o; + void shift_left(int delta, int ct); +}; +inline void S1::shift_left(int delta, int ct) +{ + int cnt = ct; + for (S1 *to_p = this, *from_p = to_p + delta; cnt--;) *to_p++ = *from_p++; +} + +void dispose_t(S1 *tp, int from_index, int ct, const int d_last_t) +{ + int new_ct = d_last_t + 1 - ct; + tp[0].o.p1[from_index].shift_left(ct, new_ct - from_index); +} diff --git a/gcc/testsuite/g++.old-deja/g++.law/missed-error1.C b/gcc/testsuite/g++.old-deja/g++.law/missed-error1.C new file mode 100644 index 000000000..17722a576 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/missed-error1.C @@ -0,0 +1,21 @@ +// { dg-do assemble } +// GROUPS passed missed-error +// missed-error file +// From: John Carr <jfc@Athena.MIT.EDU> +// Date: Tue, 02 Feb 1993 07:38:53 EST +// Subject: Re: g++ ignores language context of function pointers +// Message-ID: <9302021238.AA01513@Achates.MIT.EDU> + +typedef void (*pfv)(); +void f (); + +extern "C" +{ + typedef void (*pcfv)(void); + void cf (void); +} + +pfv p = f; +pfv p2 = cf; // { dg-error "" "" { xfail *-*-* } } mismatch +pcfv p3 = f; // { dg-error "" "" { xfail *-*-* } } mismatch +pcfv p4 = cf; diff --git a/gcc/testsuite/g++.old-deja/g++.law/missed-error2.C b/gcc/testsuite/g++.old-deja/g++.law/missed-error2.C new file mode 100644 index 000000000..7d058fd89 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/missed-error2.C @@ -0,0 +1,37 @@ +// { dg-do assemble } +// GROUPS passed missed-error +// missed-error file +// From: ndc!don@csvax.cs.caltech.edu (Don Erway) +// Date: Thu, 21 May 92 15:40:45 PDT +// Subject: More on [g++ 2.1 : overloaded function selection incorrect] +// Message-ID: <9205212240.AA17934@ndc.com> + +#include <iostream> + +// The VxWorks kernel-mode headers define a macro named "max", which is not +// ISO-compliant, but is part of the VxWorks API. +#if defined __vxworks && !defined __RTP__ +#undef max +#endif + +inline int max(int a, int b) {return a > b ? a : b;}; // { dg-message "note" } + // { dg-error "extra ';'" "extra ;" { target *-*-* } 17 } +inline double max(double a, double b) {return a > b ? a : b;}; // { dg-message "note" } candidate + // { dg-error "extra ';'" "extra ;" { target *-*-* } 19 } + +int main() { + static void foo(int i, int j, double x, double y) ;// { dg-error "" } .* + + foo(4, -37, 14.39, 14.38); +} + +// 971006 we no longer give an error for this since we emit a hard error +// about the declaration above +static void foo(int i, int j, double x, double y) { + + std::cout << "Max(int): " << max(i,j) << " Max(double): " << +max(x,y) << '\n'; + std::cout << "Max(int, double): " << max(i, y) << '\n';// { dg-error "" } + // { dg-message "candidate" "candidate note" { target *-*-* } 34 } +} + diff --git a/gcc/testsuite/g++.old-deja/g++.law/missed-error3.C b/gcc/testsuite/g++.old-deja/g++.law/missed-error3.C new file mode 100644 index 000000000..9f81bb451 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/missed-error3.C @@ -0,0 +1,124 @@ +// { dg-do assemble } +// GROUPS passed missed-error +// missed-error file +// From: Neil Wilson <csf004@cch.coventry.ac.uk> +// Date: Tue, 28 Apr 92 13:53:54 WET DST +// Subject: g++ version 2.1 bugs +// Message-ID: <15717.9204281253@cch.coventry.ac.uk> + + +// enum bool { FALSE = 0, TRUE = 1 }; + +typedef int T; + +class Traversable { +public: + virtual const T item() const = 0; + virtual const bool off() const = 0; + virtual ~Traversable() { } +}; + +class Chain : public Traversable { +public: + virtual const int count() const = 0; + virtual const bool empty() const = 0; + virtual void forth() const = 0; + virtual const bool isfirst() const = 0; + virtual const bool islast() const = 0; + virtual const int position() const = 0; + virtual const T first() const = 0; + virtual const T last() const = 0; + virtual const T i_th(const int index) const = 0; + virtual void start() const = 0; + virtual void back() const = 0; + virtual void finish() const = 0; + virtual void move(const int index) const = 0; + virtual void go(const int index) const = 0; + virtual void put(const T value) = 0; + virtual void put_i_th(const T value, const int index) = 0; + virtual void swap(const int index) = 0; + virtual void wipe_out() = 0; +}; +class List : public Chain { +protected: + int item_count; + int cursor_position; + virtual void go_offleft() const = 0; + virtual void go_offright() const = 0; + virtual void copy(const List& other) = 0; +public: + List() : item_count(0), cursor_position(0) { } + virtual const int count() const; + virtual const bool empty() const; + virtual const bool isfirst() const; + virtual const bool islast() const; + virtual const bool offleft() const; + virtual const bool offright() const; + virtual const bool off() const; + virtual const int position() const; + virtual const T first() const; + virtual const T last() const; + virtual const T i_th(const int index) const; + virtual void start() const; + virtual void forth() const; + virtual void back() const; + virtual void finish() const; + virtual void move(const int index) const; + virtual void go(const int index) const; + friend const bool operator==(const List& left, + const List& right); + friend const bool operator!=(const List& left, + const List& right); + virtual void put_i_th(const T value, const int index); + virtual void swap(const int index); +}; +typedef int T; +class Array { +private: + int lower_index; + int upper_index; + T *array; +protected: + virtual void allocate(const int minindex, const int maxindex); + virtual void copy(const Array&other); +public: + Array(const int minindex, const int maxindex); + Array(const Array& other); + virtual const int count() const; + virtual const int lower() const; + virtual const int upper() const; + virtual const T item(const int index) const; + const T Array::operator[](const int index); // { dg-error "" } qualification ignored + virtual const bool valid_index(const int index) const; + virtual const bool empty() const; + friend const bool operator==(const Array& left, const Array& right); + friend const bool operator!=(const Array& left, const Array& right); + virtual void put(const T value, const int index); + virtual void wipe_out(); + Array& operator=(const Array& other); + virtual ~Array(); +}; +class Fixed_List: public List, private Array { +protected: + virtual void go_offleft() const; + virtual void go_offright() const; + virtual void copy(const List& other); +public: + Fixed_List(const List& other); + Fixed_List(const int size): Array(1, size) { } + virtual const bool empty() const; + virtual const int count() const; + virtual const T item() const; + virtual const T i_th(const int index) const; + virtual void move(const int index) const; + virtual void put(const T value); + virtual void put_i_th(const T value, const int index); + virtual void wipe_out() { } + Fixed_List& operator=(const List& other); +}; + +void Fixed_List::go_offleft() const +{ + cursor_position = 0;// { dg-error "" } +} + diff --git a/gcc/testsuite/g++.old-deja/g++.law/missing1.C b/gcc/testsuite/g++.old-deja/g++.law/missing1.C new file mode 100644 index 000000000..9afeef6ef --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/missing1.C @@ -0,0 +1,12 @@ +// { dg-do assemble } +// GROUPS passed missing +// missing file +// Message-Id: <9207100259.AA11702@quaestor> +// From: adam@inference.com (David Adam) +// Subject: G++ does not allow parens around declarators. +// Date: Thu, 9 Jul 92 19:59:51 PDT + +void foo() +{ + long (bar)[5]; +} diff --git a/gcc/testsuite/g++.old-deja/g++.law/nest1.C b/gcc/testsuite/g++.old-deja/g++.law/nest1.C new file mode 100644 index 000000000..7b2cae55b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/nest1.C @@ -0,0 +1,15 @@ +// { dg-do assemble } +// GROUPS passed nest +// nest file +// From: gs4t@virginia.edu (Gnanasekaran Swaminathan) +// Date: Wed, 30 Dec 1992 20:38:07 GMT +// Subject: Local type names bug in g++ 2.3.3 +// Message-ID: <1992Dec30.203807.17504@murdoch.acc.Virginia.EDU> + +typedef char* T; // { dg-error "" } previous declaration + +struct Y { + T a; + typedef long T; // error. See ARM p189-191 for details// { dg-error "" } + T b; +}; diff --git a/gcc/testsuite/g++.old-deja/g++.law/nest2.C b/gcc/testsuite/g++.old-deja/g++.law/nest2.C new file mode 100644 index 000000000..cee335d9d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/nest2.C @@ -0,0 +1,13 @@ +// { dg-do assemble } +// GROUPS passed nest +struct B +{ + class B_I { }; +}; + +struct D : public B +{ + B_I foo; + class I : public B_I { }; +}; + diff --git a/gcc/testsuite/g++.old-deja/g++.law/nest3.C b/gcc/testsuite/g++.old-deja/g++.law/nest3.C new file mode 100644 index 000000000..daeaa201b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/nest3.C @@ -0,0 +1,25 @@ +// { dg-do assemble } +// GROUPS passed nest +#include <iostream> + +struct inner { + static void f() { std::cout << "inner::f()\n";} +}; + +struct outer { + + struct inner { + static void f() { std::cout << "outer::inner::f()\n";} + }; + + static void f() { + inner::f(); //call of outer::inner::f() + ::inner::f(); //(try to) call inner::f() => parse error + } +}; + +int main() { + outer::f(); + std::cout << std::endl; + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.law/nest4.C b/gcc/testsuite/g++.old-deja/g++.law/nest4.C new file mode 100644 index 000000000..ed9d2828a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/nest4.C @@ -0,0 +1,20 @@ +// { dg-do assemble } +// GROUPS passed nest +// nest file +// From: Neal Young <ney@princeton.edu> +// Date: Mon, 11 Oct 93 17:03:59 EDT +// Subject: g++ 2.4.5 bug report: local class decl can't access local static var +// Message-ID: <9310112103.AA06326@cs> + +void f() +{ + static int s; + + struct local { + int j() { return s; } // should be okay, see 1991 ref. man. r.9.8 + }; +} + +int main() +{ +} diff --git a/gcc/testsuite/g++.old-deja/g++.law/nest5.C b/gcc/testsuite/g++.old-deja/g++.law/nest5.C new file mode 100644 index 000000000..892337ccf --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/nest5.C @@ -0,0 +1,17 @@ +// { dg-do assemble } +// GROUPS passed nest +// nest file +// From: tal@vlsi.cs.caltech.edu +// Date: Mon, 11 Oct 93 16:26:02 -0700 +// Subject: Serious bug: g++2.4.5 -Doesn't support local classes +// Message-ID: <9310112325.AA13386@vlsi.cs.caltech.edu> + +void foo() { + class Wrapper { + public: + void F (void * Wrapperptr) + { + Wrapper * wrapptr = ( Wrapper *) Wrapperptr; + } + }; +} diff --git a/gcc/testsuite/g++.old-deja/g++.law/operators10.C b/gcc/testsuite/g++.old-deja/g++.law/operators10.C new file mode 100644 index 000000000..fe36beced --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/operators10.C @@ -0,0 +1,23 @@ +// { dg-do assemble } +// GROUPS passed operators +// opr-eq file +// Message-Id: <9306040324.AA22954@balder.cs.wisc.edu> +// From: so@cs.wisc.edu (Bryan So) +// Subject: g++ bug +// Date: Thu, 3 Jun 93 22:24:13 -0500 + +template <class T> +struct Test { + int data; + Test& operator=(int i) { data = i; return *this; } +}; + + +int main() +{ + Test<int> i, j; + + i = j; + + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.law/operators11.C b/gcc/testsuite/g++.old-deja/g++.law/operators11.C new file mode 100644 index 000000000..6c2883083 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/operators11.C @@ -0,0 +1,36 @@ +// { dg-do assemble } +// GROUPS passed operators +// opr-eq file +// Message-Id: <CCJrut.9M7@csc.ti.com> +// From: rowlands@hc.ti.com (Jon Rowlands) +// Subject: g++ 2.4.5: assignment operator in base class +// Date: Mon, 30 Aug 1993 00:54:29 GMT + +class B { +public: + B & operator = (B); // delete this line and problem goes away +}; + +class D : public B { +public: + D(); + D(int); + D(B); +}; + +int +main() { + B b; + D d; + + d = d; + + d = 0; // t.cxx:20: assignment not defined for type `D' + d = D(0); + + d = b; // t.cxx:23: assignment not defined for type `D' + d = D(b); + + return(0); +} + diff --git a/gcc/testsuite/g++.old-deja/g++.law/operators12.C b/gcc/testsuite/g++.old-deja/g++.law/operators12.C new file mode 100644 index 000000000..2533a7e2d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/operators12.C @@ -0,0 +1,20 @@ +// { dg-do assemble } +// GROUPS passed operators +// opr-eq file +// Message-Id: <199311181618.AA27761@oil.cs.columbia.edu> +// From: Sam Fenster <fenster@cs.columbia.edu> +// Subject: g++ 2.5.3 can't disable assignment +// Date: Thu, 18 Nov 1993 11:18:18 -0500 + +class B + { + B &operator = (const B &); //Disable assignment! + public: + virtual ~B () {} + }; + +class D: public B + { + public: + D () {} + }; diff --git a/gcc/testsuite/g++.old-deja/g++.law/operators13.C b/gcc/testsuite/g++.old-deja/g++.law/operators13.C new file mode 100644 index 000000000..3aba4f6aa --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/operators13.C @@ -0,0 +1,24 @@ +// { dg-do assemble } +// GROUPS passed operators +// opr-eq file +// Message-Id: <1993Nov18.210502.28842@midway.uchicago.edu> +// From: mps@dent.uchicago.edu (Michael Spertus) +// Subject: g++ 2.5.4 bug : operator= +// Date: Thu, 18 Nov 1993 21:05:02 GMT + +class T { +}; + +class EP { +public: + void operator=(T *); +}; + + +void EP::operator=(T *) { } + +int main() +{ + EP ep1, ep2; + ep1 = ep2; +} diff --git a/gcc/testsuite/g++.old-deja/g++.law/operators14.C b/gcc/testsuite/g++.old-deja/g++.law/operators14.C new file mode 100644 index 000000000..d0ec8a4a5 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/operators14.C @@ -0,0 +1,10 @@ +// { dg-do assemble } +// GROUPS passed operators +void foo (int * a, int * b, int * c) {} + +int main() { + int a,b,c; + foo (&a, &b, &c); + (a = b) = c; +} + diff --git a/gcc/testsuite/g++.old-deja/g++.law/operators15.C b/gcc/testsuite/g++.old-deja/g++.law/operators15.C new file mode 100644 index 000000000..ea0e68857 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/operators15.C @@ -0,0 +1,28 @@ +// { dg-do run } +// GROUPS passed operators +// opr-del file +// Message-Id: <199301272137.AA25213@world.std.com> +// From: kol@world.std.com (Nikolay Yatsenko) +// Subject: bug report +// Date: Wed, 27 Jan 1993 16:37:30 -0500 + +extern "C" int printf(const char* ...); + +int delete_counter = -1; + +struct T{ + void operator delete (void * p) {delete_counter ++; ::operator delete(p);} +}; + +int main(void) +{ + T * ps1 = new T; + + ::delete ps1; // Wrong T::operator delete() is called here + + if (delete_counter != -1) + { printf ("FAIL\n"); return 1; } + else + printf ("PASS\n"); + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.law/operators16.C b/gcc/testsuite/g++.old-deja/g++.law/operators16.C new file mode 100644 index 000000000..820e47083 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/operators16.C @@ -0,0 +1,30 @@ +// { dg-do run } +// GROUPS passed operators +// copy file +// From: gfm@mencon.mencon.oz.au (Graham Menhennitt) +// Date: Thu, 29 Apr 93 20:53:07 EST +// Subject: 4 bugs in g++ 2.3.3 +// Message-ID: <9304291053.AA00090@mencon> + +#include <stdio.h> + +int pass = 0; +struct A { + A(void) {} + A(const A& a) { ; } + A& operator = (const A& a) { pass = 1; return *this; } +}; + +struct B { + B(const A& aa) { B::a = aa; } + A a; +}; + +int main(void) +{ + B b = A(); + if (pass) + printf ("PASS\n"); + else + { printf ("FAIL\n"); return 1; } +} diff --git a/gcc/testsuite/g++.old-deja/g++.law/operators17.C b/gcc/testsuite/g++.old-deja/g++.law/operators17.C new file mode 100644 index 000000000..ea2e9beb1 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/operators17.C @@ -0,0 +1,12 @@ +// { dg-do assemble } +// { dg-options "-Wall -pedantic-errors" } +// GROUPS passed operators +// copy file +// From: gfm@mencon.mencon.oz.au (Graham Menhennitt) +// Date: Thu, 29 Apr 93 20:53:07 EST +// Subject: 4 bugs in g++ 2.3.3 +// Message-ID: <9304291053.AA00090@mencon> + +struct A { + A& operator = (const A& a) {}// { dg-warning "" } +}; diff --git a/gcc/testsuite/g++.old-deja/g++.law/operators18.C b/gcc/testsuite/g++.old-deja/g++.law/operators18.C new file mode 100644 index 000000000..d362a4c9f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/operators18.C @@ -0,0 +1,17 @@ +// { dg-do assemble } +// GROUPS passed operators +// opr-ampr file +// From: mecklen@oops.cs.utah.edu (Robert Mecklenburg) +// Date: Thu, 8 Oct 92 16:33:08 -0600 +// Subject: Type conversion and overloading bugs in 2.2.2 +// Message-ID: <9210082233.AA28203@hellgate.utah.edu> + + enum E { a, b, c }; + struct Estr { + E value; + Estr() {} + Estr( int i ) : value( (E)i ) {} + operator E() { return value; } + }; + extern Estr baz(); + int bazz() { return baz() & 2; } diff --git a/gcc/testsuite/g++.old-deja/g++.law/operators19.C b/gcc/testsuite/g++.old-deja/g++.law/operators19.C new file mode 100644 index 000000000..c9707beb1 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/operators19.C @@ -0,0 +1,19 @@ +// { dg-do assemble } +// GROUPS passed operators +// opr-ampr file +// From: Jarkko Sonninen <Jarkko.Sonninen@lut.fi> +// Date: Thu, 7 Oct 1993 08:25:26 +0200 +// Subject: type of base class member +// Message-ID: <199310070625.AA18653@kaisa.it.lut.fi> + +class A { + public: + int j; +}; + +class B: public A { + public: + B () { + !(A::j); + } +}; diff --git a/gcc/testsuite/g++.old-deja/g++.law/operators2.C b/gcc/testsuite/g++.old-deja/g++.law/operators2.C new file mode 100644 index 000000000..64f6bfadb --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/operators2.C @@ -0,0 +1,15 @@ +// { dg-do assemble } +// GROUPS passed operators +// opr-conv file +// Message-Id: <199301260142.AA13995@world.std.com> +// From: gparker@world.std.com (Glenn P Parker) +// Subject: gcc bug +// Date: Mon, 25 Jan 1993 20:42:35 -0500 + +int main(void) +{ + int i = int(); // g++ 2.3.3 cannot compile it. + + return 0; +} + diff --git a/gcc/testsuite/g++.old-deja/g++.law/operators21.C b/gcc/testsuite/g++.old-deja/g++.law/operators21.C new file mode 100644 index 000000000..e6d77c329 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/operators21.C @@ -0,0 +1,16 @@ +// { dg-do assemble } +// GROUPS passed operators + +struct A { + int x; +}; + +int operator()(A x,float y) {// { dg-error "" } .* + return 1; +} + +int main() { + A x; + x(1.0); // { dg-error "" } no match +} + diff --git a/gcc/testsuite/g++.old-deja/g++.law/operators22.C b/gcc/testsuite/g++.old-deja/g++.law/operators22.C new file mode 100644 index 000000000..2d18e0803 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/operators22.C @@ -0,0 +1,15 @@ +// { dg-do assemble } +// GROUPS passed operators +template <class T> +class t { +public: + t() {} +}; + +class m { + t<int> c; +public: + m() : c() {} +}; + +m *p() {return new m;} diff --git a/gcc/testsuite/g++.old-deja/g++.law/operators23.C b/gcc/testsuite/g++.old-deja/g++.law/operators23.C new file mode 100644 index 000000000..38ef1b13f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/operators23.C @@ -0,0 +1,36 @@ +// { dg-do run } +// GROUPS passed operators +// opr-new file +// From: (The Crossjammer) <xjam@cork.cs.berkeley.edu> +// Date: Mon, 23 Nov 92 23:35:26 PST +// Subject: g++-2.3.1 : Incorrectly calls overloaded operator new +// Message-ID: <9211240735.AA06872@cork.CS.Berkeley.EDU> + + +#include <stdio.h> +#include <stdlib.h> + +class blah { + int j; + public: + blah(); + void *operator new(size_t size) throw(); +}; + +inline blah::blah() : j(0) { + +} + + +void *blah::operator new(size_t size) throw(){ + printf ("FAIL\n"); + exit (1); + return NULL; +} + +int main(int arg, char** argv) { + blah* blahPtr; + + blahPtr = new blah[100]; + printf ("PASS\n"); +} diff --git a/gcc/testsuite/g++.old-deja/g++.law/operators24.C b/gcc/testsuite/g++.old-deja/g++.law/operators24.C new file mode 100644 index 000000000..5d182aade --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/operators24.C @@ -0,0 +1,14 @@ +// { dg-do assemble } +// GROUPS passed operators +// opr-new file +// From: rwave!myersn%rwave.roguewave@cs.orst.edu (Nathan Myers) +// Date: Wed, 16 Dec 92 11:55 PST +// Subject: 2.3.2: friend decl breaks member op new +// Message-ID: <m0n24qP-0000GmC@rwave.roguewave.com> + +#include <stddef.h> +struct Link { + void* operator new(size_t, int); + friend void* __builtin_new(size_t); // This declaration triggers the bug +}; +void f() { new(2) Link; } diff --git a/gcc/testsuite/g++.old-deja/g++.law/operators25.C b/gcc/testsuite/g++.old-deja/g++.law/operators25.C new file mode 100644 index 000000000..e37306492 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/operators25.C @@ -0,0 +1,16 @@ +// { dg-do assemble } +// GROUPS passed operators +// opr-new file +// From: gparker@world.std.com (Glenn P Parker) +// Date: Mon, 25 Jan 1993 20:43:43 -0500 +// Subject: gcc bug +// Message-ID: <199301260143.AA14133@world.std.com> + +typedef int (**PPF)(int); + +int main(void) +{ + PPF pf2 = new (int (*) (int)); // internal compiler error on this line. + + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.law/operators27.C b/gcc/testsuite/g++.old-deja/g++.law/operators27.C new file mode 100644 index 000000000..5fb3a74cb --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/operators27.C @@ -0,0 +1,34 @@ +// { dg-do run } +// GROUPS passed operators +// opr-new file +// From: David Binderman 3841 <dcb@us-es.sel.de> +// Date: Mon, 21 Jun 93 11:42:11 +0200 +// Subject: G++ 2.4.3 and operator new +// Message-ID: <9306210942.AA10276@slsvitt.us-es.sel.de> + +int FLAG=0; + +#include <new> + +extern "C" int printf( const char *, ...); + +void * operator new(std::size_t, const std::nothrow_t&) throw() { FLAG=1; return 0; } + +class K { +private: + int i; +public: + K( int j) { + i = j; + } +}; + +int main(void) +{ + K * pK = new (std::nothrow) K( 10); + if ( FLAG != 1 ) + { printf ("FAIL\n"); return 1; } + else + printf ("PASS\n"); + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.law/operators28.C b/gcc/testsuite/g++.old-deja/g++.law/operators28.C new file mode 100644 index 000000000..7d166474a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/operators28.C @@ -0,0 +1,30 @@ +// { dg-do assemble } +// GROUPS passed operators +#include <sys/types.h> +#include <stdio.h> + +class new_test +{ + int type; +public: + void* operator new(size_t sz, int count, int type); +}; + +void* new_test::operator new(size_t sz, int count, int type) +{ + void *p; + + printf("%d %d %d\n", sz, count, type); + + p = new char[sz * count]; + ((new_test *)p)->type = type; + return p; +} + +int main() +{ + new_test *test; + int count = 13; + + test = new(count, 1) new_test; +} diff --git a/gcc/testsuite/g++.old-deja/g++.law/operators29.C b/gcc/testsuite/g++.old-deja/g++.law/operators29.C new file mode 100644 index 000000000..387f8cbd7 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/operators29.C @@ -0,0 +1,23 @@ +// { dg-do assemble } +// GROUPS passed operators +// (Message bugs/opr-del:4) +// From: jamshid@ses.com (Jamshid Afshar) +// Date: Fri, 25 Feb 94 18:44:01 CST +// Subject: Re: delete on "smart pointers" +// Message-ID: <9402262328.AA16321@pancake> +// +// Who was apparently replying to kuhlins@hawk.wifo.uni-mannheim.de + + +template<class T> class Ptr { +public: + Ptr(T*); + operator T*(); +}; + +int main() { + Ptr<int> ip = new int(2); + delete ip; + operator delete(ip); + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.law/operators3.C b/gcc/testsuite/g++.old-deja/g++.law/operators3.C new file mode 100644 index 000000000..38c75b663 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/operators3.C @@ -0,0 +1,22 @@ +// { dg-do assemble } +// GROUPS passed operators +// opr-pl file +// Message-Id: <9212010409.AA24967@zeus.research.otc.com.au> +// From: grahamd@zeus.research.otca.oz.au (Graham Dumpleton) +// Subject: Failure to use conversion operator. +// Date: Tue, 1 Dec 92 15:11:18 EST + +class BUG1 +{ + public: + + operator const char*() const { return myData; } + const char* myData; +}; + +void bug1() +{ + BUG1 bug1; + bug1.myData = "0123456789"; + const char* s = bug1 + 1; +} diff --git a/gcc/testsuite/g++.old-deja/g++.law/operators30.C b/gcc/testsuite/g++.old-deja/g++.law/operators30.C new file mode 100644 index 000000000..cd57188db --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/operators30.C @@ -0,0 +1,26 @@ +// { dg-do run } +// GROUPS passed operators +// opr-mm file +// Date: Thu, 2 Jun 94 10:00:29 +0200 +// From: chatty@cenatls.cena.dgac.fr (Stephane Chatty) +// Message-Id: <9406020800.AA14201@geant.cenatls.cena.dgac.fr> +// Subject: result of operator -- with g++-2.5.8 + +#include <stdio.h> + +void nop() +{ +} + +int main () +{ + int a = 2; + + if (----a == 0) + nop (); + + if (a == 0) + printf("PASS\n"); + else + { printf("FAIL\n"); return 1; } +} diff --git a/gcc/testsuite/g++.old-deja/g++.law/operators31.C b/gcc/testsuite/g++.old-deja/g++.law/operators31.C new file mode 100644 index 000000000..8ad9c472b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/operators31.C @@ -0,0 +1,19 @@ +// { dg-do assemble } +// GROUPS passed operators +// opr-del file +// From: Eberhard Mattes <mattes@azu.informatik.uni-stuttgart.de> +// Date: Thu, 4 Aug 94 08:19:20 +0200 +// Subject: delete [] A::s +// Message-ID: <9408040619.AA27602@azu.informatik.uni-stuttgart.de> + +class A +{ + char *s; +public: + void f (); +}; + +void A::f () +{ + delete [] A::s; +} diff --git a/gcc/testsuite/g++.old-deja/g++.law/operators32.C b/gcc/testsuite/g++.old-deja/g++.law/operators32.C new file mode 100644 index 000000000..20d148dd5 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/operators32.C @@ -0,0 +1,57 @@ +// { dg-do assemble } +// GROUPS passed operators +#include <iostream> + +// +// ffrees space allocated for N-D array +// + +template <class T> +void ffree(long rows, T** array) // { dg-message "note" } +{ +for( long i = 0; i < rows; i++ ) + delete [] array[i]; // delete row +delete [] array; // delete outer array +} + +template <class T> +T* allocate1d(long size, T*& array) +{ +return array = new T[size]; +} + +template <class T> +T** allocate2d(long d1, long d2, T**& array) // { dg-message "note" } +{ +if( allocate1d(d1, array) != 0 ) + { + for( long i = 0; i < d1; i++ ) + { + if( allocate1d(d2, array[i]) == 0 ) + { + ffree(i,array); + return array; + } + } + } +return array; +} + +int main() +{ +long d1 = 3, d2 = 4; +class foo +{ +public: +foo() {std::cout << "foo created" << std::endl; } + +~foo() {std::cout << "foo deleted" << std::endl; } +}; + +foo **f2; +allocate2d(d1, d2, f2);// { dg-error "" } type.*// ERROR - trying to.* +// { dg-message "candidate" "candidate note" { target *-*-* } 52 } +ffree(d1, f2);// { dg-error "" } type.*// ERROR - trying to.* +// { dg-message "candidate" "candidate note" { target *-*-* } 54 } + +} diff --git a/gcc/testsuite/g++.old-deja/g++.law/operators33.C b/gcc/testsuite/g++.old-deja/g++.law/operators33.C new file mode 100644 index 000000000..87e50941d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/operators33.C @@ -0,0 +1,28 @@ +// { dg-do assemble } +// GROUPS passed operators +// opr-new file +// From: flisakow@cae.wisc.edu +// Date: Thu, 1 Sep 94 18:21:09 CDT +// Subject: g++ bug? +// Message-ID: <9409012321.AA05346@hprisc-19.cae.wisc.edu> + +#include <stdio.h> + + +struct fcell { + FILE *fd; + struct fcell *next; +}; + + +class FStack { +public: + struct fcell *top; + FStack() { top = NULL ; } + inline void push(FILE * fd1, int line_num, char *fname = NULL) { + struct fcell *tmp = new struct fcell; + tmp->fd = fd1; + tmp->next = top; + top = tmp ; + } +}; diff --git a/gcc/testsuite/g++.old-deja/g++.law/operators34.C b/gcc/testsuite/g++.old-deja/g++.law/operators34.C new file mode 100644 index 000000000..069f81504 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/operators34.C @@ -0,0 +1,12 @@ +// { dg-do assemble } +// GROUPS passed operators +class A { + public: + A() { + } +}; + +static class A *A_new_() { + return new class A; +} + diff --git a/gcc/testsuite/g++.old-deja/g++.law/operators4.C b/gcc/testsuite/g++.old-deja/g++.law/operators4.C new file mode 100644 index 000000000..fc623b4fc --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/operators4.C @@ -0,0 +1,32 @@ +// { dg-do assemble } +// GROUPS passed operators +// opr-del file +// From: rollins@bart.ee.queensu.ca (Mark Rollins) +// Date: Thu, 3 Sep 1992 22:01:03 -0400 Fri, 4 Sep 1992 02:00:25 GMT +// Subject: delete [size] pointer; Problem +// Message-ID: <92Sep3.220137edt.30@jarvis.csri.toronto.edu> + +#include <complex> +typedef std::complex<double> Complex; +#include <stdio.h> + +class Vector { + int size; + Complex *v; + public: + Vector(int s=1) { size = s; v = new Complex[size];} + ~Vector() { delete [size] v;}// { dg-error "" } warning +}; + +void foo(int s) +{ + Vector junk(s); +} + +int main() +{ + Vector* test; + for (int i=0;i<40;i++) // was 100000 + foo(1000); + printf ("PASS\n"); +} diff --git a/gcc/testsuite/g++.old-deja/g++.law/operators6.C b/gcc/testsuite/g++.old-deja/g++.law/operators6.C new file mode 100644 index 000000000..f15c073ff --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/operators6.C @@ -0,0 +1,24 @@ +// { dg-do assemble } +// GROUPS passed operators +// opr-as file +// From: Klaus Ahrens <ahrens@informatik.hu-berlin.de> +// Date: Fri, 26 Mar 93 12:50:37 mez +// Subject: no default assignment +// Message-ID: <199303261149.TA23114@mail.Germany.EU.net> + +class A { +public: + A(int){} + A& operator=(const A&){return *this;} +}; + +class B: public A { +public: + B(int i): A(i) {} +}; + +int main() +{ + B b=1; + b=1; +} diff --git a/gcc/testsuite/g++.old-deja/g++.law/operators8.C b/gcc/testsuite/g++.old-deja/g++.law/operators8.C new file mode 100644 index 000000000..16c91cdef --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/operators8.C @@ -0,0 +1,52 @@ +// { dg-do run } +// GROUPS passed operators +#include <stdio.h> + +class shape { + public: + virtual int vDisplay(void) const = 0; + protected: + int X; + int Y; +}; + +class square :public shape { + public: + square(int x, int y, int width_) { + X = x; + Y = y; + width = width_; + } + int vDisplay(void) const { + printf ("PASS\n"); + return 0; + } + protected: + int width; +}; + + +class triangle :public shape { + public: + triangle(int x, int y, int width_, int height_) { + X = x; + Y = y; + width = width_; + height = height_; + } + int vDisplay(void) const { + printf ("FAIL\n"); + return 1; + } + protected: + int width; + int height; +}; + +int main() { + shape* s1 = new square(4,4,5); + shape* s2 = new triangle(6,6,2,3); + *s1 = *s2; + return s1->vDisplay(); +} + diff --git a/gcc/testsuite/g++.old-deja/g++.law/operators9.C b/gcc/testsuite/g++.old-deja/g++.law/operators9.C new file mode 100644 index 000000000..3c50cbdd0 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/operators9.C @@ -0,0 +1,21 @@ +// { dg-do assemble } +// GROUPS passed operators +// opr-eq file +// Message-Id: <9301141514.AA05925@mi.el.utwente.nl> +// From: klamer@mi.el.utwente.nl (Klamer Schutte) +// Subject: 2.3.3: failed to detect error +// Date: Thu, 14 Jan 93 16:14:21 +0100 + +class B +{ +public: + operator=(B &); // { dg-error "no type" } + // { dg-message "B::operator=|no known conversion" "note" { target *-*-* } 12 } +}; + +void +test(B &b1, const B &b2) +{ + b1 = b2;// { dg-error "match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 19 } +} diff --git a/gcc/testsuite/g++.old-deja/g++.law/parsing1.C b/gcc/testsuite/g++.old-deja/g++.law/parsing1.C new file mode 100644 index 000000000..3930ae809 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/parsing1.C @@ -0,0 +1,21 @@ +// { dg-do assemble } +// GROUPS passed parsing +// parsing folder +// From: hendrik%vedge.UUCP@iro.umontreal.ca +// Date: Wed, 23 Sep 92 17:10:28 -0400 +// Subject: parenthesized method +// Message-ID: <9209232110.AA02533@.> + + +class goo{ +public: + void noo_bloo(); +}; + +void choo(goo* too) +{ (too->noo_bloo)(); +} + +void choo_too(goo* too) +{ too->noo_bloo(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.law/parsing10.C b/gcc/testsuite/g++.old-deja/g++.law/parsing10.C new file mode 100644 index 000000000..8dcb74fa6 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/parsing10.C @@ -0,0 +1,32 @@ +// { dg-do assemble } +// GROUPS passed parsing +// parsing folder +// From: Eirik Fuller <eirik@elf.ithaca.ny.us> +// Date: Wed, 15 Dec 1993 17:06:11 -0500 +// Subject: parse error +// Message-ID: <199312152206.AA06584@tonttu.TC.Cornell.EDU> + + +class s; + +template <class T> +class t +{ +public: + void f(T *t); +}; + +class l +{ +public: + void s() {} +}; + +extern t<l> g; + +class p +{ +public: + void *h; + s *a() {return (s *) h;} +}; diff --git a/gcc/testsuite/g++.old-deja/g++.law/parsing2.C b/gcc/testsuite/g++.old-deja/g++.law/parsing2.C new file mode 100644 index 000000000..73be6bbc2 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/parsing2.C @@ -0,0 +1,11 @@ +// { dg-do assemble } +// GROUPS passed parsing +// parsing folder +// From: jonathan@Pescadero.Stanford.EDU +// Date: Tue, 15 Sep 92 14:15:29 PDT +// Subject: Function taking as argument a pointer to a pointer to a function +// that returns int causes coredump in cc1plus +// Message-ID: <9209152115.AA07423@Pescadero.Stanford.EDU> + + unsigned char FindMdc ( int (**)() ); + unsigned char FindMdc2 ( int (**funcname)() ); diff --git a/gcc/testsuite/g++.old-deja/g++.law/parsing3.C b/gcc/testsuite/g++.old-deja/g++.law/parsing3.C new file mode 100644 index 000000000..a9e6e33dd --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/parsing3.C @@ -0,0 +1,15 @@ +// { dg-do assemble } +// GROUPS passed parsing +// parsing folder +// From: tll@cco.caltech.edu (Tal Lewis Lancaster) +// Date: 18 Mar 1993 17:09:43 GMT +// Subject: Re: unexpected difference between gcc and g++ (both 2.3.3) +// Message-ID: <1oaacnINNt20@gap.caltech.edu> + +/* Notice that this case parses fine */ +int (* volatile y)[10]; + +void foo2() { + /* The parser can't handle it now */ + int (* volatile x)[10]; +} diff --git a/gcc/testsuite/g++.old-deja/g++.law/parsing4.C b/gcc/testsuite/g++.old-deja/g++.law/parsing4.C new file mode 100644 index 000000000..6eced1b13 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/parsing4.C @@ -0,0 +1,10 @@ +// { dg-do assemble } +// GROUPS passed parsing +// parsing folder +// From: Glenn Engel <glenne@lsid.hp.com> +// Date: Fri, 29 Jan 93 18:42:03 PST +// Subject: Parse Error +// Message-ID: <9301300242.AA15550@hplslk.lsid.hp.com> + +int test1(void (**roc)(int,int)); // parse error +int test2(int id,void (**orc)(int,int)); // works diff --git a/gcc/testsuite/g++.old-deja/g++.law/parsing5.C b/gcc/testsuite/g++.old-deja/g++.law/parsing5.C new file mode 100644 index 000000000..370c1bc18 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/parsing5.C @@ -0,0 +1,11 @@ +// { dg-do assemble } +// GROUPS passed parsing +// From: Teemu Torma <Teemu.Torma@frend.fi> +// Date: Mon, 15 Jun 92 18:42:25 +0300 +// Subject: G++ 2.2.2: Strange parse error +// Message-ID: <"relay.fren.501:15.05.92.15.42.30"@frend.fi> + +long (*foo1 ()) (); // This is ok. + +typedef long INT; +INT (*foo2 ()) (); // This is not, g++ says "parse error before `('" diff --git a/gcc/testsuite/g++.old-deja/g++.law/parsing6.C b/gcc/testsuite/g++.old-deja/g++.law/parsing6.C new file mode 100644 index 000000000..f95c6192a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/parsing6.C @@ -0,0 +1,15 @@ +// { dg-do assemble } +// GROUPS passed parsing +// parsing folder +// From: "James S. Vera" <vera@fanaraaken.stanford.edu> +// Date: Thu, 01 Jul 1993 16:36:32 -0700 +// Subject: Mildly complicated type not understood, 2.4.5 +// Message-ID: <9307012336.AA13841@fanaraaken.Stanford.EDU> + +typedef int (*cow[3])(...); + +int main() { + cow fs; + int (*pig[3])(...); // line 5 + +} diff --git a/gcc/testsuite/g++.old-deja/g++.law/parsing7.C b/gcc/testsuite/g++.old-deja/g++.law/parsing7.C new file mode 100644 index 000000000..d39400aed --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/parsing7.C @@ -0,0 +1,24 @@ +// { dg-do assemble } +// GROUPS passed parsing +// parsing folder +// From: szahn%Robinie@goesser.sie.siemens.co.at (Hr. Zahn) +// Date: Mon, 5 Jul 93 10:45:51 +0200 +// Subject: Bug report g++ 2.4.5, unexpected syntax errors +// Message-ID: <9307050845.AA00499@ets5.uebemc.siemens.de> + +int f1( + int (**a1)() + ); + +int f2( + int (**a1)() + ); + + +int f3( + int (**a1)( int a, int b ) + ); + +int f4( + int (**a1)( int a, int b ) + ); diff --git a/gcc/testsuite/g++.old-deja/g++.law/parsing8.C b/gcc/testsuite/g++.old-deja/g++.law/parsing8.C new file mode 100644 index 000000000..797982cb9 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/parsing8.C @@ -0,0 +1,31 @@ +// { dg-do assemble } +// GROUPS passed parsing +// parsing folder +// From: nag@soft.flab.fujitsu.co.jp +// Date: Thu, 08 Jul 1993 10:54:59 +0900 +// Subject: g++ cannot understand `void (**f)()' +// Message-ID: <9307080155.AA00496@kumade.soft.flab.fujitsu.co.jp> + + void + func() { + int ( * * i )[ 2 ]; + } + +// Looks like this is probably the same problem +// parsing folder +// From: nag@soft.flab.fujitsu.co.jp +// Date: Thu, 08 Jul 1993 10:54:59 +0900 +// Subject: g++ cannot understand `void (**f)()' +// Message-ID: <9307080155.AA00496@kumade.soft.flab.fujitsu.co.jp> +int main() +{ + void (**f)(); +} + + +// Same as +// From: Chris Dodd <dodd@csl.sri.com> +// Date: Fri, 16 Jul 93 17:05:04 -0700 +// Subject: bug in declaration parsing in g++ 2.4.5 +// Message-ID: <9307170005.AA03857@pekoe.csl.sri.com> + diff --git a/gcc/testsuite/g++.old-deja/g++.law/parsing9.C b/gcc/testsuite/g++.old-deja/g++.law/parsing9.C new file mode 100644 index 000000000..b4de05278 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/parsing9.C @@ -0,0 +1,32 @@ +// { dg-do assemble } +// GROUPS passed parsing +// From: Jason Merrill <jason@cygnus.com> +// Date: Fri, 13 Aug 93 12:49:11 PDT +// Subject: 2.4.5 won't compile array of pointers to functions returning T +// Message-ID: <9308131949.AA26348@cygnus.com> +// From: "Robert M. Keller" <keller@jarthur.Claremont.EDU> +// Subject: g++ bug +// Date: Fri, 13 Aug 93 10:09:27 PDT + +/* Testing declaration of "array of pointers to functions returning T" */ + +typedef int T; + +T foo() +{ return 10; } + +T bar() +{ return 20; } + +T baz() +{ return 30; } + +int main() +{ +T (*apfrt[10])(); + +apfrt[0] = foo; +apfrt[1] = bar; +apfrt[2] = baz; + +} diff --git a/gcc/testsuite/g++.old-deja/g++.law/patches1.C b/gcc/testsuite/g++.old-deja/g++.law/patches1.C new file mode 100644 index 000000000..f32396373 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/patches1.C @@ -0,0 +1,24 @@ +// { dg-do assemble } +// GROUPS passed patches +// patches file +// From: david.binderman@pmsr.philips.co.uk +// Date: Wed, 6 Oct 93 17:05:54 BST +// Subject: Reno 1.2 bug fix +// Message-ID: <9310061605.AA04160@pmsr.philips.co.uk> + +int type(float) { return 1; } +int type(double) { return 2; } +int type(long double) { return 3; } + +extern "C" int printf( const char *, ...); + +int main() +{ + int i = 0; + if (type(0.0) != 2) + ++i; + if (i > 0) + { printf ("FAIL\n"); return 1; } + else + printf ("PASS\n"); +} diff --git a/gcc/testsuite/g++.old-deja/g++.law/pic1.C b/gcc/testsuite/g++.old-deja/g++.law/pic1.C new file mode 100644 index 000000000..561ea2460 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/pic1.C @@ -0,0 +1,9 @@ +// { dg-do assemble } +// GROUPS passed operators +// pic file +// Message-Id: <199406132030.NAA23508@dewitt.eecs.berkeley.edu> +// Subject: gcc-2.5.8 -fpic fails to compile extern const char static initializer +// Date: Mon, 13 Jun 1994 13:30:14 -0700 +// From: Christopher Hylands <cxh@dewitt.eecs.berkeley.edu> + +extern const char SDFdomainName[] = "SDF"; diff --git a/gcc/testsuite/g++.old-deja/g++.law/pr25000.C b/gcc/testsuite/g++.old-deja/g++.law/pr25000.C new file mode 100644 index 000000000..45d468020 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/pr25000.C @@ -0,0 +1,24 @@ +// { dg-do compile } +// { dg-options "-O2" } +int * f(void); +void g(int*); +bool h(void); +void Find( ) +{ + int * pRes = f(); + if( !pRes ) { + if( h()){ + if( h()){ + try + { + pRes = new int(); + f(); + }catch(int& e1 ){} + } + if( !pRes ) + f(); + } + g(pRes); + } +} + diff --git a/gcc/testsuite/g++.old-deja/g++.law/profile1.C b/gcc/testsuite/g++.old-deja/g++.law/profile1.C new file mode 100644 index 000000000..ecd3b834c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/profile1.C @@ -0,0 +1,12 @@ +// { dg-do run } +// { dg-require-profiling "-pg" } +// { dg-options "-pg" } +// { dg-options "-pg -static" { target hppa*-*-hpux* } } +// GROUPS passed profiling +#include <stdio.h> +main() +{ + printf ("PASS\n"); +} + +/* { dg-final { cleanup-profile-file } } */ diff --git a/gcc/testsuite/g++.old-deja/g++.law/refs1.C b/gcc/testsuite/g++.old-deja/g++.law/refs1.C new file mode 100644 index 000000000..d6dd21c27 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/refs1.C @@ -0,0 +1,43 @@ +// { dg-do run } +// GROUPS passed references +// (Message bugs/refs:1) +// From: tal@vlsi.cs.caltech.edu +// Date: Fri, 25 Feb 94 23:55:50 -0800 +// Subject: g++-2.5.8 produces incorrect code for references +// Message-ID: <9402260755.AA27693@vlsi.cs.caltech.edu> + +#include <stdio.h> + +class C { +private: + const char** list; +public: + C(const char** ); + void count (int&); +}; + +C::C (const char** l) { + list = l; +} + +void C::count (int& total) { + if (*list == NULL) + return; + else { + list++; + count (++total); // THIS IS WHERE THE TROUBLE STARTS + } +} + +const char * foo[] = { + "one", "two", "three", NULL}; + +int main() { + C c(foo); + int i = 0; + c.count(i); + if (i == 3) + printf ("PASS\n"); + else + { printf ("FAIL\n"); return 1; } +} diff --git a/gcc/testsuite/g++.old-deja/g++.law/refs2.C b/gcc/testsuite/g++.old-deja/g++.law/refs2.C new file mode 100644 index 000000000..74bc97225 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/refs2.C @@ -0,0 +1,11 @@ +// { dg-do assemble } +// GROUPS passed references +int func(int& i) +{ + static int& v = i; + return v; +} + +int main() +{ +} diff --git a/gcc/testsuite/g++.old-deja/g++.law/refs3.C b/gcc/testsuite/g++.old-deja/g++.law/refs3.C new file mode 100644 index 000000000..7b9a85bac --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/refs3.C @@ -0,0 +1,6 @@ +// { dg-do assemble } +// GROUPS passed references +const int& min(const int& n, const int& m) +{ + return n < m ? n : m; +} diff --git a/gcc/testsuite/g++.old-deja/g++.law/refs4.C b/gcc/testsuite/g++.old-deja/g++.law/refs4.C new file mode 100644 index 000000000..b87fa69e3 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/refs4.C @@ -0,0 +1,25 @@ +// { dg-do run } +// GROUPS passed references + +// execution test + +int r; + +const int& min(const int& tX, const int& tY) +{ + return tX < tY ? tX : tY; +} + +void foo(const int m, const int n) +{ + if (m == 1 && n == 100) + /* OK */; + else + r = 1; +} + +int main() +{ + foo(min(2, 1), min(100, 200)); + return r; +} diff --git a/gcc/testsuite/g++.old-deja/g++.law/scope1.C b/gcc/testsuite/g++.old-deja/g++.law/scope1.C new file mode 100644 index 000000000..062fc4010 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/scope1.C @@ -0,0 +1,20 @@ +// { dg-do assemble } +// GROUPS passed scoping +// scoping file +// From: kol@world.std.com (Nikolay Yatsenko) +// Date: Fri, 16 Jul 1993 18:48:32 -0400 +// Subject: g++ gives wrong error for local structure +// Message-ID: <199307162248.AA05360@world.std.com> + +int main(void) +{ + struct A{ + public: int i; + void set (int i) + {A::i = i;} // g++ gives wrong error + }; + + A a; + a.set(17); + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.law/scope2.C b/gcc/testsuite/g++.old-deja/g++.law/scope2.C new file mode 100644 index 000000000..13c02c2ae --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/scope2.C @@ -0,0 +1,45 @@ +// { dg-do run } +// GROUPS passed scoping +// scoping file +// From: svkakkad@cs.utexas.edu (Sheetal V. Kakkad) +// Date: Tue, 5 Oct 93 12:38:49 -0500 +// Subject: G++ 2.4.5 - global delete operator not called when using "::delete" +// Message-ID: <9310051738.AA14586@boogie.cs.utexas.edu> + +#include <stdio.h> +#include <stddef.h> +#include <stdlib.h> + +class foo +{ + public: + foo () { ; } + ~foo () { ; } + void *operator new (size_t); + void operator delete (void *); +}; + +void *foo::operator new (size_t size) +{ + return malloc (size); +} + +int overloaded_delete = 0; + +void foo::operator delete (void *data) +{ + free ((char *) data); + overloaded_delete++; +} + +int main () +{ + foo *f = new foo; + foo *ff = ::new foo; + ::delete ff; // should call the default delete operator + delete f; + if (overloaded_delete == 1) + printf ("PASS\n"); + else + { printf ("FAIL\n"); return 1; } +} diff --git a/gcc/testsuite/g++.old-deja/g++.law/scope3.C b/gcc/testsuite/g++.old-deja/g++.law/scope3.C new file mode 100644 index 000000000..5988d19f8 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/scope3.C @@ -0,0 +1,22 @@ +// { dg-do assemble } +// GROUPS passed scoping +// local-class file +// From: dcb@us-es.sel.de +// Date: Fri, 27 Nov 92 15:34:28 +0100 +// Subject: GNU G++ 2.3.1 bug report +// Message-ID: <9211271434.AA15612@us-es.sel.de> + + +void f() +{ + { + struct A { + A() {} + } a; + }; + { + struct A { + A() {} + } a ; + }; +} diff --git a/gcc/testsuite/g++.old-deja/g++.law/scope4.C b/gcc/testsuite/g++.old-deja/g++.law/scope4.C new file mode 100644 index 000000000..dfa73d312 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/scope4.C @@ -0,0 +1,16 @@ +// { dg-do assemble } +// GROUPS passed scoping +// local-class file +// From: daniels@sugar.neosoft.com (Brad Daniels) +// Date: Thu, 5 Aug 93 15:36:36 CDT +// Subject: Bug in g++ 2.4.5: Can't touch nested class identifier inside its members +// Message-ID: <9308051536.AA06115@NeoSoft.Com> + +void f() { + class foo { + int x; + public: + foo() : x(1) {} + int bar() { foo p; return p.x; } + }; +} diff --git a/gcc/testsuite/g++.old-deja/g++.law/scope5.C b/gcc/testsuite/g++.old-deja/g++.law/scope5.C new file mode 100644 index 000000000..34446d88c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/scope5.C @@ -0,0 +1,25 @@ +// { dg-do assemble } +// GROUPS passed scoping +// local-class file +// From: schlaege@methusalix.ert.rwth-aachen.de (Chris Schlaeger H Zivojnovic) +// Date: Tue, 10 Aug 93 16:50:33 +0200 +// Subject: Bug report +// Message-ID: <9308101450.AA28016@methusalix.ert.rwth-aachen.de> + +int main() +{ + class foo + { + int i; + } ; + class bar + { + public: + bar() { y = 0; } + void f() { foo x; } + private: + int y; + } ; + + bar c; +} diff --git a/gcc/testsuite/g++.old-deja/g++.law/shadow1.C b/gcc/testsuite/g++.old-deja/g++.law/shadow1.C new file mode 100644 index 000000000..d13dfe83e --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/shadow1.C @@ -0,0 +1,28 @@ +// { dg-do assemble } +// { dg-options "-Wshadow" } +// GROUPS passed shadow-warnings +// shadow file +// Message-Id: <9211061827.AA03517@harvey> +// From: Jeff Gehlhaar <jbg@qualcomm.com> +// Subject: GCC Bug.. +// Date: Fri, 6 Nov 1992 10:27:10 -0700 + +class Klasse +{ +public: + Klasse(void); // constructor + int Shadow(void); // member function +private: + long value; +}; + +Klasse::Klasse(void) +{ + value = 0; +} + +static inline unsigned char +Function(int Shadow) +{ + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.law/shadow2.C b/gcc/testsuite/g++.old-deja/g++.law/shadow2.C new file mode 100644 index 000000000..46f9dfcc3 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/shadow2.C @@ -0,0 +1,28 @@ +// { dg-do assemble } +// { dg-options "-Wshadow" } +// GROUPS passed shadow-warnings +// (Message bugs/shadow:2) +// From: michael@utex.rni.sub.org (Michael Utech) +// Date: Sat, 22 Jan 1994 04:28:00 +0100 +// Subject: very minor problem/bug in gcc-2.5.4, -Wshadow +// Message-ID: <m0pNZ1T-0008QUC@utex.rni.sub.org> + +class X +{ + int count; +public: + X() {} // necessary to produce the `count' warning +}; + +template <class T> +class Y +{ + T t; +public: + int f (int count) { return (count); } +}; + +main () +{ + Y<char> y; +} diff --git a/gcc/testsuite/g++.old-deja/g++.law/static-mem2.C b/gcc/testsuite/g++.old-deja/g++.law/static-mem2.C new file mode 100644 index 000000000..68623be87 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/static-mem2.C @@ -0,0 +1,27 @@ +// { dg-do assemble } +// GROUPS passed static-mem + +class desc; + +class a_desc { + public: + + static desc the_desc; + + virtual desc *get_desc(); +}; + +class desc : public a_desc { + public: + + static desc the_desc; + + desc(int); + + desc *get_desc(); +}; + + +desc desc::the_desc(1); + +desc a_desc::the_desc(0); diff --git a/gcc/testsuite/g++.old-deja/g++.law/static-mem3.C b/gcc/testsuite/g++.old-deja/g++.law/static-mem3.C new file mode 100644 index 000000000..1c7900b58 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/static-mem3.C @@ -0,0 +1,23 @@ +// { dg-do assemble } +// GROUPS passed static-mem +// static-mem file +// Message-Id: <9406021639.AA00789@oz.NeXT.COM> +// From: Sumana Srinivasan <Sumana_Srinivasan@next.com> +// Date: Thu, 2 Jun 94 09:39:09 -0700 +// Subject: static members function pointers + +class CRTFooBar; + +class CRTFoo { +public: + static const CRTFooBar & defaultFooBar( ); + + CRTFoo( const CRTFoo & ); + CRTFoo( ); + CRTFoo( const char *, + const CRTFooBar &tp = CRTFoo::defaultFooBar(), + int = 0 ); + CRTFoo &setFoo( double, + const CRTFooBar & = CRTFoo::defaultFooBar() ); + +}; diff --git a/gcc/testsuite/g++.old-deja/g++.law/static-mem4.C b/gcc/testsuite/g++.old-deja/g++.law/static-mem4.C new file mode 100644 index 000000000..4e61c6933 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/static-mem4.C @@ -0,0 +1,13 @@ +// { dg-do assemble } +// GROUPS passed static-mem +struct test { + void test_member() { + static test& ds = *this; // FIX: static test* ds = this; + } +}; + + +int main() +{ + test t; +} diff --git a/gcc/testsuite/g++.old-deja/g++.law/static-mem5.C b/gcc/testsuite/g++.old-deja/g++.law/static-mem5.C new file mode 100644 index 000000000..bbc79afae --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/static-mem5.C @@ -0,0 +1,23 @@ +// { dg-do assemble } +// { dg-options "-w -fpermissive" } +// GROUPS passed static-mem +// static-mem file +// From: bunch@tazboy.jpl.nasa.gov (Walt Bunch) +// Date: Thu, 23 Jun 94 14:58:35 UNI +// Subject: bug report +// Message-ID: <9406232258.AA03897@tazboy.JPL.NASA.GOV> + + +class A +{ +public: + static void F (int i) {} + static void A::G (int i) {} +}; + +main () +{ + A::F (17); + A::G (42); +} + diff --git a/gcc/testsuite/g++.old-deja/g++.law/template1.C b/gcc/testsuite/g++.old-deja/g++.law/template1.C new file mode 100644 index 000000000..9b5f56f07 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/template1.C @@ -0,0 +1,30 @@ +// { dg-do assemble } +// GROUPS passed templates + +class String { + char s[100]; +}; + +template <class Element> +class Art { +public: + Element *data; + Art() { data=new Element[100]; } +}; + +template <class Key,class Value> +class Assoc { +public: + struct KeyValue { + Key key; + Value value; + int filled; + }; + + Art<KeyValue> data; + int fill; +}; + +int main() { + Assoc<String,String> table; +} diff --git a/gcc/testsuite/g++.old-deja/g++.law/template3.C b/gcc/testsuite/g++.old-deja/g++.law/template3.C new file mode 100644 index 000000000..271dab0f3 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/template3.C @@ -0,0 +1,17 @@ +// { dg-do assemble } +// GROUPS passed templates +template< class R, class T1 = R, class T2 = T1 > +struct plus + { + R operator()( const T1& x, const T2& y ) const + { + return x + y; + } + }; + +int +main() + { + plus< int > p; + return 0; + } diff --git a/gcc/testsuite/g++.old-deja/g++.law/temps1.C b/gcc/testsuite/g++.old-deja/g++.law/temps1.C new file mode 100644 index 000000000..bd344b419 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/temps1.C @@ -0,0 +1,20 @@ +// { dg-do assemble } +// GROUPS passed temps +// temps file +// Date: Mon, 07 Sep 1992 13:12:28 EDT +// From: richard@ttt.kth.se +// { dg-options "-fpermissive" } +struct foo +{ + char *s; + foo(char *x) { s=x; } +}; + +struct cookie +{ + foo * v; + cookie ( foo * x) { v=x; } +}; + +cookie cat(&foo("apabepa"));// { dg-warning "deprecated conversion" "dep" } +// { dg-warning "taking address of temporary" "add" { target *-*-* } 19 } diff --git a/gcc/testsuite/g++.old-deja/g++.law/temps2.C b/gcc/testsuite/g++.old-deja/g++.law/temps2.C new file mode 100644 index 000000000..b494efd6e --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/temps2.C @@ -0,0 +1,55 @@ +// { dg-do run } +// GROUPS passed temps +// temps file +// Message-Id: <9212181914.AA05066@sparc1.cnm.us.es> +// From: juando@cnm.us.es (Juan Domingo Martin Gomez) +// Subject: Temporaries destroyed too soon +// Date: Fri, 18 Dec 92 20:14:45 +0100 + +#include <stdio.h> + +int status = 0; +int fail = 0; + +class Foo +{ +public: + Foo(); + ~Foo(); + + Foo &method(); +}; + +Foo f1() +{ + return Foo(); +} + +Foo::Foo() +{ +} + +Foo::~Foo() +{ + if (status == 2) + fail = 0; + else + fail = 1; +} + +Foo &Foo::method() +{ + status++; + return *this; +} + +int main() +{ + // f1() returns a temporary object. The member function + // method() returns a reference to the same object. + f1().method().method(); + if (fail) + { printf ("FAIL\n"); return 1; } + else + printf ("PASS\n"); +} diff --git a/gcc/testsuite/g++.old-deja/g++.law/temps3.C b/gcc/testsuite/g++.old-deja/g++.law/temps3.C new file mode 100644 index 000000000..401b00661 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/temps3.C @@ -0,0 +1,29 @@ +// { dg-do run } +// GROUPS passed temps +// temps file +// Message-Id: <9308231535.AA19432@geant.cenatls.cena.dgac.fr> +// From: chatty@geant.cenatls.cena.dgac.fr (Stephane CHATTY) +// Subject: g++ 2.4.5 does not destroy temporaries +// Date: Mon, 23 Aug 93 17:35:34 +0200 + +#include <stdio.h> + +class A { +public: + int a; + A (int i) : a (i) { ;} + A (const A& aa) : a (aa.a) { ;} + ~A () { printf ("PASS\n");; } +}; + +A +foo () +{ + return A (10); +} + +int main () +{ + int x = foo ().a; +} + diff --git a/gcc/testsuite/g++.old-deja/g++.law/temps4.C b/gcc/testsuite/g++.old-deja/g++.law/temps4.C new file mode 100644 index 000000000..3f8c9ed2c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/temps4.C @@ -0,0 +1,40 @@ +// { dg-do run } +// { dg-options "-felide-constructors" } +// GROUPS passed temps +// temps file +// Message-Id: <9311102043.AA22871@ses.com> +// From: jamshid@ses.com (Jamshid Afshar) +// Subject: elide-constructors (aka return value optimization) +// Date: Wed, 10 Nov 93 14:43:54 CST + +#include <stdio.h> +#include <stdlib.h> + +class X { + int i; + public: + X(); + X(const X&); + X(int); + ~X(); +}; + +int did_it = 0; + +X::X() { ; } +X::X(const X&) { did_it = 1; } +X::X(int) { ; } +X::~X() { ; } + +X foo() { + X x(1); + return x; +} + +main() { + X x = foo(); + if (did_it) + abort (); + else + printf ("PASS\n"); +} diff --git a/gcc/testsuite/g++.old-deja/g++.law/temps5.C b/gcc/testsuite/g++.old-deja/g++.law/temps5.C new file mode 100644 index 000000000..e33962e1c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/temps5.C @@ -0,0 +1,42 @@ +// { dg-do run } +// GROUPS passed temps +// temps file +// Message-Id: <9311171029.AA00592@mencon> +// From: gfm@mencon.mencon.oz.au (Graham Menhennitt) +// Subject: gcc 2.5.3 - bug deleting object that is still referred to +// Date: Wed, 17 Nov 93 21:29:23 EST + +#include <stdio.h> + +class C { +public: + C(int i) : val(i) { ; } + C(const C& c) : val(c.val) { ; } + ~C(void) { val = 999; } + C& operator = (const C& c) { val = c.val; return *this; } + + C& inc(int i) { val += i; return *this; } + + int val; +}; + +C +f(void) +{ + return C(3); +} + +C +f(int i) +{ + return f().inc(i); +} + +int +main(void) +{ + if (f (2).val != 5) + { printf ("FAIL\n"); return 1; } + else + printf ("PASS\n"); +} diff --git a/gcc/testsuite/g++.old-deja/g++.law/temps6.C b/gcc/testsuite/g++.old-deja/g++.law/temps6.C new file mode 100644 index 000000000..19a12d740 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/temps6.C @@ -0,0 +1,25 @@ +// { dg-do run } +// GROUPS passed temps +// Date: Tue, 22 Mar 94 12:46:28 +0100 +// From: dak@pool.informatik.rwth-aachen.de +// Message-Id: <9403221146.AA07815@messua> +// Subject: Bad code for pointer to member use as reference in g++ 2.5.8 + +#include <stdio.h> +struct str { + int i; +} xxx = {0}; + +int& test(str *arg1, int str::*arg2) +{ + return (arg1->*arg2); +} + +int main() +{ + test(&xxx, &str::i) = 5; + if (xxx.i == 0) + { printf ("FAIL\n"); return 1; } + else + printf ("PASS\n"); +} diff --git a/gcc/testsuite/g++.old-deja/g++.law/temps7.C b/gcc/testsuite/g++.old-deja/g++.law/temps7.C new file mode 100644 index 000000000..04bf35259 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/temps7.C @@ -0,0 +1,11 @@ +// { dg-do assemble } +// GROUPS passed temps + +template <class B > +class A { +public: + class C {}; +}; + +template class A<int>::C; + diff --git a/gcc/testsuite/g++.old-deja/g++.law/typeck1.C b/gcc/testsuite/g++.old-deja/g++.law/typeck1.C new file mode 100644 index 000000000..12a8ff6e8 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/typeck1.C @@ -0,0 +1,18 @@ +// { dg-do assemble } +// GROUPS passed typeck +// typeck file +// From: vern@daffy.ee.lbl.gov (Vern Paxson) +// Date: 24 Sep 1992 23:11:22 GMT +// Subject: 2.2.2 type-checking error (?) when comparing pointers +// Message-ID: <26475@dog.ee.lbl.gov> + + + class a { }; + class foo : a { }; + class bar : a { }; + + int test( const foo* f, const bar* b ) + { + return f == b;// { dg-error "comparison between distinct pointer types" } + } + diff --git a/gcc/testsuite/g++.old-deja/g++.law/typeck2.C b/gcc/testsuite/g++.old-deja/g++.law/typeck2.C new file mode 100644 index 000000000..e1bb8b584 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/typeck2.C @@ -0,0 +1,16 @@ +// { dg-do assemble } +// GROUPS passed typeck +// typeck file +// From: Jutta Degener <jutta@cs.tu-berlin.de> +// Date: Wed, 9 Jun 1993 17:58:35 +0200 (MET DST) +// Subject: 2.4.3: Type of new <typedef'ed array> +// Message-ID: <199306091558.AA19075@mail.cs.tu-berlin.de> + + typedef int arr[10]; +int main() + { + int * p = new int[10]; + int * q = new arr; /* g++ complains, but shouldn't */ + int (* r)[10] = new arr; /* g++ doesn't complain, but should */// { dg-error "" } + } + diff --git a/gcc/testsuite/g++.old-deja/g++.law/typeck3.C b/gcc/testsuite/g++.old-deja/g++.law/typeck3.C new file mode 100644 index 000000000..38e3d2214 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/typeck3.C @@ -0,0 +1,23 @@ +// { dg-do assemble } +// GROUPS passed typeck +// typeck file +// From: Dror Caspi <dror@fibronics.co.il> +// Date: Wed, 9 Jun 1993 17:43:48 +0300 +// Subject: function typedefs in classes +// Message-ID: <199306091443.AA03735@zorba.fibronics.co.il> + +class a +{ + public: + typedef void (X)(); + + X x; // Member function of type X +}; + +class b +{ + public: + typedef void (X)(); //!!!!!! g++ says : syntax error before `;' + + X x; // Member function of type X +}; diff --git a/gcc/testsuite/g++.old-deja/g++.law/typeck4.C b/gcc/testsuite/g++.old-deja/g++.law/typeck4.C new file mode 100644 index 000000000..21e2d96b4 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/typeck4.C @@ -0,0 +1,21 @@ +// { dg-do assemble } +// GROUPS passed typeck +class A { + public: + const int &operator[]( int i ); + private: + int k; +}; + +const int& A::operator[]( int i ) +{ + return k; +} + + +void ff( A &anA ) +{ + int &ani = anA[0];// { dg-error "" } + + ani = 7; +} diff --git a/gcc/testsuite/g++.old-deja/g++.law/union1.C b/gcc/testsuite/g++.old-deja/g++.law/union1.C new file mode 100644 index 000000000..9d700499d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/union1.C @@ -0,0 +1,29 @@ +// { dg-do assemble } +// GROUPS passed unions +// anon-union file +// From: "Terry R. Coley" <terry@wag.caltech.edu> +// Date: Tue, 25 Aug 1992 17:33:29 -0700 +// Subject: possible bug in gcc/g++ +// Message-ID: <199208260033.AA19417@brahms.wag.caltech.edu> + +typedef enum { BADBINOP = 0, PLUS, MINUS, MULT, DIV, POWR } binoptype; +typedef enum { BADUNOP = 0, NEG = POWR+1, SIN, COS, TAN } unoptype; + +typedef struct { + const char *s; + union { + binoptype bop; + unoptype uop; + }; +} +op_to_charp; + +op_to_charp BINOPS[] = { {"+", PLUS}, + {"-", MINUS}, + {"*", MULT}, + {"/", DIV}, + {"^", POWR} }; + +int main() { + int dummy; +} diff --git a/gcc/testsuite/g++.old-deja/g++.law/union2.C b/gcc/testsuite/g++.old-deja/g++.law/union2.C new file mode 100644 index 000000000..37de9eaf0 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/union2.C @@ -0,0 +1,25 @@ +// { dg-do assemble } +// GROUPS passed unions +// anon-union file +// From: gerlek@dat.cse.ogi.edu (Michael Gerlek) +// Date: Tue, 8 Dec 92 12:56 PST +// Subject: private anonymous unions have public members? (gcc-2.3.1) +// Message-ID: <m0mzByL-0000hoC@dat.cse.ogi.edu> + +class A { +public: + int x; +private: + int y; // { dg-error "" } private + union { + int z; // { dg-error "" } private + }; +}; + +void f() { + A a; + + a.x = 0; + a.y = 1;// { dg-error "" } .* + a.z = 2;// { dg-error "" } +} diff --git a/gcc/testsuite/g++.old-deja/g++.law/union3.C b/gcc/testsuite/g++.old-deja/g++.law/union3.C new file mode 100644 index 000000000..be874339a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/union3.C @@ -0,0 +1,13 @@ +// { dg-do assemble } +// GROUPS passed unions +// anon-union file +// From: dcb@us-es.sel.de (David Binderman 3841) +// Date: Tue, 30 Mar 93 09:06:15 +0200 +// Subject: Page 183 of the ARM +// Message-ID: <9303300706.AA17079@slsvitt> + +static union { + char* uC; +private: + int uI;// { dg-error "" } +}; diff --git a/gcc/testsuite/g++.old-deja/g++.law/union4.C b/gcc/testsuite/g++.old-deja/g++.law/union4.C new file mode 100644 index 000000000..f48ceeea2 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/union4.C @@ -0,0 +1,13 @@ +// { dg-do assemble } +// GROUPS passed unions +// anon-union file +// From: hossein@veritas.com (Hossein Raassi) +// Date: Wed, 15 Dec 93 13:52 PST +// Subject: Internal Error +// Message-ID: <m0pA49A-0000LdC@piano.veritas.com> + +static union { + struct SS { + int ss; + }; +};// { dg-warning "no members" } diff --git a/gcc/testsuite/g++.old-deja/g++.law/unsorted1.C b/gcc/testsuite/g++.old-deja/g++.law/unsorted1.C new file mode 100644 index 000000000..c220d9936 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/unsorted1.C @@ -0,0 +1,31 @@ +// { dg-do assemble } +// { dg-options "-O" } +// GROUPS passed unsorted +// unsorted.2 file +// From: skipnyc!skipsun!skip@fsg.com (Skip Gilbrech) +// Date: Wed, 10 Jun 92 6:55:18 EDT +// Subject: Problem with derived class access adjustment and -O +// Message-ID: <9206101055.AA20593@skipsun.UUCP> + + +class A { + public: + virtual void func() = 0; +}; + +class B : public A { + public: + void func() {} +}; + +class C : private B { + public: + B::func; +}; + +class D { + C c; + public: + void func() { c.func(); } +}; + diff --git a/gcc/testsuite/g++.old-deja/g++.law/unsorted2.C b/gcc/testsuite/g++.old-deja/g++.law/unsorted2.C new file mode 100644 index 000000000..17d9fa4f9 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/unsorted2.C @@ -0,0 +1,26 @@ +// { dg-do assemble } +// GROUPS passed unsorted +// code-gen file +// From: klaus@steinitz.mathematik.uni-dortmund.de +// Date: Mon, 15 Nov 1993 16:51:11 +0100 +// Message-ID: <9311151551.AA17761@steinitz.mathematik.uni-dortmund.de> + +template <int A,int B> +class X +{ +}; + +template <int A,int B,int C> +X<A,C> f(X<A,B>,X<B,C>) +{ + X<A,C> result; + return result; +} + +int main() +{ + X<1,3> x; + X<1,2> y; + X<2,3> z; + x=f(y,z); +} diff --git a/gcc/testsuite/g++.old-deja/g++.law/vbase1.C b/gcc/testsuite/g++.old-deja/g++.law/vbase1.C new file mode 100644 index 000000000..4cfe51d77 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/vbase1.C @@ -0,0 +1,29 @@ +// { dg-do assemble } +// GROUPS passed vbase +// vbase file +// From: pino@hubble.eecs.berkeley.edu (Jose Luis Pino) +// Date: 28 Jul 1994 05:17:39 GMT +// Subject: g++ 2.6 bug: virtual base class & protected methods +// Message-ID: <317f1j$o9c@agate.berkeley.edu> + + +#include <iostream> + +class a { +protected: + virtual void foo() { std::cout << "Class A\n";} +}; + +class b : public virtual a {}; + +class c : public b { +public: + void bar() { b::foo();} +}; + +int main() { + c test; + test.bar(); +} + + diff --git a/gcc/testsuite/g++.old-deja/g++.law/virtual1.C b/gcc/testsuite/g++.old-deja/g++.law/virtual1.C new file mode 100644 index 000000000..9cf6d8e45 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/virtual1.C @@ -0,0 +1,21 @@ +// { dg-do assemble } +// { dg-options "-Woverloaded-virtual" } +// GROUPS passed virtual-warnings +// copy file +// From: gfm@mencon.mencon.oz.au (Graham Menhennitt) +// Date: Thu, 29 Apr 93 20:53:07 EST +// Subject: 4 bugs in g++ 2.3.3 +// Message-ID: <9304291053.AA00090@mencon> + + struct A { + virtual ~A(void); + }; + + struct B { + friend class A; + virtual void f(void); + }; + + struct C : public A { + virtual void f(void); + }; diff --git a/gcc/testsuite/g++.old-deja/g++.law/virtual2.C b/gcc/testsuite/g++.old-deja/g++.law/virtual2.C new file mode 100644 index 000000000..5d7428c1b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/virtual2.C @@ -0,0 +1,32 @@ +// { dg-do run } +// GROUPS passed virtual-functions +// Not in g++ bugs snapshot +// From: grande@isi.edu (Jim Grande) +// Subject: g++ 2.3.3 (HPPA) virt class definition dumps core +// Date: 5 Mar 1993 22:51:14 -0500 +// Message-ID: <23611@venera.isi.edu> + +#include <stdio.h> + +class doubleclass +{ + public: + double d; + doubleclass(double x = 0) { d = x; } +}; + +class test +{ + doubleclass doublec; +}; + +class vderived : virtual public test +{ +}; + +int main() +{ + vderived v; + + printf ("PASS\n"); +} diff --git a/gcc/testsuite/g++.old-deja/g++.law/virtual3.C b/gcc/testsuite/g++.old-deja/g++.law/virtual3.C new file mode 100644 index 000000000..46fa08512 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/virtual3.C @@ -0,0 +1,49 @@ +// { dg-do run } +// GROUPS passed virtual-functions +// virtual file +// From: allan@ramjet.multinet.DE (Allan Brighton) +// Subject: pos. bug in gcc-2.5.2 on hp +// Date: 4 Nov 1993 22:57:36 -0500 +// Message-ID: <9311041820.AA05942@ramjet.multinet.DE> + +#include <iostream> +#include <sstream> + +using namespace std; + +class BugStream : public ostringstream { +public: + BugStream() {} + BugStream& eval(); +}; + + +static struct Eval_ { } eval; +BugStream& operator<<(ostream& os, Eval_); + +BugStream& BugStream::eval() +{ + // make sure str is null terminated + *this << ends; + + // eval the command and set the status + const char* s = str().data(); + cerr << s << endl; + + // reset the stream for the next command + clear(ios::goodbit); + // rdbuf()->freeze(0); + seekp(0); + + return *this; +} + +BugStream& operator<<(ostream& os, Eval_) +{ + return ((BugStream&)os).eval(); +} + +int main() { + BugStream bs; + bs << "PASS" << eval; +} diff --git a/gcc/testsuite/g++.old-deja/g++.law/virtual4.C b/gcc/testsuite/g++.old-deja/g++.law/virtual4.C new file mode 100644 index 000000000..975b6c828 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/virtual4.C @@ -0,0 +1,32 @@ +// { dg-do run } +// GROUPS passed virtual-functions +#include <stdio.h> +#include <stdlib.h> + +int aset = 0; +class A +{ + public: + void Set() { SetProp(); } + virtual void SetProp() { aset++;} +}; + +class B:public A +{ + public: + void SetProp() { if (!aset) { printf ("FAIL\n"); exit (1);} aset--;} +}; + +int main() +{ + A a; + B b; + A *c=new A; + A *d=new B; + + a.Set(); + b.Set(); + c->Set(); + d->Set(); + printf ("PASS\n"); +} diff --git a/gcc/testsuite/g++.old-deja/g++.law/visibility1.C b/gcc/testsuite/g++.old-deja/g++.law/visibility1.C new file mode 100644 index 000000000..1c786feb9 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/visibility1.C @@ -0,0 +1,68 @@ +// { dg-do assemble } +// GROUPS passed visibility +#include <iostream> + + + +class base { +//========== + + void base_priv(const char * n) + { std::cout << "base_priv called from: " << n << "\n"; } + +protected: + + void base_prot(const char * n) + { std::cout << "base_prot called from: " << n << "\n"; } + +public: + + void base_publ(const char * n) + { std::cout << "base_publ called from: " << n << "\n"; } + + void test(const char * n) { base_publ(n); base_prot(n); base_priv(n); } + +}; // class base + + + +class derived : private base { // Make this public, +//============================ // and we don't get an error + +friend void derived_friend(); + +public : + + void test(const char * n) { base_publ(n); base_prot(n);} + +}; // class derived + + + +void +derived_friend() +//-------------- +{ + derived pd; + + pd.base_publ("friend of derived class"); // Compiler error here + pd.base_prot("friend of derived class"); +} + + + +int main(int argc, char *argv[]) +//========================== +{ + base b; + b.base_publ("base class object"); + b.test("member of base class object"); + std::cout << "\n"; + + derived pd; + pd.test("member of derived class object"); + derived_friend(); + 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 new file mode 100644 index 000000000..23505f630 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/visibility10.C @@ -0,0 +1,22 @@ +// { dg-do assemble } +// GROUPS passed visibility + +#include <iostream> + +class base { +public: + void f1 () { std::cout << "f1" << std::endl; } + void f2 () { std::cout << "f2" << std::endl; } +}; + +class deriv : public base { + void base :: f1();// { dg-error "" } .* +}; + +int main () +{ + deriv d; + + d.f2(); +} + diff --git a/gcc/testsuite/g++.old-deja/g++.law/visibility11.C b/gcc/testsuite/g++.old-deja/g++.law/visibility11.C new file mode 100644 index 000000000..051bf33eb --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/visibility11.C @@ -0,0 +1,52 @@ +// { dg-do assemble } +// { dg-options "-w" } +// GROUPS passed visibility +// visibility file +// From: Alan Shepherd <a.shepherd@nexor.co.uk> +// Date: Tue, 22 Jun 1993 14:53:23 +0100 +// Subject: bug with MI in gcc-2.4.5 +// Message-ID: <9659.740757203@nexor.co.uk> + +class A +{ + int a; + +protected: + + virtual void State(int b) { a = b; } + +}; + +class B : public A +{ + char* foo; + +public: + + B(const char*); +}; + +class C : public A +{ + char* foo2; + +public: + + C(const char*); +}; + +class D : public B, public C +{ +public: + D(); +protected: + + virtual void State(int a) + { + B::State(a); + C::State(a); + } +}; + + + diff --git a/gcc/testsuite/g++.old-deja/g++.law/visibility12.C b/gcc/testsuite/g++.old-deja/g++.law/visibility12.C new file mode 100644 index 000000000..4dbb15891 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/visibility12.C @@ -0,0 +1,18 @@ +// { dg-do assemble } +// GROUPS passed visibility +// visibility file +// From: Mark Rawling <Mark.Rawling@mel.dit.csiro.au> +// Date: Wed, 30 Jun 93 15:28:34 +1000 +// Subject: member access rule bug +// Message-ID: <9306300528.AA17185@coda.mel.dit.CSIRO.AU> +struct a { + int aa; // { dg-error "" } private + }; + +class b : private a { + }; + +class c : public b { + int xx(void) { return (aa); } // aa should be invisible// { dg-error "" } .* + }; + diff --git a/gcc/testsuite/g++.old-deja/g++.law/visibility13.C b/gcc/testsuite/g++.old-deja/g++.law/visibility13.C new file mode 100644 index 000000000..025b0b1ef --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/visibility13.C @@ -0,0 +1,110 @@ +// { dg-do assemble } +// GROUPS passed visibility +// visibility file +// From: dinh@cs.ucla.edu (Dinh Le) +// Date: Mon, 12 Jul 93 22:21:06 -0700 +// Subject: class, template and their scoping problem +// Message-ID: <9307130521.AA18312@oahu.cs.ucla.edu> + +#include <iostream> +#include <cassert> + +// --------------- Array.h && Array.cc ------------------ + +using namespace std; + +const int ArraySize = 12; + +template <class Type> +class Array { // { dg-error "" } .struct Array_RC redecl.* +friend class Array_RC; +public: + Array(const Type *ar, int sz) { init(ar,sz); } + virtual ~Array() { delete [] ia; } + virtual void print(ostream& = cout); + virtual Type& operator[](int ix) { return ia[ix]; } +private: + void init(const Type*, int); + int size; + int *ia; +}; + +template <class Type> +ostream& operator<<( ostream& os, Array<Type>& ar ) +{ + ar.print(os); + return os; +} + +template <class Type> +void Array<Type>::print(ostream& os) +{ + const int lineLength = 12; + + os << "( " << size << " )< "; + for (int ix = 0; ix < size; ++ix) { + if (ix % lineLength == 0 && ix) os << "\n\t"; + os << ia[ ix ]; + + if (ix % lineLength != lineLength-1 && + ix != size-1) + os << ", "; + } + os << " >\n"; +} + +template <class Type> +void Array<Type>::init(const Type *array, int sz) +{ + ia = new Type[size = sz]; + + for (int ix = 0; ix < size; ++ix) + ia[ix] = (array!=0) ? array[ix] : (Type)0; +} + +// --------------- Array_RC.h && Array_RC.cc ---------------- + +template <class Type> +class Array_RC : public Array<Type> { +public: + Array_RC(const Type *ar, int sz); + Type& operator[](int ix); +}; + +template <class Type> +Array_RC<Type>::Array_RC(const Type *ar, int sz) : Array<Type>(ar, sz) {} + +template <class Type> +Type &Array_RC<Type>::operator[](int ix) { + assert(ix >= 0 && ix < size);// { dg-error "" } member .size.* + return ia[ix];// { dg-error "" } member .ia.* +} + +// ------------------- Test routine ---------------------- + +template <class Type> +void try_array( Array<Type> &iA ) +{ + cout << "try_array: initial array values:\n"; + cout << iA << endl; +} + +template <class Type> +inline void +try_array( Array_RC<Type> &rc ) +{ + try_array( ((Array<Type>&)rc) ); +} + +int main() +{ + static int ia[10] = { 12, 7, 14, 9, 128, 17, 6, 3, 27, 5 }; + Array_RC<int> iA(ia, 10); + + cout << "template Array_RC class" << endl; + try_array(iA); + + return 0; +} + +template class Array_RC<int>; diff --git a/gcc/testsuite/g++.old-deja/g++.law/visibility14.C b/gcc/testsuite/g++.old-deja/g++.law/visibility14.C new file mode 100644 index 000000000..24cfdcc25 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/visibility14.C @@ -0,0 +1,21 @@ +// { dg-do assemble } +// GROUPS passed visibility +// visibility file +// From: ajp@eng.cam.ac.uk +// Date: Tue, 13 Jul 93 17:15:11 BST +// Message-ID: <1171.9307131615@ace.eng.cam.ac.uk + +class A { + static A* list; + + protected: + struct AA { + AA(); + ~AA(); + }; +}; + +A::AA::~AA() +{ + A* d=list; +} diff --git a/gcc/testsuite/g++.old-deja/g++.law/visibility15.C b/gcc/testsuite/g++.old-deja/g++.law/visibility15.C new file mode 100644 index 000000000..434d7da92 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/visibility15.C @@ -0,0 +1,25 @@ +// { dg-do assemble } +// GROUPS passed visibility +// visibility file +// From: wpsun4!xinforms!johnjo@uunet.uu.net (John D. Johnson) +// Date: Wed, 4 Aug 93 13:25:25 MDT +// Subject: Access to private 'operator new()' +// Message-ID: <9308041925.AA09825@xinforms.wpunix +#include <stdio.h> +#include <sys/types.h> + +class X { +private: + void* operator new(size_t) throw(){// { dg-error "" } .* + printf("Inside private new().\n"); + return NULL; + } +public: + X() {} +}; + + +int main(void) +{ + X* p = new X;// { dg-error "" } .* +} diff --git a/gcc/testsuite/g++.old-deja/g++.law/visibility16.C b/gcc/testsuite/g++.old-deja/g++.law/visibility16.C new file mode 100644 index 000000000..e4b3bf854 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/visibility16.C @@ -0,0 +1,35 @@ +// { dg-do assemble } +// GROUPS passed visibility +// visibility file +// From: Marie Trapp <Marie.Trapp@analog.com> +// Date: Thu, 5 Aug 93 11:55:15 EDT +// Subject: access of protected members +// Message-ID: <9308051553.AA07639@nwd2sun1.analog.com> +class A { + protected: + int astuff; // { dg-error "" } protected + A() { + astuff = 3; + } +}; + +class B : public A { + int bstuff; + public: + B( A *p) { + bstuff = p->astuff;// { dg-error "" } .* + } +}; + +class C : public A { + int cstuff; + public: + C() { + cstuff = 5; + } +}; + +int main() { + C cvar; + B bvar(&cvar); +} diff --git a/gcc/testsuite/g++.old-deja/g++.law/visibility17.C b/gcc/testsuite/g++.old-deja/g++.law/visibility17.C new file mode 100644 index 000000000..67ef8927a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/visibility17.C @@ -0,0 +1,66 @@ +// { dg-do assemble } +// GROUPS passed visibility +// visibility file +// From: Sandeep Shroff <ss@caere.com> +// Date: Thu, 05 Aug 1993 17:23:20 -0700 +// Subject: Access to private constructor. +// Message-ID: <9308060023.AA10283@neptune.caere.com> +#include <iostream> +#include <cstring> + +class Base +{ +public: + char* getName() {return name_;} + +private: + Base(); + Base(char* str); + + char* name_; +}; + +class Derived : public Base +{ +public: + Derived(int n, char* str); + Derived(int n); + + int getNum() {return num_;} +private: + int num_; +}; + +Base::Base() // { dg-error "is private" } +{ + name_ = std::strcpy(new char[std::strlen(" ") + 1], " "); +} + +Base::Base(char* str) // { dg-error "is private" } +{ + if(str != NULL) + name_ = std::strcpy(new char[std::strlen(str) + 1], str); +} + +Derived::Derived(int n, char* str) : Base(str) // { dg-error "within this context" } +{ + num_ = n; +} + +Derived::Derived(int n) : Base() // { dg-error "within this context" } +{ + num_ = n; +} + + + +int main() +{ + // Derived* d = new Derived(10, "test"); + Derived* d = new Derived(10); + + std::cerr << d->getNum() << "\t" << d->getName() << std::endl; +} + + + diff --git a/gcc/testsuite/g++.old-deja/g++.law/visibility18.C b/gcc/testsuite/g++.old-deja/g++.law/visibility18.C new file mode 100644 index 000000000..cf67c2dcc --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/visibility18.C @@ -0,0 +1,20 @@ +// { dg-do assemble } +// GROUPS passed visibility +// visibility file +// From: cmwang@iis.sinica.edu.tw (Chien-Min Wang) +// Date: Fri, 6 Aug 93 19:42:31 CST +// Subject: A bug in g++ 2.4.5 +// Message-ID: <9308061142.AA08533@iiserv> +struct T1 { int i; }; + +struct T2 { int j; }; // { dg-error "" } private + +struct T3 : public T1, private T2 { +} x; + +int main () +{ + x.i = 1; + x.j = 2; // error: x.j is private// { dg-error "" } .* + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.law/visibility19.C b/gcc/testsuite/g++.old-deja/g++.law/visibility19.C new file mode 100644 index 000000000..f2bb302ca --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/visibility19.C @@ -0,0 +1,40 @@ +// { dg-do assemble } +// GROUPS passed visibility +// visibility file +// From: mclaugh@tnt.acsys.com (Mark A. McLaughlin) +// Date: Wed, 25 Aug 93 14:30:47 MDT +// Subject: g++ bug +// Message-ID: <9308252030.AA02352@tnt.acsys.com> +class B { +protected: + int i; // { dg-error "" } protected +}; + +class D1 : public B { +}; + +class D2 : public B { + friend void fr(B*,D1*,D2*); + void mem(B*,D1*); +}; + +void fr(B* pb, D1* p1, D2* p2) +{ + pb->i = 1; // illegal// { dg-error "" } .* + p1->i = 2; // illegal// { dg-error "" } .* + p2->i = 3; // ok (access through D2) +} + +void D2::mem(B* pb, D1* p1) +{ + pb->i = 1; // illegal// { dg-error "" } .* + p1->i = 2; // illegal// { dg-error "" } .* + i = 3; // ok (access through `this') +} + +void g(B* pb, D1* p1, D2* p2) +{ + pb->i = 1; // illegal// { dg-error "" } .* + p1->i = 2; // illegal// { dg-error "" } .* + p2->i = 3; // illegal// { dg-error "" } .* +} diff --git a/gcc/testsuite/g++.old-deja/g++.law/visibility2.C b/gcc/testsuite/g++.old-deja/g++.law/visibility2.C new file mode 100644 index 000000000..539169639 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/visibility2.C @@ -0,0 +1,68 @@ +// { dg-do assemble } +// GROUPS passed visibility +#include <iostream> + + + +class base { +//========== + + void base_priv(const char * n) + { std::cout << "base_priv called from: " << n << "\n"; } + +protected: + + void base_prot(const char * n) + { std::cout << "base_prot called from: " << n << "\n"; } + +public: + + void base_publ(const char * n) + { std::cout << "base_publ called from: " << n << "\n"; } + + void test(const char * n) { base_publ(n); base_prot(n); base_priv(n); } + +}; // class base + + + +class derived : public base { // Make this public, +//============================ // and we don't get an error + +friend void derived_friend(); + +public : + + void test(const char * n) { base_publ(n); base_prot(n);} + +}; // class derived + + + +void +derived_friend() +//-------------- +{ + derived pd; + + pd.base_publ("friend of derived class"); // Compiler error here + pd.base_prot("friend of derived class"); +} + + + +int main(int argc, char *argv[]) +//========================== +{ + base b; + b.base_publ("base class object"); + b.test("member of base class object"); + std::cout << "\n"; + + derived pd; + pd.test("member of derived class object"); + derived_friend(); + std::cout << "\n"; + +} /* main */ + diff --git a/gcc/testsuite/g++.old-deja/g++.law/visibility20.C b/gcc/testsuite/g++.old-deja/g++.law/visibility20.C new file mode 100644 index 000000000..0560523bf --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/visibility20.C @@ -0,0 +1,36 @@ +// { dg-do assemble } +// GROUPS passed visibility +// visibility file +// From: doug@foxtrot.ccmrc.ucsb.edu (Douglas Scott) +// Date: Tue, 10 Aug 93 10:06:33 PDT +// Subject: G++ 2.4.5 allows access to protected base members +// Message-ID: <9308101706.AA04485@foxtrot.ccmrc.ucsb.edu> + +class Base { +protected: + void protectedBaseFunction() {} // { dg-error "" } protected +public: + Base() {} +}; + + +class Derived : public Base { +public: + Derived() {} + void noticeThisFunction(Base *); +}; + + +void +Derived::noticeThisFunction(Base *b) { + b->protectedBaseFunction(); // ARM says this is not allowed// { dg-error "" } .* + // since it is not called on 'this' +} + +int main() { + Base b; + Derived d; + d.noticeThisFunction(&b); + printf("gpptest run\n");// { dg-error "" } .* +} + diff --git a/gcc/testsuite/g++.old-deja/g++.law/visibility21.C b/gcc/testsuite/g++.old-deja/g++.law/visibility21.C new file mode 100644 index 000000000..6a57783c6 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/visibility21.C @@ -0,0 +1,17 @@ +// { dg-do assemble } +// GROUPS passed visibility +// visibility file +// From: klamer@mi.el.utwente.nl (Klamer Schutte) +// Date: Thu, 12 Aug 93 12:03:09 +0200 +// Subject: g++ 2.4.5 failed to report a bug +// Message-ID: <9308121003.AA02294@mi.el.utwente.nl> +class A { +protected: + void foo(); // { dg-error "" } protected +}; + +class B : public A +{ + void bar(A &a) + { a.foo(); }// { dg-error "" } .* +}; diff --git a/gcc/testsuite/g++.old-deja/g++.law/visibility22.C b/gcc/testsuite/g++.old-deja/g++.law/visibility22.C new file mode 100644 index 000000000..f97ef8147 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/visibility22.C @@ -0,0 +1,25 @@ +// { dg-do assemble } +// GROUPS passed visibility +// visibility file +// From: Robert Carden <carden@thoth.ics.uci.edu> +// Date: Thu, 12 Aug 1993 13:48:05 -0700 +// Subject: bug 8/12/93 -- #5 +// Message-ID: <9308121348.aa26256@Paris.ics.uci.edu> + +// 5.cc +#include <iostream> + +class A { + int x; +public: + void f(int); + void f(float); + void g(void *); +}; + +class B : private A { +protected: + A::f; +public: + A::g; +}; diff --git a/gcc/testsuite/g++.old-deja/g++.law/visibility24.C b/gcc/testsuite/g++.old-deja/g++.law/visibility24.C new file mode 100644 index 000000000..3acd83707 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/visibility24.C @@ -0,0 +1,40 @@ +// { dg-do assemble } +// GROUPS passed visibility +// visibility file +// From: joe@consolve.com (Joe Shapiro) +// Date: Fri, 20 Aug 93 17:18:18 EDT +// Subject: Template classes seem to allow users to get at private members +// Message-ID: <9308202118.AA25599@ghana.consolve> +/* + * private.cc + */ +extern "C" int printf (const char *, ...); + +template <class T> +class A +{ +public: + void Fun() { printf( "Fun fun fun!\n" ); } // { dg-error "" } private +}; + + +template <class T> +class B: private A<T> +{ +}; + + +class C +{ +public: + C() { _b.Fun(); }// { dg-error "" } .* + +private: + B<int> _b; +}; + + +int main() +{ + C c; +} diff --git a/gcc/testsuite/g++.old-deja/g++.law/visibility25.C b/gcc/testsuite/g++.old-deja/g++.law/visibility25.C new file mode 100644 index 000000000..167436d00 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/visibility25.C @@ -0,0 +1,26 @@ +// { dg-do assemble } +// GROUPS passed visibility +// visibility file +// From: gfm@mencon.mencon.oz.au (Graham Menhennitt) +// 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> + +class A { +public: + A(void); +}; + +class B : private A { +public: + B(void) : A() {} +}; + +class C : public B { +public: + C(void) : B(), a() {} + +private: + ::A a; +}; diff --git a/gcc/testsuite/g++.old-deja/g++.law/visibility26.C b/gcc/testsuite/g++.old-deja/g++.law/visibility26.C new file mode 100644 index 000000000..cfef2df50 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/visibility26.C @@ -0,0 +1,18 @@ +// { dg-do assemble } +// GROUPS passed visibility +// visibility file +// From: jamshid@ses.com (Jamshid Afshar) +// Date: Sun, 12 Dec 93 03:09:15 CST +// Subject: Missed access declaration error +// Message-ID: <9312120909.AA22135@ses.com> + +class X { + public: + void f(); +}; + +class Y : private X { + public: + void f(int); + X::f; // used to be an error; now equivalent to 'using X::f' +}; diff --git a/gcc/testsuite/g++.old-deja/g++.law/visibility27.C b/gcc/testsuite/g++.old-deja/g++.law/visibility27.C new file mode 100644 index 000000000..2d41b67aa --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/visibility27.C @@ -0,0 +1,19 @@ +// { dg-do assemble } +// GROUPS passed visibility +// visibility file +// From: jbuck@synopsys.com (Joe Buck) +// Date: 3 Aug 1994 01:52:04 GMT +// Subject: 2.6.0 bug with protected members and virtual baseclasses +// Message-ID: <31mt84$lfq@hermes.synopsys.com> + +struct R { +protected: + virtual void foo(); +}; + +struct A : public R { +}; + +struct B : virtual public A { + void bletch() { foo();} +}; diff --git a/gcc/testsuite/g++.old-deja/g++.law/visibility28.C b/gcc/testsuite/g++.old-deja/g++.law/visibility28.C new file mode 100644 index 000000000..a7141ae5e --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/visibility28.C @@ -0,0 +1,24 @@ +// { dg-do assemble } +// GROUPS passed visibility +extern "C" int printf( const char *, ...); + +class B { +public: + B() { } + virtual ~B() { printf( "B::~B\n"); } +}; + +class D : public B { +public: + virtual ~D() { printf( "D::~D\n"); } + void operator = ( int i) { this->~B(); } +}; + +int +main() +{ + D * pd = new D; + B * pb = pd; + delete pb; + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.law/visibility3.C b/gcc/testsuite/g++.old-deja/g++.law/visibility3.C new file mode 100644 index 000000000..64d64df64 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/visibility3.C @@ -0,0 +1,22 @@ +// { dg-do assemble } +// GROUPS passed visibility +// visibility file +// From: kol@world.std.com (Nikolay Yatsenko) +// Date: Wed, 27 Jan 1993 16:39:00 -0500 +// Subject: g++ bug +// Message-ID: <199301272139.AA25442@world.std.com> + +int x; + +int main(void) +{ + static int s; + int x; // { dg-error "" } declared + extern int g(); + + struct local { + int g() { return x; } // illegal (non-static x); g++ does not give error// { dg-error "" } + int h() { return s; } // ok, but g++ give error + }; + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.law/visibility4.C b/gcc/testsuite/g++.old-deja/g++.law/visibility4.C new file mode 100644 index 000000000..7f346058b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/visibility4.C @@ -0,0 +1,25 @@ +// { dg-do assemble } +// GROUPS passed visibility +// visibility file +// From: dcb@us-es.sel.de (David Binderman 3841) +// Date: Tue, 30 Mar 93 15:48:47 +0200 +// Subject: page 242 of the ARM +// Message-ID: <9303301348.AA20751@slsvitt> + +class A { +public: + int b; // { dg-error "" } private +}; + +class C : private A { // NOTE WELL. private, not public +public: + int d; +}; + +extern "C" int printf( const char *, ...); + +class E : public C { + void f() { + printf( "%d\n", b);// { dg-error "" } .* + } +}; diff --git a/gcc/testsuite/g++.old-deja/g++.law/visibility5.C b/gcc/testsuite/g++.old-deja/g++.law/visibility5.C new file mode 100644 index 000000000..d8e73e7c9 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/visibility5.C @@ -0,0 +1,17 @@ +// { dg-do assemble } +// GROUPS passed visibility + +class a { + +private: + a (int i);// { dg-error "" } .* + +public: + a (); +}; + +void test () +{ + a *ap = new a; + a *ap2 = new a (3);// { dg-error "" } .* +} diff --git a/gcc/testsuite/g++.old-deja/g++.law/visibility6.C b/gcc/testsuite/g++.old-deja/g++.law/visibility6.C new file mode 100644 index 000000000..927479263 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/visibility6.C @@ -0,0 +1,23 @@ +// { dg-do assemble } +// GROUPS passed visibility +// visibility file +// From: Rob Hasker <hasker@sparc0a.cs.uiuc.edu> +// Date: Sat, 3 Apr 1993 13:19:05 -0600 +// Subject: no privacy +// Message-ID: <199304031919.AA20554@sparc17.cs.uiuc.edu +class Top { +public: + Top() {} + void val() {} // { dg-error "" } private base class +}; + +class Derived : private Top { +public: + Derived() {} +}; + +class Unrelated { + Derived derived; +public: + void oops() { derived.val(); }// { dg-error "" } .* +}; diff --git a/gcc/testsuite/g++.old-deja/g++.law/visibility7.C b/gcc/testsuite/g++.old-deja/g++.law/visibility7.C new file mode 100644 index 000000000..ed37f5f8d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/visibility7.C @@ -0,0 +1,73 @@ +// { dg-do assemble } +// GROUPS passed visibility +// visibility file +// From: Gordon Joly <G.Joly@cs.ucl.ac.uk> +// 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> + +class A { + private: + int number; + public: + A(int i) : number(i) + {} + virtual ~A() + {} + virtual void Number(int c) // { dg-error "inaccessible" } + { number = c; } + virtual int Number() // { dg-error "inaccessible" } + { return number; } +}; + +class B : private A { + private: + int second_number; + public: + B(int c, int i) : second_number(c), A(i) + {} + virtual ~B() + {} + + virtual void firstNumber(int b) // renames member function Number(int) of class A + { A::Number(b); } + virtual int firstNumber() // renames member function Number() of class A + { return A::Number(); } +}; + + + + +class C { + private: + B* bobject; + public: + C(B* bp) : bobject(bp) + {} + virtual ~C() + {} + // + // the following two functions access + // private member functions of class B + // and they should not be able to do so + // + virtual void setBValue(int i) + { if (bobject) bobject->Number(i); } // { dg-error "this context|accessible base" } + virtual int getBValue() + { if (bobject) { return bobject->Number(); } return 0; } // { dg-error "this context|accessible base" } +}; + + +int main() +{ + B* bobject = new B(2, 1); + C* cobject = new C(bobject); + cobject->setBValue(8); + std::cout << cobject->getBValue() << std::endl; + delete bobject; + delete cobject; +} + + + diff --git a/gcc/testsuite/g++.old-deja/g++.law/visibility8.C b/gcc/testsuite/g++.old-deja/g++.law/visibility8.C new file mode 100644 index 000000000..17a3cf8c0 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/visibility8.C @@ -0,0 +1,26 @@ +// { dg-do assemble } +// GROUPS passed visibility +// visibility file +// From: roland@jts.com (Roland Knight ) +// Date: Thu, 29 Apr 1993 16:17:00 -0400 +// Subject: gcc 2.3.3 bug +// Message-ID: <m0nof3E-0021ifC@jts.com +class t1 { +protected: + int a; // { dg-error "" } protected +}; + + +class t2 : private t1 { +public: + int b; +}; + + +class t3 : public t2 { +public: + int ttt(); +}; + + +int t3::ttt() { return a; }// { dg-error "" } .* diff --git a/gcc/testsuite/g++.old-deja/g++.law/visibility9.C b/gcc/testsuite/g++.old-deja/g++.law/visibility9.C new file mode 100644 index 000000000..05e7a2238 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/visibility9.C @@ -0,0 +1,22 @@ +// { dg-do assemble } +// GROUPS passed visibility +// visibility file +// rom: roland@jts.com (Roland Knight ) +// Date: Sat, 8 May 1993 17:27:35 -0400 +// Subject: gcc 2.3.3 protected member access bug +// Message-ID: <9305082127.AA19577@icepick.jts.com> + +class A { +protected: + int a; // { dg-error "" } protected +}; + +class B : public A { +public: + void f1(A* pa); +}; + + +void B::f1(A* pa) { + pa->a = 1; // illegal but allowed by gcc// { dg-error "" } .* +} diff --git a/gcc/testsuite/g++.old-deja/g++.law/vtable1.C b/gcc/testsuite/g++.old-deja/g++.law/vtable1.C new file mode 100644 index 000000000..a4c1ce994 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/vtable1.C @@ -0,0 +1,27 @@ +// { dg-do assemble } +// { dg-options "-w" } +// GROUPS passed vtable +// vtable file +// From: mrs@cygnus.com (Mike Stump) +// Date: Wed, 20 Apr 1994 17:46:11 -0700 +// Subject: vtable name generation is wrong +// Message-ID: <199404210046.RAA25652@rtl.cygnus.com> + +// prepare_fresh_vtable doesn't build the names of +// vtables very well. + +struct B { + virtual void vf() { } +}; + +struct Main { + virtual void vf() { } +}; + +struct Other : public Main, public B { + virtual void vf() { } +}; + +struct D : public Main, public B, public Other { + virtual void vf() { } +} a; diff --git a/gcc/testsuite/g++.old-deja/g++.law/vtable2.C b/gcc/testsuite/g++.old-deja/g++.law/vtable2.C new file mode 100644 index 000000000..fcd3a65a1 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/vtable2.C @@ -0,0 +1,18 @@ +// { dg-do assemble } +// GROUPS passed vtable +struct C1 +{ + virtual ~C1(); +}; + +struct C2 : public virtual C1 +{ + virtual ~C2(); +}; + +struct C3 : public virtual C2 +{ + virtual ~C3(); +}; + +C3::~C3() {} diff --git a/gcc/testsuite/g++.old-deja/g++.law/vtable3.C b/gcc/testsuite/g++.old-deja/g++.law/vtable3.C new file mode 100644 index 000000000..fc837174a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/vtable3.C @@ -0,0 +1,25 @@ +// { dg-do run } +// GROUPS passed vtable +// vtable file +// From: Pete Bevin <pete@deng.icl.co.uk> +// Date: Mon, 28 Nov 1994 19:57:53 +0000 (GMT) +// Subject: g++-2.6.2: Virtual inheritance causes incorrect padding +// Message-ID: <Pine.SOL.3.91.941128194453.7510A-100000@gabriel> + +extern "C" int printf (const char *, ...); + +struct A { +}; + + +struct B : virtual A { + public: + int b; +}; + + +int main() +{ + B blist[10]; + printf ("PASS\n"); +} diff --git a/gcc/testsuite/g++.old-deja/g++.law/weak.C b/gcc/testsuite/g++.old-deja/g++.law/weak.C new file mode 100644 index 000000000..99a0f1772 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.law/weak.C @@ -0,0 +1,20 @@ +// { dg-do link { target i?86-*-linux* x86_64-*-linux* } } +// { dg-require-effective-target static } +// { dg-options "-static" } +// Bug: g++ fails to instantiate operator<<. + +// 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> +#include <streambuf> +#include <cstdio> + +std::istream x (0); + +main () { + x.get(); + std::putc(0, 0); + std::fgets(0, 0, 0); + x.get((char*) 0, 0); +} + diff --git a/gcc/testsuite/g++.old-deja/g++.martin/access1.C b/gcc/testsuite/g++.old-deja/g++.martin/access1.C new file mode 100644 index 000000000..9927b7156 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.martin/access1.C @@ -0,0 +1,12 @@ +// { dg-do assemble } +class A{ + public: + enum Foo{f1,f2}; + + class B{ + friend class A; + Foo f; + public: + B():f(f1){} + }; +}; diff --git a/gcc/testsuite/g++.old-deja/g++.martin/ambig1.C b/gcc/testsuite/g++.old-deja/g++.martin/ambig1.C new file mode 100644 index 000000000..1ccc217a4 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.martin/ambig1.C @@ -0,0 +1,22 @@ +// { dg-do assemble } +//Based on a report by Bill Currie <bcurrie@tssc.co.nz> +struct foo { + protected: + int x; // { dg-error "" } candidate +}; + +struct bar { + public: + int x(); // { dg-error "" } candidate +}; + +struct foobar: public foo, public bar { + foobar(); +}; + +int func(int); + +foobar::foobar() +{ + func(x); // { dg-error "" } ambiguous member access +} diff --git a/gcc/testsuite/g++.old-deja/g++.martin/bitset1.C b/gcc/testsuite/g++.old-deja/g++.martin/bitset1.C new file mode 100644 index 000000000..c8be0bf88 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.martin/bitset1.C @@ -0,0 +1,10 @@ +// { dg-do run } +// Origin: Jeff Donner <jdonner@schedsys.com> +#include <bitset> + +int main() +{ + std::bitset<sizeof(int) * 8> bufWord; + + bufWord[3] = 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.martin/conv1.C b/gcc/testsuite/g++.old-deja/g++.martin/conv1.C new file mode 100644 index 000000000..552e47b46 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.martin/conv1.C @@ -0,0 +1,14 @@ +// { dg-do run } +struct S{ + operator bool() + { + return true; + } +}; + +int main() +{ + S a; + if (S &b = a); +} + diff --git a/gcc/testsuite/g++.old-deja/g++.martin/crash1.C b/gcc/testsuite/g++.old-deja/g++.martin/crash1.C new file mode 100644 index 000000000..5a81d7ed8 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.martin/crash1.C @@ -0,0 +1,15 @@ +// { dg-do assemble } +int i = 4; +struct S{ + char c[i]; // { dg-error "" } size not constant + int h; + int foo(){ + return h; + } +}; + +int main() +{ + S x; + int i = x.foo(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.martin/eval1.C b/gcc/testsuite/g++.old-deja/g++.martin/eval1.C new file mode 100644 index 000000000..e3eb3d6be --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.martin/eval1.C @@ -0,0 +1,21 @@ +// { dg-do run } +// Postfix expression must be evaluated even if accessing a static member. + +struct S +{ + static int i; + S* foo(); +}; + +S* S::foo(){ + i = 0; + return this; +} + +int S::i = 1; +int main(void) +{ + S * s = new S; + int k=(s->foo())->i; + return k; +} diff --git a/gcc/testsuite/g++.old-deja/g++.martin/lookup1.C b/gcc/testsuite/g++.old-deja/g++.martin/lookup1.C new file mode 100644 index 000000000..cb5eb07c9 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.martin/lookup1.C @@ -0,0 +1,22 @@ +// { dg-do assemble } +//In the base class list, the context of the current is used +//reported by Stephen Vavasis <vavasis@CS.Cornell.EDU> + +namespace N1 { + namespace N2 { + class A{}; + class B; + } +} + +class N1::N2::B : public A { +}; + + +class C1 { + class A{}; + class B; +}; + +class C1::B : A { +}; diff --git a/gcc/testsuite/g++.old-deja/g++.martin/new1.C b/gcc/testsuite/g++.old-deja/g++.martin/new1.C new file mode 100644 index 000000000..502c4f42a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.martin/new1.C @@ -0,0 +1,122 @@ +// { dg-do run } +//Lifetime of temporaries: +//egcs 2.92 performs cleanup for temporaries inside new expressions +//after the new is complete, not at the end of the full expression. + +#include <new> +#include <cstdlib> +#include <cstdio> + +bool new_throws; +bool ctor_throws; + +int new_done; +int ctor_done; +int func_done; +int dtor_done; +int delete_done; + +int count; + +void init() +{ + new_throws = ctor_throws = false; + new_done = ctor_done = func_done = dtor_done = delete_done = count = 0; +} + +struct line_error{ + int line; + line_error(int i):line(i){} +}; + +#define CHECK(cond) if(!(cond))throw line_error(__LINE__); + +struct A{ + A(int){ + ctor_done = ++count; + if(ctor_throws) + throw 1; + } + A(const A&){ + CHECK(false); //no copy constructors in this code + } + ~A(){ + dtor_done = ++count; + } + A* addr(){return this;} +}; + +struct B{ + B(A*){} + void* operator new(size_t s){ + new_done = ++count; + if(new_throws) + throw 1; + return malloc(s); + } + void operator delete(void *){ + delete_done = ++count; + } +}; + +void func(B* ) +{ + func_done = ++count; +} + +void test1() +{ + init(); + try{ + func(new B(A(10).addr())); + }catch(int){ + } + CHECK(ctor_done==1); + CHECK(new_done==2); + CHECK(func_done==3); + CHECK(dtor_done==4); + CHECK(delete_done==0); +} + +void test2() +{ + init(); + new_throws = true; + try{ + func(new B(A(10).addr())); + }catch(int){ + } + CHECK(ctor_done==1); + CHECK(new_done==2); + CHECK(func_done==0); + CHECK(dtor_done==3); + CHECK(delete_done==0); +} + +void test3() +{ + init(); + ctor_throws = true; + try{ + func(new B(A(10).addr())); + }catch(int){ + } + CHECK(new_done==0); + CHECK(ctor_done==1); + CHECK(func_done==0); + CHECK(dtor_done==0); + CHECK(delete_done==0); +} + +int main() +{ + try{ + test1(); + test2(); + test3(); + }catch(line_error e){ + printf("Got error in line %d\n",e.line); + return 1; + } + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.martin/overload1.C b/gcc/testsuite/g++.old-deja/g++.martin/overload1.C new file mode 100644 index 000000000..782c8bf4e --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.martin/overload1.C @@ -0,0 +1,13 @@ +// { dg-do run } +//Overload resolution should consider both declarations of func identically. + +struct S{}; +void func(S&){} + +int main() +{ + void func(S&); + S s; + func(s); +} + diff --git a/gcc/testsuite/g++.old-deja/g++.martin/pmf1.C b/gcc/testsuite/g++.old-deja/g++.martin/pmf1.C new file mode 100644 index 000000000..108754b28 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.martin/pmf1.C @@ -0,0 +1,19 @@ +// { dg-do run } +// Based on a test case by Andrew Bell <andrew.bell@bigfoot.com> +// Check for pointer-to-virtual-function calls on +// bases without virtual functions. + +struct B{}; + +struct D: public B{ + virtual void foo(); +}; + +void D::foo(){} + +int main() +{ + B *b = new D; + void (B::*f)() = static_cast<void (B::*)()>(&D::foo); + (b->*f)(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.martin/pmf2.C b/gcc/testsuite/g++.old-deja/g++.martin/pmf2.C new file mode 100644 index 000000000..e52ce9f61 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.martin/pmf2.C @@ -0,0 +1,22 @@ +// { dg-do run } +// { dg-options "-Wno-pmf-conversions" } +// Test conversion of pointers to virtual member functions to +// pointers to non-member functions. + +struct A{ + int i; + A () :i(1){} + virtual void foo(); +}a; + +void A::foo() +{ + i = 0; +} + +int main() +{ + void (*f)(A*) = (void(*)(A*))(&A::foo); + f(&a); + return a.i; +} diff --git a/gcc/testsuite/g++.old-deja/g++.martin/pure1.C b/gcc/testsuite/g++.old-deja/g++.martin/pure1.C new file mode 100644 index 000000000..f19ff0ab7 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.martin/pure1.C @@ -0,0 +1,8 @@ +// { dg-do assemble } +class A +{ + public: + virtual void f(void) = 0; // pure virtual function. + A() {f();} // { dg-warning "const" } called in a constructor + ~A() {f();} // { dg-warning "destr" } called in a destructor +}; diff --git a/gcc/testsuite/g++.old-deja/g++.martin/sts_conv.C b/gcc/testsuite/g++.old-deja/g++.martin/sts_conv.C new file mode 100644 index 000000000..93cad839f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.martin/sts_conv.C @@ -0,0 +1,20 @@ +// { dg-do run } +// ecgs-bugs 1999-02-22 14:21, Stefan Schwarzer +// sts@ica1.uni-stuttgart.de +// this code should compile quietly + +class CArray +{ +public: + operator double* (){ return a; } + // works if we comment this line: + operator double* () const { return const_cast<double *>(a); } +private: + double a[2]; +}; + +int main(){ + CArray a; + double *pa = a + 1; // { dg-bogus "" } should convert + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.martin/sts_iarr.C b/gcc/testsuite/g++.old-deja/g++.martin/sts_iarr.C new file mode 100644 index 000000000..77ae5ae59 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.martin/sts_iarr.C @@ -0,0 +1,46 @@ +// { dg-do run } +// egcs-bugs 999-02-22 14:26 Stefan Schwarzer +// sts@ica1.uni-stuttgart.de +// should compile and return 0 + +template <int N> +struct Outer{ + struct Inner{ + Inner(int n): sum(n){} + + typename Outer<N-1>::Inner operator[](int n) const + { return typename Outer<N-1>::Inner(sum + n); } + + int sum; + }; + + typename Outer<N-1>::Inner operator[](int n) const + { return typename Outer<N-1>::Inner(n); } +}; + + +// specializations for N==1 +template<> +struct Outer<1> { + struct Inner { + Inner(int n): sum(n){} + + int operator[](int n) const + { return sum+n; } + + int sum; + }; + + int operator[](int n) const + { return n; } +}; + + +int main() +{ + Outer<1> sum1; + //std::cout << sum1[1] << "\n"; + Outer<2> sum2; + //std::cout << sum2[1][1] << "\n"; + return sum1[1] + sum2[1][1] - 3; +} diff --git a/gcc/testsuite/g++.old-deja/g++.martin/sts_partial.C b/gcc/testsuite/g++.old-deja/g++.martin/sts_partial.C new file mode 100644 index 000000000..00b58e6c2 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.martin/sts_partial.C @@ -0,0 +1,15 @@ +// { dg-do run } +// ecgs-bugs 1999-02-22 14:26 Stefan Schwarzer +// sts@ica1.uni-stuttgart.de +// partial ordering problem in egcs <= 1.1.1 + +template<class T> +int f(T &){ return 1; } + +template<class T> +int f( T[] ){ return 0; } + +int main(){ + int d[] ={2}; + return f(d); +} diff --git a/gcc/testsuite/g++.old-deja/g++.martin/sts_vectini.C b/gcc/testsuite/g++.old-deja/g++.martin/sts_vectini.C new file mode 100644 index 000000000..b8ab3534a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.martin/sts_vectini.C @@ -0,0 +1,42 @@ +// { dg-do run } +// { dg-options "-O2 -w" } +// egcs-bugs 1999-02-22 14:24 Stefan Schwarzer +// sts@ica1.uni-stuttgart.de +// optimizer problem in egcs <= 1.1.1 + +struct XTVec{ + XTVec(){x[0]=x[1] =x[2] =0;} + XTVec(int ax,int y=0.,int z=0.){x[0]=ax;x[1]=y; x[2]=z; } + int& operator[](int); + + int x[3]; +}; + +inline +int & XTVec::operator[](int i){ + return x[i]; +} + +inline +XTVec& operator+=(XTVec& lhs, XTVec& rhs){ + lhs[0]+=rhs[0]; + lhs[1]+=rhs[1]; + lhs[2]+=rhs[2]; + return lhs; +} + +inline +XTVec operator+(XTVec& lhs, XTVec& rhs){ + XTVec result(lhs); + return result += rhs; +} + +int main() +{ + XTVec ur(4.,0.,1.); + XTVec ll(0.,2.,0.); + XTVec initsum(ur + ll); + + // sum of components should be 7 + return (initsum[0] + initsum[1] + initsum[2] - 7); +} diff --git a/gcc/testsuite/g++.old-deja/g++.martin/typedef1.C b/gcc/testsuite/g++.old-deja/g++.martin/typedef1.C new file mode 100644 index 000000000..990c0bb6c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.martin/typedef1.C @@ -0,0 +1,14 @@ +// { dg-do assemble } + +// Copyright (C) 1999 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 31 Mar 1999 <nathan@acm.org> + +// Make sure we see through typedefs. + +typedef int Int; + +void fn() +{ + int *p; + Int *&pr2 = p; +} diff --git a/gcc/testsuite/g++.old-deja/g++.martin/typedef2.C b/gcc/testsuite/g++.old-deja/g++.martin/typedef2.C new file mode 100644 index 000000000..be1bbcbf7 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.martin/typedef2.C @@ -0,0 +1,7 @@ +// { dg-do assemble } +// Testcase from Alexander Zvyagin <zvyagin@mx.ihep.su> +// Check implicit conversion from string constants into typedefs + +typedef char CHAR; +void f2(CHAR *s=""); + diff --git a/gcc/testsuite/g++.old-deja/g++.mike/align1.C b/gcc/testsuite/g++.old-deja/g++.mike/align1.C new file mode 100644 index 000000000..027a908bb --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/align1.C @@ -0,0 +1,57 @@ +// { dg-do run } +// Check to make sure we align virtual base classes properly + +class eel_base { +public: +}; + +class markable_eel_base : public eel_base { +private: + int mark; +}; + +class eel_edge : public markable_eel_base { +public: +private: + int foo; +}; + +class edge : public virtual eel_edge { +public: + edge() { + _weight = 0.0; + } +private: + double _weight; +}; +class eel_branch_edge : public virtual edge { +}; +class branch_edge : public eel_branch_edge { +}; + +class eel_interproc_branch_edge : public branch_edge { +}; + +class interproc_edge : public virtual edge { +}; + +class eel_jump_edge : public virtual edge { +protected: +}; + +class jump_edge : public eel_jump_edge { +public: +}; + +class eel_interproc_jump_edge : public jump_edge { +protected: +}; + +class interproc_jump_edge : public eel_interproc_jump_edge, + public interproc_edge { +public: +}; + +int main () { + void *vp = new interproc_jump_edge(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/align2.C b/gcc/testsuite/g++.old-deja/g++.mike/align2.C new file mode 100644 index 000000000..ef39bb1ac --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/align2.C @@ -0,0 +1,17 @@ +// { dg-do run } +class Foo { +}; + +class Bar : virtual Foo { +public: + int b; +} x; + +int main() +{ + // printf("Foo offset %d\n", (int)(Foo*)&x - (int)&x); + // printf("b offset %d\n", (int)&x.b - (int)&x); + // printf("sizeof is %d\n", sizeof(Bar)); + // This core dumps on a SPARC is alignment is wrong. + Bar blist[10]; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/ambig1.C b/gcc/testsuite/g++.old-deja/g++.mike/ambig1.C new file mode 100644 index 000000000..95c5eb7cd --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/ambig1.C @@ -0,0 +1,33 @@ +// { dg-do assemble } +extern "C" int printf(const char *, ...); + +struct VB { + virtual void f() { + printf("VB\n"); + } +}; + +class M : public virtual VB { +public: + int i; + void f() { + printf("M(%d)\n", i); + } +}; + +class lM : public M { +}; + +class rM : public M { +}; + +class D : public lM, rM { // { dg-error "" } ambiguous function +} d; + +int main() { + ((lM*)&d)->i = 1; + ((rM*)&d)->i = 2; + ((rM*)&d)->f(); + ((lM*)&d)->f(); + ((VB*)&d)->f(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/asm1.C b/gcc/testsuite/g++.old-deja/g++.mike/asm1.C new file mode 100644 index 000000000..907e558ad --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/asm1.C @@ -0,0 +1,9 @@ +// { dg-do assemble } +// { dg-options "" } + +struct A { + static void foo() asm("_my_routine"); +}; + +void A::foo() { +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/asm2.C b/gcc/testsuite/g++.old-deja/g++.mike/asm2.C new file mode 100644 index 000000000..62ae86235 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/asm2.C @@ -0,0 +1,25 @@ +// { dg-do run } +// Compile with -S, there should be no references to +// LTRAMP in the output. + +extern "C" int printf (const char *, ...); + +void +sub2 (void (*func) ()) +{ + (*func) (); +} + +int +main(void) +{ + extern void sub (void); + + sub2 (sub); +} + +void +sub (void) +{ + printf ("hello world\n"); +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/bool1.C b/gcc/testsuite/g++.old-deja/g++.mike/bool1.C new file mode 100644 index 000000000..baa4196bf --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/bool1.C @@ -0,0 +1,16 @@ +// { dg-do assemble } +// bool test case + + +void foo(int i) { + foo (true); +} + +struct C { + void foo(int i) { + foo(true); + } + void bar(bool b) { + bar(0); + } +}; diff --git a/gcc/testsuite/g++.old-deja/g++.mike/bool2.C b/gcc/testsuite/g++.old-deja/g++.mike/bool2.C new file mode 100644 index 000000000..3d8bc3c03 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/bool2.C @@ -0,0 +1,58 @@ +// { dg-do run } +// { dg-options "" } +class A { +public: + operator bool () { + return true; + } +} a; +class A1 { +public: + operator int () { + return true; + } +} a1; +class A2 { +public: + operator const char * () { + return ""; + } +} a2; +class A3 { +public: + operator unsigned long long int () { + return true; + } +} a3; +class A4 { +public: + operator const char * () { + return ""; + } + operator unsigned long long int () { + return true; + } +} a4; +class A5 { +public: + operator double () { + return 256.0e0*256.0e0*256.0e0*256.0e0*256.0e0*256.0e0*256.0e0*256.0e0 + *256.0e0*256.0e0*256.0e0*256.0e0*256.0e0*256.0e0*256.0e0*256.0e0 + *256.0e0*256.0e0*256.0e0*256.0e0*256.0e0*256.0e0*256.0e0*256.0e0 + *256.0e0*256.0e0*256.0e0*256.0e0*256.0e0*256.0e0*256.0e0*256.0e0; + } +} a5; +int i = true; +bool b = true; +bool c = (bool)(void (A::*)())0; +bool d = 256; +main() { + if (!d) return 1; + if (!a) return 1; + if (!(bool)a) return 1; + // if (!(long long)a) return 1; + if (!a1) return 1; + if (!a2) return 1; + if (!a3) return 1; + if (!a5) return 1; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/bool4.C b/gcc/testsuite/g++.old-deja/g++.mike/bool4.C new file mode 100644 index 000000000..3d119e5e0 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/bool4.C @@ -0,0 +1,3 @@ +// { dg-do assemble } + +void foo(bool arg = (1==0)) {} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/conv1.C b/gcc/testsuite/g++.old-deja/g++.mike/conv1.C new file mode 100644 index 000000000..b6f227224 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/conv1.C @@ -0,0 +1,11 @@ +// { dg-do run } +enum E { C }; + +E foo() { + return C; +} + +int main() { + if (foo() != C) + return 1; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/debug1.C b/gcc/testsuite/g++.old-deja/g++.mike/debug1.C new file mode 100644 index 000000000..6c477d303 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/debug1.C @@ -0,0 +1,14 @@ +// { dg-do assemble } +// { dg-options "-g -O -fkeep-inline-functions" } + +class c { +public: + ~c () { }; +}; + +int +foo (const c& lhs) +{ + c str (lhs); + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/dyncast1.C b/gcc/testsuite/g++.old-deja/g++.mike/dyncast1.C new file mode 100644 index 000000000..8764acdde --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/dyncast1.C @@ -0,0 +1,22 @@ +// { dg-do run { xfail sparc64-*-elf arm-*-pe } } +// { dg-options "-fexceptions -w" } + +#include <typeinfo> + +struct B { + virtual int f() { } +}; + +struct D { + virtual int f() { } +}; + +main() { + B b; + try { + (void)dynamic_cast<D&>(b); + } catch (std::bad_cast) { + return 0; + } + return 1; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/dyncast2.C b/gcc/testsuite/g++.old-deja/g++.mike/dyncast2.C new file mode 100644 index 000000000..ec737d6cc --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/dyncast2.C @@ -0,0 +1,25 @@ +// { dg-do run { xfail sparc64-*-elf arm-*-pe } } +// { dg-options "-fexceptions -w" } + +// Ensure reference handling works. + +#include <typeinfo> + +struct B { + virtual int f() { } +} ob; + +struct D : public B { + virtual int f() { } +} od; + +main() { + B *b=&ob; + try { + void *vp = &dynamic_cast<D&>(*b); + return 1; + } catch (std::bad_cast) { + return 0; + } + return 1; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/dyncast3.C b/gcc/testsuite/g++.old-deja/g++.mike/dyncast3.C new file mode 100644 index 000000000..662a37e0d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/dyncast3.C @@ -0,0 +1,19 @@ +// { dg-do run { xfail sparc64-*-elf arm-*-pe**-* } } +// { dg-options "-fexceptions -w" } +// Ensure that the return type of dynamic_cast is the real type. + +struct B { + virtual int f() { } +}; + +struct D : public B { + virtual int f() { } + int i; +} od; + +main() { + B *b=&od; + if (dynamic_cast<D*>(b)->i) + return 1; + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/dyncast4.C b/gcc/testsuite/g++.old-deja/g++.mike/dyncast4.C new file mode 100644 index 000000000..75e9771b5 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/dyncast4.C @@ -0,0 +1,5 @@ +// { dg-do assemble } +int main() { + int* d; + dynamic_cast<void*>(d); // { dg-error "" } +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/dyncast5.C b/gcc/testsuite/g++.old-deja/g++.mike/dyncast5.C new file mode 100644 index 000000000..b6adac72a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/dyncast5.C @@ -0,0 +1,72 @@ +// { dg-do run } +#include <stddef.h> + +void *p; +int fail; + +class HeapTracked { +public: + virtual ~HeapTracked() = 0; + void *operator new(size_t size); + void operator delete(void *ptr); + static bool isObjectAllocation(const HeapTracked *ptr); +}; + +HeapTracked::~HeapTracked(){} +void * HeapTracked::operator new(size_t size) +{ + void * memPtr = ::operator new(size); + p = memPtr; + return memPtr; +} + +void HeapTracked::operator delete(void *ptr) +{ + if (p != ptr) + fail = 1; + ::operator delete(ptr); +} + +bool HeapTracked::isObjectAllocation(const HeapTracked *ptr) +{ + if (p != const_cast<void*>(dynamic_cast<const void*>(ptr))) + fail = 1; + return false; +} + +class Mumble1: public virtual HeapTracked { + double d; +public: + virtual ~Mumble1(){} +}; + +class Mumble2: public virtual HeapTracked { + double d; +public: + virtual ~Mumble2(){} +}; + +class Foo: virtual public HeapTracked, + virtual public Mumble1, + virtual public Mumble2 { +public: + ~Foo(){} +}; + +int main() +{ + Foo *pf = new Foo; + pf->isObjectAllocation(pf); + + Mumble1 *pm1 = pf; + pm1->isObjectAllocation(pm1); + + Mumble2 *pm2 = pf; + pm2->isObjectAllocation(pm2); + + // delete pf; + // delete pm1; + delete pm2; + + return fail; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/dyncast6.C b/gcc/testsuite/g++.old-deja/g++.mike/dyncast6.C new file mode 100644 index 000000000..60065a496 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/dyncast6.C @@ -0,0 +1,13 @@ +// { dg-do assemble } +#include <typeinfo> + +class A { +public: + virtual void j () {} +}; + +class B : public A { }; + +void x (A& a) { + const B& b1 = dynamic_cast<B&>((const A&)a); // { dg-error "" } opps +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/dyncast7.C b/gcc/testsuite/g++.old-deja/g++.mike/dyncast7.C new file mode 100644 index 000000000..33e3fa787 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/dyncast7.C @@ -0,0 +1,29 @@ +// { dg-do run } +// { dg-options "-fexceptions" } + +#include <typeinfo> +#include <stdexcept> + +class A { +public: + virtual void j () {} +}; + +class B : public A { }; + +void x (A& a) { + // These should all work. + const B& b2 = dynamic_cast<B&>(a); + const B& b3 = dynamic_cast<const B&>((const A&)a); + const B& b4 = dynamic_cast<const B&>(a); +} + +int main() { + try { + B b; + x (b); + } catch (std::exception& e) { + // If we get a bad_cast, it is wrong. + return 1; + } +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/dyncast8.C b/gcc/testsuite/g++.old-deja/g++.mike/dyncast8.C new file mode 100644 index 000000000..e2c5a2df9 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/dyncast8.C @@ -0,0 +1,23 @@ +// { dg-do run } +#include <typeinfo> + +class Base +{ +public: + virtual ~Base() { } +}; + +class Derived : public Base +{ +public: + Derived() {} +}; + +int main() +{ + const Derived b; + const Base* ap = &b; + + const Derived* p1 = dynamic_cast<const Derived*>(ap); + return p1 == 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/dyncast9.C b/gcc/testsuite/g++.old-deja/g++.mike/dyncast9.C new file mode 100644 index 000000000..f2b999019 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/dyncast9.C @@ -0,0 +1,17 @@ +// { dg-do run } +class S1 { int i; }; +class S2 { int i; }; +class VB { +public: + virtual void foo() { } +}; + +class D : public S1, virtual public VB { +} d; + +class E : public S2, public D { +} e; + +int main() { + return (char *)&e - (char *)dynamic_cast<E*>((D*)&e); +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/eh1.C b/gcc/testsuite/g++.old-deja/g++.mike/eh1.C new file mode 100644 index 000000000..8105107f3 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/eh1.C @@ -0,0 +1,38 @@ +// { dg-do assemble } +// { dg-options "-fexceptions -O -S" } + +extern "C" int printf (const char *, ...); +extern "C" int atoi (const char *); +extern "C" void exit (int); + +struct Exception + { + int v; + Exception(int i) { v = i; }; + }; + + void inc(int &i) + { + try { + if (i == 0) + throw Exception(i); + else + i++; + } + catch (Exception v) { + i = v.v; + } + } + +main (int argc, const char *argv[]) +{ + if (argc != 2) + { + printf ("usage: a.out <num>\n"); + exit (1); + } + int count = atoi (argv[1]); + inc (count); + printf ("success\n"); + exit (0); +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/eh10.C b/gcc/testsuite/g++.old-deja/g++.mike/eh10.C new file mode 100644 index 000000000..a38e2ebc7 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/eh10.C @@ -0,0 +1,28 @@ +// { dg-do run { xfail sparc64-*-elf arm-*-pe } } +// { dg-options "-fexceptions" } + +void foo() { + int i; + i = 42; + throw i; +} + +void ee(int *); + +void bar() { + int i = 2; + ee(&i); +} + +void ee(int *) { } + +main() { + try { + foo(); + return 3; + } catch (int& i) { + bar(); + return i != 42; + } + return 2; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/eh11.C b/gcc/testsuite/g++.old-deja/g++.mike/eh11.C new file mode 100644 index 000000000..8042d6443 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/eh11.C @@ -0,0 +1,15 @@ +// { dg-do assemble } +// { dg-options "-fexceptions" } + +struct A { + ~A(); +}; + +int main(int argc, char** argv) { + A a; + return 0; +} + + +A::~A() { +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/eh12.C b/gcc/testsuite/g++.old-deja/g++.mike/eh12.C new file mode 100644 index 000000000..8ec2998ef --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/eh12.C @@ -0,0 +1,14 @@ +// { dg-do run { xfail sparc64-*-elf arm-*-pe } } +// { dg-options "-fexceptions" } + +class MyError { }; + +int main (int argc, char **argv) { + try { + throw MyError(); + } + catch (MyError x) { + } + + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/eh13.C b/gcc/testsuite/g++.old-deja/g++.mike/eh13.C new file mode 100644 index 000000000..bac568655 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/eh13.C @@ -0,0 +1,6 @@ +// { dg-do run { xfail arm-*-pe } } +// { dg-options "-fexceptions" } + +#include <string> + +main() { } diff --git a/gcc/testsuite/g++.old-deja/g++.mike/eh14.C b/gcc/testsuite/g++.old-deja/g++.mike/eh14.C new file mode 100644 index 000000000..2e788fa36 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/eh14.C @@ -0,0 +1,25 @@ +// { dg-do run { xfail sparc64-*-elf arm-*-pe } } +// { dg-options "-fexceptions" } + +class arghh { +public: + int n; + arghh (int v) { n = v; } +}; + +int main () { + try { + throw arghh (11); + } + catch (arghh& a) { + if (a.n != 11) + return 1; + } + try { + throw arghh (22); + } + catch (arghh& a) { + if (a.n != 22) + return 2; + } +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/eh15.C b/gcc/testsuite/g++.old-deja/g++.mike/eh15.C new file mode 100644 index 000000000..4418f1607 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/eh15.C @@ -0,0 +1,6 @@ +// { dg-do assemble } +// { dg-options "-fexceptions" } + +struct A { + A() throw (int); +}; diff --git a/gcc/testsuite/g++.old-deja/g++.mike/eh16.C b/gcc/testsuite/g++.old-deja/g++.mike/eh16.C new file mode 100644 index 000000000..73beac0a5 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/eh16.C @@ -0,0 +1,26 @@ +// { dg-do run { xfail sparc64-*-elf arm-*-pe } } +// { dg-options "-fexceptions" } + +int e = 1; + +struct A { + ~A() { + --e; + } +}; + +struct B { + A a; + B() { + throw 1; + } +}; + +main() { + try { + B b; + } catch (...) { + return e; + } + return 1; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/eh17.C b/gcc/testsuite/g++.old-deja/g++.mike/eh17.C new file mode 100644 index 000000000..5b066c9c3 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/eh17.C @@ -0,0 +1,25 @@ +// { dg-do run { xfail sparc64-*-elf arm-*-pe } } +// { dg-options "-fexceptions" } + +int e = 1; + +struct A { + ~A() { + --e; + } +}; + +struct B : public A { + B() { + throw 1; + } +}; + +main() { + try { + B b; + } catch (...) { + return e; + } + return 1; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/eh18.C b/gcc/testsuite/g++.old-deja/g++.mike/eh18.C new file mode 100644 index 000000000..02e6545e7 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/eh18.C @@ -0,0 +1,63 @@ +// { dg-do run { xfail sparc64-*-elf arm-*-pe } } +// { dg-options "-fexceptions" } + +class VB { +public: + int n; + VB (int v) { n = v; } + VB (const VB& o) { + n = o.n; +// printf("copying VB from %d to %d\n", &o, this); + } +}; + +class D : public virtual VB { + int j; +public: + D(int i1, int i2) : VB(i2) { j = i1; } + VB& vb() { return *(VB*)this; } + const VB& vb() const { return *(const VB*)this; } +}; + +class pD : private virtual VB { + int j; +public: + pD(int i1, int i2) : VB(i2) { j = i1; } + VB& vb() { return *(VB*)this; } + const VB& vb() const { return *(const VB*)this; } +}; + + +int main () { + D d(1943, 4279); + pD pd(3621, 9527); + VB *vb = &d.vb(); + VB *pvb = &pd.vb(); + + // A catch of a public virtual base. + try { +// printf("Throwing D at %d (VB at %d)\n", &d, vb); + throw d; + } + catch (VB& vb) { +// printf("Catching VB at %d\n", &vb); + if (vb.n != 4279) + return 1; + } + catch (...) { + return 1; + } + + // A catch of a private virtual base. + try { +// printf("Throwing D at %d (VB at %d)\n", &pd, pvb); + throw pd; + } + catch (VB& vb) { +// printf("Catching VB at %d\n", &vb); + // This was a private base of the throw object, don't catch it. + return 1; + } + catch (...) { + } +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/eh19.C b/gcc/testsuite/g++.old-deja/g++.mike/eh19.C new file mode 100644 index 000000000..bbd668f98 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/eh19.C @@ -0,0 +1,23 @@ +// { dg-do assemble } +// { dg-options "-fexceptions" } + +class test1 { +public: + class fehler{public:fehler(){};}; + void func(int a) { + if( a == 0 ) + throw fehler(); + } +}; + +int main() { + test1 var; + + try { + var.func(1); + var.func(0); + } catch(test1::fehler()) // function type promoted to pointer + { + ; + } +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/eh2.C b/gcc/testsuite/g++.old-deja/g++.mike/eh2.C new file mode 100644 index 000000000..0a08790fe --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/eh2.C @@ -0,0 +1,74 @@ +// { dg-do run { xfail sparc64-*-elf arm-*-pe } } +// { dg-options "-fexceptions" } + +#include <cstdlib> +#include <iostream> + +class Vector { +private: + int *p; + int sz; + +public: + // Exception class + class Range { + private: + int value_i; + + public: + Range( int i ) { value_i = i; }; + int value() { return value_i; }; + }; + + Vector( int s ); + ~Vector(); + int size() { return sz; }; + int& operator []( int i ); +}; + +Vector::Vector(int s) { + sz = s; + p = new int[sz]; +} + +Vector::~Vector() { + delete [] p; +} + +int& +Vector::operator [](int i) { + if (0<=i && i<sz) { + return p[i]; + } else { + throw Range( i ); + } +} + +void crash(Vector& v ) { + v[v.size()+10]; // Triggers range error! +} + +void do_something(Vector& v) { + crash( v ); +} + +void +f(Vector& v) { + try { + do_something( v ); + } catch (Vector::Range& r) { + std::cout << "Invalid vector range " << r.value() + << " caught in f()" << std::endl; + std::exit(0); + } +} + +main() { + Vector v(10); + + f( v ); + return 1; +} + + + diff --git a/gcc/testsuite/g++.old-deja/g++.mike/eh20.C b/gcc/testsuite/g++.old-deja/g++.mike/eh20.C new file mode 100644 index 000000000..ad29dbaa3 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/eh20.C @@ -0,0 +1,7 @@ +// { dg-do assemble } +// { dg-options "-fexceptions -Wall" } + +int +main() { + throw 1; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/eh21.C b/gcc/testsuite/g++.old-deja/g++.mike/eh21.C new file mode 100644 index 000000000..ac74fa386 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/eh21.C @@ -0,0 +1,14 @@ +// { dg-do run { xfail sparc64-*-elf arm-*-pe } } +// { dg-options "-fexceptions" } + +int main () { + try { + try { + throw 1; + } catch ( char * ) { + } + } catch ( int ) { + return 0; + } + return 1; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/eh23.C b/gcc/testsuite/g++.old-deja/g++.mike/eh23.C new file mode 100644 index 000000000..da2ac0ef3 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/eh23.C @@ -0,0 +1,47 @@ +// { dg-do run { xfail sparc64-*-elf arm-*-pe } } +// { dg-options "-fexceptions" } + +#include <exception> +#include <stdlib.h> + +struct double_fault { }; +int fault_now; + +class E { +public: + E() { } + E(const E&) { + if (fault_now) + throw double_fault(); + } +}; + +void foo() { + try { + throw E(); + } catch (...) { + fault_now = 1; + throw; + } +} + +void bar() { + try { + foo(); + } catch (E e) { // double fault here + } +} + +void my_terminate() { + exit (0); // double faults should call terminate +} + +main() { + std::set_terminate (my_terminate); + try { + bar(); + } catch (...) { + return 1; + } + return 1; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/eh24.C b/gcc/testsuite/g++.old-deja/g++.mike/eh24.C new file mode 100644 index 000000000..829819b39 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/eh24.C @@ -0,0 +1,33 @@ +// { dg-do run { xfail sparc64-*-elf arm-*-pe } } +// { dg-options "-fexceptions" } + +int fail = 0; + +struct A { + int ok; + A() { + ok = 1; + } + ~A() { + if (! ok) + fail = 1; + ok = 0; + } +}; + +main() { + try { + try { + A a; + throw 1.0; + } catch (double i) { + A a1; + throw 1; // make sure both a1 and a2 are not destroyed when we throw! + } catch (int i) { + A a2; + throw 1.0; + } + } catch (int i) { + } + return fail; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/eh25.C b/gcc/testsuite/g++.old-deja/g++.mike/eh25.C new file mode 100644 index 000000000..fb492f78a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/eh25.C @@ -0,0 +1,31 @@ +// { dg-do run { xfail sparc64-*-elf arm-*-pe } } +// { dg-options "-fexceptions" } + +#include <exception> +#include <stdlib.h> + +void my_terminate() { + exit (0); // Double faults should call terminate +} + +struct A { + A() { } + ~A() { + std::set_terminate (my_terminate); + throw 1; // This throws from EH dtor, should call my_terminate + } +}; + +main() { + try { + try { + throw 1; + } catch (int i) { + A a; // A hit on this EH dtor went to the wrong place + throw 1; + } + } catch (...) { + return 1; + } + return 1; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/eh26.C b/gcc/testsuite/g++.old-deja/g++.mike/eh26.C new file mode 100644 index 000000000..d0d65da31 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/eh26.C @@ -0,0 +1,15 @@ +// { dg-do run { xfail sparc64-*-elf arm-*-pe } } +// { dg-options "-fexceptions" } + +class MyExceptionHandler { }; + +main() { + try { + throw MyExceptionHandler(); + } catch(const MyExceptionHandler& eh) { + return 0; + } catch(...) { + return 1; + } + return 1; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/eh27.C b/gcc/testsuite/g++.old-deja/g++.mike/eh27.C new file mode 100644 index 000000000..8be08da8c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/eh27.C @@ -0,0 +1,17 @@ +// { dg-do run { xfail sparc64-*-elf arm-*-pe } } +// { dg-options "-fexceptions" } + +#include <typeinfo> + +class MyExceptionHandler { }; + +main() { + try { + throw MyExceptionHandler(); + } catch(const MyExceptionHandler& eh) { + return 0; + } catch(...) { + return 1; + } + return 1; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/eh28.C b/gcc/testsuite/g++.old-deja/g++.mike/eh28.C new file mode 100644 index 000000000..57cab1178 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/eh28.C @@ -0,0 +1,17 @@ +// { dg-do run { xfail sparc64-*-elf arm-*-pe } } +// { dg-options "-fexceptions" } + +#include <typeinfo> + +int fail = 1; + +class X { public: virtual void p() { } }; +class Y : public X { public: virtual void p() { fail = 0; } }; + +main() +{ + try { Y y; throw y; } + catch (X& x) { x.p(); } + catch (...) { } + return fail; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/eh29.C b/gcc/testsuite/g++.old-deja/g++.mike/eh29.C new file mode 100644 index 000000000..892e95964 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/eh29.C @@ -0,0 +1,27 @@ +// { dg-do run { xfail sparc64-*-elf arm-*-pe } } +// { dg-options "-fexceptions" } + +int count; + +class A { +public: + A() { +// printf("ctor %x\n", (int)this); + if (count==3) + throw 1; + ++count; + } + ~A() { + --count; +// printf("dtor %x\n", (int)this); + } +}; + +main() { + try { + A a[5]; + } catch (...) { + return count; + } + return 1; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/eh3.C b/gcc/testsuite/g++.old-deja/g++.mike/eh3.C new file mode 100644 index 000000000..8c9ddb456 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/eh3.C @@ -0,0 +1,21 @@ +// { dg-do run { xfail sparc64-*-elf arm-*-pe } } +// { dg-options "-fexceptions" } + +class foo { +public: + class error {}; + + void cause_error(void) { throw error(); } +}; + +int main(void) +{ + foo f; + try { + f.cause_error(); + } + catch (foo::error&) { + return 0; + } + return 1; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/eh30.C b/gcc/testsuite/g++.old-deja/g++.mike/eh30.C new file mode 100644 index 000000000..8da682c53 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/eh30.C @@ -0,0 +1,4 @@ +// { dg-do assemble { target native } } +// { dg-options "-fexceptions -fPIC -S" } + +main() { throw 1; } diff --git a/gcc/testsuite/g++.old-deja/g++.mike/eh31.C b/gcc/testsuite/g++.old-deja/g++.mike/eh31.C new file mode 100644 index 000000000..150d66b98 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/eh31.C @@ -0,0 +1,23 @@ +// { dg-do run { xfail sparc64-*-elf arm-*-pe } } +// { dg-options "-fexceptions" } + +int count; + +class Foo { +public: + Foo() { ++count; } + Foo(const Foo&) { ++count; } + ~Foo() { --count; } +}; + + +main() { + try { + throw Foo(); + } + catch (Foo& object) { + if (count == 1) + return 0; + } + return 1; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/eh32.C b/gcc/testsuite/g++.old-deja/g++.mike/eh32.C new file mode 100644 index 000000000..53822c743 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/eh32.C @@ -0,0 +1,20 @@ +// { dg-do assemble } +// { dg-options "-fexceptions" } + +class Base { +public: + virtual ~Base() throw(); +}; + +Base::~Base() throw() +{ +} + +class Foo : public Base { +public: + virtual ~Foo() throw(); +}; + +Foo::~Foo() throw() +{ +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/eh33.C b/gcc/testsuite/g++.old-deja/g++.mike/eh33.C new file mode 100644 index 000000000..b679991e4 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/eh33.C @@ -0,0 +1,21 @@ +// { dg-do run { xfail sparc64-*-elf z8k-*-* arm-*-pe } } +// { dg-options "-fexceptions" } + +#include <exception> + +void my_unexpected() { + throw 42; +} + +void foo() throw (int) { throw "Hi"; } + +int main() { + std::set_unexpected (my_unexpected); + try { + foo(); + } catch (int i) { + if (i == 42) + return 0; + } + return 1; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/eh34.C b/gcc/testsuite/g++.old-deja/g++.mike/eh34.C new file mode 100644 index 000000000..056f6b8df --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/eh34.C @@ -0,0 +1,16 @@ +// { dg-do run { xfail sparc64-*-elf arm-*-pe } } + +#include <exception> +#include <stdlib.h> + +void my_unexpected() { + exit (0); +} + +void foo() throw () { throw "Hi"; } + +int main() { + std::set_unexpected (my_unexpected); + foo(); + return 1; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/eh35.C b/gcc/testsuite/g++.old-deja/g++.mike/eh35.C new file mode 100644 index 000000000..adf852a64 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/eh35.C @@ -0,0 +1,17 @@ +// { dg-do run { xfail sparc64-*-elf arm-*-pe } } +// { dg-options "-fexceptions" } + +main() { + try { + throw 'a'; + } catch (char a) { + try { + throw 'a'; + } catch (int i) { + return 1; + } catch (char c) { + return 0; + } + } + return 1; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/eh36.C b/gcc/testsuite/g++.old-deja/g++.mike/eh36.C new file mode 100644 index 000000000..d6b4788cb --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/eh36.C @@ -0,0 +1,29 @@ +// { dg-do run { xfail sparc64-*-elf arm-*-pe } } +// { dg-options "-fexceptions" } + +#include <typeinfo> + +class A { + int space; +}; +class B { +public: + int data; + B(int i) : data(i) { + } +}; +class D : public A, public B { +public: + D(int i) : B(i) { + } +} d(42); + +main() { + try { + throw &d; + } catch (B* b) { + if (b->data == 42) + return 0; + } + return 1; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/eh37.C b/gcc/testsuite/g++.old-deja/g++.mike/eh37.C new file mode 100644 index 000000000..a98b5df99 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/eh37.C @@ -0,0 +1,21 @@ +// { dg-do run { xfail sparc64-*-elf arm-*-pe } } +// { dg-options "-fexceptions" } + +#include <typeinfo> + +class B { +public: + int data; + B(int i) : data(i) { + } +} b(42); + +main() { + try { + throw &b; + } catch (B* b) { + if (b->data == 42) + return 0; + } + return 1; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/eh38.C b/gcc/testsuite/g++.old-deja/g++.mike/eh38.C new file mode 100644 index 000000000..5a5687982 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/eh38.C @@ -0,0 +1,28 @@ +// { dg-do run { xfail sparc64-*-elf arm-*-pe } } +// { dg-options "-fexceptions" } + +#include <typeinfo> + +class B { +public: + int data; + B(int i) : data(i) { + } +} b(42); + +main() { + try { + throw &b; + } catch (const B* bptr) { + if (bptr->data == 42) + { + try { + throw &b; + } catch (void *bptr) { + if (((B*)bptr)->data == 42) + return 0; + } + } + } + return 1; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/eh39.C b/gcc/testsuite/g++.old-deja/g++.mike/eh39.C new file mode 100644 index 000000000..e4bfff8d1 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/eh39.C @@ -0,0 +1,28 @@ +// { dg-do run { xfail sparc64-*-elf arm-*-pe } } +// { dg-options "-fexceptions" } + +int fail = 1; +class B { +public: + B() { throw 1; } +}; +class D : public B { +public: + D(); +}; + +D::D() try : B() { + fail = 1; +} catch (...) { + fail = 0; + throw; +} + +main() { + try { + D d; + fail = 1; + } catch (...) { + } + return fail; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/eh4.C b/gcc/testsuite/g++.old-deja/g++.mike/eh4.C new file mode 100644 index 000000000..d7eb96ef7 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/eh4.C @@ -0,0 +1,6 @@ +// { dg-do assemble } +// { dg-options "-fexceptions" } + +void foo() { + throw 1; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/eh40.C b/gcc/testsuite/g++.old-deja/g++.mike/eh40.C new file mode 100644 index 000000000..e42b41974 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/eh40.C @@ -0,0 +1,29 @@ +// { dg-do run { xfail sparc64-*-elf arm-*-pe } } +// { dg-options "-fexceptions" } + +int fail = 1; +class B { +public: + B() { throw 1; } +}; +class D : public B { +public: + D() try : B() { + fail = 1; + } catch (char c) { + fail = 1; + throw; + } catch (...) { + fail = 0; + throw; + } +}; + +main() { + try { + D d; + fail = 1; + } catch (...) { + } + return fail; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/eh41.C b/gcc/testsuite/g++.old-deja/g++.mike/eh41.C new file mode 100644 index 000000000..831d75dc4 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/eh41.C @@ -0,0 +1,29 @@ +// { dg-do run { xfail sparc64-*-elf arm-*-pe } } +// { dg-options "-fexceptions" } + +int fail = 0; + +struct A { + A () { a = 'a'; b = 'b'; c = 'c'; } + ~ A () { + if ( a != 'a' ) fail = 1; + if ( b != 'b' ) fail = 1; + if ( c != 'c' ) fail = 1; + } + char a, b, c; +}; + +void some_init () { throw 1; } + +struct C : A { + C () { some_init (); } +}; + +int main () { + try { + C c; + } catch (int i) { + return 0; + } + return 1; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/eh42.C b/gcc/testsuite/g++.old-deja/g++.mike/eh42.C new file mode 100644 index 000000000..ab69c3c53 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/eh42.C @@ -0,0 +1,18 @@ +// { dg-do run { xfail sparc64-*-elf arm-*-pe } } +// { dg-options "-fexceptions" } + +struct none { int i[50]; }; + +class my_ex { } a; + +none throw_it() { + throw 1; +} + +int main() { + try { + none n = throw_it(); + } catch (int ex) { + return 0; + } +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/eh44.C b/gcc/testsuite/g++.old-deja/g++.mike/eh44.C new file mode 100644 index 000000000..27afd3fec --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/eh44.C @@ -0,0 +1,36 @@ +// { dg-do run { xfail sparc64-*-elf arm-*-pe } } +// { dg-options "-fexceptions" } +// prms-id: 9159 + +static unsigned int iCounter = 0; +static unsigned int iMax; +int fail = 0; + +class ca { +public: + ca(int) { + if (iCounter++ == iMax) + throw (const char*)"iCounter"; + } + virtual ~ca() { + } +}; + +class cc { +public: + cc(const ca &rca1, const ca &rca2) { + } + virtual ~cc() { + fail = 1; + } +}; + + +int main(int argc, char **argv) { + iMax = 1; + try { + cc sc(ca(1), ca(1)); + } catch (const char *pMsg) { + } + return fail; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/eh45.C b/gcc/testsuite/g++.old-deja/g++.mike/eh45.C new file mode 100644 index 000000000..5bd4dd476 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/eh45.C @@ -0,0 +1,35 @@ +// { dg-do run } +int i; +int fail; + +class ca { +public: + ca() { + if (++i != 1) + fail = 1; + } + virtual ~ca() { + if (++i != 4) + fail = 4; + } +}; + +class cb { +public: + cb(const ca &rca) { + if (++i != 2) + fail = 2; + } + virtual ~cb() { + if (++i != 3) + fail = 3; + } +}; + +void foo(const cb &rcb) { +} + +int main(int argc, char **argv) { + foo(cb(ca())); + return fail; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/eh46.C b/gcc/testsuite/g++.old-deja/g++.mike/eh46.C new file mode 100644 index 000000000..9785e6ad1 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/eh46.C @@ -0,0 +1,47 @@ +// { dg-do assemble } +// { dg-xfail-if "" { arm-*-pe } { "*" } { "" } } +// { dg-options "-fexceptions" } + +int atoi(const char *); + +struct ios { + virtual ~ios(); +}; + +class fstreambase : virtual public ios { +}; + +class ifstream : public fstreambase { +}; + +class ofstream : public fstreambase { +}; + +extern const short O; +extern const short D; + +const short O= 0; +const short D= -3; + + +short glc(const char* const * const l, + short& n,short& x,short& y, + ifstream* i,ofstream* o) + +{ + n=atoi(l[1]); + + x=atoi(l[2]); + y=atoi(l[3]); + + if((x < 0)||(y <0)) + { + return D; + } + + i = new ifstream[n]; + o = new ofstream[2]; + + return O; + +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/eh47.C b/gcc/testsuite/g++.old-deja/g++.mike/eh47.C new file mode 100644 index 000000000..10eb8a897 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/eh47.C @@ -0,0 +1,23 @@ +// { dg-do run { xfail sparc64-*-elf arm-*-pe } } +// { dg-options "-fexceptions" } + +#include <cstdlib> +#include <exception> + +void myterm() { + exit (0); +} + +main() { + try { + throw ""; + } catch (...) { + } + try { + std::set_terminate (myterm); + throw; + } catch (...) { + return 1; + } + return 1; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/eh48.C b/gcc/testsuite/g++.old-deja/g++.mike/eh48.C new file mode 100644 index 000000000..d9caf61b4 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/eh48.C @@ -0,0 +1,34 @@ +// { dg-do run { xfail sparc64-*-elf arm-*-pe } } +// { dg-options "-fexceptions" } + +#include <exception> +#include <stdlib.h> + +using std::uncaught_exception; +class A { +public: + ~A() { + if (uncaught_exception ()) + exit (0); + } +}; + +int main() { + if (uncaught_exception ()) + return 1; + try { + throw ""; + } catch (...) { + if (uncaught_exception ()) + return 1; + } + if (uncaught_exception ()) + return 1; + try { + A a; + throw ""; + } catch (...) { + return 1; + } + return 1; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/eh49.C b/gcc/testsuite/g++.old-deja/g++.mike/eh49.C new file mode 100644 index 000000000..1380ca02d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/eh49.C @@ -0,0 +1,15 @@ +// { dg-do run { xfail sparc64-*-elf arm-*-pe } } +// { dg-options "-fexceptions -O9" } + +void main1() { + throw 1; +} + +int main() { + try { + main1(); + } catch (...) { + return 0; + } + return 1; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/eh5.C b/gcc/testsuite/g++.old-deja/g++.mike/eh5.C new file mode 100644 index 000000000..4ece58892 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/eh5.C @@ -0,0 +1,21 @@ +// { dg-do run { xfail sparc64-*-elf arm-*-pe } } +// { dg-options "-fexceptions" } + +class foo { +public: + class error {}; + + void cause_error(void) { throw "Hello World!"; } +}; + +int main(void) +{ + foo f; + try { + f.cause_error(); + } + catch (const char cp[]) { + return 0; + } + return 1; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/eh50.C b/gcc/testsuite/g++.old-deja/g++.mike/eh50.C new file mode 100644 index 000000000..de21dc2f4 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/eh50.C @@ -0,0 +1,21 @@ +// { dg-do run { xfail sparc64-*-elf z8k-*-* arm-*-pe } } +// { dg-options "-fexceptions" } + +#include <exception> + +void my_unexpected() { + throw 42; +} + +template <class T> void foo(T) throw (int) { throw "Hi"; } + +main() { + std::set_unexpected (my_unexpected); + try { + foo(1); + } catch (int i) { + if (i == 42) + return 0; + } + return 1; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/eh51.C b/gcc/testsuite/g++.old-deja/g++.mike/eh51.C new file mode 100644 index 000000000..073980a53 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/eh51.C @@ -0,0 +1,21 @@ +// { dg-do run { xfail sparc64-*-elf z8k-*-* arm-*-pe } } +// { dg-options "-fexceptions" } + +#include <exception> + +void my_unexpected() { + throw 42; +} + +template <class T> void foo(T) throw (T) { throw "Hi"; } + +main() { + std::set_unexpected (my_unexpected); + try { + foo(1); + } catch (int i) { + if (i == 42) + return 0; + } + return 1; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/eh52.C b/gcc/testsuite/g++.old-deja/g++.mike/eh52.C new file mode 100644 index 000000000..18b477c09 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/eh52.C @@ -0,0 +1,15 @@ +// { dg-do run } +// { dg-options "-fexceptions -O9" } + +int promote_mode (int mode, int *punsignedp) +{ + int unsignedp = *punsignedp; + *punsignedp = unsignedp; + return mode; +} + +int main() { + int i; + i = promote_mode (42, &i); + return i != 42; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/eh53.C b/gcc/testsuite/g++.old-deja/g++.mike/eh53.C new file mode 100644 index 000000000..5f2ff57ac --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/eh53.C @@ -0,0 +1,15 @@ +// { dg-do run { xfail sparc64-*-elf arm-*-pe } } +// { dg-options "-fexceptions -g" } + +class zeroset { +public: + ~zeroset () { } +}; + +int main () { + zeroset a; + try { + ; + } catch( zeroset ) { + } +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/eh54.C b/gcc/testsuite/g++.old-deja/g++.mike/eh54.C new file mode 100644 index 000000000..56e57e0a4 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/eh54.C @@ -0,0 +1,4 @@ +// { dg-do assemble } +// { dg-options "-fexceptions" } + +int main() { try { 1; } } // { dg-error "" } diff --git a/gcc/testsuite/g++.old-deja/g++.mike/eh55.C b/gcc/testsuite/g++.old-deja/g++.mike/eh55.C new file mode 100644 index 000000000..148268074 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/eh55.C @@ -0,0 +1,19 @@ +// { dg-do run { xfail sparc64-*-elf arm-*-pe } } +// { dg-options "-fexceptions" } + +#include <exception> +#include <stdlib.h> + +void my_terminate_handler() { + exit(0); +} + +void throw_an_unexpected_exception() throw() { + throw 1; +} + +int main() { + std::set_terminate(my_terminate_handler); + throw_an_unexpected_exception(); + return 1; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/eh56.C b/gcc/testsuite/g++.old-deja/g++.mike/eh56.C new file mode 100644 index 000000000..1b660fca1 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/eh56.C @@ -0,0 +1,23 @@ +// { dg-do run } +// { dg-options "-fexceptions" } + +struct A { + A() { } + A(const char *) { } + A(const A&) { } + ~A() { } +}; + +struct bmf { + bmf (const A n) { } + ~bmf (void) { } + A name; +}; + +void imf (void) { + bmf Sabs ("abs"); +} + +int main(void) { + imf (); +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/eh57.C b/gcc/testsuite/g++.old-deja/g++.mike/eh57.C new file mode 100644 index 000000000..087b4131b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/eh57.C @@ -0,0 +1,18 @@ +// { dg-do assemble } +// { dg-options "-fno-exceptions" } + +class Calendar_Time { +public: + ~Calendar_Time (); + int operator <= (const Calendar_Time& t) const; +}; + +class Temporal_Model_Interval { +public: + Calendar_Time start_time (); +}; + +int intersects_p (Temporal_Model_Interval* i1, Temporal_Model_Interval* i2) { + return ((i1->start_time() <= i2->start_time()) + || (i1->start_time() <= i2->start_time())); +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/eh58.C b/gcc/testsuite/g++.old-deja/g++.mike/eh58.C new file mode 100644 index 000000000..9bc89260c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/eh58.C @@ -0,0 +1,18 @@ +// { dg-do assemble } +// { dg-options "-fexceptions" } + +struct C { + bool mem; + ~C(); +}; + +C genTemp(); + +int foo_notok(int arg) { + switch (arg) { + case 0: + return genTemp().mem; + default: + return 3; + } +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/eh59.C b/gcc/testsuite/g++.old-deja/g++.mike/eh59.C new file mode 100644 index 000000000..f2f2bb3bc --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/eh59.C @@ -0,0 +1,18 @@ +// { dg-do run } +// { dg-options "-O -funroll-loops" } + +struct A { + ~A(); +}; + +void foo(); + +int main() { + for (int i=0;i<4;i++) { + A a; + foo(); + } +} + +void foo() { } +A::~A() { } diff --git a/gcc/testsuite/g++.old-deja/g++.mike/eh6.C b/gcc/testsuite/g++.old-deja/g++.mike/eh6.C new file mode 100644 index 000000000..cc29ea595 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/eh6.C @@ -0,0 +1,19 @@ +// { dg-do run { xfail sparc64-*-elf arm-*-pe } } +// { dg-options "-fexceptions" } + +extern "C" int printf(const char *, ...); + +void main1() { + throw 1; +} + + +int main() { + try { + main1(); + } catch (...) { + printf("Unwind works!\n"); + return 0; + } + return 1; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/eh7.C b/gcc/testsuite/g++.old-deja/g++.mike/eh7.C new file mode 100644 index 000000000..f431fb96d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/eh7.C @@ -0,0 +1,7 @@ +// { dg-do run { xfail sparc64-*-elf arm-*-pe } } +// { dg-options "-fexceptions" } + +main() { + if (0) + throw 1 | 2; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/eh8.C b/gcc/testsuite/g++.old-deja/g++.mike/eh8.C new file mode 100644 index 000000000..8e01da0b5 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/eh8.C @@ -0,0 +1,20 @@ +// { dg-do run { xfail sparc64-*-elf arm-*-pe } } +// { dg-options "-fexceptions" } + +extern "C" int printf(const char *, ...); + +int i; + +main() { + try { + try { + throw i; + } catch (char *) { + return 1; + } + return 1; + } catch (int i) { + return 0; + } + return 1; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/eh9.C b/gcc/testsuite/g++.old-deja/g++.mike/eh9.C new file mode 100644 index 000000000..633642faa --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/eh9.C @@ -0,0 +1,4 @@ +// { dg-do run { xfail sparc64-*-elf arm-*-pe } } +// { dg-options "-fexceptions" } + +main() throw () { } diff --git a/gcc/testsuite/g++.old-deja/g++.mike/enum1.C b/gcc/testsuite/g++.old-deja/g++.mike/enum1.C new file mode 100644 index 000000000..35b1df089 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/enum1.C @@ -0,0 +1,11 @@ +// { dg-do assemble } +// Warn if a enum cannot fit into a small bit-field. + +enum TypeKind { ATK, BTK, CTK, DTK } ; + +struct Type { + enum TypeKind kind : 1; // { dg-warning "" } + void setBTK(); +}; + +void Type::setBTK() { kind = DTK; } // { dg-warning "truncate" } diff --git a/gcc/testsuite/g++.old-deja/g++.mike/err1.C b/gcc/testsuite/g++.old-deja/g++.mike/err1.C new file mode 100644 index 000000000..8e15dd27a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/err1.C @@ -0,0 +1,8 @@ +// { dg-do assemble } + +struct gorf { + int stuff; + void snarf(); // { dg-error "" } +}; + +template <class T> void gorf::snarf() { return; } // { dg-error "" } diff --git a/gcc/testsuite/g++.old-deja/g++.mike/err2.C b/gcc/testsuite/g++.old-deja/g++.mike/err2.C new file mode 100644 index 000000000..9d8a596e6 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/err2.C @@ -0,0 +1,7 @@ +// { dg-do assemble } +class foo { +public: + void apply(foo *(foo::*memptr)()) { + this->*memptr(); // { dg-error "" } wrong + } +}; diff --git a/gcc/testsuite/g++.old-deja/g++.mike/err3.C b/gcc/testsuite/g++.old-deja/g++.mike/err3.C new file mode 100644 index 000000000..18161b31f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/err3.C @@ -0,0 +1,10 @@ +// { dg-do assemble } +class cb { +}; + +class cc { +public: + cc() + : cb() { // { dg-error "" } + } +}; diff --git a/gcc/testsuite/g++.old-deja/g++.mike/explicit1.C b/gcc/testsuite/g++.old-deja/g++.mike/explicit1.C new file mode 100644 index 000000000..b8284abaa --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/explicit1.C @@ -0,0 +1,16 @@ +// { dg-do assemble } +struct A1 { + explicit A1(int) { } +} a1(1); + +struct A { + explicit A(int); +} a(1); + +A::A(int) { +} + +void foo(A a) { + foo(a); + foo(1); // { dg-error "" } not allowed +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/explicit2.C b/gcc/testsuite/g++.old-deja/g++.mike/explicit2.C new file mode 100644 index 000000000..989367f83 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/explicit2.C @@ -0,0 +1,24 @@ +// { dg-do assemble } + +class string { +public: + string(const char*) { } + explicit string(int size) { } +}; + +void foo(string) { } + +string bar() { + foo("hello"); // ok + foo(string(2)); // ok + foo(2); // { dg-error "" } no implicit conversion from int to string + string x = 2; // { dg-error "" } no implicit conversion from int to string + string y(2); // ok + foo((string)2); // ok + return 2; // { dg-error "" } no implicit conversion from int to string +} + +class A : string { +public: + A() : string(2) { } // ok +}; diff --git a/gcc/testsuite/g++.old-deja/g++.mike/for1.C b/gcc/testsuite/g++.old-deja/g++.mike/for1.C new file mode 100644 index 000000000..0f2e543f8 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/for1.C @@ -0,0 +1,4 @@ +// { dg-do assemble } +int main() { + for( {int i = 0; int j = 0;} i < 10; ++i ) ; // { dg-error "" } +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/for2.C b/gcc/testsuite/g++.old-deja/g++.mike/for2.C new file mode 100644 index 000000000..42e6baa55 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/for2.C @@ -0,0 +1,22 @@ +// { dg-do assemble } + +void foo() { + for (class C {};;) + ; + C c; // { dg-error "declared" "decl" } + // { dg-error "expected" "exp" { target *-*-* } 6 } +} + +void bar() { + for (enum E {num};;) + ; + E e; // { dg-error "declared" "decl" } + // { dg-error "expected" "exp" { target *-*-* } 13 } +} + +void bee () { + int i = 0; + for (int fun() = 0; i != 2; ++i) { // { dg-warning "extern" "extern" } + // { dg-error "initialized" "init" { target *-*-* } 19 } + } +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/for3.C b/gcc/testsuite/g++.old-deja/g++.mike/for3.C new file mode 100644 index 000000000..80f66913b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/for3.C @@ -0,0 +1,10 @@ +// { dg-do assemble } +// { dg-options "-Wshadow" } + +int +main(int i) { // { dg-warning "" } shadowed decl + for(int i=1; i < 3; i++); // { dg-warning "" } declaration of + for(int i=1; i < 3; i++); // { dg-warning "" } declaration of + for(int j=1; j < 3; j++); + for(int j=1; j < 3; j++); +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/fresco1.C b/gcc/testsuite/g++.old-deja/g++.mike/fresco1.C new file mode 100644 index 000000000..fe90eb7e7 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/fresco1.C @@ -0,0 +1,13 @@ +// { dg-do assemble } + +// This is a Fresco found bug. + +class WhoCares {}; + +typedef float Coord; + +class BugDemo : public WhoCares { +public: + typedef Coord Matrix[4][4]; + virtual void vf1(BugDemo::Matrix m) = 0; +}; diff --git a/gcc/testsuite/g++.old-deja/g++.mike/hog1.C b/gcc/testsuite/g++.old-deja/g++.mike/hog1.C new file mode 100644 index 000000000..0dbbc0705 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/hog1.C @@ -0,0 +1,188 @@ +// { dg-do run } +class dummy { public: void operator++(void) {} + }; +class dummy_000 : private virtual dummy { public: void operator++(void) { +dummy::operator++(); } }; +class dummy_001 : private virtual dummy { public: void operator++(void) { +dummy::operator++(); } }; +class dummy_002 : private virtual dummy { public: void operator++(void) { +dummy::operator++(); } }; +class dummy_003 : private virtual dummy { public: void operator++(void) { +dummy::operator++(); } }; +class dummy_004 : private virtual dummy { public: void operator++(void) { +dummy::operator++(); } }; +class dummy_005 : private virtual dummy { public: void operator++(void) { +dummy::operator++(); } }; +class dummy_006 : private virtual dummy { public: void operator++(void) { +dummy::operator++(); } }; +class dummy_007 : private virtual dummy { public: void operator++(void) { +dummy::operator++(); } }; +class dummy_008 : private virtual dummy { public: void operator++(void) { +dummy::operator++(); } }; +class dummy_009 : private virtual dummy { public: void operator++(void) { +dummy::operator++(); } }; +class dummy_010 : private virtual dummy { public: void operator++(void) { +dummy::operator++(); } }; +class dummy_011 : private virtual dummy { public: void operator++(void) { +dummy::operator++(); } }; +class dummy_012 : private virtual dummy { public: void operator++(void) { +dummy::operator++(); } }; +class dummy_013 : private virtual dummy { public: void operator++(void) { +dummy::operator++(); } }; +class dummy_014 : private virtual dummy { public: void operator++(void) { +dummy::operator++(); } }; +class dummy_015 : private virtual dummy { public: void operator++(void) { +dummy::operator++(); } }; +class dummy_016 : private virtual dummy { public: void operator++(void) { +dummy::operator++(); } }; +class dummy_017 : private virtual dummy { public: void operator++(void) { +dummy::operator++(); } }; +class dummy_018 : private virtual dummy { public: void operator++(void) { +dummy::operator++(); } }; +class dummy_019 : private virtual dummy { public: void operator++(void) { +dummy::operator++(); } }; +class dummy_020 : private virtual dummy { public: void operator++(void) { +dummy::operator++(); } }; +class dummy_021 : private virtual dummy { public: void operator++(void) { +dummy::operator++(); } }; +class dummy_022 : private virtual dummy { public: void operator++(void) { +dummy::operator++(); } }; +class dummy_023 : private virtual dummy { public: void operator++(void) { +dummy::operator++(); } }; +class dummy_024 : private virtual dummy { public: void operator++(void) { +dummy::operator++(); } }; +class dummy_025 : private virtual dummy { public: void operator++(void) { +dummy::operator++(); } }; +class dummy_026 : private virtual dummy { public: void operator++(void) { +dummy::operator++(); } }; +class dummy_027 : private virtual dummy { public: void operator++(void) { +dummy::operator++(); } }; +class dummy_028 : private virtual dummy { public: void operator++(void) { +dummy::operator++(); } }; +class dummy_029 : private virtual dummy { public: void operator++(void) { +dummy::operator++(); } }; +class dummy_030 : private virtual dummy { public: void operator++(void) { +dummy::operator++(); } }; +class dummy_031 : private virtual dummy { public: void operator++(void) { +dummy::operator++(); } }; +class dummy_032 : private virtual dummy { public: void operator++(void) { +dummy::operator++(); } }; +class dummy_033 : private virtual dummy { public: void operator++(void) { +dummy::operator++(); } }; +class dummy_034 : private virtual dummy { public: void operator++(void) { +dummy::operator++(); } }; +class dummy_035 : private virtual dummy { public: void operator++(void) { +dummy::operator++(); } }; +class dummy_036 : private virtual dummy { public: void operator++(void) { +dummy::operator++(); } }; +class dummy_037 : private virtual dummy { public: void operator++(void) { +dummy::operator++(); } }; +class dummy_038 : private virtual dummy { public: void operator++(void) { +dummy::operator++(); } }; +class dummy_039 : private virtual dummy { public: void operator++(void) { +dummy::operator++(); } }; +class dummy_040 : private virtual dummy { public: void operator++(void) { +dummy::operator++(); } }; +class dummy_041 : private virtual dummy { public: void operator++(void) { +dummy::operator++(); } }; +class dummy_042 : private virtual dummy { public: void operator++(void) { +dummy::operator++(); } }; +class dummy_043 : private virtual dummy { public: void operator++(void) { +dummy::operator++(); } }; +class dummy_044 : private virtual dummy { public: void operator++(void) { +dummy::operator++(); } }; +class dummy_045 : private virtual dummy { public: void operator++(void) { +dummy::operator++(); } }; +class dummy_046 : private virtual dummy { public: void operator++(void) { +dummy::operator++(); } }; +class dummy_047 : private virtual dummy { public: void operator++(void) { +dummy::operator++(); } }; +class dummy_048 : private virtual dummy { public: void operator++(void) { +dummy::operator++(); } }; +class dummy_049 : private virtual dummy { public: void operator++(void) { +dummy::operator++(); } }; + +class super : + private dummy_000, private dummy_001, private dummy_002, private +dummy_003, private dummy_004, + private dummy_005, private dummy_006, private dummy_007, private +dummy_008, private dummy_009, + private dummy_010, private dummy_011, private dummy_012, private +dummy_013, private dummy_014, + private dummy_015, private dummy_016, private dummy_017, private +dummy_018, private dummy_019, + private dummy_020, private dummy_021, private dummy_022, private +dummy_023, private dummy_024, + private dummy_025, private dummy_026, private dummy_027, private +dummy_028, private dummy_029, + private dummy_030, private dummy_031, private dummy_032, private +dummy_033, private dummy_034, + private dummy_035, private dummy_036, private dummy_037, private +dummy_038, private dummy_039, + private dummy_040, private dummy_041, private dummy_042, private +dummy_043, private dummy_044, + private dummy_045, private dummy_046, private dummy_047, private +dummy_048, private dummy_049 +{ +public: + void operator++(void); +}; + +void super::operator++(void) +{ + dummy_000::operator++(); + dummy_001::operator++(); + dummy_002::operator++(); + dummy_003::operator++(); + dummy_004::operator++(); + dummy_005::operator++(); + dummy_006::operator++(); + dummy_007::operator++(); + dummy_008::operator++(); + dummy_009::operator++(); + dummy_010::operator++(); + dummy_011::operator++(); + dummy_012::operator++(); + dummy_013::operator++(); + dummy_014::operator++(); + dummy_015::operator++(); + dummy_016::operator++(); + dummy_017::operator++(); + dummy_018::operator++(); + dummy_019::operator++(); + dummy_020::operator++(); + dummy_021::operator++(); + dummy_022::operator++(); + dummy_023::operator++(); + dummy_024::operator++(); + dummy_025::operator++(); + dummy_026::operator++(); + dummy_027::operator++(); + dummy_028::operator++(); + dummy_029::operator++(); + dummy_030::operator++(); + dummy_031::operator++(); + dummy_032::operator++(); + dummy_033::operator++(); + dummy_034::operator++(); + dummy_035::operator++(); + dummy_036::operator++(); + dummy_037::operator++(); + dummy_038::operator++(); + dummy_039::operator++(); + dummy_040::operator++(); + dummy_041::operator++(); + dummy_042::operator++(); + dummy_043::operator++(); + dummy_044::operator++(); + dummy_045::operator++(); + dummy_046::operator++(); + dummy_047::operator++(); + dummy_048::operator++(); + dummy_049::operator++(); +} + + +int main(void) +{ +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/init1.C b/gcc/testsuite/g++.old-deja/g++.mike/init1.C new file mode 100644 index 000000000..5bc1ea4a9 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/init1.C @@ -0,0 +1,28 @@ +// The VxWorks kernel has no implementation of atexit, so local statics +// are never destroyed. +// { dg-do run { xfail vxworks_kernel } } +int count; + +extern "C" void _exit(int); + +struct C { + ~C() { if (count != 1) _exit(1); } +} c; + +class A { +public: + ~A () { ++count; } +}; + +void f() { + static A a; +} + +void g() { + // Since this isn't constructed, we can't destruct it. + static A a; +} + +int main () { + f(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/init2.C b/gcc/testsuite/g++.old-deja/g++.mike/init2.C new file mode 100644 index 000000000..81f6e4f1d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/init2.C @@ -0,0 +1,9 @@ +// { dg-do assemble } + +struct Foo { + Foo (int); +}; + +int bar (Foo); + +int x = bar (3); diff --git a/gcc/testsuite/g++.old-deja/g++.mike/leak1.C b/gcc/testsuite/g++.old-deja/g++.mike/leak1.C new file mode 100644 index 000000000..403a73755 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/leak1.C @@ -0,0 +1,39 @@ +// { dg-do run } +int count = 0; + +class T { + int i; +public: + T() { + i = 1; + ++count; + } + T(const T& o) { + i = o.i; + ++count; + } + T operator +(const T& o) { + T r; + r.i = this->i + o.i; + return r; + } + operator int () { + return i; + } + ~T() { + --count; + } +} s, b; + +void bar() { + static int j = int(s+b); + int i = int(s+b); +} + +int i = int(s+b); + +int main() { + bar(); + bar(); + return count != 2; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/mangle1.C b/gcc/testsuite/g++.old-deja/g++.mike/mangle1.C new file mode 100644 index 000000000..de5e96588 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/mangle1.C @@ -0,0 +1,27 @@ +// { dg-do assemble } +// { dg-options "" } + +// Make sure the typedef name is used in name mangling, not some random +// anonymous name + +struct foo { + typedef enum { red } color; + void bar(color r) { + } +} f; + +#ifdef sparc +void f1() asm("bar__3fooQ23foo3$_0"); +void f1() { +} +void f2() asm("_bar__3fooQ23foo3$_0"); +void f2() { +} +void f3() asm("__bar__3fooQ23foo3$_0"); +void f3() { +} +#endif + +main() { + f.bar(foo::red); +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/mangle2.C b/gcc/testsuite/g++.old-deja/g++.mike/mangle2.C new file mode 100644 index 000000000..720c3c3ae --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/mangle2.C @@ -0,0 +1,17 @@ +// { dg-do assemble } +// { dg-options "" } + +typedef struct { +} color; + +void foo(color) { +} + +#ifdef sparc +void f1() asm("foo__FG3$_0"); +void f1() { } +void f2() asm("_foo__FG3$_0"); +void f2() { } +void f3() asm("__foo__FG3$_0"); +void f3() { } +#endif diff --git a/gcc/testsuite/g++.old-deja/g++.mike/mangle3.C b/gcc/testsuite/g++.old-deja/g++.mike/mangle3.C new file mode 100644 index 000000000..4b3e5812c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/mangle3.C @@ -0,0 +1,15 @@ +// { dg-do run } +struct ZZ { + int p; +}; + + +template <int ZZ::* ptr> +struct YY { + ZZ qq; + YY() { } +}; + +int main() { + YY<&ZZ::p> ww; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/mi1.C b/gcc/testsuite/g++.old-deja/g++.mike/mi1.C new file mode 100644 index 000000000..e5f01c4d6 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/mi1.C @@ -0,0 +1,45 @@ +// { dg-do run } +// { dg-options "-w" } + +class A { +public: + virtual ~A(){}; + virtual int type(void) { + return -1; + } +}; + +class B : public A { +public: + virtual ~B(){}; +}; + + +class C0 : public B, public virtual A { +public: + virtual int type(void) { + return 0; + } +}; + +class C1 : public C0 +{ +public: + virtual int type(void) { + return 1; + } +}; + +class C2 : public C0 { +public: + virtual int type(void) { + return 2; + } +}; + +main() { + C1 *one = new C1; + + if (one->type() != 1) + return 1; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/mi2.C b/gcc/testsuite/g++.old-deja/g++.mike/mi2.C new file mode 100644 index 000000000..51d8d2fa5 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/mi2.C @@ -0,0 +1,47 @@ +// { dg-do run } +class A { + char a; +public: + A(char x) : a(x) { } + virtual ~A() { } +}; + +class B : virtual public A { + char b; +public: + B(char x) : A('b'), b(x) { } + ~B() { } +}; + +class C : virtual public A { + char c; +public: + C(char x) : A('c'), c(x) { } + ~C() { } +}; + +class D : virtual public A, public B, public C { + char d; +public: + D(char x) : A('d'), B('d'), C('d'), d(x) { } + ~D() { } +}; + +class E : virtual public A, public B, public C { + char e; +public: + E(char x) : A('e'), B('e'), C('e'), e(x) { } + ~E() { } +}; + +class F : virtual public A, public D, public E { + char f; +public: + F(char x) : A('f'), D('f'), E('f'), f(x) { } + ~F() { } +}; + +int main() { + F f('x'); + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/misc1.C b/gcc/testsuite/g++.old-deja/g++.mike/misc1.C new file mode 100644 index 000000000..7a6021856 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/misc1.C @@ -0,0 +1,54 @@ +// { dg-do run } +// GROUPS passed construct-destruct +/* g++ constructs j 13 times, and destructs it once. */ + +extern "C" { + int printf (const char *, ...); + void exit(int); +} + +void foo() { +} + +class C { + int val; + public: + static int count; + C(int ii) { + val = ii; + ++count; + printf("up\n"); + } + ~C() { + --count; + printf("down\n"); + } + int operator ++() { + return ++val; + } + operator int() { + return val; + } +}; + +int C::count = 0; + +void bar() { + for (int ii=0; ii<13; ++ii) + for (C j=1; j<9; ++j) + foo(); +} + +int main() { + bar(); + if (C::count) + { + printf("FAIL\n"); + exit(1); + } + else + { + printf("PASS\n"); + } + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/misc11.C b/gcc/testsuite/g++.old-deja/g++.mike/misc11.C new file mode 100644 index 000000000..23fc10a77 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/misc11.C @@ -0,0 +1,4 @@ +// { dg-do assemble } +// GROUPS passed pt coredump +template<class T> class A; +void f () { A<int> *a; } diff --git a/gcc/testsuite/g++.old-deja/g++.mike/misc12.C b/gcc/testsuite/g++.old-deja/g++.mike/misc12.C new file mode 100644 index 000000000..1ac53bb9a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/misc12.C @@ -0,0 +1,8 @@ +// { dg-do assemble } +// GROUPS passed +struct A { virtual void f(); }; +struct B { virtual void f() ; }; +struct C : virtual A , virtual B { virtual void f(); }; + +/* This used to get an error because the DECL_CONTEXT was blown away. */ +void g(A *ptr) { ptr->f(); } diff --git a/gcc/testsuite/g++.old-deja/g++.mike/misc13.C b/gcc/testsuite/g++.old-deja/g++.mike/misc13.C new file mode 100644 index 000000000..f85a4f408 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/misc13.C @@ -0,0 +1,54 @@ +// { dg-do run } +// GROUPS passed vtable +extern "C" int printf (const char *, ...); +enum E { vf_request, vf_event } want; + +int errs = 0; + +class ivResource { +public: + virtual ~ivResource () { } +}; + +class ivHandler : public ivResource { +public: + virtual void event() { } +}; + +class ivGlyph : public ivResource { +public: + virtual ~ivGlyph () { } + virtual void request () { + if (want!=vf_request) + ++errs; + } +}; + +class ItemView : public ivGlyph, public ivHandler { +public: + virtual void event () { + if (want!=vf_event) + ++errs; + } +} a; + +ivGlyph *bar() { + return &a; +} + +ivHandler *bar2() { + return &a; +} + +int main() { + want=vf_request; + bar()->request(); + want=vf_event; + bar2()->event(); + if (errs) { + printf("FAIL\n"); + return 1; + } + printf("PASS\n"); + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/misc14.C b/gcc/testsuite/g++.old-deja/g++.mike/misc14.C new file mode 100644 index 000000000..6f966f211 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/misc14.C @@ -0,0 +1,28 @@ +// { dg-do run } +// GROUPS passed +extern "C" int printf (const char *, ...); +extern "C" void exit(int); + +class A { +public: + virtual ~A() { + printf("FAIL\n"); + exit (1); + } +}; + +class B : public A { +public: + virtual ~B() { + printf("PASS\n"); + exit (0); + } +}; + +int main() { + B b; + A *ap = &b; + ap->~A(); // This should call the destructor virtually. + printf("FAIL\n"); + return 1; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/misc2.C b/gcc/testsuite/g++.old-deja/g++.mike/misc2.C new file mode 100644 index 000000000..8ac736768 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/misc2.C @@ -0,0 +1,11 @@ +// { dg-do assemble } +// { dg-options "-ansi -pedantic" } +// GROUPS passed +/* -ansi -pedantic-errors should catch this. */ + +class C { + public: + extern inline int A() {// { dg-error "" } .* + return 1; + } +}; diff --git a/gcc/testsuite/g++.old-deja/g++.mike/misc3.C b/gcc/testsuite/g++.old-deja/g++.mike/misc3.C new file mode 100644 index 000000000..560f0c13e --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/misc3.C @@ -0,0 +1,4 @@ +// { dg-do assemble } +// GROUPS uncaught +int a;// { dg-error "" } .* +int a;// { dg-error "" } .* diff --git a/gcc/testsuite/g++.old-deja/g++.mike/misc5.C b/gcc/testsuite/g++.old-deja/g++.mike/misc5.C new file mode 100644 index 000000000..245c9a2ca --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/misc5.C @@ -0,0 +1,11 @@ +// { dg-do assemble } +// GROUPS uncaught +// Cfront bug A.3 (See Language System Release Notes for the +// SPARCompiler C++ version 3.0) + +struct S1 { + static int S1; // { dg-error "" } uses same name 9.3 +}; +struct S2 { + union { int ii; float S2; }; // { dg-error "" } uses same name 9.3 +}; diff --git a/gcc/testsuite/g++.old-deja/g++.mike/misc6.C b/gcc/testsuite/g++.old-deja/g++.mike/misc6.C new file mode 100644 index 000000000..a717483b0 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/misc6.C @@ -0,0 +1,14 @@ +// { dg-do assemble } +// { dg-prune-output "note" } +// { dg-options "-std=c++98 -pedantic-errors" } + +// GROUPS uncaught +// Cfront bug A.4 (See Language System Release Notes for the +// SPARCompiler C++ version 3.0) + +struct assign { + assign& operator = (const assign&); +}; +union U { + assign a; // { dg-error "" } member of union cannot have op= 9.4// ERROR - .* +}; diff --git a/gcc/testsuite/g++.old-deja/g++.mike/misc7.C b/gcc/testsuite/g++.old-deja/g++.mike/misc7.C new file mode 100644 index 000000000..34e0d3a37 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/misc7.C @@ -0,0 +1,16 @@ +// { dg-do assemble } +// GROUPS passed MI +struct S1 { }; + +struct S2 : S1 { }; +struct S3 : S1 { }; + +struct S4 : S3, S2 { }; + +struct S1 *p1; +struct S4 *p4; + +void foobar () +{ + p1 = p4; // { dg-error "" } this is illegal// ERROR - .* +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/misc8.C b/gcc/testsuite/g++.old-deja/g++.mike/misc8.C new file mode 100644 index 000000000..d8852c7d3 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/misc8.C @@ -0,0 +1,5 @@ +// { dg-do assemble } +// GROUPS passed vtable +class T { public: virtual ~T() {} }; +template<class P> class X : public virtual T {}; +int main() { X<int> x; } diff --git a/gcc/testsuite/g++.old-deja/g++.mike/misc9.C b/gcc/testsuite/g++.old-deja/g++.mike/misc9.C new file mode 100644 index 000000000..3d8858cf6 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/misc9.C @@ -0,0 +1,13 @@ +// { dg-do assemble } +// { dg-options "-Wall -pedantic" } +// GROUPS passed qualifiers +class bee { + public: + int bee::bar; // { dg-error "extra" } there is an extra bee:: here +}; + +class foo { + public: + int bee::bar; // { dg-error "not derived" } you cannot do this + int me(); +}; diff --git a/gcc/testsuite/g++.old-deja/g++.mike/net1.C b/gcc/testsuite/g++.old-deja/g++.mike/net1.C new file mode 100644 index 000000000..72b8e72d7 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/net1.C @@ -0,0 +1,19 @@ +// { dg-do assemble } +// Here is a net bug + +class ivAllocation { +public: + ivAllocation(); + int x_; +}; + +class TBScrollBoxInfo { +public: + ivAllocation allocation_; +}; + +TBScrollBoxInfo* items_; + +inline TBScrollBoxInfo item() { + return items_[0]; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/net10.C b/gcc/testsuite/g++.old-deja/g++.mike/net10.C new file mode 100644 index 000000000..f200f9527 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/net10.C @@ -0,0 +1,15 @@ +// { dg-do assemble } +// { dg-options "-pedantic-errors" } + +const int ci=10, *pc = &ci, *const cpc = pc, **ppc; +int i, *p, *const cp = &i; + +int main() +{ + i = ci; + *cp = ci; + pc++; + pc = cpc; + pc = p; + ppc = &pc; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/net11.C b/gcc/testsuite/g++.old-deja/g++.mike/net11.C new file mode 100644 index 000000000..c9eeec134 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/net11.C @@ -0,0 +1,16 @@ +// { dg-do assemble } +// { dg-options "-pedantic-errors" } + +struct Foo { + char *p; + const char *q; + void m() const; +}; + +void other(char &x); + +void +Foo::m() const +{ + other(*p); // this is legal +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/net12.C b/gcc/testsuite/g++.old-deja/g++.mike/net12.C new file mode 100644 index 000000000..59e062a78 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/net12.C @@ -0,0 +1,16 @@ +// { dg-do assemble } +// { dg-options "-pedantic-errors" } + +struct Foo { + char *p; + const char *q; + void m() const; +}; + +void other(char &x); // { dg-error "" } reference below + +void +Foo::m() const +{ + other(*q); // { dg-error "" } this is bad +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/net13.C b/gcc/testsuite/g++.old-deja/g++.mike/net13.C new file mode 100644 index 000000000..acf1f65ba --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/net13.C @@ -0,0 +1,14 @@ +// { dg-do assemble } + +// make sure extern "C" friends work. + +extern "C" { void func(); } + +struct crash { + int i; + friend void func(); +} a; + +void func() { + a.i = 1; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/net14.C b/gcc/testsuite/g++.old-deja/g++.mike/net14.C new file mode 100644 index 000000000..36b2b236c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/net14.C @@ -0,0 +1,7 @@ +// { dg-do assemble } +// this probably does not have correct debugging info generated. + +typedef struct Thing { + Thing(); + int x; +} Thing; diff --git a/gcc/testsuite/g++.old-deja/g++.mike/net15.C b/gcc/testsuite/g++.old-deja/g++.mike/net15.C new file mode 100644 index 000000000..4d7129ee9 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/net15.C @@ -0,0 +1,47 @@ +// { dg-do run } +// InterViews (ibuild) requires this to work. + +extern "C" void exit(int); + +void *old; + +class c1 +{ + int i; +public: + c1 () {} +}; + +class c2 +{ + int j; +public: + c2 () {} +}; + +class c3 : public c1, public c2 +{ +public: + c3 () + { + old = this; + // printf("new object c3 at %x\n", (int)this); } + } +}; + +c2* f () +{ + c2* n = new c3 (); + // printf ("new object c3 casted to c2 at %x\n", (int)n); + return n; +} + +int main () +{ + c3* o = (c3*)f (); + // printf("new object c3, upcasted from c2 at %x\n", (int)o); + // if old and o are not the same, fail the test case. + if (old != o) + exit(1); + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/net16.C b/gcc/testsuite/g++.old-deja/g++.mike/net16.C new file mode 100644 index 000000000..0f15f7133 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/net16.C @@ -0,0 +1,8 @@ +// { dg-do run } +// On an i386, this core dumps because the reg-stack.c code is wrong, and +// pops an fp register that it thinks is not used, but it is. + +extern "C" int printf (const char*, ...); +struct S { ~S () { } }; +double f (S) { return 5; } +int main() { S s; double dist = f (s); printf ("%g\n", dist); return 0; } diff --git a/gcc/testsuite/g++.old-deja/g++.mike/net17.C b/gcc/testsuite/g++.old-deja/g++.mike/net17.C new file mode 100644 index 000000000..56a3c24f3 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/net17.C @@ -0,0 +1,59 @@ +// { dg-do run } +// example from the ARM page 292 and 293 + +extern "C" int printf(const char *, ...); +extern "C" void exit(int); + +int i = 0; + +class A { +public: + A() { + printf("Doing A\n"); + if (++i != 1) + exit(1); + } +}; + +class B { +public: + B() { + printf("Doing B\n"); + if (++i != 2) + exit(1); + } +}; + +class C : public virtual A, public virtual B { +public: + C() { + printf("Doing C\n"); + if (++i != 3) + exit(1); + } +}; + +class D : public virtual B, public virtual A { +public: + D() { + printf("Doing D\n"); + if (++i != 4) + exit(1); + } +}; + +class E : public C, public D { +public: + E() { + printf("Doing E\n"); + if (++i != 5) + exit(1); + } +} e; + + +int main() { + if (++i != 6) + exit(1); + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/net18.C b/gcc/testsuite/g++.old-deja/g++.mike/net18.C new file mode 100644 index 000000000..2123c8152 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/net18.C @@ -0,0 +1,21 @@ +// { dg-do assemble } + +class ClassA { +public: + typedef ClassA& (*PMFV)(const char*); + static PMFV setMapper(PMFV); + static PMFV _mapper; +}; + +class ClassB { +public: + typedef ClassB& (*PMFV)(const char*); +}; + +ClassA::PMFV ClassA::setMapper(ClassA::PMFV newFunc) +{ + PMFV oldFunc = _mapper; + _mapper = newFunc; + + return oldFunc; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/net19.C b/gcc/testsuite/g++.old-deja/g++.mike/net19.C new file mode 100644 index 000000000..028316680 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/net19.C @@ -0,0 +1,20 @@ +// { dg-do assemble } +// Test to make sure &<incomplete record type> works in c++ + +struct FILE { + int _flags; +}; + +extern struct _fake_filebuf __std_filebuf_2; + +class Value { + int width; +public: + Value(); + friend Value operator&( __const Value&, __const Value&); +}; + +FILE* Foo () +{ + return ((FILE*)&__std_filebuf_2); +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/net2.C b/gcc/testsuite/g++.old-deja/g++.mike/net2.C new file mode 100644 index 000000000..dfc57e149 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/net2.C @@ -0,0 +1,14 @@ +// { dg-do assemble } +// Here is another program from the net. + +class B; + +class A { // { dg-message "note" } copy ctor candidate + private: + A(B *); // { dg-message "note" } + public: + A(long); // { dg-message "note" } +}; + +A a(0); // { dg-error "ambiguous" } +// { dg-message "candidate" "candidate note" { target *-*-* } 13 } diff --git a/gcc/testsuite/g++.old-deja/g++.mike/net20.C b/gcc/testsuite/g++.old-deja/g++.mike/net20.C new file mode 100644 index 000000000..e972013a0 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/net20.C @@ -0,0 +1,12 @@ +// { dg-do assemble } +// A pointer to member function test case. + +struct X +{ +}; + +void (X::* fee ())() +{ + lab: goto lab; + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/net21.C b/gcc/testsuite/g++.old-deja/g++.mike/net21.C new file mode 100644 index 000000000..dab95a6fc --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/net21.C @@ -0,0 +1,60 @@ +// { dg-do run } +// Make sure we can initialize complex (MI ambiguous) vtables. + +extern "C" int printf(const char *, ...); + +struct a +{ + virtual void f() = 0; +}; + +struct b +{ + virtual void g() { } +}; + +struct c: public a, public b +{ + virtual void f(); + virtual void g(); +}; + +void c::f() +{ + printf("c::f()\n"); +} + +void c::g() +{ + printf("c::g()\n"); +} + +struct e: public b +{ +}; + +struct h +{ +}; + +struct d: public c, public e, public h +{ + virtual void f(); + virtual void g(); +}; +void d::f() +{ + printf("d::f()\n"); +} + +void d::g() +{ + printf("d::g()\n"); +} + +int main(int argc, char* argv[]) +{ + a* tmp = new d; + tmp->f(); + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/net22.C b/gcc/testsuite/g++.old-deja/g++.mike/net22.C new file mode 100644 index 000000000..604aef9bc --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/net22.C @@ -0,0 +1,15 @@ +// { dg-do assemble } +class Parent { +public: + Parent() {} + Parent( char *s ) {} +}; + +class Child : public Parent { // { dg-message "note" } called +}; + +int main() { + Child c( "String initializer" ); // { dg-error "match" } bad + // { dg-message "candidate" "candidate note" { target *-*-* } 12 } + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/net23.C b/gcc/testsuite/g++.old-deja/g++.mike/net23.C new file mode 100644 index 000000000..97120ea90 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/net23.C @@ -0,0 +1,15 @@ +// { dg-do assemble } + +class environment { +public: + int get_font() ; +}; + +typedef int (environment::*INT_FUNCP)(); + +void myfoo(INT_FUNCP a); + +void init_env_requests() +{ + myfoo(&environment::get_font); +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/net24.C b/gcc/testsuite/g++.old-deja/g++.mike/net24.C new file mode 100644 index 000000000..471785ffb --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/net24.C @@ -0,0 +1,3 @@ +// { dg-do assemble } + + char HexDigit(unsigned char ch) { return ch < 'f'; } diff --git a/gcc/testsuite/g++.old-deja/g++.mike/net25.C b/gcc/testsuite/g++.old-deja/g++.mike/net25.C new file mode 100644 index 000000000..57b66eafa --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/net25.C @@ -0,0 +1,17 @@ +// { dg-do assemble } + +void shake_zero() +{ +} + +void shake_one() +{ +} + +void (*foo)(); + +int main(int a, char** /*argv*/) +{ + foo = a ? shake_zero : shake_one; + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/net26.C b/gcc/testsuite/g++.old-deja/g++.mike/net26.C new file mode 100644 index 000000000..8d03278b9 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/net26.C @@ -0,0 +1,28 @@ +// { dg-do run } +// A test case found by InterViews testing... + +extern "C" int printf(const char *, ...); + +class A { +public: + int foo() { printf("ok nv\n"); return 0; } + virtual int vfoo() { printf("ok v\n"); return 0; } +}; + +struct S { + int (A::*pfn1)(); + int (A::*pfn2)(); + int (A::*pfn3)(); +}; + +// This failed before. +S s = { &A::foo, &A::vfoo, &A::foo }; + +A a; + +int main() { + (a.*s.pfn1)(); + (a.*s.pfn2)(); + printf("PASS\n"); + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/net27.C b/gcc/testsuite/g++.old-deja/g++.mike/net27.C new file mode 100644 index 000000000..8b1715330 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/net27.C @@ -0,0 +1,9 @@ +// { dg-do assemble } + +class path { +public: + path (const path& r) + { "\""; + '\''; + } +}; diff --git a/gcc/testsuite/g++.old-deja/g++.mike/net28.C b/gcc/testsuite/g++.old-deja/g++.mike/net28.C new file mode 100644 index 000000000..5cac8563c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/net28.C @@ -0,0 +1,28 @@ +// { dg-do assemble } +// From reinhard@ifki50.informatik.fh-muenchen.de against gcc 2.5.0. +// shows an InterViews problem on RS6000 and i386. Doesn't happen on +// SPARC. + +// From fbrowser.c. + + +class test { +}; + + +typedef int ( test ::* test2)(int fd); + +class ivFileBrowserImpl_IOCallback +{ + public: + + int inputReady(int fd); + test * _obj; + test2 _input; +}; + + +int ivFileBrowserImpl_IOCallback ::inputReady(int fd) +{ + return (_obj->*_input)(fd); +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/net29.C b/gcc/testsuite/g++.old-deja/g++.mike/net29.C new file mode 100644 index 000000000..1cce5a296 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/net29.C @@ -0,0 +1,27 @@ +// { dg-do assemble } +// This is a test case for the recent libg++ make check problem. + +class SubString { +public: + SubString(); + SubString(const SubString& x); +}; + +class String { +public: + String(); + String(const SubString& x); +}; + +int operator!=(const String& x, const SubString& y); +int operator!=(const String& x, const String& y); + +int operator!=(const SubString& x, const String& y); +int operator!=(const SubString& x, const SubString& y); + +void comparetest() +{ + String x; + SubString s; + x != s; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/net3.C b/gcc/testsuite/g++.old-deja/g++.mike/net3.C new file mode 100644 index 000000000..7c89facdd --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/net3.C @@ -0,0 +1,16 @@ +// { dg-do assemble } +// Here is another program from the net. + +class BOOL { + public: + int val; + + BOOL(int i =0); + operator int(); +}; + +BOOL& foo() +{ + static BOOL status; + return status; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/net30.C b/gcc/testsuite/g++.old-deja/g++.mike/net30.C new file mode 100644 index 000000000..2a96ed7a0 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/net30.C @@ -0,0 +1,18 @@ +// { dg-do assemble } + +class X { +public: + void x(void); +}; + +class Y : public X { +}; + +class Z : private Y { +public: + void y(void); +}; + +void Z::y(void) { + x(); // should be OK +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/net31.C b/gcc/testsuite/g++.old-deja/g++.mike/net31.C new file mode 100644 index 000000000..8bc159b13 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/net31.C @@ -0,0 +1,68 @@ +// { dg-do assemble } + +class foo_a { + protected: + double func(int xi) {return 0.0;} + public: + foo_a() {} +}; + +class foo_b { + public: + foo_b(int); + foo_b(); + ~foo_b(); + foo_b(const foo_b&); + double& operator()(int); + foo_b& operator=(foo_b&); + void bar_a(int); +}; + +foo_b& operator*(foo_b&, foo_b&); +foo_b& operator*(double, foo_b&); + +template <class TP> +class foo_c { + typedef double (TP::* Tmatf)(int); + int m; + Tmatf* a; + void foo_cinst (int mm); + public: + foo_c(int mm); + foo_c() {m = 0; a = 0;} + ~foo_c() {delete a;} + double (TP::*& operator()(int i))(int) {return a[i];} + foo_b& bug_func(int); +}; + +template <class TP> +foo_b& foo_c<TP>::bug_func(int x) { + static foo_b retval(m); + retval.bar_a(m); + for (register int i = 0; i < m; i++) + retval(i) = (*(operator()(i)))(x); // { dg-error "invalid use of unary '\\\*'" } + return retval; +} + +template <class TP> +class foo_d { + protected: + foo_c<TP> bar_b; + public: + foo_d() {} + virtual ~foo_d() {} + virtual void setfoo_c(); +}; + +class foo_e : public foo_a, public foo_d<foo_a> { + public: + foo_e(); + ~foo_e() {} + void setfoo_c(); +}; + +void foo_e::setfoo_c() { + bar_b(0) = func; // { dg-error "" } +} + +template class foo_c<foo_a>; diff --git a/gcc/testsuite/g++.old-deja/g++.mike/net32.C b/gcc/testsuite/g++.old-deja/g++.mike/net32.C new file mode 100644 index 000000000..43c1ed141 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/net32.C @@ -0,0 +1,10 @@ +// { dg-do assemble } + +class Co_obj { +public: + Co_obj() {} + }; +class Linear_list_node : virtual public Co_obj { }; +class M1 : public Linear_list_node { }; +class M2 : public Linear_list_node { }; +class New_node : public M1, public M2 { }; diff --git a/gcc/testsuite/g++.old-deja/g++.mike/net34.C b/gcc/testsuite/g++.old-deja/g++.mike/net34.C new file mode 100644 index 000000000..19a7e16ba --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/net34.C @@ -0,0 +1,41 @@ +// { dg-do run } +// { dg-options "" } + +#include <iostream> + +class foo { +public: + foo(int i) {k = i;} +protected: + int k; +}; + +class bar_1 : public foo { +public: + bar_1(int i) : foo(i) {} + int get_k() {return k;} +}; + +class bar_2 : public foo { +public: + bar_2(int i) : foo(i) {} + int get_k() {return k;} +}; + +class multiple : public bar_1, public bar_2 { +public: + multiple(int i1, int i2) : bar_1(i1), bar_2(i2) {} + void print() { + 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"; + } +}; + +int main() { + multiple m(1,2); + m.print(); +} + + diff --git a/gcc/testsuite/g++.old-deja/g++.mike/net35.C b/gcc/testsuite/g++.old-deja/g++.mike/net35.C new file mode 100644 index 000000000..bded913c0 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/net35.C @@ -0,0 +1,28 @@ +// { dg-do run } +extern "C" int printf(const char *, ...); + +class A { + public: + char *x; +}; + +class B1:public virtual A { }; + +class B2:public virtual A { }; + +class C:public B1, public B2 { +public: + C() { } +}; + +int main() { + C c; + printf("&c.x = %x\n", &c.x); + printf("&c.B1::x = %x\n", &c.B1::x); + printf("&c.B2::x = %x\n", &c.B2::x); + printf("&c.A::x = %x\n", &c.A::x); + if (&c.x != &c.B1::x + || &c.x != &c.B2::x + || &c.x != &c.A::x) + return 1; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/net36.C b/gcc/testsuite/g++.old-deja/g++.mike/net36.C new file mode 100644 index 000000000..3ffa60e37 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/net36.C @@ -0,0 +1,19 @@ +// { dg-do assemble } + +class X; + +class A { +public: + void handlerFn(X*); +}; + +typedef void (A::*handler) (X*); + +class B { +public: + void setHandler(handler); +}; + +void f(B* b) { + b->setHandler(A::handlerFn); // { dg-error "" } +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/net37.C b/gcc/testsuite/g++.old-deja/g++.mike/net37.C new file mode 100644 index 000000000..35f3bca40 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/net37.C @@ -0,0 +1,40 @@ +// { dg-do run } +class B { +public: + int bi; + void bProc ( void ) { bi = 39; } + }; + +class D : public B { +public: + int di; + void dProc (void ){ di = 42; } + }; + +typedef void (B::*BPROC)(void); +typedef void (D::*DPROC)(void); + +union AFX_PMSG { +public: + + AFX_PMSG () {} + AFX_PMSG ( BPROC bpr ) { bfn = bpr ; } + + operator BPROC() { return bfn; } + + BPROC bfn; + DPROC dfn; +}; + + +int main(int argc, char *argv[]) { + B b; + D d; + + BPROC bpr = &B::bProc; + AFX_PMSG pmsg(bpr); + + BPROC ppr = pmsg; + + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/net38.C b/gcc/testsuite/g++.old-deja/g++.mike/net38.C new file mode 100644 index 000000000..de00a15fb --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/net38.C @@ -0,0 +1,29 @@ +// { dg-do run } +struct A { + virtual int a () { return 0; } +}; + +struct B { + virtual int b () { return 0; } + virtual int b2 () { return 0; } +}; + +struct C : public A, public B { + virtual int a () { return 1; } + virtual int b () { return 2; } + virtual int b2 () { return 3; } +}; + +int (C::*vmpb) () = &C::b; +int (C::*vmpb2) () = &C::b2; +int (C::*vmpa) () = &C::a; + +int main () { + C c; + if ((c.*vmpa)() != 1) + return 1; + if ((c.*vmpb)() != 2) + return 1; + if ((c.*vmpb2)() != 3) + return 1; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/net39.C b/gcc/testsuite/g++.old-deja/g++.mike/net39.C new file mode 100644 index 000000000..6554b3359 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/net39.C @@ -0,0 +1,31 @@ +// { dg-do run } +void *vp; + +class silly { +public: + virtual int b() { return 1; } +}; +class solly : silly { +public: + virtual int b() { return 2; } +}; +class thing { +public: + virtual int a() { return 3; } +}; +class thong : public solly, public thing { +public: + virtual int a() { + if (this != vp) return 4; + else return 0; + } +}; + +typedef int(thing::*ping)(); +ping qq = &thing::a; + +int main() { + thong b; + vp = &b; + return (b.*qq)(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/net4.C b/gcc/testsuite/g++.old-deja/g++.mike/net4.C new file mode 100644 index 000000000..cc6712f0a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/net4.C @@ -0,0 +1,32 @@ +// { dg-do assemble } +// Message-Id: <m0lLuUK-0000fRC@nix.appli.se> +// Date: Wed, 4 Mar 92 12:50 MET +// From: niklas@appli.se (Niklas Hallqvist) +// To: eichin@cygnus.com, tiemann@cygnus.com +// Cc: gcc2@cygnus.com +// Subject: nested type handling +// +// The last couple of days I've been struggling with nested types in the +// C++ compiler. Frankly, it's a mess! Was it impossible to put the stuff +// into the parser instead of the lexer? Well, anyway, to get the following +// code to compile: +// +// struct O { +// struct M { +// struct I +// {}; +// }; +// }; +// O::M::I s; +// +// a patch enclosed below is needed. I'm not sure if it causes any +// unanticipated side-effects, but it seem to work well for me. + + +struct O { + struct M { + struct I + {}; + }; +}; +O::M::I s; diff --git a/gcc/testsuite/g++.old-deja/g++.mike/net40.C b/gcc/testsuite/g++.old-deja/g++.mike/net40.C new file mode 100644 index 000000000..2a87a0c0e --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/net40.C @@ -0,0 +1,19 @@ +// { dg-do run } +#include <stddef.h> +#include <stdlib.h> + +class toto { +public: + void * operator new (size_t t) { + abort(); + } + void operator delete (void*p, size_t t) { + abort(); + } +}; + +int main() { + toto * p; + p = new toto[5]; + delete [] p; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/net41.C b/gcc/testsuite/g++.old-deja/g++.mike/net41.C new file mode 100644 index 000000000..4180778e4 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/net41.C @@ -0,0 +1,4 @@ +// { dg-do run } +int main() { + int i = ~ false; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/net42.C b/gcc/testsuite/g++.old-deja/g++.mike/net42.C new file mode 100644 index 000000000..1205812c9 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/net42.C @@ -0,0 +1,25 @@ +// { dg-do assemble } + +typedef void (*__sighandler_t)(int); + +struct sigaction { + __sighandler_t sa_handler; +}; + +struct task_struct { + struct sigaction sigaction[32]; +}; + +void +get_stat() { + struct task_struct ** p = 0; + unsigned long bit = 1; + unsigned long sigignore = 0; + int i = 0; + switch((__SIZE_TYPE__) (*p)->sigaction[i].sa_handler) + { + case 1: + sigignore |= bit; + break; + } +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/net43.C b/gcc/testsuite/g++.old-deja/g++.mike/net43.C new file mode 100644 index 000000000..aadd03de9 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/net43.C @@ -0,0 +1,12 @@ +// { dg-do assemble } +// { dg-options "-ffriend-injection" } + +class foo { + public: + friend int operator ^(const foo&, const foo&); +}; + +int main () +{ + int (*funptr) (const foo &, const foo &) = operator ^; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/net44.C b/gcc/testsuite/g++.old-deja/g++.mike/net44.C new file mode 100644 index 000000000..bc45b4878 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/net44.C @@ -0,0 +1,12 @@ +// { dg-do assemble } +// Make sure we don't dump core + +enum request { q, w, e}; // { dg-error "" } + +class request { // { dg-error "" } +public: + int a; + request( int b) { + a = b; + }; +}; diff --git a/gcc/testsuite/g++.old-deja/g++.mike/net45.C b/gcc/testsuite/g++.old-deja/g++.mike/net45.C new file mode 100644 index 000000000..9d423aa41 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/net45.C @@ -0,0 +1,19 @@ +// { dg-do assemble } + +template <class T1, class T2> +struct pair { + T1 first; + T2 second; + pair(const T1& a, const T2& b) : first(a), second(b) {} +}; + +struct myint { + myint() { + } + myint(const myint& mi) { + } + myint& operator=(const myint& mi) { return *this; } +}; + +extern pair<const myint, myint> a; +pair<const myint, myint> b(a); diff --git a/gcc/testsuite/g++.old-deja/g++.mike/net46.C b/gcc/testsuite/g++.old-deja/g++.mike/net46.C new file mode 100644 index 000000000..174022852 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/net46.C @@ -0,0 +1,22 @@ +// { dg-do run } +#include <iostream> +#include <cstdlib> +#include <cstddef> +#include <new> + +int fail = 1; + +int in_main = 0; + +void *operator new(size_t size) throw (std::bad_alloc) { + if (!in_main) return malloc (size); + --fail; + return (void*) 0; +} + +int main() { + std::cout << ""; + in_main = 1; + new int; + return fail; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/net47.C b/gcc/testsuite/g++.old-deja/g++.mike/net47.C new file mode 100644 index 000000000..026211012 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/net47.C @@ -0,0 +1,8 @@ +// { dg-do assemble } +// { dg-options "-w -fpermissive" } + +class foo {}; +class bar : foo { +public: + bar () : () {} +}; diff --git a/gcc/testsuite/g++.old-deja/g++.mike/net48.C b/gcc/testsuite/g++.old-deja/g++.mike/net48.C new file mode 100644 index 000000000..2553fab1d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/net48.C @@ -0,0 +1,14 @@ +// { dg-do assemble } + +const char *a="aê"; + +class A +{ +public: + A() + { + const char *b="aê"; + } +}; + +const char *c="aê"; diff --git a/gcc/testsuite/g++.old-deja/g++.mike/net6.C b/gcc/testsuite/g++.old-deja/g++.mike/net6.C new file mode 100644 index 000000000..d96b5dd39 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/net6.C @@ -0,0 +1,5 @@ +// { dg-do assemble } +// { dg-options "" } + +struct X {}; +X x = X(); // { dg-bogus "" } diff --git a/gcc/testsuite/g++.old-deja/g++.mike/net7.C b/gcc/testsuite/g++.old-deja/g++.mike/net7.C new file mode 100644 index 000000000..f0ef4c0f8 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/net7.C @@ -0,0 +1,7 @@ +// { dg-do assemble } +// { dg-options "" } + +// This should compile. + +int foo (signed char *); +int foo (char *); diff --git a/gcc/testsuite/g++.old-deja/g++.mike/net8.C b/gcc/testsuite/g++.old-deja/g++.mike/net8.C new file mode 100644 index 000000000..09f9c30a8 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/net8.C @@ -0,0 +1,32 @@ +// { dg-do assemble } +// { dg-options "-pedantic-errors" } + +class Base { +public: + int foo; +}; + +class Derived : public Base { +public: + int bar; +}; + +void func(Base&); // { dg-error "passing argument 1" } + +void func2(const Derived& d) { + func(d); // { dg-error "invalid initialization" } +} + +void +foo (int& a) // { dg-error "in passing argument 1" } +{ +} + +int main () +{ + int b; + const int*const a = &b; + *a = 10; // { dg-error "read-only location" } + foo (*a); // { dg-error "invalid initialization" } + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/net9.C b/gcc/testsuite/g++.old-deja/g++.mike/net9.C new file mode 100644 index 000000000..774690c97 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/net9.C @@ -0,0 +1,15 @@ +// { dg-do assemble } +// { dg-options "-pedantic-errors" } + +const int ci=10, *pc = &ci, *const cpc = pc, **ppc; +int i, *p, *const cp = &i; + +int main() +{ + ci = 1; // { dg-error "" } bad + ci++; // { dg-error "" } bad + *pc = 2; // { dg-error "" } bad + cp = &ci; // { dg-error "" } bad + cpc++; // { dg-error "" } bad + p = pc; // { dg-error "" } bad +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/ns1.C b/gcc/testsuite/g++.old-deja/g++.mike/ns1.C new file mode 100644 index 000000000..c92ea944a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/ns1.C @@ -0,0 +1,12 @@ +// { dg-do run } +namespace Foo { + int bar() { + return 0; + } +} + +using namespace Foo; + +int main() { + bar(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/ns10.C b/gcc/testsuite/g++.old-deja/g++.mike/ns10.C new file mode 100644 index 000000000..73e3cfd72 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/ns10.C @@ -0,0 +1,10 @@ +// { dg-do run } +namespace Foo { + int bar() { + return 0; + } +} + +int main() { + return Foo::bar(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/ns11.C b/gcc/testsuite/g++.old-deja/g++.mike/ns11.C new file mode 100644 index 000000000..c9d2c7bb2 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/ns11.C @@ -0,0 +1,19 @@ +// { dg-do run } +class Foo { +}; + +namespace A { + namespace Foo { + int bar() { + return 0; + } + } + + int mymain() { + return Foo::bar(); + } +} + +int main() { + return A::mymain(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/ns12.C b/gcc/testsuite/g++.old-deja/g++.mike/ns12.C new file mode 100644 index 000000000..76e187243 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/ns12.C @@ -0,0 +1,15 @@ +// { dg-do run } +namespace { + int i = 10; + enum fish { one = 1, two = 2, red = 3, blue = 4 }; +} +extern "C" int printf (const char *, ...); +int main(void) +{ + if (i != 10) { + return 1; + } + if (one != 1) { + return 2; + } +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/ns13.C b/gcc/testsuite/g++.old-deja/g++.mike/ns13.C new file mode 100644 index 000000000..23a10469a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/ns13.C @@ -0,0 +1,13 @@ +// { dg-do assemble } + +namespace N { + struct C { + C(); + }; +} + +namespace M { + struct C { + C(); + }; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/ns14.C b/gcc/testsuite/g++.old-deja/g++.mike/ns14.C new file mode 100644 index 000000000..463131d56 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/ns14.C @@ -0,0 +1,11 @@ +// { dg-do assemble } + +namespace Jazz { + int horn( int h ) { return 1; } +} + +using Jazz::horn; + +namespace Jazz { + int horn ( char c ) { return 0; } +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/ns15.C b/gcc/testsuite/g++.old-deja/g++.mike/ns15.C new file mode 100644 index 000000000..4e767b836 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/ns15.C @@ -0,0 +1,32 @@ +// { dg-do assemble } +// { dg-xfail-if "" { xstormy16-*-* } { "*" } { "" } } + +#include <stdio.h> +#include <stdlib.h> + +#define MAX 256 +#define MAXSTATE 1000000 + +struct R { + int count; + int state1; + int state2; +}; + +int cmp_d(const R* a, const R* b) { + return a->count > b->count; +} + +namespace CXX { + template<class T, long i1, long i2> + inline void qsort (T b[i1][i2], int (*cmp)(const T*, const T*)) { + ::qsort ((void*)b, i1*i2, sizeof(T), (int (*)(const void *, const void *))cmp); + } +} + +using namespace CXX; + +void sort_machine() { + struct R d[MAX][MAX]; + qsort<R,MAX> (d, cmp_d); +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/ns2.C b/gcc/testsuite/g++.old-deja/g++.mike/ns2.C new file mode 100644 index 000000000..8b5aedc1c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/ns2.C @@ -0,0 +1,10 @@ +// { dg-do run } +namespace N { + int i; +} + +using namespace N; + +int main() { + return i; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/ns3.C b/gcc/testsuite/g++.old-deja/g++.mike/ns3.C new file mode 100644 index 000000000..eb40fe4ae --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/ns3.C @@ -0,0 +1,5 @@ +// { dg-do assemble } +int i; // { dg-error "" } + +namespace i { // { dg-error "" } +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/ns4.C b/gcc/testsuite/g++.old-deja/g++.mike/ns4.C new file mode 100644 index 000000000..b1e7ee9a1 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/ns4.C @@ -0,0 +1,6 @@ +// { dg-do assemble } + +namespace i { +} +namespace i { +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/ns5.C b/gcc/testsuite/g++.old-deja/g++.mike/ns5.C new file mode 100644 index 000000000..fd1fbffce --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/ns5.C @@ -0,0 +1,7 @@ +// { dg-do assemble } +namespace A { + int i = 1; // { dg-message "A::i" } +} + +int j = i; // { dg-error "" } + // { dg-message "suggested alternative" "suggested alternative" { target *-*-* } 6 } diff --git a/gcc/testsuite/g++.old-deja/g++.mike/ns6.C b/gcc/testsuite/g++.old-deja/g++.mike/ns6.C new file mode 100644 index 000000000..275e7ba85 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/ns6.C @@ -0,0 +1,9 @@ +// { dg-do assemble } + +namespace A { + int i = 1; +} + +namespace A { + int j = i; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/ns7.C b/gcc/testsuite/g++.old-deja/g++.mike/ns7.C new file mode 100644 index 000000000..67d9e7741 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/ns7.C @@ -0,0 +1,10 @@ +// { dg-do assemble } + +namespace A { + int i = 1; // { dg-message "A::i" } +} + +namespace B { + int j = i; // { dg-error "" } + // { dg-message "suggested alternative" "suggested alternative" { target *-*-* } 8 } +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/ns9.C b/gcc/testsuite/g++.old-deja/g++.mike/ns9.C new file mode 100644 index 000000000..84f7a133e --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/ns9.C @@ -0,0 +1,12 @@ +// { dg-do run } +namespace Foo { + int bar() { + return 0; + } +} + +using Foo::bar; + +int main() { + return bar(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/offset1.C b/gcc/testsuite/g++.old-deja/g++.mike/offset1.C new file mode 100644 index 000000000..b0ddc7b54 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/offset1.C @@ -0,0 +1,39 @@ +// { dg-do run } +extern "C" int printf(const char *, ...); +void *vp; +int fail = 0; + +class Foo { +public: + virtual void setName() { + printf("Foo at %x\n", this); + if (vp != (void*)this) + fail = 1; + } +}; + +class Bar : public Foo { +public: + virtual void init(int argc, char **argv) { + printf("Bar's Foo at %x\n", (Foo*)this); + vp = (void*)(Foo*)this; + setName(); + } +}; + +class Barf : virtual public Bar { +public: + virtual void init(int argc, char **argv) { Bar::init(argc, argv); } +}; + +class Baz : virtual public Bar, virtual public Barf { +public: + virtual void init(int argc, char **argv) { Barf::init(argc, argv); } +}; + +Bar *theBar = new Baz(); + +int main(int argc, char **argv) { + theBar->init(argc, argv); + return fail; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/opr-as1.C b/gcc/testsuite/g++.old-deja/g++.mike/opr-as1.C new file mode 100644 index 000000000..9133d748c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/opr-as1.C @@ -0,0 +1,12 @@ +// { dg-do run } +// Shows a problem with the default op= not being an implementation... + +class C { + int i; +}; + +C a, b; + +int main() { + a = b; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/opr-dot1.C b/gcc/testsuite/g++.old-deja/g++.mike/opr-dot1.C new file mode 100644 index 000000000..a761a40c2 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/opr-dot1.C @@ -0,0 +1,22 @@ +// { dg-do assemble } + +typedef struct base1 { + int x; +} base1_t; + +typedef struct base2 { + int x; +} base2_t; + +class derived1 : public base1 { +}; + +class derived2 : public derived1, public base2 { +}; + +struct test { + derived2& fails; + void test1() { + fails.base1::x = 5; + } +}; diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p10148.C b/gcc/testsuite/g++.old-deja/g++.mike/p10148.C new file mode 100644 index 000000000..2cb359c9b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p10148.C @@ -0,0 +1,35 @@ +// { dg-do run } +// { dg-options "" } +// prms-id: 10148 + +int fail = 1; +void ok() { fail = 0; } + +class TC { + int s_; +}; + +class TIRD { + public: + void (*itc)(); + TIRD() { itc = ok; } +}; + +class TCCB : public TC, public TIRD { +}; + +class TCRCB : public TCCB { +public: + virtual void eat (); +}; + +void TCRCB::eat () { + void *vp = (void *)((TIRD*)this)->itc; + this->itc(); +} + +int main() { + TCRCB a; + a.eat(); + return fail; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p10247.C b/gcc/testsuite/g++.old-deja/g++.mike/p10247.C new file mode 100644 index 000000000..76eaebf0e --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p10247.C @@ -0,0 +1,7 @@ +// { dg-do assemble } +// prms-id: 10247 + +class a { +public: + int operator++(int) { return operator()++ ; } // { dg-error "" } +}; diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p10416.C b/gcc/testsuite/g++.old-deja/g++.mike/p10416.C new file mode 100644 index 000000000..2d21d19dd --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p10416.C @@ -0,0 +1,9 @@ +// { dg-do assemble } +// { dg-xfail-if "" { sparc64-*-elf arm-*-pe } { "*" } { "" } } +// { dg-options "-fexceptions" } +// prms-id: 10416 + +class not_ok { +public: + void f() throw(int) { } +}; diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p10511.C b/gcc/testsuite/g++.old-deja/g++.mike/p10511.C new file mode 100644 index 000000000..2adce9131 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p10511.C @@ -0,0 +1,15 @@ +// { dg-do assemble } +// prms-id: 10511 + +class S { +public: + enum E {a, b, c}; +}; + +class C { +public: + bool f (S::E()) { return true; } + virtual void foo(); +}; + +void C::foo() { } diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p10769b.C b/gcc/testsuite/g++.old-deja/g++.mike/p10769b.C new file mode 100644 index 000000000..9210a452a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p10769b.C @@ -0,0 +1,27 @@ +// { dg-do assemble } +// { dg-options "" } +// prms-id: 10769 + +#define PMF2PF(PMF) ((void (*)())(PMF)) + +class A { +public: + void f1a() { } + void main(); +} a; + +class B { +public: + void bf1() { } +} b; + +void A::main() { + void (B::*mPtrB)(B*); + (*(void (*)(A*))PMF2PF(mPtrB))(&b); // { dg-error "argument passing" } + // { dg-warning "convert" "warn" { target *-*-* } 20 } +} + +int main() { + void (A::*mPtr)() = &A::f1a; + (*(void (*)(A*))PMF2PF(mPtr))(&a); // { dg-warning "convert" } +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p10849a.C b/gcc/testsuite/g++.old-deja/g++.mike/p10849a.C new file mode 100644 index 000000000..96bb064b5 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p10849a.C @@ -0,0 +1,34 @@ +// { dg-do run } +// prms-id: 10849 + +struct A +{ + int comm; + A(int i) : comm(i) { } +}; + +struct S1 { char c1; }; + +struct B : public S1, public A +{ + B(int i) : A(i) { } +}; + +struct C : public A +{ + C(int i) : A(i) { } +}; + +struct D : public B, public C +{ + virtual int g() { + int D::*pmd = (int C::*)&C::comm; + return (this->*pmd) == 42; + } + D() : B(41), C(42) { } +} d; + +int main() { + if (! d.g()) + return 1; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p10951.C b/gcc/testsuite/g++.old-deja/g++.mike/p10951.C new file mode 100644 index 000000000..352b1a958 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p10951.C @@ -0,0 +1,21 @@ +// { dg-do assemble } +// prms-id: 10951 + +inline int m1(const int& a) { + return 1; +} + +template <class T> +class A { +public: + typedef int st; + + static int m2t() { + return m1(1); + } +}; + +A<int>::st i; +int m3() { + return A<int>::m2t(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p11012.C b/gcc/testsuite/g++.old-deja/g++.mike/p11012.C new file mode 100644 index 000000000..b851f2c44 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p11012.C @@ -0,0 +1,14 @@ +// { dg-do assemble } +// { dg-options "-Wno-pmf-conversions" } +// prms-id: 11012 + +class Foo { +public: + int f(){ return 0; } +}; + +void foo() { + void *p1 = &Foo::f; + const void *p2 = &Foo::f; + int (*p3)() = &Foo::f; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p11110.C b/gcc/testsuite/g++.old-deja/g++.mike/p11110.C new file mode 100644 index 000000000..7e3a1ffa3 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p11110.C @@ -0,0 +1,22 @@ +// { dg-do assemble } +// prms-id: 11110 + +class data; + +class conatiner { +public: + virtual void* first (); + virtual data* contents (void* i); // { dg-message "conatiner::contents|no known conversion" } +}; + +class user { +public: + data* data1 () const; +private: + conatiner& _c; +}; + +data* user::data1() const { + return (_c.contents (_c.first)); // { dg-error "match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 20 } +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p11142.C b/gcc/testsuite/g++.old-deja/g++.mike/p11142.C new file mode 100644 index 000000000..9fee770f8 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p11142.C @@ -0,0 +1,18 @@ +// { dg-do assemble } +// { dg-options "-fexceptions -O -g" } +// prms-id: 11142 + +class RWxmsg { +public: + RWxmsg(); + virtual ~RWxmsg(); +}; + +class RWTHRInternalError : public RWxmsg { +public: + virtual ~RWTHRInternalError() { } +}; + +void setCount(int count) { + throw RWTHRInternalError(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p11144.C b/gcc/testsuite/g++.old-deja/g++.mike/p11144.C new file mode 100644 index 000000000..cd1483eba --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p11144.C @@ -0,0 +1,18 @@ +// { dg-do run } +// { dg-options "-O" } +// prms-id: 11144 + +class Id { +public: + int d_i; + Id(int i) : d_i(i) {} + int value() {return d_i;} +} ID(1); + +Id foo() { return ID; } + +int main() { + const Id &id1 = foo(); + const Id &id2 = foo(); + return &id1 == &id2; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p11482.C b/gcc/testsuite/g++.old-deja/g++.mike/p11482.C new file mode 100644 index 000000000..ff5e7bad2 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p11482.C @@ -0,0 +1,10 @@ +// { dg-do assemble } +// prms-id: 11482 + +void *vp; + +enum E { bad, ok } e; + +void foo() { + e = (E)vp; // { dg-error "" } +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p11667.C b/gcc/testsuite/g++.old-deja/g++.mike/p11667.C new file mode 100644 index 000000000..802c0cf9b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p11667.C @@ -0,0 +1,62 @@ +// { dg-do run { xfail sparc64-*-elf arm-*-pe } } +// { dg-options "-fexceptions" } +// prms-id: 11667 + +extern "C" int printf(const char *,...); + +template < class T > +class LIST { +public: + + LIST() { nitems = 16; items = new T[nitems]; }; + + LIST(int u) { nitems = u; items = new T[nitems]; }; + + T& operator[](int i) const { + return items[i]; + } + + void grow(int n) { + T* newlist = new T[n]; + T* src = items; + T* dst = newlist; + int i = nitems; + + try { + while (i--) *dst++ = *src++; + } catch (...) { + delete[] newlist; + throw; + } + + if (items) delete[] items; + nitems = n; + items = newlist; + } + +private: + int nitems; + T *items; +}; + +int main(int argc, char **argv) { + int i; + LIST<int> mylist(10); + + printf("Start dumping initial 10 item list\n"); + for (i = 0; i < 10 ; i++) { + mylist[i] = i; + printf("%d\n", mylist[i]); + } + + printf("Growing list to 20\n"); + mylist.grow(20); + + printf("Start dumping grown 20 item list\n"); + for (i = 0; i < 20; i++) { + mylist[i] = i; + printf("%d\n", mylist[i]); + } + + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p12306.C b/gcc/testsuite/g++.old-deja/g++.mike/p12306.C new file mode 100644 index 000000000..6309016a3 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p12306.C @@ -0,0 +1,76 @@ +// { dg-do run } +// prms-id: 12306 + +void *ptr1, *ptr2; +int fail = 0; + +extern "C" int printf(const char *...); + +class RWSlist { }; + +class RWSlistIterator { +public: + RWSlist *slist; + RWSlistIterator(RWSlist& s) { } + void toLast() { + if (ptr1 != (RWSlistIterator*)this) + fail = 5; + if (ptr2 != &(*this).slist) + fail = 6; + + if (0) printf("at %x %x\n", (RWSlistIterator*)this, &(*this).slist); + } +}; + +class RWCollectable { +}; + +class RWSlistCollectables : public RWSlist { +public: + RWSlistCollectables() { } + RWSlistCollectables(RWCollectable* a) { } +}; + +class RWIterator { }; + +class RWSlistCollectablesIterator : public RWIterator, public RWSlistIterator { +public: + RWSlistCollectablesIterator(RWSlistCollectables& s) : RWSlistIterator(s) { } +}; + +class Sim_Event_Manager { +public: + RWSlistCollectables scheduled_events_; + RWSlistCollectablesIterator last_posted_event_position_; + Sim_Event_Manager(); + void post_event(); +}; + +Sim_Event_Manager::Sim_Event_Manager () + :last_posted_event_position_(scheduled_events_) +{ +} + +void Sim_Event_Manager::post_event () { + ptr1 = (RWSlistIterator*)&last_posted_event_position_; + ptr2 = &((RWSlistIterator*)&last_posted_event_position_)->slist; + if (0) printf("at %x %x\n", (RWSlistIterator*)&last_posted_event_position_, + &((RWSlistIterator*)&last_posted_event_position_)->slist); + if (ptr1 != (RWSlistIterator*)&last_posted_event_position_) + fail = 1; + if (ptr2 != &((RWSlistIterator&)last_posted_event_position_).slist) + fail = 2; + if (0) printf("at %x ?%x\n", (RWSlistIterator*)&last_posted_event_position_, + &((RWSlistIterator&)last_posted_event_position_).slist); + if (ptr1 != (RWSlistIterator*)&last_posted_event_position_) + fail = 3; + if (ptr2 != &((RWSlistIterator&)last_posted_event_position_).slist) + fail = 4; + last_posted_event_position_.toLast(); +} + +int main(int argc, char **argv) { + Sim_Event_Manager foo; + foo.post_event(); + return fail; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p12306a.C b/gcc/testsuite/g++.old-deja/g++.mike/p12306a.C new file mode 100644 index 000000000..8e47837c6 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p12306a.C @@ -0,0 +1,36 @@ +// { dg-do run } +// prms-id: 12306 +// a net report of the same problem as 12306 + +class a { +public: + int i; +}; + +class g : virtual public a { +}; + +class b : virtual public a { + int j; +}; + +class c : public g, public b { +}; + +class d { +public: + virtual class b* get() {return 0;} +}; + +class f : public d { +public: + virtual class b* get() {return &_c;} + c _c; +}; + +int main(void) { + f D; + b* bp=D.get(); + D._c.i = 42; + return &D._c.i != &bp->i; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p1248.C b/gcc/testsuite/g++.old-deja/g++.mike/p1248.C new file mode 100644 index 000000000..d54e555f3 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p1248.C @@ -0,0 +1,29 @@ +// { dg-do run } +// GROUPS passed pure-virt +extern "C" int printf (const char *, ...); +class Base { +public: + virtual ~Base() =0; +}; + +class Deranged : public Base { +public: + int value; + virtual ~Deranged(); +}; + + +Deranged::~Deranged(){} + +void foo() { + Deranged d; +} + +int main() +{ + foo(); + printf("PASS\n"); + return 0; +} + +Base::~Base () { } diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p1567.C b/gcc/testsuite/g++.old-deja/g++.mike/p1567.C new file mode 100644 index 000000000..4f02d84b6 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p1567.C @@ -0,0 +1,42 @@ +// { dg-do run } +// GROUPS passed vtable +extern "C" int printf (const char *, ...); +extern "C" void exit(int); + +class A { +public: + virtual const char* f1() { return "A::f1"; } + virtual const char* f2() { return "A::f2"; } + virtual const char* f3() { printf("FAIL\n"); exit(1); return "A::f3"; } +}; + +class B { +public: + virtual const char* f2() { return "B::f2"; } + virtual const char* f3() { return "B::f3"; } +}; + +class C: public A, public B { +public: + const char* f2() { return B::f2(); } + const char* f1() { return f2(); } + const char* f3() { return A::f3(); } +}; + +class D: public A, public B { +public: + const char* f2() { return B::f2(); } + const char* f1() { return D :: f2(); } + const char* f3() { return A::f3(); } +}; + +int main() { + C* tempC = new C; + D* tempD = new D; + A* a = tempC; + printf("calling f1 on a C gives %s\n", a->f1()); + a = tempD; + printf("calling f1 on a D gives %s\n", a->f1()); + printf("PASS\n"); + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p16146.C b/gcc/testsuite/g++.old-deja/g++.mike/p16146.C new file mode 100644 index 000000000..991a793e5 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p16146.C @@ -0,0 +1,90 @@ +// { dg-do run } +// prms-id: 16146 + +extern "C" int printf (const char *, ...); + +class myFoundation { +protected: + myFoundation () { count = 0; } + virtual ~myFoundation () {} + +public: + void addRef () { ++count; } + void removeRef () { if (count > 0) --count; } + +private: + long count; +}; + + +class firstIntermediate :virtual public myFoundation { +public: + firstIntermediate () {} + ~firstIntermediate () {} + + void bar () { printf ("Bar\n"); } +}; + + +class firstBase : public firstIntermediate { +public: + firstBase () {} + ~firstBase () {} + + virtual void g () {} +}; + + +class secondIntermediate : virtual public myFoundation { +public: + secondIntermediate () {} + ~secondIntermediate () {} + + virtual void h () {} +}; + + +class secondBase : public secondIntermediate { +public: + secondBase () {} + ~secondBase () {} + + virtual void h () {} +}; + + +class typeInterface : virtual public firstBase { +public: + typeInterface () {} + ~typeInterface () {} + + virtual void i () {} +}; + +class classServices : virtual public firstBase, + public secondBase { +public: + classServices () {} + ~classServices () {} + + virtual void j () {} +}; + +class classImplementation : public typeInterface, + public classServices { +public: + classImplementation () {} + ~classImplementation () {} + + void g () {} + void h () {} + void i () {} + void j () {} +}; + +int main () { + firstBase* fbp = new classImplementation; + classImplementation* cip = dynamic_cast <classImplementation*> (fbp); + cip->addRef(); + myFoundation* mfp = cip; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p1862.C b/gcc/testsuite/g++.old-deja/g++.mike/p1862.C new file mode 100644 index 000000000..7765ec1ea --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p1862.C @@ -0,0 +1,63 @@ +// { dg-do run } +// GROUPS vtable +extern "C" int printf (const char *, ...); + +class A +{ +public: + virtual ~A(){} + virtual int type(void) + { + return -1; + } +}; + +class B +{ +public: + virtual ~B(){} +}; + + +class C0 : public B, public A +{ +public: + virtual int type(void) + { + return 0; + } +}; + +class C1 : public C0 +{ +public: + virtual int type(void) + { + return 1; + } +}; + +class C2 : public C0 +{ +public: + virtual int type(void) + { + return 2; + } +}; + +int main() +{ + C1 *one = new C1; + + if (one->type() == 1) + { + printf ("PASS\n"); + return 0; + } + else + { + printf ("FAIL\n"); + return 1; + } +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p1989.C b/gcc/testsuite/g++.old-deja/g++.mike/p1989.C new file mode 100644 index 000000000..487f609a1 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p1989.C @@ -0,0 +1,495 @@ +// { dg-do assemble } +// prms-id: 1989 + +#define TRUE true +#define FALSE false +typedef void *Pix; + +template<class T> +struct link { + T item; + link *next; + link *prev; + + link(const T& t): item(t), prev(0), next(0) + { } + link(const T& t, link<T> *p, link<T> *n): item(t), prev(p), next(n) + { } +}; + +template<class T> +class List_DL { +public: + List_DL(); + List_DL(const List_DL&); + ~List_DL(); + + void append(const T& item); + void prepend(const T& item); + void insert(const T& item, Pix x, bool before); + + void remove(Pix& x) + { T tmp; remove(x, tmp); } + void remove(Pix& x, T& item); + + void clear(); + + unsigned length() const + { return count; } + +private: + + unsigned count; + link<T> *head; + link<T> *tail; + +public: + Pix first() const + { return Pix(head); } + Pix last() const + { return Pix(tail); } + void next(Pix& x) const + { if (0 != x) x = ((link<T> *) x)->next; } + void prev(Pix& x) const + { if (0 != x) x = ((link<T> *) x)->prev; } + T& operator()(Pix x) const + { return ((link<T> *) x)->item; } +}; + +template<class T> +List_DL<T>::List_DL(): +count(0), +head(0) +{ } + +template<class T> +List_DL<T>::List_DL(const List_DL& other): +count(0), +head(0) +{ + for (Pix x=other.first(); 0 != x; other.next(x)) + append(other(x)); +} + +template<class T> +List_DL<T>::~List_DL() +{ + clear(); +} + +template<class T> +void +List_DL<T>::append(const T& item) +{ + count++; + if (0 == head) { + head = new link<T>(item); + tail = head; + } else { + tail->next = new link<T>(item, tail, 0); + tail = tail->next; + } +} + +template<class T> +void +List_DL<T>::prepend(const T& item) +{ + count++; + if (0 == head) { + head = new link<T>(item); + tail = head; + } else { + head = new link<T>(item, 0, head); + if (tail == head) + tail = tail->next; + } +} + +template<class T> +void +List_DL<T>::insert(const T& item, Pix x, bool before = TRUE) +{ + link<T> *l = (link<T> *) x; + + if (before) { + if (0 == l || l == head) { + prepend(item); + } else { + link<T> *n = new link<T>(item, l->prev, l); + l->prev->next = n; + l->prev = n; + } + } else { + if (0 == l || l == tail) { + append(item); + } else { + link<T> *n = new link<T>(item, l, l->next); + l->next->prev = n; + l->prev = n; + } + } +} + +template<class T> +void +List_DL<T>::remove(Pix& x, T& item) +{ + link<T> *l = (link<T> *) x; + + if (0 == l) + return; + + item = l->item; + if (1 == count) { + delete head; + head = 0; + tail = 0; + } else { + // more than one item in the list + if (l == head) { + link<T> *old = head; + head = head->next; + head->prev = 0; + delete old; + } else if (l == tail) { + link<T> *old = tail; + tail = tail->prev; + tail->next = 0; + delete old; + } else { + l->next->prev = l->prev; + l->prev->next = l->next; + delete l; + } + } +} + +template<class T> +void +List_DL<T>::clear() +{ + link<T> *l, *succ; + for (l=head; 0 != l; l=succ) { + succ = l->next; + delete l; + } + head = 0; + tail = 0; +} + +template<class T> +class List_DLS: public List_DL<T> { +public: + List_DLS(): List_DL<T>() + { } + List_DLS(const List_DLS& other): List_DL<T>(other) + { } + + bool contains(const T& item) const + { return search(item) != 0 ? TRUE: FALSE; } + Pix search(const T&) const; +}; + +template<class T> +Pix +List_DLS<T>::search(const T& item) const +{ + for (Pix x=this->first(); 0 != x; this->next(x)) { + if (item == this->operator()(x)) // { dg-error "match" } const subversion + // { dg-message "candidate" "candidate note" { target *-*-* } 199 } + return x; + } + return 0; +} + +template<class T> +class List_DLSp: public List_DL<T> { +public: + List_DLSp(): List_DL<T>() + { } + List_DLSp(const List_DLSp& other): List_DL<T>(other) + { } + + bool contains(const T& item) const +#ifndef INTERNAL_ERROR + ; +#else + { return search(item) != 0 ? TRUE: FALSE; } +#endif + Pix search(const T&) const; +}; + +template<class T> +bool +List_DLSp<T>::contains(const T& item) const +{ + for (Pix x=this->first(); 0 != x; this->next(x)) { + if (*item == *(this->operator()(x))) + return TRUE; + } + return FALSE; +} + +template<class T> +class Set { +public: + Set(); + Set(const Set& other); + + virtual void add(const T& item); + + void remove(const T& item) + { Pix x = search(item); remove(x); } + void remove(Pix& x) + { T tmp; remove(x, tmp); } + virtual void remove(Pix& x, T& item); + + virtual void clear(); + + virtual bool contains(const T&) const; + virtual Pix search(const T&) const; + + virtual unsigned length() const; + + virtual Pix first() const; + virtual void next(Pix& x) const; + virtual T& operator()(Pix x) const; +}; + +template<class T> +Set<T>::Set() +{ } + +template<class T> +Set<T>::Set(const Set& other) +{ } + + +template<class T> +class Set_DL: public List_DLS<T> { +public: + Set_DL(); + Set_DL(const Set_DL& other); + + void add(const T& item) + { list.append(item); } + void remove(Pix& x, T& item) + { list.remove(x, item); } + + void clear() + { list.clear(); } + + bool contains(const T& item) const + { return list.contains(item); } + Pix search(const T& item) const + { return list.search(item); } + + unsigned length() const + { return list.length(); } + + Pix first() const + { return list.first(); } + void next(Pix& x) const + { list.next(x); } + T& operator()(Pix x) const + { return list(x); } +private: + List_DLS<T> list; +}; + +template<class T> +class Set_DLp: public List_DLSp<T> { +public: + Set_DLp(); + Set_DLp(const Set_DLp& other); + + void add(const T& item) + { list.append(item); } + void remove(Pix& x, T& item) + { list.remove(x, item); } + + void clear() + { list.clear(); } + + bool contains(const T& item) const + { return list.contains(item); } + Pix search(const T& item) const + { return list.search(item); } + + unsigned length() const + { return list.length(); } + + Pix first() const + { return list.first(); } + void next(Pix& x) const + { list.next(x); } + T& operator()(Pix x) const + { return list(x); } +private: + List_DLSp<T> list; +}; + +template<class T> +struct vertex { + T item; + List_DL<vertex<T> *> fanout; + + vertex(): item(), fanout() // { dg-bogus "" } + { } + vertex(const T& i): item(), fanout() // { dg-bogus "" } + { } +}; + +template<class T> +class Graph { +public: + Graph(); + Graph(const Graph&); + ~Graph(); + + void add(const T& from, const T& to); + bool contains(const T& from, const T& to) const; + + void clear() + { vertices.clear(); } + + unsigned lengthV() const + { return vertices.length(); } + + Pix firstV() const + { return vertices.first(); } + void nextV(Pix& x) const + { vertices.next(x); } + T& V(Pix x) const + { return vertices(x).item; } + + Pix firstV1(Pix vx) const; + void nextV1(Pix vx, Pix& x) const; + T& V1(Pix vx, Pix x) const; +private: + vertex<T> *lookup(const T& from) const; + vertex<T> *lookup_new(const T& from); + + List_DLS<vertex<T> > vertices; +}; + +template<class T> +Graph<T>::Graph(): +vertices() +{ } + +template<class T> +Graph<T>::Graph(const Graph& other): +vertices() +{ + for (Pix vx=firstV(); 0 != vx; nextV(vx)) { + for (Pix vx1=firstV1(vx); 0 != vx1; nextV1(vx, vx1)) { + add(V(vx), V1(vx, vx1)); + } + } +} + +template<class T> +Graph<T>::~Graph() +{ + clear(); +} + +template<class T> +void +Graph<T>::add(const T& from, const T& to) +{ + vertex<T> *fromv = lookup_new(from); + if (from == to) + return; + vertex<T> *tov = lookup_new(to); + fromv->fanout.append(tov); +} + +template<class T> +bool +Graph<T>::contains(const T& from, const T& to) const +{ + vertex<T> *fromv = lookup(from); + if (0 == fromv) + return FALSE; + + for (Pix x=fromv->fanout.first(); 0 != x; fromv->fanout.next(x)) { + if (fromv->fanout(x)->item == to) + return TRUE; + } + + return FALSE; +} + +template<class T> +vertex<T> * +Graph<T>::lookup(const T& from) const +{ + for (Pix x=vertices.first(); 0 != x; vertices.next(x)) { + if (vertices(x).item == from) + return &vertices(x); + } + return 0; +} + +template<class T> +vertex<T> * +Graph<T>::lookup_new(const T& from) +{ + vertex<T> *v = lookup(from); + if (0 == v) { + vertices.append(from); + return &vertices(vertices.last()); + } + return v; +} + +template<class T> +Pix +Graph<T>::firstV1(Pix vx) const +{ + vertex<T> *v = (vertex<T> *) vx; + return v->fanout.first(); +} + +template<class T> +void +Graph<T>::nextV1(Pix vx, Pix& x) const +{ + vertex<T> *v = (vertex<T> *) vx; + return v->fanout.next(x); +} + +template<class T> +T& +Graph<T>::V1(Pix vx, Pix x) const +{ + vertex<T> *v = (vertex<T> *) vx; + static T x1; + return x1; +} + +class STRLIdentifier; + +extern int x(List_DL<STRLIdentifier *>); +extern int x(List_DLS<STRLIdentifier *>); + +extern int x(Set<STRLIdentifier *>); +extern int x(Set_DL<STRLIdentifier *>); +extern int x(Set_DLp<STRLIdentifier *>); + +extern int x(Graph<STRLIdentifier *>); + +class STRLIdentifier { + char buf[10]; +}; + +extern int operator==(vertex<STRLIdentifier*>&, vertex<STRLIdentifier*>&); // { dg-message "note" } const subversion +extern int operator==(STRLIdentifier&, STRLIdentifier&); // { dg-message "note" } fn ref in err msg + +extern int x(List_DLSp<STRLIdentifier *>); + +template class Graph<STRLIdentifier *>; +template class List_DLS<vertex<STRLIdentifier *> >; diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p2394.C b/gcc/testsuite/g++.old-deja/g++.mike/p2394.C new file mode 100644 index 000000000..6581f9f2f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p2394.C @@ -0,0 +1,37 @@ +// { dg-do run } +// prms-id: 2394 + +class Foo { + public: + int x; + int y; + Foo(int i, int j) { x = i; y = j; } +} foo(10, 11); + +class Wasted { int unsed; }; + +class Bar : Wasted, public Foo { +public: + Bar() : Foo(12, 13) { } +} bar; + +int +test0() { + int Foo::* pmi = &Foo::y; + return (int)(foo.*pmi); +} + +int +test1() { + int Foo::* pmi = &Foo::y; + return (int)(bar.*pmi); +} + +int +main() { + if (test0() != 11) + return 1; + if (test1() != 13) + return 2; + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p2431.C b/gcc/testsuite/g++.old-deja/g++.mike/p2431.C new file mode 100644 index 000000000..4e74899a1 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p2431.C @@ -0,0 +1,24 @@ +// { dg-do assemble } +// GROUPS passed infinite_loop +class A +{ + public: + A(A &); // { dg-message "note" } +}; + +class B +{ + public: + operator A (); +}; + +class C +{ + public : + C() + { + B b; + A a = b;// { dg-error "match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 21 } + } +}; diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p2573.C b/gcc/testsuite/g++.old-deja/g++.mike/p2573.C new file mode 100644 index 000000000..0906979c3 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p2573.C @@ -0,0 +1,15 @@ +// { dg-do assemble } +// prms-id: 2573 + +class X { +public: + int key(); + virtual int vkey(); + char *add(); +}; + +char *X::add() { + char *f1 = (char *) &key; // { dg-error "" } + char *f2 = (char *) &vkey; // { dg-error "" } + return f1; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p2736.C b/gcc/testsuite/g++.old-deja/g++.mike/p2736.C new file mode 100644 index 000000000..6ae61e892 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p2736.C @@ -0,0 +1,33 @@ +// The VxWorks kernel has no implementation of atexit, so local statics +// are never destroyed. +// { dg-do run { xfail vxworks_kernel } } +// This is a poor test case, it is meant to ensure that function local +// statics are destroyed at the right time. See PR 2736 for details. +// prms-id: 2736 + +#include <stdlib.h> + +int count; + +struct A { + int which; + A(int i) :which(i) { + // printf("ctor %x\n", this); + } + ~A() { + // printf("dtor %x\n", this); + if (++count != which) + abort (); + } +}; + +void +foo() { + static A a(1); +} + +A a(2); + +int main() { + foo(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p2746.C b/gcc/testsuite/g++.old-deja/g++.mike/p2746.C new file mode 100644 index 000000000..1bc1ce359 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p2746.C @@ -0,0 +1,156 @@ +// { dg-do assemble } +// GROUPS passed scope pt +class Link { +public: + Link(); + Link(Link *); +private: + Link *next_; + +friend class IListBase; +friend class IListIterBase; +}; + +inline +Link::Link() : next_(0) +{ +} + +inline +Link::Link(Link *next) : next_(next) +{ +} + +class IListBase { +public: + IListBase(); + IListBase(Link *); + void append(Link *); + void insert(Link *); + Link *head(); + int empty(); + Link *get(); + void remove(Link *); +private: + Link *head_; +friend class IListIterBase; +}; + +inline +IListBase::IListBase() : head_(0) +{ +} + +inline +IListBase::IListBase(Link *head) : head_(head) +{ +} + +inline +void IListBase::insert(Link *p) +{ + p->next_ = head_; + head_ = p; +} + +inline +Link *IListBase::head() +{ + return head_; +} + +inline +int IListBase::empty() +{ + return head_ == 0; +} + +inline +Link *IListBase::get() +{ + Link *tem = head_; + head_ = head_->next_; + return tem; +} + +template<class T> class IListIter; + +template<class T> +class IList : private IListBase { +public: + IList() { } + IList(T *p) : IListBase(p) { } + ~IList(); + void append(T *p) { IListBase::append(p); } + void insert(T *p) { IListBase::insert(p); } + void remove(T *p) { IListBase::remove(p); } + T *head() { return (T *)IListBase::head(); } + T *get() { return (T *)IListBase::get(); } + IListBase::empty; +friend class IListIter<T>; +}; + +template<class T> +IList<T>::~IList() +{ + while (!empty()) + delete get(); +} + +class IListIterBase { +public: + IListIterBase(const IListBase &); + int done(); + Link *cur(); + void next(); +private: + Link *p_; +}; + +inline +IListIterBase::IListIterBase(const IListBase &list) : p_(list.head_) +{ +} + +inline +int IListIterBase::done() +{ + return p_ == 0; +} + +inline +Link *IListIterBase::cur() +{ + return p_; +} + +inline +void IListIterBase::next() +{ + p_ = p_->next_; +} + + +template<class T> +class IListIter : private IListIterBase { +public: + IListIter(const IList<T> &list) : IListIterBase(list) { } + T *cur() { return (T *)IListIterBase::cur(); } + IListIterBase::next; + IListIterBase::done; +}; + + +struct A { + IList<Link> list; + int x; + void foo(); +}; + + +void A::foo() +{ + for (IListIter<Link> iter(list); !iter.done(); iter.next()) + ; + x = 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p2793.C b/gcc/testsuite/g++.old-deja/g++.mike/p2793.C new file mode 100644 index 000000000..68fee7dfd --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p2793.C @@ -0,0 +1,6 @@ +// { dg-do assemble } +// prms-id: 2793 + +void f(char&) { // { dg-error "" } referenced by error below + f('c'); // { dg-error "" } +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p2806.C b/gcc/testsuite/g++.old-deja/g++.mike/p2806.C new file mode 100644 index 000000000..71d5139e1 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p2806.C @@ -0,0 +1,20 @@ +// { dg-do assemble } +// GROUPS passed +template<class T> +class List +{ + public: + List(); + void f() const; +}; + +template<class T> +void List<T>::f() const +{ +} + +void func() +{ + List<int> list; + list.f(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p2846.C b/gcc/testsuite/g++.old-deja/g++.mike/p2846.C new file mode 100644 index 000000000..bce20bb00 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p2846.C @@ -0,0 +1,67 @@ +// { dg-do run } +// prms-id: 2846 + +extern "C" int printf(const char *, ...); +extern "C" void exit(int); + +class A; +class B; + +int c; + +class A { +public: + + A(void){} + A(const A&){} + A(const B&); + + virtual ~A(void){} + + virtual void print(void) const { + printf("A::print\n"); + printf("FAIL\n"); + exit(1); + } + B compute(void) const; +}; + +class B : private A { +friend class A; +public: + + virtual ~B(void){} + + void print(void) const { + ++c; + printf("B::print\n"); + } + +private: + B(const A& x, int){} +}; + +A::A(const B& s) { + s.print(); +} + +B A::compute(void) const { + B sub(*this, 1); + return sub; +} + +int main () +{ + A titi; + A toto = titi.compute(); + if (c != 1) + { + printf ("FAIL\n"); + return 1; + } + else + { + printf("PASS\n"); + return 0; + } +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p2846a.C b/gcc/testsuite/g++.old-deja/g++.mike/p2846a.C new file mode 100644 index 000000000..8825de4e8 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p2846a.C @@ -0,0 +1,35 @@ +// { dg-do run } +// Shows that problem of initializing one object's vtable pointer from +// another object's vtable pointer when doing a default copy of it +// and the vtable pointer involved is the main one. + +// Correct answer is B::print. +// g++ prints D::print, which is wrong. Cfront gets is right. + +// prms-id: 2846 + +extern "C" int printf(const char *, ...); +extern "C" void exit(int); + +class B { +public: + virtual void print(void) const { printf("B::print\n"); } +}; + +class D : public B { +public: + void print(void) const { printf("D::print\n"); exit(1); } + B compute(void) const; +}; + +B D::compute(void) const +{ + B sub(*(B*)this); + return sub; +} + +int main () { + D titi; + titi.compute().print(); + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p2846b.C b/gcc/testsuite/g++.old-deja/g++.mike/p2846b.C new file mode 100644 index 000000000..57422fe64 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p2846b.C @@ -0,0 +1,53 @@ +// { dg-do run } +// Shows that problem of initializing one object's secondary base from +// another object via a user defined copy constructor for that base, +// the pointer for the secondary vtable is not set after implicit +// copying of the outer class, but rather has the pointer to the main +// vtable for the secondary base left over from the user defined copy +// constructor for that base. + +// Correct answer is B::beefy. +// g++ prints A::beefy, which is wrong. Cfront gets it right. + +// prms-id: 2846 + +extern "C" int printf(const char *, ...); +extern "C" void exit(int); + +class B; + +class A { + public: + + A(void){} + A(const A&){} + + virtual void print(void) const { } + B compute(void) const; +}; + +class C { +public: + C() { } + C(C& o) { } // with it, things are wrong, without it, they're ok + virtual void beefy(void) const { printf("A::beefy\n"); exit(1); } +}; + +class B : private A, public C { +public: + B(const A& x, int){} + void beefy(void) const { printf("B::beefy\n"); } +}; + +B A::compute(void) const +{ + B sub(*this, 1); + return sub; +} + +int main () +{ + A titi; + titi.compute().beefy(); + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p2855.C b/gcc/testsuite/g++.old-deja/g++.mike/p2855.C new file mode 100644 index 000000000..3f269d276 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p2855.C @@ -0,0 +1,21 @@ +// { dg-do assemble } +// { dg-options "-Wcast-qual" } +// prms-id: 2855 + +class Ctest { +private: + char* data; +public: + operator const char *() const; +}; + +Ctest::operator const char *() const +{ + return data; +} +int main() +{ + Ctest obj; + char* temp = (char *)obj; // { dg-error "invalid cast" } + temp[0] = '\0'; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p2960.C b/gcc/testsuite/g++.old-deja/g++.mike/p2960.C new file mode 100644 index 000000000..510decd3d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p2960.C @@ -0,0 +1,31 @@ +// { dg-do run } +// prms-id: 2960 + +extern "C" int printf(const char *, ...); + +class Test0 { +public: + virtual void f0() { } // works fine if this virtual removed +}; + +class Test1 : public Test0 { +public: + void f1() { f2(); } // generates bus error here + virtual void f2() { printf("Test1::f2\n"); } +}; + +class Test2 { +public: + virtual void f3() { } +}; + +class Test3 : public Test2, public Test1 { // works fine if Test1 first +public: + virtual ~Test3() { f1(); } // calling f2 directly works + virtual void f2() { printf("Test3::f2\n"); } +}; + +int main() { + Test3 t3; + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p3041.C b/gcc/testsuite/g++.old-deja/g++.mike/p3041.C new file mode 100644 index 000000000..189d2f3ba --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p3041.C @@ -0,0 +1,34 @@ +// { dg-do run } +// prms-id: 3041 + +class A { +public: + A() { } + virtual void a() = 0; + static int b(A * p) { + p->a(); + return 1; + } +}; + +class B : virtual public A { +public: + B() { + static int installed = b(this); + } + void a() { } +}; + +class C : virtual public B { +public: + C() { + static int installed = b(this); + } + void a() { } +}; + +int main() +{ + C c; + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p3060c.C b/gcc/testsuite/g++.old-deja/g++.mike/p3060c.C new file mode 100644 index 000000000..8d9bd2e44 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p3060c.C @@ -0,0 +1,23 @@ +// { dg-do assemble } +// A new problem with my pointer to member function work. +// prms-id: 3060 + +class Foo +{ + public: + int x; + int y; + Foo (int i, int j) { x = i; y = j; } + operator int (); +}; + +int Foo::operator int() { return x; } // { dg-error "return" } can't specify return type + +Foo foo(10, 11); + +int +main() +{ + int Foo::* pmi = &Foo::y; + return foo.*pmi; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p3060d.C b/gcc/testsuite/g++.old-deja/g++.mike/p3060d.C new file mode 100644 index 000000000..11ac0daa6 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p3060d.C @@ -0,0 +1,35 @@ +// { dg-do run } +// This is a test case to make sure the explicit cast on a pointer to +// a member function works ok. +// prms-id: 3060 + +extern "C" int printf(const char *, ...); + +class Object; + +typedef void (Object::*VoidObjMemberFunc)(Object *tracker, void *ap); + +class Object { +public: + int foo; +}; + +class Clipper: public Object { +public: + int bar; + void Feedback(Object*, void*); +}; +void Clipper::Feedback(Object *tracker, void *ap) { + printf("Doing feedback\n"); +} + +void vfunc(VoidObjMemberFunc of, Object *op, void *v1) { + (op->*of)(op, v1); +} + +int main() { + Object o; + + vfunc((VoidObjMemberFunc)&Clipper::Feedback, &o, 0); + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p3068.C b/gcc/testsuite/g++.old-deja/g++.mike/p3068.C new file mode 100644 index 000000000..65dab70b0 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p3068.C @@ -0,0 +1,61 @@ +// { dg-do run } +// prms-id: 3068 + +extern "C" int printf(const char *, ...); +extern "C" void exit(int); + +class LB { +public: + virtual int test() { return 0; } + virtual ~LB() { } +protected: + LB() { } +}; + +class RRB { +public: + virtual ~RRB() { } + virtual void test2(int a) { } +}; + +class RR : public RRB { +public: + virtual ~RR() { } +}; + +class RL { +public: + virtual void real(int a) { + printf("RL::real\n"); + } +}; + + +class R : public RL, public RR { +public: + virtual void test3(int a) { } + virtual void test2(int a) { } +}; + +class L : public LB { +}; + +class C : public L, public R { +public: + C() { } + virtual ~C() { + printf("C::~C\n"); + exit(1); + } + virtual void real(int a) { + printf("RL::real\n"); + } +}; + +int main() { + C& bb = *new C; + R& mv = bb; + bb.real(0); + mv.real(0); + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p3070.C b/gcc/testsuite/g++.old-deja/g++.mike/p3070.C new file mode 100644 index 000000000..b292d4127 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p3070.C @@ -0,0 +1,32 @@ +// { dg-do assemble } +// Caused an Internal Compiler Error. Works now. +// prms-id: 3070 + +class Object { +public: + virtual ~Object() {} +}; + +class BaseView { +protected: + virtual void _forwardReceiveUpdate() = 0; +}; + + +class View : public BaseView { +public: + virtual ~View(); +}; + +class TestViewBaseUpdate { +protected: + virtual void _receiveUpdate(); +}; + +class TestViewBase : public TestViewBaseUpdate, private View { +}; + +class TestView : public Object, public TestViewBase { +protected: + virtual void _receiveUpdate(); +}; diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p3139.C b/gcc/testsuite/g++.old-deja/g++.mike/p3139.C new file mode 100644 index 000000000..691017859 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p3139.C @@ -0,0 +1,26 @@ +// { dg-do run } +// prms-id: 3139 + +extern "C" int printf(const char *, ...); + +class A { + public: + A() { } + virtual int a() = 0; +}; + +class B : virtual public A { + public: + virtual int a() = 0; +}; + +class C : public B { + public: + int a() { return 42; } +}; + +int main() { + B * b = new C; + printf("%d.\n", b->a()); + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p3524a.C b/gcc/testsuite/g++.old-deja/g++.mike/p3524a.C new file mode 100644 index 000000000..1b0afede5 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p3524a.C @@ -0,0 +1,25 @@ +// { dg-do assemble } +// Make sure we can initialize a reference to a templated type, that +// requires a conversion from a derived type to a base type. + +// prms-id: 3524 + +struct cc2Vector +{}; + +template <class T> +struct ccPair +{ + ccPair (const cc2Vector&); +}; + +struct ccLine : cc2Vector +{ + double distToPoint (const ccPair <float> &); +}; + +void foo () +{ + ccLine l2; + l2.distToPoint (l2); +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p3524b.C b/gcc/testsuite/g++.old-deja/g++.mike/p3524b.C new file mode 100644 index 000000000..34d106040 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p3524b.C @@ -0,0 +1,21 @@ +// { dg-do assemble } +// Make sure we can cast to a templated type, that requires a conversion by +// constructor, from a derived type to a base type. + +// prms-id: 3524 + +template <class T> +struct ccPair { + ccPair () { } +}; + +template <class T> +struct ccO : ccPair<T> { + ccO () { } +}; + +void foo () +{ + ccO<float> r; + (ccPair<float>)r; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p3524c.C b/gcc/testsuite/g++.old-deja/g++.mike/p3524c.C new file mode 100644 index 000000000..2f5d23bed --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p3524c.C @@ -0,0 +1,15 @@ +// { dg-do assemble } +// Make sure we can cast to a templated type, that requires a conversion by +// constructor, from a non-aggregate type. + +// prms-id: 3524 + +template <class T> +struct ccPair { + ccPair (int i) { } +}; + +void foo () +{ + (ccPair<float>)1; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p3538a.C b/gcc/testsuite/g++.old-deja/g++.mike/p3538a.C new file mode 100644 index 000000000..a2c985386 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p3538a.C @@ -0,0 +1,33 @@ +// { dg-do assemble } +// This tests for the compiler_error in binfo_value. +// prms-id: 3538 + +class ccObjectInfo +{ +public: + virtual const ccObjectInfo& repInvariant (int); +}; + +template<class T> +class ccHandle : public ccObjectInfo +{ +protected: + T* p; +public: + virtual const ccObjectInfo& repInvariant (int); +}; + +template <class T> +const ccObjectInfo& ccHandle<T>::repInvariant (int) +{ return p->ri(1); } + +class ccHandleBase : public ccObjectInfo +{}; + +class cc_CircleHdl : public virtual ccHandleBase, public ccObjectInfo // { dg-warning "" } +{ +public: + virtual const ccObjectInfo& ri (int); +}; + +class ccCircleHdl : public ccHandle <cc_CircleHdl> {}; diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p3538b.C b/gcc/testsuite/g++.old-deja/g++.mike/p3538b.C new file mode 100644 index 000000000..96ba124a1 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p3538b.C @@ -0,0 +1,35 @@ +// { dg-do assemble } +// prms-id: 3538 + +// This tests for an ambiguous conversion of the this pointer (going +// down to DECL_CONTEXT of a FUNCTION_DECL. + +class ccObjectInfo +{ +public: + virtual const ccObjectInfo& repInvariant (int); +}; + +template<class T> +class ccHandle : public ccObjectInfo +{ +protected: + T* p; +public: + virtual const ccObjectInfo& repInvariant (int); +}; + +template <class T> +const ccObjectInfo& ccHandle<T>::repInvariant (int) +{ return p->repInvariant(1); } + +class ccHandleBase : public ccObjectInfo +{}; + +class cc_CircleHdl : public virtual ccHandleBase, public ccObjectInfo // { dg-warning "" } +{ +public: + virtual const ccObjectInfo& repInvariant (int); +}; + +class ccCircleHdl : public ccHandle <cc_CircleHdl> {}; diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p3570.C b/gcc/testsuite/g++.old-deja/g++.mike/p3570.C new file mode 100644 index 000000000..e8502d535 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p3570.C @@ -0,0 +1,30 @@ +// { dg-do run } +// prms-id: 3570 + +extern "C" int printf(const char *, ...); + +struct A { + void print() {printf("A");} +}; + +struct B : A { + typedef A superB; + void print() {superB::print(); printf("B");} +}; + +struct C : B { + typedef B superC; + void print() {superC::print(); printf("C");} +}; + +int main () +{ + A a; + B b; + C c; + + a.print(); printf("\n"); + b.print(); printf("\n"); + c.print(); printf("\n"); + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p3579.C b/gcc/testsuite/g++.old-deja/g++.mike/p3579.C new file mode 100644 index 000000000..90a134446 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p3579.C @@ -0,0 +1,40 @@ +// { dg-do run } +// prms-id: 3579 + +extern "C" int printf(const char *, ...); + +int num_x; + +class Y { +public: + Y () { printf("Y() this: %x\n", this); } + ~Y () { printf("~Y() this: %x\n", this); } +}; + +class X { +public: + X () { + ++num_x; + printf("X() this: %x\n", this); + Y y; + *this = (X) y; + } + + X (const Y & yy) { printf("X(const Y&) this: %x\n", this); ++num_x; } + X & operator = (const X & xx) { + printf("X.op=(X&) this: %x\n", this); + return *this; + } + + ~X () { printf("~X() this: %x\n", this); --num_x; } +}; + +int main (int, char **) { + { X anX; } + if (num_x) { + printf("FAIL\n"); + return 1; + } + printf("PASS\n"); + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p3708.C b/gcc/testsuite/g++.old-deja/g++.mike/p3708.C new file mode 100644 index 000000000..56e4bcbe2 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p3708.C @@ -0,0 +1,87 @@ +// { dg-do run } +// prms-id: 3708 + +extern "C" int printf (const char *, ...); +extern "C" int atoi (const char *); + +void *ptr; + +class A { +public: + A() { printf ("A is constructed.\n"); } + virtual void xx(int doit) { printf ("A is destructed.\n"); } +}; + +class A1 { +public: + A1() { printf ("A1 is constructed.\n"); } + virtual void xx(int doit) { printf ("A1 is destructed.\n"); } +}; + +class B : public virtual A, public A1 { +public: + B() { printf ("B is constructed.\n"); } + virtual void xx(int doit) { + printf ("B is destructed.\n"); + A1::xx (1); + if (doit) A::xx (1); + } +}; + +int num; + +class C : public virtual A, public B { +public: + C() { ++num; printf ("C is constructed.\n"); + ptr = this; + } + virtual void xx(int doit) { + --num; + if (ptr != this) + printf("FAIL\n%x != %x\n", ptr, this); + printf ("C is destructed.\n"); + B::xx (0); + if (doit) A::xx (1); + } +}; + +void fooA(A *a) { + printf ("Casting to A!\n"); + a->xx (1); +} +void fooA1(A1 *a) { + printf ("Casting to A1!\n"); + a->xx (1); +} + +void fooB(B *b) { + printf ("Casting to B!\n"); + b->xx (1); +} + +void fooC(C *c) { + printf ("Casting to C!\n"); + c->xx (1); +} + +int main(int argc, char *argv[]) { + printf ("*** Construct C object!\n"); + C *c = new C(); + + int i = 0; + + printf ("*** Try to delete the casting pointer!\n"); + switch (i) + { + case 0: fooA1(c); + break; + case 1: fooA(c); + break; + case 2: fooB(c); + break; + case 3: fooC(c); + break; + } + + return num!=0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p3708a.C b/gcc/testsuite/g++.old-deja/g++.mike/p3708a.C new file mode 100644 index 000000000..dff53b553 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p3708a.C @@ -0,0 +1,87 @@ +// { dg-do run } +// prms-id: 3708 + +extern "C" int printf (const char *, ...); +extern "C" int atoi (const char *); + +void *ptr; + +class A { +public: + A() { printf ("A is constructed.\n"); } + virtual void xx(int doit) { printf ("A is destructed.\n"); } +}; + +class A1 { +public: + A1() { printf ("A1 is constructed.\n"); } + virtual void xx(int doit) { printf ("A1 is destructed.\n"); } +}; + +class B : public A1, public virtual A { +public: + B() { printf ("B is constructed.\n"); } + virtual void xx(int doit) { + printf ("B is destructed.\n"); + A1::xx (1); + if (doit) A::xx (1); + } +}; + +int num; + +class C : public virtual A, public B { +public: + C() { ++num; printf ("C is constructed.\n"); + ptr = this; + } + virtual void xx(int doit) { + --num; + if (ptr != this) + printf("FAIL\n%x != %x\n", ptr, this); + printf ("C is destructed.\n"); + B::xx (0); + if (doit) A::xx (1); + } +}; + +void fooA(A *a) { + printf ("Casting to A!\n"); + a->xx (1); +} +void fooA1(A1 *a) { + printf ("Casting to A1!\n"); + a->xx (1); +} + +void fooB(B *b) { + printf ("Casting to B!\n"); + b->xx (1); +} + +void fooC(C *c) { + printf ("Casting to C!\n"); + c->xx (1); +} + +int main(int argc, char *argv[]) { + printf ("*** Construct C object!\n"); + C *c = new C(); + + int i = 0; + + printf ("*** Try to delete the casting pointer!\n"); + switch (i) + { + case 0: fooA1(c); + break; + case 1: fooA(c); + break; + case 2: fooB(c); + break; + case 3: fooC(c); + break; + } + + return num!=0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p3708b.C b/gcc/testsuite/g++.old-deja/g++.mike/p3708b.C new file mode 100644 index 000000000..2cccc4691 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p3708b.C @@ -0,0 +1,86 @@ +// { dg-do run } +// prms-id: 3708 + +extern "C" int printf (const char *, ...); +extern "C" void exit(int); + +void *ptr; + +class A { +public: + A() { printf ("A is constructed.\n"); } + virtual void xx(int doit) { printf ("A is destructed.\n"); } +}; + +class A1 { +public: + A1() { printf ("A1 is constructed.\n"); } + virtual void xx(int doit) { printf ("A1 is destructed.\n"); } +}; + +class B : public virtual A, public A1 { +public: + B() { printf ("B is constructed.\n"); } + virtual void xx(int doit) { + printf ("B is destructed.\n"); + A1::xx (1); + if (doit) A::xx (1); + } +}; + +int num; + +class C : public virtual A { +public: + C() { printf ("C is constructed.\n"); + } + virtual void xx(int doit) { + printf ("C is destructed.\n"); + if (doit) A::xx (1); + } +}; + +class D : public C, public B { +public: + D() { ++num; printf ("D is constructed.\n"); + ptr = this; + } + virtual void xx(int doit) { + --num; + if (ptr != this) { + printf("FAIL\n%x != %x\n", ptr, this); + exit(1); + } + printf ("D is destructed.\n"); + C::xx (0); + B::xx (0); + } +}; + +void fooA(A *a) { + printf ("Casting to A!\n"); + a->xx (1); +} +void fooA1(A1 *a) { + printf ("Casting to A1!\n"); + a->xx (1); +} + +void fooB(B *b) { + printf ("Casting to B!\n"); + b->xx (1); +} + +void fooC(C *c) { + printf ("Casting to C!\n"); + c->xx (1); +} + +int main(int argc, char *argv[]) { + printf ("*** Construct D object!\n"); + D *d = new D(); + + printf ("*** Try to delete the casting pointer!\n"); + fooA1(d); + return num!=0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p3764.C b/gcc/testsuite/g++.old-deja/g++.mike/p3764.C new file mode 100644 index 000000000..5a833b32f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p3764.C @@ -0,0 +1,25 @@ +// { dg-do assemble } +// prms-id: 3764 + +class Menu; +class MenuItem; + +class MenuAction { +public: + virtual void execute (Menu& menu, MenuItem& menuItem) = 0; +protected: + MenuAction () {} +}; + +class Test { + class MenuCBA : public MenuAction { + public: + typedef void (Test::* MenuCBA_Member) (Menu& menu, MenuItem& menuItem) ; + MenuCBA(Test& instance, MenuCBA_Member member) + : _instance(&instance), _member(member) { } + void execute(Menu& menu, MenuItem& menuItem); + private: + MenuCBA_Member _member; + Test *_instance; + }; +}; diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p3836.C b/gcc/testsuite/g++.old-deja/g++.mike/p3836.C new file mode 100644 index 000000000..77f859b2c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p3836.C @@ -0,0 +1,15 @@ +// { dg-do assemble } +// prms-id: 3836 + +void f(int &i) { // { dg-error "" } ref line + i = 10; +} + +int main() +{ + int i=1, j=2; + f(i); + f((int)j); // { dg-error "" } passing in to non-const + if (j != 2) + return 1; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p4068.C b/gcc/testsuite/g++.old-deja/g++.mike/p4068.C new file mode 100644 index 000000000..1e65adce4 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p4068.C @@ -0,0 +1,23 @@ +// { dg-do run } +// prms-id: 4068 + +struct A { + A(); + typedef void (A::*F)(); + void d(); + void foo() { } + F& f() { return f_; } + F f_; +}; + +A::A() : f_(&A::foo) { +} + +void A::d() { + (this->*(f()))(); +} + +int main() { + A a; + a.d(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p4104.C b/gcc/testsuite/g++.old-deja/g++.mike/p4104.C new file mode 100644 index 000000000..0f61cd27f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p4104.C @@ -0,0 +1,16 @@ +// { dg-do run } +// prms-id: 4104 + +template <class T> +void F(T &a, void (*P)(T &temp)) { + (*P)(a); +} + +template <class T> +void G(T &a) { +} + +int main() { + int a; + F(a, G); +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p4173.C b/gcc/testsuite/g++.old-deja/g++.mike/p4173.C new file mode 100644 index 000000000..e07bc0695 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p4173.C @@ -0,0 +1,26 @@ +// { dg-do assemble } +// { dg-options "-Wall -ansi -pedantic-errors" } +// This error happens because lvalue is not done well in the C++ front-end. +// NOPs should be lvalues if their arguments are. +// NON_LVALUE_EXPRs shouldn't be. + +// prms-id: 4173 + +enum TypeKind { + RecordTypeKind +}; +struct Type +{ + enum TypeKind kind : 8; + unsigned char prefixLen; +}; + +Type a; +Type b; +TypeKind c; + +int +main() { + a.kind = b.kind = c; + (a.kind = c) = b.kind; // { dg-bogus "" } +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p418.C b/gcc/testsuite/g++.old-deja/g++.mike/p418.C new file mode 100644 index 000000000..412884071 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p418.C @@ -0,0 +1,18 @@ +// { dg-do assemble } +// prms-id: 418 + +class Base { +public: + int foo; +}; + +class Derived : public Base { +public: + int bar; +}; + +void func(Base&); // { dg-error "" } referenced by error below + +void func2(const Derived& d) { + func(d); // { dg-error "" } should be error because of const +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p4238.C b/gcc/testsuite/g++.old-deja/g++.mike/p4238.C new file mode 100644 index 000000000..48d30ce7f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p4238.C @@ -0,0 +1,7 @@ +// { dg-do assemble } +// This showed a problem with default op= +// prms-id: 4238 + +struct sigcontext { + int sc_wbuf[31][25]; +}; // { dg-bogus "" } default op= seems broken diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p4246.C b/gcc/testsuite/g++.old-deja/g++.mike/p4246.C new file mode 100644 index 000000000..c81ae7571 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p4246.C @@ -0,0 +1,49 @@ +// { dg-do run } +// prms-id: 4246 + +extern "C" void abort (); +int num_d; + +class A +{ + public: + A() { } + virtual ~A() { } + virtual void id() { } +}; + +class B +{ + public: + B() { } + virtual ~B() { } + virtual void id() { } +}; + +class C : public A, public B +{ + public: + C() { } + virtual ~C() { } + void id() { abort(); } +}; + +class D : public C +{ + public: + D() { ++num_d; } + virtual ~D() { -- num_d; } + void id() { } +}; + +int main() +{ + D* dp2 = new D; + ((B*)dp2)->id(); + delete (B*) dp2; + + B* bp1 = new D; + bp1->id(); + delete bp1; + return num_d != 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p4263.C b/gcc/testsuite/g++.old-deja/g++.mike/p4263.C new file mode 100644 index 000000000..7a49c2ba7 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p4263.C @@ -0,0 +1,15 @@ +// { dg-do assemble } +// prms-id: 4263 + +enum OT {A_type, B_Type}; +enum AT {A, B}; + +/* These are not ok. */ +OT t = A; // { dg-error "" } +OT e2 = 1; // { dg-error "" } +OT e3 = 1.1; // { dg-error "" } + +/* These are ok. */ +int i = A; +double d = A; +OT e4 = A_type; diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p438.C b/gcc/testsuite/g++.old-deja/g++.mike/p438.C new file mode 100644 index 000000000..6e78af165 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p438.C @@ -0,0 +1,24 @@ +// { dg-do assemble } +// prms-id: 438 + +class D; + +class C +{ + public: + void test() const; +}; + +class D +{ + public: + void a(C& b); // { dg-message "D::a|no known conversion" } +}; + +void C::test() const +{ + D d; + + d.a(*this); // { dg-error "match" } *this is const, so should get error + // { dg-message "candidate" "candidate note" { target *-*-* } 22 } +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p4484.C b/gcc/testsuite/g++.old-deja/g++.mike/p4484.C new file mode 100644 index 000000000..b0ec0c9fc --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p4484.C @@ -0,0 +1,26 @@ +// { dg-do assemble } +// prms-id: 4484 + +class A { + char buf[64]; +}; + +typedef void (A::*pmf)(); +typedef void (A::*pmfc)() const; + +pmfc p = (pmfc)(pmf)0; + +class B { +}; + +class D : public A, public B { +}; + +typedef int (B::*bmfp)(); +typedef int (D::*dmfp)(); + +bmfp foo; + +void bar(dmfp a) { + bar(foo); +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p4511.C b/gcc/testsuite/g++.old-deja/g++.mike/p4511.C new file mode 100644 index 000000000..25348f463 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p4511.C @@ -0,0 +1,34 @@ +// { dg-do run } +// prms-id: 4511 + +int bad; + +class A { +public: + virtual void dummy (){} +}; + +class B { +public: + virtual void f(void) = 0; +}; + +class C : public A, public B { +public: + void f(void) { bad=1; } +}; + +class D : public C { +public: + void f(void) { } +}; + +class E : public D { }; + +int main() { + E e; + e.f(); + E * ep = &e; + ep->f(); + return bad; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p4619.C b/gcc/testsuite/g++.old-deja/g++.mike/p4619.C new file mode 100644 index 000000000..866146a56 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p4619.C @@ -0,0 +1,10 @@ +// { dg-do assemble } +// prms-id: 4619 + +int main() { + int i = 3; + int (*p)[10] = new int [20][10]; + int (*p1)[5][7][13][10] = new int [i][5][7][13][10]; + delete [] p1; + delete [] p; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p4623.C b/gcc/testsuite/g++.old-deja/g++.mike/p4623.C new file mode 100644 index 000000000..f602c9fdf --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p4623.C @@ -0,0 +1,36 @@ +// { dg-do run } +// prms-id: 4623 + +class base { +public: + int b_data; + base( int i=0 ) { b_data = i; } + void b_print() { } +}; + +class base1: virtual public base { +public: + int b1_data; + base1( int i = 0 ) { b1_data = i; b_data++; } + void b1_print() { } +}; + +class base2: virtual public base { +public: + int b2_data; + base2( int i = 0 ) { b2_data = i; b_data++; } + void b2_print() { } +}; + +class base3: public base {}; + +class derived: public base3, public base1, public base2 { +public: + int d_data; + derived( int i ) { d_data = i; ((base3 *)this)->b_data++; } + void d_print() { } +}; + +int main() { + derived d(1); d.d_print(); return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p4667.C b/gcc/testsuite/g++.old-deja/g++.mike/p4667.C new file mode 100644 index 000000000..e8eee21be --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p4667.C @@ -0,0 +1,32 @@ +// { dg-do run } +// prms-id: 4667 + +int counter = 0; +int a = 0; +int b = 0; +int c = 0; + +struct A { + A() { a = counter++; } +}; + +struct B { + B() { b = counter++; } +}; + +struct C : public virtual B { + C() { c = counter++; } +}; + +struct D : public virtual A, public virtual C { }; + +extern "C" int printf(const char*,...); +int main(void) { + D d; + + if (!(a == 0 && b == 1 && c == 2)) { + return 1; + } + + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p4671.C b/gcc/testsuite/g++.old-deja/g++.mike/p4671.C new file mode 100644 index 000000000..54b182c2b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p4671.C @@ -0,0 +1,16 @@ +// { dg-do assemble } +// prms-id: 4671 + +class ccUnwind { +public: + virtual void _c_getInfo() const; + virtual ~ccUnwind (); +}; +class ccTransmittable { +public: + virtual ~ccTransmittable(); +}; +class ccCommand : public ccUnwind, public ccTransmittable { +}; +class foo : public ccCommand { +}; diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p4677.C b/gcc/testsuite/g++.old-deja/g++.mike/p4677.C new file mode 100644 index 000000000..92f0f397a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p4677.C @@ -0,0 +1,9 @@ +// { dg-do assemble } +// prms-id: 4677 + +struct A { + A(double d) { } +}; + +struct B { B(A) { } } bad = 1; // { dg-error "" } +B good (1); diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p4693.C b/gcc/testsuite/g++.old-deja/g++.mike/p4693.C new file mode 100644 index 000000000..67d040e91 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p4693.C @@ -0,0 +1,24 @@ +// { dg-do assemble } +// prms-id: 4693 + +class a { +public: + virtual ~a(); +}; + +class b { +public: + virtual void set_var() = 0; +}; + +class c : public b, public a { }; + +class d : public c { +public: + void set_var() { } +}; + +int main() { + d * test; + test = new d; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p4736a.C b/gcc/testsuite/g++.old-deja/g++.mike/p4736a.C new file mode 100644 index 000000000..f50dbcdb3 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p4736a.C @@ -0,0 +1,40 @@ +// { dg-do run } +// prms-id: 4736 + +int did_fail = 1; + +class O { +public: + virtual void of() { } +}; + +class A : public O { +public: + virtual void vf() { } +}; + +class W { +public: + virtual void vf() { } +}; + +class X : public W, public A { +public: + virtual void vf() { } +}; + +class Z : public X { +public: + virtual void vf() { did_fail = 0; } +}; + +Z sz; + +void fail1(W* w) { + w->vf(); +} + +int main() { + fail1 (&sz); + return did_fail; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p4736b.C b/gcc/testsuite/g++.old-deja/g++.mike/p4736b.C new file mode 100644 index 000000000..c2fce17b4 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p4736b.C @@ -0,0 +1,49 @@ +// { dg-do run } +// prms-id: 4736 + +class Rep { +public: + virtual int foo() { return 1; } +}; + +class Rep_1 : public Rep { +}; + +class VBaseMain { +public: + virtual int foo() { return 2; } +}; + +class OtherVBase { +public: + virtual int foo() { return 3; } +}; + +class Rep_2 : public Rep { +}; + +class DVBase : public VBaseMain, public Rep_2, public OtherVBase { +public: + virtual int foo() { return 4; } +}; + +class Main : public Rep_1, virtual public DVBase { +public: + virtual int foo() { return 5; } +}; + +int main() { + Main m; + if (m.foo() != 5) + return 1; + if (((Rep*)(Rep_1*)&m)->foo() != 5) + return 2; + if (((DVBase*)&m)->foo() != 5) + return 3; + if (((VBaseMain*)(DVBase*)&m)->foo() != 5) + return 4; + if (((Rep*)(Rep_2*)(DVBase*)&m)->foo() != 5) + return 5; + if (((OtherVBase*)(DVBase*)&m)->foo() != 5) + return 6; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p4736c.C b/gcc/testsuite/g++.old-deja/g++.mike/p4736c.C new file mode 100644 index 000000000..d260b3afe --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p4736c.C @@ -0,0 +1,63 @@ +// { dg-do run } +// prms-id: 4736 + +int did_fail; + +class Rep { +public: + virtual ~Rep() { } +}; + +class Rep_1 : public Rep { +}; + +class VBaseMain { +public: + virtual ~VBaseMain() { } +}; + +class OtherVBase { +public: + virtual ~OtherVBase() { } +}; + +class Rep_2 : public Rep { +}; + +class DVBase : public VBaseMain, public Rep_2, public OtherVBase { +public: + virtual ~DVBase() { } +}; + +class Main : public Rep_1, virtual public DVBase { +public: + virtual ~Main() { did_fail = 0; } +}; + +int main() { + Main* m; + did_fail = 1; + delete new Main; + if (did_fail) + return 1; + did_fail = 1; + delete (Rep*)(Rep_1*)new Main; + if (did_fail) + return 2; + did_fail = 1; + delete (DVBase*)new Main; + if (did_fail) + return 3; + did_fail = 1; + delete (VBaseMain*)(DVBase*)new Main; + if (did_fail) + return 4; + did_fail = 1; + delete (Rep*)(Rep_2*)(DVBase*)new Main; + if (did_fail) + return 5; + did_fail = 1; + delete (OtherVBase*)(DVBase*)new Main; + if (did_fail) + return 6; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p4750.C b/gcc/testsuite/g++.old-deja/g++.mike/p4750.C new file mode 100644 index 000000000..ccf462be0 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p4750.C @@ -0,0 +1,10 @@ +// { dg-do assemble { target native } } +// { dg-options "-fpic -pedantic-errors -S" } +// prms-id: 4750 + +extern const int FRAME_VEC_MAX; + +const int FRAME_VEC_MAX = 12; +int frame_vec_sizes[FRAME_VEC_MAX+1] = { + 0, 1, 3, 3, 6, 6, 6, 9, 9, 9, 12, 12, 12 +}; diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p5469.C b/gcc/testsuite/g++.old-deja/g++.mike/p5469.C new file mode 100644 index 000000000..8c82c7e3d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p5469.C @@ -0,0 +1,22 @@ +// { dg-do run } +// prms-id: 5469 + +int count; + +class A { + A(); + A(const A&); +public: + A(int) { ++count; } + ~A() { --count; } + int operator== (const A& r) { return 0; } +}; + +int main() { + { + A a (1); + 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 new file mode 100644 index 000000000..03a398469 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p5469a.C @@ -0,0 +1,22 @@ +// { dg-do run } +// prms-id: 5469 + +int count; + +class A { + A(); + A(const A&); +public: + A(int) { ++count; } + ~A() { --count; } + int operator== (const A& r) { return 1; } +}; + +int main() { + { + A a (1); + if (a == 2 || a == 1) + ; + } + return count; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p5571.C b/gcc/testsuite/g++.old-deja/g++.mike/p5571.C new file mode 100644 index 000000000..b03675fbf --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p5571.C @@ -0,0 +1,71 @@ +// { dg-do run } +// prms-id: 5571 + +int e = 0; +void *vp = 0; + +class ParentOne { +public: + ParentOne() {} +#ifdef MAKE_WORK + virtual ~ParentOne() {} +#endif +private: + char SomeData[101]; +}; + +class ParentTwo { +public: + ParentTwo() {} + virtual ~ParentTwo() {} +private: + int MoreData[12]; + virtual int foo() { return 0; } +}; + +struct Child : public ParentOne, public ParentTwo { + int ChildsToy; + virtual void PrintThis() = 0; +}; + +struct Student : public Child { + int StudentsBook; + void PrintThis() { + if (vp == 0) + vp = (void *)this; + else + { + if (vp != (void *)this) + ++e; + } + } + void LocalPrintThis() { + if (vp == 0) + vp = (void *)this; + else + { + if (vp != (void *)this) + ++e; + } + PrintThis(); + } + void ForcedPrintThis() { + if (vp == 0) + vp = (void *)this; + else + { + if (vp != (void *)this) + ++e; + } + Student::PrintThis(); + } +}; + +int main() { + Student o; + o.LocalPrintThis(); + o.ForcedPrintThis(); + Child* pX = &o; + pX->PrintThis(); + return e; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p5611.C b/gcc/testsuite/g++.old-deja/g++.mike/p5611.C new file mode 100644 index 000000000..b5c180658 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p5611.C @@ -0,0 +1,12 @@ +// { dg-do run } +// prms-id: 5611 + +int main(void) +{ + struct B + { + virtual void b1() { } + }; + + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p5673.C b/gcc/testsuite/g++.old-deja/g++.mike/p5673.C new file mode 100644 index 000000000..759d5d8b6 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p5673.C @@ -0,0 +1,21 @@ +// { dg-do run } +// prms-id: 5673 + +class A { +public: + operator int () { + return 7; + } + ~A(); +}; + +int foo() { + return A(); +} + +int main() { + return foo() != 7; +} + +A::~A() { +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p5718.C b/gcc/testsuite/g++.old-deja/g++.mike/p5718.C new file mode 100644 index 000000000..d0acbb9bd --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p5718.C @@ -0,0 +1,38 @@ +// { dg-do run } +// prms-id: 5718 + +class Base { + int i; +public: + Base() { i = 42; } +}; + + +class Mixin { + int j; +public: + Mixin() { j = 42; } +}; + + +class Derived : public Base, public Mixin { +public: + Derived() { } + Derived & operator=(Mixin & m) { return *this; } +}; + + +void +testFunct(Derived * arg) { + Mixin temp; + + (Mixin &)(*arg) = temp; // { dg-bogus "" } +} + + +int +main(int argc, char *argv[]) { + Derived temp; + + testFunct(&temp); +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p5793.C b/gcc/testsuite/g++.old-deja/g++.mike/p5793.C new file mode 100644 index 000000000..db6e658aa --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p5793.C @@ -0,0 +1,21 @@ +// { dg-do assemble } +// prms-id: 5793 + +class temp_string { + public: + temp_string (const int); + temp_string (const char * const); +}; + +class Range { + public: + Range ( const int); + operator int () const ; +}; + +int operator == (const int, temp_string ); + +void CheckArrayConstraints(void) { + if (Range(0L) == 0L) + ; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p5840.C b/gcc/testsuite/g++.old-deja/g++.mike/p5840.C new file mode 100644 index 000000000..1cd033005 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p5840.C @@ -0,0 +1,36 @@ +// { dg-do run } +// prms-id: 5840 + +class Signal { +public: + int Name(void) { return 1; } +}; + +class Derived : public Signal { +public: + int Name(void) { return 2; } +}; + +template <class Foo , int (Foo::*Id)(void)> +class Bar +{ +public: + int value (Foo* a) { return (a->*Id)(); } +}; + +/* The following line is illegal under the new rules for non-type + template arguments in the standard, so it is commented out. */ +/* template class Bar <Derived, &Signal::Name>; */ +template class Bar <Signal, &Signal::Name>; +template class Bar <Derived, &Derived::Name>; + +Derived a; + +/* Bar<Derived, &Signal::Name> dispatcher1; */ +Bar<Derived, &Derived::Name> dispatcher2; + +int main() { + /* int i1 = dispatcher1.value(&a); */ + int i2 = dispatcher2.value(&a); + return /* i1 != 1 || */ i2 != 2; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p5958.C b/gcc/testsuite/g++.old-deja/g++.mike/p5958.C new file mode 100644 index 000000000..666a44945 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p5958.C @@ -0,0 +1,28 @@ +// { dg-do run } +// { dg-options "-ansi" } +// prms-id: 5958 + +class A { }; + +main() { + int i = 1; + if (1 not_eq 1) + return 1; + if (not (1 and 1)) + return 1; + if (not (1 or 1)) + return 1; + if (compl ~0) + return 1; + if (1 bitand 2) + return 1; + if (not (1 bitor 2)) + return 1; + if (1 xor 1) + return 1; + i and_eq 1; + i or_eq 2; + i xor_eq 4; + if (i not_eq 7) + return 1; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p6004.C b/gcc/testsuite/g++.old-deja/g++.mike/p6004.C new file mode 100644 index 000000000..2b262bdb0 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p6004.C @@ -0,0 +1,21 @@ +// { dg-do run } +// { dg-options "" } +// prms-id: 6004 + +class A { +public: + static int foo() asm("_my_routine"); +}; + +int bar1() asm("foo__1A"); +int bar2() asm("_foo__1A"); +int bar3() asm("__foo__1A"); +int bar1() { return 45; } +int bar2() { return 44; } +int bar3() { return 43; } + +int A::foo() { return 42; } + +main() { + return A::foo() - 42; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p6058.C b/gcc/testsuite/g++.old-deja/g++.mike/p6058.C new file mode 100644 index 000000000..3146e542a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p6058.C @@ -0,0 +1,18 @@ +// { dg-do assemble } +// { dg-options "-fexceptions -pedantic-errors" } +// prms-id: 6058 + +void bar(struct s1 { } a) { (void)a; } // { dg-error "" } + +struct s2*fooey() +{ + try { + static_cast<struct s3 { } *>(0); // { dg-error "" } + const_cast<struct s4 { } *>((s4*)0); // { dg-error "" } + reinterpret_cast<struct s5 { } *>((s3*)0); // { dg-error "" } + dynamic_cast<struct s6 { } *>((s6*)0); // { dg-error "" } + (struct s7 { } *)(int*)0xffedec; // { dg-error "" } + } catch (struct s8 { } s) { // { dg-error "" } + } + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p6149.C b/gcc/testsuite/g++.old-deja/g++.mike/p6149.C new file mode 100644 index 000000000..d7b819637 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p6149.C @@ -0,0 +1,4 @@ +// { dg-do assemble } +// prms-id: 6149 + +int a[3 - sizeof(double)]; // { dg-error "" } diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p6311.C b/gcc/testsuite/g++.old-deja/g++.mike/p6311.C new file mode 100644 index 000000000..309a083ad --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p6311.C @@ -0,0 +1,17 @@ +// { dg-do run } +// prms-id: 6311 + +struct Foo { + int member; +} a = { 42 }, *ptra = &a; + +int Foo::*pmd = &Foo::member; + +int main() { + if (pmd == 0) + return 1; + if (a.*pmd != 42) + return 2; + if (ptra->*pmd != 42) + return 3; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p646.C b/gcc/testsuite/g++.old-deja/g++.mike/p646.C new file mode 100644 index 000000000..4f7807d11 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p646.C @@ -0,0 +1,163 @@ +// { dg-do assemble } +// { dg-options "-Wno-deprecated -Wreturn-type" } +// GROUPS passed i960 +/* + Bug Id: bnr + PMRS Id: p0000646 + Bug is: Urgent Code Generation Problem in gcc-i960 V 1.95 +*/ + + + +extern "C" +{ + int printf (const char *, ...); + void abort (); +} + +struct foo +{ + static int si; + int i; + foo (); + foo (const foo&); + ~foo (); +}; + +int +foo_parm_returns_i (foo foo_arg) +{ + return foo_arg.i; +} + +int foo::si = 0; + +foo::foo () +{ + si++; + printf ("new foo @ 0x%x; now %d foos\n", this, si); +} + +foo::foo (const foo &other) +{ + si++; + printf ("another foo @ 0x%x; now %d foos\n", this, si); + *this = other; +} + +foo::~foo () +{ + si--; + printf ("deleted foo @ 0x%x; now %d foos\n", this, si); +} + +int +return_1 () +{ + foo f; + printf ("returning 1\n"); + return 1; +} + +int +return_arg (int arg) +{ + foo f; + printf ("returning %d\n", arg); + return arg; +} + +int +return_sum (int x, int y) +{ + foo f; + printf ("returning %d+%d\n", x, y); + return x + y; +} + +foo +return_foo () +{ + foo f; + printf ("returning foo\n"); + return f; +} + +foo +foo_parm_returns_foo (foo f) +{ + return f; +} + +void +abort_because (const char *str) +{ + printf ("aborting because %s\n", str); + abort (); +} + +int +warn_return_1 () +{ + foo f; + printf ("returning 1\n"); +} // { dg-warning "" } control reaches end + +int +warn_return_arg (int arg) +{ + foo f; + printf ("returning %d\n", arg); + arg; +} // { dg-warning "" } control reaches end + +int +warn_return_sum (int x, int y) +{ + foo f; + printf ("returning %d+%d\n", x, y); + x + y; +} // { dg-warning "" } control reaches end + +foo +warn_return_foo () +{ + foo f; + printf ("returning foo\n"); +} // { dg-warning "" } control reaches end + +foo +warn_foo_parm_returns_foo (foo f) +{ + f; +} // { dg-warning "" } control reaches end + +main () // { dg-warning "" } no type +{ + int ii = return_1 (); + if (ii != 1) + abort_because ("wrong value returned"); + int j = return_arg (42); + if (j != 42) + abort_because ("wrong value returned"); + int k = return_sum (-69, 69); + if (k != 0) + abort_because ("wrong value returned"); + foo f1 = return_foo (); + if (foo::si != 1) + abort_because ("wrong number of foos"); + f1.i = 5; + int l = foo_parm_returns_i (f1); + if (l != 5) + abort_because ("l != 5"); + foo f2 = foo_parm_returns_foo (f1); + if (foo::si != 2) + abort_because ("wrong number of foos"); + if (f2.i != 5) + abort_because ("f2.i != 5"); + foo f3 = return_foo (); + if (foo::si != 3) + abort_because ("wrong number of foos"); + printf("PASS\n"); + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p6578.C b/gcc/testsuite/g++.old-deja/g++.mike/p6578.C new file mode 100644 index 000000000..d738f3cf1 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p6578.C @@ -0,0 +1,8 @@ +// { dg-do assemble } +// prms-id: 6578 + +struct A { + operator int (); +}; + +int i = A(); diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p658.C b/gcc/testsuite/g++.old-deja/g++.mike/p658.C new file mode 100644 index 000000000..8fc7cd51b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p658.C @@ -0,0 +1,109 @@ +// { dg-do run } +// prms-id: 658 + +#include <iostream> +#include <cstdlib> + +/* We may not find the libg++ <bool.h>. */ +#ifndef FALSE +#define FALSE false +#endif +#ifndef TRUE +#define TRUE true +#endif + +// The VxWorks kernel-mode headers define a macro named "OK", which is not +// ISO-compliant, but is part of the VxWorks API. +#if defined __vxworks && !defined __RTP__ +#undef OK +#endif + +class Object { +public: + Object(); + Object(const Object&); + ~Object(); + + void OK() const; +private: + bool _destructed; +}; + +class Char: public Object { +public: + Char(); + Char(char); + Char(const Char&); + ~Char(); + + operator char () const; +private: + char _c; +}; + +int main() +{ + Char r, s; + + r = Char('r'); + s = Char('s'); +} + +// +// Object stuff +// +Object::Object(): +_destructed(FALSE) +{} + +Object::Object(const Object& other): +_destructed(FALSE) +{ + other.OK(); +} + +Object::~Object() +{ + OK(); + _destructed = TRUE; +} + +void +Object::OK() const +{ + if (_destructed) { + std::cerr << "FAILURE - reference was made to a destructed object\n"; + std::abort(); + } +} + +// +// Char stuff +// + +Char::Char(): +Object(), +_c('a') +{ } + +Char::Char(char c): +Object(), +_c(c) +{ } + +Char::Char(const Char& other): +Object(other), +_c(other._c) +{ } + +Char::~Char() +{ + OK(); +} + +Char::operator char () const +{ + return _c; +} + + diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p6610a.C b/gcc/testsuite/g++.old-deja/g++.mike/p6610a.C new file mode 100644 index 000000000..4870e074d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p6610a.C @@ -0,0 +1,15 @@ +// { dg-do run } +// prms-id: 6610 +// There is a bug in vtable thunks with multiple/virtual inheritance. + +int fail = 1; +struct B; +struct A { virtual int f(const B*) = 0; int g(const B*); }; +int A::g(const B* t) { return f(t); } +struct B : virtual A { B(); int f(const B*); B* B_this; }; +B::B() { if (g(this)) fail = 0; } +int B::f(const B* t) { return t == this; } +struct C : B { int f(const B*); int x; }; +int C::f(const B*) { return 0; } + +int main() { C c; return fail; } diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p6610b.C b/gcc/testsuite/g++.old-deja/g++.mike/p6610b.C new file mode 100644 index 000000000..664a0ca03 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p6610b.C @@ -0,0 +1,15 @@ +// { dg-do run } +// prms-id: 6610 + +int fail = 1; +struct B; +struct A { virtual int f(const B*) = 0; int g(const B*); }; +int A::g(const B* t) { return f(t); } +struct B : virtual A { int f(const B*); B* B_this; }; +int B::f(const B* t) { return t == this; } +struct S1 { }; +struct C : virtual S1, virtual B, virtual A { C(); }; +C::C() { if (g(this)) fail = 0; } +struct D : virtual B, virtual A, C { }; + +int main() { D d; return fail; } diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p6611.C b/gcc/testsuite/g++.old-deja/g++.mike/p6611.C new file mode 100644 index 000000000..9a2a28ed1 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p6611.C @@ -0,0 +1,27 @@ +// { dg-do run } +// prms-id: 6611 + +class COMPLEX { +public: + COMPLEX(double a, double b=0) { re = a; im = b; } + void print() const { } +private: + double re; + double im; +}; + +int main(void) +{ + COMPLEX a[3][3] = { + { 1, COMPLEX(2,3), COMPLEX(3,4), }, + { 1, COMPLEX(2,3), COMPLEX(3,4), }, + { 1, COMPLEX(2,3), COMPLEX(3,4), }, + }; + int i,j; + + for (i = 0; i < 3; i++) { + for (j = 0; j < 3; j++) { + a[i][j].print(); + } + } +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p6746.C b/gcc/testsuite/g++.old-deja/g++.mike/p6746.C new file mode 100644 index 000000000..09809a801 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p6746.C @@ -0,0 +1,18 @@ +// { dg-do assemble } +// prms-id: 6746 + +class call_trace { +public: + call_trace(const char* fcn_name); + ~call_trace(); +}; + +static char * last_tree; +extern "C" void prt(); + +char * smt_mark_stree() { + const char* _my_name = "smt_mark_stree" ; + call_trace _t(_my_name); + + return last_tree = 0 ? (char*)0 : (prt(), (char*)0); +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p6901.C b/gcc/testsuite/g++.old-deja/g++.mike/p6901.C new file mode 100644 index 000000000..0d55c8d96 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p6901.C @@ -0,0 +1,7 @@ +// { dg-do assemble } +// prms-id: 6901 + +void green() { + for (int i = 0; i < 10; i++) {} + for (int i = 0; i < 10; i++) {} +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p6927.C b/gcc/testsuite/g++.old-deja/g++.mike/p6927.C new file mode 100644 index 000000000..22b4875e3 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p6927.C @@ -0,0 +1,17 @@ +// { dg-do run } +// prms-id: 6927 + +class Object { +public: + Object(); + int Value; +}; + +Object::Object() : Value(-1) { } + +Object *pArr = new Object[2]; + +int main() { + if (pArr[0].Value != -1 || pArr[1].Value != -1) + return 1; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p700.C b/gcc/testsuite/g++.old-deja/g++.mike/p700.C new file mode 100644 index 000000000..1fef5c855 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p700.C @@ -0,0 +1,2386 @@ +// { dg-do assemble } +// { dg-options "-Wno-deprecated" } +// { dg-error "limited range of data type" "16-bit target" { target xstormy16-*-* } 0 } +// prms-id: 700 + +//# 1 "../../../../libg++/etc/benchmarks/dhrystone.cc" + + + + + + + + + + + + + + + + + + + + + + + + + +//# 1 "../../../../libg++/etc/benchmarks/Int.h" 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +class Int +{ +protected: + int rep; + + + +public: + Int (); + Int (const int b); + Int (const Int& b); + ~Int(); + + operator int() const; + + inline virtual int val() const; + + inline virtual void operator = (const int); + inline virtual void operator = (const Int&); + + inline virtual void negate(); + inline virtual void complement(); + inline virtual void operator ++ (); + inline virtual void operator -- (); + + inline virtual void operator += (const Int & ); + inline virtual void operator -= (const Int & ); + inline virtual void operator *= (const Int & ); + inline virtual void operator /= (const Int & ); + inline virtual void operator %= (const Int & ); + inline virtual void operator |= (const Int & ); + inline virtual void operator &= (const Int & ); + inline virtual void operator ^= (const Int & ); + inline virtual void operator <<=(const Int & ); + inline virtual void operator >>=(const Int & ); + + + inline virtual void operator += (const int); + inline virtual void operator -= (const int); + inline virtual void operator *= (const int); + inline virtual void operator /= (const int); + inline virtual void operator %= (const int); + inline virtual void operator |= (const int); + inline virtual void operator &= (const int); + inline virtual void operator ^= (const int); + inline virtual void operator <<=(const int); + inline virtual void operator >>=(const int); + + +}; + +inline int Int::val() const { return rep; } +inline Int::operator int() const { return val(); } + +inline Int::Int () :rep(0) {} +inline Int::Int (const int b) :rep(b) {} +inline Int::Int (const Int& b) :rep(b.Int::val()) {} +inline Int::~Int() {} + +inline void Int::operator = (const int b) +{ rep = b; ; } +inline void Int::operator = (const Int& b) +{ rep = b.Int::val(); ; } + +inline void Int::complement() +{ rep = ~rep; ; } +inline void Int::negate() +{ rep = -rep; ; } +inline void Int::operator ++ () +{ ++rep; ; } +inline void Int::operator -- () +{ --rep; ; } + +inline void Int::operator += (const Int & b) +{ rep += b.Int::val(); ; } +inline void Int::operator -= (const Int & b) +{ rep -= b.Int::val(); ; } +inline void Int::operator *= (const Int & b) +{ rep *= b.Int::val(); ; } +inline void Int::operator /= (const Int & b) +{ rep /= b.Int::val(); ; } +inline void Int::operator %= (const Int & b) +{ rep %= b.Int::val(); ; } +inline void Int::operator |= (const Int & b) +{ rep |= b.Int::val(); ; } +inline void Int::operator &= (const Int & b) +{ rep &= b.Int::val(); ; } +inline void Int::operator ^= (const Int & b) +{ rep ^= b.Int::val(); ; } +inline void Int::operator <<=(const Int & b) +{ rep <<= b.Int::val(); ; } +inline void Int::operator >>=(const Int & b) +{ rep >>= b.Int::val(); ; } + + + +inline void Int::operator += (const int b) +{ rep += b; ; } +inline void Int::operator -= (const int b) +{ rep -= b; ; } +inline void Int::operator *= (const int b) +{ rep *= b; ; } +inline void Int::operator /= (const int b) +{ rep /= b; ; } +inline void Int::operator %= (const int b) +{ rep %= b; ; } +inline void Int::operator |= (const int b) +{ rep |= b; ; } +inline void Int::operator &= (const int b) +{ rep &= b; ; } +inline void Int::operator ^= (const int b) +{ rep ^= b; ; } +inline void Int::operator <<=(const int b) +{ rep <<= b; ; } +inline void Int::operator >>=(const int b) +{ rep >>= b; ; } + + +inline int& operator = (int& a, const Int & b) // { dg-error "" } +{ a = b.Int::val(); return a;} +inline int& operator += (int& a, const Int & b) +{ a += b.Int::val(); return a; } +inline int& operator -= (int& a, const Int & b) +{ a -= b.Int::val(); return a;} +inline int& operator *= (int& a, const Int & b) +{ a *= b.Int::val(); return a;} +inline int& operator /= (int& a, const Int & b) +{ a /= b.Int::val(); return a;} +inline int& operator %= (int& a, const Int & b) +{ a %= b.Int::val(); return a;} +inline int& operator |= (int& a, const Int & b) +{ a |= b.Int::val(); return a;} +inline int& operator &= (int& a, const Int & b) +{ a &= b.Int::val(); return a;} +inline int& operator ^= (int& a, const Int & b) +{ a ^= b.Int::val(); return a;} +inline int& operator <<=(int& a, const Int & b) +{ a <<= b.Int::val(); return a;} +inline int& operator >>=(int& a, const Int & b) +{ a >>= b.Int::val(); return a;} + + + +//# 289 "../../../../libg++/etc/benchmarks/Int.h" + + +inline Int operator - (const Int & a) return r(a) // { dg-error "" } +{ r.negate(); } // { dg-error "" } +inline Int operator ~ (const Int & a) return r(a) // { dg-error "" } +{ r.complement(); } // { dg-error "" } + +inline Int operator + (const Int & a, const Int & b) return r(a) // { dg-error "" } +{ r += b.Int::val(); } // { dg-error "" } +inline Int operator - (const Int & a, const Int & b) return r(a) // { dg-error "" } +{ r -= b.Int::val(); } // { dg-error "" } +inline Int operator * (const Int & a, const Int & b) return r(a) // { dg-error "" } +{ r *= b.Int::val(); } // { dg-error "" } +inline Int operator / (const Int & a, const Int & b) return r(a) // { dg-error "" } +{ r /= b.Int::val(); } // { dg-error "" } +inline Int operator % (const Int & a, const Int & b) return r(a) // { dg-error "" } +{ r %= b.Int::val(); } // { dg-error "" } +inline Int operator << (const Int & a, const Int & b) return r(a) // { dg-error "" } +{ r <<= b.Int::val(); } // { dg-error "" } +inline Int operator >> (const Int & a, const Int & b) return r(a) // { dg-error "" } +{ r >>= b.Int::val(); } // { dg-error "" } +inline Int operator & (const Int & a, const Int & b) return r(a) // { dg-error "" } +{ r &= b.Int::val(); } // { dg-error "" } +inline Int operator | (const Int & a, const Int & b) return r(a) // { dg-error "" } +{ r |= b.Int::val(); } // { dg-error "" } +inline Int operator ^ (const Int & a, const Int & b) return r(a) // { dg-error "" } +{ r ^= b.Int::val(); } // { dg-error "" } + +inline Int operator + (const Int & a, const int b) return r(a) // { dg-error "" } +{ r += b; } // { dg-error "" } +inline Int operator - (const Int & a, const int b) return r(a) // { dg-error "" } +{ r -= b; } // { dg-error "" } +inline Int operator * (const Int & a, const int b) return r(a) // { dg-error "" } +{ r *= b; } // { dg-error "" } +inline Int operator / (const Int & a, const int b) return r(a) // { dg-error "" } +{ r /= b; } // { dg-error "" } +inline Int operator % (const Int & a, const int b) return r(a) // { dg-error "" } +{ r %= b; } // { dg-error "" } +inline Int operator << (const Int & a, const int b) return r(a) // { dg-error "" } +{ r <<= b; } // { dg-error "" } +inline Int operator >> (const Int & a, const int b) return r(a) // { dg-error "" } +{ r >>= b; } // { dg-error "" } +inline Int operator & (const Int & a, const int b) return r(a) // { dg-error "" } +{ r &= b; } // { dg-error "" } +inline Int operator | (const Int & a, const int b) return r(a) // { dg-error "" } +{ r |= b; } // { dg-error "" } +inline Int operator ^ (const Int & a, const int b) return r(a) // { dg-error "" } +{ r ^= b; } // { dg-error "" } + +inline Int operator + (const int a, const Int & b) return r(a) // { dg-error "" } +{ r += b.Int::val(); } // { dg-error "" } +inline Int operator - (const int a, const Int & b) return r(a) // { dg-error "" } +{ r -= b.Int::val(); } // { dg-error "" } +inline Int operator * (const int a, const Int & b) return r(a) // { dg-error "" } +{ r *= b.Int::val(); } // { dg-error "" } +inline Int operator / (const int a, const Int & b) return r(a) // { dg-error "" } +{ r /= b.Int::val(); } // { dg-error "" } +inline Int operator % (const int a, const Int & b) return r(a) // { dg-error "" } +{ r %= b.Int::val(); } // { dg-error "" } +inline Int operator << (const int a, const Int & b) return r(a) // { dg-error "" } +{ r <<= b.Int::val(); } // { dg-error "" } +inline Int operator >> (const int a, const Int & b) return r(a) // { dg-error "" } +{ r >>= b.Int::val(); } // { dg-error "" } +inline Int operator & (const int a, const Int & b) return r(a) // { dg-error "" } +{ r &= b.Int::val(); } // { dg-error "" } +inline Int operator | (const int a, const Int & b) return r(a) // { dg-error "" } +{ r |= b.Int::val(); } // { dg-error "" } +inline Int operator ^ (const int a, const Int & b) return r(a) // { dg-error "" } +{ r ^= b.Int::val(); } // { dg-error "" } + + + +inline int operator ! (const Int & a) { return !a.Int::val(); } + +inline int operator == (const Int & a, const Int & b) +{ return a.Int::val() == b.Int::val(); } +inline int operator != (const Int & a, const Int & b) +{ return a.Int::val() != b.Int::val(); } +inline int operator < (const Int & a, const Int & b) +{ return a.Int::val() < b.Int::val(); } +inline int operator <= (const Int & a, const Int & b) +{ return a.Int::val() <= b.Int::val(); } +inline int operator > (const Int & a, const Int & b) +{ return a.Int::val() > b.Int::val(); } +inline int operator >= (const Int & a, const Int & b) +{ return a.Int::val() >= b.Int::val(); } + +inline int operator == (const Int & a, const int b) +{ return a.Int::val() == b; } +inline int operator != (const Int & a, const int b) +{ return a.Int::val() != b; } +inline int operator < (const Int & a, const int b) +{ return a.Int::val() < b; } +inline int operator <= (const Int & a, const int b) +{ return a.Int::val() <= b; } +inline int operator > (const Int & a, const int b) +{ return a.Int::val() > b; } +inline int operator >= (const Int & a, const int b) +{ return a.Int::val() >= b; } + +inline int operator == (const int a, const Int & b) +{ return a == b.Int::val(); } +inline int operator != (const int a, const Int & b) +{ return a != b.Int::val(); } +inline int operator < (const int a, const Int & b) +{ return a < b.Int::val(); } +inline int operator <= (const int a, const Int & b) +{ return a <= b.Int::val(); } +inline int operator > (const int a, const Int & b) +{ return a > b.Int::val(); } +inline int operator >= (const int a, const Int & b) +{ return a >= b.Int::val(); } + + + +//# 26 "../../../../libg++/etc/benchmarks/dhrystone.cc" 2 + +//# 1 "../../../../libg++/etc/benchmarks/Char.h" 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +class Char +{ +protected: + char rep; + + + +public: + Char (); + Char (const char b); + Char (const Char& b); + ~Char(); + + operator char() const; + + inline virtual char val() const; + + inline virtual void operator = (const char); + inline virtual void operator = (const Char&); + + inline virtual void negate(); + inline virtual void complement(); + inline virtual void operator ++ (); + inline virtual void operator -- (); + + inline virtual void operator += (const Char & ); + inline virtual void operator -= (const Char & ); + inline virtual void operator *= (const Char & ); + inline virtual void operator /= (const Char & ); + inline virtual void operator %= (const Char & ); + inline virtual void operator |= (const Char & ); + inline virtual void operator &= (const Char & ); + inline virtual void operator ^= (const Char & ); + inline virtual void operator <<=(const Char & ); + inline virtual void operator >>=(const Char & ); + + + inline virtual void operator += (const char); + inline virtual void operator -= (const char); + inline virtual void operator *= (const char); + inline virtual void operator /= (const char); + inline virtual void operator %= (const char); + inline virtual void operator |= (const char); + inline virtual void operator &= (const char); + inline virtual void operator ^= (const char); + inline virtual void operator <<=(const char); + inline virtual void operator >>=(const char); + + +}; + +inline char Char::val() const { return rep; } +inline Char::operator char() const { return val(); } + +inline Char::Char () :rep(0) {} +inline Char::Char (const char b) :rep(b) {} +inline Char::Char (const Char& b) :rep(b.Char::val()) {} +inline Char::~Char() {} + +inline void Char::operator = (const char b) +{ rep = b; ; } +inline void Char::operator = (const Char& b) +{ rep = b.Char::val(); ; } + +inline void Char::complement() +{ rep = ~rep; ; } +inline void Char::negate() +{ rep = -rep; ; } +inline void Char::operator ++ () +{ ++rep; ; } +inline void Char::operator -- () +{ --rep; ; } + +inline void Char::operator += (const Char & b) +{ rep += b.Char::val(); ; } +inline void Char::operator -= (const Char & b) +{ rep -= b.Char::val(); ; } +inline void Char::operator *= (const Char & b) +{ rep *= b.Char::val(); ; } +inline void Char::operator /= (const Char & b) +{ rep /= b.Char::val(); ; } +inline void Char::operator %= (const Char & b) +{ rep %= b.Char::val(); ; } +inline void Char::operator |= (const Char & b) +{ rep |= b.Char::val(); ; } +inline void Char::operator &= (const Char & b) +{ rep &= b.Char::val(); ; } +inline void Char::operator ^= (const Char & b) +{ rep ^= b.Char::val(); ; } +inline void Char::operator <<=(const Char & b) +{ rep <<= b.Char::val(); ; } +inline void Char::operator >>=(const Char & b) +{ rep >>= b.Char::val(); ; } + + + +inline void Char::operator += (const char b) +{ rep += b; ; } +inline void Char::operator -= (const char b) +{ rep -= b; ; } +inline void Char::operator *= (const char b) +{ rep *= b; ; } +inline void Char::operator /= (const char b) +{ rep /= b; ; } +inline void Char::operator %= (const char b) +{ rep %= b; ; } +inline void Char::operator |= (const char b) +{ rep |= b; ; } +inline void Char::operator &= (const char b) +{ rep &= b; ; } +inline void Char::operator ^= (const char b) +{ rep ^= b; ; } +inline void Char::operator <<=(const char b) +{ rep <<= b; ; } +inline void Char::operator >>=(const char b) +{ rep >>= b; ; } + + +inline char& operator = (char& a, const Char & b) // { dg-error "" } +{ a = b.Char::val(); return a;} +inline char& operator += (char& a, const Char & b) +{ a += b.Char::val(); return a; } +inline char& operator -= (char& a, const Char & b) +{ a -= b.Char::val(); return a;} +inline char& operator *= (char& a, const Char & b) +{ a *= b.Char::val(); return a;} +inline char& operator /= (char& a, const Char & b) +{ a /= b.Char::val(); return a;} +inline char& operator %= (char& a, const Char & b) +{ a %= b.Char::val(); return a;} +inline char& operator |= (char& a, const Char & b) +{ a |= b.Char::val(); return a;} +inline char& operator &= (char& a, const Char & b) +{ a &= b.Char::val(); return a;} +inline char& operator ^= (char& a, const Char & b) +{ a ^= b.Char::val(); return a;} +inline char& operator <<=(char& a, const Char & b) +{ a <<= b.Char::val(); return a;} +inline char& operator >>=(char& a, const Char & b) +{ a >>= b.Char::val(); return a;} + + + +//# 291 "../../../../libg++/etc/benchmarks/Char.h" + + +inline Char operator - (const Char & a) return r(a) // { dg-error "" } +{ r.negate(); } // { dg-error "" } +inline Char operator ~ (const Char & a) return r(a) // { dg-error "" } +{ r.complement(); } // { dg-error "" } + +inline Char operator + (const Char & a, const Char & b) return r(a) // { dg-error "" } +{ r += b.Char::val(); } // { dg-error "" } +inline Char operator - (const Char & a, const Char & b) return r(a) // { dg-error "" } +{ r -= b.Char::val(); } // { dg-error "" } +inline Char operator * (const Char & a, const Char & b) return r(a) // { dg-error "" } +{ r *= b.Char::val(); } // { dg-error "" } +inline Char operator / (const Char & a, const Char & b) return r(a) // { dg-error "" } +{ r /= b.Char::val(); } // { dg-error "" } +inline Char operator % (const Char & a, const Char & b) return r(a) // { dg-error "" } +{ r %= b.Char::val(); } // { dg-error "" } +inline Char operator << (const Char & a, const Char & b) return r(a) // { dg-error "" } +{ r <<= b.Char::val(); } // { dg-error "" } +inline Char operator >> (const Char & a, const Char & b) return r(a) // { dg-error "" } +{ r >>= b.Char::val(); } // { dg-error "" } +inline Char operator & (const Char & a, const Char & b) return r(a) // { dg-error "" } +{ r &= b.Char::val(); } // { dg-error "" } +inline Char operator | (const Char & a, const Char & b) return r(a) // { dg-error "" } +{ r |= b.Char::val(); } // { dg-error "" } +inline Char operator ^ (const Char & a, const Char & b) return r(a) // { dg-error "" } +{ r ^= b.Char::val(); } // { dg-error "" } + +inline Char operator + (const Char & a, const char b) return r(a) // { dg-error "" } +{ r += b; } // { dg-error "" } +inline Char operator - (const Char & a, const char b) return r(a) // { dg-error "" } +{ r -= b; } // { dg-error "" } +inline Char operator * (const Char & a, const char b) return r(a) // { dg-error "" } +{ r *= b; } // { dg-error "" } +inline Char operator / (const Char & a, const char b) return r(a) // { dg-error "" } +{ r /= b; } // { dg-error "" } +inline Char operator % (const Char & a, const char b) return r(a) // { dg-error "" } +{ r %= b; } // { dg-error "" } +inline Char operator << (const Char & a, const char b) return r(a) // { dg-error "" } +{ r <<= b; } // { dg-error "" } +inline Char operator >> (const Char & a, const char b) return r(a) // { dg-error "" } +{ r >>= b; } // { dg-error "" } +inline Char operator & (const Char & a, const char b) return r(a) // { dg-error "" } +{ r &= b; } // { dg-error "" } +inline Char operator | (const Char & a, const char b) return r(a) // { dg-error "" } +{ r |= b; } // { dg-error "" } +inline Char operator ^ (const Char & a, const char b) return r(a) // { dg-error "" } +{ r ^= b; } // { dg-error "" } + +inline Char operator + (const char a, const Char & b) return r(a) // { dg-error "" } +{ r += b.Char::val(); } // { dg-error "" } +inline Char operator - (const char a, const Char & b) return r(a) // { dg-error "" } +{ r -= b.Char::val(); } // { dg-error "" } +inline Char operator * (const char a, const Char & b) return r(a) // { dg-error "" } +{ r *= b.Char::val(); } // { dg-error "" } +inline Char operator / (const char a, const Char & b) return r(a) // { dg-error "" } +{ r /= b.Char::val(); } // { dg-error "" } +inline Char operator % (const char a, const Char & b) return r(a) // { dg-error "" } +{ r %= b.Char::val(); } // { dg-error "" } +inline Char operator << (const char a, const Char & b) return r(a) // { dg-error "" } +{ r <<= b.Char::val(); } // { dg-error "" } +inline Char operator >> (const char a, const Char & b) return r(a) // { dg-error "" } +{ r >>= b.Char::val(); } // { dg-error "" } +inline Char operator & (const char a, const Char & b) return r(a) // { dg-error "" } +{ r &= b.Char::val(); } // { dg-error "" } +inline Char operator | (const char a, const Char & b) return r(a) // { dg-error "" } +{ r |= b.Char::val(); } // { dg-error "" } +inline Char operator ^ (const char a, const Char & b) return r(a) // { dg-error "" } +{ r ^= b.Char::val(); } // { dg-error "" } + + + +inline char operator ! (const Char & a) { return !a.Char::val(); } + +inline char operator == (const Char & a, const Char & b) +{ return a.Char::val() == b.Char::val(); } +inline char operator != (const Char & a, const Char & b) +{ return a.Char::val() != b.Char::val(); } +inline char operator < (const Char & a, const Char & b) +{ return a.Char::val() < b.Char::val(); } +inline char operator <= (const Char & a, const Char & b) +{ return a.Char::val() <= b.Char::val(); } +inline char operator > (const Char & a, const Char & b) +{ return a.Char::val() > b.Char::val(); } +inline char operator >= (const Char & a, const Char & b) +{ return a.Char::val() >= b.Char::val(); } + +inline char operator == (const Char & a, const char b) +{ return a.Char::val() == b; } +inline char operator != (const Char & a, const char b) +{ return a.Char::val() != b; } +inline char operator < (const Char & a, const char b) +{ return a.Char::val() < b; } +inline char operator <= (const Char & a, const char b) +{ return a.Char::val() <= b; } +inline char operator > (const Char & a, const char b) +{ return a.Char::val() > b; } +inline char operator >= (const Char & a, const char b) +{ return a.Char::val() >= b; } + +inline char operator == (const char a, const Char & b) +{ return a == b.Char::val(); } +inline char operator != (const char a, const Char & b) +{ return a != b.Char::val(); } +inline char operator < (const char a, const Char & b) +{ return a < b.Char::val(); } +inline char operator <= (const char a, const Char & b) +{ return a <= b.Char::val(); } +inline char operator > (const char a, const Char & b) +{ return a > b.Char::val(); } +inline char operator >= (const char a, const Char & b) +{ return a >= b.Char::val(); } + + + +//# 27 "../../../../libg++/etc/benchmarks/dhrystone.cc" 2 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +//# 1 "/giga/hgs/lib/g++-include/sys/types.h" 1 + + +//# 1 "/giga/hgs/lib/g++-include/stddef.h" 1 + +extern "C" { +//# 1 "/giga/hgs/lib/gcc/sun4/cygnus-1.96/include/stddef.h" 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +typedef int ptrdiff_t; + + + + + + + + + + + + + + + + + + + + + +typedef int size_t; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +//# 3 "/giga/hgs/lib/g++-include/stddef.h" 2 + +} +//# 73 "/giga/hgs/lib/g++-include/stddef.h" + +//# 3 "/giga/hgs/lib/g++-include/sys/types.h" 2 + + + + +extern "C" +{ + + + + + + + + + + + + + + + + + + + + + + + + + + +//# 1 "/usr/include/sys/types.h" 1 + + + + + + + + + + + + + + + +//# 1 "/usr/include/sys/stdtypes.h" 1 + + + + + + + + + + + + + +typedef int sigset_t; + +typedef unsigned int speed_t; +typedef unsigned long tcflag_t; +typedef unsigned char cc_t; +typedef int pid_t; + +typedef unsigned short mode_t; +typedef short nlink_t; + +typedef long clock_t; +typedef long time_t; + +typedef int size_t; +typedef int ptrdiff_t; + + +//# 16 "/usr/include/sys/types.h" 2 + + + +//# 1 "/usr/include/sys/sysmacros.h" 1 + + + + + + + + + + + + + + + + + + + +//# 19 "/usr/include/sys/types.h" 2 + + + + + +typedef unsigned char u_char; +typedef unsigned short u_short; +typedef unsigned int u_int; +typedef unsigned long u_long; +typedef unsigned short ushort; +typedef unsigned int uint; + + + + + + + + + + + + + + + +typedef struct _physadr_t { int r[1]; } *physadr_t; +typedef struct label_t { + int val[2]; +} label_t; + + + + + + + +typedef struct _quad_t { long val[2]; } quad_t; +typedef long daddr_t; +typedef char * caddr_t; +typedef unsigned long ino_t; +typedef short dev_t; +typedef long off_t; +typedef unsigned short uid_t; +typedef unsigned short gid_t; +typedef long key_t; +typedef char * addr_t; + + + + + + + + + + + + + + +typedef long fd_mask; + + + + + + + + + +typedef struct fd_set { + fd_mask fds_bits[(((256 )+(( (sizeof (fd_mask) * 8 ) )-1))/( (sizeof (fd_mask) * 8 ) )) ]; +} fd_set; + + + + + + + +//# 113 "/usr/include/sys/types.h" + + + +//# 35 "/giga/hgs/lib/g++-include/sys/types.h" 2 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +} + + + + +//# 310 "../../../../libg++/etc/benchmarks/dhrystone.cc" 2 + +//# 1 "/giga/hgs/lib/g++-include/sys/times.h" 1 +//# 1 "/giga/hgs/lib/g++-include/time.h" 1 + + + + + +//# 1 "/giga/hgs/lib/g++-include/stddef.h" 1 + +extern "C" { +//# 1 "/giga/hgs/lib/gcc/sun4/cygnus-1.96/include/stddef.h" 1 +//# 94 "/giga/hgs/lib/gcc/sun4/cygnus-1.96/include/stddef.h" + +//# 3 "/giga/hgs/lib/g++-include/stddef.h" 2 + +} +//# 73 "/giga/hgs/lib/g++-include/stddef.h" + +//# 6 "/giga/hgs/lib/g++-include/time.h" 2 + +//# 1 "/giga/hgs/lib/g++-include/stdio.h" 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +//#pragma interface + + + + + + + + + + + + + + + + + + + +//# 80 "/giga/hgs/lib/g++-include/stdio.h" + + + +//# 117 "/giga/hgs/lib/g++-include/stdio.h" + + + + + +//# 153 "/giga/hgs/lib/g++-include/stdio.h" + + + +extern "C" { + + + + + + + + + + + + + + + + + + + + + + + + + + + + +//# 1 "/usr/include/stdio.h" 1 + + + + + +extern struct _iobuf { + int _cnt; + unsigned char *_ptr; + unsigned char *_base; + int _bufsiz; + short _flag; + char _file; +} _iob[]; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +extern struct _iobuf *c_proto_fopen (); +extern struct _iobuf *c_proto_fdopen (); +extern struct _iobuf *c_proto_freopen (); +extern struct _iobuf *c_proto_popen (); +extern struct _iobuf *tmpfile(); +extern long ftell(_iobuf *); +extern char *fgets(char *, int, _iobuf *); +extern char *gets(char *); +extern char *c_proto_sprintf (); +extern char *ctermid(); +extern char *cuserid(); +extern char *c_proto_tempnam (); +extern char *tmpnam(); + + + + + + +//# 185 "/giga/hgs/lib/g++-include/stdio.h" 2 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +} +//# 417 "/giga/hgs/lib/g++-include/stdio.h" + + + + + + +extern "C" { + + + + + + + +int _doprnt(const char*, void*, struct _iobuf *); +int _doscan(struct _iobuf *, const char*, ...); +int _filbuf(struct _iobuf *); +int _flsbuf(unsigned, struct _iobuf *); + +int fclose(struct _iobuf *); +struct _iobuf * fdopen(int, const char*); +int fflush(struct _iobuf *); +int fgetc(struct _iobuf *); +char* fgets(char*, int, struct _iobuf *); +struct _iobuf * fopen(const char*, const char*); +int fprintf(struct _iobuf *, const char* ...); +int fputc(int, struct _iobuf *); +int fputs(const char*, struct _iobuf *); +int fread(void*, int, int, struct _iobuf *); + + + +struct _iobuf * freopen(const char*, const char*, struct _iobuf *); + +int fscanf(struct _iobuf *, const char* ...); +int fseek(struct _iobuf *, long, int); +long ftell(struct _iobuf *); +int fwrite(const void*, int, int, struct _iobuf *); +char* gets(char*); +int getw(struct _iobuf *); +int pclose(struct _iobuf *); +void perror(const char*); +struct _iobuf * popen(const char*, const char*); +int printf(const char* ...); +int puts(const char*); +int putw(int, struct _iobuf *); +int rewind(struct _iobuf *); +int scanf(const char* ...); +int setbuf(struct _iobuf *, char*); +int setbuffer(struct _iobuf *, char*, int); +int setlinebuf(struct _iobuf *); +int setvbuf(struct _iobuf *, char*, int, int); +int sscanf(char*, const char* ...); +struct _iobuf * tmpfile(); +int ungetc(int, struct _iobuf *); +int vfprintf(struct _iobuf *, const char*, ...); + + + + +int vprintf(const char*, ... ); + + + + + +int sprintf(char*, const char*, ...); +char* vsprintf(char*, const char*, ...); + + +} + + + + + + + + + + + + + + + + + +//# 7 "/giga/hgs/lib/g++-include/time.h" 2 + + +//# 1 "/giga/hgs/lib/g++-include/sys/types.h" 1 + + +//# 1 "/giga/hgs/lib/g++-include/stddef.h" 1 + +extern "C" { +//# 1 "/giga/hgs/lib/gcc/sun4/cygnus-1.96/include/stddef.h" 1 +//# 94 "/giga/hgs/lib/gcc/sun4/cygnus-1.96/include/stddef.h" + +//# 3 "/giga/hgs/lib/g++-include/stddef.h" 2 + +} +//# 73 "/giga/hgs/lib/g++-include/stddef.h" + +//# 3 "/giga/hgs/lib/g++-include/sys/types.h" 2 + + + + +extern "C" +{ + + + + + + + + + + + + + + + + + + + + + + + + + + +//# 1 "/usr/include/sys/types.h" 1 + + + + + + + + +//# 115 "/usr/include/sys/types.h" + +//# 35 "/giga/hgs/lib/g++-include/sys/types.h" 2 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +} + + + + +//# 9 "/giga/hgs/lib/g++-include/time.h" 2 + + +extern "C" { + + + + + + + + + + + + + + + + + +//# 42 "/giga/hgs/lib/g++-include/time.h" + + + + + + + +//# 1 "/usr/include/time.h" 1 + + + + + +//# 1 "/usr/include/sys/stdtypes.h" 1 + + + + + + + + + + +//# 32 "/usr/include/sys/stdtypes.h" + +//# 6 "/usr/include/time.h" 2 + + + + +struct tm { + int tm_sec; + int tm_min; + int tm_hour; + int tm_mday; + int tm_mon; + int tm_year; + int tm_wday; + int tm_yday; + int tm_isdst; + char *tm_zone; + long tm_gmtoff; +}; + +extern struct tm *c_proto_gmtime (), *c_proto_localtime (); +extern char *c_proto_asctime (), *c_proto_ctime (); +extern void c_proto_tzset (), c_proto_tzsetwall (); +extern int dysize(int); +extern time_t timelocal(), timegm(); + + +//# 49 "/giga/hgs/lib/g++-include/time.h" 2 + + +//# 1 "/usr/include/sys/times.h" 1 + + + + + + + + + +//# 1 "/giga/hgs/lib/g++-include/sys/types.h" 1 + + +//# 1 "/giga/hgs/lib/g++-include/stddef.h" 1 + +extern "C" { +//# 1 "/giga/hgs/lib/gcc/sun4/cygnus-1.96/include/stddef.h" 1 +//# 94 "/giga/hgs/lib/gcc/sun4/cygnus-1.96/include/stddef.h" + +//# 3 "/giga/hgs/lib/g++-include/stddef.h" 2 + +} +//# 73 "/giga/hgs/lib/g++-include/stddef.h" + +//# 3 "/giga/hgs/lib/g++-include/sys/types.h" 2 + + + + +extern "C" +{ + + + + + + + + + + + + + + + + + + + + + + + + + + +//# 1 "/usr/include/sys/types.h" 1 + + + + + + + + +//# 115 "/usr/include/sys/types.h" + +//# 35 "/giga/hgs/lib/g++-include/sys/types.h" 2 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +} + + + + +//# 10 "/usr/include/sys/times.h" 2 + + +struct tms { + clock_t tms_utime; + clock_t tms_stime; + clock_t tms_cutime; + clock_t tms_cstime; +}; + + +clock_t times(tms * ); + + + +//# 51 "/giga/hgs/lib/g++-include/time.h" 2 + + + + + + + + + + + + + + + + + + + + + +extern struct tm* localtime(long*); +extern struct tm* gmtime(long*); +extern char* ctime(long*); +extern char* asctime(struct tm*); +extern void tzset(); +extern void tzsetwall(); + + + + + + +extern long times(struct tms*); + + +//# 97 "/giga/hgs/lib/g++-include/time.h" + +extern char* timezone(int, int); +extern int getitimer(int, struct itimerval*); +extern int setitimer(int, struct itimerval*, struct itimerval*); +extern int gettimeofday(struct timeval*, struct timezone*); +extern int settimeofday(struct timeval*, struct timezone*); +extern int stime(long*); +int dysize(int); + + + + + + + + +long clock(void); + +long time(long*); +unsigned ualarm(unsigned, unsigned); +unsigned usleep(unsigned); +int profil(char*, int, int, int); + +} + + + +//# 1 "/giga/hgs/lib/g++-include/sys/times.h" 2 + +//# 311 "../../../../libg++/etc/benchmarks/dhrystone.cc" 2 + + + + + + + + + + + + + + + + + + + + + + + + +typedef enum {Ident1, Ident2, Ident3, Ident4, Ident5} Enumeration; + + + + +typedef Int OneToThirty; +typedef Int OneToFifty; +typedef Char CapitalLetter; +typedef Char String30[31]; +typedef Int Array1Dim[51]; +typedef Int Array2Dim[51][51]; + +struct Record +{ + struct Record *PtrComp; + Enumeration Discr; + Enumeration EnumComp; + OneToFifty IntComp; + String30 StringComp; +}; + +typedef struct Record RecordType; +typedef RecordType * RecordPtr; +typedef int boolean; + + + + + + + + + + + +extern "C" { +extern int printf(const char* ...); +extern void exit(int); +} + +void Proc0(); +void Proc1(RecordPtr PtrParIn); +void Proc2(OneToFifty *IntParIO); +void Proc3(RecordPtr *PtrParOut); +void Proc4(); +void Proc5(); +boolean Func3(Enumeration EnumParIn); +void Proc6( Enumeration EnumParIn, Enumeration *EnumParOut); +void Proc7(OneToFifty IntParI1, OneToFifty IntParI2, OneToFifty *IntParOut); +void Proc8(Array1Dim Array1Par, + Array2Dim Array2Par, + OneToFifty IntParI1, + OneToFifty IntParI2); +Enumeration Func1(CapitalLetter CharPar1, CapitalLetter CharPar2); +boolean Func2(String30 StrParI1, String30 StrParI2); +boolean Func3(Enumeration EnumParIn); + +void mystrcpy(String30 s, const char* t) +{ + for (; *t != '\0'; ++s, ++t) *s = *t; + *s = '\0'; +} + +char mystrcmp(String30 s, String30 t) +{ + for (; *s == *t; ++s, ++t) if (*s == '\0') return 0; + return char(*s - *t); +} + + + +main() +{ + Proc0(); + exit(0); +} + + + + +Int IntGlob; +boolean BoolGlob; +char Char1Glob; +char Char2Glob; +Array1Dim Array1Glob; +Array2Dim Array2Glob; +RecordPtr PtrGlb; +RecordPtr PtrGlbNext; + +void Proc0() +{ + OneToFifty IntLoc1; + OneToFifty IntLoc2; + OneToFifty IntLoc3; + char CharLoc; + char CharIndex; + Enumeration EnumLoc; + String30 String1Loc; + String30 String2Loc; + +//# 445 "../../../../libg++/etc/benchmarks/dhrystone.cc" + + + time_t starttime; + time_t benchtime; + time_t nulltime; + struct tms Tms; + register unsigned int i; + + times(&Tms); starttime = Tms.tms_utime; + for (i = 0; i < 500000 ; ++i); + times(&Tms); + nulltime = Tms.tms_utime - starttime; + + + PtrGlbNext = new Record; + PtrGlb = new Record; + PtrGlb->PtrComp = PtrGlbNext; + PtrGlb->Discr = Ident1; + PtrGlb->EnumComp = Ident3; + PtrGlb->IntComp = 40; + mystrcpy(PtrGlb->StringComp, "DHRYSTONE PROGRAM, SOME STRING"); + mystrcpy(String1Loc, "JUST INITIALIZED TO SOME JUNK."); + + + + + + + + + times(&Tms); starttime = Tms.tms_utime; + + for (i = 0; i < 500000 ; ++i) + { + + Proc5(); + Proc4(); + IntLoc1 = 2; + IntLoc2 = 3; + mystrcpy(String2Loc, "DHRYSTONE PROGRAM, 2'ND STRING"); + EnumLoc = Ident2; + BoolGlob = ! Func2(String1Loc, String2Loc); + while (IntLoc1 < IntLoc2) + { + IntLoc3 = 5 * IntLoc1 - IntLoc2; + Proc7(IntLoc1, IntLoc2, &IntLoc3); + ++IntLoc1; + } + Proc8(Array1Glob, Array2Glob, IntLoc1, IntLoc3); + Proc1(PtrGlb); + for (CharIndex = 'A'; CharIndex <= Char2Glob; ++CharIndex) + if (EnumLoc == Func1(CharIndex, 'C')) + Proc6(Ident1, &EnumLoc); + IntLoc3 = IntLoc2 * IntLoc1; + IntLoc2 = IntLoc3 / IntLoc1; + IntLoc2 = 7 * (IntLoc3 - IntLoc2) - IntLoc1; + Proc2(&IntLoc1); + } + + + + + + + + + + + + + + times(&Tms); + benchtime = Tms.tms_utime - starttime - nulltime; + printf("Dhrystone time for %ld passes = %ld\n", + (long) 500000 , benchtime/60 ); + printf("This machine benchmarks at %ld dhrystones/second\n", + ((long) 500000 ) * 60 / benchtime); + + +} + +void Proc1(RecordPtr PtrParIn) +{ + + + (*(PtrParIn->PtrComp)) = *PtrGlb ; + PtrParIn->IntComp = 5; + (*(PtrParIn->PtrComp)) .IntComp = PtrParIn->IntComp; + (*(PtrParIn->PtrComp)) .PtrComp = PtrParIn->PtrComp; + + Proc3(&((*(PtrParIn->PtrComp)) .PtrComp)); + if ((*(PtrParIn->PtrComp)) .Discr == Ident1) + { + (*(PtrParIn->PtrComp)) .IntComp = 6; + Proc6(PtrParIn->EnumComp, &(*(PtrParIn->PtrComp)) .EnumComp); + (*(PtrParIn->PtrComp)) .PtrComp = PtrGlb->PtrComp; + Proc7((*(PtrParIn->PtrComp)) .IntComp, 10, &(*(PtrParIn->PtrComp)) .IntComp); + } + else + *PtrParIn = (*(PtrParIn->PtrComp)) ; + + +} + +void Proc2(OneToFifty *IntParIO) +{ + OneToFifty IntLoc; + Enumeration EnumLoc; + + IntLoc = *IntParIO + 10; + for(;;) + { + if (Char1Glob == 'A') + { + --IntLoc; + *IntParIO = IntLoc - IntGlob; + EnumLoc = Ident1; + } + if (EnumLoc == Ident1) + break; + } +} + +void Proc3(RecordPtr *PtrParOut) +{ + if (PtrGlb != 0 ) + *PtrParOut = PtrGlb->PtrComp; + else + IntGlob = 100; + Proc7(10, IntGlob, &PtrGlb->IntComp); +} + +void Proc4() +{ + boolean BoolLoc; + + BoolLoc = Char1Glob == 'A'; + BoolLoc |= BoolGlob; + Char2Glob = 'B'; +} + +void Proc5() +{ + Char1Glob = 'A'; + BoolGlob = 0 ; +} + + + + +void Proc6( Enumeration EnumParIn, Enumeration *EnumParOut) +{ + *EnumParOut = EnumParIn; + if (! Func3(EnumParIn) ) + *EnumParOut = Ident4; + switch (EnumParIn) + { + case Ident1: *EnumParOut = Ident1; break; + case Ident2: if (IntGlob > 100) *EnumParOut = Ident1; + else *EnumParOut = Ident4; + break; + case Ident3: *EnumParOut = Ident2; break; + case Ident4: break; + case Ident5: *EnumParOut = Ident3; + } +} + +void Proc7(OneToFifty IntParI1, OneToFifty IntParI2, OneToFifty *IntParOut) +{ + OneToFifty IntLoc; + + IntLoc = IntParI1 + 2; + *IntParOut = IntParI2 + IntLoc; +} + +void Proc8(Array1Dim Array1Par, + Array2Dim Array2Par, + OneToFifty IntParI1, + OneToFifty IntParI2) +{ + OneToFifty IntLoc; + OneToFifty IntIndex; + + IntLoc = IntParI1 + 5; + Array1Par[IntLoc] = IntParI2; + Array1Par[IntLoc+1] = Array1Par[IntLoc]; + Array1Par[IntLoc+30] = IntLoc; + for (IntIndex = IntLoc; IntIndex <= (IntLoc+1); ++IntIndex) + Array2Par[IntLoc][IntIndex] = IntLoc; + ++Array2Par[IntLoc][IntLoc-1]; + Array2Par[IntLoc+20][IntLoc] = Array1Par[IntLoc]; + IntGlob = 5; +} + +Enumeration Func1(CapitalLetter CharPar1, CapitalLetter CharPar2) +{ + CapitalLetter CharLoc1; + CapitalLetter CharLoc2; + + CharLoc1 = CharPar1; + CharLoc2 = CharLoc1; + if (CharLoc2 != CharPar2) + return (Ident1); + else + return (Ident2); +} + +boolean Func2(String30 StrParI1, String30 StrParI2) +{ + OneToThirty IntLoc; + CapitalLetter CharLoc; + + IntLoc = 1; + while (IntLoc <= 1) + if (Func1(StrParI1[IntLoc], StrParI2[IntLoc+1]) == Ident1) + { + CharLoc = 'A'; + ++IntLoc; + } + if (CharLoc >= 'W' && CharLoc <= 'Z') + IntLoc = 7; + if (CharLoc == 'X') + return( 1 ); + else + { + if (mystrcmp(StrParI1, StrParI2) > 0) + { + IntLoc += 7; + return ( 1 ); + } + else + return ( 0 ); + } +} + +boolean Func3(Enumeration EnumParIn) +{ + Enumeration EnumLoc; + + EnumLoc = EnumParIn; + if (EnumLoc == Ident3) return ( 1 ); + return ( 0 ); +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p701.C b/gcc/testsuite/g++.old-deja/g++.mike/p701.C new file mode 100644 index 000000000..6a5259104 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p701.C @@ -0,0 +1,34 @@ +// { dg-do assemble } +// prms-id: 701 + +extern "C" +{ + int printf(const char *, ...); +} + + +void Munge(int& x) // { dg-error "passing argument 1" } +{ + x = 2; +} + + +class A +{ + public: + int i; + A(int x) : i(x) {} + void Safe() const; +}; + +void +A::Safe() const +{ + Munge(i); // { dg-error "invalid initialization" } +} + +int main() +{ + const A a(1); + a.Safe(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p710.C b/gcc/testsuite/g++.old-deja/g++.mike/p710.C new file mode 100644 index 000000000..7fdd5b022 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p710.C @@ -0,0 +1,43 @@ +// { dg-do assemble } +// GROUPS passed delete +/* + Bug Id: + PRMS Id: p0000710 + Bug is : overloading operator delete in class def not allowed +*/ + +/* + In addition to this bug, the compiler permits overloading operator + delete in the class definition. This is verboten, and should be + caught by a regression suite. In other words, the following is also a + bug that's not caught: +*/ + + +#include <stdlib.h> + +extern "C" +{ + int printf(const char*, ...); +} + + + +class B +{ + public: + int x; + virtual ~B() {} + void operator delete(void*,size_t s) + { + printf("B::delete() %d\n",s); + } + void operator delete(void*){} +}; + +int main() +{ + B* p = new B; + delete p; + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p7180.C b/gcc/testsuite/g++.old-deja/g++.mike/p7180.C new file mode 100644 index 000000000..55b7e1006 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p7180.C @@ -0,0 +1,18 @@ +// { dg-do run } +// prms-id: 7180 + +class String { +public: + String(const char*); + ~String(); +}; + +String::String(const char* str = "") { +} + +String::~String(void) { +} + +int main() { + const String array[] = {"3"}; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p7476.C b/gcc/testsuite/g++.old-deja/g++.mike/p7476.C new file mode 100644 index 000000000..04d77880f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p7476.C @@ -0,0 +1,20 @@ +// { dg-do assemble } +// prms-id: 7476 + +class HeapTracked { +public: + virtual ~HeapTracked() { } + static void isObjectAllocation(const HeapTracked *ptr); + static void isObjectAllocation(HeapTracked *ptr); +}; + +void HeapTracked::isObjectAllocation(HeapTracked *ptr) +{ + dynamic_cast<const void*>(ptr); + dynamic_cast<void*>(ptr); +} +void HeapTracked::isObjectAllocation(const HeapTracked *ptr) +{ + const_cast<void*>(dynamic_cast<const void*>(ptr)); + dynamic_cast<void*>(ptr); // { dg-error "" } +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p755.C b/gcc/testsuite/g++.old-deja/g++.mike/p755.C new file mode 100644 index 000000000..28eeefad4 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p755.C @@ -0,0 +1,19 @@ +// { dg-do run } +// It checks to see if you can define your own global new operator. +// prms-id: 755 + +#include <new> + +extern "C" void _exit(int); + +void* operator new(std::size_t sz) throw (std::bad_alloc) { + void* p = 0; + _exit(0); + return p; +} + +int main () { + int* i = new int; + delete i; + return 1; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p755a.C b/gcc/testsuite/g++.old-deja/g++.mike/p755a.C new file mode 100644 index 000000000..bc23d579e --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p755a.C @@ -0,0 +1,15 @@ +// { dg-do run } +// It checks to see if you can define your own global delete operator. +// prms-id: 755 + +extern "C" void _exit(int); + +void operator delete(void *p) throw() { + _exit(0); +} + +int main () { + int* i = new int; + delete i; + return 1; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p7626.C b/gcc/testsuite/g++.old-deja/g++.mike/p7626.C new file mode 100644 index 000000000..32c950df2 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p7626.C @@ -0,0 +1,43 @@ +// { dg-do assemble } +// prms-id: 7626 + +int fail; + +typedef unsigned int UINT; + +class CObject{}; + +class CCmdTarget : public CObject { +}; + +typedef void (CCmdTarget::*AFX_PMSG)(void); + +struct AFX_MSGMAP_ENTRY { + AFX_PMSG pfn; +}; + +class CWnd : public CCmdTarget { +public: + void OnMyMsg() { fail = 1; } // If this one is called, something is wrong. + static AFX_MSGMAP_ENTRY _messageEntries[]; +}; + +typedef void (CWnd::*AFX_PMSGW)(void); + +class CDialog : public CWnd +{ +public: + void OnMyMsg() { } + static AFX_MSGMAP_ENTRY _messageEntries[]; +}; + +AFX_MSGMAP_ENTRY CDialog ::_messageEntries[] = { + { (AFX_PMSG)(AFX_PMSGW)(void (CWnd::*)())&CDialog::OnMyMsg }, + { (AFX_PMSG)0 } +}; + +int main() { + CDialog d; + (d.*((CDialog::_messageEntries)[0]).pfn)(); // This should call CDialog::OnMyMsg + return fail; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p7635.C b/gcc/testsuite/g++.old-deja/g++.mike/p7635.C new file mode 100644 index 000000000..ac31af202 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p7635.C @@ -0,0 +1,7 @@ +// { dg-do assemble } +// prms-id: 7635 + +class DaycountBasis { + mutable const int * p; + mutable int * const q; // { dg-error "" } +}; diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p7651.C b/gcc/testsuite/g++.old-deja/g++.mike/p7651.C new file mode 100644 index 000000000..6e0aede0d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p7651.C @@ -0,0 +1,26 @@ +// { dg-do run } +// prms-id: 7651 + +int fail = 0; + +class Foo { +public: + Foo(double i) : data(i) { if (data != 1.0) fail = 1; } + ~Foo() { if (data != 1.0) fail = 1; } +private: + volatile double data; +}; + +int DingDong(double A) { + volatile Foo a(A); + + if ( A != 0.0 ) { + return 1; + } + return 0; +} + + +int main() { + DingDong(1.0); +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p783.C b/gcc/testsuite/g++.old-deja/g++.mike/p783.C new file mode 100644 index 000000000..0c04d643f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p783.C @@ -0,0 +1,16 @@ +// { dg-do run } +// prms-id: 783 + +extern "C" int printf (const char *, ...); + +class C { +public: + C() { } + ~C() { } +}; + +int main(int argc, char**argv) { + C c,d; + c = (argc&1) ? C() : d; + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p783a.C b/gcc/testsuite/g++.old-deja/g++.mike/p783a.C new file mode 100644 index 000000000..17609d583 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p783a.C @@ -0,0 +1,27 @@ +// { dg-do run } +// Copying into an object directly is a lose according to tiemann. +// Deleting an object many times is a lose. +// prms-id: 783 + +extern "C" int printf (const char *, ...); +extern "C" void exit (int); + +class C { + int i; +public: + C() { + i = 1; + } + ~C() { + if (i != 1) { + exit(1); + } + i = 0; + } +}; + +int main(int argc, char**argv) { + C c; + c = C(); + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p783b.C b/gcc/testsuite/g++.old-deja/g++.mike/p783b.C new file mode 100644 index 000000000..0aacb3285 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p783b.C @@ -0,0 +1,38 @@ +// { dg-do run } +// This one check for objects being destroyed twice. The bug it is +// looking for is the extra dtor call on C() even though it is never +// built. +// prms-id: 783 + +extern "C" int printf (const char *, ...); +extern "C" void exit (int); + +class C { + int i; +public: +// C() {printf ("C ctor at %x\n", this);} +// ~C() {printf ("C dtor at %x\n", this);} + C() { + i = 1; + } + ~C() { + if (i != 1) { + exit(1); + } + i = 0; + } +}; + +C g; + +C func() { + return g; +} + +int main(int argc, char**argv) { + C c,d; +// printf ("\n"); + c = (argc != 1) ? C() : d; +// printf ("\n"); + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p784.C b/gcc/testsuite/g++.old-deja/g++.mike/p784.C new file mode 100644 index 000000000..04a70c2ee --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p784.C @@ -0,0 +1,3658 @@ +// { dg-do assemble } +// { dg-require-effective-target ilp32 } */ +// { dg-options "-w" } +// prms-id: 784 + +//# 1 "GctSymbol.GctSymbol.CHMap.cc" +// This may look like C code, but it is really -*- C++ -*- +/* +Copyright (C) 1988, 2000, 2002 Free Software Foundation + written by Doug Lea (dl@rocky.oswego.edu) + +This file is part of the GNU C++ Library. This library is free +software; you can redistribute it and/or modify it under the terms of +the GNU Library General Public License as published by the Free +Software Foundation; either version 2 of the License, or (at your +option) any later version. This library is distributed in the hope +that it will be useful, but WITHOUT ANY WARRANTY; without even the +implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU Library General Public License for more details. +You should have received a copy of the GNU Library General Public +License along with this library; if not, write to the Free Software +Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + + +//#pragma implementation + +//# 1 "GctSymbol.GctSymbol.CHMap.h" 1 +// This may look like C code, but it is really -*- C++ -*- +/* +Copyright (C) 1988 Free Software Foundation + written by Doug Lea (dl@rocky.oswego.edu) + +This file is part of the GNU C++ Library. This library is free +software; you can redistribute it and/or modify it under the terms of +the GNU Library General Public License as published by the Free +Software Foundation; either version 2 of the License, or (at your +option) any later version. This library is distributed in the hope +that it will be useful, but WITHOUT ANY WARRANTY; without even the +implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU Library General Public License for more details. +You should have received a copy of the GNU Library General Public +License along with this library; if not, write to the Free Software +Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + + + + +//#pragma interface + + + +//# 1 "GctSymbol.GctSymbol.Map.h" 1 +// This may look like C code, but it is really -*- C++ -*- +/* +Copyright (C) 1988 Free Software Foundation + written by Doug Lea (dl@rocky.oswego.edu) + +This file is part of the GNU C++ Library. This library is free +software; you can redistribute it and/or modify it under the terms of +the GNU Library General Public License as published by the Free +Software Foundation; either version 2 of the License, or (at your +option) any later version. This library is distributed in the hope +that it will be useful, but WITHOUT ANY WARRANTY; without even the +implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU Library General Public License for more details. +You should have received a copy of the GNU Library General Public +License along with this library; if not, write to the Free Software +Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + + + + +//#pragma interface + + + +//# 1 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/Pix.h" 1 + + + +typedef void* Pix; + +//# 26 "GctSymbol.GctSymbol.Map.h" 2 + +//# 1 "GctSymbol.defs.h" 1 +// This may look like C code, but it is really -*- C++ -*- +/* +Copyright (C) 1988 Free Software Foundation + written by Doug Lea (dl@rocky.oswego.edu) + +This file is part of the GNU C++ Library. This library is free +software; you can redistribute it and/or modify it under the terms of +the GNU Library General Public License as published by the Free +Software Foundation; either version 2 of the License, or (at your +option) any later version. This library is distributed in the hope +that it will be useful, but WITHOUT ANY WARRANTY; without even the +implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU Library General Public License for more details. +You should have received a copy of the GNU Library General Public +License along with this library; if not, write to the Free Software +Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + + + + + + + +//# 1 "../../GctSymbol.h" 1 +// -*- C++ -*- + + + +// +// GctSymbol class +// +// Expects to be included by Gct.h +// +// Wendell Baker, Berkeley CAD Group, 1992 (wbaker@ic.Berkeley.EDU) +// + + + + + +//#pragma interface + + + + + +//# 25 "../../GctSymbol.h" 2 + +//# 1 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/String.h" 1 +// This may look like C code, but it is really -*- C++ -*- +/* +Copyright (C) 1988 Free Software Foundation + written by Doug Lea (dl@rocky.oswego.edu) + +This file is part of the GNU C++ Library. This library is free +software; you can redistribute it and/or modify it under the terms of +the GNU Library General Public License as published by the Free +Software Foundation; either version 2 of the License, or (at your +option) any later version. This library is distributed in the hope +that it will be useful, but WITHOUT ANY WARRANTY; without even the +implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU Library General Public License for more details. +You should have received a copy of the GNU Library General Public +License along with this library; if not, write to the Free Software +Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + + + + +//#pragma interface + + + +//# 1 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/stream.h" 1 + + + +// Compatibility with old library. + + +//# 1 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/iostream.h" 1 +// This is part of the iostream library, providing -*- C++ -*- input/output. +// Copyright (C) 1991 Per Bothner. +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Library General Public +// License as published by the Free Software Foundation; either +// version 2 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Library General Public License for more details. +// +// You should have received a copy of the GNU Library General Public +// License along with this library; if not, write to the Free +// Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + + + +//#pragma interface + + + + +//# 1 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/streambuf.h" 1 +// This is part of the iostream library, providing -*- C++ -*- input/output. +// Copyright (C) 1991 Per Bothner. +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Library General Public +// License as published by the Free Software Foundation; either +// version 2 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Library General Public License for more details. +// +// You should have received a copy of the GNU Library General Public +// License along with this library; if not, write to the Free +// Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + + + + +//#pragma interface + + +/* KLUDGES!! */ +//# 1 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/stddef.h" 1 + + +extern "C" { + + + +//# 1 "/projects/gnu-cygnus/gnu-cygnus-8/mips/lib/gcc/decstatn/cygnus-1.96/include/stddef.h" 1 + + + + + + +/* This avoids lossage on Sunos but only if stdtypes.h comes first. + There's no way to win with the other order! Sun lossage. */ + +/* In case nobody has defined these types, but we aren't running under + GCC 2.00, make sure that __PTRDIFF_TYPE__, __SIZE__TYPE__, and + __WCHAR_TYPE__ have reasonable values. This can happen if the + parts of GCC is compiled by an older compiler, that actually + include gstddef.h, such as collect2. */ + +/* Signed type of difference of two pointers. */ + + + + + + + + + + + + + + +typedef long int ptrdiff_t; + + + + + + +/* Unsigned type of `sizeof' something. */ + + + + + + + + + + + + + + +typedef unsigned int size_t; + + + + + + +/* Data type for wide chars. */ + + + + + + + + + + + + + + + + + + + + + + +/* A null pointer constant. */ + + + + +/* Offset of member MEMBER in a struct of type TYPE. */ + + + + + +//# 7 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/stddef.h" 2 + + + + +} + +//# 25 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/streambuf.h" 2 + + + + + + + + + + + + + + + + +class ostream; class streambuf; + +typedef long streamoff, streampos; + +struct _ios_fields { // The data members of an ios. + streambuf *_strbuf; + ostream* _tie; + long _width; + unsigned long _flags; + char _fill; + unsigned char _state; + unsigned short _precision; +}; + + +enum state_value { _good = 0, _eof = 1, _fail = 2, _bad = 4 }; + + +class ios : public _ios_fields { + public: + enum io_state { goodbit=0, eofbit=1, failbit=2, badbit=4 }; + enum open_mode { + in=1, + out=2, + ate=4, + app=8, + trunc=16, + nocreate=32, + noreplace=64 }; + enum seek_dir { beg, cur, end}; + enum { skipws=01, left=02, right=04, internal=010, + dec=020, oct=040, hex=0100, + showbase=0200, showpoint=0400, uppercase=01000, showpos=02000, + scientific=04000, fixed=0100000, unitbuf=020000, stdio=040000, + dont_close=0x80000000 //Don't close streambuf when destroying stream + }; + + ostream* tie() { return _tie; } + ostream* tie(ostream* val) { ostream* save=_tie; _tie=val; return save; } + + // Methods to change the format state. + char fill() { return _fill; } + char fill(char newf) { char oldf = _fill; _fill = newf; return oldf; } + unsigned long flags() { return _flags; } + unsigned long flags(unsigned long new_val) { + unsigned long old_val = _flags; _flags = new_val; return old_val; } + unsigned short precision() { return _precision; } + unsigned short precision(int newp) { + unsigned short oldp = _precision; _precision = (unsigned short)newp; + return oldp; } + unsigned long setf(unsigned long val) { + unsigned long oldbits = _flags; + _flags |= val; return oldbits; } + unsigned long setf(unsigned long val, unsigned long mask) { + unsigned long oldbits = _flags; + _flags = (_flags & ~mask) | (val & mask); return oldbits; } + unsigned long unsetf(unsigned long mask) { + unsigned long oldbits = _flags & mask; + _flags &= ~mask; return oldbits; } + long width() { return _width; } + long width(long val) { long save = _width; _width = val; return save; } + + static const unsigned long basefield; + static const unsigned long adjustfield; + static const unsigned long floatfield; + + streambuf* rdbuf() { return _strbuf; } + void clear(int state = 0) { _state = state; } + int good() { return _state == 0; } + int eof() { return _state & ios::eofbit; } + int fail() { return _state & (ios::badbit|ios::failbit); } + int bad() { return _state & ios::badbit; } + int rdstate() { return _state; } + void set(int flag) { _state |= flag; } + operator void*() { return fail() ? (void*)0 : (void*)this; } + int operator!() { return fail(); } + + + void unset(state_value flag) { _state &= ~flag; } + void close(); + int is_open(); + int readable(); + int writable(); + + + protected: + ios(streambuf*sb) { _strbuf=sb; _state=0; _width=0; _fill=' '; + _flags=ios::skipws; _precision=6; } +}; + + + + +typedef ios::seek_dir _seek_dir; + + +// Magic numbers and bits for the _flags field. +// The magic numbers use the high-order bits of _flags; +// the remaining bits are abailable for variable flags. +// Note: The magic numbers must all be negative if stdio +// emulation is desired. + + + + + + + + + + + + + + + +struct __streambuf { + // NOTE: If this is changed, also change __FILE in stdio/stdio.h! + int _flags; /* High-order word is _IO_MAGIC; rest is flags. */ + char* _gptr; /* Current get pointer */ + char* _egptr; /* End of get area. */ + char* _eback; /* Start of putback+get area. */ + char* _pbase; /* Start of put area. */ + char* _pptr; /* Current put pointer. */ + char* _epptr; /* End of put area. */ + char* _base; /* Start of reserve area. */ + char* _ebuf; /* End of reserve area. */ + struct streambuf *_chain; +}; + +struct streambuf : private __streambuf { + friend class ios; + friend class istream; + friend class ostream; + protected: + static streambuf* _list_all; /* List of open streambufs. */ + streambuf*& xchain() { return _chain; } + void _un_link(); + void _link_in(); + char* gptr() const { return _gptr; } + char* pptr() const { return _pptr; } + char* egptr() const { return _egptr; } + char* epptr() const { return _epptr; } + char* pbase() const { return _pbase; } + char* eback() const { return _eback; } + char* ebuf() const { return _ebuf; } + char* base() const { return _base; } + void xput_char(char c) { *_pptr++ = c; } + int xflags() { return _flags; } + int xflags(int f) { int fl = _flags; _flags = f; return fl; } + void xsetflags(int f) { _flags |= f; } + void gbump(int n) { _gptr += n; } + void pbump(int n) { _pptr += n; } + void setb(char* b, char* eb, int a=0); + void setp(char* p, char* ep) { _pbase=_pptr=p; _epptr=ep; } + void setg(char* eb, char* g, char *eg) { _eback=eb; _gptr=g; _egptr=eg; } + public: + static int flush_all(); + static void flush_all_linebuffered(); // Flush all line buffered files. + virtual int underflow(); // Leave public for now + virtual int overflow(int c = (-1) ); // Leave public for now + virtual int doallocate(); + virtual streampos seekoff(streamoff, _seek_dir, int mode=ios::in|ios::out); + virtual streampos seekpos(streampos pos, int mode = ios::in|ios::out); + int sputbackc(char c); + int sungetc(); + streambuf(); + virtual ~streambuf(); + int unbuffered() { return _flags & 2 ? 1 : 0; } + int linebuffered() { return _flags & 0x4000 ? 1 : 0; } + void unbuffered(int i) + { if (i) _flags |= 2 ; else _flags &= ~2 ; } + void linebuffered(int i) + { if (i) _flags |= 0x4000 ; else _flags &= ~0x4000 ; } + int allocate() { + if (base() || unbuffered()) return 0; + else return doallocate(); } + virtual int sync(); + virtual int pbackfail(int c); + virtual int ungetfail(); + virtual streambuf* setbuf(char* p, int len); + int in_avail() { return _egptr - _gptr; } + int out_waiting() { return _pptr - _pbase; } + virtual int sputn(const char* s, int n); + virtual int sgetn(char* s, int n); + long sgetline(char* buf, size_t n, char delim, int putback_delim); + int sbumpc() { + if (_gptr >= _egptr && underflow() == (-1) ) return (-1) ; + else return *(unsigned char*)_gptr++; } + int sgetc() { + if (_gptr >= _egptr && underflow() == (-1) ) return (-1) ; + else return *(unsigned char*)_gptr; } + int snextc() { + if (++_gptr >= _egptr && underflow() == (-1) ) return (-1) ; + else return *(unsigned char*)_gptr; } + int sputc(int c) { + if (_pptr >= _epptr) return overflow(c); + return *_pptr++ = c, (unsigned char)c; } + int vscan(char const *fmt0, char* ap); + int vform(char const *fmt0, char* ap); +}; + +struct __file_fields { + char _fake; + char _shortbuf[1]; + short _fileno; + int _blksize; + char* _save_gptr; + char* _save_egptr; + long _offset; +}; + +class filebuf : public streambuf { + struct __file_fields _fb; + void init(); + public: + filebuf(); + filebuf(int fd); + filebuf(int fd, char* p, int len); + ~filebuf(); + filebuf* attach(int fd); + filebuf* open(const char *filename, const char *mode); + filebuf* open(const char *filename, int mode, int prot = 0664); + virtual int underflow(); + virtual int overflow(int c = (-1) ); + int is_open() { return _fb._fileno >= 0; } + int fd() { return is_open() ? _fb._fileno : (-1) ; } + filebuf* close(); + virtual int doallocate(); + virtual streampos seekoff(streamoff, _seek_dir, int mode=ios::in|ios::out); + int sputn(const char* s, int n); + int sgetn(char* s, int n); + protected: // See documentation in filebuf.C. + virtual int pbackfail(int c); + virtual int sync(); + int is_reading() { return eback() != egptr(); } + char* cur_ptr() { return is_reading() ? gptr() : pptr(); } + /* System's idea of pointer */ + char* file_ptr() { return _fb._save_gptr ? _fb._save_egptr : egptr(); } + int do_flush(); + // Low-level operations (Usually invoke system calls.) + virtual int sys_read(char* buf, size_t size); + virtual long sys_seek(long , _seek_dir); + virtual long sys_write(const void*, long); + virtual int sys_stat(void*); // Actually, a (struct stat*) + virtual int sys_close(); +}; + + +inline int ios::readable() { return rdbuf()->_flags & 4 ; } +inline int ios::writable() { return rdbuf()->_flags & 8 ; } +inline int ios::is_open() {return rdbuf()->_flags & 4 +8 ;} + + + + +//# 25 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/iostream.h" 2 + + +class istream; class ostream; +typedef istream& (*__imanip)(istream&); +typedef ostream& (*__omanip)(ostream&); + +extern istream& ws(istream& ins); +extern ostream& flush(ostream& outs); +extern ostream& endl(ostream& outs); +extern ostream& ends(ostream& outs); + +class ostream : public ios +{ + void do_osfx(); + public: + ostream(); + ostream(streambuf* sb, ostream* tied=(__null) ); + ~ostream(); + + int opfx() { if (!good()) return 0; if (_tie) _tie->flush(); return 1; } + void osfx() { if (flags() & (ios::unitbuf|ios::stdio)) + do_osfx(); } + streambuf* ostreambuf() const { return _strbuf; } + ostream& flush(); + ostream& put(char c); + ostream& write(const char *s, int n); + ostream& write(const unsigned char *s, int n) { return write((char*)s, n);} + ostream& write(const void *s, int n) { return write((char*)s, n);} + ostream& seekp(streampos); + ostream& seekp(streamoff, _seek_dir); + streampos tellp(); + ostream& form(const char *format ...); + ostream& vform(const char *format, char* args); +}; + +ostream& operator<<(ostream&, char c); +ostream& operator<<(ostream& os, unsigned char c) { return os << (char)c; } +//ostream& operator<<(ostream &os, signed char c) { return os << (char)c; } +extern ostream& operator<<(ostream&, const char *s); +inline ostream& operator<<(ostream& os, const unsigned char *s) +{ return os << (const char*)s; } +//inline ostream& operator<<(ostream& os, const signed char *s) +//{ return os << (const char*)s; } +ostream& operator<<(ostream&, void *p); +ostream& operator<<(ostream&, int n); +ostream& operator<<(ostream&, long n); +ostream& operator<<(ostream&, unsigned int n); +ostream& operator<<(ostream&, unsigned long n); +ostream& operator<<(ostream& os, short n) {return os << (int)n;} +ostream& operator<<(ostream& os, unsigned short n) +{return os << (unsigned int)n;} +ostream& operator<<(ostream&, float n); +ostream& operator<<(ostream&, double n); +ostream& operator<<(ostream& os, __omanip func) { return (*func)(os); } +ostream& operator<<(ostream&, streambuf*); + +class istream : public ios +{ + size_t _gcount; + public: + istream(); + istream(streambuf* sb, ostream*tied=(__null) ); + ~istream(); + streambuf* istreambuf() const { return _strbuf; } + istream& get(char& c); + istream& get(unsigned char& c); + istream& read(char *ptr, int n); + istream& read(unsigned char *ptr, int n) { return read((char*)ptr, n); } + istream& read(void *ptr, int n) { return read((char*)ptr, n); } + int get() { return _strbuf->sbumpc(); } + istream& getline(char* ptr, int len, char delim = '\n'); + istream& get(char* ptr, int len, char delim = '\n'); + istream& gets(char **s, char delim = '\n'); + int ipfx(int need) { + if (!good()) { set(ios::failbit); return 0; } + if (_tie && (need == 0 || rdbuf()->in_avail())) ; //??? THIS LINE IS QUESTIONABLE */ + if (!need && (flags() & ios::skipws) && !ws(*this)) return 0; + return 1; + } + int ipfx0() { // Optimized version of ipfx(0). + if (!good()) { set(ios::failbit); return 0; } + if (_tie) _tie->flush(); + if ((flags() & ios::skipws) && !ws(*this)) return 0; + return 1; + } + int ipfx1() { // Optimized version of ipfx(1). + if (!good()) { set(ios::failbit); return 0; } + if (_tie && rdbuf()->in_avail() == 0) _tie->flush(); + return 1; + } + size_t gcount() { return _gcount; } + istream& seekg(streampos); + istream& seekg(streamoff, _seek_dir); + streampos tellg(); + istream& putback(char ch) { + if (good() && _strbuf->sputbackc(ch) == (-1) ) clear(ios::badbit); + return *this;} + istream& unget() { + if (good() && _strbuf->sungetc() == (-1) ) clear(ios::badbit); + return *this;} + + istream& unget(char ch) { return putback(ch); } + int skip(int i); + +}; + +istream& operator>>(istream&, char*); +istream& operator>>(istream& is, unsigned char* p) { return is >> (char*)p; } +//istream& operator>>(istream& is, signed char* p) { return is >> (char*)p; } +istream& operator>>(istream&, char& c); +istream& operator>>(istream&, unsigned char& c); +//istream& operator>>(istream&, signed char& c); +istream& operator>>(istream&, int&); +istream& operator>>(istream&, long&); +istream& operator>>(istream&, short&); +istream& operator>>(istream&, unsigned int&); +istream& operator>>(istream&, unsigned long&); +istream& operator>>(istream&, unsigned short&); +istream& operator>>(istream&, float&); +istream& operator>>(istream&, double&); +istream& operator>>(istream& is, __imanip func) { return (*func)(is); } + +class iostream : public ios { + size_t _gcount; + public: + iostream(); + operator istream&() { return *(istream*)this; } + operator ostream&() { return *(ostream*)this; } + ~iostream(); + // NOTE: These duplicate istream methods. + istream& get(char& c) { return ((istream*)this)->get(c); } + istream& get(unsigned char& c) { return ((istream*)this)->get(c); } + istream& read(char *ptr, int n) { return ((istream*)this)->read(ptr, n); } + istream& read(unsigned char *ptr, int n) + { return ((istream*)this)->read((char*)ptr, n); } + istream& read(void *ptr, int n) + { return ((istream*)this)->read((char*)ptr, n); } + int get() { return _strbuf->sbumpc(); } + istream& getline(char* ptr, int len, char delim = '\n') + { return ((istream*)this)->getline(ptr, len, delim); } + istream& get(char* ptr, int len, char delim = '\n') + { return ((istream*)this)->get(ptr, len, delim); } + istream& gets(char **s, char delim = '\n') + { return ((istream*)this)->gets(s, delim); } + int ipfx(int need) { return ((istream*)this)->ipfx(need); } + int ipfx0() { return ((istream*)this)->ipfx0(); } + int ipfx1() { return ((istream*)this)->ipfx1(); } + size_t gcount() { return _gcount; } + istream& putback(char ch) { return ((istream*)this)->putback(ch); } + istream& unget() { return ((istream*)this)->unget(); } + istream& seekg(streampos pos) { return ((istream*)this)->seekg(pos); } + istream& seekg(streamoff off, _seek_dir dir) + { return ((istream*)this)->seekg(off, dir); } + streampos tellg() { return ((istream*)this)->tellg(); } + + istream& unget(char ch) { return putback(ch); } + + + // NOTE: These duplicate ostream methods. + int opfx() { return ((ostream*)this)->opfx(); } + void osfx() { ((ostream*)this)->osfx(); } + ostream& flush() { return ((ostream*)this)->flush(); } + ostream& put(char c) { return ((ostream*)this)->put(c); } + ostream& write(const char *s, int n) + { return ((ostream*)this)->write(s, n); } + ostream& write(const unsigned char *s, int n) + { return ((ostream*)this)->write((char*)s, n); } + ostream& write(const void *s, int n) + { return ((ostream*)this)->write((char*)s, n); } + ostream& form(const char *format ...); + ostream& vform(const char *format, char* args) + { return ((ostream*)this)->vform(format, args); } + ostream& seekp(streampos pos) { return ((ostream*)this)->seekp(pos); } + ostream& seekp(streamoff off, _seek_dir dir) + { return ((ostream*)this)->seekp(off, dir); } + streampos tellp() { return ((ostream*)this)->tellp(); } +}; + +extern istream cin; +extern ostream cout, cerr, clog; // clog->rdbuf() == cerr->rdbuf() + +inline ostream& ostream::put(char c) { _strbuf->sputc(c); return *this; } + +struct Iostream_init { } ; // Compatibility hack for AT&T libraray. + + +//# 7 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/stream.h" 2 + + +extern char* form(char*, ...); + +extern char* dec(long, int=0); +extern char* dec(int, int=0); +extern char* dec(unsigned long, int=0); +extern char* dec(unsigned int, int=0); + +extern char* hex(long, int=0); +extern char* hex(int, int=0); +extern char* hex(unsigned long, int=0); +extern char* hex(unsigned int, int=0); + +extern char* oct(long, int=0); +extern char* oct(int, int=0); +extern char* oct(unsigned long, int=0); +extern char* oct(unsigned int, int=0); + +inline istream& WS(istream& str) { return ws(str); } + + +//# 26 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/String.h" 2 + +//# 1 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/Regex.h" 1 +// This may look like C code, but it is really -*- C++ -*- +/* +Copyright (C) 1988 Free Software Foundation + written by Doug Lea (dl@rocky.oswego.edu) + +This file is part of the GNU C++ Library. This library is free +software; you can redistribute it and/or modify it under the terms of +the GNU Library General Public License as published by the Free +Software Foundation; either version 2 of the License, or (at your +option) any later version. This library is distributed in the hope +that it will be useful, but WITHOUT ANY WARRANTY; without even the +implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU Library General Public License for more details. +You should have received a copy of the GNU Library General Public +License along with this library; if not, write to the Free Software +Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + + + + +//#pragma interface + + + + + + + + + +struct re_pattern_buffer; // defined elsewhere +struct re_registers; + +class Regex +{ +private: + + Regex(const Regex&) {} // no X(X&) + void operator = (const Regex&) {} // no assignment + +protected: + re_pattern_buffer* buf; + re_registers* reg; + +public: + Regex(const char* t, + int fast = 0, + int bufsize = 40, + const char* transtable = 0); + + ~Regex(); + + int match(const char* s, int len, int pos = 0) const; + int search(const char* s, int len, + int& matchlen, int startpos = 0) const; + int match_info(int& start, int& length, int nth = 0) const; + + int OK() const; // representation invariant +}; + +// some built in regular expressions + +extern const Regex RXwhite; // = "[ \n\t\r\v\f]+" +extern const Regex RXint; // = "-?[0-9]+" +extern const Regex RXdouble; // = "-?\\(\\([0-9]+\\.[0-9]*\\)\\| + // \\([0-9]+\\)\\|\\(\\.[0-9]+\\)\\) + // \\([eE][---+]?[0-9]+\\)?" +extern const Regex RXalpha; // = "[A-Za-z]+" +extern const Regex RXlowercase; // = "[a-z]+" +extern const Regex RXuppercase; // = "[A-Z]+" +extern const Regex RXalphanum; // = "[0-9A-Za-z]+" +extern const Regex RXidentifier; // = "[A-Za-z_][A-Za-z0-9_]*" + + + +//# 27 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/String.h" 2 + + +struct StrRep // internal String representations +{ + unsigned short len; // string length + unsigned short sz; // allocated space + char s[1]; // the string starts here + // (at least 1 char for trailing null) + // allocated & expanded via non-public fcts +}; + +// primitive ops on StrReps -- nearly all String fns go through these. + +StrRep* Salloc(StrRep*, const char*, int, int); +StrRep* Scopy(StrRep*, StrRep*); +StrRep* Sresize(StrRep*, int); +StrRep* Scat(StrRep*, const char*, int, const char*, int); +StrRep* Scat(StrRep*, const char*, int,const char*,int, const char*,int); +StrRep* Sprepend(StrRep*, const char*, int); +StrRep* Sreverse(StrRep*, StrRep*); +StrRep* Supcase(StrRep*, StrRep*); +StrRep* Sdowncase(StrRep*, StrRep*); +StrRep* Scapitalize(StrRep*, StrRep*); + +// These classes need to be defined in the order given + +class String; +class SubString; + +class SubString +{ + friend class String; +protected: + + String& S; // The String I'm a substring of + unsigned short pos; // starting position in S's rep + unsigned short len; // length of substring + + void assign(StrRep*, const char*, int = -1); + SubString(String& x, int p, int l); + SubString(const SubString& x); + +public: + +// Note there are no public constructors. SubStrings are always +// created via String operations + + ~SubString(); + + void operator = (const String& y); + void operator = (const SubString& y); + void operator = (const char* t); + void operator = (char c); + +// return 1 if target appears anywhere in SubString; else 0 + + int contains(char c) const; + int contains(const String& y) const; + int contains(const SubString& y) const; + int contains(const char* t) const; + int contains(const Regex& r) const; + +// return 1 if target matches entire SubString + + int matches(const Regex& r) const; + +// IO + + friend ostream& operator<<(ostream& s, const SubString& x); + +// status + + unsigned int length() const; + int empty() const; + const char* chars() const; + + int OK() const; + +}; + + +class String +{ + friend class SubString; + +protected: + StrRep* rep; // Strings are pointers to their representations + +// some helper functions + + int search(int, int, const char*, int = -1) const; + int search(int, int, char) const; + int match(int, int, int, const char*, int = -1) const; + int _gsub(const char*, int, const char* ,int); + int _gsub(const Regex&, const char*, int); + SubString _substr(int, int); + +public: + +// constructors & assignment + + String(); + String(const String& x); + String(const SubString& x); + String(const char* t); + String(const char* t, int len); + String(char c); + + ~String(); + + void operator = (const String& y); + void operator = (const char* y); + void operator = (char c); + void operator = (const SubString& y); + +// concatenation + + void operator += (const String& y); + void operator += (const SubString& y); + void operator += (const char* t); + void operator += (char c); + + void prepend(const String& y); + void prepend(const SubString& y); + void prepend(const char* t); + void prepend(char c); + + +// procedural versions: +// concatenate first 2 args, store result in last arg + + friend void cat(const String&, const String&, String&); + friend void cat(const String&, const SubString&, String&); + friend void cat(const String&, const char*, String&); + friend void cat(const String&, char, String&); + + friend void cat(const SubString&, const String&, String&); + friend void cat(const SubString&, const SubString&, String&); + friend void cat(const SubString&, const char*, String&); + friend void cat(const SubString&, char, String&); + + friend void cat(const char*, const String&, String&); + friend void cat(const char*, const SubString&, String&); + friend void cat(const char*, const char*, String&); + friend void cat(const char*, char, String&); + +// double concatenation, by request. (yes, there are too many versions, +// but if one is supported, then the others should be too...) +// Concatenate first 3 args, store in last arg + + friend void cat(const String&,const String&, const String&,String&); + friend void cat(const String&,const String&,const SubString&,String&); + friend void cat(const String&,const String&, const char*, String&); + friend void cat(const String&,const String&, char, String&); + friend void cat(const String&,const SubString&,const String&,String&); + friend void cat(const String&,const SubString&,const SubString&,String&); + friend void cat(const String&,const SubString&, const char*, String&); + friend void cat(const String&,const SubString&, char, String&); + friend void cat(const String&,const char*, const String&, String&); + friend void cat(const String&,const char*, const SubString&, String&); + friend void cat(const String&,const char*, const char*, String&); + friend void cat(const String&,const char*, char, String&); + + friend void cat(const char*, const String&, const String&,String&); + friend void cat(const char*,const String&,const SubString&,String&); + friend void cat(const char*,const String&, const char*, String&); + friend void cat(const char*,const String&, char, String&); + friend void cat(const char*,const SubString&,const String&,String&); + friend void cat(const char*,const SubString&,const SubString&,String&); + friend void cat(const char*,const SubString&, const char*, String&); + friend void cat(const char*,const SubString&, char, String&); + friend void cat(const char*,const char*, const String&, String&); + friend void cat(const char*,const char*, const SubString&, String&); + friend void cat(const char*,const char*, const char*, String&); + friend void cat(const char*,const char*, char, String&); + + +// searching & matching + +// return position of target in string or -1 for failure + + int index(char c, int startpos = 0) const; + int index(const String& y, int startpos = 0) const; + int index(const SubString& y, int startpos = 0) const; + int index(const char* t, int startpos = 0) const; + int index(const Regex& r, int startpos = 0) const; + +// return 1 if target appears anyhere in String; else 0 + + int contains(char c) const; + int contains(const String& y) const; + int contains(const SubString& y) const; + int contains(const char* t) const; + int contains(const Regex& r) const; + +// return 1 if target appears anywhere after position pos +// (or before, if pos is negative) in String; else 0 + + int contains(char c, int pos) const; + int contains(const String& y, int pos) const; + int contains(const SubString& y, int pos) const; + int contains(const char* t, int pos) const; + int contains(const Regex& r, int pos) const; + +// return 1 if target appears at position pos in String; else 0 + + int matches(char c, int pos = 0) const; + int matches(const String& y, int pos = 0) const; + int matches(const SubString& y, int pos = 0) const; + int matches(const char* t, int pos = 0) const; + int matches(const Regex& r, int pos = 0) const; + +// return number of occurences of target in String + + int freq(char c) const; + int freq(const String& y) const; + int freq(const SubString& y) const; + int freq(const char* t) const; + +// SubString extraction + +// Note that you can't take a substring of a const String, since +// this leaves open the possiblility of indirectly modifying the +// String through the SubString + + SubString at(int pos, int len); + SubString operator () (int pos, int len); // synonym for at + + SubString at(const String& x, int startpos = 0); + SubString at(const SubString& x, int startpos = 0); + SubString at(const char* t, int startpos = 0); + SubString at(char c, int startpos = 0); + SubString at(const Regex& r, int startpos = 0); + + SubString before(int pos); + SubString before(const String& x, int startpos = 0); + SubString before(const SubString& x, int startpos = 0); + SubString before(const char* t, int startpos = 0); + SubString before(char c, int startpos = 0); + SubString before(const Regex& r, int startpos = 0); + + SubString through(int pos); + SubString through(const String& x, int startpos = 0); + SubString through(const SubString& x, int startpos = 0); + SubString through(const char* t, int startpos = 0); + SubString through(char c, int startpos = 0); + SubString through(const Regex& r, int startpos = 0); + + SubString from(int pos); + SubString from(const String& x, int startpos = 0); + SubString from(const SubString& x, int startpos = 0); + SubString from(const char* t, int startpos = 0); + SubString from(char c, int startpos = 0); + SubString from(const Regex& r, int startpos = 0); + + SubString after(int pos); + SubString after(const String& x, int startpos = 0); + SubString after(const SubString& x, int startpos = 0); + SubString after(const char* t, int startpos = 0); + SubString after(char c, int startpos = 0); + SubString after(const Regex& r, int startpos = 0); + + +// deletion + +// delete len chars starting at pos + void del(int pos, int len); + +// delete the first occurrence of target after startpos + + void del(const String& y, int startpos = 0); + void del(const SubString& y, int startpos = 0); + void del(const char* t, int startpos = 0); + void del(char c, int startpos = 0); + void del(const Regex& r, int startpos = 0); + +// global substitution: substitute all occurrences of pat with repl + + int gsub(const String& pat, const String& repl); + int gsub(const SubString& pat, const String& repl); + int gsub(const char* pat, const String& repl); + int gsub(const char* pat, const char* repl); + int gsub(const Regex& pat, const String& repl); + +// friends & utilities + +// split string into array res at separators; return number of elements + + friend int split(const String& x, String res[], int maxn, + const String& sep); + friend int split(const String& x, String res[], int maxn, + const Regex& sep); + + friend String common_prefix(const String& x, const String& y, + int startpos = 0); + friend String common_suffix(const String& x, const String& y, + int startpos = -1); + friend String replicate(char c, int n); + friend String replicate(const String& y, int n); + friend String join(String src[], int n, const String& sep); + +// simple builtin transformations + + friend String reverse(const String& x); + friend String upcase(const String& x); + friend String downcase(const String& x); + friend String capitalize(const String& x); + +// in-place versions of above + + void reverse(); + void upcase(); + void downcase(); + void capitalize(); + +// element extraction + + char& operator [] (int i); + char elem(int i) const; + char firstchar() const; + char lastchar() const; + +// conversion + + operator const char*() const; + const char* chars() const; + + +// IO + + friend ostream& operator<<(ostream& s, const String& x); + friend ostream& operator<<(ostream& s, const SubString& x); + friend istream& operator>>(istream& s, String& x); + + friend int readline(istream& s, String& x, + char terminator = '\n', + int discard_terminator = 1); + +// status + + unsigned int length() const; + int empty() const; + +// preallocate some space for String + void alloc(int newsize); + +// report current allocation (not length!) + + int allocation() const; + + + volatile void error(const char* msg) const; + + int OK() const; +}; + +typedef String StrTmp; // for backward compatibility + +// other externs + +int compare(const String& x, const String& y); +int compare(const String& x, const SubString& y); +int compare(const String& x, const char* y); +int compare(const SubString& x, const String& y); +int compare(const SubString& x, const SubString& y); +int compare(const SubString& x, const char* y); +int fcompare(const String& x, const String& y); // ignore case + +extern StrRep _nilStrRep; +extern String _nilString; + +// other inlines + +String operator + (const String& x, const String& y); +String operator + (const String& x, const SubString& y); +String operator + (const String& x, const char* y); +String operator + (const String& x, char y); +String operator + (const SubString& x, const String& y); +String operator + (const SubString& x, const SubString& y); +String operator + (const SubString& x, const char* y); +String operator + (const SubString& x, char y); +String operator + (const char* x, const String& y); +String operator + (const char* x, const SubString& y); + +int operator==(const String& x, const String& y); +int operator!=(const String& x, const String& y); +int operator> (const String& x, const String& y); +int operator>=(const String& x, const String& y); +int operator< (const String& x, const String& y); +int operator<=(const String& x, const String& y); +int operator==(const String& x, const SubString& y); +int operator!=(const String& x, const SubString& y); +int operator> (const String& x, const SubString& y); +int operator>=(const String& x, const SubString& y); +int operator< (const String& x, const SubString& y); +int operator<=(const String& x, const SubString& y); +int operator==(const String& x, const char* t); +int operator!=(const String& x, const char* t); +int operator> (const String& x, const char* t); +int operator>=(const String& x, const char* t); +int operator< (const String& x, const char* t); +int operator<=(const String& x, const char* t); +int operator==(const SubString& x, const String& y); +int operator!=(const SubString& x, const String& y); +int operator> (const SubString& x, const String& y); +int operator>=(const SubString& x, const String& y); +int operator< (const SubString& x, const String& y); +int operator<=(const SubString& x, const String& y); +int operator==(const SubString& x, const SubString& y); +int operator!=(const SubString& x, const SubString& y); +int operator> (const SubString& x, const SubString& y); +int operator>=(const SubString& x, const SubString& y); +int operator< (const SubString& x, const SubString& y); +int operator<=(const SubString& x, const SubString& y); +int operator==(const SubString& x, const char* t); +int operator!=(const SubString& x, const char* t); +int operator> (const SubString& x, const char* t); +int operator>=(const SubString& x, const char* t); +int operator< (const SubString& x, const char* t); +int operator<=(const SubString& x, const char* t); + + + + +// status reports, needed before defining other things + +inline unsigned int String::length() const { return rep->len; } +inline int String::empty() const { return rep->len == 0; } +inline const char* String::chars() const { return &(rep->s[0]); } +inline int String::allocation() const { return rep->sz; } +inline void String::alloc(int newsize) { rep = Sresize(rep, newsize); } + +inline unsigned int SubString::length() const { return len; } +inline int SubString::empty() const { return len == 0; } +inline const char* SubString::chars() const { return &(S.rep->s[pos]); } + + +// constructors + +inline String::String() + : rep(&_nilStrRep) {} +inline String::String(const String& x) + : rep(Scopy(0, x.rep)) {} +inline String::String(const char* t) + : rep(Salloc(0, t, -1, -1)) {} +inline String::String(const char* t, int tlen) + : rep(Salloc(0, t, tlen, tlen)) {} +inline String::String(const SubString& y) + : rep(Salloc(0, y.chars(), y.length(), y.length())) {} +inline String::String(char c) + : rep(Salloc(0, &c, 1, 1)) {} + +inline String::~String() { if (rep != &_nilStrRep) delete rep; } + +inline SubString::SubString(const SubString& x) + :S(x.S), pos(x.pos), len(x.len) {} +inline SubString::SubString(String& x, int first, int l) + :S(x), pos(first), len(l) {} + +inline SubString::~SubString() {} + +// assignment + +inline void String::operator = (const String& y) +{ + rep = Scopy(rep, y.rep); +} + +inline void String::operator=(const char* t) +{ + rep = Salloc(rep, t, -1, -1); +} + +inline void String::operator=(const SubString& y) +{ + rep = Salloc(rep, y.chars(), y.length(), y.length()); +} + +inline void String::operator=(char c) +{ + rep = Salloc(rep, &c, 1, 1); +} + + +inline void SubString::operator = (const char* ys) +{ + assign(0, ys); +} + +inline void SubString::operator = (char ch) +{ + assign(0, &ch, 1); +} + +inline void SubString::operator = (const String& y) +{ + assign(y.rep, y.chars(), y.length()); +} + +inline void SubString::operator = (const SubString& y) +{ + assign(y.S.rep, y.chars(), y.length()); +} + +// Zillions of cats... + +inline void cat(const String& x, const String& y, String& r) +{ + r.rep = Scat(r.rep, x.chars(), x.length(), y.chars(), y.length()); +} + +inline void cat(const String& x, const SubString& y, String& r) +{ + r.rep = Scat(r.rep, x.chars(), x.length(), y.chars(), y.length()); +} + +inline void cat(const String& x, const char* y, String& r) +{ + r.rep = Scat(r.rep, x.chars(), x.length(), y, -1); +} + +inline void cat(const String& x, char y, String& r) +{ + r.rep = Scat(r.rep, x.chars(), x.length(), &y, 1); +} + +inline void cat(const SubString& x, const String& y, String& r) +{ + r.rep = Scat(r.rep, x.chars(), x.length(), y.chars(), y.length()); +} + +inline void cat(const SubString& x, const SubString& y, String& r) +{ + r.rep = Scat(r.rep, x.chars(), x.length(), y.chars(), y.length()); +} + +inline void cat(const SubString& x, const char* y, String& r) +{ + r.rep = Scat(r.rep, x.chars(), x.length(), y, -1); +} + +inline void cat(const SubString& x, char y, String& r) +{ + r.rep = Scat(r.rep, x.chars(), x.length(), &y, 1); +} + +inline void cat(const char* x, const String& y, String& r) +{ + r.rep = Scat(r.rep, x, -1, y.chars(), y.length()); +} + +inline void cat(const char* x, const SubString& y, String& r) +{ + r.rep = Scat(r.rep, x, -1, y.chars(), y.length()); +} + +inline void cat(const char* x, const char* y, String& r) +{ + r.rep = Scat(r.rep, x, -1, y, -1); +} + +inline void cat(const char* x, char y, String& r) +{ + r.rep = Scat(r.rep, x, -1, &y, 1); +} + +inline void cat(const String& a, const String& x, const String& y, String& r) +{ + r.rep = Scat(r.rep, a.chars(), a.length(), x.chars(), x.length(), y.chars(), y.length()); +} + +inline void cat(const String& a, const String& x, const SubString& y, String& r) +{ + r.rep = Scat(r.rep, a.chars(), a.length(), x.chars(), x.length(), y.chars(), y.length()); +} + +inline void cat(const String& a, const String& x, const char* y, String& r) +{ + r.rep = Scat(r.rep, a.chars(), a.length(), x.chars(), x.length(), y, -1); +} + +inline void cat(const String& a, const String& x, char y, String& r) +{ + r.rep = Scat(r.rep, a.chars(), a.length(), x.chars(), x.length(), &y, 1); +} + +inline void cat(const String& a, const SubString& x, const String& y, String& r) +{ + r.rep = Scat(r.rep, a.chars(), a.length(), x.chars(), x.length(), y.chars(), y.length()); +} + +inline void cat(const String& a, const SubString& x, const SubString& y, String& r) +{ + r.rep = Scat(r.rep, a.chars(), a.length(), x.chars(), x.length(), y.chars(), y.length()); +} + +inline void cat(const String& a, const SubString& x, const char* y, String& r) +{ + r.rep = Scat(r.rep, a.chars(), a.length(), x.chars(), x.length(), y, -1); +} + +inline void cat(const String& a, const SubString& x, char y, String& r) +{ + r.rep = Scat(r.rep, a.chars(), a.length(), x.chars(), x.length(), &y, 1); +} + +inline void cat(const String& a, const char* x, const String& y, String& r) +{ + r.rep = Scat(r.rep, a.chars(), a.length(), x, -1, y.chars(), y.length()); +} + +inline void cat(const String& a, const char* x, const SubString& y, String& r) +{ + r.rep = Scat(r.rep, a.chars(), a.length(), x, -1, y.chars(), y.length()); +} + +inline void cat(const String& a, const char* x, const char* y, String& r) +{ + r.rep = Scat(r.rep, a.chars(), a.length(), x, -1, y, -1); +} + +inline void cat(const String& a, const char* x, char y, String& r) +{ + r.rep = Scat(r.rep, a.chars(), a.length(), x, -1, &y, 1); +} + + +inline void cat(const char* a, const String& x, const String& y, String& r) +{ + r.rep = Scat(r.rep, a, -1, x.chars(), x.length(), y.chars(), y.length()); +} + +inline void cat(const char* a, const String& x, const SubString& y, String& r) +{ + r.rep = Scat(r.rep, a, -1, x.chars(), x.length(), y.chars(), y.length()); +} + +inline void cat(const char* a, const String& x, const char* y, String& r) +{ + r.rep = Scat(r.rep, a, -1, x.chars(), x.length(), y, -1); +} + +inline void cat(const char* a, const String& x, char y, String& r) +{ + r.rep = Scat(r.rep, a, -1, x.chars(), x.length(), &y, 1); +} + +inline void cat(const char* a, const SubString& x, const String& y, String& r) +{ + r.rep = Scat(r.rep, a, -1, x.chars(), x.length(), y.chars(), y.length()); +} + +inline void cat(const char* a, const SubString& x, const SubString& y, String& r) +{ + r.rep = Scat(r.rep, a, -1, x.chars(), x.length(), y.chars(), y.length()); +} + +inline void cat(const char* a, const SubString& x, const char* y, String& r) +{ + r.rep = Scat(r.rep, a, -1, x.chars(), x.length(), y, -1); +} + +inline void cat(const char* a, const SubString& x, char y, String& r) +{ + r.rep = Scat(r.rep, a, -1, x.chars(), x.length(), &y, 1); +} + +inline void cat(const char* a, const char* x, const String& y, String& r) +{ + r.rep = Scat(r.rep, a, -1, x, -1, y.chars(), y.length()); +} + +inline void cat(const char* a, const char* x, const SubString& y, String& r) +{ + r.rep = Scat(r.rep, a, -1, x, -1, y.chars(), y.length()); +} + +inline void cat(const char* a, const char* x, const char* y, String& r) +{ + r.rep = Scat(r.rep, a, -1, x, -1, y, -1); +} + +inline void cat(const char* a, const char* x, char y, String& r) +{ + r.rep = Scat(r.rep, a, -1, x, -1, &y, 1); +} + + +// operator versions + +inline void String::operator +=(const String& y) +{ + cat(*this, y, *this); +} + +inline void String::operator +=(const SubString& y) +{ + cat(*this, y, *this); +} + +inline void String::operator += (const char* y) +{ + cat(*this, y, *this); +} + +inline void String:: operator +=(char y) +{ + cat(*this, y, *this); +} + +// constructive concatenation + + + +inline String operator + (const String& x, const String& y) return r; // { dg-error "" } +{ + cat(x, y, r); // { dg-error "" } +} + +inline String operator + (const String& x, const SubString& y) return r; // { dg-error "" } +{ + cat(x, y, r); // { dg-error "" } +} + +inline String operator + (const String& x, const char* y) return r; // { dg-error "" } +{ + cat(x, y, r); // { dg-error "" } +} + +inline String operator + (const String& x, char y) return r; // { dg-error "" } +{ + cat(x, y, r); // { dg-error "" } +} + +inline String operator + (const SubString& x, const String& y) return r; // { dg-error "" } +{ + cat(x, y, r); // { dg-error "" } +} + +inline String operator + (const SubString& x, const SubString& y) return r; // { dg-error "" } +{ + cat(x, y, r); // { dg-error "" } +} + +inline String operator + (const SubString& x, const char* y) return r; // { dg-error "" } +{ + cat(x, y, r); // { dg-error "" } +} + +inline String operator + (const SubString& x, char y) return r; // { dg-error "" } +{ + cat(x, y, r); // { dg-error "" } +} + +inline String operator + (const char* x, const String& y) return r; // { dg-error "" } +{ + cat(x, y, r); // { dg-error "" } +} + +inline String operator + (const char* x, const SubString& y) return r; // { dg-error "" } +{ + cat(x, y, r); // { dg-error "" } +} + +inline String reverse(const String& x) return r; // { dg-error "" } +{ + r.rep = Sreverse(x.rep, r.rep); // { dg-error "" } +} + +inline String upcase(const String& x) return r; // { dg-error "" } +{ + r.rep = Supcase(x.rep, r.rep); // { dg-error "" } +} + +inline String downcase(const String& x) return r; // { dg-error "" } +{ + r.rep = Sdowncase(x.rep, r.rep); // { dg-error "" } +} + +inline String capitalize(const String& x) return r; // { dg-error "" } +{ + r.rep = Scapitalize(x.rep, r.rep); // { dg-error "" } +} + +//# 883 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/String.h" + + +// prepend + +inline void String::prepend(const String& y) +{ + rep = Sprepend(rep, y.chars(), y.length()); +} + +inline void String::prepend(const char* y) +{ + rep = Sprepend(rep, y, -1); +} + +inline void String::prepend(char y) +{ + rep = Sprepend(rep, &y, 1); +} + +inline void String::prepend(const SubString& y) +{ + rep = Sprepend(rep, y.chars(), y.length()); +} + +// misc transformations + + +inline void String::reverse() +{ + rep = Sreverse(rep, rep); +} + + +inline void String::upcase() +{ + rep = Supcase(rep, rep); +} + + +inline void String::downcase() +{ + rep = Sdowncase(rep, rep); +} + + +inline void String::capitalize() +{ + rep = Scapitalize(rep, rep); +} + +// element extraction + +inline char& String::operator [] (int i) +{ + if (((unsigned)i) >= length()) error("invalid index"); + return rep->s[i]; +} + +inline char String::elem (int i) const +{ + if (((unsigned)i) >= length()) error("invalid index"); + return rep->s[i]; +} + +inline char String::firstchar() const +{ + return elem(0); +} + +inline char String::lastchar() const +{ + return elem(length() - 1); +} + +// searching + +inline int String::index(char c, int startpos) const +{ + return search(startpos, length(), c); +} + +inline int String::index(const char* t, int startpos) const +{ + return search(startpos, length(), t); +} + +inline int String::index(const String& y, int startpos) const +{ + return search(startpos, length(), y.chars(), y.length()); +} + +inline int String::index(const SubString& y, int startpos) const +{ + return search(startpos, length(), y.chars(), y.length()); +} + +inline int String::index(const Regex& r, int startpos) const +{ + int unused; return r.search(chars(), length(), unused, startpos); +} + +inline int String::contains(char c) const +{ + return search(0, length(), c) >= 0; +} + +inline int String::contains(const char* t) const +{ + return search(0, length(), t) >= 0; +} + +inline int String::contains(const String& y) const +{ + return search(0, length(), y.chars(), y.length()) >= 0; +} + +inline int String::contains(const SubString& y) const +{ + return search(0, length(), y.chars(), y.length()) >= 0; +} + +inline int String::contains(char c, int p) const +{ + return match(p, length(), 0, &c, 1) >= 0; +} + +inline int String::contains(const char* t, int p) const +{ + return match(p, length(), 0, t) >= 0; +} + +inline int String::contains(const String& y, int p) const +{ + return match(p, length(), 0, y.chars(), y.length()) >= 0; +} + +inline int String::contains(const SubString& y, int p) const +{ + return match(p, length(), 0, y.chars(), y.length()) >= 0; +} + +inline int String::contains(const Regex& r) const +{ + int unused; return r.search(chars(), length(), unused, 0) >= 0; +} + +inline int String::contains(const Regex& r, int p) const +{ + return r.match(chars(), length(), p) >= 0; +} + + +inline int String::matches(const SubString& y, int p) const +{ + return match(p, length(), 1, y.chars(), y.length()) >= 0; +} + +inline int String::matches(const String& y, int p) const +{ + return match(p, length(), 1, y.chars(), y.length()) >= 0; +} + +inline int String::matches(const char* t, int p) const +{ + return match(p, length(), 1, t) >= 0; +} + +inline int String::matches(char c, int p) const +{ + return match(p, length(), 1, &c, 1) >= 0; +} + +inline int String::matches(const Regex& r, int p) const +{ + int l = (p < 0)? -p : length() - p; + return r.match(chars(), length(), p) == l; +} + + +inline int SubString::contains(const char* t) const +{ + return S.search(pos, pos+len, t) >= 0; +} + +inline int SubString::contains(const String& y) const +{ + return S.search(pos, pos+len, y.chars(), y.length()) >= 0; +} + +inline int SubString::contains(const SubString& y) const +{ + return S.search(pos, pos+len, y.chars(), y.length()) >= 0; +} + +inline int SubString::contains(char c) const +{ + return S.search(pos, pos+len, 0, c) >= 0; +} + +inline int SubString::contains(const Regex& r) const +{ + int unused; return r.search(chars(), len, unused, 0) >= 0; +} + +inline int SubString::matches(const Regex& r) const +{ + return r.match(chars(), len, 0) == len; +} + + +inline int String::gsub(const String& pat, const String& r) +{ + return _gsub(pat.chars(), pat.length(), r.chars(), r.length()); +} + +inline int String::gsub(const SubString& pat, const String& r) +{ + return _gsub(pat.chars(), pat.length(), r.chars(), r.length()); +} + +inline int String::gsub(const Regex& pat, const String& r) +{ + return _gsub(pat, r.chars(), r.length()); +} + +inline int String::gsub(const char* pat, const String& r) +{ + return _gsub(pat, -1, r.chars(), r.length()); +} + +inline int String::gsub(const char* pat, const char* r) +{ + return _gsub(pat, -1, r, -1); +} + + + +inline ostream& operator<<(ostream& s, const String& x) +{ + s << x.chars(); return s; +} + +// a zillion comparison operators + +inline int operator==(const String& x, const String& y) +{ + return compare(x, y) == 0; +} + +inline int operator!=(const String& x, const String& y) +{ + return compare(x, y) != 0; +} + +inline int operator>(const String& x, const String& y) +{ + return compare(x, y) > 0; +} + +inline int operator>=(const String& x, const String& y) +{ + return compare(x, y) >= 0; +} + +inline int operator<(const String& x, const String& y) +{ + return compare(x, y) < 0; +} + +inline int operator<=(const String& x, const String& y) +{ + return compare(x, y) <= 0; +} + +inline int operator==(const String& x, const SubString& y) +{ + return compare(x, y) == 0; +} + +inline int operator!=(const String& x, const SubString& y) +{ + return compare(x, y) != 0; +} + +inline int operator>(const String& x, const SubString& y) +{ + return compare(x, y) > 0; +} + +inline int operator>=(const String& x, const SubString& y) +{ + return compare(x, y) >= 0; +} + +inline int operator<(const String& x, const SubString& y) +{ + return compare(x, y) < 0; +} + +inline int operator<=(const String& x, const SubString& y) +{ + return compare(x, y) <= 0; +} + +inline int operator==(const String& x, const char* t) +{ + return compare(x, t) == 0; +} + +inline int operator!=(const String& x, const char* t) +{ + return compare(x, t) != 0; +} + +inline int operator>(const String& x, const char* t) +{ + return compare(x, t) > 0; +} + +inline int operator>=(const String& x, const char* t) +{ + return compare(x, t) >= 0; +} + +inline int operator<(const String& x, const char* t) +{ + return compare(x, t) < 0; +} + +inline int operator<=(const String& x, const char* t) +{ + return compare(x, t) <= 0; +} + +inline int operator==(const SubString& x, const String& y) +{ + return compare(y, x) == 0; +} + +inline int operator!=(const SubString& x, const String& y) +{ + return compare(y, x) != 0; +} + +inline int operator>(const SubString& x, const String& y) +{ + return compare(y, x) < 0; +} + +inline int operator>=(const SubString& x, const String& y) +{ + return compare(y, x) <= 0; +} + +inline int operator<(const SubString& x, const String& y) +{ + return compare(y, x) > 0; +} + +inline int operator<=(const SubString& x, const String& y) +{ + return compare(y, x) >= 0; +} + +inline int operator==(const SubString& x, const SubString& y) +{ + return compare(x, y) == 0; +} + +inline int operator!=(const SubString& x, const SubString& y) +{ + return compare(x, y) != 0; +} + +inline int operator>(const SubString& x, const SubString& y) +{ + return compare(x, y) > 0; +} + +inline int operator>=(const SubString& x, const SubString& y) +{ + return compare(x, y) >= 0; +} + +inline int operator<(const SubString& x, const SubString& y) +{ + return compare(x, y) < 0; +} + +inline int operator<=(const SubString& x, const SubString& y) +{ + return compare(x, y) <= 0; +} + +inline int operator==(const SubString& x, const char* t) +{ + return compare(x, t) == 0; +} + +inline int operator!=(const SubString& x, const char* t) +{ + return compare(x, t) != 0; +} + +inline int operator>(const SubString& x, const char* t) +{ + return compare(x, t) > 0; +} + +inline int operator>=(const SubString& x, const char* t) +{ + return compare(x, t) >= 0; +} + +inline int operator<(const SubString& x, const char* t) +{ + return compare(x, t) < 0; +} + +inline int operator<=(const SubString& x, const char* t) +{ + return compare(x, t) <= 0; +} + + +// a helper needed by at, before, etc. + +inline SubString String::_substr(int first, int l) +{ + if (first >= length() ) // ??? THIS LINE IS QUESTIONABLE + return SubString(_nilString, 0, 0) ; + else + return SubString(*this, first, l); +} + + + + + +//# 26 "../../GctSymbol.h" 2 + + +//# 1 "../../../../../../mips/include/Gct/Object/GctHashObject.h" 1 +// -*- C++ -*- + + + +// +// GctHashObject class (is abstract) +// +// Expects to be included by Object.h or where needed explicitly. +// +// Wendell Baker, Berkeley CAD Group, 1992 (wbaker@ic.Berkeley.EDU) +// + + + + + +//#pragma interface + + + +//# 1 "../../../../../../mips/include/Gct/Object/GctObject.h" 1 +// -*- C++ -*- + + + +// +// GctObject class (is abstract) +// +// Expects to be included by Object.h or where needed explicitly. +// +// Wendell Baker, Berkeley CAD Group, 1992 (wbaker@ic.Berkeley.EDU) +// + + + + + +//#pragma interface + + + +//# 1 "/sandbox/wbaker/wbaker0/source/mips/include/tostrstream.h" 1 +// -*- C++ -*- + + + +// +// tostrstream class +// +// A terminated oststream - an ostsrstream that auto-terminates on str() +// +// Wendell Baker, Berkeley CAD Group, 1992 (wbaker@ic.Berkeley.EDU) +// + + + + + +//#pragma interface + + + +//# 1 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/strstream.h" 1 +// This is part of the iostream library, providing input/output for C++. +// Copyright (C) 1991 Per Bothner. +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Library General Public +// License as published by the Free Software Foundation; either +// version 2 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Library General Public License for more details. +// +// You should have received a copy of the GNU Library General Public +// License along with this library; if not, write to the Free +// Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + + + + +//#pragma interface + +//# 1 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/iostream.h" 1 +// This is part of the iostream library, providing -*- C++ -*- input/output. +// Copyright (C) 1991 Per Bothner. +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Library General Public +// License as published by the Free Software Foundation; either +// version 2 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Library General Public License for more details. +// +// You should have received a copy of the GNU Library General Public +// License along with this library; if not, write to the Free +// Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +//# 210 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/iostream.h" + +//# 23 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/strstream.h" 2 + + +class strstreambuf : public streambuf { + size_t *lenp; /* current (logical) length (i.e. valid data bytes) */ + size_t *sizep; /* allocated (physical) buffer size */ + char **bufp; + size_t _len; + size_t _size; + char *buf; + int _frozen; + protected: + virtual int overflow(int = (-1) ); + public: + strstreambuf(); + strstreambuf(int initial); + strstreambuf(char *ptr, int size, char *pstart = (__null) ); + ~strstreambuf(); + int frozen() { return _frozen; } + void freeze(int n=1) { _frozen = n != 0; } + size_t pcount(); + char *str(); +}; + +class istrstream : public istream { + public: + istrstream(char*); + istrstream(char*, int); + strstreambuf* rdbuf() { return (strstreambuf*)_strbuf; } +}; + +class ostrstream : public ostream { + public: + ostrstream(); + ostrstream(char *cp, int n, int mode=ios::out); + size_t pcount() { return ((strstreambuf*)_strbuf)->pcount(); } + char *str() { return ((strstreambuf*)_strbuf)->str(); } + void freeze(int n = 1) { ((strstreambuf*)_strbuf)->freeze(n); } + int frozen() { return ((strstreambuf*)_strbuf)->frozen(); } + strstreambuf* rdbuf() { return (strstreambuf*)_strbuf; } +}; + + +//# 25 "/sandbox/wbaker/wbaker0/source/mips/include/tostrstream.h" 2 + + +// +// tostrstream class +// +// An isteam class that doesn't have that nasty skipws parameter that +// you have to remember to set. This class simply provides the istream +// functionality with a set of constructors which defaults skipws to +// FALSE (instead of defaulting to TRUE as is the case with plain istream). +// +class tostrstream: public ostrstream { +public: + tostrstream(): ostrstream() + { } + // This constructor defines cp as the buffer to use for the + // stream (instead of one of its own devising); it does NOT + // initialize the ostrstream to contain cp (of length n). + tostrstream(char *cp, int n, int mode=ios::out): ostrtream(cp, n, mode) // { dg-error "" } + { } + char *str() + { + char *s = ostrstream::str(); + s[ostrstream::pcount()] = '\0'; + return s; + } +}; + + +//# 25 "../../../../../../mips/include/Gct/Object/GctObject.h" 2 + + +//# 1 "/sandbox/wbaker/wbaker0/source/mips/include/Gtt/GttObject.h" 1 +// -*- C++ -*- + + + +// +// GttObject class (is abstract) +// +// Expects to be included where needed explicitly. +// +// Wendell Baker, Berkeley CAD Group, 1992 (wbaker@ic.Berkeley.EDU) +// + + + + + +//#pragma interface + + + +//# 1 "/sandbox/wbaker/wbaker0/source/mips/include/tostrstream.h" 1 +// -*- C++ -*- +//# 52 "/sandbox/wbaker/wbaker0/source/mips/include/tostrstream.h" + +//# 25 "/sandbox/wbaker/wbaker0/source/mips/include/Gtt/GttObject.h" 2 + + +//# 1 "/sandbox/wbaker/wbaker0/source/mips/include/Gtt/GttErrorHandler.h" 1 +// -*- C++ -*- + + + +// +// GttErrorHandler class +// +// Expects to be included by Gtt.h +// +// Wendell Baker, Berkeley CAD Group, 1992 (wbaker@ic.Berkeley.EDU) +// + + + + + +//#pragma interface + + + +//# 1 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/bool.h" 1 + + + + + + + +//# 25 "/sandbox/wbaker/wbaker0/source/mips/include/Gtt/GttErrorHandler.h" 2 + + +//# 1 "/sandbox/wbaker/wbaker0/source/mips/include/stuff++.h" 1 +// -*- C++ -*- + + + +// +// Fake up a libstuff++ +// +// This is done as a complete and utter hack; this library has no function +// at all being in the boot area; it is here solely in order to provide a +// libstuff++ against which the Makefiles can resolve link lines. +// +// The only reason that this is done is to allow the STANDARD_C++_LIBRARIES +// as provided by the Makefile templates in the boot area to be the same +// ones that are used by the tools outside this hierarchy. +// +// The tools outside this hierarchy use a different libstuff++; one that is +// written in C++. This one is not written in C++ in order to be simpler. +// + + + + + +//#pragma interface + + + +extern "C" { +//# 1 "/sandbox/wbaker/wbaker0/source/mips/include/stuff.h" 1 + + + +/* + * Useful stuff + */ + +/* + */ + +//# 1 "/sandbox/wbaker/wbaker0/source/mips/include/ansi.h" 1 + + + + +/* + * ANSI Compiler Support + * + * David Harrison + * University of California, Berkeley + * 1988 + * + * ANSI compatible compilers are supposed to define the preprocessor + * directive __STDC__. Based on this directive, this file defines + * certain ANSI specific macros. + * + * ARGS: + * Used in function prototypes. Example: + * extern int foo + * ARGS((char *blah, double threshold)); + */ + +/* + * + * Modifications + * Wendell C Baker + * University of California, Berkeley + */ + +/* Function prototypes */ + + + + + + + + + + + + + + + + + + + + + + + + + + + +//# 15 "/sandbox/wbaker/wbaker0/source/mips/include/stuff.h" 2 + + + +/* + * If g++, then we stub out part of this thing and let the C++ types take + * over and do the same job; some compatibility must be given however + */ + +/* + * Use the GNU libg++ definition + */ +//# 1 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/bool.h" 1 + + + + + + + +//# 26 "/sandbox/wbaker/wbaker0/source/mips/include/stuff.h" 2 + +//# 35 "/sandbox/wbaker/wbaker0/source/mips/include/stuff.h" + + +/* + * Make various pieces of C code that use the old ``Boolean'' + * be compatible by faking up the definition of Boolean using + * the new bool type. + */ + + +//# 58 "/sandbox/wbaker/wbaker0/source/mips/include/stuff.h" + + +typedef long FitAny; /* can fit any integral type */ + +/* + * typedef char *String; - DO NOT USE THIS - it conflicts with C++ + * typedef char **Stringv; - just use char* and char** instead. + * - void* can be used for arbitrary pointers + */ + + + + +extern int nocase_strcmp (char *, char *) ; +extern int nocase_strncmp (char *, char *, int) ; + +extern bool nocase_strequal (char *, char *) ; +extern bool nocase_strnequal (char *, char *, int) ; + +extern bool lead_strequal (char *, char *) ; +extern bool nocase_lead_strequal (char *, char *) ; + +extern int strhash (char *, int) ; +extern int nocase_strhash (char *, int) ; + +extern int sign (int) ; + +/* + * Some useful macros. + */ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +//# 33 "/sandbox/wbaker/wbaker0/source/mips/include/stuff++.h" 2 + +} + +// +// This is here because we wish to provide externs for the two +// functions btoa(bool, unsigned = 0) and operator<<(ostream&, bool) +// because they are not provided in bool.h. +// +//# 1 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/bool.h" 1 + + + + + + + +//# 41 "/sandbox/wbaker/wbaker0/source/mips/include/stuff++.h" 2 + +extern const char *stringify(bool b); +//# 1 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/iostream.h" 1 +// This is part of the iostream library, providing -*- C++ -*- input/output. +// Copyright (C) 1991 Per Bothner. +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Library General Public +// License as published by the Free Software Foundation; either +// version 2 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Library General Public License for more details. +// +// You should have received a copy of the GNU Library General Public +// License along with this library; if not, write to the Free +// Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +//# 210 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/iostream.h" + +//# 43 "/sandbox/wbaker/wbaker0/source/mips/include/stuff++.h" 2 + +extern ostream& operator<<(ostream&, bool); + +// Should this be kept separate? bool isn't, but then is +// included here only to define ostream& operator<<(ostream&, bool) +//# 1 "/sandbox/wbaker/wbaker0/source/mips/include/unit.h" 1 +// -*- C++ -*- + + + +// +// unit enum +// +// Wendell Baker, Berkeley CAD Group, 1991 (wbaker@ic.Berkeley.EDU) +// + + +// +// unit enum +// +// This _looks_ silly, but it has an important theoretical basis in category +// theory. For the pragmatic reason for its existence, see the example below. +// +enum unit { + UNIT = 1, +}; + +extern const char *stringify(unit u); + +//# 1 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/iostream.h" 1 +// This is part of the iostream library, providing -*- C++ -*- input/output. +// Copyright (C) 1991 Per Bothner. +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Library General Public +// License as published by the Free Software Foundation; either +// version 2 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Library General Public License for more details. +// +// You should have received a copy of the GNU Library General Public +// License along with this library; if not, write to the Free +// Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +//# 210 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/iostream.h" + +//# 28 "/sandbox/wbaker/wbaker0/source/mips/include/unit.h" 2 + +extern ostream& operator<<(ostream&, unit); + +// +// A unit is used in cases where the type signature of an overloaded +// function must be differentiated in some stronger way than can be +// denoted unambiguously in the C++ syntax. This enum is used to give +// one of the functions a different type signature, thereby allowing +// the overloading. +// +// The use of ``unit'' instead of int or bool is important because a unit +// has only one possible value; therefore it adds no more information to +// the code. For example, say a bool was used instead, then in the testing +// phase, would have to ask: what if TRUE was given, what if FALSE was given. +// The problem is compounded if char or int is used. +// +// Example: +// +// class ID { +// public: +// ID(); // construct a null ID +// ID(unit); // alloc a ID with a new id +// private: +// static unsigned high_water; +// unsigned id; +// }; +// +// Try working this example save that ID implements all of the generic +// features of the identifier object, but the high_water is stored +// in the heir. That is what originally motivated the creation of unit. +// + + +//# 48 "/sandbox/wbaker/wbaker0/source/mips/include/stuff++.h" 2 + + +// +// In the spirit of the standard GNU error handler functions +// as described in +// typedef void (*one_arg_error_handler_t)(const char*); +// a one argument error handler function pointer +// typedef void (*two_arg_error_handler_t)(const char*, const char*); +// a two argument error handler function pointer +// +// And now the NEW +// +// typedef void (*zero_arg_error_handler_t)(); +// a zero argument error handler function pointer +// +typedef void (*zero_arg_error_handler_t)(); + +// +// In the spirit of the default GNU error handler functions +// as described in +// extern void default_one_arg_error_handler(const char *message); +// print out message on stderr, and do the default thing (abort) +// extern void default_two_arg_error_handler(const char *kind, const char *message); +// print out kind and message on stderr, and do the default thing (abort) +// +// And now the NEW +// +// extern void default_zero_arg_error_handler(const char *message); +// do the default thing (abort) +// +extern void default_zero_arg_error_handler(); + +// Guaranteed to exit (1) +extern void exit_zero_arg_error_handler(); +extern void exit_one_arg_error_handler(const char *message); +extern void exit_two_arg_error_handler(const char *kind, const char *message); + +// Guaranteed to abort() +extern void abort_zero_arg_error_handler(); +extern void abort_one_arg_error_handler(const char *message); +extern void abort_two_arg_error_handler(const char *kind, const char *message); + +// +// In the spirit of the standard GNU error handlers +// as described in +// extern void verbose_File_error_handler(const char*); +// perror and set errno = 0 +// extern void quiet_File_error_handler(const char*); +// set errno = 0 +// extern void fatal_File_error_handler(const char*); +// perror and exit 1 +// +// And now the NEW +// +// extern void preserve_File_error_handler(const char *message); +// no perror, no assignment to errno. +// +extern void preserve_File_error_handler(const char *message); + + +//# 27 "/sandbox/wbaker/wbaker0/source/mips/include/Gtt/GttErrorHandler.h" 2 + +//# 1 "/sandbox/wbaker/wbaker0/source/mips/include/tostrstream.h" 1 +// -*- C++ -*- +//# 52 "/sandbox/wbaker/wbaker0/source/mips/include/tostrstream.h" + +//# 28 "/sandbox/wbaker/wbaker0/source/mips/include/Gtt/GttErrorHandler.h" 2 + + +// +// It is expected that this will be virtually multiply inherited +// into all of the classes that need error reporting services. +// +// The typical way to have that done is by inheriting the GttObject +// as a virtual base class. +// + +// +// GttErrorHandler class +// +class GttErrorHandler { +public: + GttErrorHandler(); + GttErrorHandler(const char *program); + virtual ~GttErrorHandler(); + + // + // Error messages + // - an unacceptable, but expected and recoverable condition + // was detected (but the test fails) + // - errors are for ``the expected environment was not found'' + // rather than for ``file couldn't be opened'' + // - these messages cannot be shut off + // - the error handler determines the recovery action + // TODO - one day exceptions will be used here + // + static void error(const char *message); + static void error(tostrstream& message); + + static void error(const char *function, const char *message); + static void error(const char *function, tostrstream& message); + + static void error(const char *class_name, const char *method, const char *message); + static void error(const char *class_name, const char *method, tostrstream& message); + + // + // Fatal messages + // - an unacceptable and unexpected error was detected + // the data invariants were violated, there is no recovery + // - these messages cannot be shut off + // - the error handler determines the recovery action + // TODO - one day exceptions will be used here + // + static void fatal(const char *message); + static void fatal(tostrstream& message); + + static void fatal(const char *function, const char *message); + static void fatal(const char *function, tostrstream& message); + + static void fatal(const char *class_name, const char *method, const char *message); + static void fatal(const char *class_name, const char *method, tostrstream& message); +private: + // + // Two underscores are used here in order to prevent confusion of these + // private variables with any of the heir's private variables. Note that + // access control is different than visibility in C++, so all the variable + // names in a class hierarchy must be unique. + // + + static bool __partial_init; + static void __partial_initialize(); + static bool __full_init; + static void __full_initialize(const char *program); + static char *__program; + + static void __handle_error(); + static void __handle_fatal(); + static void __add_newline(const char *message); + + static bool __output_valid(); + static ostream *__output; +}; + + +//# 27 "/sandbox/wbaker/wbaker0/source/mips/include/Gtt/GttObject.h" 2 + + +// +// GttObject class (is abstract) +// +class GttObject: virtual public GttErrorHandler { +protected: + GttObject(); + GttObject(const GttObject&); + virtual ~GttObject(); // ensure descendants have virtual destructors + +public: + // + // I/O Support + // + // The value typically persists only long enough for an i/o operation + // to be performed (see the defintion of output via operator<<(... ) below) + virtual const char *stringify(); +protected: + // This is the buffer into which the printed representation of this + // object will be put when the time comes. It is associated with the + // object so it will never go away (so long as the object exists). + // Use a pointer so that you only pay for the space when I/O is used + tostrstream *stringbuf; + void clear_stringbuf(); + +public: + // + // Consistency + // + // The global data invariant for the whole object (heirs included). + // This OK function will call the local invariant function ok() if + // necessary and in addition the OK functions of the heirs + // This is expected to compute the data invariant of the object. + // It will execute GctErrorHandler::fatal if there is wrong. + virtual void OK() const; + +protected: + // + // consistency + // + // This function computes the invariant which is local to this object. + // It does not call any of the ancestor's OK() or ok() functions. + // It is not a virtual function so that it can be called from within a + // constructor with impunity. Thus this function MUST NOT call any + // virtual functions either; it should call them by their full name if + // that is necessary. The global OK() function will call this function + // as necessary. + // + // This function must NOT NEVER EVER be made virtual. + void ok() const; + +protected: + // + // Class Name + // + // This must return a static (constant) string which is the name + // of the class being declared. By convention, not all classes + // must have one of these, but the major root abstract class must + // have one in order to allow the stringify() to work approximately + // correctly. + virtual const char *class_name() const = 0; +}; + +//# 1 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/iostream.h" 1 +// This is part of the iostream library, providing -*- C++ -*- input/output. +// Copyright (C) 1991 Per Bothner. +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Library General Public +// License as published by the Free Software Foundation; either +// version 2 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Library General Public License for more details. +// +// You should have received a copy of the GNU Library General Public +// License along with this library; if not, write to the Free +// Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +//# 210 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/iostream.h" + +//# 91 "/sandbox/wbaker/wbaker0/source/mips/include/Gtt/GttObject.h" 2 + +extern ostream& operator<<(ostream&, GttObject&); + +// There may be other X& operator<<(X&, GttObject&) defined in the +// packages defining class X. For example see the definition of +// GttUnitObject& operator<<(GttUnitObject&, GttObject&) in Unit. + + +//# 27 "../../../../../../mips/include/Gct/Object/GctObject.h" 2 + + +//# 1 "../../../../../../mips/include/Gct/GctErrorHandler.h" 1 +// -*- C++ -*- + + + +// +// GctErrorHandler class +// +// Expects to be included by Gct.h +// +// Wendell Baker, Berkeley CAD Group, 1991 (wbaker@ic.Berkeley.EDU) +// + + + + + +//#pragma interface + + + +//# 1 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/bool.h" 1 + + + + + + + +//# 25 "../../../../../../mips/include/Gct/GctErrorHandler.h" 2 + +//# 1 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/String.h" 1 +// This may look like C code, but it is really -*- C++ -*- +/* +Copyright (C) 1988 Free Software Foundation + written by Doug Lea (dl@rocky.oswego.edu) + +This file is part of the GNU C++ Library. This library is free +software; you can redistribute it and/or modify it under the terms of +the GNU Library General Public License as published by the Free +Software Foundation; either version 2 of the License, or (at your +option) any later version. This library is distributed in the hope +that it will be useful, but WITHOUT ANY WARRANTY; without even the +implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU Library General Public License for more details. +You should have received a copy of the GNU Library General Public +License along with this library; if not, write to the Free Software +Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + + +//# 1321 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/String.h" + +//# 26 "../../../../../../mips/include/Gct/GctErrorHandler.h" 2 + +//# 1 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/iostream.h" 1 +// This is part of the iostream library, providing -*- C++ -*- input/output. +// Copyright (C) 1991 Per Bothner. +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Library General Public +// License as published by the Free Software Foundation; either +// version 2 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Library General Public License for more details. +// +// You should have received a copy of the GNU Library General Public +// License along with this library; if not, write to the Free +// Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +//# 210 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/iostream.h" + +//# 27 "../../../../../../mips/include/Gct/GctErrorHandler.h" 2 + + +//# 1 "/sandbox/wbaker/wbaker0/source/mips/include/stuff++.h" 1 +// -*- C++ -*- +//# 107 "/sandbox/wbaker/wbaker0/source/mips/include/stuff++.h" + +//# 29 "../../../../../../mips/include/Gct/GctErrorHandler.h" 2 + +//# 1 "/sandbox/wbaker/wbaker0/source/mips/include/tostrstream.h" 1 +// -*- C++ -*- +//# 52 "/sandbox/wbaker/wbaker0/source/mips/include/tostrstream.h" + +//# 30 "../../../../../../mips/include/Gct/GctErrorHandler.h" 2 + + +//# 1 "/sandbox/wbaker/wbaker0/source/mips/include/Gtt/GttObject.h" 1 +// -*- C++ -*- +//# 98 "/sandbox/wbaker/wbaker0/source/mips/include/Gtt/GttObject.h" + +//# 32 "../../../../../../mips/include/Gct/GctErrorHandler.h" 2 + + +// +// It is expected that this will be virtually multiply inherited +// into all of the classes that need error reporting services. +// +// The typical way to have that done is by inheriting the GctObject +// as a virtual base class. +// + +// +// GctErrorHandler class +// +// GPP_1_96_BUG +// NOTE - virtual public GttObject should be MI into GctObject - but that +// causes g++ 1.96 to segfault; so we must inherit GttObject here and use SI +// GPP_1_96_BUG +class GctErrorHandler: virtual public GttObject { +public: + GctErrorHandler(); + GctErrorHandler(const String& program); + virtual ~GctErrorHandler(); + + // + // Debugging messages + // - these are turned off for production code. + // - these messages can be shut off + // + static void debug(const char *message); + static void debug(tostrstream& message); + + static void debug(const char *function, const char *message); + static void debug(const char *function, tostrstream& message); + + static void debug(const char *class_name, const char *method, const char *message); + static void debug(const char *class_name, const char *method, tostrstream& message); + + static bool debug(); // current debug switch + static void debug(bool value); // change the debug switch + + // + // Informational messages + // - these correspond to a ``verbose'' mode + // - these are not errors, just chatty progress reports + // - these messages can be shut off + // + static void note(const char *message); + static void note(tostrstream& message); + + static void note(const char *function, const char *message); + static void note(const char *function, tostrstream& message); + + static void note(const char *class_name, const char *method, const char *message); + static void note(const char *class_name, const char *method, tostrstream& message); + + static bool note(); // current note switch + static void note(bool value); // change the note switch + + // + // Warning messages + // - warnings are system-recoverable errors + // - the system has noticed something and taken some + // corrective action + // - these messages can be shut off + // + static void warning(const char *message); + static void warning(tostrstream& message); + + static void warning(const char *function, const char *message); + static void warning(const char *function, tostrstream& message); + + static void warning(const char *class_name, const char *method, const char *message); + static void warning(const char *class_name, const char *method, tostrstream& message); + + static bool warning(); // current warning switch + static void warning(bool value); // change the warning switch + + // + // Error messages + // - an unacceptable, but expected and recoverable + // condition was detected + // - errors are for ``the expected environment was not found'' + // rather than for ``file couldn't be opened'' + // - these messages cannot be shut off + // - the error handler determines the recovery action + // TODO - one day exceptions will be used here + // + static void error(const char *message); + static void error(tostrstream& message); + + static void error(const char *function, const char *message); + static void error(const char *function, tostrstream& message); + + static void error(const char *class_name, const char *method, const char *message); + static void error(const char *class_name, const char *method, tostrstream& message); + + // can't turn off errors - no ``static void error(bool value);'' + static zero_arg_error_handler_t error(); // current error handler + static void error(zero_arg_error_handler_t handler);// change the error handler + + static void error_is_lib_error_handler(); // change the error handler + static void error_is_exit(); // change the error handler + + // Describes the fatal handler - WATCHOUT - implicitly uses AllocRing + static const char *error_handler_description(); + + // + // Fatal messages + // - an unacceptable and unexpected error was detected + // the data invariants were violated, there is no recovery + // - these messages cannot be shut off + // - the error handler determines the recovery action + // TODO - one day exceptions will be used here + // + static void fatal(const char *message); + static void fatal(tostrstream& message); + + static void fatal(const char *function, const char *message); + static void fatal(const char *function, tostrstream& message); + + static void fatal(const char *class_name, const char *method, const char *message); + static void fatal(const char *class_name, const char *method, tostrstream& message); + + // can't turn off fatals - no ``static void fatal(bool value);'' + static zero_arg_error_handler_t fatal(); // return the fatal handler + static void fatal(zero_arg_error_handler_t handler); // change the fatal handler + + static void fatal_is_exit(); // change the fatal handler + static void fatal_is_abort(); // change the fatal handler + + // Describes the fatal handler - WATCHOUT - implicitly uses AllocRing + static const char *fatal_handler_description(); +private: + // + // Two underscores are used here in order to prevent confusion of these + // private variables with any of the heir's private variables. Note that + // access control is different than visibility in C++, so all the variable + // names in a class hierarchy must be unique. + // + static bool __debug; + static bool __note; + static bool __warning; + static void (*__error_handler)(); // can't turn off errors + static void (*__fatal_handler)(); // can't turn off fatals + + static bool __partial_init; + static void __partial_initialize(); + static bool __full_init; + static void __full_initialize(const char *program); + static char *__program; + + static void __handle_error(); + static void __handle_fatal(); + static void __add_newline(const char *message); + static void __message_switch(bool value, bool& flag, const char *description); + static void __message_switch(bool value, bool& flag); + static const char *__describe_handler(zero_arg_error_handler_t handler); + + static bool __output_valid(); + static ostream *__output; + + // GPP_1_96_BUG + const char *class_name() const; + // GPP_1_96_BUG +}; + + +//# 29 "../../../../../../mips/include/Gct/Object/GctObject.h" 2 + + +// +// GctObject class (is abstract) +// +class GctObject: virtual public GctErrorHandler /*, virtual public GttObject*/ { +protected: + GctObject(); + GctObject(const GctObject&); + virtual ~GctObject(); // ensure descendants have virtual destructors + +public: + // + // I/O Support + // + // The value typically persists only long enough for an i/o operation + // to be performed (see the defintion of output via operator<<(... ) below) + virtual const char *stringify(); +protected: + // This is the buffer into which the printed representation of this + // object will be put when the time comes. It is associated with the + // object so it will never go away (so long as the object exists). + // Use a pointer so that you only pay for the space when I/O is used + tostrstream *stringbuf; + void clear_stringbuf(); + +public: + // + // Consistency (global consistency) + // + // The global data invariant for the whole object (heirs included). + // This OK function will call the local invariant function ok() if + // necessary and in addition the OK functions of the heirs + // This is expected to compute the data invariant of the object. + // It will execute GctErrorHandler::fatal if there is wrong. + virtual void OK() const; + +protected: + // + // consistency (local consistency) + // + // This function computes the invariant which is local to this object. + // It does not call any of the ancestor's OK() or ok() functions. + // It is not a virtual function so that it can be called from within a + // constructor with impunity. Thus this function MUST NOT call any + // virtual functions either; it should call them by their full name if + // that is necessary. The global OK() function will call this function + // as necessary. + // + // This function must NOT NEVER EVER be made virtual. + void ok() const; +protected: + // + // Class Name + // + // This must return a static (constant) string which is the name + // of the class being declared. By convention, not all classes + // must have one of these, but the major root abstract class must + // have one in order to allow the stringify() to work approximately + // correctly. + virtual const char *class_name() const = 0; + +public: + // + // The ``id'' of this object + // + // NOTE - we explicitly allow the situation where this function + // can return the address of the object - the ``this'' pointer + // instead of a computed id field (the __object_id field below). + // + // This function is protected because we don't want too much dependence + // on this notion of object identity. I want to be able to rip it + // out if it becomes to cumbersome. + unsigned objectId() const; +private: + // + // Symbolic ID + // + // NOTE - Normally this would be implemented by the `this' pointer. + // TODO - remove this for production code + // + // However, in order to make the test suites run on all machines, we + // make this into a symbolic id that is maintained with each object. + // Thus the valid outputs are always consistent across all machines. + unsigned __object_id; + static unsigned __next_id; +}; + +//# 1 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/iostream.h" 1 +// This is part of the iostream library, providing -*- C++ -*- input/output. +// Copyright (C) 1991 Per Bothner. +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Library General Public +// License as published by the Free Software Foundation; either +// version 2 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Library General Public License for more details. +// +// You should have received a copy of the GNU Library General Public +// License along with this library; if not, write to the Free +// Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +//# 210 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/iostream.h" + +//# 117 "../../../../../../mips/include/Gct/Object/GctObject.h" 2 + +extern ostream& operator<<(ostream&, GctObject&); + + +//# 25 "../../../../../../mips/include/Gct/Object/GctHashObject.h" 2 + + +// +// GctHashObject class (is abstract) +// +class GctHashObject: virtual public GctObject { +protected: + GctHashObject(); + GctHashObject(const GctHashObject&); + +public: + // + // hash support + // + virtual unsigned hash() const; +}; + + +//# 28 "../../GctSymbol.h" 2 + + +// +// GctSymbol +// +class GctSymbol: virtual public GctHashObject, String { +public: + GctSymbol(); // vacuous symbol required for genclass usage + GctSymbol(const char*); + GctSymbol(const String&); + GctSymbol(const GctSymbol&); + + operator const char *() const; + + bool operator==(const GctSymbol&) const; + bool operator!=(const GctSymbol&) const; + + bool operator<=(const GctSymbol&) const; + bool operator<(const GctSymbol&) const; + bool operator>=(const GctSymbol&) const; + bool operator>(const GctSymbol&) const; + + unsigned hash() const; + + // I/O Support + const char *stringify(); + + // Consistency + void OK() const; +private: + const char *class_name() const; +}; + +extern unsigned hash(GctSymbol&); // genclass support (no const) + +// +// Inline functions +// +// Note - none of the String operators save for operator const char *() +// are String member functions, instead, they are anonymous functions +// which work by overloading. +// + + + + + +GctSymbol::operator const char *() const +{ + + + + + + return String::operator const char *(); +} + +bool +GctSymbol::operator==(const GctSymbol& other) const +{ + + + + + + return (bool)::operator==(*this, other); +} + +bool +GctSymbol::operator!=(const GctSymbol& other) const +{ + + + + + + return (bool)::operator!=(*this, other); +} + +bool +GctSymbol::operator<=(const GctSymbol& other) const +{ + + + + + + return (bool)::operator<=(*this, other); +} + +bool +GctSymbol::operator<(const GctSymbol& other) const +{ + + + + + + return (bool)::operator<(*this, other); +} + +bool +GctSymbol::operator>=(const GctSymbol& other) const +{ + + + + + + return (bool)::operator>=(*this, other); +} + +bool +GctSymbol::operator>(const GctSymbol& other) const +{ + + + + + + return (bool)::operator>(*this, other); +} + + +//# 25 "GctSymbol.defs.h" 2 + + +// equality operator + + + + +// less-than-or-equal + + + + +// comparison : less-than -> 0 + + + + +// hash function + +extern unsigned int hash(GctSymbol&); + + + +// initial capacity for structures requiring one + + + + + + + +//# 27 "GctSymbol.GctSymbol.Map.h" 2 + + +class GctSymbolGctSymbolMap +{ +protected: + int count; + GctSymbol def; + +public: + GctSymbolGctSymbolMap(GctSymbol& dflt); + virtual ~GctSymbolGctSymbolMap(); + + int length(); // current number of items + int empty(); + + virtual int contains(GctSymbol& key); // is key mapped? + + virtual void clear(); // delete all items + + virtual GctSymbol& operator [] (GctSymbol& key) = 0; // access contents by key + + virtual void del(GctSymbol& key) = 0; // delete entry + + virtual Pix first() = 0; // Pix of first item or 0 + virtual void next(Pix& i) = 0; // advance to next or 0 + virtual GctSymbol& key(Pix i) = 0; // access key at i + virtual GctSymbol& contents(Pix i) = 0; // access contents at i + + virtual int owns(Pix i); // is i a valid Pix ? + virtual Pix seek(GctSymbol& key); // Pix of key + + GctSymbol& dflt(); // access default val + + void error(const char* msg); + virtual int OK() = 0; // rep invariant +}; + + + +inline GctSymbolGctSymbolMap::~GctSymbolGctSymbolMap() {} + +inline int GctSymbolGctSymbolMap::length() +{ + return count; +} + +inline int GctSymbolGctSymbolMap::empty() +{ + return count == 0; +} + +inline GctSymbol& GctSymbolGctSymbolMap::dflt() +{ + return def; +} + +inline GctSymbolGctSymbolMap::GctSymbolGctSymbolMap(GctSymbol& dflt) :def(dflt) +{ + count = 0; +} + + + + +//# 26 "GctSymbol.GctSymbol.CHMap.h" 2 + + + + + +struct GctSymbolGctSymbolCHNode +{ + GctSymbolGctSymbolCHNode* tl; + GctSymbol hd; + GctSymbol cont; + GctSymbolGctSymbolCHNode(); + GctSymbolGctSymbolCHNode(GctSymbol& h, GctSymbol& c, GctSymbolGctSymbolCHNode* t = 0); + ~GctSymbolGctSymbolCHNode(); +}; + + + +inline GctSymbolGctSymbolCHNode::GctSymbolGctSymbolCHNode() {} + +inline GctSymbolGctSymbolCHNode::GctSymbolGctSymbolCHNode(GctSymbol& h, GctSymbol& c, GctSymbolGctSymbolCHNode* t) + : hd(h), cont(c), tl(t) {} + +inline GctSymbolGctSymbolCHNode::~GctSymbolGctSymbolCHNode() {} + + + + +typedef GctSymbolGctSymbolCHNode* GctSymbolGctSymbolCHNodePtr; + + + + +class GctSymbolGctSymbolCHMap : public GctSymbolGctSymbolMap +{ +protected: + GctSymbolGctSymbolCHNode** tab; + unsigned int size; + +public: + GctSymbolGctSymbolCHMap(GctSymbol& dflt,unsigned int sz=100 ); + GctSymbolGctSymbolCHMap(GctSymbolGctSymbolCHMap& a); + ~GctSymbolGctSymbolCHMap(); + + GctSymbol& operator [] (GctSymbol& key); + + void del(GctSymbol& key); + + Pix first(); + void next(Pix& i); + GctSymbol& key(Pix i); + GctSymbol& contents(Pix i); + + Pix seek(GctSymbol& key); + int contains(GctSymbol& key); + + void clear(); + int OK(); +}; + + + +inline GctSymbolGctSymbolCHMap::~GctSymbolGctSymbolCHMap() +{ + clear(); + delete tab; +} + +inline int GctSymbolGctSymbolCHMap::contains(GctSymbol& key) +{ + return seek(key) != 0; +} + +inline GctSymbol& GctSymbolGctSymbolCHMap::key(Pix p) +{ + if (p == 0) error("null Pix"); + return ((GctSymbolGctSymbolCHNode*)p)->hd; +} + +inline GctSymbol& GctSymbolGctSymbolCHMap::contents(Pix p) +{ + if (p == 0) error("null Pix"); + return ((GctSymbolGctSymbolCHNode*)p)->cont; +} + + + + +//# 22 "GctSymbol.GctSymbol.CHMap.cc" 2 + + +// The nodes are linked together serially via a version +// of a trick used in some vtables: odd pointers are +// actually links to the next table entry. +// Not terrible, but not wonderful either + +static inline int goodCHptr(GctSymbolGctSymbolCHNode* t) +{ + return ((((unsigned)t) & 1) == 0); +} + +static inline GctSymbolGctSymbolCHNode* index_to_CHptr(int i) +{ + return (GctSymbolGctSymbolCHNode*)((i << 1) + 1); +} + +static inline int CHptr_to_index(GctSymbolGctSymbolCHNode* t) +{ + return ( ((unsigned) t) >> 1); +} + +GctSymbolGctSymbolCHMap::GctSymbolGctSymbolCHMap(GctSymbol& dflt, unsigned int sz) + :GctSymbolGctSymbolMap(dflt) +{ + tab = (GctSymbolGctSymbolCHNode**)(new GctSymbolGctSymbolCHNodePtr[size = sz]); + for (unsigned int i = 0; i < size; ++i) tab[i] = index_to_CHptr(i+1); + count = 0; +} + +GctSymbolGctSymbolCHMap::GctSymbolGctSymbolCHMap(GctSymbolGctSymbolCHMap& a) :GctSymbolGctSymbolMap(a.def) +{ + tab = (GctSymbolGctSymbolCHNode**)(new GctSymbolGctSymbolCHNodePtr[size = a.size]); + for (unsigned int i = 0; i < size; ++i) tab[i] = index_to_CHptr(i+1); + count = 0; + for (Pix p = a.first(); p; a.next(p)) (*this)[a.key(p)] = a.contents(p); // { dg-bogus "" } type `GctSymbol' is derived from private `String' +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p786.C b/gcc/testsuite/g++.old-deja/g++.mike/p786.C new file mode 100644 index 000000000..ebe89c6ab --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p786.C @@ -0,0 +1,36 @@ +// { dg-do run } +// prms-id: 786 + +extern "C" int printf (const char *, ...); +extern "C" void exit(int); +class C + { + int a; +public: + C() {a = 1;} + }; + +void func(const C& a, C& b) +{ + printf ("in const func\n"); + exit(1); +} + +void func(C& a, C& b) +{ + printf ("in non-const func\n"); +} + +void testit(const C& a, C& b) +{ + func(a,b); +} + +int main() +{ + C a; + C b; + + func(a,b); + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p7865.C b/gcc/testsuite/g++.old-deja/g++.mike/p7865.C new file mode 100644 index 000000000..8727e1554 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p7865.C @@ -0,0 +1,29 @@ +// { dg-do run } +// prms-id: 7865 + +int count; + +struct A { + A() { ++count; } + ~A() { --count; } +}; + +int foo() { return 1; } + +int bar() +{ + A a; + for (;;) { + A b; + if (foo()) + return 0; + if (foo()) + return 0; + } + return 0; +} + +int main() { + bar(); + return count; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p7868.C b/gcc/testsuite/g++.old-deja/g++.mike/p7868.C new file mode 100644 index 000000000..48bdf8b25 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p7868.C @@ -0,0 +1,21 @@ +// { dg-do assemble } +// prms-id: 7868 + +struct DIAGTYP { +}; +struct DIAGTYP1 { + struct DIAGTYP; // { dg-error "" } forward declaration + void bar() { new struct DIAGTYP; } // { dg-error "" } undefined + void foo() { new struct DIAGTYP1; } +}; + +int main () { + struct DIAGTYP; // { dg-error "" } forward declaration + struct DIAGTYP *lerror_desc; + lerror_desc= new struct DIAGTYP; // { dg-error "" } undefined +} + +void foo () { + struct DIAGTYP *lerror_desc; + lerror_desc= new struct DIAGTYP; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p789.C b/gcc/testsuite/g++.old-deja/g++.mike/p789.C new file mode 100644 index 000000000..24dbf6e71 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p789.C @@ -0,0 +1,29 @@ +// { dg-do run } +// prms-id: 789 + +extern "C" int printf (const char *, ...); +struct foo +{ + static int count; + virtual void print (int i, int j) { printf ("foo[%d][%d] = %d\n", i, j, x); } + int x; + foo () { x = count++; } +}; +int foo::count; +struct bar : virtual public foo +{ + virtual void print (int i, int j) { printf ("bar[%d][%d] = %d\n", i, j, x); } +}; + +// bar array[3][3]; +foo array[3][3]; + +int main () +{ + for (int i = 0; i < 3; i++) + for (int j = 0; j < 3; j++) { +// printf("&a[%d][%d] = %x\n", i, j, (void *)&array[i][j]); + array[i][j].print (i, j); + } + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p789a.C b/gcc/testsuite/g++.old-deja/g++.mike/p789a.C new file mode 100644 index 000000000..bee0228bb --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p789a.C @@ -0,0 +1,44 @@ +// { dg-do run } +// global and local multidimensional array objects are not getting +// constructors called on any dimension, other than the first. Also, +// the destructors are not being called. Seems odd, they probably +// used to work. :-( +// prms-id: 789 + +extern "C" int printf (const char *, ...); +struct foo +{ + static int count; + void print (int i, int j) { printf ("foo[%d][%d] = %d\n", i, j, x); } + int x; + foo () { + x = count++; + printf("this %d = %x\n", x, (void *)this); + } + virtual ~foo () { + printf("this %d = %x\n", x, (void *)this); + --count; + } +}; +int foo::count; + + +int main () +{ + { + foo array[3][3]; + for (int i = 0; i < 3; i++) + { + for (int j = 0; j < 3; j++) + { + printf("&a[%d][%d] = %x\n", i, j, (void *)&array[i][j]); + } + } + // The count should be nine, if not, fail the test. + if (foo::count != 9) + return 1; + } + if (foo::count != 0) + return 1; + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p7912.C b/gcc/testsuite/g++.old-deja/g++.mike/p7912.C new file mode 100644 index 000000000..e5584ec4c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p7912.C @@ -0,0 +1,23 @@ +// { dg-do run { xfail sparc64-*-elf arm-*-pe } } +// { dg-options "-fexceptions" } +// prms-id: 7912 + +int count = 0; + +class Foo { +public: + Foo() { ++count; }; + Foo(const Foo&) { ++count; }; + ~Foo() { --count; }; +}; + + +main() +{ + try { + throw Foo(); + } + catch (Foo object) { + } + return count; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p8009.C b/gcc/testsuite/g++.old-deja/g++.mike/p8009.C new file mode 100644 index 000000000..b082d650d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p8009.C @@ -0,0 +1,13 @@ +// { dg-do assemble } +// prms-id: 8009 + +class A { +public: + int i; +}; + +class B : public A { + B(); +}; + +B::B() : i (-1) {} // { dg-error "" } diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p8018.C b/gcc/testsuite/g++.old-deja/g++.mike/p8018.C new file mode 100644 index 000000000..f085b6e82 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p8018.C @@ -0,0 +1,86 @@ +// { dg-do run } +// prms-id: 8018 + +class RefCount { +private: + int nref; + +public: + RefCount() : nref(0) {} + ~RefCount() {} + + int nrefs() const { return nref; } + int reference() { + nref++; + return nref; + } + int unreference() { + nref--; + return nref; + } +}; + +class A : public RefCount { +public: + A() {} + ~A() {} +}; + +class RefA { +private: + A *p; + + void clear() { + if (p) { + p->unreference(); + if (!p->nrefs()) + delete p; + } + } + +public: + RefA(A* a) : p(a) { if (p) p->reference(); } + RefA(const RefA& a) : p(a.p) { if (p) p->reference(); } + ~RefA() { clear(); } + + A* operator->() { return p; } + + RefA& operator=(const RefA& a) { + clear(); + p=a.p; + if (p) + p->reference(); + return *this; + } + + RefA& operator=(A* a) { + clear(); + p=a; + if (p) + p->reference(); + return *this; + } +}; + +class AccRefA { +private: + RefA a; + +public: + AccRefA(A* ap) : a(ap) {} + AccRefA(const RefA& ar) : a(ar) {} + ~AccRefA() {} + + operator RefA&() { return a; } + RefA& result() { return a; } +}; + +int +main() { + RefA a1 = new A; + AccRefA aa1(a1); + RefA a3 = aa1; + + if (a1->nrefs() != 3) + return 1; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p8039.C b/gcc/testsuite/g++.old-deja/g++.mike/p8039.C new file mode 100644 index 000000000..4dfb556ea --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p8039.C @@ -0,0 +1,15 @@ +// { dg-do assemble } +// prms-id: 8039 + +class C { +public: + int func (); +}; + +extern void bar(int*); + +int main() +{ + int (C::*mfp)() = &C::func; + bar((int*)mfp); // { dg-error "" } no clear semantics +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p807.C b/gcc/testsuite/g++.old-deja/g++.mike/p807.C new file mode 100644 index 000000000..7b343a50f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p807.C @@ -0,0 +1,35 @@ +// { dg-do assemble } +// prms-id: 807 + +extern "C" int printf(const char*, ...); + +class B; + +class AX +{ + protected: + int x; + + public: + operator B(); +}; + + +class B +{ + private: + int x; + public: + B(const AX&); +}; + + +int foo(B& b); // { dg-error "" } referenced below + + +int main() +{ + AX a; + foo(a); // { dg-error "" } Ambiguous B(a) or a.operator B() // See ARM 12.3.2 + +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p807a.C b/gcc/testsuite/g++.old-deja/g++.mike/p807a.C new file mode 100644 index 000000000..04c9c4867 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p807a.C @@ -0,0 +1,22 @@ +// { dg-do assemble } +// prms-id: 807 + +// See ARM page 275 Section 12.3.2 + +extern "C" int printf (const char *, ...); +extern "C" void exit(int); + +class B; + +class A { +public: + A(B&); // { dg-message "note" } fn ref in err msg +}; + +class B { +public: + operator A(); // { dg-message "note" } fn ref in err msg +}; + +B b; // { dg-message "candidate" } +A a = b; // { dg-error "ambiguous" } should fail as it is ambigious. diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p811.C b/gcc/testsuite/g++.old-deja/g++.mike/p811.C new file mode 100644 index 000000000..260c6459c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p811.C @@ -0,0 +1,549 @@ +// { dg-do assemble } +// { dg-options "" } +// This test case caused the compiler to abort at one point in time. +// prms-id: 811 + +class ostream; class streambuf; + +typedef long streamoff, streampos; + +struct _ios_fields { + streambuf *_strbuf; + ostream* _tie; + int _width; + unsigned long _flags; + char _fill; + unsigned char _state; + unsigned short _precision; +}; + + +enum state_value { _good = 0, _eof = 1, _fail = 2, _bad = 4 }; +enum open_mode { input=1, output=2, append=8 }; + + +class ios : public _ios_fields { + public: + enum io_state { goodbit=0, eofbit=1, failbit=2, badbit=4 }; + enum open_mode { + in=1, + out=2, + ate=4, + app=8, + trunc=16, + nocreate=32, + noreplace=64 }; + enum seek_dir { beg, cur, end}; + enum { skipws=01, left=02, right=04, internal=010, + dec=020, oct=040, hex=0100, + showbase=0200, showpoint=0400, uppercase=01000, showpos=02000, + scientific=04000, fixed=0100000, unitbuf=020000, stdio=040000, + dont_close=0x80000000 + }; + + ostream* tie() const { return _tie; } + ostream* tie(ostream* val) { ostream* save=_tie; _tie=val; return save; } + + + char fill() const { return _fill; } + char fill(char newf) { char oldf = _fill; _fill = newf; return oldf; } + unsigned long flags() const { return _flags; } + unsigned long flags(unsigned long new_val) { + unsigned long old_val = _flags; _flags = new_val; return old_val; } + unsigned short precision() const { return _precision; } + unsigned short precision(int newp) { + unsigned short oldp = _precision; _precision = (unsigned short)newp; + return oldp; } + unsigned long setf(unsigned long val) { + unsigned long oldbits = _flags; + _flags |= val; return oldbits; } + unsigned long setf(unsigned long val, unsigned long mask) { + unsigned long oldbits = _flags; + _flags = (_flags & ~mask) | (val & mask); return oldbits; } + unsigned long unsetf(unsigned long mask) { + unsigned long oldbits = _flags & mask; + _flags &= ~mask; return oldbits; } + int width() const { return _width; } + int width(long val) { long save = _width; _width = val; return save; } + + static const unsigned long basefield; + static const unsigned long adjustfield; + static const unsigned long floatfield; + + streambuf* rdbuf() const { return _strbuf; } + void clear(int state = 0) { _state = state; } + int good() const { return _state == 0; } + int eof() const { return _state & ios::eofbit; } + int fail() const { return _state & (ios::badbit|ios::failbit); } + int bad() const { return _state & ios::badbit; } + int rdstate() const { return _state; } + void set(int flag) { _state |= flag; } + operator void*() const { return fail() ? (void*)0 : (void*)this; } + int operator!() const { return fail(); } + + + void unset(state_value flag) { _state &= ~flag; } + void close(); + int is_open(); + int readable(); + int writable(); + + + protected: + ios(streambuf*sb) { _strbuf=sb; _state=0; _width=0; _fill=' '; + _flags=ios::skipws; _precision=6; } +}; + + + + +typedef ios::seek_dir _seek_dir; + + + + + + + + + + + + + + + + + + + + + + +//# 168 "/usr/latest/lib/g++-include/streambuf.h" 3 + + +struct __streambuf { + + int _flags; + char* _gptr; + char* _egptr; + char* _eback; + char* _pbase; + char* _pptr; + char* _epptr; + char* _base; + char* _ebuf; + struct streambuf *_chain; + + + + +}; + +struct streambuf : private __streambuf { + friend class ios; + friend class istream; + friend class ostream; + protected: + static streambuf* _list_all; + streambuf*& xchain() { return _chain; } + void _un_link(); + void _link_in(); + char* gptr() const { return _gptr; } + char* pptr() const { return _pptr; } + char* egptr() const { return _egptr; } + char* epptr() const { return _epptr; } + char* pbase() const { return _pbase; } + char* eback() const { return _eback; } + char* ebuf() const { return _ebuf; } + char* base() const { return _base; } + void xput_char(char c) { *_pptr++ = c; } + int xflags() { return _flags; } + int xflags(int f) { int fl = _flags; _flags = f; return fl; } + void xsetflags(int f) { _flags |= f; } + void gbump(int n) { _gptr += n; } + void pbump(int n) { _pptr += n; } + void setb(char* b, char* eb, int a=0); + void setp(char* p, char* ep) { _pbase=_pptr=p; _epptr=ep; } + void setg(char* eb, char* g, char *eg) { _eback=eb; _gptr=g; _egptr=eg; } + public: + static int flush_all(); + static void flush_all_linebuffered(); + virtual int underflow(); + virtual int overflow(int c = (-1) ); + virtual int doallocate(); + virtual streampos seekoff(streamoff, _seek_dir, int mode=ios::in|ios::out); + virtual streampos seekpos(streampos pos, int mode = ios::in|ios::out); + int sputbackc(char c); + int sungetc(); + streambuf(); + virtual ~streambuf(); + int unbuffered() { return _flags & 2 ? 1 : 0; } + int linebuffered() { return _flags & 0x4000 ? 1 : 0; } + void unbuffered(int i) + { if (i) _flags |= 2 ; else _flags &= ~2 ; } + void linebuffered(int i) + { if (i) _flags |= 0x4000 ; else _flags &= ~0x4000 ; } + int allocate() { + if (base() || unbuffered()) return 0; + else return doallocate(); } + virtual int sync(); + virtual int pbackfail(int c); + virtual int ungetfail(); + virtual streambuf* setbuf(char* p, int len); + int in_avail() { return _egptr - _gptr; } + int out_waiting() { return _pptr - _pbase; } + virtual int sputn(const char* s, int n); + virtual int sgetn(char* s, int n); + long sgetline(char* buf, int n, char delim, int putback_delim); + int sbumpc() { + if (_gptr >= _egptr && underflow() == (-1) ) return (-1) ; + else return *(unsigned char*)_gptr++; } + int sgetc() { + if (_gptr >= _egptr && underflow() == (-1) ) return (-1) ; + else return *(unsigned char*)_gptr; } + int snextc() { + if (++_gptr >= _egptr && underflow() == (-1) ) return (-1) ; + else return *(unsigned char*)_gptr; } + int sputc(int c) { + if (_pptr >= _epptr) return overflow(c); + return *_pptr++ = c, (unsigned char)c; } + int vscan(char const *fmt0, char* ap); + int vform(char const *fmt0, char* ap); + + + + + + +}; + +struct __file_fields { + char _fake; + char _shortbuf[1]; + short _fileno; + int _blksize; + char* _save_gptr; + char* _save_egptr; + long _offset; +}; + +class filebuf : public streambuf { + struct __file_fields _fb; + void init(); + public: + filebuf(); + filebuf(int fd); + filebuf(int fd, char* p, int len); + ~filebuf(); + filebuf* attach(int fd); + filebuf* open(const char *filename, const char *mode); + filebuf* open(const char *filename, int mode, int prot = 0664); + virtual int underflow(); + virtual int overflow(int c = (-1) ); + int is_open() { return _fb._fileno >= 0; } + int fd() { return is_open() ? _fb._fileno : (-1) ; } + filebuf* close(); + virtual int doallocate(); + virtual streampos seekoff(streamoff, _seek_dir, int mode=ios::in|ios::out); + int sputn(const char* s, int n); + int sgetn(char* s, int n); + virtual int sync(); + protected: + virtual int pbackfail(int c); + int is_reading() { return eback() != egptr(); } + char* cur_ptr() { return is_reading() ? gptr() : pptr(); } + + char* file_ptr() { return _fb._save_gptr ? _fb._save_egptr : egptr(); } + int do_flush(); + + virtual int sys_read(char* buf, int size); + virtual long sys_seek(long , _seek_dir); + virtual long sys_write(const void*, long); + virtual int sys_stat(void*); + virtual int sys_close(); +}; + + +inline int ios::readable() { return rdbuf()->_flags & 4 ; } +inline int ios::writable() { return rdbuf()->_flags & 8 ; } +inline int ios::is_open() {return rdbuf()->_flags & 4 +8 ;} + + + + +//# 25 "/usr/latest/lib/g++-include/iostream.h" 2 3 + + +class istream; class ostream; +typedef istream& (*__imanip)(istream&); +typedef ostream& (*__omanip)(ostream&); + +extern istream& ws(istream& ins); +extern ostream& flush(ostream& outs); +extern ostream& endl(ostream& outs); +extern ostream& ends(ostream& outs); + +class ostream : public ios +{ + void do_osfx(); + public: + ostream(); + ostream(streambuf* sb, ostream* tied=__null ); + ~ostream(); + + int opfx() { if (!good()) return 0; if (_tie) _tie->flush(); return 1; } + void osfx() { if (flags() & (ios::unitbuf|ios::stdio)) + do_osfx(); } + streambuf* ostreambuf() const { return _strbuf; } + ostream& flush(); + ostream& put(char c); + ostream& write(const char *s, int n); + ostream& write(const unsigned char *s, int n) { return write((char*)s, n);} + ostream& write(const void *s, int n) { return write((char*)s, n);} + ostream& seekp(streampos); + ostream& seekp(streamoff, _seek_dir); + streampos tellp(); + ostream& form(const char *format ...); + ostream& vform(const char *format, char* args); +}; + +extern ostream& operator<<(ostream&, char c); +inline ostream& operator<<(ostream& os, unsigned char c) +{ return os << (char)c; } + +extern ostream& operator<<(ostream&, const char *s); +inline ostream& operator<<(ostream& os, const unsigned char *s) +{ return os << (const char*)s; } + + +extern ostream& operator<<(ostream&, void *p); +extern ostream& operator<<(ostream&, int n); +extern ostream& operator<<(ostream&, long n); +extern ostream& operator<<(ostream&, unsigned int n); +extern ostream& operator<<(ostream&, unsigned long n); +inline ostream& operator<<(ostream& os, short n) {return os << (int)n;} +inline ostream& operator<<(ostream& os, unsigned short n) +{return os << (unsigned int)n;} +extern ostream& operator<<(ostream&, float n); +extern ostream& operator<<(ostream&, double n); +inline ostream& operator<<(ostream& os, __omanip func) { return (*func)(os); } +extern ostream& operator<<(ostream&, streambuf*); + +class istream : public ios +{ + int _gcount; + public: + istream(); + istream(streambuf* sb, ostream*tied=__null ); + ~istream(); + streambuf* istreambuf() const { return _strbuf; } + istream& get(char& c); + istream& get(unsigned char& c); + istream& read(char *ptr, int n); + istream& read(unsigned char *ptr, int n) { return read((char*)ptr, n); } + istream& read(void *ptr, int n) { return read((char*)ptr, n); } + + istream& getline(char* ptr, int len, char delim = '\n'); + istream& get(char* ptr, int len, char delim = '\n'); + istream& gets(char **s, char delim = '\n'); + int ipfx(int need) { + if (!good()) { set(ios::failbit); return 0; } + if (_tie && (need == 0 || rdbuf()->in_avail() < need)) _tie->flush(); + if (!need && (flags() & ios::skipws) && !ws(*this)) return 0; + return 1; + } + int ipfx0() { + if (!good()) { set(ios::failbit); return 0; } + if (_tie) _tie->flush(); + if ((flags() & ios::skipws) && !ws(*this)) return 0; + return 1; + } + int ipfx1() { + if (!good()) { set(ios::failbit); return 0; } + if (_tie && rdbuf()->in_avail() == 0) _tie->flush(); + return 1; + } + int get() { if (!ipfx1()) return (-1) ; + int ch = _strbuf->sbumpc(); + if (ch == (-1) ) set(ios::eofbit); + return ch; } + int peek() { if (!ipfx1()) return (-1) ; + int ch = _strbuf->sgetc(); + if (ch == (-1) ) set(ios::eofbit); + return ch; } + int gcount() { return _gcount; } + istream& ignore(int n=1, int delim = (-1) ); + istream& seekg(streampos); + istream& seekg(streamoff, _seek_dir); + streampos tellg(); + istream& putback(char ch) { + if (good() && _strbuf->sputbackc(ch) == (-1) ) clear(ios::badbit); + return *this;} + istream& unget() { + if (good() && _strbuf->sungetc() == (-1) ) clear(ios::badbit); + return *this;} + + istream& unget(char ch) { return putback(ch); } + int skip(int i); + +}; + +extern istream& operator>>(istream&, char*); +inline istream& operator>>(istream& is, unsigned char* p) +{ return is >> (char*)p; } + +extern istream& operator>>(istream&, char& c); +extern istream& operator>>(istream&, unsigned char& c); + +extern istream& operator>>(istream&, int&); +extern istream& operator>>(istream&, long&); +extern istream& operator>>(istream&, short&); +extern istream& operator>>(istream&, unsigned int&); +extern istream& operator>>(istream&, unsigned long&); +extern istream& operator>>(istream&, unsigned short&); +extern istream& operator>>(istream&, float&); +extern istream& operator>>(istream&, double&); +inline istream& operator>>(istream& is, __imanip func) { return (*func)(is); } + +inline ostream& ostream::put(char c) { _strbuf->sputc(c); return *this; } + +class iostream : public ios { + int _gcount; + public: + iostream(); + iostream(streambuf* sb, ostream*tied=__null ); + operator istream&() { return *(istream*)this; } + operator ostream&() { return *(ostream*)this; } + ~iostream(); + + istream& get(char& c) { return ((istream*)this)->get(c); } + istream& get(unsigned char& c) { return ((istream*)this)->get(c); } + istream& read(char *ptr, int n) { return ((istream*)this)->read(ptr, n); } + istream& read(unsigned char *ptr, int n) + { return ((istream*)this)->read((char*)ptr, n); } + istream& read(void *ptr, int n) + { return ((istream*)this)->read((char*)ptr, n); } + istream& getline(char* ptr, int len, char delim = '\n') + { return ((istream*)this)->getline(ptr, len, delim); } + istream& get(char* ptr, int len, char delim = '\n') + { return ((istream*)this)->get(ptr, len, delim); } + istream& gets(char **s, char delim = '\n') + { return ((istream*)this)->gets(s, delim); } + istream& ignore(int n=1, int delim = (-1) ) + { return ((istream*)this)->ignore(n, delim); } + int ipfx(int need) { return ((istream*)this)->ipfx(need); } + int ipfx0() { return ((istream*)this)->ipfx0(); } + int ipfx1() { return ((istream*)this)->ipfx1(); } + int get() { return _strbuf->sbumpc(); } + int peek() { return ipfx1() ? _strbuf->sgetc() : (-1) ; } + int gcount() { return _gcount; } + istream& putback(char ch) { return ((istream*)this)->putback(ch); } + istream& unget() { return ((istream*)this)->unget(); } + istream& seekg(streampos pos) { return ((istream*)this)->seekg(pos); } + istream& seekg(streamoff off, _seek_dir dir) + { return ((istream*)this)->seekg(off, dir); } + streampos tellg() { return ((istream*)this)->tellg(); } + + istream& unget(char ch) { return putback(ch); } + + + + int opfx() { return ((ostream*)this)->opfx(); } + void osfx() { ((ostream*)this)->osfx(); } + ostream& flush() { return ((ostream*)this)->flush(); } + ostream& put(char c) { return ((ostream*)this)->put(c); } + ostream& write(const char *s, int n) + { return ((ostream*)this)->write(s, n); } + ostream& write(const unsigned char *s, int n) + { return ((ostream*)this)->write((char*)s, n); } + ostream& write(const void *s, int n) + { return ((ostream*)this)->write((char*)s, n); } + ostream& form(const char *format ...); + ostream& vform(const char *format, char* args) + { return ((ostream*)this)->vform(format, args); } + ostream& seekp(streampos pos) { return ((ostream*)this)->seekp(pos); } + ostream& seekp(streamoff off, _seek_dir dir) + { return ((ostream*)this)->seekp(off, dir); } + streampos tellp() { return ((ostream*)this)->tellp(); } +}; + +extern istream cin; +extern ostream cout, cerr, clog; + +struct Iostream_init { } ; + +inline ios& dec(ios& i) +{ i.setf(ios::dec, ios::dec|ios::hex|ios::oct); return i; } +inline ios& hex(ios& i) +{ i.setf(ios::hex, ios::dec|ios::hex|ios::oct); return i; } +inline ios& oct(ios& i) +{ i.setf(ios::oct, ios::dec|ios::hex|ios::oct); return i; } + + +//# 7 "/usr/latest/lib/g++-include/stream.h" 2 3 + + +extern char* form(const char*, ...); + +extern char* dec(long, int=0); +extern char* dec(int, int=0); +extern char* dec(unsigned long, int=0); +extern char* dec(unsigned int, int=0); + +extern char* hex(long, int=0); +extern char* hex(int, int=0); +extern char* hex(unsigned long, int=0); +extern char* hex(unsigned int, int=0); + +extern char* oct(long, int=0); +extern char* oct(int, int=0); +extern char* oct(unsigned long, int=0); +extern char* oct(unsigned int, int=0); + +inline istream& WS(istream& str) { return ws(str); } + + +//# 9 "test.C" 2 + + +class Y { +public: + Y() {} + virtual const char *stringify() = 0; + virtual char *stringify2() const = 0; // { dg-error "overriding" } +}; + +class X: public Y { +public: + X(): Y() {} + const char *stringify(); // { dg-error "candidate" } + const char *stringify2() const; // { dg-error "candidate|conflicting return type" } +}; + +char * +X::stringify() const // { dg-error "does not match" } +{ + return "stringify"; +} + +const char * +X::stringify2() // { dg-error "does not match" } +{ + return "stringify2"; +} + +main() +{ + X x; + Y& y = x; + + cout << "x\n"; + cout << x.stringify() << '\n'; + cout << x.stringify2() << '\n'; + + cout << "y\n"; + cout << y.stringify() << '\n'; + cout << y.stringify2() << '\n'; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p8154.C b/gcc/testsuite/g++.old-deja/g++.mike/p8154.C new file mode 100644 index 000000000..126eb25e4 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p8154.C @@ -0,0 +1,19 @@ +// { dg-do assemble } +// { dg-options "-w -fpermissive" } +// prms-id: 8154 + +class QvFieldData; +class QvNode { + QvFieldData *fieldData; +}; +class QvGroup : public QvNode { + static QvFieldData *fieldData; +}; +class QvUnknownNode : public QvGroup +{ +public: + QvUnknownNode :: QvUnknownNode (); +private: + static QvFieldData *fieldData; + virtual QvFieldData *getFieldData() { return fieldData; } +}; diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p8155.C b/gcc/testsuite/g++.old-deja/g++.mike/p8155.C new file mode 100644 index 000000000..79384717c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p8155.C @@ -0,0 +1,148 @@ +// { dg-do run } +// prms-id: 8155 + +int fail = 1; + +class CMainWindow; +class CFrameWnd; +class CWnd; +class CCmdTarget; + +typedef void (CCmdTarget::*AFX_PMSG)( void); +typedef void (CWnd::*AFX_PMSGW)( void); + +struct AFX_MSGMAP_ENTRY { + unsigned int nMessage; + AFX_PMSG pfn; +}; + +struct AFX_MSGMAP { + const AFX_MSGMAP* pBaseMap; + const AFX_MSGMAP_ENTRY* lpEntries; +}; + +class CCmdTarget { +public: + CCmdTarget(); +private: + static AFX_MSGMAP_ENTRY _messageEntries[]; +protected: + static const AFX_MSGMAP messageMap; + virtual const AFX_MSGMAP* GetMessageMap() const; +}; + +const AFX_MSGMAP CCmdTarget::messageMap = { + 0, &CCmdTarget::_messageEntries[0] +}; + +const AFX_MSGMAP* CCmdTarget::GetMessageMap() const { + return &CCmdTarget::messageMap; +} + +AFX_MSGMAP_ENTRY CCmdTarget::_messageEntries[] = +{ + { 0, 0 } +}; + +CCmdTarget :: CCmdTarget() { } + +class CWnd : public CCmdTarget { +public: + CWnd(); + +protected: + void OnPaint(); +private: + static AFX_MSGMAP_ENTRY _messageEntries[]; +protected: + static const AFX_MSGMAP messageMap; + virtual const AFX_MSGMAP* GetMessageMap() const; +}; + +CWnd :: CWnd() { +} + +void CWnd :: OnPaint() { +} + +const AFX_MSGMAP* CWnd ::GetMessageMap() const { + return & CWnd ::messageMap; +} +const AFX_MSGMAP CWnd ::messageMap = { + & CCmdTarget ::messageMap, & CWnd ::_messageEntries[0] + }; +AFX_MSGMAP_ENTRY CWnd ::_messageEntries[] = { + {0, (AFX_PMSG)0 } }; + +class CFrameWnd : public CWnd { +public: + CFrameWnd(); +protected: +private: + static AFX_MSGMAP_ENTRY _messageEntries[]; +protected: + static const AFX_MSGMAP messageMap; + virtual const AFX_MSGMAP* GetMessageMap() const; +}; + +CFrameWnd :: CFrameWnd() { } + +const AFX_MSGMAP* CFrameWnd ::GetMessageMap() const { + return & CFrameWnd ::messageMap; +} +const AFX_MSGMAP CFrameWnd ::messageMap = { + & CWnd ::messageMap, & CFrameWnd ::_messageEntries[0] + }; +AFX_MSGMAP_ENTRY CFrameWnd ::_messageEntries[] = { + {0, (AFX_PMSG)0 } }; + +class CMainWindow : public CFrameWnd { +public: + CMainWindow(); + void OnPaint(); + void callProc(); +private: + static AFX_MSGMAP_ENTRY _messageEntries[]; +protected: + static const AFX_MSGMAP messageMap; + virtual const AFX_MSGMAP* GetMessageMap() const; +}; + +CMainWindow :: CMainWindow() +{ +} +void CMainWindow :: OnPaint() +{ + fail = 0; +} + +void CMainWindow :: callProc() +{ + const AFX_MSGMAP* pMessageMap; + const AFX_MSGMAP_ENTRY *lpEntry; + + pMessageMap = GetMessageMap(); + lpEntry = pMessageMap->lpEntries; + + if( lpEntry->nMessage == 100) { + (this->*lpEntry->pfn)(); + } +} + +const AFX_MSGMAP* CMainWindow ::GetMessageMap() const { + return & CMainWindow ::messageMap; +} +const AFX_MSGMAP CMainWindow ::messageMap = { + & CFrameWnd ::messageMap, & CMainWindow ::_messageEntries[0] + }; +AFX_MSGMAP_ENTRY CMainWindow ::_messageEntries[] = { + { 100, (AFX_PMSG)(AFX_PMSGW)(void (CWnd::*)(void))&CMainWindow::OnPaint }, + {0, (AFX_PMSG)0 } +}; + +int main( int argc, char **argv) { + CMainWindow myWindow; + + myWindow.callProc(); + return fail; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p8175.C b/gcc/testsuite/g++.old-deja/g++.mike/p8175.C new file mode 100644 index 000000000..23006e72a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p8175.C @@ -0,0 +1,15 @@ +// { dg-do assemble } +// prms-id: 8175 + +class AtoBoolC { +public: + AtoBoolC(const AtoBoolC& aBool); +private: + int myValue; +}; + +struct TestCase { + AtoBoolC is_call_on_unack; +}; + +static TestCase the_cases[] = { { 0 } }; // { dg-error "" } diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p8269.C b/gcc/testsuite/g++.old-deja/g++.mike/p8269.C new file mode 100644 index 000000000..3b97d1e8b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p8269.C @@ -0,0 +1,11 @@ +// { dg-do assemble } +// prms-id: 8269 + +typedef char* const char_ptr; + +class Foo_Bar { +public: + static char* const counter; +}; + +char_ptr Foo_Bar::counter = 0; diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p8460.C b/gcc/testsuite/g++.old-deja/g++.mike/p8460.C new file mode 100644 index 000000000..4e0f0d22c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p8460.C @@ -0,0 +1,17 @@ +// { dg-do assemble } +// prms-id: 8460 + +class A { +public: + A(); + A(int) { } + A(const A&) { } +private: +}; + +int main() +{ + A a; + + a.A(1); // { dg-error "" } cannot find name this way +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p8483.C b/gcc/testsuite/g++.old-deja/g++.mike/p8483.C new file mode 100644 index 000000000..08b5161ba --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p8483.C @@ -0,0 +1,36 @@ +// { dg-do run } +// prms-id: 8483 + +int count; + +class A { +public: + A() { ++count; } + ~A() { } +}; + +class B { +private: + A b[2]; +}; + +class C { +public: +private: + A c[2][2]; +}; + +class D { +public: +private: + A d[2][2][2]; +}; + +int main() { + { A a; } + { B b; } + { C c; } + { D d; } + if (count != 15) + return 1; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p8620.C b/gcc/testsuite/g++.old-deja/g++.mike/p8620.C new file mode 100644 index 000000000..8064c8299 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p8620.C @@ -0,0 +1,14 @@ +// { dg-do assemble } +// prms-id: 8620 + +struct S { + long l; +}; + +typedef unsigned long l; + +void f() { + S* p; + if (p->l < 0) + return; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p8786.C b/gcc/testsuite/g++.old-deja/g++.mike/p8786.C new file mode 100644 index 000000000..577111ec3 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p8786.C @@ -0,0 +1,24 @@ +// { dg-do assemble } +// { dg-options "-O" } +// prms-id: 8786 + +class B { +public: + ~B(); +}; + +class D : public B { +public: + D(int); +}; + +int foo() { + D t(0); + + bool h = 1; + if (h) { + D p(0); + return 0; + } + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p8804.C b/gcc/testsuite/g++.old-deja/g++.mike/p8804.C new file mode 100644 index 000000000..d3a2401dd --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p8804.C @@ -0,0 +1,19 @@ +// { dg-do run } +// prms-id: 8804 + +extern "C" int printf (const char *, ...); + +struct Fails { + int i; + union { + union { + int c; + }; + }; +}; + +Fails d; + +int main() { + return &d.i == &d.c; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p8825.C b/gcc/testsuite/g++.old-deja/g++.mike/p8825.C new file mode 100644 index 000000000..f6748996c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p8825.C @@ -0,0 +1,14 @@ +// { dg-do assemble } +// prms-id: 8825 + +class A { + typedef A x; +}; + +class B { + typedef B x; +}; + +class C : public A, public B { + typedef C x; +}; diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p9068.C b/gcc/testsuite/g++.old-deja/g++.mike/p9068.C new file mode 100644 index 000000000..2c62f5c79 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p9068.C @@ -0,0 +1,23 @@ +// { dg-do assemble } +// prms-id: 9068 + +struct ostream { + void operator<< (int); // { dg-message "operator|no known conversion" } fn ref in err msg +}; + +class C { +public: + static int& i (); + static int& i (int signatureDummy); +}; + +void foo (ostream& lhs, const C& rhs) +{ + lhs << rhs.i; // { dg-error "match" } no such i for any opr << () + // { dg-message "candidate" "candidate note" { target *-*-* } 16 } +} + +int& C::i () { + static int _i = 4711; + return _i; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p9129.C b/gcc/testsuite/g++.old-deja/g++.mike/p9129.C new file mode 100644 index 000000000..54cf53e89 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p9129.C @@ -0,0 +1,12 @@ +// { dg-do assemble } +// { dg-options "-ansi -pedantic-errors" } +// prms-id: 9129 + +class Foo { +public: + int DoSomething(); +}; + +int (Foo::*pA)() = { &Foo::DoSomething }; +int (Foo::*X[1])(int) = { { &Foo::DoSomething } }; // { dg-error "" } +int (Foo::*Y[])(int) = { { &Foo::DoSomething, &Foo::DoSomething, 0 } }; // { dg-error "" } diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p9206.C b/gcc/testsuite/g++.old-deja/g++.mike/p9206.C new file mode 100644 index 000000000..a5452e133 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p9206.C @@ -0,0 +1,22 @@ +// { dg-do run } +// prms-id: 9206 + +class X { +public: + void xtest() { } +}; + +class Y { }; + +typedef void (X::*Xptr)(); +typedef void (Y::*Yptr)(); + +int main() { + X xx; + + Xptr xp = &X::xtest; + Yptr yp = reinterpret_cast<Yptr>(xp); + xp = reinterpret_cast<Xptr>(yp); + + (xx.*xp)(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p9506.C b/gcc/testsuite/g++.old-deja/g++.mike/p9506.C new file mode 100644 index 000000000..db16e3738 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p9506.C @@ -0,0 +1,7 @@ +// { dg-do assemble } +// prms-id: 9506 + +char * volatile p; +void foo() { + --p = 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p9706.C b/gcc/testsuite/g++.old-deja/g++.mike/p9706.C new file mode 100644 index 000000000..0ed15e4c8 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p9706.C @@ -0,0 +1,37 @@ +// { dg-do run { xfail sparc64-*-elf arm-*-pe } } +// { dg-options "-fexceptions" } +// prms-id: 9706 + +#include <stdlib.h> + +int count, acount; + +void *operator new(size_t sz) { ++count; return malloc (sz); } +void operator delete(void *p) throw() { --count; free (p); } + +class A { +public: + A() { ++acount; } + A(const A&) { ++acount; } + ~A() { --acount; } +}; + +int main() { + int i; + + // The standard library may have called new and/or delete during + // startup, so we have to reset the counter here. + count = 0; + + for( i = 0; i < 10; i++ ) { + try { + throw A(); + } + catch (A& a) { + } + } + if (acount) + return 1; + if (count) + return 2; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p9732a.C b/gcc/testsuite/g++.old-deja/g++.mike/p9732a.C new file mode 100644 index 000000000..9af5a9002 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p9732a.C @@ -0,0 +1,37 @@ +// { dg-do run } +// prms-id: 9732 + +class A { + int i; +public: + A() { i = 1; } + ~A() { } +}; + +struct value { + A x,y,z; +}; + +int crash(const value* capt, value* jet) { + return capt == jet; +} + +class euler { +public: + value number() const { return _value; } + int distance(); + +private: + value _value; +}; + +int euler::distance() { + const value& capt = number(); + value jet; + return crash (&capt, &jet); +} + +int main() { + euler e; + return e.distance(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p9732b.C b/gcc/testsuite/g++.old-deja/g++.mike/p9732b.C new file mode 100644 index 000000000..b10727ef3 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p9732b.C @@ -0,0 +1,47 @@ +// { dg-do run } +// prms-id: 9732 + +int count; +int bail = 0; + +extern "C" void abort (void); +extern "C" void _exit (int); + + +struct base { + base () { ++count; } + ~base () { --count; } + base(const base&o) { ++count; } +}; + +class D { +public: + ~D() { + if (bail++) + { + // On some Linux boxes, we run the dtor for d twice, + // once before exit, and once after! + abort (); + } + else + { + if (count != 0) + _exit (1); + _exit (0); + } + } +} d; + +base base_object; + +base base_returning_function (); + +const base& base_ref = base_returning_function (); + +int main () { +} + +base base_returning_function () { + base local_base_object; + return local_base_object; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p9732c.C b/gcc/testsuite/g++.old-deja/g++.mike/p9732c.C new file mode 100644 index 000000000..9239a0978 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p9732c.C @@ -0,0 +1,5 @@ +// { dg-do assemble } +// prms-id: 9732 + +struct foo {}; +foo& x() { return foo(); } // { dg-error "invalid init" } diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p991.C b/gcc/testsuite/g++.old-deja/g++.mike/p991.C new file mode 100644 index 000000000..fd71dde68 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/p991.C @@ -0,0 +1,22 @@ +// { dg-do assemble } +// prms-id: 991 + +class Complex { +public: + double re; + double im; + Complex(double r,double i) : re(r), im(i) {} +}; + +Complex cos(const Complex&); + +extern "C" double cos (double); // not the same as the above +extern "C" double cosh (double); +extern "C" double sin (double); +extern "C" double sinh (double); + +Complex cos(const Complex& arg) { + double nr = cos(arg.re)*cosh(arg.im); + double ni = -sin(arg.re)*sinh(arg.im); + return Complex(nr,ni); +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/parse1.C b/gcc/testsuite/g++.old-deja/g++.mike/parse1.C new file mode 100644 index 000000000..621bb0995 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/parse1.C @@ -0,0 +1,7 @@ +// { dg-do assemble } + +enum { name1 }; +struct name0 { }; +struct name1 { }; +struct derived1 : public name1 { }; +struct derived2 : public name0, public name1 { }; diff --git a/gcc/testsuite/g++.old-deja/g++.mike/pmd1.C b/gcc/testsuite/g++.old-deja/g++.mike/pmd1.C new file mode 100644 index 000000000..8fddb22b5 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/pmd1.C @@ -0,0 +1,12 @@ +// { dg-do assemble } + +class A; +struct XX { int A::*py; }; + +class A { +public: + int p; + void setp(XX *xp); +}; + +void A::setp(XX *xp) { xp->py = &A::p; } diff --git a/gcc/testsuite/g++.old-deja/g++.mike/pmf1.C b/gcc/testsuite/g++.old-deja/g++.mike/pmf1.C new file mode 100644 index 000000000..15460ebaa --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/pmf1.C @@ -0,0 +1,91 @@ +// { dg-do run } +// extern "C" printf(const char *, ...); + +class X +{ +public: + int a; + int f(int); +}; + +class Y +{ +public: + int b; + int c; + int g(int); +}; + +class MD : public X, public Y +{ +public: + int c; + int hf(int); +}; + +int MD::* pmi0 = &MD::a; +int MD::* pmi1 = &MD::b; +int MD::* pmi2 = &MD::c; + +int (MD::* pmf0)(int) = &MD::f; +int (MD::* pmf1)(int) = &MD::g; +int (MD::* pmf2)(int) = &MD::hf; + +int main() +{ + MD obj; + int fail = 0; + + obj.a = 1; + obj.b = 2; + obj.c = 3; + + obj.*pmi0 = 7; + obj.*pmi1 = 8; + obj.*pmi2 = 9; + + fail += (obj.*pmf0)(7); + fail += (obj.*pmf1)(8); + fail += (obj.*pmf2)(9); + +#if 0 + if (fail != 0) + printf ("failed %d tests\n", fail); + else + printf ("passed\n"); + + printf ("sizeof(X) = %d, sizeof(Y) = %d, sizeof(MD) = %d\n", + sizeof(X), sizeof(Y), sizeof(MD)); +#endif + return fail; +} + +int X::f(int v) +{ + if (v != a) + { +// printf ("failed in X::f, a = %d\n", a); + return 1; + } + return 0; +} + +int Y::g(int v) +{ + if (v != b) + { +// printf ("failed in Y::g, b = %d\n", b); + return 1; + } + return 0; +} + +int MD::hf(int v) +{ + if (v != c) + { +// printf ("failed in MD::hf, c = %d\n", c); + return 1; + } + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/pmf2.C b/gcc/testsuite/g++.old-deja/g++.mike/pmf2.C new file mode 100644 index 000000000..209c5ebea --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/pmf2.C @@ -0,0 +1,55 @@ +// { dg-do run } +extern "C" int printf(const char *, ...); + +class A_table { + int c; +public: + A_table() { c = 3;} + virtual void func2(int &item) { printf("func2(%d,) c=%d\n",item,c);} +}; + +class B_table : private A_table { +public: + typedef void (B_table::* B_ti_fn) (int &item); + B_table() { j = 0x4321;} + virtual void call_fn_fn1(int &item, void *pfn1); + void func1(int &item) { printf("func1(%d)\n",item);} + virtual void func2(int &item) { printf("func2(%d) j=%d\n",item,j);} + int j; +}; + +class foo : public A_table { +public: + int i; + virtual ~foo(); + virtual void func2(int &item) { printf("func2(%d) i=%d\n",item,i);} +}; +foo::~foo() { i = 0;} + +class bar :public foo,public B_table { +public: + int w; + virtual ~bar(); + virtual void func2(int &item) { printf("func2(%d) w=%d\n",item,w);} +}; +bar::~bar() { w = 0;} + +void B_table::call_fn_fn1(int &item, void *pfn1) { + (this->*(*(B_ti_fn*)pfn1))(item); +} + +B_table b; +bar jar; + +int main() { + printf("ptr to B_table=%x, ptr to A_table=%x\n",&b,(A_table*)&b); + B_table::B_ti_fn z = &B_table::func1; + int j = 1; + jar.call_fn_fn1(j,(void *)&z); + j++; + z = &B_table::func2; + b.call_fn_fn1(j,(void *)&z); + j++; + jar.call_fn_fn1(j,(void *)&z); + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/pmf3.C b/gcc/testsuite/g++.old-deja/g++.mike/pmf3.C new file mode 100644 index 000000000..8dee9278f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/pmf3.C @@ -0,0 +1,20 @@ +// { dg-do assemble } +struct Fooey { + void f(char* pX); + void f(int in); + void f(float fx); + void h(double dx); +}; + +void Fooey::f(char*) { } // { dg-error "" } candidate +void Fooey::f(int) { } // { dg-error "" } candidate +void Fooey::f(float) { } // { dg-error "" } candidate +void Fooey::h(double zahl) { } + +int main() { + Fooey Blah; + void (Fooey::*pointer)(double); + pointer = &Fooey::f; // { dg-error "" } don't call Fooey::h + (Blah.*pointer)(42.5); + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/pmf4.C b/gcc/testsuite/g++.old-deja/g++.mike/pmf4.C new file mode 100644 index 000000000..944993a98 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/pmf4.C @@ -0,0 +1,13 @@ +// { dg-do assemble } + +class NF { }; + +struct QF { + NF nf; + + typedef float(NF::* const NPF)() const; + + void p (NPF npf) const { + float q = (nf.*npf)(); + } +}; diff --git a/gcc/testsuite/g++.old-deja/g++.mike/pmf6.C b/gcc/testsuite/g++.old-deja/g++.mike/pmf6.C new file mode 100644 index 000000000..7ff34d049 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/pmf6.C @@ -0,0 +1,13 @@ +// { dg-do assemble } +// { dg-options "" } + +class S { +public: + void (S::*pmf)(); + void foo() { + pmf(); // { dg-error "pointer-to-member" } + } + static void foo1(S* sp) { + (sp->pmf)(); // { dg-error "pointer-to-member" } + } +}; diff --git a/gcc/testsuite/g++.old-deja/g++.mike/pmf7.C b/gcc/testsuite/g++.old-deja/g++.mike/pmf7.C new file mode 100644 index 000000000..ab9ead011 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/pmf7.C @@ -0,0 +1,30 @@ +// { dg-do run } +class A; +typedef int (A::*f_ptr) (void); + +class B { +public: + B() {} ~B() {} + B& dummy(f_ptr cb) { return *this; } +}; + +template<class SP, class CB> SP& call_dummy(SP* sp, CB cb) { + sp->dummy(cb); + return *sp; +} + +class A { +public: + A() {} ~A() {} + int ok() { return 0; } + A& call_it(B* s) { + call_dummy(s, &A::ok); + return *this; + } +}; + +int main() { + A a; B b; + a.call_it(&b); + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/pmf8.C b/gcc/testsuite/g++.old-deja/g++.mike/pmf8.C new file mode 100644 index 000000000..10f67c6f0 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/pmf8.C @@ -0,0 +1,32 @@ +// { dg-do run } +int fail; + +class A *ptr_a; + +class A { +public: + char space1[24]; + virtual void foo() { + if (this != ptr_a) + fail = 1; + } +}; + +class Space { + char space2[36]; +}; + +class B : public Space, public A { +} b; + +void (B::*pmf1)() = &A::foo; +void (A::*pmf2)() = &A::foo; + +int main() { + ptr_a = &b; + (b .* (void (B::*) ()) &A::foo) (); + (b .* pmf1) (); + (b .* pmf2) (); + (b .* &A::foo) (); + return fail; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/pmf9.C b/gcc/testsuite/g++.old-deja/g++.mike/pmf9.C new file mode 100644 index 000000000..17e58b4d7 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/pmf9.C @@ -0,0 +1,24 @@ +// { dg-do run } +class K { +public: + int f(int i) { return i; } +}; + +class Q { +public: + Q() { kp = new K; } + int g(); +private: + K * kp; +}; + +int Q::g() { + return (kp->f)(42); +} + + +int main () { + Q q; + if (q.g() != 42) + return 1; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/pt1.C b/gcc/testsuite/g++.old-deja/g++.mike/pt1.C new file mode 100644 index 000000000..5ab78e71e --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/pt1.C @@ -0,0 +1,37 @@ +// { dg-do run } +template <class T, class V> +class A { +public: + A (T at, V av); + void print () { } +protected: + T t; + V v; +}; + +template <class T, class V> +A<T, V>::A (T at, V av) { + t = at; + v = av; +} + + +template <class T, class V> +class B: public virtual A<T, V> { +public: + B (T at, V av); + void print () { } +}; + +template <class T, class V> +B<T, V>::B (T at, V av) : A<T, V> (at, av) { } // { dg-bogus "" } + +int main () { + int i = 2; + double x = 2; + + B<int, double> ab(i, x); + ab.print(); + + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/pt2.C b/gcc/testsuite/g++.old-deja/g++.mike/pt2.C new file mode 100644 index 000000000..e2f77ecf0 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/pt2.C @@ -0,0 +1,23 @@ +// { dg-do run } +class A { +public: +}; + +template <class T> +class B: public virtual A { +public: + B (); + ~B (); +}; + +template <class T> +B<T>::B () { } + +template <class T> +B<T>::~B () { } + +int main () { + B<int> ab; + + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/pt3.C b/gcc/testsuite/g++.old-deja/g++.mike/pt3.C new file mode 100644 index 000000000..201b1085c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/pt3.C @@ -0,0 +1,29 @@ +// { dg-do assemble } + +template<class Repr> +class syHandle +{ +protected: + syHandle(); + ~syHandle(); + Repr *_repr; +}; + +template<class Repr> +syHandle<Repr>::~syHandle() +{ +} + +typedef char * char_ptr_t; + +template <> +syHandle<char_ptr_t>::syHandle() +{ + _repr = 0; +} + +template <> +syHandle<char_ptr_t>::~syHandle() +{ + _repr = 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/pt4.C b/gcc/testsuite/g++.old-deja/g++.mike/pt4.C new file mode 100644 index 000000000..4068cece4 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/pt4.C @@ -0,0 +1,4 @@ +// { dg-do assemble } + +template <char* c> struct B { B() { } }; +B<0> bnull; // { dg-error "" } could not convert template argument diff --git a/gcc/testsuite/g++.old-deja/g++.mike/ref1.C b/gcc/testsuite/g++.old-deja/g++.mike/ref1.C new file mode 100644 index 000000000..802ede359 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/ref1.C @@ -0,0 +1,22 @@ +// { dg-do run } +int count; + +struct base { + base () { ++count; } + ~base () { --count; } + base(const base&o) { ++count; } +}; + +base base_returning_function (); + +const base& base_ref = base_returning_function (); + +int main () { + if (count != 1) + return 1; +} + +base base_returning_function () { + base local_base_object; + return local_base_object; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/rtti1.C b/gcc/testsuite/g++.old-deja/g++.mike/rtti1.C new file mode 100644 index 000000000..19aa3894e --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/rtti1.C @@ -0,0 +1,4 @@ +// { dg-do assemble } + +#include <typeinfo> +#include <iostream> diff --git a/gcc/testsuite/g++.old-deja/g++.mike/rtti2.C b/gcc/testsuite/g++.old-deja/g++.mike/rtti2.C new file mode 100644 index 000000000..1f5944a1c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/rtti2.C @@ -0,0 +1,6 @@ +// { dg-do run } +#include <typeinfo> + +int main() { + typeid(bool); +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/rtti3.C b/gcc/testsuite/g++.old-deja/g++.mike/rtti3.C new file mode 100644 index 000000000..d2d48d1c7 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/rtti3.C @@ -0,0 +1,24 @@ +// { dg-do run } +class base { +public: + virtual ~base() {} + virtual void m1() = 0; + virtual void m2() = 0; +}; + +class intermediate : public virtual base { +public: + virtual ~intermediate() {} + virtual void m1() {} + virtual void m2() {} +}; + +class derived : public intermediate { +public: + virtual int IwantedThisMethod() { return 0; } + virtual int ButIgotThisOne() { return 1; } +}; + +int main() { + return derived().IwantedThisMethod(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/s24939.C b/gcc/testsuite/g++.old-deja/g++.mike/s24939.C new file mode 100644 index 000000000..915cfe224 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/s24939.C @@ -0,0 +1,13 @@ +// { dg-do assemble } + +class A; + +class B { +public: + B(); +private: + A a; // { dg-error "" } +}; + +class A { }; +B::B() { } diff --git a/gcc/testsuite/g++.old-deja/g++.mike/s35520.C b/gcc/testsuite/g++.old-deja/g++.mike/s35520.C new file mode 100644 index 000000000..cb73482bd --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/s35520.C @@ -0,0 +1,4 @@ +// { dg-do assemble } + +static void kbdNormal() { } +void (*keyHandler)() = kbdNormal; diff --git a/gcc/testsuite/g++.old-deja/g++.mike/s9959.C b/gcc/testsuite/g++.old-deja/g++.mike/s9959.C new file mode 100644 index 000000000..896620bc4 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/s9959.C @@ -0,0 +1,20 @@ +// { dg-do assemble } + +class A { +protected: + int aData; +}; + +class B : public A { +public: + virtual void func1() { + A::aData = 1; + } +}; + +class C : virtual public B { +public: + virtual void func1(void) { + A::aData = 2; + } +}; diff --git a/gcc/testsuite/g++.old-deja/g++.mike/scast1.C b/gcc/testsuite/g++.old-deja/g++.mike/scast1.C new file mode 100644 index 000000000..9a905d028 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/scast1.C @@ -0,0 +1,8 @@ +// { dg-do assemble } +class A {}; +class C {}; + +int main() { + A* a = 0; + C* c = static_cast<C*>(a); // { dg-error "" } bad static cast +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/sizeof.C b/gcc/testsuite/g++.old-deja/g++.mike/sizeof.C new file mode 100644 index 000000000..c336a7a46 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/sizeof.C @@ -0,0 +1,9 @@ +// { dg-do compile } + +class Foo { + int children[4]; +public: + unsigned function(void) { + return sizeof (((Foo*)0)->children); + } +}; diff --git a/gcc/testsuite/g++.old-deja/g++.mike/temp.C b/gcc/testsuite/g++.old-deja/g++.mike/temp.C new file mode 100644 index 000000000..0a5ce5812 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/temp.C @@ -0,0 +1,32 @@ +// { dg-do run } +extern "C" int printf(const char *, ...); +extern "C" const char *getenv(const char *); + +class T { + int i; +public: + T() { + i = 1; + printf("T() at %x\n", this); + } + T(const T& o) { + i = o.i; + printf("T(const T&) at %x <-- %x\n", this, &o); + } + T operator +(const T& o) { + T r; + r.i = this->i + o.i; + return r; + } + operator int () { + return i; + } + ~T() { printf("~T() at %x\n", this); } +} s, b; + +int foo() { return getenv("TEST") == 0; } + +int main() { + int i = foo() ? s+b : s; + return i != 2; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/thunk1.C b/gcc/testsuite/g++.old-deja/g++.mike/thunk1.C new file mode 100644 index 000000000..8a7be6234 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/thunk1.C @@ -0,0 +1,18 @@ +// { dg-do assemble } + +struct C1 +{ + virtual ~C1(); +}; + +struct C2 : public virtual C1 +{ + virtual ~C2(); +}; + +struct C3 : public virtual C2 +{ + virtual ~C3(); +}; + +C3::~C3() {} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/thunk2.C b/gcc/testsuite/g++.old-deja/g++.mike/thunk2.C new file mode 100644 index 000000000..fa864b4aa --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/thunk2.C @@ -0,0 +1,39 @@ +// { dg-do run } +#include <typeinfo> + +int state; +int fail; + +class A { +public: + A() { + if (++state != 1) + fail = 1; + } + virtual int foo() { + if (++state != 2) + fail = 1; + return 0; + } + virtual ~A() { + if (++state != 3) + fail = 1; + } +}; + +A* bar() { + return new A; +} + +int main() { + A *aptr = bar(); + aptr->foo(); + if (dynamic_cast <void*> (aptr) != aptr) + fail = 1; + if (typeid (*aptr) != typeid (A)) + fail = 1; + delete aptr; + if (++state != 4) + fail = 1; + return fail; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/thunk3.C b/gcc/testsuite/g++.old-deja/g++.mike/thunk3.C new file mode 100644 index 000000000..053e035bb --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/thunk3.C @@ -0,0 +1,35 @@ +// { dg-do run } +int state; +int fail; + +class A { +public: + A() { + if (++state != 1) + fail = 1; + } + virtual int foo() { + if (++state != 2) + fail = 1; + return 0; + } + virtual ~A() { + if (++state != 3) + fail = 1; + } +}; + +A* bar() { + return new A; +} + +int main() { + A *aptr = bar(); + aptr->foo(); + if (dynamic_cast <void*> (aptr) != aptr) + fail = 1; + delete aptr; + if (++state != 4) + fail = 1; + return fail; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/unroll1.C b/gcc/testsuite/g++.old-deja/g++.mike/unroll1.C new file mode 100644 index 000000000..e3e7cd50e --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/unroll1.C @@ -0,0 +1,11 @@ +// { dg-do assemble } +// { dg-options "-g -O -funroll-loops" } + +struct A { + inline ~A() { } +}; + +void foo (A) { + while (1) + A bar; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/unused.C b/gcc/testsuite/g++.old-deja/g++.mike/unused.C new file mode 100644 index 000000000..b441a77f5 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/unused.C @@ -0,0 +1,7 @@ +// { dg-do compile { target *-*-darwin* } } +// { dg-options { -Wunused-parameter } } +// Radar 4125055 + +void foo(int x) { +#pragma unused ( x ) +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/virt1.C b/gcc/testsuite/g++.old-deja/g++.mike/virt1.C new file mode 100644 index 000000000..f8ee4edb0 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/virt1.C @@ -0,0 +1,13 @@ +// { dg-do assemble } + +struct S0 { virtual void f1 () { } }; + +struct S1 : virtual public S0 { virtual void f1 () { } }; + +struct S2 : public S1 { virtual void f1 () { } }; + +struct S3 : virtual public S0 { virtual void f1 () { } }; + +struct S4 : public S3 { }; + +void creator () { new S4; } diff --git a/gcc/testsuite/g++.old-deja/g++.mike/virt2.C b/gcc/testsuite/g++.old-deja/g++.mike/virt2.C new file mode 100644 index 000000000..8cbe4d194 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/virt2.C @@ -0,0 +1,26 @@ +// { dg-do run } +struct S0 { + virtual int is_kind_of_S1 () const { return 0; } + virtual void dummy () { } +}; + +struct S1 : virtual public S0 { + virtual int is_kind_of_S1 () const { return 1; } + virtual void dummy () { } +}; + +struct S2 : virtual public S0 { + virtual void dummy () { } +}; + +struct S3 : public S2, public S1 { + virtual void dummy () { } +}; + +static struct S0 *var = new S3 (); + +int main () { + if (var->is_kind_of_S1() != 1) + return 1; + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/virt3.C b/gcc/testsuite/g++.old-deja/g++.mike/virt3.C new file mode 100644 index 000000000..e030fee9d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/virt3.C @@ -0,0 +1,17 @@ +// { dg-do assemble } + +class B { +public: + int Bi; + virtual int g() { return 0; } +}; + +class D : private B { + int Di; +}; + +class E : public virtual D, public B { // { dg-warning "" } direct base inaccessible due to ambiguity + int Ei; +}; + +E e; diff --git a/gcc/testsuite/g++.old-deja/g++.mike/virt4.C b/gcc/testsuite/g++.old-deja/g++.mike/virt4.C new file mode 100644 index 000000000..2d8b04263 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/virt4.C @@ -0,0 +1,28 @@ +// { dg-do run } +// { dg-options "" } + +void Foo () {} + +class B { +public: + virtual void foo() = 0; +}; + +class D: virtual public B { +public: + void foo() { Foo(); } +}; + +class D1: public D {}; + +class D2: public D {}; + +class D1_2: public D1, public D2 { +public: + void foo() { D1::foo(); D2::foo(); } +}; + +main() { + D1_2 h; + h.foo(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/virt5.C b/gcc/testsuite/g++.old-deja/g++.mike/virt5.C new file mode 100644 index 000000000..cee8b3cb1 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/virt5.C @@ -0,0 +1,54 @@ +// { dg-do run } +// Ensure that virtual base upcast and downcasting works on this +// conversions during virtual function dispatch at ctor/dtor time +// when dynamic vtable fixups for deltas are needed. + +int fail = 0; + +struct BASE1 { + virtual ~BASE1 () { } +}; + +class MID; + +class BASE2 { +public: + virtual MID *VFN (){ return 0; } +}; + +class MIBASE : public BASE1, public BASE2 { }; + +class VBB : public MIBASE { +public: + virtual long get_STATE () const = 0; + void print_STATE() { if (get_STATE () != 87654321) fail = 1; } +}; + +class VBD : public virtual VBB { + long STATE; +public: + long get_STATE() const { return STATE; } + VBD() { STATE = 87654321; } + ~VBD() { STATE = 87654321; } +}; + +class MID : public virtual VBD { +public: + MID () { print_STATE(); } + ~MID () { print_STATE(); } + virtual MID *VFN() { return this; } +}; + +class LAST : public MID { +public: + LAST () { print_STATE(); } + ~LAST () { print_STATE(); } +}; + +int main() { + MIBASE *o = new LAST; + MID *p = o->VFN(); + p->print_STATE(); + delete o; + return fail; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/virt6.C b/gcc/testsuite/g++.old-deja/g++.mike/virt6.C new file mode 100644 index 000000000..db13bb2be --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/virt6.C @@ -0,0 +1,40 @@ +// { dg-do run } +// This testcase ensures that we can build vtable names for complex MI +// classes. + +class C_A { +public: + virtual int foo(void *) { return 0; } +} a; + +class C_B : public C_A { +} b; + +class C_C : public C_A { +} c; + +class C_D : public C_A { +} d; + +class C_E : public C_C, public C_B { +public: + virtual int foo(void *) { return 0; } +} e; + +class C_F : public C_D, public C_B { +public: + virtual int foo(void *) { return 0; } +} f; + +class C_G : public C_A { +public: + virtual int foo(void *) { return 0; } +} g; + +class C_H : public C_G, public C_E, public C_F { +public: + virtual int foo(void *) { return 0; } +} h; + +int main() { +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/visibility-1.C b/gcc/testsuite/g++.old-deja/g++.mike/visibility-1.C new file mode 100644 index 000000000..40e742708 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/visibility-1.C @@ -0,0 +1,22 @@ +/* Test visibility attribute on template member function + instantiations. */ + +/* { dg-do compile } */ +/* { dg-options "-fvisibility=hidden" } */ +/* { dg-require-visibility "" } */ +/* { dg-final { scan-not-hidden "_ZN7myClassIiE3maxEii" } } */ + +#define EXPORT __attribute__((visibility("default"))) + +template <class T> +class EXPORT myClass { +public: + T max (T t1, T t2); +}; + +template <class T> +T myClass<T>::max (T t1, T t2) { + return (t1 > t2 ? t1 : t2); +} + +template class myClass<int>; diff --git a/gcc/testsuite/g++.old-deja/g++.mike/vtable1.C b/gcc/testsuite/g++.old-deja/g++.mike/vtable1.C new file mode 100644 index 000000000..fc07a9ea5 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/vtable1.C @@ -0,0 +1,12 @@ +// { dg-do link } +// { dg-options "-fno-implement-inlines " } +struct type { + virtual void m1(); + virtual void m2() { } +}; + +void type::m1() { } + +int main() { + type t; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/warn1.C b/gcc/testsuite/g++.old-deja/g++.mike/warn1.C new file mode 100644 index 000000000..5d6fdec52 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/warn1.C @@ -0,0 +1,14 @@ +// { dg-do assemble } +// { dg-options "-Wall -Wno-int-to-pointer-cast" } + +typedef char * charptr; +typedef __SIZE_TYPE__ size_t; +char c[]={'A','B','C','D'}; +int i=size_t(&c); +int *pp=&i; +void foo() { } +int main() +{ + charptr(*pp)++; // { dg-error "lvalue" } + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/warn2.C b/gcc/testsuite/g++.old-deja/g++.mike/warn2.C new file mode 100644 index 000000000..d505b29ae --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/warn2.C @@ -0,0 +1,26 @@ +// { dg-do assemble } +// { dg-options "-Wall" } + +enum Boolean { + Ok = 0, + NotOk = 1, +}; + +enum OpResult { + Succeeded = 0, + TempFail = 1, + PermFail = 2, +}; + +OpResult fn1() { + return TempFail; +} + +extern void foo(); + +int +main () { + if (fn1() == Ok) { // { dg-warning "" } + foo(); + } +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/warn3.C b/gcc/testsuite/g++.old-deja/g++.mike/warn3.C new file mode 100644 index 000000000..74fe17045 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/warn3.C @@ -0,0 +1,12 @@ +// { dg-do assemble } +// { dg-options "-Wall" } + +class B { +public: + B(int) { } +}; + +class D : public B { + int member; // { dg-warning "" } reordered + D() : member(0), B(member) { } // { dg-warning "" } reordered +}; diff --git a/gcc/testsuite/g++.old-deja/g++.mike/warn4.C b/gcc/testsuite/g++.old-deja/g++.mike/warn4.C new file mode 100644 index 000000000..d94de4506 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/warn4.C @@ -0,0 +1,2 @@ +// { dg-do assemble } +void foo (int a, int a) { } // { dg-error "" } diff --git a/gcc/testsuite/g++.old-deja/g++.mike/warn5.C b/gcc/testsuite/g++.old-deja/g++.mike/warn5.C new file mode 100644 index 000000000..af94d53b3 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/warn5.C @@ -0,0 +1,21 @@ +// { dg-do assemble } +// { dg-options "-Wpointer-arith" } + +double X(const double x) { return x; } +double Y() { return 1.0; } +double Z() { return 2.0; } + +struct A { + void bar() { } + void foo() { } +}; + +typedef void (A::*pmf)(); + +static int mememe = &A::foo - &A::bar; // { dg-error "invalid operands" } +pmf b = &A::foo-1; // { dg-error "invalid operands" } + +int main() { + double y; + y=X(Y-Z); // { dg-error "pointer to a function" } +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/warn6.C b/gcc/testsuite/g++.old-deja/g++.mike/warn6.C new file mode 100644 index 000000000..9c694d625 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/warn6.C @@ -0,0 +1,42 @@ +// { dg-do assemble } +// { dg-options "-Woverloaded-virtual" } + +struct B4 { + virtual void bothfardiff(float); // { dg-warning "" } was hidden +}; + +struct B3 : public B4 { +}; + +struct B2 { +}; + +struct B { + virtual void baseonly(int); + + virtual void bothsame(int); + + virtual void bothdiff(float); // { dg-warning "" } was hidden + + virtual void both2same(int); + virtual void both2same(float); + + virtual void both12diff(int); + virtual void both12diff(float); // { dg-warning "" } was hidden +}; + +struct D : public B, public B2, public B3 { + virtual void derivedonly(int); + + virtual void bothsame(int); + + virtual void bothdiff(int); // { dg-warning "" } + + virtual void both2same(int); + virtual void both2same(float); + + virtual void both12diff(int); // { dg-warning "" } + + virtual void bothfardiff(int); // { dg-warning "" } +}; + diff --git a/gcc/testsuite/g++.old-deja/g++.mike/warn7.C b/gcc/testsuite/g++.old-deja/g++.mike/warn7.C new file mode 100644 index 000000000..3fb78895a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/warn7.C @@ -0,0 +1,14 @@ +// { dg-do assemble } +// { dg-options "-Wall" } + +const int& foo() { + extern int bar; + + return bar; +} + +const int* baz() { + extern int bar; + + return &bar; +} diff --git a/gcc/testsuite/g++.old-deja/g++.mike/warn8.C b/gcc/testsuite/g++.old-deja/g++.mike/warn8.C new file mode 100644 index 000000000..ea9dfb868 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/warn8.C @@ -0,0 +1,20 @@ +// { dg-do assemble } +// { dg-options "-Waddress" } + +struct foo { + bool test(); +}; +bool func(); + +void test() { + foo A; + bool (foo::* pmf)() = &foo::test; + bool (*pf)() = func; + + if (A.test) ; // { dg-error "" } + if (func) ; // { dg-warning "" } + if (bool(A.test)) ; // { dg-error "" } + if (bool(func)) ; // { dg-warning "" } + if (pmf) ; + if (pf) ; +} diff --git a/gcc/testsuite/g++.old-deja/g++.niklas/README b/gcc/testsuite/g++.old-deja/g++.niklas/README new file mode 100644 index 000000000..83bc592a7 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.niklas/README @@ -0,0 +1,18 @@ +Date: Fri, 22 Jan 93 15:20:55 +0100 +From: niklas@della.appli.se (Niklas Hallqvist) +Message-Id: <9301221420.AA18489@della.appli.se> +Subject: g++.niklas DejaGnu sharfile + +These are my testcases in DejaGnu format. + +The tests which have "passed" in the groups variable do actually pass +on my local G++ so if there is a specific "passed" test you'd like to +see working in your version of G++ but it doesn't pass, contact me and +I'll dig up the specific patches you'll need. + +I have about a hundred or so unsorted testcases which are not +included in this archive, due to lack of time and boredom stemming +from writing .exp-files. But they will show up eventually. + +All these files, and this file are Copyright FSF 1993, 2007 and fall +under the GPL version 3 or later. diff --git a/gcc/testsuite/g++.old-deja/g++.niklas/t113.C b/gcc/testsuite/g++.old-deja/g++.niklas/t113.C new file mode 100644 index 000000000..aa984d49d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.niklas/t113.C @@ -0,0 +1,7 @@ +// { dg-do assemble } +// GROUPS passed niklas explicit-construct virtual-base +struct A {}; +struct B : virtual A { B(); }; +struct C : B {}; +struct D { D(C&); }; +D d(C()); diff --git a/gcc/testsuite/g++.old-deja/g++.niklas/t114.C b/gcc/testsuite/g++.old-deja/g++.niklas/t114.C new file mode 100644 index 000000000..9cb4abf59 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.niklas/t114.C @@ -0,0 +1,5 @@ +// { dg-do assemble } +// GROUPS passed niklas explicit-construct +struct A { A(); }; +struct B { B(A&); }; +B b(A()); diff --git a/gcc/testsuite/g++.old-deja/g++.niklas/t115.C b/gcc/testsuite/g++.old-deja/g++.niklas/t115.C new file mode 100644 index 000000000..46f757567 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.niklas/t115.C @@ -0,0 +1,7 @@ +// { dg-do assemble } +// GROUPS passed niklas virtual-base +struct A { A(); virtual void f(); }; +struct B : virtual A { B(); }; +struct C : B {}; +C *c = new C; + diff --git a/gcc/testsuite/g++.old-deja/g++.niklas/t118.C b/gcc/testsuite/g++.old-deja/g++.niklas/t118.C new file mode 100644 index 000000000..2319a338b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.niklas/t118.C @@ -0,0 +1,4 @@ +// { dg-do assemble } +// GROUPS niklas pt +template <class T> class C1 {}; +class C1<int> C1_int_object; diff --git a/gcc/testsuite/g++.old-deja/g++.niklas/t119.C b/gcc/testsuite/g++.old-deja/g++.niklas/t119.C new file mode 100644 index 000000000..8b411d8ee --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.niklas/t119.C @@ -0,0 +1,6 @@ +// { dg-do assemble } +// GROUPS passed niklas i386 +unsigned long foo(unsigned long x) +{ + return x & ~0104000; +} diff --git a/gcc/testsuite/g++.old-deja/g++.niklas/t120.C b/gcc/testsuite/g++.old-deja/g++.niklas/t120.C new file mode 100644 index 000000000..7a54e051b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.niklas/t120.C @@ -0,0 +1,6 @@ +// { dg-do assemble } +// GROUPS passed niklas ellipsis +typedef void (*T) (...); +void f (); +struct S { void g (T); void h() { g(f); } };// { dg-error "match" "match" } +// { dg-message "candidate|S::g|no known conversion" "match candidate text" { target *-*-* } 5 } diff --git a/gcc/testsuite/g++.old-deja/g++.niklas/t121.C b/gcc/testsuite/g++.old-deja/g++.niklas/t121.C new file mode 100644 index 000000000..b0c9253da --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.niklas/t121.C @@ -0,0 +1,6 @@ +// { dg-do assemble } +// GROUPS passed niklas ellipsis +void f (); +void g1 (void (*) (...)); void h1 () { g1 (f); }// { dg-error "invalid conversion" } +struct S { void g2 (void (*) (...)); void h2 () { g2 (f); } };// { dg-error "match" "match" } +// { dg-message "candidate|S::g2|no known conversion" "match candidate text" { target *-*-* } 5 } diff --git a/gcc/testsuite/g++.old-deja/g++.niklas/t122.C b/gcc/testsuite/g++.old-deja/g++.niklas/t122.C new file mode 100644 index 000000000..4decaf1e9 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.niklas/t122.C @@ -0,0 +1,14 @@ +// { dg-do assemble } +// GROUPS passed niklas dwarf +struct S { S(); }; + +inline void +foo ( + S a, + S b + ) +{} + +void +bar (S s1, S s2) +{ foo (s1, s2); } diff --git a/gcc/testsuite/g++.old-deja/g++.niklas/t123.C b/gcc/testsuite/g++.old-deja/g++.niklas/t123.C new file mode 100644 index 000000000..b2019f539 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.niklas/t123.C @@ -0,0 +1,4 @@ +// { dg-do assemble } +// GROUPS passed niklas dwarf +struct S { S(); }; +void f(S) {} diff --git a/gcc/testsuite/g++.old-deja/g++.niklas/t124.C b/gcc/testsuite/g++.old-deja/g++.niklas/t124.C new file mode 100644 index 000000000..7e48fc0cf --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.niklas/t124.C @@ -0,0 +1,10 @@ +// { dg-do assemble } +// GROUPS passed niklas nested-types static-members +struct A +{ + static void f (); + struct B + { + static void g () { f (); } + }; +}; diff --git a/gcc/testsuite/g++.old-deja/g++.niklas/t125.C b/gcc/testsuite/g++.old-deja/g++.niklas/t125.C new file mode 100644 index 000000000..90fb2b975 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.niklas/t125.C @@ -0,0 +1,10 @@ +// { dg-do assemble } +// GROUPS passed niklas nested-types static-members +struct A +{ + static void f (); + struct B + { + void h () { f (); } + }; +}; diff --git a/gcc/testsuite/g++.old-deja/g++.niklas/t126.C b/gcc/testsuite/g++.old-deja/g++.niklas/t126.C new file mode 100644 index 000000000..00b1ca6df --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.niklas/t126.C @@ -0,0 +1,11 @@ +// { dg-do assemble } +// GROUPS passed niklas nested-types static-members +struct A +{ + static void f (); + struct B + { + void g () {} + void h () {} + }; +}; diff --git a/gcc/testsuite/g++.old-deja/g++.niklas/t127.C b/gcc/testsuite/g++.old-deja/g++.niklas/t127.C new file mode 100644 index 000000000..0499faa07 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.niklas/t127.C @@ -0,0 +1,4 @@ +// { dg-do assemble } +// GROUPS passed niklas nested-types +struct A { struct B { ~B (); }; }; +A::B::~B () {} diff --git a/gcc/testsuite/g++.old-deja/g++.niklas/t128.C b/gcc/testsuite/g++.old-deja/g++.niklas/t128.C new file mode 100644 index 000000000..cf0a4f71b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.niklas/t128.C @@ -0,0 +1,6 @@ +// { dg-do assemble } +// GROUPS niklas uncaught default-construct +struct A { A (int); }; +struct B : A {}; // { dg-message "note" } without ctor // ERROR - candidates +void f () { B (0); }// { dg-error "match" } .* +// { dg-message "candidate" "candidate note" { target *-*-* } 5 } diff --git a/gcc/testsuite/g++.old-deja/g++.niklas/t129.C b/gcc/testsuite/g++.old-deja/g++.niklas/t129.C new file mode 100644 index 000000000..66ffbce51 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.niklas/t129.C @@ -0,0 +1,6 @@ +// { dg-do assemble } +// GROUPS passed niklas nested-types +struct X { +struct A { A (int); }; +struct B : A { B (int a) : A (a) {} }; +}; diff --git a/gcc/testsuite/g++.old-deja/g++.niklas/t130.C b/gcc/testsuite/g++.old-deja/g++.niklas/t130.C new file mode 100644 index 000000000..1df676057 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.niklas/t130.C @@ -0,0 +1,4 @@ +// { dg-do assemble } +// GROUPS passed niklas nested-types +struct A; +struct B { struct A { A(int); }; struct C : A { C() : A (0) {} }; }; diff --git a/gcc/testsuite/g++.old-deja/g++.niklas/t131.C b/gcc/testsuite/g++.old-deja/g++.niklas/t131.C new file mode 100644 index 000000000..b29b654d7 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.niklas/t131.C @@ -0,0 +1,4 @@ +// { dg-do assemble } +// GROUPS passed niklas static-members +struct A { static A a; }; +A f () { return A::a; } diff --git a/gcc/testsuite/g++.old-deja/g++.niklas/t132.C b/gcc/testsuite/g++.old-deja/g++.niklas/t132.C new file mode 100644 index 000000000..04653899b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.niklas/t132.C @@ -0,0 +1,5 @@ +// { dg-do assemble } +// GROUPS passed niklas construct-destruct +struct S { S (); ~S (); }; +void f () { while (1) S s; } + diff --git a/gcc/testsuite/g++.old-deja/g++.niklas/t133.C b/gcc/testsuite/g++.old-deja/g++.niklas/t133.C new file mode 100644 index 000000000..b9ad346aa --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.niklas/t133.C @@ -0,0 +1,4 @@ +// { dg-do assemble } +// GROUPS passed niklas nested-types +struct A { struct B { void operator = (const B&); }; }; +void A::B::operator = (const B&) {} diff --git a/gcc/testsuite/g++.old-deja/g++.niklas/t134.C b/gcc/testsuite/g++.old-deja/g++.niklas/t134.C new file mode 100644 index 000000000..67273a471 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.niklas/t134.C @@ -0,0 +1,4 @@ +// { dg-do assemble } +// GROUPS passed niklas static-members +extern "C" int f (); +struct A { static void f () {} }; diff --git a/gcc/testsuite/g++.old-deja/g++.niklas/t135.C b/gcc/testsuite/g++.old-deja/g++.niklas/t135.C new file mode 100644 index 000000000..566b0ca1b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.niklas/t135.C @@ -0,0 +1,27 @@ +// { dg-do compile } +// GROUPS niklas pt friend +template <class T> class C1 +{ +public: + void diddle_C2 (); +}; + +class C2 +{ + int data_member; // { dg-error "" } + friend class C1; // { dg-error "" } +}; + +class C2 C2_object; + +template <class T> void C1<T>::diddle_C2 () +{ + C2_object.data_member = 99; // { dg-error "" } +} + +C1<int> C1_int_object; + +void foobar () +{ + C1_int_object.diddle_C2 (); +} diff --git a/gcc/testsuite/g++.old-deja/g++.niklas/t136.C b/gcc/testsuite/g++.old-deja/g++.niklas/t136.C new file mode 100644 index 000000000..24f8a57fd --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.niklas/t136.C @@ -0,0 +1,4 @@ +// { dg-do assemble } +// GROUPS niklas overloading +extern "C" void f (char*); +void f (const char*) {} diff --git a/gcc/testsuite/g++.old-deja/g++.niklas/t137.C b/gcc/testsuite/g++.old-deja/g++.niklas/t137.C new file mode 100644 index 000000000..d7c5ca976 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.niklas/t137.C @@ -0,0 +1,6 @@ +// { dg-do assemble } +// GROUPS passed niklas nested-types +struct A { + struct B { void f (); }; + struct C : B { void f () { B::f (); } }; +}; diff --git a/gcc/testsuite/g++.old-deja/g++.niklas/t138.C b/gcc/testsuite/g++.old-deja/g++.niklas/t138.C new file mode 100644 index 000000000..e3d210fff --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.niklas/t138.C @@ -0,0 +1,6 @@ +// { dg-do assemble } +// GROUPS passed niklas hiding +struct A; +void f (A*); +A* A; +void g () { f (A); } diff --git a/gcc/testsuite/g++.old-deja/g++.niklas/t139.C b/gcc/testsuite/g++.old-deja/g++.niklas/t139.C new file mode 100644 index 000000000..9d7729b25 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.niklas/t139.C @@ -0,0 +1,7 @@ +// { dg-do assemble } +// { dg-options "-w" } +// GROUPS passed niklas hiding ARM +struct stat {}; +stat gstat; +int stat (struct stat*); +void f () { struct stat* ps; stat (ps); } diff --git a/gcc/testsuite/g++.old-deja/g++.niklas/t140.C b/gcc/testsuite/g++.old-deja/g++.niklas/t140.C new file mode 100644 index 000000000..ba803c777 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.niklas/t140.C @@ -0,0 +1,12 @@ +// { dg-do run } +// GROUPS passed niklas hiding local-types +extern "C" int printf (const char*, ...); +int val = 1; +void S () { printf ("FAIL\n"); } +void f () { printf ("PASS\n"); val = 0; } +int main () +{ + struct S { S () { f (); } }; + S (); + return val; +} diff --git a/gcc/testsuite/g++.old-deja/g++.niklas/t141.C b/gcc/testsuite/g++.old-deja/g++.niklas/t141.C new file mode 100644 index 000000000..08e105161 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.niklas/t141.C @@ -0,0 +1,6 @@ +// { dg-do assemble } +// { dg-options "-Wshadow" } +// GROUPS passed niklas scoping ARM +class X { X (int); }; +void X (int);// { dg-warning "hides constructor" } +void f () { X (1); } diff --git a/gcc/testsuite/g++.old-deja/g++.ns/alias1.C b/gcc/testsuite/g++.old-deja/g++.ns/alias1.C new file mode 100644 index 000000000..e46d74dff --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ns/alias1.C @@ -0,0 +1,19 @@ +// { dg-do run } +namespace foo{ + int eine_funktion(int) + { + return 0; + } +} + +namespace foo{ + void eine_funktion(int,int) + {} +} + +namespace bar = foo; + +int main() +{ + return bar::eine_funktion(3); +} diff --git a/gcc/testsuite/g++.old-deja/g++.ns/alias2.C b/gcc/testsuite/g++.old-deja/g++.ns/alias2.C new file mode 100644 index 000000000..56712836c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ns/alias2.C @@ -0,0 +1,8 @@ +// { dg-do assemble } +namespace NS1 +{ + int a; +} + +namespace NS2 = NonExistant; //{ dg-error "" } + diff --git a/gcc/testsuite/g++.old-deja/g++.ns/alias3.C b/gcc/testsuite/g++.old-deja/g++.ns/alias3.C new file mode 100644 index 000000000..45f004984 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ns/alias3.C @@ -0,0 +1,31 @@ +// { dg-do run } +namespace A{ + struct X{}; + void f(X&); + extern int i; + namespace a_very_long_namespace_name{ + int k; + } +} + +namespace B = A; +namespace B = A; +namespace B = B; + +namespace avl = A::a_very_long_namespace_name; + +void B::f(A::X& x) +{ + B::f(x); + f(x); + avl::k = 1; +} + +int B::i = 0; + +int main() +{ + B::X x; + if (B::i) + A::f(x); +} diff --git a/gcc/testsuite/g++.old-deja/g++.ns/alias4.C b/gcc/testsuite/g++.old-deja/g++.ns/alias4.C new file mode 100644 index 000000000..5bff439fc --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ns/alias4.C @@ -0,0 +1,14 @@ +// { dg-do assemble } +namespace A = B; // { dg-error "" } unknown namespace + +namespace C{} +namespace D = C; +namespace D { // { dg-error "" } reopening namespace with alias + void f(); +} + +void C::f(){} // { dg-error "" } previous definition + +void D::f(){} // { dg-error "" } redefinition + +namespace E = C::F; // { dg-error "" } unknown namespace diff --git a/gcc/testsuite/g++.old-deja/g++.ns/alias6.C b/gcc/testsuite/g++.old-deja/g++.ns/alias6.C new file mode 100644 index 000000000..31b10bf38 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ns/alias6.C @@ -0,0 +1,36 @@ +// { dg-do run } +// Check namespace aliases inside blocks +namespace A { + int i; + void f(){ + i = 0; + } +} + +int g(); + +int main () +{ + namespace B = A; + B::i=42; + B::f(); + using namespace B; + f(); + // A::i is now 0, B::i is 1 + return g(); +} + +namespace B { + int i = 1; +} + +int g() +{ + namespace x = A; + if (x::i) + { + namespace x = B; + return x::i; + } + return x::i; +} diff --git a/gcc/testsuite/g++.old-deja/g++.ns/alias7.C b/gcc/testsuite/g++.old-deja/g++.ns/alias7.C new file mode 100644 index 000000000..3145e4a3b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ns/alias7.C @@ -0,0 +1,11 @@ +// { dg-do assemble } +namespace A{ + namespace B{int i;} + using namespace B; +} + +namespace C=A; + +void f(){ + C::i = 1; +} diff --git a/gcc/testsuite/g++.old-deja/g++.ns/anon1.C b/gcc/testsuite/g++.old-deja/g++.ns/anon1.C new file mode 100644 index 000000000..97d3d905d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ns/anon1.C @@ -0,0 +1,13 @@ +// { dg-do run } +namespace{ + void f(); +} + +int main() +{ + f(); +} + +namespace{ + void f(){} +} diff --git a/gcc/testsuite/g++.old-deja/g++.ns/bogus1.C b/gcc/testsuite/g++.old-deja/g++.ns/bogus1.C new file mode 100644 index 000000000..4b927a3d6 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ns/bogus1.C @@ -0,0 +1,10 @@ +// { dg-do assemble } + +namespace N {} + +void f(int N::k); // { dg-error "" } + +class Foo +{ + int N::j; // { dg-error "" } invalid use of `::' +}; diff --git a/gcc/testsuite/g++.old-deja/g++.ns/crash1.C b/gcc/testsuite/g++.old-deja/g++.ns/crash1.C new file mode 100644 index 000000000..eac605b9c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ns/crash1.C @@ -0,0 +1,12 @@ +// { dg-do assemble } + +template <class T> +struct S1 {}; + +namespace N { +} + +struct S2 +{ + typedef N::S1<int> S2_T; // { dg-error "" } parse error +}; diff --git a/gcc/testsuite/g++.old-deja/g++.ns/crash2.C b/gcc/testsuite/g++.old-deja/g++.ns/crash2.C new file mode 100644 index 000000000..72714299b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ns/crash2.C @@ -0,0 +1,11 @@ +// { dg-do assemble } + +// Submitted by bjornw@fairplay.no + + +namespace hei { + class CSomeClass {}; + extern CSomeClass SomeClass; +} + +hei::CSomeClass hei::CSomeClass; // { dg-error "" "" { xfail *-*-* } } should be hei::SomeClass - diff --git a/gcc/testsuite/g++.old-deja/g++.ns/crash3.C b/gcc/testsuite/g++.old-deja/g++.ns/crash3.C new file mode 100644 index 000000000..37211d0db --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ns/crash3.C @@ -0,0 +1,10 @@ +// { dg-do assemble } + +namespace N { + template <class T> struct S; +} + +void f() +{ + N::S(); // { dg-error "" } invalid use of template +} diff --git a/gcc/testsuite/g++.old-deja/g++.ns/crash4.C b/gcc/testsuite/g++.old-deja/g++.ns/crash4.C new file mode 100644 index 000000000..a3c17403e --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ns/crash4.C @@ -0,0 +1,11 @@ +// { dg-do assemble } +// Origin: Geoffrey Furnish <furnish@actel.com> + +namespace N { + + template<class T> class C + { + template<class U> friend class C; + }; + +} diff --git a/gcc/testsuite/g++.old-deja/g++.ns/extern1.C b/gcc/testsuite/g++.old-deja/g++.ns/extern1.C new file mode 100644 index 000000000..c5b7ea747 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ns/extern1.C @@ -0,0 +1,18 @@ +// { dg-do link } + +// Based on a testcase by eyal.ben-david@aks.com + +// An extern declaration of an undeclared object within a function +// introduces the object into the enclosing namespace [basic.link]/7 + +namespace { + void foo() { + extern int xx; + xx = 0; + } + int xx = 1; +} + +int main() { + xx = 2; +} diff --git a/gcc/testsuite/g++.old-deja/g++.ns/friend1.C b/gcc/testsuite/g++.old-deja/g++.ns/friend1.C new file mode 100644 index 000000000..7bdea05dc --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ns/friend1.C @@ -0,0 +1,8 @@ +// { dg-do assemble } +namespace A{ + void f(int); +} + +class X{ + friend void A::f(int); +}; diff --git a/gcc/testsuite/g++.old-deja/g++.ns/friend2.C b/gcc/testsuite/g++.old-deja/g++.ns/friend2.C new file mode 100644 index 000000000..ad6a7d12b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ns/friend2.C @@ -0,0 +1,11 @@ +// { dg-do assemble } +namespace A{ + void foo(); +} + + +namespace B{ +class B{ + friend void A::foo(); +}; +} diff --git a/gcc/testsuite/g++.old-deja/g++.ns/invalid1.C b/gcc/testsuite/g++.old-deja/g++.ns/invalid1.C new file mode 100644 index 000000000..38e4d3305 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ns/invalid1.C @@ -0,0 +1,12 @@ +// { dg-do assemble } +namespace x { } + +void f(int); + +int main() +{ + x(); // { dg-error "" } calling a namespace + x=4; // { dg-error "" } assigning to a namespace + f(x); // { dg-error "" } passing a namespace as parameter +} + diff --git a/gcc/testsuite/g++.old-deja/g++.ns/koenig1.C b/gcc/testsuite/g++.old-deja/g++.ns/koenig1.C new file mode 100644 index 000000000..4b4ddb18a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ns/koenig1.C @@ -0,0 +1,18 @@ +// { dg-do assemble } +class ostream; +extern ostream cout; +namespace foo +{ + struct S + { + int i; + }; + + extern ostream &operator<<(ostream &, const S &); +} + + +void bar(foo::S s) +{ + cout << s ; +} diff --git a/gcc/testsuite/g++.old-deja/g++.ns/koenig2.C b/gcc/testsuite/g++.old-deja/g++.ns/koenig2.C new file mode 100644 index 000000000..16d22a29f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ns/koenig2.C @@ -0,0 +1,10 @@ +// { dg-do assemble } +// { dg-options "" } +// Check association of {error} for Koenig lookup + +struct QString { operator void * (); }; +int foo() +{ + QString bar; + return (bar == __null ); +} diff --git a/gcc/testsuite/g++.old-deja/g++.ns/koenig3.C b/gcc/testsuite/g++.old-deja/g++.ns/koenig3.C new file mode 100644 index 000000000..58b1d571e --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ns/koenig3.C @@ -0,0 +1,22 @@ +// { dg-do run } +//Check association of member pointer in overload resolution. +struct A { + int m_val; + friend int operator ->* (A & other, int A::*pm) + { return 31; } +}; + +int A::*pi = & A::m_val; + +int +main(void) +{ + A c; + c.m_val = 42; + int j = c ->* pi; + + if (j == 31) + return 0; + else + return 1; +} diff --git a/gcc/testsuite/g++.old-deja/g++.ns/koenig4.C b/gcc/testsuite/g++.old-deja/g++.ns/koenig4.C new file mode 100644 index 000000000..d26bd130e --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ns/koenig4.C @@ -0,0 +1,25 @@ +// { dg-do run } +void f(); +void f(int); + +namespace A{ + struct S{ + void f(); + void f(S); + }; + void f(S&){} + void h(S&){} +} + +template<class T> +void g(T t){ + f(t); +} + +int main() +{ + A::S s; + f(s); + g(s); + h(s); +} diff --git a/gcc/testsuite/g++.old-deja/g++.ns/koenig5.C b/gcc/testsuite/g++.old-deja/g++.ns/koenig5.C new file mode 100644 index 000000000..7c56d5cbc --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ns/koenig5.C @@ -0,0 +1,19 @@ +// { dg-do assemble } +// Function pointers are ignored in Koenig lookup. (DR 218) +namespace A{ + void foo(); + struct X{}; + void (*bar)(X*)=0; // { dg-message "A::bar" } +} +using A::X; + +void (*foo)(X*)=0; + +void g() +{ + foo(new X); // ok -- DR 218 says that we find the global + // foo variable first, and therefore do not + // perform argument-dependent lookup. + bar(new X); // { dg-error "not declared" } + // { dg-message "suggested alternative" "suggested alternative" { target *-*-* } 17 } +} diff --git a/gcc/testsuite/g++.old-deja/g++.ns/koenig6.C b/gcc/testsuite/g++.old-deja/g++.ns/koenig6.C new file mode 100644 index 000000000..b5fa9c989 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ns/koenig6.C @@ -0,0 +1,13 @@ +// { dg-do assemble } +namespace A{ + struct X{}; + + X* foo(X a); + void bar(X*){} +} + +int main() +{ + A::X x; + bar(foo(x)); +} diff --git a/gcc/testsuite/g++.old-deja/g++.ns/koenig7.C b/gcc/testsuite/g++.old-deja/g++.ns/koenig7.C new file mode 100644 index 000000000..61b68d803 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ns/koenig7.C @@ -0,0 +1,23 @@ +// { dg-do run } +// Test for Koenig lookup involving overloaded functions. + +namespace N1 { + struct A { }; + void f1(A) {} + void f2(float) {} + void g(void (*)(float)) {} +} + +using N1::f1; +void f1(float) {} + +using N1::f2; +template <class T> +void f2(N1::A, T) {} + +void g(void (*)(int)) {} + +int main() { + g(&f1); // Works? + g(f2); // Works? +} diff --git a/gcc/testsuite/g++.old-deja/g++.ns/koenig8.C b/gcc/testsuite/g++.old-deja/g++.ns/koenig8.C new file mode 100644 index 000000000..351da5171 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ns/koenig8.C @@ -0,0 +1,14 @@ +// { dg-do assemble } +// Copyright (C) 1999 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 15 Dec 1999 <nathan@acm.org> + +// caused an ICE determining whether to perform Koenig lookup +// when checking is enabled + +template<class T> void Zap (T); + +void V3 () +{ + Zap (1); +} + diff --git a/gcc/testsuite/g++.old-deja/g++.ns/koenig9.C b/gcc/testsuite/g++.old-deja/g++.ns/koenig9.C new file mode 100644 index 000000000..46efcb72d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ns/koenig9.C @@ -0,0 +1,14 @@ +// { dg-do assemble } + +// Copyright (C) 2000 Free Software Foundation, Inc. +// Contributed by Theodore.Papadopoulo 23 Jun 2000 <Theodore.Papadopoulo@sophia.inria.fr> + +int count (int); +void *count (char *, char); + +void foo(const char*,...); + +inline void +bar() { + foo("",count); // { dg-error "overloaded function" "multiple overloaded functions" } +} diff --git a/gcc/testsuite/g++.old-deja/g++.ns/lookup1.C b/gcc/testsuite/g++.old-deja/g++.ns/lookup1.C new file mode 100644 index 000000000..bb0dd0a33 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ns/lookup1.C @@ -0,0 +1,3 @@ +// { dg-do assemble } +typedef int __quad_t; +typedef __quad_t __qaddr_t; diff --git a/gcc/testsuite/g++.old-deja/g++.ns/lookup2.C b/gcc/testsuite/g++.old-deja/g++.ns/lookup2.C new file mode 100644 index 000000000..fff53fa90 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ns/lookup2.C @@ -0,0 +1,9 @@ +// { dg-do assemble } +template <class charT> +struct basic_string +{ + charT append (charT c) + { return c; } +}; +typedef char c; +template class basic_string <char>; diff --git a/gcc/testsuite/g++.old-deja/g++.ns/lookup3.C b/gcc/testsuite/g++.old-deja/g++.ns/lookup3.C new file mode 100644 index 000000000..1159a1167 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ns/lookup3.C @@ -0,0 +1,15 @@ +// { dg-do run } +namespace A{ + int i; + int f(); +} + +int A::f() +{ + return i; +} + +int main() +{ + return A::f(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.ns/lookup4.C b/gcc/testsuite/g++.old-deja/g++.ns/lookup4.C new file mode 100644 index 000000000..e4b4be31f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ns/lookup4.C @@ -0,0 +1,23 @@ +// { dg-do assemble } +namespace X{ + typedef int foo; + const int bar=2; + namespace Y{ + void f(foo); + extern int g; + extern int g1; + struct h{ + void i(foo); + }; + } +} + +void X::Y::f(foo) +{ +} + +int X::Y::g = bar; +int X::Y::g1(bar); + +void X::Y::h::i(foo) +{} diff --git a/gcc/testsuite/g++.old-deja/g++.ns/lookup5.C b/gcc/testsuite/g++.old-deja/g++.ns/lookup5.C new file mode 100644 index 000000000..95af00ffd --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ns/lookup5.C @@ -0,0 +1,23 @@ +// { dg-do assemble } +namespace A{ + void f(); +} + +namespace B{ + using namespace A; + void f(int); /* { dg-message "note: declared here" } */ +} + +using namespace B; + +void g() +{ + ::f(); // { dg-error "" } A::f is not found +} + +using namespace A; + +void g1() +{ + ::f(); // ok, it is found now +} diff --git a/gcc/testsuite/g++.old-deja/g++.ns/main1.C b/gcc/testsuite/g++.old-deja/g++.ns/main1.C new file mode 100644 index 000000000..e002d323c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ns/main1.C @@ -0,0 +1,15 @@ +// { dg-do assemble } + +// main is only reserved in the global namespace [basic.start.main]/3 + +// submitted by Gerald Gutierrez <gutier@intergate.bc.ca> + +namespace A { void main () { } } +namespace B { void main () { } } +namespace C { + void main () { } + namespace D { + void main () { } + } +} + diff --git a/gcc/testsuite/g++.old-deja/g++.ns/ns1.C b/gcc/testsuite/g++.old-deja/g++.ns/ns1.C new file mode 100644 index 000000000..3fa883cce --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ns/ns1.C @@ -0,0 +1,17 @@ +// { dg-do run } +namespace foo{ + int eine_funktion(int) + { + return 0; + } + + int eine_funktion(int,int) + { + return 1; + } +} + +int main(int,char**) +{ + return foo::eine_funktion(1); +} diff --git a/gcc/testsuite/g++.old-deja/g++.ns/ns10.C b/gcc/testsuite/g++.old-deja/g++.ns/ns10.C new file mode 100644 index 000000000..bbdfb0897 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ns/ns10.C @@ -0,0 +1,13 @@ +// { dg-do assemble } +namespace bb +{ + int f(int); + + namespace k + { + void foo(int bar) + { + int i=bb:f(bar); // { dg-error "" } namespace + } + } +} diff --git a/gcc/testsuite/g++.old-deja/g++.ns/ns11.C b/gcc/testsuite/g++.old-deja/g++.ns/ns11.C new file mode 100644 index 000000000..2dc0344f3 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ns/ns11.C @@ -0,0 +1,20 @@ +// { dg-do assemble } +// Build don't link +// Check [namespace.memdef]/2 + +namespace A{ + void f(int); + void f(int,int); + int i; // { dg-error "" } .* +} + +void A::f(){} // { dg-error "" } should have been declared before + +namespace B{ + void A::f(int){} // { dg-error "" } B does not surround A +} + +int A::i; // { dg-error "" } redefinition + +void A::f(int,int){} // ok + diff --git a/gcc/testsuite/g++.old-deja/g++.ns/ns12.C b/gcc/testsuite/g++.old-deja/g++.ns/ns12.C new file mode 100644 index 000000000..c5468914f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ns/ns12.C @@ -0,0 +1,23 @@ +// { dg-do run } +namespace fred +{ + int barney(); + extern int wilma; +} + +int fred::barney() +{ + return fred::wilma; +} + +int fred::wilma; + +int barney() +{ + return 1; +} + +int main() +{ + return fred::barney(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.ns/ns13.C b/gcc/testsuite/g++.old-deja/g++.ns/ns13.C new file mode 100644 index 000000000..6f91328ef --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ns/ns13.C @@ -0,0 +1,14 @@ +// { dg-do run } +namespace std{ + void f(){} + void g(); + int i=5; +} + +void std::g() +{} + +int main() +{ + return std::i-5; +} diff --git a/gcc/testsuite/g++.old-deja/g++.ns/ns14.C b/gcc/testsuite/g++.old-deja/g++.ns/ns14.C new file mode 100644 index 000000000..00b901ac1 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ns/ns14.C @@ -0,0 +1,17 @@ +// { dg-do run } + +namespace std{ + int f(){ + return 0; + } +} + +int f() +{ + return 1; +} + +int main() +{ + return std::f(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.ns/ns15.C b/gcc/testsuite/g++.old-deja/g++.ns/ns15.C new file mode 100644 index 000000000..bfe510036 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ns/ns15.C @@ -0,0 +1,2 @@ +// { dg-do assemble } +namespace std {} diff --git a/gcc/testsuite/g++.old-deja/g++.ns/ns16.C b/gcc/testsuite/g++.old-deja/g++.ns/ns16.C new file mode 100644 index 000000000..5860dcb0a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ns/ns16.C @@ -0,0 +1,14 @@ +// { dg-do assemble } + +class Y { +public: + void operator +(int) const; +}; + +namespace X { + extern Y const& z; +} + +void f(void) { + X::z + 1; +} diff --git a/gcc/testsuite/g++.old-deja/g++.ns/ns17.C b/gcc/testsuite/g++.old-deja/g++.ns/ns17.C new file mode 100644 index 000000000..033b0af19 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ns/ns17.C @@ -0,0 +1,13 @@ +// { dg-do assemble } +namespace foo +{ + class c + { + }; +} + +int +foo::c:fn () // { dg-error "" } syntax error +{ +} + diff --git a/gcc/testsuite/g++.old-deja/g++.ns/ns18.C b/gcc/testsuite/g++.old-deja/g++.ns/ns18.C new file mode 100644 index 000000000..192fa4291 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ns/ns18.C @@ -0,0 +1,30 @@ +// { dg-do assemble } +// Origin: Theo Papadopoulo <Theodore.Papadopoulo@sophia.inria.fr> + +namespace Bname { + class B; +} + +template <class T> +class A { + friend class Bname::B; + static const int a = 1; +public: + A() { } +}; + +namespace Bname { + class B { + int a; + public: + template<class T> + B(const T&):a(T::a) { } + }; +} + +int +main() +{ + A<int> a; + Bname::B b(a); +} diff --git a/gcc/testsuite/g++.old-deja/g++.ns/ns19.C b/gcc/testsuite/g++.old-deja/g++.ns/ns19.C new file mode 100644 index 000000000..77e77380b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ns/ns19.C @@ -0,0 +1,7 @@ +// { dg-do assemble } +// Origin: Chip Salzenberg <chip@valinux.com> + +namespace N { +enum { E = 0 }; +static int f() { return E; } +} diff --git a/gcc/testsuite/g++.old-deja/g++.ns/ns2.C b/gcc/testsuite/g++.old-deja/g++.ns/ns2.C new file mode 100644 index 000000000..0f65cbc54 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ns/ns2.C @@ -0,0 +1,27 @@ +// { dg-do run } +namespace foo{ + struct X{ + int i; + void f(); + static int k1,k2; + }; + void X::f(){} + int var; + int X::k1; +} + +using namespace foo; +X zzz; +int X::k2; + +void andere_funktion() +{ + zzz.f(); + var=4; +} + +int main(int,char**) +{ + andere_funktion(); + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.ns/ns3.C b/gcc/testsuite/g++.old-deja/g++.ns/ns3.C new file mode 100644 index 000000000..6cb289b57 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ns/ns3.C @@ -0,0 +1,17 @@ +// { dg-do assemble } +namespace foo{ + void eine_funktion(int) + {} +} + +using namespace foo; + +namespace foo{ + void eine_funktion(int,int) + {} +} + +void andere_funktion() +{ + eine_funktion(3,4); +} diff --git a/gcc/testsuite/g++.old-deja/g++.ns/ns4.C b/gcc/testsuite/g++.old-deja/g++.ns/ns4.C new file mode 100644 index 000000000..c2b8feebb --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ns/ns4.C @@ -0,0 +1,11 @@ +// { dg-do assemble } +namespace A{ + enum foo{a,b,c}; +} +using A::foo; +using A::b; +void g() +{ + foo x; + x=b; +} diff --git a/gcc/testsuite/g++.old-deja/g++.ns/ns5.C b/gcc/testsuite/g++.old-deja/g++.ns/ns5.C new file mode 100644 index 000000000..8ee4c403d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ns/ns5.C @@ -0,0 +1,6 @@ +// { dg-do assemble } +namespace X{ + class Y{}; +} + +X::Y z; diff --git a/gcc/testsuite/g++.old-deja/g++.ns/ns6.C b/gcc/testsuite/g++.old-deja/g++.ns/ns6.C new file mode 100644 index 000000000..211df81eb --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ns/ns6.C @@ -0,0 +1,14 @@ +// { dg-do run } +namespace A{ + int i; + namespace B{ + void f(){i++;} + int i; + void g(){i++;} + } +} + +int main() +{ + return A::i-A::B::i; +} diff --git a/gcc/testsuite/g++.old-deja/g++.ns/ns7.C b/gcc/testsuite/g++.old-deja/g++.ns/ns7.C new file mode 100644 index 000000000..ee834c56b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ns/ns7.C @@ -0,0 +1,26 @@ +// { dg-do assemble } +namespace A{ + struct X{ + int i; + X(){} + X(int j); + void operator=(const X&); + virtual ~X(){} + }; + void X::operator=(const X&o) + { + i=o.i; + } +} + +A::X::X(int j):i(j){} + +namespace A{ + struct Y:public X{ + int j; + Y(int,int); + }; +} + +A::Y::Y(int a,int b):X(a),j(b) +{} diff --git a/gcc/testsuite/g++.old-deja/g++.ns/ns8.C b/gcc/testsuite/g++.old-deja/g++.ns/ns8.C new file mode 100644 index 000000000..7ef3dee25 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ns/ns8.C @@ -0,0 +1,11 @@ +// { dg-do assemble } +namespace B{ + void f(); +} + +using namespace B; + +void g() +{ + ::f(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.ns/ns9.C b/gcc/testsuite/g++.old-deja/g++.ns/ns9.C new file mode 100644 index 000000000..9b181e4fd --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ns/ns9.C @@ -0,0 +1,13 @@ +// { dg-do assemble } +namespace bb +{ + int f(int); + + namespace k + { + void foo(int bar) + { + return bb:f(bar); //{ dg-error "" } syntax error + } + } +} diff --git a/gcc/testsuite/g++.old-deja/g++.ns/overload1.C b/gcc/testsuite/g++.old-deja/g++.ns/overload1.C new file mode 100644 index 000000000..d177e02bb --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ns/overload1.C @@ -0,0 +1,34 @@ +// { dg-do run } +// Unqualified lookup should find all functions. +// Duplicates are ignored as long as they lose during overload resolution. +namespace A{ + int f(){ + return 1; + } + int f(double); +} +namespace B{ + int f(int){ + return 2; + } + int f(double); +} + +int f(int,int) +{ + return 3; +} + +using namespace A; +using namespace B; + +int main() +{ + if(f() != 1) + return 1; + if(f(1) != 2) + return 1; + if(f(0,0) != 3) + return 1; + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.ns/overload2.C b/gcc/testsuite/g++.old-deja/g++.ns/overload2.C new file mode 100644 index 000000000..facfa3f56 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ns/overload2.C @@ -0,0 +1,14 @@ +// { dg-do assemble } +namespace A{ + void f(); // { dg-message "note" } +} + +using namespace A; + +void f(); // { dg-message "note" } + +void g() +{ + f(); // { dg-error "ambiguous" } ambiguous, ::f or A::f ? + // { dg-message "candidate" "candidate note" { target *-*-* } 12 } +} diff --git a/gcc/testsuite/g++.old-deja/g++.ns/overload3.C b/gcc/testsuite/g++.old-deja/g++.ns/overload3.C new file mode 100644 index 000000000..418355396 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ns/overload3.C @@ -0,0 +1,18 @@ +// { dg-do assemble } + +namespace A{ + void f(); +} + +using A::f; + +namespace A{ + void f(int); +} + +using A::f; + +void g() +{ + f(4); +} diff --git a/gcc/testsuite/g++.old-deja/g++.ns/overload4.C b/gcc/testsuite/g++.old-deja/g++.ns/overload4.C new file mode 100644 index 000000000..260817530 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ns/overload4.C @@ -0,0 +1,8 @@ +// { dg-do assemble } +namespace A{ + void f(); +} + +using A::f; +void f(); // { dg-error "" } duplicate declaration + diff --git a/gcc/testsuite/g++.old-deja/g++.ns/overload5.C b/gcc/testsuite/g++.old-deja/g++.ns/overload5.C new file mode 100644 index 000000000..ee86c8b9a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ns/overload5.C @@ -0,0 +1,14 @@ +// { dg-do assemble } +namespace A{ + void f(){} +} + +using A::f; + +void f(int); +void f(){} // { dg-error "" } conflict + +void g() +{ + f(4); +} diff --git a/gcc/testsuite/g++.old-deja/g++.ns/scoped1.C b/gcc/testsuite/g++.old-deja/g++.ns/scoped1.C new file mode 100644 index 000000000..32c20903e --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ns/scoped1.C @@ -0,0 +1,26 @@ +// { dg-do assemble } +// +// Copyright (C) 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 10 Aug 2000 <nathan@codesourcery.com> + +// Bug 354. We ICE'd before saying a namespace isn't an aggregate type. + +namespace mlp +{ + struct base + { + void reset (); + }; +} + +struct eo : mlp:: base +{ +}; + +void foo (eo &ref) +{ + ref.mlp::base::reset (); + ref.base::reset (); + ref.reset (); + ref.mlp::reset (); // { dg-error "" } not an aggregate type +} diff --git a/gcc/testsuite/g++.old-deja/g++.ns/template1.C b/gcc/testsuite/g++.old-deja/g++.ns/template1.C new file mode 100644 index 000000000..61fd72f81 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ns/template1.C @@ -0,0 +1,9 @@ +// { dg-do assemble } +namespace foo { + + template <class T> + class x {}; + +} + +foo::x<int> y; diff --git a/gcc/testsuite/g++.old-deja/g++.ns/template10.C b/gcc/testsuite/g++.old-deja/g++.ns/template10.C new file mode 100644 index 000000000..423822576 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ns/template10.C @@ -0,0 +1,7 @@ +// { dg-do assemble } +// Origin: Manuel Menezes de Sequeira <mms@torga.iscte.pt> + +namespace N { + template <class T> void g() {} +} +void (*pf)() = N::g<int>; diff --git a/gcc/testsuite/g++.old-deja/g++.ns/template11.C b/gcc/testsuite/g++.old-deja/g++.ns/template11.C new file mode 100644 index 000000000..4363773cd --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ns/template11.C @@ -0,0 +1,16 @@ +// { dg-do run } +void foo(){} + +namespace Bar{ + template<class X> + class Y{ + friend void foo(Y<X>){} + }; +} + +int main() +{ + Bar::Y<int> y; + foo(y); + foo(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.ns/template12.C b/gcc/testsuite/g++.old-deja/g++.ns/template12.C new file mode 100644 index 000000000..32dfe0f2c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ns/template12.C @@ -0,0 +1,19 @@ +// { dg-do assemble } +// Templates can be defined outside of the namespace if the have been declared +// inside +namespace bar +{ + template <typename T> + T const foo(T const &); + template<> const int foo<int>(int const &); +} + +template <typename T> +T const +bar::foo(T const &a) +{ + return a; +} + +template<> const int bar::foo<int>(int const &){return 0;} + diff --git a/gcc/testsuite/g++.old-deja/g++.ns/template13.C b/gcc/testsuite/g++.old-deja/g++.ns/template13.C new file mode 100644 index 000000000..a9559c715 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ns/template13.C @@ -0,0 +1,23 @@ +// { dg-do compile } +// Templates defined outside must be declared inside +namespace bar +{ + // trick it to provide some prior declaration + template<class T> + void foo(); // { dg-error "definition" } + template<class T>class X; // { dg-message "note: previous declaration" } +} + +template <typename T> +T const +bar::foo(T const &a) // { dg-error "" "" { xfail *-*-* } } not declared in bar - +{ + return a; +} + +template<> void bar::foo<int>() // { dg-error "different namespace" } +{ +} + +template<class T,class U> +class bar::X{}; // { dg-error "redeclared with 2 template parameter" } diff --git a/gcc/testsuite/g++.old-deja/g++.ns/template14.C b/gcc/testsuite/g++.old-deja/g++.ns/template14.C new file mode 100644 index 000000000..437a8aff0 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ns/template14.C @@ -0,0 +1,14 @@ +// { dg-do assemble } +// Origin: Alex Samuel <samuel@codesourcery.com> + +namespace Outer +{ +template <class T> class Inner; +} + +template <class T> +class Outer::Inner +{ +public: + Inner (); +}; 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 000000000..ea0a677b3 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ns/template15.C @@ -0,0 +1,5 @@ +// { dg-do assemble } +// 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/template16.C b/gcc/testsuite/g++.old-deja/g++.ns/template16.C new file mode 100644 index 000000000..c07cb4486 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ns/template16.C @@ -0,0 +1,15 @@ +// { dg-do assemble } +// Test that pushing into a namespace for a definition doesn't affect +// template instantiations. + + +namespace N { + template <class T> void f () { } + template <class T> struct A { friend void f<T>(); }; +} + +namespace M { + struct B; +} + +struct M::B: public N::A<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 000000000..010a1b030 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ns/template17.C @@ -0,0 +1,37 @@ +// { dg-do assemble } +// +// Copyright (C) 2001, 2003 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)); + +namespace whatever +{ + template <typename T> T end3 (T); +} + +template <class T> void mycout(const T& data) +{ + using namespace thing; + using namespace whatever; + + fn (data, end2); + fn (data, end3); +} + +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 000000000..f5a4755e8 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ns/template18.C @@ -0,0 +1,24 @@ +// { dg-do link } +// 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/template2.C b/gcc/testsuite/g++.old-deja/g++.ns/template2.C new file mode 100644 index 000000000..c88293e43 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ns/template2.C @@ -0,0 +1,14 @@ +// { dg-do assemble } +//Inheritance from templates which are namespace members +namespace foo { + + template <class T> + struct x { + x(){} + }; + +} + +class y : public foo::x<int> {}; + +y r; diff --git a/gcc/testsuite/g++.old-deja/g++.ns/template3.C b/gcc/testsuite/g++.old-deja/g++.ns/template3.C new file mode 100644 index 000000000..d6b51a91d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ns/template3.C @@ -0,0 +1,22 @@ +// { dg-do run } +//Check instantiation of templates outside their namespace +namespace A{ +template <class T>void g(){} +template <class T> struct B { + B(){ + f(); + } + void f() + { + g<T>(); + } +}; +} + +template class A::B<int>; +A::B<int> s; + +int main() +{ + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.ns/template4.C b/gcc/testsuite/g++.old-deja/g++.ns/template4.C new file mode 100644 index 000000000..0291417ba --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ns/template4.C @@ -0,0 +1,18 @@ +// { dg-do run } +namespace NS +{ +template <typename T> +void solver (){} + +} + +template<typename T> +void solver(){} + +int main() +{ + solver<double>(); + NS::solver<double>(); +} + + diff --git a/gcc/testsuite/g++.old-deja/g++.ns/template5.C b/gcc/testsuite/g++.old-deja/g++.ns/template5.C new file mode 100644 index 000000000..8338fef10 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ns/template5.C @@ -0,0 +1,34 @@ +// { dg-do run } +//Check whether namespace-scoped template instantiations +//are mangled differently. + +namespace X{ + template<class T> + struct Y{ + int f(T){ + return 1; + } + template<class X>void g(){} + }; +} + +template<class T> +struct Y{ + int f(T){ + return 2; + } +}; + +int main() +{ + X::Y<int> z; + if (z.f(4) != 1) + return 1; + z.g<long>(); + + Y<int> z1; + if (z1.f(5) != 2) + return 1; + return 0; +} + diff --git a/gcc/testsuite/g++.old-deja/g++.ns/template6.C b/gcc/testsuite/g++.old-deja/g++.ns/template6.C new file mode 100644 index 000000000..7d85403c7 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ns/template6.C @@ -0,0 +1,24 @@ +// { dg-do assemble } +//reported by Theodore Papadopoulo (Theodore.Papadopoulo@sophia.inria.fr) + +namespace A { + + namespace B { + + template <class T1,class T2> + struct B { + static const unsigned count = 0; + template <class ForwardIter> + void SetError(ForwardIter it,const T1& p1,const T2& p2) const { } + }; + + template <> + const unsigned B<int,int>::count = 2; // { dg-error "" } duplicate init + } +} + +int +main() +{ + unsigned kk = A::B<int,int>::count; // { dg-error "" } not a template: syntax error +} diff --git a/gcc/testsuite/g++.old-deja/g++.ns/template7.C b/gcc/testsuite/g++.old-deja/g++.ns/template7.C new file mode 100644 index 000000000..876096b74 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ns/template7.C @@ -0,0 +1,12 @@ +// { dg-do assemble } + + +// Based on bug report by Eric NICOLAS <nicolas@bnp-eng.remcomp.com> + +namespace foo { + template<class F> struct bar {}; +} + +void baz() { + foo::bar(); // { dg-error "" } template used as expression +} diff --git a/gcc/testsuite/g++.old-deja/g++.ns/template8.C b/gcc/testsuite/g++.old-deja/g++.ns/template8.C new file mode 100644 index 000000000..232bb9e50 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ns/template8.C @@ -0,0 +1,9 @@ +// { dg-do assemble } +namespace X { + template <class T> class foo; +} + +template <class T> +class X::foo { + T worthless; +}; diff --git a/gcc/testsuite/g++.old-deja/g++.ns/template9.C b/gcc/testsuite/g++.old-deja/g++.ns/template9.C new file mode 100644 index 000000000..3914746d7 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ns/template9.C @@ -0,0 +1,41 @@ +// { dg-do run } +// Produces ICE 980519. +// Test case from Dirk Engelmann <Dirk.Engelmann@IWR.Uni-Heidelberg.De> + +namespace vector { + + // allocate memory for vector + + template <class T> + inline T* alloc(const int aWidth) + { + // allocate memory + return new T[aWidth]; + } + +} + +namespace matrix { + + // allocate memory for matrix + template <class T> + T** alloc(const int aWidth,const int aHeight) + { + // allocate memory + T **mat = vector::alloc<T*>(aHeight); + T *data = vector::alloc<T> (aWidth*aHeight); + // set pointer + for (int i=0; i<aHeight; i++) + mat[i] = &data[aWidth*i]; + // ok + return mat; + } + +} + +int main(void) +{ + // sample + double **m=matrix::alloc<double>(10,20); + +} diff --git a/gcc/testsuite/g++.old-deja/g++.ns/type1.C b/gcc/testsuite/g++.old-deja/g++.ns/type1.C new file mode 100644 index 000000000..a7d4c8152 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ns/type1.C @@ -0,0 +1,18 @@ +// { dg-do assemble } +// Test that using an elaborated-type-specifier in a namespace to refer +// to a class outside the namespace does not cause its name to be considered +// declared in the namespace. + +// Contributed by Jason Merrill <jason@cygnus.com> + +struct A { }; + +int A; + +namespace N { + struct A *f (); +} + +using namespace N; + +struct A *a; 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 000000000..49bb8b2d6 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ns/type2.C @@ -0,0 +1,19 @@ +// { dg-do assemble } +// +// 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++.ns/undef1.C b/gcc/testsuite/g++.old-deja/g++.ns/undef1.C new file mode 100644 index 000000000..f88c07632 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ns/undef1.C @@ -0,0 +1,5 @@ +// { dg-do assemble } +namespace A{ +} + +struct Y: A::S<int>{}; //{ dg-error "" } no such type diff --git a/gcc/testsuite/g++.old-deja/g++.ns/using1.C b/gcc/testsuite/g++.old-deja/g++.ns/using1.C new file mode 100644 index 000000000..71c4b01d6 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ns/using1.C @@ -0,0 +1,3 @@ +// { dg-do assemble } +using namespace bb; // { dg-error "" } .* + diff --git a/gcc/testsuite/g++.old-deja/g++.ns/using10.C b/gcc/testsuite/g++.old-deja/g++.ns/using10.C new file mode 100644 index 000000000..64c353f28 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ns/using10.C @@ -0,0 +1,9 @@ +// { dg-do assemble } +//Based on a report by Helmut Jarausch <jarausch@IGPM.Rwth-Aachen.DE> +template<class> +class foo{}; + +namespace ABC +{ + using ::foo; +} diff --git a/gcc/testsuite/g++.old-deja/g++.ns/using11.C b/gcc/testsuite/g++.old-deja/g++.ns/using11.C new file mode 100644 index 000000000..e00d3b1d1 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ns/using11.C @@ -0,0 +1,9 @@ +// { dg-do assemble } + +class joey { +public: + typedef int SVec; +}; + +using joey::SVec; // { dg-error "" } joey is not a namespace + diff --git a/gcc/testsuite/g++.old-deja/g++.ns/using12.C b/gcc/testsuite/g++.old-deja/g++.ns/using12.C new file mode 100644 index 000000000..343cfefc4 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ns/using12.C @@ -0,0 +1,20 @@ +// { dg-do assemble } +// Origin: Brendan Kehoe <brendan@cygnus.com> + +namespace foo +{ + void x (bool); // { dg-message "note" } + void x (char); // { dg-message "note" } candidates + void x (int); // { dg-message "note" } candidates + void x (double); // { dg-message "note" } candidates +} + +namespace baz { void x (int); } // { dg-message "note" } candidates + +void fn (int i) +{ + using foo::x; + using baz::x; + x(i); // { dg-error "ambiguous" } + // { dg-message "candidate" "candidate note" { target *-*-* } 18 } +} diff --git a/gcc/testsuite/g++.old-deja/g++.ns/using13.C b/gcc/testsuite/g++.old-deja/g++.ns/using13.C new file mode 100644 index 000000000..29867deaa --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ns/using13.C @@ -0,0 +1,24 @@ +// { dg-do run } +namespace A{ + void foo(int){} +} +namespace B{ + void foo(bool){} +} + +void bar() +{ + using B::foo; + using A::foo; + foo(true); +} + +namespace Foo { + template<class N> void Hello(N) {} +} + +int main() { + using Foo::Hello; + Hello(4); + bar(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.ns/using14.C b/gcc/testsuite/g++.old-deja/g++.ns/using14.C new file mode 100644 index 000000000..a5f984768 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ns/using14.C @@ -0,0 +1,15 @@ +// { dg-do assemble } +// Origin: Mark Mitchell <mark@codesourcery.com> + +extern "C" void f (); + +namespace N { +extern "C" void f (); +} + +using N::f; + +void g () +{ + f (); +} diff --git a/gcc/testsuite/g++.old-deja/g++.ns/using2.C b/gcc/testsuite/g++.old-deja/g++.ns/using2.C new file mode 100644 index 000000000..f65f230d5 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ns/using2.C @@ -0,0 +1,5 @@ +// { dg-do assemble } +void f(); +namespace A{ + using ::f; +} diff --git a/gcc/testsuite/g++.old-deja/g++.ns/using3.C b/gcc/testsuite/g++.old-deja/g++.ns/using3.C new file mode 100644 index 000000000..93549a296 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ns/using3.C @@ -0,0 +1,16 @@ +// { dg-do assemble } + +typedef unsigned int atypedef; +struct astruct{}; +void afunction(); +void aovlfunction(); +void aovlfunction(int); +int avariable; + +namespace foo { + using ::atypedef; + using ::astruct; + using ::afunction; + using ::aovlfunction; + using ::avariable; +} diff --git a/gcc/testsuite/g++.old-deja/g++.ns/using4.C b/gcc/testsuite/g++.old-deja/g++.ns/using4.C new file mode 100644 index 000000000..72332f13e --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ns/using4.C @@ -0,0 +1,6 @@ +// { dg-do assemble } +//Build don't link +#include <vector> +namespace csp { +using namespace std::vector; // { dg-error "" } vector is not a namespace +} diff --git a/gcc/testsuite/g++.old-deja/g++.ns/using5.C b/gcc/testsuite/g++.old-deja/g++.ns/using5.C new file mode 100644 index 000000000..ea7d84cc3 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ns/using5.C @@ -0,0 +1,6 @@ +// { dg-do assemble } +namespace a { + class b { + using std::c; //{ dg-error "" } namespace using on class level + }; +} diff --git a/gcc/testsuite/g++.old-deja/g++.ns/using6.C b/gcc/testsuite/g++.old-deja/g++.ns/using6.C new file mode 100644 index 000000000..68cf2da11 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ns/using6.C @@ -0,0 +1,9 @@ +// { dg-do assemble } +#include <vector> + +namespace csp { + using namespace std; + struct X { + vector<int> v; + }; +} diff --git a/gcc/testsuite/g++.old-deja/g++.ns/using7.C b/gcc/testsuite/g++.old-deja/g++.ns/using7.C new file mode 100644 index 000000000..6617bc606 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ns/using7.C @@ -0,0 +1,12 @@ +// { dg-do run } +namespace X{ + void f(int){} +} + +void f(); + +int main() +{ + using X::f; + f(3); +} diff --git a/gcc/testsuite/g++.old-deja/g++.ns/using8.C b/gcc/testsuite/g++.old-deja/g++.ns/using8.C new file mode 100644 index 000000000..1d5e58bc9 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ns/using8.C @@ -0,0 +1,20 @@ +// { dg-do assemble } +namespace M { + int i; +} +namespace N { + using namespace M; +} + +using namespace N; +int j = i; + +namespace O{ + int k; +} + +namespace N { + using namespace O; +} + +int l = k; diff --git a/gcc/testsuite/g++.old-deja/g++.ns/using9.C b/gcc/testsuite/g++.old-deja/g++.ns/using9.C new file mode 100644 index 000000000..9de6b3199 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.ns/using9.C @@ -0,0 +1,24 @@ +// { dg-do assemble } +// Test for proper merging of functions from multiple using directives. + + +namespace standard +{ void print(int) {} + void dump(int) {} +} +namespace A { using standard::print; } +namespace B { using namespace standard; } +namespace User +{ using namespace standard; + using namespace A; + void test() + { print(1); } + // egcs-1.1: call of overloaded `print (int)' is ambiguous +} +namespace User2 +{ using namespace standard; + using namespace B; + void test() + { print(1); } // egcs has no problems here +} + diff --git a/gcc/testsuite/g++.old-deja/g++.oliva/ChangeLog b/gcc/testsuite/g++.old-deja/g++.oliva/ChangeLog new file mode 100644 index 000000000..363ea1795 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.oliva/ChangeLog @@ -0,0 +1,147 @@ +2013-04-12 Release Manager + + * GCC 4.6.4 released. + +2012-03-01 Release Manager + + * GCC 4.6.3 released. + +2011-10-26 Release Manager + + * GCC 4.6.2 released. + +2011-06-27 Release Manager + + * GCC 4.6.1 released. + +2011-03-25 Release Manager + + * GCC 4.6.0 released. + +2005-04-03 Alexandre Oliva <aoliva@redhat.com> + + PR c++/19199 + * expr2.C: Fixed. + +2003-06-04 J"orn Rennecke <joern.rennecke@superh.com> + + * template1.C (bar): Remove xfail marker. + +2002-07-06 Alexandre Oliva <aoliva@redhat.com> + + * linkage1.C, linkage1-main.cc: New test. + +2001-02-15 Alexandre Oliva <aoliva@redhat.com> + + * friend1.C: New test. + +2000-05-28 Alexandre Oliva <aoliva@cygnus.com> + + * expr2.C: New test. + +2000-04-19 Alexandre Oliva <oliva@lsd.ic.unicamp.br> + + * stkalign.C: New test. + +1999-12-22 Alexandre Oliva <oliva@lsd.ic.unicamp.br> + + * nameret2.C: New test. + + * nameret1.C: New test. + + * template10.C: New test. + +1999-11-21 Alexandre Oliva <oliva@lsd.ic.unicamp.br> + + * delete2.C, delete3.C, delete4.C, delete5.C: New tests. + +1999-11-19 Alexandre Oliva <oliva@lsd.ic.unicamp.br> + + * template7.C: Crash test passes, bug error is now bogus. + +1999-11-11 Alexandre Oliva <oliva@lsd.ic.unicamp.br> + + * template9.C: New test. + +1999-09-18 Alexandre Oliva <oliva@lsd.ic.unicamp.br> + + * overload1.C: New test. + + * inline1.C: New test. + +1999-08-25 Alexandre Oliva <oliva@dcc.unicamp.br> + + * thunk1.C: New test. + +1999-08-06 Alexandre Oliva <oliva@dcc.unicamp.br> + + * dwarf2.C, dwarf3.C: Added XFAIL for Solaris/x86. Removed + -gdwarf. + * dwarf1.C: Removed -gdwarf. + +1999-08-05 Alexandre Oliva <oliva@dcc.unicamp.br> + + * new1.C, template8.C: Removed XFAIL. + * template3.C: Re-introduced XFAIL. :-( + +1999-08-03 Alexandre Oliva <oliva@dcc.unicamp.br> + + * ext1.C: New test. + + * dwarf1.C, dwarf2.C, dwarf3.C: New tests. + +1999-07-20 Alexandre Oliva <oliva@dcc.unicamp.br> + + * template8.C, typeof1.C: New test. + +1999-07-17 Alexandre Oliva <oliva@dcc.unicamp.br> + + * template6.C, delete1.C, template7.C: New test. + +1999-07-13 Alexandre Oliva <oliva@dcc.unicamp.br> + + * template5.C: New test. + + * template4.C: New test. + + * expr1.C: New test. + + * partspec1.C: New test. + +1999-07-05 Alexandre Oliva <oliva@dcc.unicamp.br> + + * typename1.C, typename2.C: New tests. + + * template3.C: Fixed. + + * ns3.C: New test. + +1999-07-03 Alexandre Oliva <oliva@dcc.unicamp.br> + + * ctor1.C: New test. + + * template3.C: New test. + +1999-07-02 Alexandre Oliva <oliva@dcc.unicamp.br> + + * ns1.C: Typo. + * ns2.C: New test. + + * template2.C: New test. + + * ns1.C: New test. + +1999-07-01 Alexandre Oliva <oliva@dcc.unicamp.br> + + * new1.C: New test. + + * partord1.C: New test. + + * template1.C: New test. + + +Copyright (C) 1999, 2000, 2001, 2002, 2003, 2005 Free Software Foundation, Inc. + +Copying and distribution of this file, with or without modification, +are permitted in any medium without royalty provided the copyright +notice and this notice are preserved. diff --git a/gcc/testsuite/g++.old-deja/g++.oliva/ctor1.C b/gcc/testsuite/g++.old-deja/g++.oliva/ctor1.C new file mode 100644 index 000000000..d8ad0c74d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.oliva/ctor1.C @@ -0,0 +1,19 @@ +// { dg-do assemble } + +// Copyright (C) 1999 Free Software Foundation + +// by Alexandre Oliva <oliva@dcc.unicamp.br> +// based on bug report by Harri Porten <porten@tu-harburg.de> + +struct A { + A() : x; // { dg-error "" } missing body +}; + +struct B { + void m() {} +}; + +struct C { + // The error message below says it is within A::B::m()! + void n() {} +}; diff --git a/gcc/testsuite/g++.old-deja/g++.oliva/delete1.C b/gcc/testsuite/g++.old-deja/g++.oliva/delete1.C new file mode 100644 index 000000000..368a87a2a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.oliva/delete1.C @@ -0,0 +1,31 @@ +// { dg-do assemble } + +// Copyright (C) 1999, 2001 Free Software Foundation + +// by Alexandre Oliva <oliva@dcc.unicamp.br> +// simplified from bug report by K. Haley <khaley@bigfoot.com> +// based on analysis by Martin v. Loewis + +// [class.dtor]/11: delete must be implicitly checked for +// accessibility only in the definition of virtual destructors, +// implicitly defined or not. + +struct foo { + foo() {} +private: + void operator delete(void *) {} // { dg-error "" } private +} foo_; + +struct bar : foo { + ~bar() { + delete this; // { dg-error "" } delete is private + // An implicit invocation of delete is emitted in destructors, but + // it should only be checked in virtual destructors + } // { dg-bogus "" } not virtual +} bar_; + +struct baz : foo { + virtual ~baz() {} // { dg-error "" } delete is private in vdtor +} baz_; + +struct bad : baz {} bad_; // { dg-message "" } delete is private in vdtor diff --git a/gcc/testsuite/g++.old-deja/g++.oliva/delete2.C b/gcc/testsuite/g++.old-deja/g++.oliva/delete2.C new file mode 100644 index 000000000..4a5cda45e --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.oliva/delete2.C @@ -0,0 +1,26 @@ +// { dg-do run } +// Copyright (C) 1999 Free Software Foundation + +// by Alexandre Oliva <oliva@lsd.ic.unicamp.br> +// distilled from bug report by Barry M. Caceres <barryc@itravelpartners.com> + +// Test whether dtors of vbases are called on delete[]. + +extern "C" void abort(); +extern "C" void exit(int); + +struct Foo { + ~Foo() { + exit(0); + } +}; + +struct Bar : virtual Foo { +}; + +int main() { + delete [] new Bar[1]; + abort(); +} + + diff --git a/gcc/testsuite/g++.old-deja/g++.oliva/delete3.C b/gcc/testsuite/g++.old-deja/g++.oliva/delete3.C new file mode 100644 index 000000000..39b6fbe9e --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.oliva/delete3.C @@ -0,0 +1,38 @@ +// { dg-do run } +// Copyright (C) 1999 Free Software Foundation + +// by Alexandre Oliva <oliva@lsd.ic.unicamp.br> + +// Test whether dtors of vbases are called on throw within new[]. +// Variant of delete2.C. + +extern "C" void abort(); +extern "C" void exit(int); + +struct Foo { + static bool first; + + Foo() { + if (first) + first = false; + else + throw first; + } + + ~Foo() { + exit(0); + } +}; + +bool Foo::first = true; + +struct Bar : virtual Foo { +}; + +int main() { + try { + delete [] new Bar[2]; + } catch (...) { + } + abort(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.oliva/delete4.C b/gcc/testsuite/g++.old-deja/g++.oliva/delete4.C new file mode 100644 index 000000000..83084a173 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.oliva/delete4.C @@ -0,0 +1,30 @@ +// { dg-do run } +// Copyright (C) 1999 Free Software Foundation + +// by Alexandre Oliva <oliva@lsd.ic.unicamp.br> + +// Test whether dtors of vbases are called from dtor of aggregate of array. +// Variant of delete2.C and delete3.C. + +extern "C" void abort(); +extern "C" void exit(int); + +struct Foo { + ~Foo() { + exit(0); + } +}; + +struct Bar : virtual Foo { +}; + +struct Baz { + Bar i[1]; +}; + +int main() { + Baz(); + abort(); +} + + diff --git a/gcc/testsuite/g++.old-deja/g++.oliva/delete5.C b/gcc/testsuite/g++.old-deja/g++.oliva/delete5.C new file mode 100644 index 000000000..daf2b53a7 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.oliva/delete5.C @@ -0,0 +1,30 @@ +// { dg-do run } +// Copyright (C) 1999 Free Software Foundation + +// by Alexandre Oliva <oliva@lsd.ic.unicamp.br> + +// Test whether dtors of vbases are called from dtor of auto array. +// Variant of delete2.C, delete3.C and delete4.C. + +extern "C" void abort(); +extern "C" void exit(int); + +struct Foo { + ~Foo() { + exit(0); + } +}; + +struct Bar : virtual Foo { +}; + +void foo() { + Bar i[1]; +} + +int main() { + foo(); + abort(); +} + + diff --git a/gcc/testsuite/g++.old-deja/g++.oliva/dwarf1.C b/gcc/testsuite/g++.old-deja/g++.oliva/dwarf1.C new file mode 100644 index 000000000..3b932f712 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.oliva/dwarf1.C @@ -0,0 +1,15 @@ +// { dg-do assemble } + +// Copyright (C) 1999 Free Software Foundation + +// by Alexandre Oliva <oliva@dcc.unicamp.br> +// based on bug report by Chris McKay <chris.mckay@solipsys.com> + +// Used to fail with dwarf debugging. + +template <class T = void> +struct foo { + static const int ELEMENTS = 1; + int bar[ELEMENTS]; +}; +foo<> bar; diff --git a/gcc/testsuite/g++.old-deja/g++.oliva/dwarf2.C b/gcc/testsuite/g++.old-deja/g++.oliva/dwarf2.C new file mode 100644 index 000000000..c50b1b7d6 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.oliva/dwarf2.C @@ -0,0 +1,10 @@ +// { dg-do assemble } + +// Copyright (C) 1999 Free Software Foundation + +// by Alexandre Oliva <oliva@dcc.unicamp.br> + +// Fails with dwarf debugging. + +typedef __java_boolean jboolean; +void foo() {} diff --git a/gcc/testsuite/g++.old-deja/g++.oliva/dwarf3.C b/gcc/testsuite/g++.old-deja/g++.oliva/dwarf3.C new file mode 100644 index 000000000..bbe5b0c9c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.oliva/dwarf3.C @@ -0,0 +1,25 @@ +// { dg-do assemble } + +// Copyright (C) 1999 Free Software Foundation + +// by Alexandre Oliva <oliva@dcc.unicamp.br> +// based on bug report by Andreas Stolcke <stolcke@speech.sri.com> + +// Fails with dwarf debugging. + +template <class T = void> struct foo { + int data[1]; +}; + +template <class T = void> struct bar { + bar(foo<> *); +}; + +template <class T> bar<T>::bar(foo<> *x) { + *x; +} + +void baz() { + foo<> *baz; + bar<> baar(baz); +} diff --git a/gcc/testsuite/g++.old-deja/g++.oliva/expr1.C b/gcc/testsuite/g++.old-deja/g++.oliva/expr1.C new file mode 100644 index 000000000..2d6e8f96b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.oliva/expr1.C @@ -0,0 +1,12 @@ +// { dg-do assemble } + +// Copyright (C) 1999 Free Software Foundation + +// by Alexandre Oliva <oliva@dcc.unicamp.br> +// simplified from bug report by Tudor Hulubei <tudor.hulubei@ecora.com> + +// gcc 2.95 reports: +// invalid operands `foo' and `int' to binary `operator !=' + +class foo {} bar; +int i = void(bar) ? 1 : 0; // { dg-bogus "" "" { xfail *-*-* } } - operator!= - diff --git a/gcc/testsuite/g++.old-deja/g++.oliva/expr2.C b/gcc/testsuite/g++.old-deja/g++.oliva/expr2.C new file mode 100644 index 000000000..1e63c645b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.oliva/expr2.C @@ -0,0 +1,16 @@ +// { dg-do run } + +// Copyright (C) 2000 Free Software Foundation + +// by Alexandre Oliva <aoliva@cygnus.com> + +int i, j; + +const int &f(const int& I, const int& J) { + // this must not be optimized to I because it's an lvalue + return (I != J) ? I : J; +} + +int main () { + return (&f(i, j) != &j); +} diff --git a/gcc/testsuite/g++.old-deja/g++.oliva/ext1.C b/gcc/testsuite/g++.old-deja/g++.oliva/ext1.C new file mode 100644 index 000000000..1bc37357a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.oliva/ext1.C @@ -0,0 +1,19 @@ +// { dg-do run } +// { dg-options "" } +// Copyright (C) 1999 Free Software Foundation + +// by Alexandre Oliva <oliva@dcc.unicamp.br> +// simplified from bug report by Michael Rosenbruch <Rosenbruch@bfw-online.de> + + +extern "C" void abort(); + +int main () { + char x[1]; + char *y = x ? /* implicit x */ : 0; + /* For some reason, the array x is copied twice, and y points to the + second copy (the first is never used). If x is explicit, no copy + is created, and the program succeeds. */ + if (x != y) + 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 000000000..636260780 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.oliva/friend1.C @@ -0,0 +1,12 @@ +// { dg-do assemble } + +// 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/inline1.C b/gcc/testsuite/g++.old-deja/g++.oliva/inline1.C new file mode 100644 index 000000000..f182b8344 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.oliva/inline1.C @@ -0,0 +1,30 @@ +// { dg-do assemble } + +// Copyright (C) 1999 Free Software Foundation + +// by Alexandre Oliva <oliva@lsd.ic.unicamp.br> +// Derived from GNU lilypond. + + +struct foo { + foo(); + foo(const foo&); + ~foo(); +}; + +struct bar { + foo foo_member; + bar(); + bar(const bar&); + // ~bar(); +}; + +struct baz { + void error (bar s); +}; + +void fail() __attribute__((noreturn)); + +void baz::error (bar s) { + fail(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.oliva/linkage1-main.cc b/gcc/testsuite/g++.old-deja/g++.oliva/linkage1-main.cc new file mode 100644 index 000000000..80d27c36c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.oliva/linkage1-main.cc @@ -0,0 +1,13 @@ +// Copyright 2002 Free Software Foundation + +// Derived by Alexandre Oliva <aoliva@redhat.com> from code posted by +// Mark Mitchell <mark@codesourcery.com> + +typedef struct { + void f(); +} S; + +int main() { + S s; + s.f(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.oliva/linkage1.C b/gcc/testsuite/g++.old-deja/g++.oliva/linkage1.C new file mode 100644 index 000000000..23295ea36 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.oliva/linkage1.C @@ -0,0 +1,20 @@ +// { dg-do link } +// { dg-additional-sources " linkage1-main.cc" } + +// Copyright 2002 Free Software Foundation + +// Derived by Alexandre Oliva <aoliva@redhat.com> from code posted by +// Mark Mitchell <mark@codesourcery.com> + +// Verify that a member of a class is given global linkage when it's a +// member of a function whose name is taken from a typedef, by +// checking that another translation unit can call it. We don't do +// the right things on functions, but we do on data members. + +// { dg-bogus "" "" { xfail *-*-* } 0 } + +typedef struct { + void f(); +} S; + +void S::f() {} diff --git a/gcc/testsuite/g++.old-deja/g++.oliva/nameret1.C b/gcc/testsuite/g++.old-deja/g++.oliva/nameret1.C new file mode 100644 index 000000000..b32deedd4 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.oliva/nameret1.C @@ -0,0 +1,14 @@ +// { dg-do assemble } +// { dg-options "-Wno-deprecated" } +// Copyright (C) 1999, 2000, 2002 Free Software Foundation + +// by Alexandre Oliva <oliva@lsd.ic.unicamp.br> + +// distilled from libg++'s Rational.cc + + +inline int bar () return r {} // { dg-error "" } + +int foo () { + return bar (); +} diff --git a/gcc/testsuite/g++.old-deja/g++.oliva/nameret2.C b/gcc/testsuite/g++.old-deja/g++.oliva/nameret2.C new file mode 100644 index 000000000..e0dfb7e12 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.oliva/nameret2.C @@ -0,0 +1,15 @@ +// { dg-do assemble } +// { dg-options "-O1 -Wno-deprecated" } +// Copyright (C) 1999, 2000, 2002 Free Software Foundation + +// by Alexandre Oliva <oliva@lsd.ic.unicamp.br> + +// distilled from libg++'s Integer.cc + + +inline int bar () return r {} // { dg-error "" } + +int& foo (int& x) { + bar (); + return x; +} diff --git a/gcc/testsuite/g++.old-deja/g++.oliva/new1.C b/gcc/testsuite/g++.old-deja/g++.oliva/new1.C new file mode 100644 index 000000000..86d25f8e6 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.oliva/new1.C @@ -0,0 +1,20 @@ +// { dg-do run } +// Copyright (C) 1999 Free Software Foundation + +// by Alexandre Oliva <oliva@dcc.unicamp.br> + +// based on comp.std.c++ post by Alexander Schiemann <aschiem@math.uni-sb.de> + +// execution test + +#include <new> +#include <stdlib.h> + +struct A { + A() { throw 0; } + void* operator new(size_t size, double = 0.0) { return ::operator new(size);} + void operator delete(void* p, double) { exit(0); } + void operator delete(void* p) { abort(); } +}; + +int main() { try { new A; } catch(...) {} } diff --git a/gcc/testsuite/g++.old-deja/g++.oliva/ns1.C b/gcc/testsuite/g++.old-deja/g++.oliva/ns1.C new file mode 100644 index 000000000..cda0f0e2e --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.oliva/ns1.C @@ -0,0 +1,13 @@ +// { dg-do assemble } + +// Copyright (C) 1999, 2000 Free Software Foundation + +// by Alexandre Oliva <oliva@dcc.unicamp.br> +// based on bug report by Dima Volodin <dvv@dvv.ru> + +void foo(); +namespace bar { + class baz { + friend void ::foo(); // { dg-bogus "" } parse error + }; +} diff --git a/gcc/testsuite/g++.old-deja/g++.oliva/ns2.C b/gcc/testsuite/g++.old-deja/g++.oliva/ns2.C new file mode 100644 index 000000000..0541a3f71 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.oliva/ns2.C @@ -0,0 +1,15 @@ +// { dg-do assemble } + +// Copyright (C) 1999 Free Software Foundation + +// by Alexandre Oliva <oliva@dcc.unicamp.br> +// based on bug report by Dima Volodin <dvv@dvv.ru> +// variation of ns1.C + +void foo(); +namespace bar { + using ::foo; + class baz { + friend void foo(); // { dg-bogus "" "" { xfail *-*-* } } - conflict - + }; +} diff --git a/gcc/testsuite/g++.old-deja/g++.oliva/ns3.C b/gcc/testsuite/g++.old-deja/g++.oliva/ns3.C new file mode 100644 index 000000000..4ddbb3289 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.oliva/ns3.C @@ -0,0 +1,13 @@ +// { dg-do assemble } + +// Copyright (C) 1999 Free Software Foundation + +// by Alexandre Oliva <oliva@dcc.unicamp.br> +// based on bug report by Ovidiu Toader <ovi@physics.utoronto.ca> + + +namespace N { + template <typename T> class A { + template <typename T_> friend class A; + }; +} diff --git a/gcc/testsuite/g++.old-deja/g++.oliva/overload1.C b/gcc/testsuite/g++.old-deja/g++.oliva/overload1.C new file mode 100644 index 000000000..91b3b02a4 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.oliva/overload1.C @@ -0,0 +1,24 @@ +// { dg-do assemble } + +// Copyright (C) 1999 Free Software Foundation + +// by Alexandre Oliva <oliva@lsd.ic.unicamp.br> +// Based on bug report by JDonner <jdonner@schedsys.com> + +struct foo { + static int bar(); // { dg-error "candidate" } + void bar(int); // { dg-error "foo::bar" } +}; + +/* gcc emits a hard error without -pedantic, and a warning with + -pedantic, even in bad1. */ +int (*ok1)() = foo::bar; +void (foo::*bad1)(int) = foo::bar; // { dg-error "assuming pointer" } +// { dg-message "note" "note" { target *-*-* } 16 } + +int (*ok2)() = &foo::bar; // ok +void (*bad2)(int) = foo::bar; // { dg-error "no matches" } + +void (foo::*ok3)(int) = &foo::bar; // ok +int (foo::*bad3)() = foo::bar; // { dg-error "no matches" } + diff --git a/gcc/testsuite/g++.old-deja/g++.oliva/partord1.C b/gcc/testsuite/g++.old-deja/g++.oliva/partord1.C new file mode 100644 index 000000000..34fe92e64 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.oliva/partord1.C @@ -0,0 +1,28 @@ +// { dg-do assemble } + +// Copyright (C) 1999 Free Software Foundation + +// by Alexandre Oliva <oliva@dcc.unicamp.br> + +template <typename T> void foo(T); +template <typename T> void foo(T*); + +template <typename T> class bar { + private: + int i; // { dg-error "" } this variable + friend void foo<T>(T); +}; + +template <typename T> void foo(T) { + bar<T>().i; // ok, I'm a friend +} +template <typename T> void foo(T*) { + bar<T*>().i; // { dg-error "" } not a friend +} + +int main() { + int j = 0; + foo(j); // calls foo<int>(int), ok + foo(&j); // calls foo<int>(int*) + foo<int*>(&j); // calls foo<int*>(int*), ok +} diff --git a/gcc/testsuite/g++.old-deja/g++.oliva/partspec1.C b/gcc/testsuite/g++.old-deja/g++.oliva/partspec1.C new file mode 100644 index 000000000..887924781 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.oliva/partspec1.C @@ -0,0 +1,20 @@ +// { dg-do assemble } + +// Copyright (C) 1999 Free Software Foundation + +// by Alexandre Oliva <oliva@dcc.unicamp.br> +// simplified from bug report by Andrey Slepuhin <pooh@msu.ru> + +template <typename A, int* P> struct X; + +int a; + +template <typename A> +struct X<A,&a> {}; + +int b; + +template <typename A> +struct X<A,&b> {}; + +X<int,&a> x; diff --git a/gcc/testsuite/g++.old-deja/g++.oliva/stkalign.C b/gcc/testsuite/g++.old-deja/g++.oliva/stkalign.C new file mode 100644 index 000000000..2b24f489e --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.oliva/stkalign.C @@ -0,0 +1,18 @@ +// { dg-do assemble } + +// Copyright (C) 2000 Free Software Foundation + +// by Alexandre Oliva <aoliva@cygnus.com> +// distilled from libg++'s Fix.cc + + +struct Integer { + ~Integer () {} +}; + +void foo (const Integer& y); +Integer bar (const Integer& x); + +void show (const Integer& x) { + foo (bar (x)); +} diff --git a/gcc/testsuite/g++.old-deja/g++.oliva/template1.C b/gcc/testsuite/g++.old-deja/g++.oliva/template1.C new file mode 100644 index 000000000..ce3949618 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.oliva/template1.C @@ -0,0 +1,15 @@ +// { dg-do assemble } + +// Copyright (C) 1999, 2003 Free Software Foundation + +// by Alexandre Oliva <oliva@dcc.unicamp.br> +// based on bug report by Stefan Wetzel <Stefan_Wetzel@Physik.TU-Muenchen.DE> + + +template<int P = 0> struct foo { + static void bar(double (*)[dim]) {} // { dg-error "'dim' was not declared" } +}; + +void bar() { + foo<>::bar(0); +} diff --git a/gcc/testsuite/g++.old-deja/g++.oliva/template10.C b/gcc/testsuite/g++.old-deja/g++.oliva/template10.C new file mode 100644 index 000000000..5c1204bdd --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.oliva/template10.C @@ -0,0 +1,22 @@ +// { dg-do assemble } + +// Copyright (C) 1999 Free Software Foundation + +// by Alexandre Oliva <oliva@lsd.ic.unicamp.br> +// bug report by Martin Sebor <sebor@roguewave.com> +// based on C++ Standard example in [temp.expl.spec]/5 + +/* Members of explicitly specialized template classes shall not be + defined with template-specialization syntax. The example in the + Standard contains a definition of a member function of the + explicitly specialized class template, but the paragraph refers to + members in general, not only member functions. */ + +template<class T> struct A {}; + +template<> struct A<int> { + static bool a, b; +}; + +bool A<int>::a = true; // ok +template<> bool A<int>::b = false; // { dg-error "template header" } diff --git a/gcc/testsuite/g++.old-deja/g++.oliva/template2.C b/gcc/testsuite/g++.old-deja/g++.oliva/template2.C new file mode 100644 index 000000000..359e9b465 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.oliva/template2.C @@ -0,0 +1,14 @@ +// { dg-do assemble } + +// Copyright (C) 1999 Free Software Foundation + +// by Alexandre Oliva <oliva@dcc.unicamp.br> +// based on bug report by Gabriel Dos_Reis <Gabriel.Dos_Reis@sophia.inria.fr> + +template <template <typename> class C, typename T> class foo { + typedef typename C<T>::bar bar; + foo(bar); +}; + +template <template <typename> class C, typename T> foo<C,T>::foo(bar) +{} // { dg-bogus "" } C<T> not a class diff --git a/gcc/testsuite/g++.old-deja/g++.oliva/template3.C b/gcc/testsuite/g++.old-deja/g++.oliva/template3.C new file mode 100644 index 000000000..056f77c61 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.oliva/template3.C @@ -0,0 +1,9 @@ +// { dg-do assemble } + +// Copyright (C) 1999 Free Software Foundation + +// by Alexandre Oliva <oliva@dcc.unicamp.br> +// based on bug report by Ulf Larsson <ulf.larsson@mbow337.swipnet.se> + +template <class T> class C {}; +class foo {} bar = bar.C(); // { dg-error "" } call to template diff --git a/gcc/testsuite/g++.old-deja/g++.oliva/template4.C b/gcc/testsuite/g++.old-deja/g++.oliva/template4.C new file mode 100644 index 000000000..2268fde40 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.oliva/template4.C @@ -0,0 +1,20 @@ +// { dg-do assemble } + +// Copyright (C) 1999 Free Software Foundation + +// by Alexandre Oliva <oliva@dcc.unicamp.br> +// based on bug report by Andrey Slepuhin <pooh@msu.ru> + +template <const int&> struct X {}; + +int a = 1; +X<a> x; // ok, a has external linkage + +const int b = 2; +X<b> y; // { dg-error "" } const b has internal linkage + +extern const int c; +X<c> z; // ok, c has external linkage + +extern const int c = 3; +X<c> z_; // { dg-bogus "" } using c as constant diff --git a/gcc/testsuite/g++.old-deja/g++.oliva/template5.C b/gcc/testsuite/g++.old-deja/g++.oliva/template5.C new file mode 100644 index 000000000..baecea576 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.oliva/template5.C @@ -0,0 +1,12 @@ +// { dg-do assemble } + +// Copyright (C) 1999 Free Software Foundation + +// by Alexandre Oliva <oliva@dcc.unicamp.br> +// simplified from bug report by Andrey Slepuhin <pooh@msu.ru> + +template <typename> class X { + template <typename> class Z; +}; + +X<void> a; diff --git a/gcc/testsuite/g++.old-deja/g++.oliva/template6.C b/gcc/testsuite/g++.old-deja/g++.oliva/template6.C new file mode 100644 index 000000000..270d67695 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.oliva/template6.C @@ -0,0 +1,12 @@ +// { dg-do assemble } + +// Copyright (C) 1999 Free Software Foundation + +// by Alexandre Oliva <oliva@dcc.unicamp.br> +// simplified from bug report by Meenaradchagan Vishnu <mvishnu@fore.com> + +template <typename> struct foo {}; +template <> void foo(); // { dg-error "not a template function" } bad specialization + +struct baz {}; +template <> void baz (); // { dg-error "not a template function" } bad specialization diff --git a/gcc/testsuite/g++.old-deja/g++.oliva/template7.C b/gcc/testsuite/g++.old-deja/g++.oliva/template7.C new file mode 100644 index 000000000..3bcff56ae --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.oliva/template7.C @@ -0,0 +1,14 @@ +// { dg-do assemble } + +// Copyright (C) 1999, 2000 Free Software Foundation + +// by Alexandre Oliva <oliva@lsd.ic.unicamp.br> +// simplified from bug report by Paul Burchard <burchard@pobox.com> + +template<class> struct A {}; +template<template<class> class T> struct B { + B() { + T<B>(); // { dg-bogus "" } conversion from int to non-scalar + } +}; +B<A> foo; diff --git a/gcc/testsuite/g++.old-deja/g++.oliva/template8.C b/gcc/testsuite/g++.old-deja/g++.oliva/template8.C new file mode 100644 index 000000000..86c4d0c69 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.oliva/template8.C @@ -0,0 +1,18 @@ +// { dg-do assemble } + +// Copyright (C) 1999 Free Software Foundation + +// by Alexandre Oliva <oliva@dcc.unicamp.br> +// simplified from bug report by redleaf <e1wwater@dingo.cc.uq.edu.au> + +struct B { + template <class> void bar(); +} b; + +template <class T> void foo() { + b.bar<T>(); // no longer { dg-bogus "" } bar undeclared + b.template bar<T>(); // no longer { dg-bogus "" } ditto + b.B::bar<T>(); // ok +} + +template void foo<void>(); // no longer { dg-bogus "" } diff --git a/gcc/testsuite/g++.old-deja/g++.oliva/template9.C b/gcc/testsuite/g++.old-deja/g++.oliva/template9.C new file mode 100644 index 000000000..02be37a5f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.oliva/template9.C @@ -0,0 +1,11 @@ +// { dg-do assemble } + +// Copyright (C) 1999 Free Software Foundation + +// by Alexandre Oliva <oliva@lsd.ic.unicamp.br> +// based on bug report by Philippe Bouchard <boucp00@DMI.USherb.CA> + +struct foo { + template <class> + void bar() = 0; // { dg-error "virtual" } +}; diff --git a/gcc/testsuite/g++.old-deja/g++.oliva/thunk1.C b/gcc/testsuite/g++.old-deja/g++.oliva/thunk1.C new file mode 100644 index 000000000..640023ff7 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.oliva/thunk1.C @@ -0,0 +1,36 @@ +// { dg-do run } +// Copyright (C) 1999 Free Software Foundation + +// by Alexandre Oliva <oliva@dcc.unicamp.br> +// based on bug report by Fredrik Öhrström <d92-foh@nada.kth.se> + +#include <cstdlib> + +using namespace std; + +struct vbase { + virtual int get_a() const = 0; +}; + +struct base: virtual vbase { + int a; + base(int aa) : a(aa) {} + int get_a() const { return a; } +}; + +struct mid: base { + mid(int bb) : base(bb) { + // when mid is not in charge of vbase initialization, + // a derived-aware vtable is needed for vbase + if (((vbase*)this)->get_a() != bb) + abort(); + } +}; + +struct derived: virtual mid { + derived(int cc) : mid(cc) {} +}; + +int main () { + derived(1); +} diff --git a/gcc/testsuite/g++.old-deja/g++.oliva/typename1.C b/gcc/testsuite/g++.old-deja/g++.oliva/typename1.C new file mode 100644 index 000000000..83569dd3f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.oliva/typename1.C @@ -0,0 +1,16 @@ +// { dg-do assemble } + +// Copyright (C) 1999 Free Software Foundation + +// by Alexandre Oliva <oliva@dcc.unicamp.br> +// based on bug report by Nick Rasmussen <nick@jive.org> + +template <class T> struct foo; + +template <class T> struct bar { + typedef int foo; +}; + +template <class T> struct baz { + typedef bar<T>::foo foo; // { dg-error "" } missing typename +}; diff --git a/gcc/testsuite/g++.old-deja/g++.oliva/typename2.C b/gcc/testsuite/g++.old-deja/g++.oliva/typename2.C new file mode 100644 index 000000000..86512c983 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.oliva/typename2.C @@ -0,0 +1,28 @@ +// { dg-do assemble } +// { dg-options "" } + +// Copyright (C) 1999 Free Software Foundation + +// by Alexandre Oliva <oliva@dcc.unicamp.br> +// based on bug report by Nick Rasmussen <nick@jive.org> + +// This is slightly different from typename1.C. This one tests +// whether the implicit typename extension works. gcc 2.95 reports: + +// warning: lookup of `foo' finds `struct foo' +// warning: instead of `baz<T>::foo' from dependent base class +// warning: (use `typename baz::foo' if that's what you meant) + +// But baz<T>::foo is not a base class, and `foo' should have been +// found in baz's scope. + +struct foo; + +template <class T> struct bar { + typedef int foo; +}; + +template <class T> struct baz { + typedef bar<T>::foo foo; // { dg-error "" } implicit typename + void m(foo); +}; diff --git a/gcc/testsuite/g++.old-deja/g++.oliva/typeof1.C b/gcc/testsuite/g++.old-deja/g++.oliva/typeof1.C new file mode 100644 index 000000000..197abe6a5 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.oliva/typeof1.C @@ -0,0 +1,19 @@ +// { dg-do assemble } + +// Copyright (C) 1999 Free Software Foundation + +// by Alexandre Oliva <oliva@dcc.unicamp.br> + +struct B { + int i; +}; + +template <class T> void foo(T b) { + b.T::i; // ok + // b.__typeof__(b)::i; // parse error, should this be accepted? + typedef T t1; + b.t1::i; // ok + typedef __typeof__(b) t2; +} + +template void foo(B); // not needed for the crash diff --git a/gcc/testsuite/g++.old-deja/g++.other/900403_04.C b/gcc/testsuite/g++.old-deja/g++.other/900403_04.C new file mode 100644 index 000000000..ba6aef0d2 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/900403_04.C @@ -0,0 +1,12 @@ +// { dg-do assemble } +// GROUPS passed abort +// g++ 1.37.1 bug 900403_04 + +// The following erroneous code causes g++ to abort. + +// keywords: abort, bit-fields, zero length + +struct s { + unsigned int foo:0; // { dg-error "" } causes abort + unsigned int field; +}; diff --git a/gcc/testsuite/g++.old-deja/g++.other/900519_12.C b/gcc/testsuite/g++.old-deja/g++.other/900519_12.C new file mode 100644 index 000000000..82d0f9f7d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/900519_12.C @@ -0,0 +1,11 @@ +// { dg-do assemble } +// GROUPS abort +// g++ 1.37.1 bug 900519_12 + +// The following erroneous code causes g++ to segfault. + +// cfront 2.0 passes this test. + +// keywords: segfault, typedef, pointer type, function type + +typedef eek void (*)(); // { dg-error "" } diff --git a/gcc/testsuite/g++.old-deja/g++.other/access1.C b/gcc/testsuite/g++.old-deja/g++.other/access1.C new file mode 100644 index 000000000..e463ef4c4 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/access1.C @@ -0,0 +1,14 @@ +// { dg-do assemble } + +class X{ + unsigned int i; + public: + void f(); +}; + +void X::f() +{ + union { + int foo[sizeof (i)]; + }; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/access10.C b/gcc/testsuite/g++.old-deja/g++.other/access10.C new file mode 100644 index 000000000..103cd4108 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/access10.C @@ -0,0 +1,9 @@ +// { dg-do assemble } +// Test that defining a static member of private type with the () syntax works. + +class A { + private: + struct B { B(int) {} }; + static B b; +}; +A::B A::b (1); diff --git a/gcc/testsuite/g++.old-deja/g++.other/access11.C b/gcc/testsuite/g++.old-deja/g++.other/access11.C new file mode 100644 index 000000000..72fc333c1 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/access11.C @@ -0,0 +1,20 @@ +// { dg-do assemble } +// { dg-options "-w" } +// Origin: r.spatschek@fz-juelich.de + +class A +{ +private: + template <class T> void g(T t) {} + int i; +}; + +template <> +void A::g<int>(int t) { i = 1; } // { dg-error "" } private + +int main() +{ + A a; + + a.g<int>(0); // { dg-error "" } private +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/access2.C b/gcc/testsuite/g++.old-deja/g++.other/access2.C new file mode 100644 index 000000000..51722aecd --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/access2.C @@ -0,0 +1,12 @@ +// { dg-do assemble } +// Based on a testcase in the Standard, submitted by several people + +class Outer { + typedef int T; + struct Inner { + T i; // { dg-error "" "" { xfail *-*-* } } not accessible - + void f() { + T j; // { dg-error "" "" { xfail *-*-* } } not accessible - + } + }; +}; diff --git a/gcc/testsuite/g++.old-deja/g++.other/access3.C b/gcc/testsuite/g++.old-deja/g++.other/access3.C new file mode 100644 index 000000000..4752ac8a8 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/access3.C @@ -0,0 +1,26 @@ +// { dg-do assemble } +// The standard sez that a use of a name gets the most access it can through +// the various paths that can reach it. Here, the access decl in B gives +// us access. + +struct A +{ + void f (); +}; + +struct B: private virtual A +{ + A::f; +}; + +struct C: private virtual A, public B +{ +}; + +int +main () +{ + C c; + + c.f (); +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/access4.C b/gcc/testsuite/g++.old-deja/g++.other/access4.C new file mode 100644 index 000000000..939bebcf0 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/access4.C @@ -0,0 +1,11 @@ +// { dg-do assemble } + +struct A { // { dg-error "" } inaccessible + static int i; +}; + +struct B : private A { }; + +struct C : public B { + int f () { return A::i; } // { dg-error "" } context +}; diff --git a/gcc/testsuite/g++.old-deja/g++.other/access5.C b/gcc/testsuite/g++.old-deja/g++.other/access5.C new file mode 100644 index 000000000..431ba416a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/access5.C @@ -0,0 +1,22 @@ +// { dg-do assemble } + +class A +{ +protected: + int i; +}; + +class B : private A +{ +protected: + A::i; +}; + +struct C : public B { + friend int f(C *p); +}; + +int f(C *p) { + return p->i; +} + diff --git a/gcc/testsuite/g++.old-deja/g++.other/access6.C b/gcc/testsuite/g++.old-deja/g++.other/access6.C new file mode 100644 index 000000000..59d92975b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/access6.C @@ -0,0 +1,17 @@ +// { dg-do assemble } + +template <int I> +struct S { + void g(); +}; + +class C { + static const int i = 3; // { dg-bogus "" } private +public: + S<C::i>* f(); // { dg-bogus "" } redeclared +}; + +S<C::i>* C::f() { // { dg-bogus "" } private + return 0; +} + diff --git a/gcc/testsuite/g++.old-deja/g++.other/access7.C b/gcc/testsuite/g++.old-deja/g++.other/access7.C new file mode 100644 index 000000000..635c6df77 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/access7.C @@ -0,0 +1,33 @@ +// { dg-do assemble } +// Test that access control for types and statics works properly +// with nested types. + + +class A { + static int I1; // { dg-error "" } private + struct B1 { }; // { dg-error "" } private +public: + static int I2; + struct B2 { }; +}; + +class D: public A { + struct E { + void f (); + }; +}; + +void D::E::f () +{ + int i = I1; // { dg-error "" } within this context + B1 b1; // { dg-error "" } within this context + i = I2; + B2 b2; +} + +void f () +{ + A::B1 b1; // { dg-error "" } within this context + new A::B1; // { dg-error "" } within this context + (A::B1) b1; // { dg-error "" } within this context +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/access8.C b/gcc/testsuite/g++.old-deja/g++.other/access8.C new file mode 100644 index 000000000..abd401b12 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/access8.C @@ -0,0 +1,27 @@ +// { dg-do assemble } +// Copyright (C) 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 10 Feb 2000 <nathan@acm.org> + +// Test that access to static members from a nested class of the derived +// type works. + +class Base +{ + protected: + static int Some_var; + typedef int Some_t; +}; + +class Derived : Base +{ + protected: + struct Nested + { + void Foo (Some_t); + void Bar (Base::Some_t) { Base::Some_var = 1; } + }; +}; + +void Derived::Nested::Foo (Some_t) { + Some_var = 2; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/access9.C b/gcc/testsuite/g++.old-deja/g++.other/access9.C new file mode 100644 index 000000000..6e60a07bc --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/access9.C @@ -0,0 +1,10 @@ +// { dg-do assemble } +// Test that g++ allows friends to use private types in their declarations. + +class A { + typedef int I; + friend I f (I); +}; + +A::I f (A::I); +A::I f (A::I) { return 0; } diff --git a/gcc/testsuite/g++.old-deja/g++.other/addrof1.C b/gcc/testsuite/g++.old-deja/g++.other/addrof1.C new file mode 100644 index 000000000..2702ee07b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/addrof1.C @@ -0,0 +1,34 @@ +// { dg-do run } + +extern "C" void abort (); + +typedef struct st { + unsigned char a; + unsigned char b; + unsigned char c; + unsigned char d; +} __attribute__((aligned(4))) st; + +void testme(int, int, int); + +static inline void +stupid_func(st s) +{ + testme(s.a, s.b, s.c); +} + +int main() +{ + st s; + + s.a = s.b = s.c = 216; + stupid_func(s); + + return 0; +} + +void testme(int a, int b, int c) +{ + if (a != 216 || b != 216 || c != 216) + abort(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/align.C b/gcc/testsuite/g++.old-deja/g++.other/align.C new file mode 100644 index 000000000..a5269515c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/align.C @@ -0,0 +1,15 @@ +// { dg-do assemble } +#include <string.h> + +class bar { +public: + bar() { rw = 0; } + static const bar baz; +private: + unsigned char rw; +}; +char buf[4096]; +void foo(char *uc) +{ + memcpy(buf,&bar::baz,sizeof(bar)); +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/ambig1.C b/gcc/testsuite/g++.old-deja/g++.other/ambig1.C new file mode 100644 index 000000000..f3fe0a8dd --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/ambig1.C @@ -0,0 +1,28 @@ +// { dg-do assemble } + +struct A { + int operator ++(); // { dg-error "" } candidates + void operator ()(); // { dg-error "" } candidates + void operator delete(void*); // { dg-error "" } candidates +}; + +struct B { + int operator ++(int); // { dg-error "" } candidates + void operator ()(); // { dg-error "" } candidates + void operator delete(void*); // { dg-error "" } candidates + void f(); +}; + +struct C : public A, public B { +}; + +void f() +{ + C c; + C* cp; + + delete cp; // { dg-error "" } ambiguous + c(); // { dg-error "" } ambiguous + c++; // { dg-error "" } ambiguous +} + diff --git a/gcc/testsuite/g++.old-deja/g++.other/ambig2.C b/gcc/testsuite/g++.old-deja/g++.other/ambig2.C new file mode 100644 index 000000000..7f6096876 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/ambig2.C @@ -0,0 +1,21 @@ +// { dg-do assemble } +// Copyright (C) 1999, 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 29 Aug 1999 <nathan@acm.org> + +// We should spot all ambiguities + +struct A {int m;}; +struct B : A { int m; }; +struct C : A { int m; }; +struct D0 : virtual B, virtual C { int m; }; +struct D1 : virtual B, C { int m; }; +struct D2 : B, virtual C { int m; }; +struct D3 : B, C { int m; }; + +void fn(D0 *d0, D1 *d1, D2 *d2, D3 *d3) +{ + A *a0 = d0; // { dg-error "" } A is an ambiguous base + A *a1 = d1; // { dg-error "" } A is an ambiguous base + A *a2 = d2; // { dg-error "" } A is an ambiguous base + A *a3 = d3; // { dg-error "" } A is an ambiguous base +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/ambig3.C b/gcc/testsuite/g++.old-deja/g++.other/ambig3.C new file mode 100644 index 000000000..3b14e75c7 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/ambig3.C @@ -0,0 +1,34 @@ +// { dg-do assemble } + +// Copyright (C) 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 23 June 2000 <nathan@codesourcery.com> + +// Origin GNATS bug report 69 from Glenn Ammons <ammons@cs.wisc.edu> +// +// A base which derives a virtual base hides declarations in the virtual base, +// even if that virtual base is accessible via another path [10.2]/6. Make +// sure that non-virtual bases of the virtual base are also hidden, not matter +// what order bases are declared in. + +struct A {int a;}; +struct B : A {}; + +struct L1 : virtual B { int a; }; +struct L2 : virtual A { int a; }; + +struct R1 : virtual B {}; +struct R2 : virtual A {}; + +struct C1 : R1, L1 {}; +struct C2 : R2, L2 {}; + +struct D1 : L1, R1 {}; +struct D2 : L2, R2 {}; + +void fn (C1 *c1, D1 *d1, C2 *c2, D2 *d2) +{ + c1->a = 1; + d1->a = 1; + c2->a = 1; + d2->a = 1; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/anon1.C b/gcc/testsuite/g++.old-deja/g++.other/anon1.C new file mode 100644 index 000000000..5886b1a71 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/anon1.C @@ -0,0 +1,6 @@ +// { dg-do assemble } + +static union { + union { + }; +}; // { dg-warning "" } anonymous union with no members diff --git a/gcc/testsuite/g++.old-deja/g++.other/anon2.C b/gcc/testsuite/g++.old-deja/g++.other/anon2.C new file mode 100644 index 000000000..f35d5ff31 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/anon2.C @@ -0,0 +1,32 @@ +// { dg-do run } +extern "C" void abort (void); + +static union { + int x1; + long x2; + short x3; + long x4; +}; + +static union { + union { + union { + int z; + }; + }; + union { + union { + double d; + int i; + }; + }; +}; + + +int main() +{ + z = 3; + if (i != 3) + abort (); + d = 2.5; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/anon3.C b/gcc/testsuite/g++.old-deja/g++.other/anon3.C new file mode 100644 index 000000000..3f8b5cc00 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/anon3.C @@ -0,0 +1,86 @@ +// { dg-do run } +// Copyright (C) 1999 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 20 May 1999 <nathan@acm.org> + +// Although anon unions cannot have user defined member functions +// [class.union/2]. They should have implicitly defined copy ctors and +// and the like [class.copy/4]. Make sure we generate one of the correct +// signature and that it works ok. + +extern "C" void abort(); + +struct A +{ + union + { + int a; + }; +}; +union B +{ + int a; +}; + +static A Ctor(A const &src) +{ + A result(src); // this should not cause a const violation + + result = src; // and neither should this + + return result; +} + +typedef __SIZE_TYPE__ size_t; + +void *operator new(size_t, void *ptr) +{ + return ptr; +} + +// check copy ctor and assignment for plain union +void check_union() +{ + B b1; + B b2; + + b1.a = 5; + b2.a = 6; + b2 = b1; + if(b2.a != 5) + abort(); + + b2.a = 6; + new (&b2) B(b1); + if(b2.a != 5) + abort(); + + return; +} + +// check copy ctor and assignment for class containing anon-union +void check_union_member() +{ + A a1; + A a2; + + a1.a = 5; + a2.a = 6; + a2 = a1; + if(a2.a != 5) + abort(); + + a2.a = 6; + new (&a2) A(a1); + if(a2.a != 5) + abort(); + + return; +} + +int main() +{ + check_union(); + check_union_member(); + + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/anon4.C b/gcc/testsuite/g++.old-deja/g++.other/anon4.C new file mode 100644 index 000000000..2a01be3d0 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/anon4.C @@ -0,0 +1,16 @@ +// { dg-do assemble } + +// Copyright (C) 1999 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 20 May 1999 <nathan@acm.org> + +// Anon unions cannot have user defined member functions +// [class.union/2]. Make sure we spot that. + + +struct A +{ + union + { // { dg-error "" } anon union cannot have member fns + void bad(); + }; +}; diff --git a/gcc/testsuite/g++.old-deja/g++.other/anon5.C b/gcc/testsuite/g++.old-deja/g++.other/anon5.C new file mode 100644 index 000000000..4b0943683 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/anon5.C @@ -0,0 +1,17 @@ +// { dg-do assemble } +// Copyright (C) 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 14 Nov 2000 <nathan@codesourcery.com> + +// Bug 649. A cv qualified anonymous union would cause confusion. + +struct X +{ + int fn () const + { + return member; + } + const union + { + int member; + }; +}; diff --git a/gcc/testsuite/g++.old-deja/g++.other/anon6.C b/gcc/testsuite/g++.old-deja/g++.other/anon6.C new file mode 100644 index 000000000..e1cfeb253 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/anon6.C @@ -0,0 +1,37 @@ +// { dg-do run } +extern "C" void abort (); + +struct A { + union { + int a; + double b; + int d; + }; + int c; +}; + +struct B : public A { + union { + double a; + void *c; + }; + float b; + int e; +}; + +int main () +{ + struct B b; + + b.a = 1.5; + b.b = 2.5; + b.d = 1; + b.e = 2; + if (b.a != 1.5 || b.b != 2.5 || b.d != 1 || b.e != 2) + abort (); + b.c = &b.a; + b.d = b.e; + if (b.c != &b.a || b.d != 2) + abort (); + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/anon7.C b/gcc/testsuite/g++.old-deja/g++.other/anon7.C new file mode 100644 index 000000000..ebc378005 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/anon7.C @@ -0,0 +1,24 @@ +// { dg-do assemble } + +struct A { + union { + int a; // { dg-error "" } conflicts with previous declaration + }; + int a; // { dg-error "" } +}; + +struct B { + int b; // { dg-error "" } conflicts with previous declaration + union { + int b; // { dg-error "" } duplicate member + }; +}; + +struct C { + union { + int c; // { dg-error "" } conflicts with previous declaration + }; + union { + int c; // { dg-error "" } duplicate member + }; +}; 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 000000000..fb26d7313 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/anon8.C @@ -0,0 +1,22 @@ +// { dg-do assemble } + +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/anon9.C b/gcc/testsuite/g++.old-deja/g++.other/anon9.C new file mode 100644 index 000000000..a364db8e9 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/anon9.C @@ -0,0 +1,6 @@ +// { dg-do assemble } +// Test that we properly diagnose an attempt to use an anonymous class +// in declaring an external function. + +typedef const struct { int i; } T; // { dg-error "" } referenced below +void f (T* t); // { dg-error "" } uses unnamed type diff --git a/gcc/testsuite/g++.old-deja/g++.other/array1.C b/gcc/testsuite/g++.old-deja/g++.other/array1.C new file mode 100644 index 000000000..5aa5b1ed6 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/array1.C @@ -0,0 +1,27 @@ +// { dg-do run } +int i; + +struct S { + S (int) { + ++i; + if (i == 3) + throw 3; + } + + S () {} + + ~S() { + --i; + } +}; + +int main() +{ + try { + S s[5] = { 0, 1, 2, 3, 4 }; + } catch (...) { + } + + if (i != 1) + return 1; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/array2.C b/gcc/testsuite/g++.old-deja/g++.other/array2.C new file mode 100644 index 000000000..5c1b66577 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/array2.C @@ -0,0 +1,19 @@ +// { dg-do run } +int i; + +struct S { + S () { + ++i; + } + + S (int) { + } +}; + +int main() +{ + S s[3][3] = { 2 }; + + if (i != 8) + return 1; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/array3.C b/gcc/testsuite/g++.old-deja/g++.other/array3.C new file mode 100644 index 000000000..f89090f17 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/array3.C @@ -0,0 +1,25 @@ +// { dg-do assemble } +// +// Copyright (C) 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 10 Aug 2000 <nathan@codesourcery.com> + +// bug 386.C We ICE'd before emitting a diagnostic when trying to +// initialize a constant non-pod array from something bogus. + + +struct A +{ + A(char); +}; + +class B +{ + const A ary[16]; + + B (const A ary[]); +}; + +B::B (const A a[]) + : ary(a) // { dg-error "array" } +{ +} 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 000000000..7e9260234 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/array4.C @@ -0,0 +1,5 @@ +// { dg-do assemble } +// Origin: j_bouis@hotmail.com + +enum { FOO = 3 }; +int* arr = new int[FOO]; 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 000000000..e32bbea5a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/array5.C @@ -0,0 +1,10 @@ +// { dg-do assemble } +// 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/array6.C b/gcc/testsuite/g++.old-deja/g++.other/array6.C new file mode 100644 index 000000000..1ffc42a59 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/array6.C @@ -0,0 +1,21 @@ +// { dg-do run } +// { dg-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/array9.C b/gcc/testsuite/g++.old-deja/g++.other/array9.C new file mode 100644 index 000000000..c2c2d79b9 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/array9.C @@ -0,0 +1,6 @@ +// { dg-do assemble } + +template <class T> class A { + T *d; + public: void f() { (T[10])d; } +}; diff --git a/gcc/testsuite/g++.old-deja/g++.other/asm1.C b/gcc/testsuite/g++.old-deja/g++.other/asm1.C new file mode 100644 index 000000000..87edbe164 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/asm1.C @@ -0,0 +1,6 @@ +// { dg-do assemble } +// Origin: Mark Mitchell <mark@codesourcery.com> + +struct S { + int i asm ("abc"); // { dg-error "" } `asm' specifier not permitted +}; 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 000000000..d5fd5a922 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/asm2.C @@ -0,0 +1,12 @@ +// { dg-do assemble } +// Origin: Mark Mitchell <mark@codesourcery.com> + +struct C +{ + void f (); +}; + +void C::f () +{ + asm ("" : : "m" (f)); // { dg-error "" } type could not be determined +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/asm3.C b/gcc/testsuite/g++.old-deja/g++.other/asm3.C new file mode 100644 index 000000000..5cbf04893 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/asm3.C @@ -0,0 +1,10 @@ +// { dg-do assemble { target i?86-*-* x86_64-*-* } } +// { dg-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/badarrow.C b/gcc/testsuite/g++.old-deja/g++.other/badarrow.C new file mode 100644 index 000000000..6e7578d1d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/badarrow.C @@ -0,0 +1,10 @@ +// { dg-do assemble } + +struct S { + int i; +} s; + +void f() +{ + s->i = 3; // { dg-error "" } base operand +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/badopt1.C b/gcc/testsuite/g++.old-deja/g++.other/badopt1.C new file mode 100644 index 000000000..a4daa221e --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/badopt1.C @@ -0,0 +1,16 @@ +// { dg-do run } +// { dg-options "-O2" } +// Based on a testcase by Bryan Weston <bryanw@bluemoon.sps.mot.com> +// egcs 1.1 fails to increment count + + +struct Base { Base() {} }; // removing the constructor fixes the problem +struct Derived : Base {}; // so does removing the base class + +int main() { + int count = 0; + Derived* array[1]; // making this Base*[1] does not fix the problem + array[count++] = new Derived (); // but then new Base() does + if (count!=1) + return 1; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/base1.C b/gcc/testsuite/g++.old-deja/g++.other/base1.C new file mode 100644 index 000000000..3c9ac264e --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/base1.C @@ -0,0 +1,20 @@ +// { dg-do assemble } + +// Copyright (C) 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 25 Nov 2000 <nathan@codesourcery.com> + +// We lost information about which base wasn't an aggregate type, plus we +// allowed cv qualifed bases via typedefs. + +typedef int I; +typedef int cI; + +struct A {}; + +typedef const A cA; +typedef A pA; + +struct B : I {}; // { dg-error "" } not an aggregate +struct C : cI {}; // { dg-error "" } not an aggregate +struct D : cA {}; // { dg-error "" } cv qualified +struct E : pA {}; diff --git a/gcc/testsuite/g++.old-deja/g++.other/bitfld1.C b/gcc/testsuite/g++.old-deja/g++.other/bitfld1.C new file mode 100644 index 000000000..471032173 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/bitfld1.C @@ -0,0 +1,12 @@ +// { dg-do assemble } +// Based on a bug report by Stephen Vavasis <vavasis@CS.Cornell.EDU> + +// declares template operator!= +#include <utility> + +struct foo { + enum e { bar } baz:1; + void test() { + baz != bar; + } +}; diff --git a/gcc/testsuite/g++.old-deja/g++.other/bitfld2.C b/gcc/testsuite/g++.old-deja/g++.other/bitfld2.C new file mode 100644 index 000000000..62a971363 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/bitfld2.C @@ -0,0 +1,9 @@ +// { dg-do assemble } +// { dg-options "-funsigned-bitfields" } +// Origin: Mark Mitchell <mark@codesourcery.com> + +typedef int i[4]; + +struct S { + i j:12; // { dg-error "" } array type as bitfield +}; diff --git a/gcc/testsuite/g++.old-deja/g++.other/bitfld3.C b/gcc/testsuite/g++.old-deja/g++.other/bitfld3.C new file mode 100644 index 000000000..7e16a7206 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/bitfld3.C @@ -0,0 +1,34 @@ +// { dg-do assemble } + +// Copyright (C) 1999, 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 4 Jun 1999 <nathan@acm.org> +// Derived from a bug report from Stephan Riess <riess@bfw-online.de> +// http://gcc.gnu.org/ml/gcc-bugs/1999-06n/msg00107.html + +// Builtin ops don't always need reference bindings, and we weren't removing +// them always after doing overload resolution. This caused us to try and take +// the address of a bitfield. + +enum E {one}; +struct A { + E m1: 8; + E m2: 8; + unsigned m3 : 8; + unsigned m4 : 8; +}; + +int fn (int f) +{ + A a; + E m1, m2; + E e; + int i; + + e = f ? m1 : m2; + e = f ? a.m1 : a.m2; + i = f ? a.m3 : a.m4; + (f ? m1 : m2) = e; + (f ? a.m1 : a.m2) = e; + (f ? a.m3 : a.m4) = i; + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/bitfld4.C b/gcc/testsuite/g++.old-deja/g++.other/bitfld4.C new file mode 100644 index 000000000..96cb216b5 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/bitfld4.C @@ -0,0 +1,25 @@ +// { dg-do assemble } +// Origin: "Chen, Wen-Ke" <chwk@cs.arizona.edu> + +template <class T> +bool operator!=(const T&, const T&); + +enum MsgType { + MSG_DATA +}; + +class C { +public: + MsgType mType : 8; +}; + +int main(void) +{ + extern C& c; + + c.mType = MSG_DATA; + if (c.mType != MSG_DATA) + return -1; + + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/bitfld5.C b/gcc/testsuite/g++.old-deja/g++.other/bitfld5.C new file mode 100644 index 000000000..2808ae1e2 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/bitfld5.C @@ -0,0 +1,7 @@ +// { dg-do assemble } +// { dg-options "-w" } + +struct S +{ + int i : 1756; +}; diff --git a/gcc/testsuite/g++.old-deja/g++.other/builtins1.C b/gcc/testsuite/g++.old-deja/g++.other/builtins1.C new file mode 100644 index 000000000..ee714d715 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/builtins1.C @@ -0,0 +1,21 @@ +// { dg-do run } +// { dg-options "-O2" } +// Test whether this builtin minimally works in G++. +// Origin: Kaveh Ghazi Jan 16, 2001 +// Copyright (C) 2001 Free Software Foundation. +// + +namespace std +{ + extern "C" void abort (void); +} + +int main () +{ + using namespace std; + + if (::__builtin_strlen ("hello") != 5) + abort (); + + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/builtins10.C b/gcc/testsuite/g++.old-deja/g++.other/builtins10.C new file mode 100644 index 000000000..07f74f8f6 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/builtins10.C @@ -0,0 +1,7 @@ +// { dg-do assemble } +// Test that built-in functions don't warn when prototyped without arguments. +// Origin: PR c++/9367 +// Copyright (C) 2003 Free Software Foundation. + +extern "C" int snprintf(); + diff --git a/gcc/testsuite/g++.old-deja/g++.other/builtins2.C b/gcc/testsuite/g++.old-deja/g++.other/builtins2.C new file mode 100644 index 000000000..68cb4e2a1 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/builtins2.C @@ -0,0 +1,23 @@ +// { dg-do run } +// { dg-options "-O2" } +// Test whether this builtin minimally works in G++. +// Origin: Kaveh Ghazi Jan 16, 2001 +// Copyright (C) 2001 Free Software Foundation. +// + +namespace std +{ + extern "C" void abort (void); +} + +int main () +{ + using namespace std; + char f[16]; + + if (::__builtin_strcpy (f, "hello world") != f + || __builtin_memcmp (f, "hello world", sizeof ("hello world"))) + abort (); + + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/builtins3.C b/gcc/testsuite/g++.old-deja/g++.other/builtins3.C new file mode 100644 index 000000000..ace31b0f7 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/builtins3.C @@ -0,0 +1,24 @@ +// { dg-do run } +// { dg-options "-O2" } +// Test whether this builtin minimally works in G++. +// Origin: Kaveh Ghazi Jan 16, 2001 +// Copyright (C) 2001 Free Software Foundation. +// + +namespace std +{ + extern "C" void abort (void); +} + +int main () +{ + using namespace std; + void *foo; + + foo = ::__builtin_alloca (32); + if (!foo) + abort (); + + return 0; +} + diff --git a/gcc/testsuite/g++.old-deja/g++.other/builtins4.C b/gcc/testsuite/g++.old-deja/g++.other/builtins4.C new file mode 100644 index 000000000..2cb1552e2 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/builtins4.C @@ -0,0 +1,24 @@ +// { dg-do run } +// { dg-options "-O2" } +// Test whether this builtin minimally works in G++. +// Origin: Kaveh Ghazi Jan 16, 2001 +// Copyright (C) 2001 Free Software Foundation. +// + +namespace std +{ + extern "C" void abort (void); +} + +int main () +{ + using namespace std; + + ::__builtin_printf ("hello world\n"); + ::__builtin_printf ("\n"); + ::__builtin_printf ("%s\n", "hello world"); + ::__builtin_printf ("%c", '\n'); + + return 0; +} + diff --git a/gcc/testsuite/g++.old-deja/g++.other/builtins5.C b/gcc/testsuite/g++.old-deja/g++.other/builtins5.C new file mode 100644 index 000000000..f229d2922 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/builtins5.C @@ -0,0 +1,16 @@ +// { dg-do assemble } +// Test that built-in functions aren't recognized without a prototype. +// Origin: Roger Sayle Mar 20, 2002 +// Copyright (C) 2002 Free Software Foundation. + +int +foo () +{ + return (int) ::strlen ("foo"); // { dg-error "" } undeclared +} + +int +bar () +{ + return (int) std::strlen ("bar"); // { dg-error "" } undeclared +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/builtins6.C b/gcc/testsuite/g++.old-deja/g++.other/builtins6.C new file mode 100644 index 000000000..75285db9c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/builtins6.C @@ -0,0 +1,19 @@ +// { dg-do run } +// { dg-options "-O2" } +// Test that built-in functions are recognized with a prototype. +// Origin: Roger Sayle Mar 20, 2002 +// Copyright (C) 2002 Free Software Foundation. +// + +typedef __SIZE_TYPE__ size_t; +extern "C" size_t strlen (const char*); +extern "C" void link_error (void); + +int +main () +{ + if (strlen ("foo") != 3) + link_error (); + return 0; +} + diff --git a/gcc/testsuite/g++.old-deja/g++.other/builtins7.C b/gcc/testsuite/g++.old-deja/g++.other/builtins7.C new file mode 100644 index 000000000..4d664c1a7 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/builtins7.C @@ -0,0 +1,21 @@ +// { dg-do run } +// { dg-options "-O2" } +// Test that built-in functions are recognized with a prototype. +// Origin: Roger Sayle Mar 20, 2002 +// Copyright (C) 2002 Free Software Foundation. +// + +extern "C" void link_error (void); + +namespace std { +typedef __SIZE_TYPE__ size_t; +extern "C" size_t strlen (const char*); +} + +int +main () +{ + if (std::strlen ("foo") != 3) + link_error (); + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/builtins8.C b/gcc/testsuite/g++.old-deja/g++.other/builtins8.C new file mode 100644 index 000000000..9d12a45a7 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/builtins8.C @@ -0,0 +1,25 @@ +// { dg-do run } +// { dg-options "-O2" } +// Test that built-in functions are recognized with a prototype. +// Origin: Roger Sayle Mar 20, 2002 +// Copyright (C) 2002 Free Software Foundation. +// + + +extern "C" void link_error (void); + +namespace std { +typedef __SIZE_TYPE__ size_t; +extern "C" size_t strlen (const char*); +} + +using namespace std; + +int +main () +{ + if (strlen ("foo") != 3) + link_error (); + return 0; +} + diff --git a/gcc/testsuite/g++.old-deja/g++.other/builtins9.C b/gcc/testsuite/g++.old-deja/g++.other/builtins9.C new file mode 100644 index 000000000..2933866fc --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/builtins9.C @@ -0,0 +1,14 @@ +// { dg-do run } +// Test that inline redeclarations of builtins are emitted. +// Origin: Roger Sayle Mar 28, 2002 +// Copyright (C) 2002 Free Software Foundation. + +namespace std { + inline int fabs (void) { return 0; } +} + + +int main () +{ + return std::fabs (); +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/call1.C b/gcc/testsuite/g++.old-deja/g++.other/call1.C new file mode 100644 index 000000000..e12cffedf --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/call1.C @@ -0,0 +1,52 @@ +// { dg-do run } +// Test that various calls to non-functions work. + +void f () { } + +typedef void (*fptr)(); +typedef void (&fref)(); +fptr p = f; +fref r = f; +const fptr &pr = p; + +struct A { + fptr p; + + A (fptr n): p(n) { } + operator fptr () { return p; } +}; + +struct B { + fref r; + + B (fptr n): r(*n) { } + operator const fref () { return r; } +}; + +struct C { + const fptr pr; + + C (fptr n): pr(n) { } + operator const fptr& () { return pr; } +}; + +int main () +{ + f(); + + p(); + r(); + pr(); + + A a (f); + a(); + a.p(); + + B b (f); + b(); + b.r(); + + C c (f); + c(); + c.pr(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/cast1.C b/gcc/testsuite/g++.old-deja/g++.other/cast1.C new file mode 100644 index 000000000..989667a37 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/cast1.C @@ -0,0 +1,16 @@ +// { dg-do assemble } + +struct S0 { }; +struct S1 : virtual public S0 { }; +struct S2 : virtual public S0 { }; + +struct S3 : public S1, public S2, virtual public S0 +{ +}; + +void f(const S0*) {} + +void g() +{ + f(static_cast<S3*>(0)); +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/cast2.C b/gcc/testsuite/g++.old-deja/g++.other/cast2.C new file mode 100644 index 000000000..7e99ead65 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/cast2.C @@ -0,0 +1,17 @@ +// { dg-do assemble } +// Origin: Mark Mitchell <mark@codesourcery.com> + +struct A { +}; + +int main() +{ + A a; + typedef void (A::*F)(); + F p; + + const_cast<const A>(a); // { dg-error "" } const_cast requires pointer/ref types + const_cast<F>(p); // { dg-error "" } const_cast requires pointer/ref types + const_cast<int (*)()>(&main); // { dg-error "" } function type in const_cast + const_cast<int (&)()>(main); // { dg-error "" } function type in const_cast +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/cast3.C b/gcc/testsuite/g++.old-deja/g++.other/cast3.C new file mode 100644 index 000000000..15a27bb6c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/cast3.C @@ -0,0 +1,44 @@ +// { dg-do assemble } +// Copyright (C) 1999 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 12 Dec 1999 <nathan@acm.org> + +// static_cast should not cast _away_ constness ([expr.static.cast]/6), +// but nothing bans _adding_ constness. [expr.static.cast]/10 states that a +// pointer of type cv void can be cast to pointer to object type. + +struct X; +struct Y {}; +struct Z : Y {}; + +void fn (void *p, void const *cp, Y *yp, Y const *ycp, Z *zp, Z const *zcp) +{ + static_cast <X *> (p); + static_cast <X const *> (p); + static_cast <int *> (p); + static_cast <int const *> (p); + static_cast <int **> (p); + static_cast <int const **> (p); + static_cast <int *const *> (p); + static_cast <int const *const *> (p); + + static_cast <X *> (cp); // { dg-error "" } lose const + static_cast <X const *> (cp); + static_cast <int *> (cp); // { dg-error "" } lose const + static_cast <int const *> (cp); + static_cast <int **> (cp); // { dg-error "" } lose const + static_cast <int const **> (cp); // { dg-error "" } lose const + static_cast <int *const *> (cp); + static_cast <int const *const *> (cp); + + static_cast <Z *> (yp); + static_cast <Z const *> (yp); + + static_cast <Z *> (ycp); // { dg-error "" } lose const + static_cast <Z const *> (ycp); + + static_cast <Y *> (zp); + static_cast <Y const *> (zp); + + static_cast <Y *> (zcp); // { dg-error "" } lose const + static_cast <Y const *> (zcp); +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/cast4.C b/gcc/testsuite/g++.old-deja/g++.other/cast4.C new file mode 100644 index 000000000..3348dcee8 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/cast4.C @@ -0,0 +1,63 @@ +// { dg-do assemble } + +// Copyright (C) 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 3 Jan 2000 <nathan@acm.org> + +// Derived from a bug report by Ulrich Drepper <drepper@cygnus.com> + +struct A {operator char * () { return 0;} }; +struct B {operator char * () const { return 0;} }; +struct C {operator char const * () { return 0;} }; +struct D {operator char const * () const { return 0;} }; + +void f0 () +{ + A a = A (); + B b = B (); + C c = C (); + D d = D (); + + static_cast <char *> (a); + static_cast <char *> (b); + static_cast <char *> (c); // { dg-error "" } static cast + static_cast <char *> (d); // { dg-error "" } static cast +} + +void f1 () +{ + A a = A (); + B b = B (); + C c = C (); + D d = D (); + + static_cast <const char *> (a); + static_cast <const char *> (b); + static_cast <const char *> (c); + static_cast <const char *> (d); +} + +void f2 () +{ + A const a = A (); + B const b = B (); + C const c = C (); + D const d = D (); + + static_cast <char *> (a); // { dg-error "" } static cast + static_cast <char *> (b); + static_cast <char *> (c); // { dg-error "" } static cast + static_cast <char *> (d); // { dg-error "" } static cast +} + +void f3 () +{ + A const a = A (); + B const b = B (); + C const c = C (); + D const d = D (); + + static_cast <const char *> (a); // { dg-error "" } static cast + static_cast <const char *> (b); + static_cast <const char *> (c); // { dg-error "" } static cast + static_cast <const char *> (d); +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/cast5.C b/gcc/testsuite/g++.old-deja/g++.other/cast5.C new file mode 100644 index 000000000..bae4f1695 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/cast5.C @@ -0,0 +1,38 @@ +// { dg-do assemble } + +// Copyright (C) 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 4 Feb 2000 <nathan@acm.org> + +// Array of cv T decays to pointer to cv T, and pointer to array of cv T can +// be converted to pointer to cv T. We need to make sure the `cv's don't +// confuse us. + +typedef char const *ary_t[2]; + +void f0 (ary_t const *const &ary) +{ + static_cast <void const *> (ary); + static_cast <void *> (ary); // { dg-error "" } casts away const + (void const *) (ary); +} + +void f1 (ary_t *const &ary) +{ + static_cast <void *> (ary); + static_cast <void const *> (ary); + (void const *) (ary); +} + +void f2 (ary_t const *&ary) +{ + static_cast <void const *> (ary); + static_cast <void *> (ary); // { dg-error "" } casts away const + (void const *) (ary); +} + +void f3 (ary_t *&ary) +{ + static_cast <void *> (ary); + static_cast <void const *> (ary); + (void const *) (ary); +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/cast6.C b/gcc/testsuite/g++.old-deja/g++.other/cast6.C new file mode 100644 index 000000000..4bf90fab5 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/cast6.C @@ -0,0 +1,57 @@ +// { dg-do assemble } + +// Copyright (C) 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 28 Nov 2000 <nathan@codesourcery.com> + +// We failed to reject static_cast and implicit conversions of pointers to +// member that traversed a virtual base. + +struct bar +{ + int barm; + static void a(); +}; +struct filler1 {int fm;}; +struct filler2 {int fm;}; +struct filler3 {int fm;}; +struct filler4 {int fm;}; + +struct baz : filler1, bar, filler2 +{ + int bazm; +}; + +struct foo : filler3, virtual baz, filler4 +{ + static void a(); + void b() {} + int m; +}; + +typedef void (bar::*barfPtr)(); +typedef void (foo::*foofPtr)(); +typedef int bar::*barmPtr; +typedef int foo::*foomPtr; + +struct X; +typedef void (X::*xfPtr) (); +typedef int X::*xmPtr; + +int main () +{ + { + foofPtr fp = &foo::b; + barfPtr bp = static_cast <barfPtr> (fp); // { dg-error "via virtual base" } invalid static_cast + foofPtr fp2 = static_cast <foofPtr> (bp); // { dg-error "via virtual base" } invalid static_cast + foofPtr fp3 = bp; // { dg-error "via virtual base" } cannot convert + fp3 = (foofPtr)bp; // { dg-error "via virtual base" } via virtual base + + foomPtr fmp = &foo::m; + barmPtr bmp = static_cast <barmPtr> (fmp); // { dg-error "via virtual base" } invalid static_cast + foomPtr fmp2 = static_cast <foomPtr> (bmp); // { dg-error "via virtual base" } invalid static_cast + foomPtr fmp3 = bmp; // { dg-error "via virtual base" } cannot convert + fmp3 = (foomPtr)bmp; // { dg-error "via virtual base" } via virtual base + } + + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/cast7.C b/gcc/testsuite/g++.old-deja/g++.other/cast7.C new file mode 100644 index 000000000..4f433f424 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/cast7.C @@ -0,0 +1,12 @@ +// { dg-do run } +// Test that we can add cv-quals in a static cast to a pointer-to-base type. + +struct A { int i; }; +struct B : public A {}; + +int main() +{ + int B::* bp = &B::i; + const int A::* ap = static_cast<const int A::*>(bp); + return ap != bp; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/cleanup1.C b/gcc/testsuite/g++.old-deja/g++.other/cleanup1.C new file mode 100644 index 000000000..27eb8ede4 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/cleanup1.C @@ -0,0 +1,21 @@ +// { dg-do run } +// Bug: fold is too eager about pushing down CLEANUP_POINT_EXPR. + +int d; + +struct A { + A() { } + ~A() { d = 1; } +}; + +int f (const A& a) +{ + return 1; +} + +int main () +{ + if (f (A()) && d == 0) + return 0; + return 1; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/cleanup2.C b/gcc/testsuite/g++.old-deja/g++.other/cleanup2.C new file mode 100644 index 000000000..976b86411 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/cleanup2.C @@ -0,0 +1,27 @@ +// { dg-do run } +// { dg-options "-O -fno-exceptions -w" } +// Origin: Bryan Scattergood <bryan@fsel.com> + +extern "C" void abort(); + +class A +{ +public: + A(); + ~A(); + int foo(); +}; + +A::A() {} +A::~A() { abort (); } +int A::foo() {} + +extern int f() +{ + return 0; +} + +int main() +{ + return ((f() != 0) ? A().foo() : 0); +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/cleanup4.C b/gcc/testsuite/g++.old-deja/g++.other/cleanup4.C new file mode 100644 index 000000000..8bdaa1977 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/cleanup4.C @@ -0,0 +1,34 @@ +// { dg-do assemble } +// { dg-options "-O2 -fno-exceptions" } +// Origin: Jakub Jelinek <jakub@redhat.com> + +class foo +{ +public: + foo (); + ~foo (); +}; + +class bar +{ +public: + bar (); + bar (const foo&); +}; + +int i; +foo f (); + +inline bar x () +{ + switch (i) + { + case 0: return bar (f ()); + default: return bar (); + } +} + +bar y () +{ + return x (); +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/comdat1-aux.cc b/gcc/testsuite/g++.old-deja/g++.other/comdat1-aux.cc new file mode 100644 index 000000000..34eb88ff8 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/comdat1-aux.cc @@ -0,0 +1,10 @@ +inline int f () +{ + static int i; + return ++i; +} + +int g () +{ + return f(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/comdat1.C b/gcc/testsuite/g++.old-deja/g++.other/comdat1.C new file mode 100644 index 000000000..a60c86593 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/comdat1.C @@ -0,0 +1,23 @@ +// { dg-do run } +// { dg-additional-sources " comdat1-aux.cc" } +// { dg-options "-O" } +// Test that statics in inline functions are unified between +// translation units. Currently we handle this by just suppressing +// inling and relying on unification of the function itself. + +inline int f () +{ + static int i; + return ++i; +} + +int g (); + +int main () +{ + if (f() != 1 + || g() != 2 + || f() != 3) + return 1; + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/comdat2-aux.cc b/gcc/testsuite/g++.old-deja/g++.other/comdat2-aux.cc new file mode 100644 index 000000000..283e4e092 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/comdat2-aux.cc @@ -0,0 +1,17 @@ +template <class T> +struct S { + static int f () + { + static int i; + return ++i; + } + S () {}; + ~S () {}; +}; + +typedef S<int> a; + +int g () +{ + return a::f(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/comdat2.C b/gcc/testsuite/g++.old-deja/g++.other/comdat2.C new file mode 100644 index 000000000..5c44d0c33 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/comdat2.C @@ -0,0 +1,30 @@ +// { dg-do run } +// { dg-additional-sources " comdat2-aux.cc" } +// { dg-options "-O" } +// Test that statics in inline functions are unified between +// translation units. Currently we handle this by just suppressing +// inling and relying on unification of the function itself. + +template <class T> +struct S { + static int f () + { + static int i; + return ++i; + } + S () {}; + ~S () {}; +}; + +typedef S<int> a; + +int g (); + +int main () +{ + if (a::f() != 1 + || g() != 2 + || a::f() != 3) + return 1; + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/comdat3-aux.cc b/gcc/testsuite/g++.old-deja/g++.other/comdat3-aux.cc new file mode 100644 index 000000000..fc011e27a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/comdat3-aux.cc @@ -0,0 +1,6 @@ +#include "comdat3.h" + +void f () +{ + const bool *p = &A<int>::b; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/comdat3.C b/gcc/testsuite/g++.old-deja/g++.other/comdat3.C new file mode 100644 index 000000000..2a538cad9 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/comdat3.C @@ -0,0 +1,14 @@ +// { dg-do run } +// { dg-additional-sources " comdat3-aux.cc" } +// Test that duplicate elimination of implicit instantiations of static +// data members works properly. + +// Additional files: comdat3.h + +#include "comdat3.h" + +int main () +{ + const bool *p = &A<int>::b; + f (); +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/comdat3.h b/gcc/testsuite/g++.old-deja/g++.other/comdat3.h new file mode 100644 index 000000000..e2ec97090 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/comdat3.h @@ -0,0 +1,8 @@ +template <class T> struct A { + static const bool b = false; +}; + +template <class T> +const bool A<T>::b; + +void f (); diff --git a/gcc/testsuite/g++.old-deja/g++.other/comdat4-aux.cc b/gcc/testsuite/g++.old-deja/g++.other/comdat4-aux.cc new file mode 100644 index 000000000..e0556a529 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/comdat4-aux.cc @@ -0,0 +1,40 @@ +extern void +bar (int x); + +inline void +foo (int i) +{ + switch (i) + { + case 3: + case 5: + case 6: + case 9: + case 15: + bar (1); + break; + case 2: + case 4: + case 7: + case 10: + case 11: + case 12: + bar (2); + break; + case 0: + case 1: + case 8: + case 13: + case 16: + bar (3); + break; + case 14: + bar (4); + break; + default: + bar (5); + break; + } +} + +void *fooaddr2 = (void *) foo; diff --git a/gcc/testsuite/g++.old-deja/g++.other/comdat4.C b/gcc/testsuite/g++.old-deja/g++.other/comdat4.C new file mode 100644 index 000000000..28b26a1df --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/comdat4.C @@ -0,0 +1,57 @@ +// PR c++/16276 +// { dg-do link } +// { dg-additional-sources " comdat4-aux.cc" } +// { dg-options "-O2" } + +extern void +bar (int x); + +inline void +foo (int i) +{ + switch (i) + { + case 3: + case 5: + case 6: + case 9: + case 15: + bar (1); + break; + case 2: + case 4: + case 7: + case 10: + case 11: + case 12: + bar (2); + break; + case 0: + case 1: + case 8: + case 13: + case 16: + bar (3); + break; + case 14: + bar (4); + break; + default: + bar (5); + break; + } +} + +void *fooaddr = (void *) foo; + +void +bar (int x) +{ + __asm __volatile ("" : : "r" (x)); +} + +int +main (void) +{ + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/comdat5-aux.cc b/gcc/testsuite/g++.old-deja/g++.other/comdat5-aux.cc new file mode 100644 index 000000000..e6ee7c74f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/comdat5-aux.cc @@ -0,0 +1 @@ +#include "comdat4-aux.cc" diff --git a/gcc/testsuite/g++.old-deja/g++.other/comdat5.C b/gcc/testsuite/g++.old-deja/g++.other/comdat5.C new file mode 100644 index 000000000..ad707f572 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/comdat5.C @@ -0,0 +1,7 @@ +// PR target/17828 +// { dg-do link { target fpic } } +// { dg-additional-sources " comdat5-aux.cc" } +// { dg-options "-O2 -fPIC" } +// { dg-skip-if "requires unsupported run-time relocation" { spu-*-* } { "*" } { "" } } + +#include "comdat4.C" diff --git a/gcc/testsuite/g++.old-deja/g++.other/cond1.C b/gcc/testsuite/g++.old-deja/g++.other/cond1.C new file mode 100644 index 000000000..64cc728fc --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/cond1.C @@ -0,0 +1,26 @@ +// { dg-do link } +// Origin: Mark Mitchell <mark@codesourcery.com> + +template <class T> +void f (T&) ; + +template <> +void f (void (&)()) +{ +} + +void g () +{ +} + +void h () +{ +} + +bool b; + +int main () +{ + f (b ? g : h); +} + diff --git a/gcc/testsuite/g++.old-deja/g++.other/cond2.C b/gcc/testsuite/g++.old-deja/g++.other/cond2.C new file mode 100644 index 000000000..a7c369110 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/cond2.C @@ -0,0 +1,11 @@ +// { dg-do assemble } +// Origin: Loring Holden <lsh@cs.brown.edu> + +class Wpt {}; + +class RAYhit { + protected: + Wpt _nearpt; + public: + Wpt surf () const { return true ? Wpt(): _nearpt; } +}; diff --git a/gcc/testsuite/g++.old-deja/g++.other/cond3.C b/gcc/testsuite/g++.old-deja/g++.other/cond3.C new file mode 100644 index 000000000..1fe95fcbb --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/cond3.C @@ -0,0 +1,18 @@ +// { dg-do assemble } +// Origin: Loring Holden <lsh@cs.brown.edu> + +class Wtransf {}; + +const Wtransf Identity2 = Wtransf (); + +class HELPER { + public: + int current() const { return 0; } +}; + +void +problem_function() +{ + HELPER tm; + Wtransf delta = (tm.current()) ? Identity2 : Wtransf(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/cond4.C b/gcc/testsuite/g++.old-deja/g++.other/cond4.C new file mode 100644 index 000000000..6b28824d1 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/cond4.C @@ -0,0 +1,31 @@ +// { dg-do assemble } +// Origin: Loring Holden <lsh@cs.brown.edu> + +template <class V> +class _vec3d +{ + public: + double _x, _y; +}; + +class Wvec : public _vec3d<int> { }; + +template <class T> +class TDI { + public: + T &get(); +}; + +template <class T> +class hashvar { + public : + T _val; + TDI<T> *val() const; + T get() const { return true ? val()->get() : _val; } +}; + +int +main() { + hashvar<Wvec> CONSTRAINT_DIR; + CONSTRAINT_DIR.get(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/cond5.C b/gcc/testsuite/g++.old-deja/g++.other/cond5.C new file mode 100644 index 000000000..994ea6d95 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/cond5.C @@ -0,0 +1,45 @@ +// { dg-do assemble } +// { dg-options "-W -pedantic -ansi" } + +// Copyright (C) 1999, 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 1 Sep 1999 <nathan@acm.org> +// Derived from bug report from Gabriel Dos Reis +// <Gabriel.Dos-Reis@cmla.ens-cachan.fr> +// http://gcc.gnu.org/ml/gcc-bugs/1999-03n/msg00888.html + +// conditional exprs have some funny rules when one of the types is void. +// [expr.cond] 5.16, make sure we do the right things +// We have checks for mismatching enumerations, check we give them -- they had +// got lost due to changes in add_builtin_candidate and subsequent changes. + +struct X {}; +enum E1 {e1 = -1}; +enum E2 {e2 = -1}; +void f(int, ...); + +void fn(int i) +{ + double d; + int j; + + j = (i ? e1 : e2); // { dg-warning "mismatch" } + d = (i ? e1 : 1.0); // { dg-warning "non-enumeral" } + d = (i ? 1.0 : e2); // { dg-warning "non-enumeral" } + E1 e = (i ? e1 : e1); // ok + j = (i ? 1 : e2); // ok + j = (i ? e1 : 1); // ok + + j = (i ? throw X() : 1); // ok, int + j = (i ? 1 : throw X()); // ok, int + + (i ? throw X() : throw X()); // ok, void + + (i ? i : j) = 1; // ok, int & + (i ? throw X() : j) = 1; // { dg-error "lvalue" } + (i ? j : throw X()) = 1; // { dg-error "lvalue" } + (i ? throw X() : throw X()) = 1; // { dg-error "lvalue" } + + (i ? (void)1 : i++); // { dg-error "throw-expression" } + (i ? i++ : (void)1); // { dg-error "throw-expression" } + +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/cond6.C b/gcc/testsuite/g++.old-deja/g++.other/cond6.C new file mode 100644 index 000000000..db018a4a3 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/cond6.C @@ -0,0 +1,15 @@ +// { dg-do assemble } +// Test that the result of `x ? const E : E' is an E rvalue. +// Contributed by Jason Merrill <jason@cygnus.com> + +enum E { a }; + +bool b; + +int main () +{ + E e1 = a; + const E &er = e1; + E e2 = b ? er : a; // OK + const E* ep = &(b ? er : a); // { dg-error "" } non-lvalue +} 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 000000000..63d7366a8 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/cond7.C @@ -0,0 +1,26 @@ +// { dg-do assemble } +// +// 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); // { dg-error "" } incomplete type + a ? OVL1 : OVL2; // { dg-error "" } incomplete type +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/const1.C b/gcc/testsuite/g++.old-deja/g++.other/const1.C new file mode 100644 index 000000000..995f466fe --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/const1.C @@ -0,0 +1,9 @@ +// { dg-do assemble } + +struct S +{ + void f() + { + const int i; // { dg-error "" } uninitialized const + } +}; diff --git a/gcc/testsuite/g++.old-deja/g++.other/const2.C b/gcc/testsuite/g++.old-deja/g++.other/const2.C new file mode 100644 index 000000000..4463b9cc9 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/const2.C @@ -0,0 +1,5 @@ +// { dg-do assemble } + +struct S { + static const char* cp = "abc"; // { dg-error "" } initialization of non-const +}; diff --git a/gcc/testsuite/g++.old-deja/g++.other/conv1.C b/gcc/testsuite/g++.old-deja/g++.other/conv1.C new file mode 100644 index 000000000..4fe02d3fa --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/conv1.C @@ -0,0 +1,6 @@ +// { dg-do assemble } + +class X { +public: + const operator int (); // { dg-error "" } invalid declaration. +}; diff --git a/gcc/testsuite/g++.old-deja/g++.other/conv2.C b/gcc/testsuite/g++.old-deja/g++.other/conv2.C new file mode 100644 index 000000000..56e41039e --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/conv2.C @@ -0,0 +1,19 @@ +// { dg-do assemble } +// { dg-options "-pedantic-errors" } + +void cheat( int* i ) { ++(*i); } + +struct t { + void cheat( int& i ) { ++i; } +}; + +int main() +{ + void (t::*member)( const int& ) = &t::cheat; // { dg-error "" } conversion + void (*cheater)( const int* ) = &cheat; // { dg-error "" } converting + t t2; + const int i=1; + int j=1; + (t2.*member)( i ); + (t2.*member)( j ); +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/conv3.C b/gcc/testsuite/g++.old-deja/g++.other/conv3.C new file mode 100644 index 000000000..383932d8c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/conv3.C @@ -0,0 +1,13 @@ +// { dg-do assemble } + +// submitted by David C Binderman <dcb@pncl.co.uk> + +typedef const int ci; +typedef ci aci[ 10]; +aci var = { 2, 3, 5, 7, 11, 13 }; + +void +f() +{ + int * ip = var; // { dg-error "" } requires const_cast +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/conv4.C b/gcc/testsuite/g++.old-deja/g++.other/conv4.C new file mode 100644 index 000000000..c195e41d6 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/conv4.C @@ -0,0 +1,18 @@ +// { dg-do run } +// Testcase for proper hiding of base conversion ops. + +struct A +{ + operator const char *(); +}; + +struct B : public A +{ + operator const char *() { return 0; } +}; + +int main( void ) +{ + B b; + const char *p = b; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/conv5.C b/gcc/testsuite/g++.old-deja/g++.other/conv5.C new file mode 100644 index 000000000..fb3dccf17 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/conv5.C @@ -0,0 +1,8 @@ +// { dg-do assemble } +// { dg-options "" } + +// Based on bug report by Thomas Kunert <kunert@physik.tu-dresden.de> + + +int foo(); +const int (*bar)() = foo; // { dg-error "" } adding const diff --git a/gcc/testsuite/g++.old-deja/g++.other/conv6.C b/gcc/testsuite/g++.old-deja/g++.other/conv6.C new file mode 100644 index 000000000..7a299553e --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/conv6.C @@ -0,0 +1,29 @@ +// { dg-do run } +// Test for composite pointer types, as defined in [expr.rel], +// and common pointer to member types, as defined in [expr.eq]. + +struct A { int i; }; +struct B : public A { }; + +int main () +{ + B b; + + // The composite type is `A const *' + A* ap = &b; + const B* bp = &b; + if (ap != bp) // { dg-bogus "" } distinct types + return 1; + + // The composite type is `B const *const *' + B *const * p = 0; + B const * * q = 0; + if (p != q) // { dg-bogus "" } distinct types + return 1; + + // The common type is `int const B::*' + const int A::*apm = &A::i; + int B::*bpm = &A::i; + if (apm != bpm) // { dg-bogus "" } distinct types + return 1; +} 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 000000000..7042e147c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/conv7.C @@ -0,0 +1,46 @@ +// { dg-do assemble } +// { dg-options "-Wconversion" } +// +// 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; + return 1; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/conv8.C b/gcc/testsuite/g++.old-deja/g++.other/conv8.C new file mode 100644 index 000000000..205ad4382 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/conv8.C @@ -0,0 +1,31 @@ +// { dg-do assemble } +// Origin: Jakub Jelinek <jakub@redhat.com> + +class bar +{ +public: + bar(); + virtual ~bar(); + static void a(); +}; + +class baz : public bar +{ +}; + +class foo : virtual public baz +{ +public: + static void a(); + void b(); +}; + +typedef void (bar::*T)(); +T d; + +void foo::a() +{ + typedef void(foo::*t)(); + t c = & foo::b; + d = (T) c; // { dg-error "pointer to member" } +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/conv9.C b/gcc/testsuite/g++.old-deja/g++.other/conv9.C new file mode 100644 index 000000000..0fcf980be --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/conv9.C @@ -0,0 +1,31 @@ +// { dg-do assemble } + +struct +Foo +{ +public: + typedef void* (*copier_fn)(void const*); + void foo() const; + void bar(char const*, void const*) const; +private: + struct + Bar + { + char const* key; + void const* item; + }; +}; + +void +Foo::foo() const +{ + Bar* cp = 0; + copier_fn copyfn = 0; + + bar(cp->key, cp->item); + bar(cp->key, (copyfn) ? (*copyfn)(cp) : 0); + bar(cp->key, (copyfn) ? (*copyfn)(0) : 0); + + bar(cp->key, (copyfn) ? (*copyfn)(0) : cp->item); + bar(cp->key, (copyfn) ? (*copyfn)(cp) : cp->item); +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/copy1.C b/gcc/testsuite/g++.old-deja/g++.other/copy1.C new file mode 100644 index 000000000..978599a80 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/copy1.C @@ -0,0 +1,26 @@ +// { dg-do run } +// Bug: expand_vec_init doesn't copy arrays of builtin types. + +struct B { + B() { } + B(const B&) { } +}; + +struct A +{ + B b; + int ar[5]; +}; + +int main() +{ + A a; + for (int i = 0; i < 5; ++i) + a.ar[i] = i; + + A a2 = a; + + for (int i = 0; i < 5; ++i) + if (a2.ar[i] != a.ar[i]) + return 1; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/copy2.C b/gcc/testsuite/g++.old-deja/g++.other/copy2.C new file mode 100644 index 000000000..c3e96e103 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/copy2.C @@ -0,0 +1,22 @@ +// { dg-do run } +// Origin: Mark Mitchell <mark@codesourcery.com> + +int i; + +struct B { + B () {} + B (B&) { i = 1; } + B (const B&) { i = 2; } +}; + +struct D : public B { + D () {} +}; + +int main () +{ + D d; + D d2 (d); + if (i != 2) + 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 000000000..3b74a905f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/copy3.C @@ -0,0 +1,23 @@ +// { dg-do link } +// 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/covar1.C b/gcc/testsuite/g++.old-deja/g++.other/covar1.C new file mode 100644 index 000000000..217f01714 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/covar1.C @@ -0,0 +1,10 @@ +// { dg-do assemble } +// Origin: Jason Merrill <jason@cygnus.com> + +struct A { + virtual A& f(); +}; + +struct B: public A { + B& f(); +}; diff --git a/gcc/testsuite/g++.old-deja/g++.other/crash1.C b/gcc/testsuite/g++.old-deja/g++.other/crash1.C new file mode 100644 index 000000000..d62968919 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/crash1.C @@ -0,0 +1,7 @@ +// { dg-do assemble } +class A +{ + enum B { ONE, TWO, THREE }; // { dg-error "" } private +}; + +class A::B; // { dg-error "" } A::B is not a class type, context diff --git a/gcc/testsuite/g++.old-deja/g++.other/crash10.C b/gcc/testsuite/g++.old-deja/g++.other/crash10.C new file mode 100644 index 000000000..d0534f06d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/crash10.C @@ -0,0 +1,52 @@ +// { dg-do assemble } +// Origin: Loring Holden <lsh@cs.brown.edu> + +template <class T> +class REFptr { + public: + REFptr(); + REFptr(T *pObj); + virtual ~REFptr(); + operator T* () const; +}; + +class GEL; +class GELsubc { + public : + virtual GEL *GELcast() const; +}; +class GELptr : public REFptr<GEL>{ + public : + GELptr(const GELptr &p); + GELptr(const GELsubc &p); +}; +class GEL { }; + +class GEOM; +class GEOMptr : public REFptr<GEOM>, public GELsubc { + public: + GEOMptr() { } + GEOMptr(GEOM *g); +}; +class GEOM : public GEL { + public: + GEOM(const GEOMptr &o); + GEOM(); +}; + +class TEXT2D; +class TEXT2Dptr : public REFptr<TEXT2D> { + public: + TEXT2Dptr(); + TEXT2Dptr(TEXT2D *g); +}; +class TEXT2D : public GEOM { }; + +void testit(const GELptr g); + +void +FPS() +{ + TEXT2Dptr fps_text; + testit(GEOMptr(&*fps_text)); +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/crash11.C b/gcc/testsuite/g++.old-deja/g++.other/crash11.C new file mode 100644 index 000000000..16fd61042 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/crash11.C @@ -0,0 +1,21 @@ +// { dg-do assemble } +// Origin: Alfred Minarik <a8601248@unet.univie.ac.at> + +template <typename T> +struct allocator +{ + typedef int size_type; +}; + +template <typename T> +struct string +{ + typedef typename allocator<T>::size_type size_type; + + static size_type size; + + size_type + max_size() const { return size; } +}; + +template struct string <char>; diff --git a/gcc/testsuite/g++.old-deja/g++.other/crash12.C b/gcc/testsuite/g++.old-deja/g++.other/crash12.C new file mode 100644 index 000000000..73bbb8bb6 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/crash12.C @@ -0,0 +1,17 @@ +// { dg-do assemble } +// { dg-options "" } +// Origin: Alfred Minarik <a8601248@unet.univie.ac.at> + +template<typename T> +struct S +{ + void f() {} +}; + +int main() +{ + S<int> s; + int len = 50; + char array[len]; + s.f(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/crash13.C b/gcc/testsuite/g++.old-deja/g++.other/crash13.C new file mode 100644 index 000000000..03b25df89 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/crash13.C @@ -0,0 +1,13 @@ +// { dg-do assemble } + +struct Base_bitset { + unsigned M_w[2]; + void M_do_right_shift(); +}; + + +void Base_bitset::M_do_right_shift () +{ + unsigned n = 0; + M_w[0] = M_w[n + 1] ; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/crash14.C b/gcc/testsuite/g++.old-deja/g++.other/crash14.C new file mode 100644 index 000000000..d97577d1d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/crash14.C @@ -0,0 +1,22 @@ +// { dg-do assemble } +// Origin: Mark Mitchell <mark@codesourcery.com> + +struct S +{ +}; + +struct T : public S +{ +}; + +struct U : public T +{ +}; + +void f (U); + +int main () +{ + U u; + f (u); +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/crash15.C b/gcc/testsuite/g++.old-deja/g++.other/crash15.C new file mode 100644 index 000000000..c4af169a2 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/crash15.C @@ -0,0 +1,43 @@ +// { dg-do assemble } +// { dg-options "-O2" } +// g++ crashed because we unsaved the TARGET_EXPR for the return value +// for get_allocator without first expanding it, because it was part of the +// cleanup for the temporary string. + +// Derived from libstdc++ v3 code. + + +class AA {}; + +void fee (const AA&); + +class basic_string +{ +public: + basic_string(const char*); + + ~basic_string() + { fee (this->get_allocator()); } + + AA get_allocator(); +}; + +class failure +{ +public: + failure(const basic_string& __str); +}; + +class foo +{ +public: + foo(int x) + { + throw failure (""); + } +}; + +void test05() +{ + foo ofs(0); +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/crash16.C b/gcc/testsuite/g++.old-deja/g++.other/crash16.C new file mode 100644 index 000000000..22583260a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/crash16.C @@ -0,0 +1,20 @@ +// { dg-do assemble } +// { dg-options "-O2" } +// Origin: scott snyder <snyder@fnal.gov> + + +void _S_initialize(); + +class locale +{ +public: + locale() throw() + { _S_initialize (); } +}; + +void foo(const locale& __loc); + +void print (const int&) +{ + foo(locale()); +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/crash17.C b/gcc/testsuite/g++.old-deja/g++.other/crash17.C new file mode 100644 index 000000000..35195492f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/crash17.C @@ -0,0 +1,6 @@ +// { dg-do assemble } +// Origin: Dima Volodin <dvv@dvv.org> + +class C { + static int const N (1000); // { dg-error "" } invalid declaration +}; diff --git a/gcc/testsuite/g++.old-deja/g++.other/crash19.C b/gcc/testsuite/g++.old-deja/g++.other/crash19.C new file mode 100644 index 000000000..bafde81c5 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/crash19.C @@ -0,0 +1,12 @@ +// { dg-do assemble } +// Origin: Mark Mitchell <mark@codesourcery.com> + +template <class T> +struct S {}; + +struct X {}; + +void f () { + typedef X Y; + S<Y> s; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/crash2.C b/gcc/testsuite/g++.old-deja/g++.other/crash2.C new file mode 100644 index 000000000..3d62d04eb --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/crash2.C @@ -0,0 +1,9 @@ +// { dg-do assemble } + +struct A { + int rep; + static const A a(0); // { dg-error "" } initialization + static const A b = 3; // { dg-error "" } initialization + static const A& c = 2; // { dg-error "" } initialization + A(int x) : rep(x) {} +}; diff --git a/gcc/testsuite/g++.old-deja/g++.other/crash20.C b/gcc/testsuite/g++.old-deja/g++.other/crash20.C new file mode 100644 index 000000000..dd236e120 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/crash20.C @@ -0,0 +1,38 @@ +// { dg-do assemble } + +#include <typeinfo> + +struct GcspFlags +{ + enum Enum + { + OffYes, + OffNo, + Root + }; + + static char const* name(Enum flag); + + template<Enum GCSP_FLAG> + struct btmFlag + { + static Enum const f=OffNo; + }; + +}; + +template<> +struct +GcspFlags::btmFlag<GcspFlags::OffYes> +{ + static GcspFlags::Enum const f=GcspFlags::OffYes; +}; + +int +main () +{ + GcspFlags::btmFlag<GcspFlags::OffYes> f; + const std::type_info& ti = typeid (f); + return 0; +} + diff --git a/gcc/testsuite/g++.old-deja/g++.other/crash21.C b/gcc/testsuite/g++.old-deja/g++.other/crash21.C new file mode 100644 index 000000000..62ba7f946 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/crash21.C @@ -0,0 +1,14 @@ +// { dg-do assemble } +// Origin: Gabriel Dos Reis <gdr@codesourcery.com> + +struct A { + virtual void f(int&) const; +}; + +struct B : public A { + int x; +}; + +void B::f(int& t) { // { dg-error "" } undeclared method + x = t; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/crash22.C b/gcc/testsuite/g++.old-deja/g++.other/crash22.C new file mode 100644 index 000000000..0890aef4a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/crash22.C @@ -0,0 +1,56 @@ +// { dg-do link } +// { dg-options "-O2" } + +class foo +{ +}; + +typedef void *voidp; +class vect : public foo +{ +public: + voidp& a(); + int b(); +}; + +class bar +{ +public: + bar *c(bool (*f)(bar *node), voidp g) + { + int i=0; + bool j; + while (i < d.b()){ + j = (f == __null) || f((bar*)d.a()); + if (j) + ((bar*)d.a())->c(f, g); + i++; + } + return this; + } + public: + vect d; + bar *e(foo *k); +}; + +bar *bar::e(foo *k) +{ + return c(__null, k); +} + +voidp &vect::a() +{ + static voidp x; + return x; +} + +int vect::b() +{ + static int x; + return x; +} + +int main() +{ + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/crash23.C b/gcc/testsuite/g++.old-deja/g++.other/crash23.C new file mode 100644 index 000000000..13249020f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/crash23.C @@ -0,0 +1,7 @@ +// { dg-do assemble } +// Origin: Gerald Pfeifer <pfeifer@dbai.tuwien.ac.at> + +class T; +inline void operator<(T&, T&) { } // { dg-error "" } previous definition +inline void operator<(T&, T&) { } // { dg-error "" } duplicate definition + diff --git a/gcc/testsuite/g++.old-deja/g++.other/crash24.C b/gcc/testsuite/g++.old-deja/g++.other/crash24.C new file mode 100644 index 000000000..b1fa01c9b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/crash24.C @@ -0,0 +1,19 @@ +// { dg-do assemble } +// Origin: Jakub Jelinek <jakub@redhat.com> + +class foo { + public: + class __iterator; + friend class __iterator; + typedef __iterator const_iterator; + virtual ~foo() { } + __iterator begin(); // { dg-message "foo::begin|no known conversion for implicit" } +}; +static void iteratorTest(const foo &x) +{ + foo::const_iterator i = x.begin(); // { dg-error "incomplete type" "incomplete type" } + // { dg-message "candidate" "candidate note" { target *-*-* } 14 } + // { dg-error "no matching" "no matching" { target *-*-* } 14 } + for (; i; ++i) + *i; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/crash25.C b/gcc/testsuite/g++.old-deja/g++.other/crash25.C new file mode 100644 index 000000000..5460e0388 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/crash25.C @@ -0,0 +1,18 @@ +// { dg-do assemble } +// { dg-options "-fshow-column" } +// Origin: Jakub Jelinek <jakub@redhat.com> + +class X { // { dg-error "1:new types may not be defined in a return type" "new types" } +// { dg-message "1:\\(perhaps a semicolon is missing after the definition of 'X'\\)" "note" { target *-*-* } 5 } +public: + X(); + virtual ~X(); +} + +X::x() // { dg-error "6:no 'X X::x\\(\\)' member function declared in class 'X'" } +{ +} + +X::~x() // { dg-error "6:expected class-name before '\\(' token" } +{ +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/crash26.C b/gcc/testsuite/g++.old-deja/g++.other/crash26.C new file mode 100644 index 000000000..c9a12d0fb --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/crash26.C @@ -0,0 +1,13 @@ +// { dg-do assemble } +// Origin: Jakub Jelinek <jakub@redhat.com> + +class foo { +public: + foo(int); +}; + +void bar(bool x) +{ + if(x) + foo *a = new foo(foo::not); // { dg-error "" } +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/crash27.C b/gcc/testsuite/g++.old-deja/g++.other/crash27.C new file mode 100644 index 000000000..b02f3103b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/crash27.C @@ -0,0 +1,12 @@ +// { dg-do assemble } +// Origin: Jakub Jelinek <jakub@redhat.com> + +X(Y(long, Type, CLink)); break; default: break; } } } // { dg-error "" } + +struct A { + inline A (); +}; + +inline A::A () +{ +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/crash28.C b/gcc/testsuite/g++.old-deja/g++.other/crash28.C new file mode 100644 index 000000000..59f1e844e --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/crash28.C @@ -0,0 +1,35 @@ +// { dg-do assemble } +// Origin: Jakub Jelinek <jakub@redhat.com> + +namespace N +{ + class X; + template <class T> + class Y + { + public: + inline Y () {} + inline operator const Y<X> & () const + { + return *reinterpret_cast<const Y<X> *>(this); + } + }; +} +class bar +{ +public: + inline bar () {} + inline bar (const ::N::Y< ::N::X>& a); +}; + +class foo +{ + bool b; +public: + foo(); + void x () throw(bar); +}; +void foo::x() throw(bar) +{ + if (!b) throw bar (static_cast<::N::X*>(this)); // { dg-error "lambda expressions|expected" } parse error +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/crash29.C b/gcc/testsuite/g++.old-deja/g++.other/crash29.C new file mode 100644 index 000000000..cbcfcf5c8 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/crash29.C @@ -0,0 +1,13 @@ +// { dg-do assemble } +// Origin: Jakub Jelinek <jakub@redhat.com> + +class bar +{ +public: + void foo (); + void baz (); +}; +void bar::foo () +{ + baz x(); // { dg-error "" } +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/crash3.C b/gcc/testsuite/g++.old-deja/g++.other/crash3.C new file mode 100644 index 000000000..5a2182716 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/crash3.C @@ -0,0 +1,14 @@ +// { dg-do assemble } +// { dg-options "-g -O2" } + +inline void f() { + struct S {}; + S s; +} + +void g() +{ + for (int i = 0; i < 2; ++i) + f(); +} + diff --git a/gcc/testsuite/g++.old-deja/g++.other/crash30.C b/gcc/testsuite/g++.old-deja/g++.other/crash30.C new file mode 100644 index 000000000..043d54fa4 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/crash30.C @@ -0,0 +1,17 @@ +// { dg-do assemble } +// Origin: Jakub Jelinek <jakub@redhat.com> + +struct foo +{ + foo(); + void x(); +}; + +void foo::x() throw(bar) // { dg-error "" } parse error +{ +} + +void bar() +{ + foo x; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/crash31.C b/gcc/testsuite/g++.old-deja/g++.other/crash31.C new file mode 100644 index 000000000..b6d19527a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/crash31.C @@ -0,0 +1,9 @@ +// { dg-do assemble } +// Origin: Jakub Jelinek <jakub@redhat.com> + +namespace bar +{ +struct foo +{ + foo(); +}; // { dg-error "expected" } diff --git a/gcc/testsuite/g++.old-deja/g++.other/crash32.C b/gcc/testsuite/g++.old-deja/g++.other/crash32.C new file mode 100644 index 000000000..b9c4cf98c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/crash32.C @@ -0,0 +1,29 @@ +// { dg-do assemble } +// Origin: Jakub Jelinek <jakub@redhat.com> + +struct foo +{ + enum e + { + not // { dg-error "" } + }; // { dg-bogus "" } + ~foo(); // { dg-bogus "" "" { xfail *-*-* } } + void x (foo *&a, bool b = (unsigned char)0); +}; // { dg-bogus "" "" { xfail *-*-* } } + +namespace N +{ + struct bar; + + template<class T> + struct baz + { + baz(T *p); + }; + + typedef baz<bar> c; +} + +{ + int a; +}; diff --git a/gcc/testsuite/g++.old-deja/g++.other/crash33.C b/gcc/testsuite/g++.old-deja/g++.other/crash33.C new file mode 100644 index 000000000..1d2227aa6 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/crash33.C @@ -0,0 +1,13 @@ +// { dg-do assemble } +// Origin: Jakub Jelinek <jakub@redhat.com> + +template <class T> +inline const T& bar(const T& a, const T& b) +{ + return a < b ? b : a; +} + +int foo(void) +{ + return bar(sizeof(int), sizeof(long)); +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/crash34.C b/gcc/testsuite/g++.old-deja/g++.other/crash34.C new file mode 100644 index 000000000..4e3c30a9a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/crash34.C @@ -0,0 +1,23 @@ +// { dg-do assemble } +// Origin: Jakub Jelinek <jakub@redhat.com> + + +class v +{ + double x, y; +public: + v(); +}; + +class w : public v { +public : + static const w X; + w(); +}; + +void bar(w x); + +void foo() +{ + bar(w::X); +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/crash35.C b/gcc/testsuite/g++.old-deja/g++.other/crash35.C new file mode 100644 index 000000000..bb52ff779 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/crash35.C @@ -0,0 +1,7 @@ +// { dg-do assemble } +// Origin: Jakub Jelinek <jakub@redhat.com> + +void foo() +{ + if [ // { dg-error "" } parse error +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/crash36.C b/gcc/testsuite/g++.old-deja/g++.other/crash36.C new file mode 100644 index 000000000..4002ce3af --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/crash36.C @@ -0,0 +1,21 @@ +// { dg-do assemble } +// Copyright (C) 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 7 Nov 2000 <nathan@codesourcery.com> + +// Bug 573. We ICE'd verifying operator new and operator delete conformed +// to the standard's expectation. + +void *operator new (__SIZE_TYPE__); // ok +void operator new (__SIZE_TYPE__); // { dg-error "" } must return void * +void *operator new (); // { dg-error "" } must take size_t +void *operator new (char); // { dg-error "" } must take size_t +void *operator new (__SIZE_TYPE__, ...) throw(); // ok + +void operator delete (void *) throw (); // ok +int operator delete (void *) throw (); // { dg-error "" } must return void +void operator delete () throw (); // { dg-error "" } must take void * +void operator delete (int *) throw (); // { dg-error "" } must take void * +void operator delete (void *, __SIZE_TYPE__) throw (); // ok + +void operator delete (...) throw (); // { dg-error "" } must take void * +void operator delete (void *, ...) throw (); // ok diff --git a/gcc/testsuite/g++.old-deja/g++.other/crash37.C b/gcc/testsuite/g++.old-deja/g++.other/crash37.C new file mode 100644 index 000000000..900fd72cd --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/crash37.C @@ -0,0 +1,18 @@ +// { dg-do assemble } + +// Copyright (C) 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 23 Nov 2000 <nathan@codesourcery.com> + +// bug 706. We iced when meeting a decl with type error-mark-node + +class bifstream; + + +int main() +{ + bifstream bifs; // { dg-error "" } incomplete type + if (!bifs) + { + } + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/crash38.C b/gcc/testsuite/g++.old-deja/g++.other/crash38.C new file mode 100644 index 000000000..d07115e51 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/crash38.C @@ -0,0 +1,19 @@ +// { dg-do assemble } + +// Copyright (C) 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 28 Nov 2000 <nathan@codesourcery.com> + +// Bug 611. We ICEd when calling a member function returning an incomplete +// type by value. + +struct X; // { dg-error "" } forward ref + +struct Y +{ + X foo (); +}; + +void baz (Y *p) +{ + p->foo (); // { dg-error "" } incomplete +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/crash39.C b/gcc/testsuite/g++.old-deja/g++.other/crash39.C new file mode 100644 index 000000000..a7af2881b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/crash39.C @@ -0,0 +1,18 @@ +// { dg-do assemble } + +// Copyright (C) 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 10 Jan 2001 <nathan@codesourcery.com> + +// Bug 595. We failed to clear out some things after seeing a duplicate +// struct definition. That caused us to become inconsistent. + +struct X +{ + ~X (); +}; +struct S { X a; }; // { dg-error "" } previous defn +struct S { X a; }; // { dg-error "" } redefinition + +void c1(S s) +{ +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/crash4.C b/gcc/testsuite/g++.old-deja/g++.other/crash4.C new file mode 100644 index 000000000..929847196 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/crash4.C @@ -0,0 +1,7 @@ +// { dg-do assemble } + +struct T { + struct S __attribute__ ((packed)) { // { dg-error "" } parse error + int i; + }; +}; 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 000000000..4eb0233b3 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/crash40.C @@ -0,0 +1,19 @@ +// { dg-do assemble } +// 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 000000000..77f152b49 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/crash41.C @@ -0,0 +1,13 @@ +// { dg-do assemble } +// +// 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 + +@ // { dg-error "" } parse error +int a; #// { dg-error "" } parse error +## // { dg-error "" } parse error +$ // { dg-error "" } parse error +£ // { dg-error "" } parse error +` // { dg-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 000000000..a6d9e6149 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/crash42.C @@ -0,0 +1,17 @@ +// { dg-do assemble } +// { dg-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/crash5.C b/gcc/testsuite/g++.old-deja/g++.other/crash5.C new file mode 100644 index 000000000..070410296 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/crash5.C @@ -0,0 +1,21 @@ +// { dg-do assemble } + +class TecMesh {}; + +extern TecMesh& m; + +struct X { + X(TecMesh&); +}; + +struct D { + D(); + TecMesh& Mesh; +}; + + +D::D () + : Mesh(m) +{ + X x(D::Mesh); +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/crash6.C b/gcc/testsuite/g++.old-deja/g++.other/crash6.C new file mode 100644 index 000000000..6c1b7f69e --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/crash6.C @@ -0,0 +1,19 @@ +// { dg-do assemble } +// { dg-options "-O2" } + +struct E +{ + int f(int); +}; + +void ha() +{ + enum {X = 0}; + + int A, C; + + E vList[10]; + + A = (C + 1) % 3; + vList[1].f(A); +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/crash60.C b/gcc/testsuite/g++.old-deja/g++.other/crash60.C new file mode 100644 index 000000000..06f31272b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/crash60.C @@ -0,0 +1,7 @@ +// { dg-do assemble } + +void foo () +{ + int e; + e := e; // { dg-error "" } parse error +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/crash7.C b/gcc/testsuite/g++.old-deja/g++.other/crash7.C new file mode 100644 index 000000000..d579df0bf --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/crash7.C @@ -0,0 +1,11 @@ +// { dg-do assemble } + +void f() +{ + union { + private: + int i; // { dg-error "" } private + } u; + + u.i = 3; // { dg-error "" } within this context +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/crash8.C b/gcc/testsuite/g++.old-deja/g++.other/crash8.C new file mode 100644 index 000000000..5e35793e8 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/crash8.C @@ -0,0 +1,10 @@ +// { dg-do assemble } +// Origin: Jason Merrill <jason@cygnus.com> + +int main() +{ + void f(); + class A { + friend void f(); + }; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/crash9.C b/gcc/testsuite/g++.old-deja/g++.other/crash9.C new file mode 100644 index 000000000..a0d487320 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/crash9.C @@ -0,0 +1,9 @@ +// { dg-do assemble } +// Origin: Jason Merrill <jason@cygnus.com> + +struct A { }; +struct B : public A +{ + int A; +}; +struct C : public B { }; diff --git a/gcc/testsuite/g++.old-deja/g++.other/ctor1-aux.cc b/gcc/testsuite/g++.old-deja/g++.other/ctor1-aux.cc new file mode 100644 index 000000000..9990ca293 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/ctor1-aux.cc @@ -0,0 +1,12 @@ +// Origin: Mark Mitchell <mark@codesourcery.com> + +template <class T> +struct S { + template <class U> + S (U); +}; + +int main () +{ + S<int> (3.0); +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/ctor1.C b/gcc/testsuite/g++.old-deja/g++.other/ctor1.C new file mode 100644 index 000000000..e813d20b1 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/ctor1.C @@ -0,0 +1,16 @@ +// { dg-do run } +// { dg-additional-sources " ctor1-aux.cc" } + +// Origin: Mark Mitchell <mark@codesourcery.com> + +template <class T> +struct S { + template <class U> + S (U); +}; + +template <class T> +template <class U> +S<T>::S (U) {} + +template S<int>::S (double); diff --git a/gcc/testsuite/g++.old-deja/g++.other/cvqual1.C b/gcc/testsuite/g++.old-deja/g++.other/cvqual1.C new file mode 100644 index 000000000..e00590a26 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/cvqual1.C @@ -0,0 +1,10 @@ +// { dg-do assemble } +// Origin: Mark Mitchell <mark@codesourcery.com> + +int i = 3; +void *pv=&i; +const void* pcv=&i; +int main() +{ + pcv = 0 ? pv : pcv; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/cvt1.C b/gcc/testsuite/g++.old-deja/g++.other/cvt1.C new file mode 100644 index 000000000..aa030827a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/cvt1.C @@ -0,0 +1,23 @@ +// { dg-do assemble } + +typedef int Array_T[2]; + +struct S1 { + S1(const Array_T&); +}; + +struct S2 { + S1 g(); + Array_T a; +}; + +S1 S2::g() +{ + return S1(a); +} + +void h() +{ + S2 s2; + s2.g(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/dcast1.C b/gcc/testsuite/g++.old-deja/g++.other/dcast1.C new file mode 100644 index 000000000..830def8cb --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/dcast1.C @@ -0,0 +1,15 @@ +// { dg-do assemble } + +class C { +public: + virtual void f(); +}; + +extern volatile C* cp; +extern volatile C& cr; + +void f () +{ + dynamic_cast<void*>(cp); // { dg-error "" } cannot dynamic_cast + dynamic_cast<C&>(cr); // { dg-error "" } cannot dynamic_cast +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/dcast2.C b/gcc/testsuite/g++.old-deja/g++.other/dcast2.C new file mode 100644 index 000000000..0f08e066e --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/dcast2.C @@ -0,0 +1,17 @@ +// { dg-do assemble } + +// Based on a testcase by Ruslan Shevchenko <Ruslan@Shevchenko.Kiev.UA> + +struct B { + virtual ~B(); +}; + +struct D : public B { +}; + +void foo() { + B x; + dynamic_cast<D*>(&x); // { dg-warning "" } will never succeed + B* p = &x; + dynamic_cast<D*>(p); +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/debug1.C b/gcc/testsuite/g++.old-deja/g++.other/debug1.C new file mode 100644 index 000000000..58fd2ca19 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/debug1.C @@ -0,0 +1,48 @@ +// { dg-do assemble } +// { dg-options "-g" } + +typedef unsigned int size_t; + + +struct dummy { }; + +struct arrrrrgh { }; + + +template<class Par,class Rand = arrrrrgh> +struct whyyyyyyy { }; + + + + +template<class T, class S =dummy> +struct grrrrrrrr { }; + + +template<class Par, class Par2 =Par, class Rand =arrrrrgh> +class no_future +{ +public: + + + template<class S> + no_future(const grrrrrrrr<whyyyyyyy<Par,Rand>*,S>& man ) { } + + ~no_future( ) { } + +private: + + + no_future(const no_future&); + no_future& operator=(const no_future&); +}; + + +int main( ) +{ + grrrrrrrr<whyyyyyyy<double>*> man; + + no_future<double> here(man); + + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/debug2.C b/gcc/testsuite/g++.old-deja/g++.other/debug2.C new file mode 100644 index 000000000..f5f0a4f2e --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/debug2.C @@ -0,0 +1,31 @@ +// { dg-do assemble } +// { dg-options "-funroll-loops -O2 -g" } + +inline void f() +{ + typedef int T; +} + +inline void g() +{ + typedef double U; +} + +int n; + +struct B +{ + ~B() { + for (int i = 0; i < n; ++i) + g(); + } +}; + +struct D : public B { + ~D() { + for (int j = 0; j < n; ++j) + f(); + } +}; + +D d; diff --git a/gcc/testsuite/g++.old-deja/g++.other/debug3.C b/gcc/testsuite/g++.old-deja/g++.other/debug3.C new file mode 100644 index 000000000..1b5507b16 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/debug3.C @@ -0,0 +1,22 @@ +// { dg-do assemble } +// { dg-options "-O2" } +// Origin: Mark Mitchell <mark@codesourcery.com> + +struct S +{ + ~S(); +}; + +inline void f() +{ + static S s; +} + +typedef void (*fn_t)(); + +fn_t g() +{ + return &f; +} + + diff --git a/gcc/testsuite/g++.old-deja/g++.other/debug4.C b/gcc/testsuite/g++.old-deja/g++.other/debug4.C new file mode 100644 index 000000000..e6c640792 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/debug4.C @@ -0,0 +1,6 @@ +// { dg-do assemble } +// { dg-options "-g" } + +typedef volatile struct { + int i; +} mutex_t; diff --git a/gcc/testsuite/g++.old-deja/g++.other/debug5.C b/gcc/testsuite/g++.old-deja/g++.other/debug5.C new file mode 100644 index 000000000..706eabec5 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/debug5.C @@ -0,0 +1,15 @@ +// { dg-do assemble } +// { dg-options "-g" } +// Origin: Mark Mitchell <mark@codesourcery.com> + +struct S +{ + ~S (); +}; + +void f () +{ + t: + S s3; +} + diff --git a/gcc/testsuite/g++.old-deja/g++.other/debug6.C b/gcc/testsuite/g++.old-deja/g++.other/debug6.C new file mode 100644 index 000000000..a4d088413 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/debug6.C @@ -0,0 +1,24 @@ +// { dg-do assemble } +// { dg-options "-g -O2" } + +// Copyright (C) 1999 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 21 Nov 1999 <nathan@acm.org> + +// This causes assember relocation errors + +struct X +{ + virtual ~X () {} +}; + +struct Y +{ + Y (){}; +}; + +void foo () +{ + X *x = new X; + x->~X (); + Y ys[2]; +} 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 000000000..f486de1ab --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/debug7.C @@ -0,0 +1,11 @@ +// { dg-do link } +// { dg-options "-g -O2" } +// Origin: Loren James Rittle <rittle@latour.rsch.comm.mot.com> + +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 000000000..d50aec487 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/debug8.C @@ -0,0 +1,21 @@ +// { dg-do assemble } +// { dg-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/debug9.C b/gcc/testsuite/g++.old-deja/g++.other/debug9.C new file mode 100644 index 000000000..2ddc927d8 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/debug9.C @@ -0,0 +1,42 @@ +// { dg-do assemble } +// { dg-options "-g" } + +// Copyright (C) 2001 Free Software Foundation, Inc. +// Contributed by Jeffrey D. Oldham 2001 May 17 <oldham@codesourcery.com>. + +// This illustrates that debugging information for CONCAT RTL's +// supports only COMPLEX_TYPE types, not other types. + +namespace std { + template<typename _Tp> class complex; + + template<> class complex<double> + { + public: + complex(double =0.0, double =0.0); + + private: + typedef __complex__ double _ComplexT; + _ComplexT _M_value; + }; + + inline + complex<double>::complex(double __r, double __i) + { + __real__ _M_value = __r; + __imag__ _M_value = __i; + } +} + +template <int Dim, class T> +class Engine +{ +public: + Engine (T val = T()) {} +}; + +int main() +{ + Engine<1, std::complex<double> > e; + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/decl1.C b/gcc/testsuite/g++.old-deja/g++.other/decl1.C new file mode 100644 index 000000000..07bcc9145 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/decl1.C @@ -0,0 +1,9 @@ +// { dg-do assemble } +// Based on a test case by Phil Blecker <tmwg@inxservices.com> + + +int foo(int); +int bar() { + int baz(int(foo(0))); + int foo = baz; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/decl2.C b/gcc/testsuite/g++.old-deja/g++.other/decl2.C new file mode 100644 index 000000000..a466a207a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/decl2.C @@ -0,0 +1,7 @@ +// { dg-do assemble } +// Based on a testcase by Maciej Radziejewski <maciejr@iws.uni-stuttgart.de> + +int i(0)(1); // { dg-error "" } multiple initialization +int j(2) = 3; // { dg-error "" } multiple initialization +int k(4)(5)(6); // { dg-error "" } multiple initialization +int m, n(7)(8); // { dg-error "" } multiple initialization diff --git a/gcc/testsuite/g++.old-deja/g++.other/decl3.C b/gcc/testsuite/g++.old-deja/g++.other/decl3.C new file mode 100644 index 000000000..bdcfcb02c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/decl3.C @@ -0,0 +1,19 @@ +// { dg-do assemble } + +// Origin: Adapted by Nathan Sidwell 29 Apr 1999 <nathan@acm.org> +// from a test case submitted by Corey Kosak <kosak@cs.cmu.edu> +// http://gcc.gnu.org/ml/gcc-bugs/1999-04n/msg00505.html + +// We should not allow arrays of abstract type. [class.abstract/2] + +struct cow_t { // { dg-message "pure" } + virtual void f()=0; // { dg-message "note" } +}; + + +int main() +{ + cow_t cow[2]; // { dg-error "invalid abstract type" } + cow[0].f(); + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/decl4.C b/gcc/testsuite/g++.old-deja/g++.other/decl4.C new file mode 100644 index 000000000..11196022c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/decl4.C @@ -0,0 +1,8 @@ +// { dg-do assemble } + +// Reported by Harri Porten <porten@tu-harburg.de> +// Simplified for testsuite by Alexandre Oliva + +struct foo { operator long double(); }; +int bar(int __opr); +int bar(int __ope); diff --git a/gcc/testsuite/g++.old-deja/g++.other/decl5.C b/gcc/testsuite/g++.old-deja/g++.other/decl5.C new file mode 100644 index 000000000..d13f7b1d0 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/decl5.C @@ -0,0 +1,79 @@ +// { dg-do assemble } + +// Copyright (C) 1999, 2000, 2002, 2003 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 22 Apr 1999 <nathan@acm.org> +// derived from a bug report by <rch@larissa.sd.bi.ruhr-uni-bochum.de> +// http://gcc.gnu.org/ml/gcc-bugs/1999-04n/msg00631.html +// the code is wrong, but we fell over badly + + +struct A { + int A::fn(); // { dg-error "extra qualification" } + int A::m; // { dg-error "extra qualification" } + struct e; + struct A::e {int i;}; // { dg-error "extra qualification" "qual" } + // { dg-error "anonymous struct" "anon" { target *-*-* } 14 } + struct A::expand { // { dg-error "qualified name" } + int m; + }; + struct Z; + expand me; // { dg-error "'expand' does not name a type" } + void foo(struct A::e); + void foo(struct A::z); // { dg-error "does not name a type" } +}; + +struct Q; +struct B { + struct A::fink { // { dg-error "does not name a class before" } + int m; + }; + struct A::Z { // { dg-error "does not enclose" } A::Z not a member of B + int m; + }; + int m; + int n; + struct ::Q { // { dg-error "global qual" } ::Q not a member of B + int m; + }; + int A::fn() { // { dg-error "cannot define member" } A::fn not a member of B + return 0; + } + void fn(struct ::Q &); + void foo(struct A::y); // { dg-error "does not name a type" } no such member +}; + +struct ::C { // { dg-error "invalid before" } extra qualification + int i; +}; + +namespace N { + int fn(); + struct F; +} + +namespace NMS +{ + void NMS::fn(); // { dg-error "explicit qual" } + int NMS::i; // { dg-error "explicit qual" } + struct NMS::D { // { dg-error "does not name a class" } + int i; + }; + struct N::E { // { dg-error "does not name a class" } no such type + int i; + }; + struct ::F { // { dg-error "global qual" } no such type + int i; + }; + int N::fn() { // { dg-error "namespace" } N::fn not a member of NMS + return 0; + } + struct N::F { // { dg-error "namespace" } N::F not a member of NMS + int i; + }; +} + +NMS::D thing; // { dg-error "'D' in namespace 'NMS' does not name a type" } +void NMS::fn() +{ + i = 3; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/decl6.C b/gcc/testsuite/g++.old-deja/g++.other/decl6.C new file mode 100644 index 000000000..40247b81e --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/decl6.C @@ -0,0 +1,26 @@ +// { dg-do assemble } +// +// Copyright (C) 1999 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 27 Sep 1999 <nathan@acm.org> + +int j(); +struct B {}; +struct A +{ + friend explicit int j(); // { dg-error "" } only ctor decls can be explicit + friend explicit B::B (); // { dg-error "" } only ctor decls can be explicit + int f(const); // { dg-error "" } ansi forbids no type + const k; // { dg-error "" } ansi forbids no type + mutable friend int j1 (); // { dg-error "" } non-member cannot be mutable + mutable typedef int d; // { dg-error "" } non-object cannot be mutable + mutable int fn (); // { dg-error "" } non-object cannot be mutable + void fn (mutable int); // { dg-error "" } non-member cannot be mutable + mutable static int s; // { dg-error "" } static cannot be mutable + mutable const int s1; // { dg-error "" } const cannot be mutable + mutable const int *s2; // ok + mutable int *const s3; // { dg-error "" } const cannot be mutable + explicit A (); // ok +}; +mutable int g; // { dg-error "" } non-member cannot be mutable +explicit A::A () {} // { dg-error "" } only ctor decls can be explicit + diff --git a/gcc/testsuite/g++.old-deja/g++.other/decl7.C b/gcc/testsuite/g++.old-deja/g++.other/decl7.C new file mode 100644 index 000000000..cc9e3a983 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/decl7.C @@ -0,0 +1,13 @@ +// { dg-do assemble } +// Origin: Mark Mitchell <mark@codesourcery.com> + +struct S +{ + void* sp; +}; + +void* f () +{ + struct S s = { &s.sp }; + return s.sp; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/decl8.C b/gcc/testsuite/g++.old-deja/g++.other/decl8.C new file mode 100644 index 000000000..705fc6c5d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/decl8.C @@ -0,0 +1,10 @@ +// { dg-do assemble } +// Origin: Sergei Organov <osv@javad.ru> + +void foo(void) +{ + extern int i; // { dg-error "" } previous declaration + extern double i; // { dg-error "" } conflicting type + extern int j; + extern int j; +} 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 000000000..9be187add --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/decl9.C @@ -0,0 +1,10 @@ +// { dg-do assemble } +// Build don't link +// Origin: batali@cogsci.ucsd.edu +// Contributed by Gabriel Dos Reis <gdr@codesourcery.com> + +typedef struct { } S; // OK +typedef struct { }; // { dg-error "" } Missing type-name + +typedef union { } U; // OK +typedef union { }; // { dg-error "" } Missing type-name diff --git a/gcc/testsuite/g++.old-deja/g++.other/defarg1.C b/gcc/testsuite/g++.old-deja/g++.other/defarg1.C new file mode 100644 index 000000000..773336ca0 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/defarg1.C @@ -0,0 +1,28 @@ +// { dg-do assemble } + +int f (int x) +{ + extern void g (int i = f (x)); // { dg-error "" } default argument uses local + + g(); + + return 0; +} + +int f (void); + +int h1 (int (*)(int) = f); +int h2 (int (*)(double) = f); // { dg-error "" } no matching f + +template <class T> +int j (T t) +{ + extern void k (int i = j (t)); // { dg-error "" } default argument uses local + + k (); + + return 0; +} + +template int j (double); + diff --git a/gcc/testsuite/g++.old-deja/g++.other/defarg2.C b/gcc/testsuite/g++.old-deja/g++.other/defarg2.C new file mode 100644 index 000000000..cc03cebc1 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/defarg2.C @@ -0,0 +1,16 @@ +// { dg-do run } +// Test that default args don't mess up pmf type comparisons. +// Contributed by Jason Merrill <jason@cygnus.com>. + +struct A { + void f (int = 0) { } +}; + +int +main () +{ + void (A::*p)(int) = 0; + p = &A::f; + if (p != &A::f) + return 1; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/defarg3.C b/gcc/testsuite/g++.old-deja/g++.other/defarg3.C new file mode 100644 index 000000000..34709613c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/defarg3.C @@ -0,0 +1,9 @@ +// { dg-do assemble } +// Origin: Mark Mitchell <mark@codesourcery.com> + +int* hp; +int* jp; + +void f (int *ip, int kp = hp - jp) +{ +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/defarg4.C b/gcc/testsuite/g++.old-deja/g++.other/defarg4.C new file mode 100644 index 000000000..ace3ee220 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/defarg4.C @@ -0,0 +1,28 @@ +// { dg-do assemble } +// Origin: scott snyder <snyder@fnal.gov> + +class complex +{ +public: + complex(); +}; + +struct MLC33 +{ + MLC33( const complex& = complex() ); +}; + +void EmptyClone() +{ + MLC33(); +} + +void makeM33() +{ + MLC33(); +} + +void Clone() +{ + MLC33(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/defarg5.C b/gcc/testsuite/g++.old-deja/g++.other/defarg5.C new file mode 100644 index 000000000..9b294766f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/defarg5.C @@ -0,0 +1,20 @@ +// { dg-do assemble } +// Bug: the SAVE_EXPR in the new expression remembers that it's in g(), +// causing the compiler to crash in h(). + + +struct A { + A (); +}; + +void f (A* = new A); + +void g () +{ + f (); +} + +void h () +{ + f (); +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/defarg6.C b/gcc/testsuite/g++.old-deja/g++.other/defarg6.C new file mode 100644 index 000000000..fabf01980 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/defarg6.C @@ -0,0 +1,13 @@ +// { dg-do assemble } +// Origin: Gerald Pfeifer <pfeifer@dbai.tuwien.ac.at> + +#include <vector> +#include <fstream> + +class STACK { +public: + std::vector<int> data; + + STACK() : data() + { } +}; diff --git a/gcc/testsuite/g++.old-deja/g++.other/defarg7.C b/gcc/testsuite/g++.old-deja/g++.other/defarg7.C new file mode 100644 index 000000000..244b55ed5 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/defarg7.C @@ -0,0 +1,44 @@ +// { dg-do assemble } + +// Copyright (C) 2000, 2002 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 7 Jan 2001 <nathan@codesourcery.com> + +// As of G++ 3.4, we no longer attempt to detect dependencies; the +// standard does not require that we do. + +// Bug 1038. Default args on class members can produce circular dependencies. +// Make sure we spot them, and don't depend on a particular ordering. + +struct A +{ + static int Foo (int = Baz ()); // { dg-error "" } + static int Baz (int = Foo ()); +}; + +struct Test +{ + Test (void * = 0); + void set (const Test &arg = Test ()); +}; + +struct B +{ + static int Bar (int = Foo (1)); + static int Foo (int = Baz ()); // { dg-error "" } + static int Baz (int = Foo (1)); +}; + +int main () +{ + Test t; + t.set (); + t.set (t); + B::Bar (); + B::Bar (1); + B::Baz (); + B::Baz (1); + B::Foo (); + B::Foo (1); + + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/defarg8.C b/gcc/testsuite/g++.old-deja/g++.other/defarg8.C new file mode 100644 index 000000000..359843186 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/defarg8.C @@ -0,0 +1,27 @@ +// { dg-do assemble } +// { dg-options "-pedantic-errors -ansi -w" } + +// Copyright (C) 2000, 2002, 2003 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 7 Jan 2001 <nathan@codesourcery.com> + +// As of G++ 3.4, we no longer attempt to detect dependencies; the +// standard does not require that we do. + +// Bug 1038. Default args on class members can produce circular dependencies. +// Make sure we spot them, and don't depend on a particular ordering. + +struct AA +{ + static int Foo (int = Baz ()); // { dg-error "" } not yet been parsed + static int Baz (int = Foo ()); +}; + +int main () +{ + AA::Foo (); + AA::Foo (1); + AA::Baz (); + AA::Baz (1); + + return 0; +} 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 000000000..440f3a270 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/defarg9.C @@ -0,0 +1,52 @@ +// { dg-do assemble } +// +// 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/delete1.C b/gcc/testsuite/g++.old-deja/g++.other/delete1.C new file mode 100644 index 000000000..d8c86a7f5 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/delete1.C @@ -0,0 +1,15 @@ +// { dg-do assemble } +struct cl_heap_ring{ + void operator delete (void* ptr) { } + cl_heap_ring () + { } +}; + +struct cl_heap_null_ring : public cl_heap_ring { + void operator delete (void* ptr) { } +}; + +void f() +{ + new cl_heap_null_ring(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/delete2.C b/gcc/testsuite/g++.old-deja/g++.other/delete2.C new file mode 100644 index 000000000..1d0554f2d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/delete2.C @@ -0,0 +1,13 @@ +// { dg-do assemble } + +struct foo { + operator char*() const; +}; + +void bar(foo a) { + delete a; // should be accepted + delete[] a; // should be accepted + char b[1]; + delete b; // { dg-warning "deleting array" } expecting pointer type + delete[] b; // { dg-warning "deleting array" } expecting pointer type +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/delete3.C b/gcc/testsuite/g++.old-deja/g++.other/delete3.C new file mode 100644 index 000000000..9c6c58e96 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/delete3.C @@ -0,0 +1,39 @@ +// { dg-do run } +#include <new> + +int i; + +extern "C" int printf (const char *, ...); + +template <class T, class U> +struct map { + ~map (); +}; + +template <class T, class U> +map<T, U>::~map () +{} + +struct SomeClass { }; + +void* operator new(std::size_t numBytes, SomeClass&, const std::nothrow_t&) throw() +{ + return operator new(numBytes, std::nothrow); +} + +void operator delete(void* pMemory, SomeClass&, const std::nothrow_t&) throw() +{ + i = 7; + return operator delete(pMemory); +} + +int +main() +{ + map< int, int>* pMap = new map< int, int>; + + delete pMap; + + if (i == 7) + return 1; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/delete4.C b/gcc/testsuite/g++.old-deja/g++.other/delete4.C new file mode 100644 index 000000000..0971eb982 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/delete4.C @@ -0,0 +1,53 @@ +// { dg-do assemble } + +// Copyright (C) 1999 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 15 Apr 1999 <nathan@acm.org> + +// delete (void *)e and delete[] (void *)e result in undefined behavior +// [expr.delete/3]. Check we warn about them +// operator new functions can only return NULL, if their exceptions +// specification is `throw()'. All other cases must return a non-null pointer +// [expr.new/13]. + +typedef __SIZE_TYPE__ size_t; + +void *operator new(size_t) +{ + return 0; // { dg-warning "NULL" } cannot return NULL +} +void *operator new[](size_t) +{ + return 0; // { dg-warning "NULL" } cannot return NULL +} + +struct X +{ + void *operator new(size_t) + { + return 0; // { dg-warning "NULL" } cannot return NULL + } + void *operator new[](size_t) + { + return 0; // { dg-warning "NULL" } cannot return NULL + } +}; + +struct Y +{ + void *operator new(size_t) throw() + { + return 0; // ok + } + void *operator new[](size_t) throw() + { + return 0; // ok + } +}; + +void fn(double *d, void *v) +{ + delete d; // ok + delete v; // { dg-warning "" } deleting void + delete[] d; // ok + delete[] v; // { dg-warning "" } deleting void +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/delete5.C b/gcc/testsuite/g++.old-deja/g++.other/delete5.C new file mode 100644 index 000000000..c447b73e5 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/delete5.C @@ -0,0 +1,42 @@ +// { dg-do assemble } +// Copyright (C) 1999 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 15 Apr 1999 <nathan@acm.org> + +typedef __SIZE_TYPE__ size_t; + +struct X +{ + int i; + + X():i(){} + void *operator new(size_t) + { + return 0; // { dg-warning "" } cannot return NULL + } + void *operator new[](size_t) + { + return 0; // { dg-warning "" } cannot return NULL + } +}; + +struct Y +{ + int i; + + Y():i(){} + void *operator new(size_t) throw() + { + return 0; // ok + } + void *operator new[](size_t) throw() + { + return 0; // ok + } +}; + +int main() +{ + Y *yp = new Y; + + return yp != 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/delete6.C b/gcc/testsuite/g++.old-deja/g++.other/delete6.C new file mode 100644 index 000000000..733a6e22c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/delete6.C @@ -0,0 +1,28 @@ +// { dg-do run } +// Origin: Alexander Schiemann (aschiem@count.math.uni-sb.de) + +typedef __SIZE_TYPE__ size_t; + +int i; + +struct B{}; + +struct A{ + + static void* operator new(size_t) + {return &i;} + + inline static void operator delete(void*p); + + static void operator delete(void*, const B&){} + +}; + + +inline void A::operator delete(void*p) +{A::operator delete(p,B());} + + +int main() +{A *ap=new A; +delete ap;} diff --git a/gcc/testsuite/g++.old-deja/g++.other/delete7.C b/gcc/testsuite/g++.old-deja/g++.other/delete7.C new file mode 100644 index 000000000..e55af6a8d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/delete7.C @@ -0,0 +1,18 @@ +// { dg-do run } +// Test that we call a class-specific vector op delete. + +#include <new> + +int r = 1; + +struct A +{ + void operator delete[](void *p) { r = 0; ::operator delete (p); } +}; + +int main () +{ + A (*p)[2] = new A[2][2]; + delete [] p; + return r; +} 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 000000000..ea44445b0 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/delete8.C @@ -0,0 +1,40 @@ +// { dg-do run } +// 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/deref1.C b/gcc/testsuite/g++.old-deja/g++.other/deref1.C new file mode 100644 index 000000000..1b32c8c56 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/deref1.C @@ -0,0 +1,14 @@ +// { dg-do assemble } +// Copyright (C) 1999 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 1 Sep 1999 <nathan@acm.org> + +// [expr.unary.op]/1 says you can dereference all pointers except for pointers +// to cv void. + +void fn (void *vp, volatile void *vvp) +{ + *vp; // { dg-error "" } not a pointer to object + *vvp; // { dg-error "" } not a pointer to object + &*vp; // { dg-error "" } not a pointer to object + &*vvp; // { dg-error "" } not a pointer to object +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/dll-1.C b/gcc/testsuite/g++.old-deja/g++.other/dll-1.C new file mode 100644 index 000000000..8468c1b91 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/dll-1.C @@ -0,0 +1,9 @@ +// { dg-do assemble { target arm-*-*pe } } +// { dg-options "-mno-nop-fun-dllimport" } +// declspec test #1 +// set compiler_result "__imp_imp.*\.section${spaces}.drectve\n\[^\n\]*-export:exp" +// set not_compiler_result "__imp_exp" + +__declspec (dllimport) void imp (); + +__declspec (dllexport) void exp () { imp (); } diff --git a/gcc/testsuite/g++.old-deja/g++.other/dll-2.C b/gcc/testsuite/g++.old-deja/g++.other/dll-2.C new file mode 100644 index 000000000..d3fb6a7ba --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/dll-2.C @@ -0,0 +1,18 @@ +// { dg-do assemble { target arm-*-*pe } } +// Microsoft's MSVC 2.0 allows dllimport followed by dllexport for variables, +// but does not allow dllexport followed by dllimport. +// +// Switching between dll{export,import} works for functions. +// We test for that too (by ensuring no error is produced). + +__declspec (dllimport) int foo1 (); +__declspec (dllexport) int foo1 (); + +__declspec (dllexport) int foo2 (); +__declspec (dllimport) int foo2 (); + +__declspec (dllimport) int bar1; +__declspec (dllexport) int bar1; + +__declspec (dllexport) int bar2; // { dg-error "" } previously declared +__declspec (dllimport) int bar2; // { dg-error "" } redefinition diff --git a/gcc/testsuite/g++.old-deja/g++.other/dll-3.C b/gcc/testsuite/g++.old-deja/g++.other/dll-3.C new file mode 100644 index 000000000..d2784bca8 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/dll-3.C @@ -0,0 +1,16 @@ +// { dg-do assemble { target arm-*-*pe } } +// { dg-options "-mno-nop-fun-dllimport" } +// set compiler_result "__imp_f1.*\.section${spaces}.drectve\n\[^\n\]*-export:f2" +// set not_compiler_result "__imp_f2" + +class aClass +{ +public: + __declspec(dllimport) int f1(); + __declspec(dllexport) int f2(); +}; + +__declspec(dllexport) int aClass::f2() +{ + return f1(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/dll-4.C b/gcc/testsuite/g++.old-deja/g++.other/dll-4.C new file mode 100644 index 000000000..ea5593e5f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/dll-4.C @@ -0,0 +1,13 @@ +// { dg-do assemble { target arm-*-*pe } } +// Ensure dllexport overrides dllimport. +// set compiler_result "\.section${spaces}\.drectve\n\[^\n\]*-export:foo1.*\.section${spaces}\.drectve\n\[^\n\]*-export:foo2" +// set not_compiler_result "(__imp_foo1|__imp_foo2)" + +__declspec (dllimport) int foo1 (); +__declspec (dllexport) int foo1 (); + +__declspec (dllexport) int foo2 (); +__declspec (dllimport) int foo2 (); + +__declspec (dllexport) int foo1 () { return foo2 (); } +__declspec (dllexport) int foo2 () { return foo1 (); } diff --git a/gcc/testsuite/g++.old-deja/g++.other/dll-5.C b/gcc/testsuite/g++.old-deja/g++.other/dll-5.C new file mode 100644 index 000000000..c02be8932 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/dll-5.C @@ -0,0 +1,12 @@ +// { dg-do assemble { target arm-*-*pe } } +// dllimport is "sorta like" to "extern". +// set compiler_result "(\nfoo1:.*\nfoo2:|\nfoo2:.*\nfoo1:)" +// set not_compiler_result "__imp_" + +__declspec (dllimport) int foo1; +int foo1; + +__declspec (dllimport) int foo2; +int foo2 = 5; + +int f () { return foo1 + foo2; } diff --git a/gcc/testsuite/g++.old-deja/g++.other/dll-6.C b/gcc/testsuite/g++.old-deja/g++.other/dll-6.C new file mode 100644 index 000000000..f094c08bf --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/dll-6.C @@ -0,0 +1,14 @@ +// { dg-do assemble { target arm-*-*pe } } +// set not_compiler_result "__imp_" +// dll.h +class aClass + { +public: + __declspec(dllimport) aClass(); + }; + +// dll.cpp + +__declspec(dllexport) aClass::aClass() + { + } diff --git a/gcc/testsuite/g++.old-deja/g++.other/dtor1.C b/gcc/testsuite/g++.old-deja/g++.other/dtor1.C new file mode 100644 index 000000000..103c4705f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/dtor1.C @@ -0,0 +1,18 @@ +// { dg-do run } +// Test for use of typedef in explicit destructor call. + +#include <new> + +struct X { + typedef X foo; +}; + +X x; +unsigned char bar[sizeof (X)]; + +int +main () +{ + X* p = new (bar) X; + p->~foo(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/dtor10.C b/gcc/testsuite/g++.old-deja/g++.other/dtor10.C new file mode 100644 index 000000000..81ed0c1ac --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/dtor10.C @@ -0,0 +1,41 @@ +// { dg-do run } +// Origin: Mark Mitchell <mark@codesourcery.com> + +extern "C" void abort (); + +int j; + +struct S { + static S* s[5]; + + S () { s[j++] = this; } + S (const S&) { s[j++] = this; } + ~S () { + for (int k = 0; k < j; ++k) + if (s[k] == this) + return; + abort (); + } +}; + +S* S::s[5]; + +struct T { + int i; + S s; +}; + +T t; + +T f () { + return t; +} + +void g (S) { +} + +int main () +{ + g (f ().s); +} + diff --git a/gcc/testsuite/g++.old-deja/g++.other/dtor11.C b/gcc/testsuite/g++.old-deja/g++.other/dtor11.C new file mode 100644 index 000000000..e20fa034f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/dtor11.C @@ -0,0 +1,35 @@ +// { dg-do run } +// Origin: Mark Mitchell <mark@codesourcery.com> + +extern "C" void abort (); + +int j; + +struct S { + S () { ++j; } + S (const S&) { ++j; } + ~S () { + if (--j < 0) + abort (); + } +}; + +struct T { + void g (S) { + } +}; + +struct U { + int i; + S s; +}; + +U u; + +U f () { return u; } + +int main () +{ + T t; + t.g (f ().s); +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/dtor12.C b/gcc/testsuite/g++.old-deja/g++.other/dtor12.C new file mode 100644 index 000000000..9890e6392 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/dtor12.C @@ -0,0 +1,16 @@ +// { dg-do run } +// Test that we don't complain about calling a destructor on a const object. + +#include <new> + +struct A +{ + ~A() {} +}; + +const A a = {}; +int main() +{ + a.~A(); + a.A::~A(); // { dg-bogus "" } const violation +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/dtor13.C b/gcc/testsuite/g++.old-deja/g++.other/dtor13.C new file mode 100644 index 000000000..0b998ab46 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/dtor13.C @@ -0,0 +1,10 @@ +// { dg-do assemble } +// Origin: Mark Mitchell <mark@codesourcery.com> + +template <class T> struct S { ~S(); }; +int i; + +void f () +{ + i.~S(); // { dg-error "" } invalid destructor call. +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/dtor2.C b/gcc/testsuite/g++.old-deja/g++.other/dtor2.C new file mode 100644 index 000000000..48f89bcc2 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/dtor2.C @@ -0,0 +1,13 @@ +// { dg-do assemble } + +class K { +public: + friend class C; + +private: + static K qwe; + K(); + ~K(); +}; + +K K::qwe; diff --git a/gcc/testsuite/g++.old-deja/g++.other/dtor3.C b/gcc/testsuite/g++.old-deja/g++.other/dtor3.C new file mode 100644 index 000000000..f5a00ed57 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/dtor3.C @@ -0,0 +1,51 @@ +// { dg-do assemble } + +struct S1 +{ + ~S1(int); // { dg-error "" } destructors may not have parameters +}; + + +template <class T> +struct S2 +{ + ~S2(int); // { dg-error "" } destructors may not have parameters +}; + + +struct S3 +{ + ~S3(double) {} // { dg-error "" } destructors may not have parameters +}; + + +template <class T> +struct S4 +{ + ~S4(double) {} // { dg-error "" } destructors may not have parameters +}; + + +struct S5 +{ + ~S5(); +}; + +S5::~S5(float) // { dg-error "" } destructors may not have parameters +{ +} + + +template <class T> +struct S6 +{ + ~S6(); +}; + +template <class T> +S6<T>::~S6(float) // { dg-error "" } destructors may not have parameters +{ +} + + + diff --git a/gcc/testsuite/g++.old-deja/g++.other/dtor4.C b/gcc/testsuite/g++.old-deja/g++.other/dtor4.C new file mode 100644 index 000000000..a4db38ba7 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/dtor4.C @@ -0,0 +1,31 @@ +// { dg-do assemble } + +struct S1 { + ~S1(); // { dg-error "" } candidate +}; + +S1::~S1() const // { dg-error "" } prototype does not match +{ +} + + +struct S2 { + ~S2() volatile; // { dg-error "" } destructors may not be volatile +}; + + +template <class T> +struct S3 { + ~S3(); // { dg-error "" } candidate +}; + +template <class T> +S3<T>::~S3() volatile // { dg-error "" } prototype does not match +{ +} + + +template <class T> +struct S4 { + ~S4() const; // { dg-error "" } destructors may not be const +}; diff --git a/gcc/testsuite/g++.old-deja/g++.other/dtor5.C b/gcc/testsuite/g++.old-deja/g++.other/dtor5.C new file mode 100644 index 000000000..fc1ef385d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/dtor5.C @@ -0,0 +1,37 @@ +// { dg-do run } +// Origin: Mark Mitchell <mark@codesourcery.com> + +extern "C" void abort (); + +struct B; + +struct S +{ + S (B*); + ~S (); + + B* b_; +}; + +struct B +{ + B () : s (this) { } + + virtual void f () { } + + S s; +}; + +S::S (B* b) : b_ (b) { } + +S::~S () { b_->f (); } + +struct D : public B +{ + virtual void f () { abort (); } +}; + +int main () +{ + D d; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/dtor6.C b/gcc/testsuite/g++.old-deja/g++.other/dtor6.C new file mode 100644 index 000000000..f8c1d8563 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/dtor6.C @@ -0,0 +1,45 @@ +// { dg-do run } +// Origin: Mark Mitchell <mark@codesourcery.com> + +extern "C" void abort (); + +int count; + +struct S +{ + S (); + S (const S&); + ~S (); + + int i; +}; + +S::S () +{ + i = count++; +} + +S::S (const S&) +{ + i = count++; +} + +S::~S () +{ + if (--count != i) + abort (); +} + +void f (S, S) +{ +} + +int main () +{ + { + S s; + f (s, s); + } + return count != 0; +} + diff --git a/gcc/testsuite/g++.old-deja/g++.other/dtor7.C b/gcc/testsuite/g++.old-deja/g++.other/dtor7.C new file mode 100644 index 000000000..c212d9476 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/dtor7.C @@ -0,0 +1,43 @@ +// { dg-do run } +// { dg-options "-O2" } +// Origin: Mark Mitchell <mitchell@codesourcery.com> + +int i; +int j; + +struct A +{ + A (); + A (const A&); + ~A (); +}; + +A::A () +{ + ++i; +} + +A::A (const A&) +{ + ++i; +} + +A::~A () +{ + --i; +} + +A f () +{ + return A (); +} + +void g (const A&) +{ +} + +int main () +{ + g (f ()); + return i; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/dtor8.C b/gcc/testsuite/g++.old-deja/g++.other/dtor8.C new file mode 100644 index 000000000..5f2071d5a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/dtor8.C @@ -0,0 +1,39 @@ +// { dg-do run } +// { dg-options "-O1" } +// Origin: Mark Mitchell <mark@codesourcery.com> + +int result; + +struct S +{ + S (); + S (const S&); + ~S (); + + int i; + double d[18]; +}; + +S* s; + +S::S () +{ + s = this; +} + +S::~S () +{ + if (s != this) + result = 1; +} + +inline S f () +{ + return S (); +} + +int main () +{ + f (); + return result; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/dtor9.C b/gcc/testsuite/g++.old-deja/g++.other/dtor9.C new file mode 100644 index 000000000..0df88a828 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/dtor9.C @@ -0,0 +1,24 @@ +// { dg-do run } +int i; + +struct CC +{ + virtual ~CC () { ++i; } +}; + +class BB : virtual public CC +{ +}; + +class AA : public virtual BB +{ +}; + +int main () +{ + { + AA xx; + } + if (i != 1) + return 1; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/dyncast1.C b/gcc/testsuite/g++.old-deja/g++.other/dyncast1.C new file mode 100644 index 000000000..6feec30e6 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/dyncast1.C @@ -0,0 +1,123 @@ +// { dg-do run } +// Author: Alfred Miniarik <a8601248@unet.univie.ac.at> +// test of dynamic_cast +// runtime detecting of nonpublic +// inheritance within a cast +// and therefor failing with result 0. + +extern "C" void abort(); +extern "C" int printf (const char *, ...); + +static int errors = 0; +void error(int i) +{ + printf("Error %i\n",i); + errors++; +} + +// 1. downcast + +// 1.1. single inheritance case + +struct A {virtual ~A(){}}; +struct AA : A {}; +struct B : A {}; +struct BB : B {}; +class C : B {}; +struct D : C {}; + +struct CC : B {}; +class DD : CC {}; + +class CCC : protected B {}; +class DDD : protected CCC {}; + +void +test01 () +{ + D d; + if(dynamic_cast<D*> ((A*)&d)) error(1); + if(dynamic_cast<D*> ((B*)&d)) error(2); + if(&d != dynamic_cast<D*> ((C*)&d)) error(3); //counter example + if(dynamic_cast<C*> ((B*)&d)) error(4); + + DD dd; + if(dynamic_cast<DD*> ((A*)&dd)) error(5); + if(dynamic_cast<DD*> ((B*)&dd)) error(6); + + DDD ddd; + if(dynamic_cast<DDD*> ((A*)&ddd)) error(7); + if(dynamic_cast<DDD*> ((B*)&ddd)) error(8); + if(dynamic_cast<CCC*> ((B*)&ddd)) error(9); +} + +// 1.2. multiple inheritance case +// 1.2.1. all bases are public + +struct E : D, CC {}; +struct EE : CC, D {}; //Will search in reverse order. + +void +test02 () +{ + E e; + if(dynamic_cast<E*> ((A*)(D*)&e)) error(10); + if(dynamic_cast<E*> ((B*)(D*)&e)) error(11); + if(&e != dynamic_cast<E*> ((C*)(D*)&e)) error(12); //counter example + if(&e != dynamic_cast<E*> ((B*)(CC*)&e)) error(13); //counter example + if((CC*)&e != dynamic_cast<CC*> ((B*)(CC*)&e)) error(14); //counter example + + EE ee; + if(dynamic_cast<EE*> ((A*)(D*)&ee)) error(15); + if(dynamic_cast<EE*> ((B*)(D*)&ee)) error(16); + if(&ee != dynamic_cast<EE*> ((C*)(D*)&ee)) error(17); //counter example + if(&ee != dynamic_cast<EE*> ((B*)(CC*)&ee)) error(18); //counter example + if((CC*)&ee != dynamic_cast<CC*> ((B*)(CC*)&ee)) error(19); //counter example +} + +// 1.2.2 one or more branches are nonpublic + +struct X : private BB, E {}; +struct Y : AA, private B {}; + +class XX : BB, E {}; + +void +test03 () +{ + X x; + if(&x != dynamic_cast<X*>((B*)(CC*)(E*)&x)) error(20); //counter example + XX xx; + if(dynamic_cast<XX*>((B*)(CC*)(E*)&xx)) error(21); + Y y; + if(dynamic_cast<Y*>((B*)&y)) error (22); + if(dynamic_cast<Y*>((A*)(B*)&y)) error (23); +} + +// 2. crosscast + +struct J {virtual ~J(){}}; +struct K : CC, private J {}; +class KK : J, CC{}; + +void +test04 () +{ + E e; + if(dynamic_cast<CC*> ((B*)(D*)&e)) error(24); + if((CC*)&e != dynamic_cast<CC*> ((C*)(D*)&e)) error(25); //counter example + K k; + if(dynamic_cast<J*> ((B*)&k)) error(26); + KK kk; + if(dynamic_cast<J*> ((CC*)&kk)) error(27); +} + +int +main () +{ + test01(); + test02(); + test03(); + test04(); + return errors ? 1 : 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/dyncast2.C b/gcc/testsuite/g++.old-deja/g++.other/dyncast2.C new file mode 100644 index 000000000..bea82cb46 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/dyncast2.C @@ -0,0 +1,85 @@ +// { dg-do run } +// Author: Alfred Miniarik <a8601248@unet.univie.ac.at> +// test of dynamic_cast +// runtime detecting of valid +// downcasts within nonpublic +// baseclasses. + +extern "C" void abort(); +extern "C" int printf (const char *, ...); + +static int errors = 0; + +void error(int i) +{ + printf("Error %i\n",i); + errors++; +} + +// 1. downcast +// 1.1 single inheritance case + +struct A {virtual ~A(){} int i;}; +struct B : A {int i;}; +struct C : B {int i;}; +struct CC : C {}; +class D : C {int i;}; + +struct E : D {int i;}; +class F : E {int i;}; + +void +test01 () +{ + D d; + if((C*)&d != dynamic_cast<C*> ((A*)&d)) error(1); + if((C*)&d != dynamic_cast<C*> ((B*)&d)) error(2); + if((B*)&d != dynamic_cast<B*> ((A*)&d)) error(3); + + E e; + if((C*)&e != dynamic_cast<C*> ((A*)&e)) error(4); + + F f; + if((C*)&f != dynamic_cast<C*> ((B*)&f)) error(5); + if((B*)&f != dynamic_cast<B*> ((A*)&f)) error(6); + if((E*)&f != dynamic_cast<E*> ((D*)&f)) error(7); + if(dynamic_cast<E*> ((C*)&f)) error(8); //counter example +} + +// 1.2 multiple inheritance case + +struct G : CC, F{}; + +void +test02 () +{ + G g; + if((B*)(F*)&g != dynamic_cast<B*> ((A*)(F*)&g)) error(9); + if(dynamic_cast<D*> ((A*)(F*)&g)) error(10); + if(dynamic_cast<G*> ((B*)(F*)&g)) error(11); +} + +// 2. crosscast (always fail) + +struct I : C{}; +struct J : F{}; +struct K : I, J{}; +class L : K{}; + +void +test03 () +{ + L l; + if(dynamic_cast<J*> ((I*)&l)) error(12); + if(dynamic_cast<J*> ((E*)&l)) error(13); + if(dynamic_cast<I*> ((J*)&l)) error(14); +} + +int +main () +{ + test01(); + test02(); + test03(); + return errors ? 1 : 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/dyncast3.C b/gcc/testsuite/g++.old-deja/g++.other/dyncast3.C new file mode 100644 index 000000000..cd59efa6c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/dyncast3.C @@ -0,0 +1,33 @@ +// { dg-do run } +// Author: Alfred Miniarik <a8601248@unet.univie.ac.at> +// test of dynamic_cast +// runtime detecting of nonpublic +// inheritance within a cast +// and therefor failing with result 0. + +extern "C" void abort(); +extern "C" int printf (const char *, ...); + +static int errors = 0; + +void error(int i) +{ + printf("Error %i\n",i); + errors++; +} + +struct A {virtual ~A(){}}; +struct B : private virtual A {}; +struct C : virtual A {}; +struct D : B, C {}; + +int +main() +{ + D d; + A* ap= &d; + if(&d != dynamic_cast<D*>(ap)) error(1); + if((B*)&d != dynamic_cast<B*>(ap)) error(2); + if((C*)&d != dynamic_cast<C*>(ap)) error(3); + return errors ? 1 : 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/dyncast4.C b/gcc/testsuite/g++.old-deja/g++.other/dyncast4.C new file mode 100644 index 000000000..a49ef4b67 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/dyncast4.C @@ -0,0 +1,28 @@ +// { dg-do run } +// Author: Alfred Miniarik <a8601248@unet.univie.ac.at> + +// Even in a derived class, a private base cannot be dynamically downcasted +// from. + +extern "C" void abort(); + +struct A { + virtual ~A () {} +}; + +struct B : private A { + B* a2b (A* objp) + { + return dynamic_cast<B*> (objp); + } +}; + +int +main () +{ + B b; + A* aptr = (A*) &b; + if (dynamic_cast <B*> (aptr)) abort (); + if (b.a2b (aptr)) abort(); + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/dyncast5.C b/gcc/testsuite/g++.old-deja/g++.other/dyncast5.C new file mode 100644 index 000000000..120a75ae6 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/dyncast5.C @@ -0,0 +1,38 @@ +// { dg-do run } +// Copyright (C) 1999 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 6 Jun 1999 <nathan@acm.org> + +// dynamic cast can only cast to public unambiguous bases + +extern "C" void abort (); + +struct A {virtual ~A(){} int m; }; +struct B {virtual ~B(){} int m; }; + +struct C1 : A {int m;}; +struct C2 : A {int m;}; + +// A is ambiguous, but private in one branch +struct D1 : B, C1, private C2 {int m;}; +// A is ambiguous, and public in both branches +struct D2 : B, C1, C2 {int m;}; + +void fn(B *bd1, B *bd2) +{ + A *ad1; + A *ad2; + + ad1 = dynamic_cast<A *>(bd1); + if(ad1) abort(); + ad2 = dynamic_cast<A *>(bd2); + if(ad2) abort(); +} + +int main() +{ + D1 d1; + D2 d2; + + fn((B *)&d1, (B *)&d2); + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/dyncast6.C b/gcc/testsuite/g++.old-deja/g++.other/dyncast6.C new file mode 100644 index 000000000..52b57e544 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/dyncast6.C @@ -0,0 +1,73 @@ +// { dg-do run } +// { dg-options "-w -ansi -pedantic-errors" } + +// Copyright (C) 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 20 June 2000 <nathan@codesourcery.com> + +// Origin GNATS bug report 143 from Carlo Wood <carlo@runaway.xs4all.nl> +// We were generating incorrect type_info structures, and hence breaking +// dynamic_cast. + +#include <stdio.h> + +class OBASE { public: virtual void bz () {}}; +class IBASE { public: virtual void by () {}}; + +class V {public:int m; }; + +class A : public virtual V { }; +class AA : public A {}; + +class B : public OBASE, public A { public: virtual void foo(void) { } }; +class B1 : public OBASE, public AA { public: virtual void foo(void) { } }; + +class C : public IBASE, public virtual V { }; + +class D : public B, public C { }; + +class E : public B, public virtual V { }; + +class E1 : public B1, public virtual V {}; + +class E2 : public B1, public A, public virtual V {}; + +int main(void) +{ + D d; + E e; + E1 e1; + E2 e2; + int code = 0; + + OBASE* osd = &d; + OBASE* ose = &e; + OBASE* ose1 = &e1; + OBASE* ose2 = &e2; + + + if (!dynamic_cast<V*>(osd)) + { + printf ("fail osd\n"); + code++; + } + + if (!dynamic_cast<V*>(ose)) + { + printf ("fail ose\n"); + code++; + } + + if (!dynamic_cast<V*>(ose1)) + { + printf ("fail ose1\n"); + code++; + } + + if (!dynamic_cast<V*>(ose2)) + { + printf ("fail ose2\n"); + code++; + } + + return code; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/eh.C b/gcc/testsuite/g++.old-deja/g++.other/eh.C new file mode 100644 index 000000000..13cbb730c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/eh.C @@ -0,0 +1,20 @@ +// { dg-do assemble } + +class foo { +public: + ~foo(); + foo &operator=(const foo &); + foo e() const; +}; +class bar { +public: + foo d() const; +}; +struct x { + foo a; + bar* b; +}; +void baz(x *f, int ic) +{ + f->a = ic ? f->b->d().e() : f->b->d(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/eh1.C b/gcc/testsuite/g++.old-deja/g++.other/eh1.C new file mode 100644 index 000000000..e7cdc2777 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/eh1.C @@ -0,0 +1,21 @@ +// { dg-do assemble } + +class C2 { +public: + ~C2(); + C2 a() const; +}; +class C3 { +public: + C3(const C2 &c); +}; +class C4 +{ +public: + C3 *foo(bool b, const C2 &c); + C2 d() const; +}; +C3 *C4::foo(bool b, const C2 &c) +{ + return new C3(b ? d().a() : c); +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/eh2.C b/gcc/testsuite/g++.old-deja/g++.other/eh2.C new file mode 100644 index 000000000..158ae2087 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/eh2.C @@ -0,0 +1,18 @@ +// { dg-do assemble } +// { dg-options "-O2" } +// Origin: Jakub Jelinek <jakub@redhat.com> + +class a { +public: + double b; + int c; + ~a() { } +}; + +int bar(a x); +a foo(double x); + +int baz(double x, int y) +{ + return bar(foo(x)); +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/eh3.C b/gcc/testsuite/g++.old-deja/g++.other/eh3.C new file mode 100644 index 000000000..4e6189282 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/eh3.C @@ -0,0 +1,33 @@ +// { dg-do run } +// { dg-options "-O" } +typedef struct { } e; + +char *p; + +void _Jv_throw (); + +int barf (int len) +{ + char a[len]; + + p = a; + _Jv_throw (); + return 0; +} + +void _Jv_throw () +{ + e ex; + throw ex; +} + +int main () +{ + try { + barf (2); + } + catch (...) { + } + + return 0; +} 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 000000000..999e2943a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/eh4.C @@ -0,0 +1,12 @@ +// { dg-do assemble } +// Origin: Jean-Marc Bourguet <bourguet@cadence.com> + +class foo { +public: + foo() {} + void throwMe () { + throw *this; // { dg-error "" } cannot be used in throw-expression + } + virtual void test () = 0; +}; + diff --git a/gcc/testsuite/g++.old-deja/g++.other/eh5.C b/gcc/testsuite/g++.old-deja/g++.other/eh5.C new file mode 100644 index 000000000..59ed4dd5b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/eh5.C @@ -0,0 +1,34 @@ +// { dg-do assemble } +// { dg-options "-O2" } + +struct X {}; + +struct Y +{ + Y(); + virtual ~Y(); +}; + +struct Z +{ + int f (const int *x); + int g; +}; + +inline int +operator<< (Z &os, int x) +{ + os.f (&x); + return os.g; +} + +void foo (Z &a, X *b, X &c) +{ + X *d = b; + int e = 0; + Z &f = a; + if (!(f << e)) + do { do { } while (&c == 0); throw Y(); } while (0); + do { } while (&d == 0); + do { } while (&c == 0); +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/elab1.C b/gcc/testsuite/g++.old-deja/g++.other/elab1.C new file mode 100644 index 000000000..5588651df --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/elab1.C @@ -0,0 +1,10 @@ +// { dg-do assemble } +typedef struct {} S; // { dg-error "" } Previous declaration of S + +S s1; +struct S* s2; // { dg-error "" } S is a typedef name + +template <class T> +struct X { + friend class T; // { dg-error "" } T is a template type parameter +}; diff --git a/gcc/testsuite/g++.old-deja/g++.other/empty1.C b/gcc/testsuite/g++.old-deja/g++.other/empty1.C new file mode 100644 index 000000000..47a5b7a51 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/empty1.C @@ -0,0 +1,28 @@ +// { dg-do run } +// Origin: Mark Mitchell <mark@codesourcery.com> +// This test case checks that the return value optimization works for +// empty classes. + +// PR c++/5995 + +extern "C" void abort(); +extern "C" int printf (const char *, ...); + +int i; + +struct A; + +struct A* as[10]; + +struct A { + A () { as[i++] = this; } + A (const A&) { as[i++] = this; } + ~A() { if (i == 0 || as[--i] != this) abort(); } +}; + +A f() { return A(); } + +int main () +{ + A a (f ()); +} 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 000000000..a3a6bace6 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/empty2.C @@ -0,0 +1,10 @@ +// { dg-do assemble } +// 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/enum1.C b/gcc/testsuite/g++.old-deja/g++.other/enum1.C new file mode 100644 index 000000000..9685f6a04 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/enum1.C @@ -0,0 +1,16 @@ +// { dg-do run } +extern "C" void abort(); + +struct A +{ + enum { a = 3}* p; + int f() { return (int) a; } +}; + +int main() +{ + A a; + + if (a.f() != 3) + abort(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/enum2.C b/gcc/testsuite/g++.old-deja/g++.other/enum2.C new file mode 100644 index 000000000..40328bfc6 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/enum2.C @@ -0,0 +1,16 @@ +// { dg-do assemble } + +// Copyright (C) 1999 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 3 Jun 1999 <nathan@acm.org> + +// We'd like the enum location to be its identifier. + +enum thing // { dg-error "" } previous def +{ + val1 +}; + +enum thing // { dg-error "" } multiple def +{ + val2 +}; 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 000000000..16e71ac67 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/enum3.C @@ -0,0 +1,14 @@ +// { dg-do assemble } + +// Copyright (C) 2001 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 28 Feb 2001 <nathan@codesourcery.com> + +// Bug 338 and DR 128. Allow static cast to convert between enums. + +enum E1 {e1}; +enum E2 {e2}; + +E2 Foo (E1 e) +{ + return static_cast <E2> (e); +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/enum4.C b/gcc/testsuite/g++.old-deja/g++.other/enum4.C new file mode 100644 index 000000000..429e8127c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/enum4.C @@ -0,0 +1,26 @@ +// { dg-do run } +// { dg-options "-fshort-enums" } + +// Origin: Mark Mitchell <mark@codesourcery.com> + +// On ARM EABI targets this testcase will cause a warning to be emitted +// whilst EABI attributes are being merged at link time unless +// the --no-enum-size-warning option is passed to the linker. Whilst the +// enum-size attributes should only be emitted if there are values of +// enum type that can escape the compilation unit, gcc cannot currently +// detect this; if this facility is added then this linker option should +// not be needed. arm-*-linux*eabi should be a good approximation to +// those platforms where the EABI supplement defines enum values to be +// 32 bits wide. +// { dg-options "-fshort-enums -Wl,--no-enum-size-warning" { target arm*-*-linux*eabi } } + +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/enum5.C b/gcc/testsuite/g++.old-deja/g++.other/enum5.C new file mode 100644 index 000000000..ad40d4e1f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/enum5.C @@ -0,0 +1,26 @@ +// { dg-do run } +// Copyright (C) 2001, 2003, 2004 Free Software Foundation, Inc. +// Contributed by Ben Elliston <bje@redhat.com> + +// PR 80: Packed enums use minimum required storage. + +extern "C" void abort(); + +enum numbers { one, two, three } __attribute__ ((packed)) nums; +enum colours { red = 1000, green, blue } __attribute__ ((packed)) cols; +enum conditions { fine, rain, cloudy } __attribute__ ((packed)) forecast; + +int +main() +{ + if (sizeof (nums) != 1) + abort (); + + if (sizeof (cols) != 2) + abort (); + + if (sizeof (forecast) != 1) + abort (); + + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/explicit1.C b/gcc/testsuite/g++.old-deja/g++.other/explicit1.C new file mode 100644 index 000000000..123efb743 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/explicit1.C @@ -0,0 +1,13 @@ +// { dg-do assemble } +// Origin: Jason Merrill <jason@redhat.com> + +struct A +{ + A (); + explicit A (int); +}; + +int main () +{ + const A& r = 1; // { dg-error "" } no suitable constructor +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/expr1.C b/gcc/testsuite/g++.old-deja/g++.other/expr1.C new file mode 100644 index 000000000..87166f0ae --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/expr1.C @@ -0,0 +1,11 @@ +// { dg-do assemble } + +// Simplified from bug report by Trevor Taylor <ttaylor@powerup.com.au> + +struct T { // { dg-message "candidate" } + int operator()(int) { } // { dg-message "operator|candidate expects" } +}; + +int main() { + T()(); // { dg-error "match" } no such operator +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/exprstmt1.C b/gcc/testsuite/g++.old-deja/g++.other/exprstmt1.C new file mode 100644 index 000000000..abe072999 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/exprstmt1.C @@ -0,0 +1,26 @@ +// { dg-do run } +// { dg-options "-O" } +// { dg-error "limited range of data type" "16-bit target" { target xstormy16-*-* } 0 } +// { dg-error "shift count >=" "16-bit target" { target xstormy16-*-* } 0 } + +int main() +{ + unsigned int x = 1381237248; + + if (sizeof (x) != 4) + return 0; + + x = + ({ + unsigned int y = x; + ({ + unsigned int z = y; + (unsigned int) + ((((unsigned int)z & (unsigned int)0x000000ffUL) << 24) + | (((unsigned int)z & (unsigned int)0x0000ff00UL) << 8) + | (((unsigned int)z & (unsigned int)0x00ff0000UL) >> 8) + | (((unsigned int)z & (unsigned int)0xff000000UL) >> 24)); + }); + }); + return x != 152658; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/externC1.C b/gcc/testsuite/g++.old-deja/g++.other/externC1.C new file mode 100644 index 000000000..0e485053a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/externC1.C @@ -0,0 +1,22 @@ +// { dg-do assemble } +// Origin: Mark Mitchell <mitchell@codesourcery.com> + +extern "C" +{ + struct T + { + ~T (); + }; + + struct S + { + T t; + }; +} + +S* s; + +void f () +{ + delete s; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/externC2.C b/gcc/testsuite/g++.old-deja/g++.other/externC2.C new file mode 100644 index 000000000..d5b23303b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/externC2.C @@ -0,0 +1,16 @@ +// { dg-do assemble } +// Origin: Boris Zentner <boris@m2b.de> + +extern "C" +{ +struct xx +{ + int x; + xx(); +}; + +xx::xx() +{ + x = 0; +} +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/externC3.C b/gcc/testsuite/g++.old-deja/g++.other/externC3.C new file mode 100644 index 000000000..9f56ed3a7 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/externC3.C @@ -0,0 +1,16 @@ +// { dg-do run } +// Test that two extern "C" declarations of the same name in different +// namespaces are treated as declaring the same function. + +namespace foo { + extern "C" int f (); +} + +extern "C" int f () { return 0; } + +using namespace foo; + +int main () +{ + f (); +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/externC4.C b/gcc/testsuite/g++.old-deja/g++.other/externC4.C new file mode 100644 index 000000000..daf097fc8 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/externC4.C @@ -0,0 +1,14 @@ +// { dg-do assemble } +// Origin: Neil Booth, from PR #66 + +extern "C" +{ + class foo + { + public: + ~foo (); + void bar (foo *); + foo (); + }; +} + 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 000000000..3e32d4ffa --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/externC5.C @@ -0,0 +1,19 @@ +// { dg-do assemble } +// 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/field1.C b/gcc/testsuite/g++.old-deja/g++.other/field1.C new file mode 100644 index 000000000..5b8b3617c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/field1.C @@ -0,0 +1,7 @@ +// { dg-do assemble } + +struct X +{ + static const bool b = true; + static const int i = b ? 1 : 2; +}; diff --git a/gcc/testsuite/g++.old-deja/g++.other/field2.C b/gcc/testsuite/g++.old-deja/g++.other/field2.C new file mode 100644 index 000000000..5dd1e97fb --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/field2.C @@ -0,0 +1,21 @@ +// { dg-do run } +// Test for proper handling of field calls. +// Contributed by Jason Merrill <jason@cygnus.com> + +struct A { + inline A* operator()() { return this; } +}; + +struct B { + int i; + union { A a; }; +}; + +int +main () +{ + B b; + A* ap = &b.a; + A* ap2 = b.a(); + return (ap != ap2); +} 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 000000000..e8e3254ab --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/fnname1.C @@ -0,0 +1,8 @@ +// { dg-do link } +// { dg-options "-g" } +// Origin: Loren James Rittle <rittle@latour.rsch.comm.mot.com> + +int main () +{ + const char *s = __FUNCTION__; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/for1.C b/gcc/testsuite/g++.old-deja/g++.other/for1.C new file mode 100644 index 000000000..88d79933b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/for1.C @@ -0,0 +1,43 @@ +// { dg-do assemble } + +int i; +int j; + +struct S { + int operator()(int) + { + i = 1; + return i; + } + + typedef int I; + + void f() { + for (S I; false; ) + ; + int k = I(3); + } +}; + +typedef int J; + +struct T { + int operator()(int) + { + j = 1; + return j; + } + + void f() { + for (T J; false; ) + ; + int k = J(3); + } +}; + +int main() +{ + S s; + s.f(); + return 2 * i + j; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/for2.C b/gcc/testsuite/g++.old-deja/g++.other/for2.C new file mode 100644 index 000000000..0ba12b46d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/for2.C @@ -0,0 +1,14 @@ +// { dg-do assemble } + +// Copyright (C) 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 24 Jul 2000 <nathan@codesourcery.com> + +// Bug 306 +// binding a reference in for scope creates nameless objects. Make sure +// we don't try and inject them into scope, for ARM compatibility. + +void foo () +{ + for (const int &thing = 0;;) + ; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/friend1.C b/gcc/testsuite/g++.old-deja/g++.other/friend1.C new file mode 100644 index 000000000..56236ab33 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/friend1.C @@ -0,0 +1,88 @@ +// { dg-do assemble } +// f() should be able to access B::j, as of FDIS [class.protected]/1 + +// Subject: Re: [bug] Inheritance and friend access control broken +// References: <199803032141.WAA09332@piano.dptmaths.ens-cachan.fr> +// <orhg5ff544.fsf@iguacu.dcc.unicamp.br> +// <199803041125.MAA06937@cor.dptmaths.ens-cachan.fr> +// <orn2f6ek92.fsf@iguacu.dcc.unicamp.br> <19980304102900.46897@dgii.com> +// From: Alexandre Oliva <oliva@dcc.unicamp.br> +// Date: 06 Mar 1998 01:43:18 -0300 + +template <int*> +class X {}; + +template <typename T> +void g(); + +struct S; + +template <typename T> +struct R; + +class B { +protected: + int i; // { dg-error "" } in this context + static int j; +}; + +class D : public B { + friend void f(); + template <typename T> + friend void g(); + friend struct S; + template <typename T> + friend struct R; +}; + +struct S { + void h(); + X<&B::j> x; +}; + +template <typename T> +struct R { + void h(); + X<&B::j> x; +}; + +B b; +D d; + +void f() +{ + b.i = 3; // { dg-error "" } protected + d.i = 4; + B::j = 5; + D::j = 6; +} + +template <typename T> +void g() +{ + b.i = 3; // { dg-error "" } protected + d.i = 4; + B::j = 5; + D::j = 6; +} + +template void g<int>(); + +void S::h() +{ + b.i = 3; // { dg-error "" } protected + d.i = 4; + B::j = 5; + D::j = 6; +} + +template <typename T> +void R<T>::h() +{ + b.i = 3; // { dg-error "" } protected + d.i = 4; + B::j = 5; + D::j = 6; +} + +template struct R<double>; diff --git a/gcc/testsuite/g++.old-deja/g++.other/friend10.C b/gcc/testsuite/g++.old-deja/g++.other/friend10.C new file mode 100644 index 000000000..935b2fe5b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/friend10.C @@ -0,0 +1,30 @@ +// { dg-do assemble } +// Origin: Neil Booth, from PR #78 + +namespace MySpace + { + class Tag1 { }; + class Tag2 { }; + + template<class Tag> + class Object + { + public: + + friend void Forgotten(Object const & m) {} + }; + + typedef Object<Tag1> U1; + typedef Object<Tag2> U2; + + void foo() + { + Forgotten(U1()); + Forgotten(U2()); + } + + void bar() + { + Forgotten(U1()); + } + } 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 000000000..7c04f03ac --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/friend11.C @@ -0,0 +1,12 @@ +// { dg-do assemble } +// Origin: robt@flyingpig.com + +class Outer +{ + friend void f1(); + class Inner2; +}; + +class Outer::Inner2 +{ +}; diff --git a/gcc/testsuite/g++.old-deja/g++.other/friend2.C b/gcc/testsuite/g++.old-deja/g++.other/friend2.C new file mode 100644 index 000000000..3f5f2a7de --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/friend2.C @@ -0,0 +1,19 @@ +// { dg-do assemble } + +void +f() +{ + class Local_2 { + friend class Friend; + + int i; + }; + + class Friend { + public: + void g() { + Local_2 l2; + l2.i = 3; + } + }; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/friend3.C b/gcc/testsuite/g++.old-deja/g++.other/friend3.C new file mode 100644 index 000000000..79323f6ec --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/friend3.C @@ -0,0 +1,23 @@ +// { dg-do assemble } + +class foo { +public: + class bar; + void func(bar *); + class bar { + int st; + friend void foo::func(bar *); + }; +}; + + +void foo::func(bar *obj) { + obj->st++; +} + +void test02() { + foo obj_f; + foo::bar obj_b; + + obj_f.func( &obj_b); +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/friend4.C b/gcc/testsuite/g++.old-deja/g++.other/friend4.C new file mode 100644 index 000000000..41d3a6a48 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/friend4.C @@ -0,0 +1,23 @@ +// { dg-do assemble } + +// by Alexandre Oliva <oliva@dcc.unicamp.br> + +// I'm not 100% sure this program is correct, but g++ shouldn't just +// crash. + +// The idea is to give privileged access to bar<A> only to +// specializations foo<A,B>, for all B. + +template <class A, class B> void foo(); +template <class C> class bar { + int i; // { dg-error "" } private + template <class B> friend void foo<C,B>(); // { dg-error "" } bogus declaration +}; +template <class A, class B> void foo() { + bar<A> baz; baz.i = 1; // { dg-error "" } foo cannot access bar<int>::i + bar<int> buz; buz.i = 1; // { dg-error "" } foo cannot access bar<int>::i +} +int main() { + foo<void,void>(); + foo<int,void>(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/friend5.C b/gcc/testsuite/g++.old-deja/g++.other/friend5.C new file mode 100644 index 000000000..44f16678a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/friend5.C @@ -0,0 +1,6 @@ +// { dg-do assemble } +// submitted by David C Binderman <dcb@pncl.co.uk> + +struct A { + friend bool(); // { dg-error "" } invalid declaration +}; diff --git a/gcc/testsuite/g++.old-deja/g++.other/friend6.C b/gcc/testsuite/g++.old-deja/g++.other/friend6.C new file mode 100644 index 000000000..05763d986 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/friend6.C @@ -0,0 +1,19 @@ +// { dg-do assemble } +// Origin: Martin v. Löwis <loewis@informatik.hu-berlin.de> +// Test for resolution of core issue 125. + +struct A{ + struct B{}; +}; + +A::B C(); + +namespace B{ + A C(); +} + +class Test{ + friend A (::B::C)(); // Ok + friend A::B (::C)(); // Ok + friend A::B::C(); // { dg-error "" } no A::B::C +}; diff --git a/gcc/testsuite/g++.old-deja/g++.other/friend7.C b/gcc/testsuite/g++.old-deja/g++.other/friend7.C new file mode 100644 index 000000000..aed56a187 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/friend7.C @@ -0,0 +1,21 @@ +// { dg-do assemble } +// Origin: Martin v. Löwis <loewis@informatik.hu-berlin.de> +// Test that a friend declaration with an explicit :: finds the right fn. + +namespace M { +class S; +} +void foo(M::S *); + +namespace M { +class S { + friend void (::foo)(S *); + void Fn(); + static S s; +}; +} + +void (foo)(M::S *ptr) { + M::S::s.Fn(); + ptr->Fn(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/friend8.C b/gcc/testsuite/g++.old-deja/g++.other/friend8.C new file mode 100644 index 000000000..bbe4bf598 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/friend8.C @@ -0,0 +1,16 @@ +// { dg-do assemble } +// +// Copyright (C) 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 14 Aug 2000 <nathan@codesourcery.com> + +// We failed to diagnose when a class friend declaration did not use an +// elaborated type specifier. + +struct Y; +struct Z; +struct X +{ + friend class Z; + friend Y; // { dg-error "" } friend must use aggr tag +}; + diff --git a/gcc/testsuite/g++.old-deja/g++.other/friend9.C b/gcc/testsuite/g++.old-deja/g++.other/friend9.C new file mode 100644 index 000000000..db9a248f7 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/friend9.C @@ -0,0 +1,23 @@ +// { dg-do assemble } + +// Copyright (C) 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 24 Nov 2000 <nathan@codesourcery.com> + +// Bug 853: We reported the wrong line no for a friend access violation + +class F +{ + class Internal; // { dg-error "" } is private +}; + +class C +{ + friend class F::Internal; // { dg-error "" } in this context + public: + typedef enum { A, B } e; + + C (); + ~C(); + + void m(); +}; diff --git a/gcc/testsuite/g++.old-deja/g++.other/goto1.C b/gcc/testsuite/g++.old-deja/g++.other/goto1.C new file mode 100644 index 000000000..0dcc8bc00 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/goto1.C @@ -0,0 +1,21 @@ +// { dg-do assemble } +// Origin: Mark Mitchell <mark@codesourcery.com> + +struct S +{ + S (); + ~S (); +}; + +void f () +{ + { + S s1; // { dg-error "" } skips initialization + + t: // { dg-error "" } jump to label + S s2; + ; + } + + goto t; // { dg-error "" } from here +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/goto2.C b/gcc/testsuite/g++.old-deja/g++.other/goto2.C new file mode 100644 index 000000000..07adbb95d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/goto2.C @@ -0,0 +1,20 @@ +// { dg-do assemble } +// { dg-options "-Wunused" } +// Origin: Mark Mitchell <mark@codesourcery.com> + +struct S +{ + S (); + ~S (); +}; + +void f () +{ + { + S s1; + int j; // { dg-warning "" } unused + + t: // { dg-warning "" } unused + S s2; + } +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/goto3.C b/gcc/testsuite/g++.old-deja/g++.other/goto3.C new file mode 100644 index 000000000..e063ad27d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/goto3.C @@ -0,0 +1,20 @@ +// { dg-do assemble } +// Testcase for various invalid gotos. +// Origin: Jason Merrill <jason@redhat.com> + +void f () +{ + goto foo1; // { dg-error "" } jumps + try { foo1:; } catch (...) { } // { dg-error "" } into try + goto foo2; // { dg-error "" } jumps + try { } catch (...) { foo2:; } // { dg-error "" } into catch + goto foo3; // { dg-error "" } jumps + { int i=2; foo3:; } // { dg-error "" } past init + + try { foo4:; } catch (...) { } // { dg-error "" } + goto foo4; // { dg-error "" } + try { } catch (...) { foo5:; } // { dg-error "" } + goto foo5; // { dg-error "" } + { int i=2; foo6:; } // { dg-error "" } + goto foo6; // { dg-error "" } +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/goto4.C b/gcc/testsuite/g++.old-deja/g++.other/goto4.C new file mode 100644 index 000000000..fa0dd5a79 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/goto4.C @@ -0,0 +1,27 @@ +// { dg-do run } +// Test that we clean up temporaries bound to references properly when +// jumping out of their scope. + +int ret = 1; + +struct A +{ + ~A() { ret = 0; } +}; + +void f() +{ + if (0) + { + out: + return; + } + const A& a = A(); + goto out; +} + +int main() +{ + f(); + return ret; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/headers1.C b/gcc/testsuite/g++.old-deja/g++.other/headers1.C new file mode 100644 index 000000000..1080fe38c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/headers1.C @@ -0,0 +1,59 @@ +// { dg-do run } +// Copyright (C) 2000 Free Software Foundation, Inc. +// Contributed by Loren J. Rittle 07 Jun 2000 <ljrittle@acm.org> +// +// This test catches the occasional macro/symbol conflict between +// C++ and system-provided headers. + +#include <algorithm> +#include <bitset> +#include <cassert> +#include <cctype> +#include <cerrno> +#include <cfloat> +#include <ciso646> +#include <climits> +#include <clocale> +#include <cmath> +#include <complex> +#include <csetjmp> +#include <csignal> +#include <cstdarg> +#include <cstddef> +#include <cstdio> +#include <cstdlib> +#include <cstring> +#include <ctime> +#include <deque> +#include <exception> +#include <fstream> +#include <functional> +#include <iomanip> +#include <iosfwd> +#include <iostream> +#include <iterator> +#include <list> +#include <map> +#include <memory> +#include <new> +#include <numeric> +#include <queue> +#include <set> +#include <stack> +#include <stdexcept> +#include <string> +#include <typeinfo> +#include <utility> +// The VxWorks kernel-mode headers define macros named "max" and +// "min", which is not ISO-compliant, but is part of the VxWorks API. +#if defined __vxworks && !defined __RTP__ +#undef max +#undef min +#endif +#include <valarray> +#include <vector> + +int main () +{ + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/incomplete.C b/gcc/testsuite/g++.old-deja/g++.other/incomplete.C new file mode 100644 index 000000000..a00ea1c7d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/incomplete.C @@ -0,0 +1,16 @@ +// { dg-do assemble } + +// gcc represents non-ellipsis parmlists by terminating them with +// a void parm. We need to distinguish between a parmlist of (void), and +// some ill-formed ones. + +struct S; // { dg-error "" } forward ref + +void f(S); // ok +void f(S s) {} // { dg-error "" } incomplete type +void j (int){} // ok +void k (){} // ok +void q (void){} // ok +void t (void t); // { dg-error "" } incomplete +void r (void, ...); // { dg-error "" } incomplete +void s (void const); // { dg-error "" } incomplete diff --git a/gcc/testsuite/g++.old-deja/g++.other/init1.C b/gcc/testsuite/g++.old-deja/g++.other/init1.C new file mode 100644 index 000000000..0759e460b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/init1.C @@ -0,0 +1,11 @@ +// { dg-do run } +extern "C" void abort(); + +int i; +int j = i++; + +int main() +{ + if (i != 1) + abort(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/init10.C b/gcc/testsuite/g++.old-deja/g++.other/init10.C new file mode 100644 index 000000000..7fd07fa89 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/init10.C @@ -0,0 +1,23 @@ +// { dg-do run } +int i; + +struct D { + D () { + i++; + } +}; + +struct C { + C() {} + + D d[1]; +}; + + +int main () +{ + C c; + + if (i != 1) + return 1; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/init11.C b/gcc/testsuite/g++.old-deja/g++.other/init11.C new file mode 100644 index 000000000..f315e570d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/init11.C @@ -0,0 +1,39 @@ +// { dg-do run } +// Check that elements for which no explicit initializer was given are +// default-initialized properly. + +extern "C" int printf (const char *, ...); + +struct A +{ + int i; + A(): i (42) { } + A(int j): i(j) { } +}; + +A ar[4] = { 1, 2 }; + +struct B +{ + A a1, a2, a3, a4; +}; + +B b = { 1, 2 }; + +struct C +{ + A ar[4]; +}; + +C c = { 1, 2 }; + +int +main () +{ + printf ("%d %d %d %d\n%d %d %d %d\n%d %d %d %d\n", + ar[0].i, ar[1].i, ar[2].i, ar[3].i, + b.a1.i, b.a2.i, b.a3.i, b.a4.i, + c.ar[1-1].i, c.ar[2-1].i, c.ar[3-1].i, c.ar[4-1].i); + + return (b.a4.i != 42 || c.ar[3].i != 42); +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/init12.C b/gcc/testsuite/g++.old-deja/g++.other/init12.C new file mode 100644 index 000000000..9b7242699 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/init12.C @@ -0,0 +1,22 @@ +// { dg-do link } +// { dg-options "-O3" } +// Origin: Mark Mitchell <mark@codesourcery.com> + +typedef int (*fp)(); + +struct S +{ + fp f; +}; + +struct T +{ + static int f() { return 0; } +}; + +static const S s = { &T::f }; + +int main() +{ + return (*s.f)(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/init13.C b/gcc/testsuite/g++.old-deja/g++.other/init13.C new file mode 100644 index 000000000..a658c29cd --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/init13.C @@ -0,0 +1,13 @@ +// { dg-do link } +// { dg-options "-O3" } +// Origin: Gabriel Dos_Reis <Gabriel.Dos_Reis@sophia.inria.fr> + +void f() {} + +struct X { + ~X() { f (); } +}; + +X x; + +int main () {} diff --git a/gcc/testsuite/g++.old-deja/g++.other/init14.C b/gcc/testsuite/g++.old-deja/g++.other/init14.C new file mode 100644 index 000000000..e3fca53f6 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/init14.C @@ -0,0 +1,22 @@ +// { dg-do assemble } +// Origin: bkoz@nabi.net + +typedef struct +{ + int count; +} mbstate_t; + +struct fpos +{ + mbstate_t _M_st; + fpos(int __pos) + : _M_st() { + } +}; + +int main () +{ + fpos f (2); +} + + diff --git a/gcc/testsuite/g++.old-deja/g++.other/init15.C b/gcc/testsuite/g++.old-deja/g++.other/init15.C new file mode 100644 index 000000000..022f2ef98 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/init15.C @@ -0,0 +1,22 @@ +// { dg-do assemble } +// Copyright (C) 2000 Free Software Foundation +// Contributed by Nathan Sidwell 21 June 2000 <nathan@codesourcery.com> + +// Origin GNATS bug report 136 from +// language specific constants caused the backend's constant caching machinery +// to fall over. + +struct A { + const char *name; + int reserved; + int a; + int b; + void (A::*func)(); + void Fn (); +}; + +void Interpret() { + struct A cmd_list = + {"a",0,0, 0,&A::Fn} + ; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/init16.C b/gcc/testsuite/g++.old-deja/g++.other/init16.C new file mode 100644 index 000000000..de4c0ad97 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/init16.C @@ -0,0 +1,29 @@ +// { dg-do run } +// Origin: Jakub Jelinek <jakub@redhat.com> + +struct bar { + char c; + bar (const char *); + bar (const bar &); +}; + +struct foo { + 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/init17.C b/gcc/testsuite/g++.old-deja/g++.other/init17.C new file mode 100644 index 000000000..32b2f1d60 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/init17.C @@ -0,0 +1,18 @@ +// { dg-do assemble } + +// Copyright (C) 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 17 Jan 2001 <nathan@codesourcery.com> + +// Bug 1631. Default initialization of enumeral types did not convert to the +// enumeral type. + +enum X { alpha, beta }; + +void f(void *ptr) +{ + X y = X (); + X y1 (0); // { dg-error "" } cannot convert + X y2 = X (0); + X *x = new X (); + X *x2 = new X (0); // { dg-error "" } cannot convert +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/init18.C b/gcc/testsuite/g++.old-deja/g++.other/init18.C new file mode 100644 index 000000000..db579452d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/init18.C @@ -0,0 +1,42 @@ +// Some targets (e.g. those with "set_board_info needs_status_wrapper 1" +// in their dejagnu baseboard description) require that the status is +// final when exit is entered (or main returns), and not "overruled" by a +// destructor calling _exit. It's not really worth it to handle that. +// +// Any platform that doesn't have proper __cxa_atexit support will also fail. +// +// { dg-do run } +// { dg-require-effective-target unwrapped } +// { dg-require-effective-target cxa_atexit } + +#include <stdlib.h> +extern "C" void _exit (int); + +static int cnt = 0; + +class Foo2 +{ + public: + Foo2() {} + ~Foo2() { if (++cnt == 2) _exit (0); } +}; + +static Foo2& GetFoo2() +{ + static Foo2 foo2; + return foo2; +} + +class Foo1 +{ + public: + Foo1() {} + ~Foo1() { if (++cnt != 1) abort(); GetFoo2(); } +}; + +int main( int argc, const char* argv[] ) +{ + static Foo1 anotherFoo; + exit (1); +} + diff --git a/gcc/testsuite/g++.old-deja/g++.other/init19.C b/gcc/testsuite/g++.old-deja/g++.other/init19.C new file mode 100644 index 000000000..bcbe82287 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/init19.C @@ -0,0 +1,85 @@ +// { dg-do run { xfail { { ! cxa_atexit } && { ! { mips-sgi-irix* *-*-solaris2* } } } } } +#include <stdlib.h> + +#define assert(x) do { if (! (x)) abort(); } while (0) + +int count = 0; + +class A +{ +public: + explicit A(int i); + ~A(); + + int i; + + A(const A&); + A& operator=(const A&); +}; + +A::A(int i_) + : i(i_) +{ +} + +A::~A() +{ + assert(++count == i); + i = -1; +} + +extern "C" { + +void one() +{ + static bool second_time; + if (second_time) + assert(++count == 9); + else + { + assert(++count == 1); + second_time = true; + } + static A a(10); + assert(a.i == 10); +} + +void two() +{ + assert(++count == 7); + static A a(8); + assert(a.i == 8); +} + +void three() +{ + assert(++count == 2); + static A a(6); + assert(a.i == 6); +} + +void five() +{ + assert(++count == 4); + static A a(5); + assert(a.i == 5); +} + +void four() +{ + assert(++count == 3); + atexit(five); +} + +} + +A zero(11); + +int main() +{ + one(); + atexit(one); + atexit(two); + three(); + atexit(four); +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/init2.C b/gcc/testsuite/g++.old-deja/g++.other/init2.C new file mode 100644 index 000000000..681229241 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/init2.C @@ -0,0 +1,21 @@ +// { dg-do run } +// { dg-options "-O3" } + +typedef int (*fp)(); + +struct S +{ + fp f; +}; + +static int f() +{ + return 0; +} + +static const S s = { &f }; + +int main() +{ + return (*s.f)(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/init3.C b/gcc/testsuite/g++.old-deja/g++.other/init3.C new file mode 100644 index 000000000..d9eb65447 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/init3.C @@ -0,0 +1,7 @@ +// { dg-do assemble } + +struct X +{ + static const bool is_signed = true ; + static const int digits = is_signed ? 8 *sizeof(wchar_t)-1 : 0; +}; diff --git a/gcc/testsuite/g++.old-deja/g++.other/init4.C b/gcc/testsuite/g++.old-deja/g++.other/init4.C new file mode 100644 index 000000000..f877f2a87 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/init4.C @@ -0,0 +1,12 @@ +// { dg-do assemble } + +class error { +public: + error(int) {} +}; + +class foo { + const error x = 1; // { dg-error "" } initialization of non-static data member +}; + + diff --git a/gcc/testsuite/g++.old-deja/g++.other/init5.C b/gcc/testsuite/g++.old-deja/g++.other/init5.C new file mode 100644 index 000000000..7bb263a93 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/init5.C @@ -0,0 +1,29 @@ +// { dg-do run { xfail { ! cxa_atexit } } } +// Objects must be destructed in decreasing cnt order +// Original test attributed to James Kanze <jkanze@otelo.ibmmail.com> + +extern "C" void abort (); + +static int cnt; + +class A { + int myCnt; +public: + A() : myCnt(cnt++) {} + ~A() { if (--cnt != myCnt) abort(); } +}; + +void f() { static A a; /* a.myCnt == 1 */ } + +class B { + int myCnt; +public: + B() : myCnt(cnt+1) { f(); ++cnt; } + ~B() { if (--cnt != myCnt) abort(); } +}; + +static A a1; // a1.myCnt == 0 +static B b1; // b1.myCnt == 2 +static A a2; // a2.myCnt == 3 + +int main() {} diff --git a/gcc/testsuite/g++.old-deja/g++.other/init6.C b/gcc/testsuite/g++.old-deja/g++.other/init6.C new file mode 100644 index 000000000..66e511a6b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/init6.C @@ -0,0 +1,13 @@ +// { dg-do run } +// Test for default-initialization of POD-structs in functional cast notation. + +struct foo { int a[10]; }; + +int main() +{ + foo f = foo(); + int r = 0; + for (int i = 0; i < 10; ++i) + r |= f.a[i]; + return r; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/init7.C b/gcc/testsuite/g++.old-deja/g++.other/init7.C new file mode 100644 index 000000000..e6c7dc151 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/init7.C @@ -0,0 +1,31 @@ +// { dg-do run } +// simplified from testcase in Windows Developer Journal, +// submitted by eyal.ben-david@aks.com + +// The initialization of a static local variable must be retried if a +// previous try finished by throwing an exception [stmt.dcl]/4 + +extern "C" void abort (); + +struct foo { + foo() { throw true; } +}; + +void bar() { + static foo baz; +} + +int main() { + try { + bar(); // must throw + } + catch (bool) { + try { + bar(); // must throw again! + } + catch (bool) { + return 0; + } + } + abort(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/init8.C b/gcc/testsuite/g++.old-deja/g++.other/init8.C new file mode 100644 index 000000000..0b4b2945c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/init8.C @@ -0,0 +1,11 @@ +// { dg-do assemble } + +// submitted by David C Binderman <dcb@pncl.co.uk> + +// According to [dcl.init]/9, this should be ill-formed + +void +f() +{ + const int var [ 10 ]; // { dg-error "" } missing initializer +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/init9.C b/gcc/testsuite/g++.old-deja/g++.other/init9.C new file mode 100644 index 000000000..6780b5a97 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/init9.C @@ -0,0 +1,40 @@ +// { dg-do assemble } + +// Based on a testcase submitted by Tudor Hulubei <tudor@cs.unh.edu> + +// X is not a POD because it has a user-defined destructor. +// Therefore, we can't cross its initialization. + +// vector<int> is not even an aggregate; nevertheless, no error is +// reported... + +struct A { + A() {} +}; + +void a() { + goto bar; // { dg-error "" } jump from here + A x; // { dg-error "" } jump crosses initialization + bar: // { dg-error "" } jump to here + ; +} + +struct X { + ~X() {} +}; + +void b() { + goto bar; // { dg-error "" } jump from here + X x; // { dg-error "" } jump crosses initialization + bar: // { dg-error "" } jump to here + ; +} + +#include <vector> + +void c() { + goto bar; // { dg-error "" } jump from here + std::vector<int> x; // { dg-error "" } jump crosses initialization + bar: // { dg-error "" } jump to here + ; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/initstring.C b/gcc/testsuite/g++.old-deja/g++.other/initstring.C new file mode 100644 index 000000000..d56189260 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/initstring.C @@ -0,0 +1,3 @@ +// { dg-do assemble } + +static const char foo[] = { "bar" }; diff --git a/gcc/testsuite/g++.old-deja/g++.other/inline1.C b/gcc/testsuite/g++.old-deja/g++.other/inline1.C new file mode 100644 index 000000000..d862f00fb --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/inline1.C @@ -0,0 +1,20 @@ +// { dg-do assemble } +// { dg-options "-O2 -Winline" } +// Origin: Martin Reinecke <martin@MPA-Garching.MPG.DE> + +class foo +{ + public: + float x; + + foo (float xval) + : x (xval) {} + + foo operator+ (const foo &foo2) const + { return foo (x+foo2.x); } +}; + +int main() +{ + foo f=foo(1)+foo(2); +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/inline10.C b/gcc/testsuite/g++.old-deja/g++.other/inline10.C new file mode 100644 index 000000000..cd2415753 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/inline10.C @@ -0,0 +1,18 @@ +// { dg-do assemble } +// { dg-options "-O2" } +// Origin: Mark Mitchell <mark@codesourcery.com> + +struct S +{ +}; + +inline const S f () +{ + return S (); +} + +void g () +{ + S s; + f (); +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/inline11.C b/gcc/testsuite/g++.old-deja/g++.other/inline11.C new file mode 100644 index 000000000..56d803b64 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/inline11.C @@ -0,0 +1,34 @@ +// { dg-do assemble } +// { dg-options "-O2" } +// Origin: Jakub Jelinek <jakub@redhat.com> + +class baz +{ +public: + baz& operator += (const baz&); +}; + +inline baz& baz::operator += (const baz& r) +{ + return *this; +} + +inline baz operator + (int x, const baz& y) +{ + return y; +} + +static inline baz bar (int alpha); +static inline baz foo (int alpha) +{ + baz tmp = alpha + foo (alpha); + tmp += alpha + bar (alpha); + return tmp; +} + +static inline baz bar (int alpha) +{ + baz tmp = alpha + bar (alpha); + tmp += alpha + foo (alpha); + return tmp; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/inline12.C b/gcc/testsuite/g++.old-deja/g++.other/inline12.C new file mode 100644 index 000000000..c91845c41 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/inline12.C @@ -0,0 +1,326 @@ +// { dg-do assemble } +// { dg-options "-O2 -g" } +// (Should preferrably cycle through options.) +// Origin: Hans-Peter Nilsson <hp@axis.com> +// See <URL:http://gcc.gnu.org/ml/gcc-patches/2000-06/msg00310.html> + +typedef unsigned int udword; +extern "C" { +void __assert (const char *, int, const char *); +} +class ShZzy; +class ShBe; +class Sh +{ + public: + class Xy; + inline Sh(const char* theName, + const Xy& theXys); + virtual ~Sh(); + inline const char* name() const; + inline bool shXy(const Xy& theXy); + virtual void setParent(Sh* theParent); + class Xy + { + public: + Xy(int theXy); + Xy(const Xy& theXy); + Xy& operator = (const Xy&); + bool sh(const Xy& theXy); + private: + int myXyFlags; + }; + protected: + Xy myXys; + private: + Sh(); + Sh(const Sh&); + Sh& operator = (const Sh&); + const char* myName; + Sh* myParent; +}; +class ShZzy : public Sh +{ + public: + inline ShZzy(const char* theName); + inline ShZzy(const char* theName, + const Xy& theXys); + virtual ~ShZzy(); + void addShTo(char* theParent); + virtual void ap() {} + void addSh(Sh* theSh); + virtual void setParent(Sh* theParent); + void baseAp(); + private: + ShZzy(); + ShZzy(const ShZzy&); + ShZzy& operator = (const ShZzy&); + bool iAmInited; +}; +class ShBop +{ + public: + inline ShBop(const ShBe* theBe); + void shWw(bool, + const char* a1 = "", + const char* a2 = "", + int a3 = -1, + const char* a4 = "foo"); + typedef enum { shOk, + shFailed, + shDone, + invalidBop } bopType; + inline bopType bop(); + inline int numberOfVs(); + inline void closeBop(); + private: + ShBop(const ShBop&); + ShBop& operator = (const ShBop&); + const ShBe* myBe; + bopType myBop; + int my1; + int my2; + const char* my3; + const char* my4; + int my5; + const char* my6; +}; +Sh::Sh(const char* theName, + const Xy& theXys) + :myXys(theXys), + myName(theName), + myParent(0) +{} +const char* +Sh::name() const +{ + return myName; +} +bool +Sh::shXy(const Xy& theXy) +{ + return myXys.sh(theXy); +} +ShZzy::ShZzy(const char* theName) + :Sh(theName, Xy(0)), + iAmInited(false) +{} +ShZzy::ShZzy(const char* theName, + const Xy& theXys) + :Sh(theName, theXys), + iAmInited(false) +{} +ShBop::ShBop(const ShBe* theBe) + :myBe(theBe), + myBop(invalidBop), + my1(0), + my2(0), + my3(""), + my4(""), + my5(0), + my6("") +{} +ShBop::bopType +ShBop::bop() +{ + ((!my2 || myBop == shFailed) ? (void)0 : __assert("foo", 91,"foo")); + return myBop; +} +int +ShBop::numberOfVs() +{ + return my2 + my1; +} +void +ShBop::closeBop() +{ + if (myBop == invalidBop) + { + myBop = shDone; + } +} +class ShBe; +template <class ShCc> +class ShAp : public ShZzy +{ + public: + ShAp(const char* theName); + ShAp(const char* theName, + const Xy& theXys); + virtual ~ShAp() {} + typedef void (ShCc::*ShMethod)(); + virtual void ap() {} + protected: + ShBop* bop(); + private: + ShAp(); + ShAp(const ShAp&); + ShAp& operator = (const ShAp&); + ShBop* myBop; + ShBe* myBe; +}; +class ShBe : public Sh +{ + public: + inline ShBe(const char* theName); + inline ShBe(const char* theName, + const Xy& theXys); + inline virtual ~ShBe(); + virtual void run() = 0; + ShBop* runBe(); + protected: + inline ShBop* bop(); + private: + ShBe(); + ShBe(const ShBe&); + ShBe& operator = (const ShBe&); + ShBop* myBop; +}; +template <class ShCc> +ShAp<ShCc>::ShAp(const char* theName) + : ShZzy(theName), + myBop(0), + myBe(0) +{} +template <class ShCc> +ShAp<ShCc>::ShAp(const char* theName, + const Sh::Xy& theXys) + : ShZzy(theName, theXys), + myBop(0), + myBe(0) +{} +template <class ShCc> +ShBop* +ShAp<ShCc>::bop() +{ + ((myBop) ? (void)0 : __assert("foo", 96,"foo")); + return myBop; +} +class xSh : public ShAp<xSh> +{ + public: + xSh(); + virtual ~xSh(); + void ap(); + void uff(); + void rtt(); +}; +class xUff +{ + public: + xUff(); + xUff(const xUff&); + xUff& operator = (const xUff&); + xUff(udword); + operator udword() const; + xUff& operator = (udword); + bool operator < (const xUff) const; + bool operator <= (const xUff) const; + bool operator > (const xUff) const; + bool operator >= (const xUff) const; + bool operator == (const xUff) const; + enum {size = 4}; + xUff(unsigned char* theUff); + private: + udword myUff; +}; +inline +xUff::xUff() + : myUff(0) +{ +} +inline +xUff::xUff(udword theUff) + : myUff(theUff) +{ +} +inline +xUff::xUff( + const xUff& theUff) + : myUff(theUff.myUff) +{ +} +inline xUff& +xUff::operator = (const xUff& theUff) +{ + myUff = theUff.myUff; + return *this; +} +inline xUff& +xUff::operator = (udword theUff) +{ + myUff = theUff; + return *this; +} +inline +xUff::operator udword() const +{ + return myUff; +} +inline bool +xUff::operator < (const xUff ding) const +{ + return (((int) (myUff - ding.myUff)) < 0); +} +inline bool +xUff::operator <= (const xUff ding) const +{ + return (((int) (myUff - ding.myUff)) <= 0); +} +inline bool +xUff::operator > (const xUff ding) const +{ + return (((int) (myUff - ding.myUff)) > 0); +} +inline bool +xUff::operator >= (const xUff ding) const +{ + return (((int) (myUff - ding.myUff)) >= 0); +} +inline bool +xUff::operator == (const xUff ding) const +{ + return (myUff == ding.myUff); +} +inline +xUff::xUff(unsigned char* theUff) +{ + myUff = *(udword *)theUff; +} +void +xSh::uff() +{ + static const udword halfudword = 0x80000000; + xUff aGah((udword)0); + udword diagonal = halfudword + (udword) aGah; + xUff aGeh(diagonal - 1); + xUff aGoh(diagonal + 1); + (bop()->shWw ((aGah.operator <=(aGah)), ("foo"), ( ""), 118, "foo")); + (bop()->shWw ((aGah.operator >=(aGah)), ("foo"), ( ""), 119, "foo")); + (bop()->shWw ((!(aGah.operator <(aGah))), ("foo"), ( ""), 120, "foo")); + (bop()->shWw ((!(aGah.operator >(aGah))), ("foo"), ( ""), 121, "foo")); + (bop()->shWw ((aGah.operator <(aGeh)), ("foo"), ( ""), 124, "foo")); + (bop()->shWw ((aGah.operator <=(aGeh)), ("foo"), ( ""), 125, "foo")); + (bop()->shWw ((!(aGah.operator >(aGeh))), ("foo"), ( ""), 126, "foo")); + (bop()->shWw ((!(aGah.operator >=(aGeh))), ("foo"), ( ""), 127, "foo")); + (bop()->shWw ((aGeh.operator >(aGah)), ("foo"), ( ""), 130, "foo")); + (bop()->shWw ((aGeh.operator >=(aGah)), ("foo"), ( ""), 131, "foo")); + (bop()->shWw ((!(aGeh.operator <(aGah))), ("foo"), ( ""), 132, "foo")); + (bop()->shWw ((!(aGeh.operator <=(aGah))), ("foo"), ( ""), 133, "foo")); + (bop()->shWw ((aGeh.operator <(aGoh)), ("foo"), ( ""), 136, "foo")); + (bop()->shWw ((aGeh.operator <=(aGoh)), ("foo"), ( ""), 137, "foo")); + (bop()->shWw ((!(aGeh.operator >(aGoh))), ("foo"), ( ""), 138, "foo")); + (bop()->shWw ((!(aGeh.operator >=(aGoh))), ("foo"), ( ""), 139, "foo")); + (bop()->shWw ((aGoh.operator >(aGeh)), ("foo"), ( ""), 142, "foo")); + (bop()->shWw ((aGoh.operator >=(aGeh)), ("foo"), ( ""), 143, "foo")); + (bop()->shWw ((!(aGoh.operator <(aGeh))), ("foo"), ( ""), 144, "foo")); + (bop()->shWw ((!(aGoh.operator <=(aGeh))), ("foo"), ( ""), 145, "foo")); + (bop()->shWw ((aGah.operator >(aGoh)), ("foo"), ( ""), 152, "foo")); + (bop()->shWw ((aGah.operator >=(aGoh)), ("foo"), ( ""), 153, "foo")); + (bop()->shWw ((!(aGah.operator <(aGoh))), ("foo"), ( ""), 154, "foo")); + (bop()->shWw ((!(aGah.operator <=(aGoh))), ("foo"), ( ""), 155, "foo")); + (bop()->shWw ((aGoh.operator <(aGah)), ("foo"), ( ""), 158, "foo")); + (bop()->shWw ((aGoh.operator <=(aGah)), ("foo"), ( ""), 159, "foo")); + (bop()->shWw ((!(aGoh.operator >(aGah))), ("foo"), ( ""), 160, "foo")); + (bop()->shWw ((!(aGoh.operator >=(aGah))), ("foo"), ( ""), 161, "foo")); +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/inline13.C b/gcc/testsuite/g++.old-deja/g++.other/inline13.C new file mode 100644 index 000000000..bf8e52e01 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/inline13.C @@ -0,0 +1,18 @@ +// { dg-do assemble } +// Origin: Alexandre Oliva <aoliva@cygnus.com> + +struct foo { + inline void bar(); + foo(); +}; + +inline void foo::bar() { + switch (0) { + case 0: + break; + } +} + +foo::foo() { + bar(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/inline14.C b/gcc/testsuite/g++.old-deja/g++.other/inline14.C new file mode 100644 index 000000000..1bd74b4ac --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/inline14.C @@ -0,0 +1,49 @@ +// { dg-do assemble } +// Origin: Gerald Pfeifer <pfeifer@dbai.tuwien.ac.at> + +#include <iostream> + +struct IDENT + { + enum TYPE { Variable, Constant } type; + + std::ostream& printTo(std::ostream& out) const + { + switch (type) + { + case Variable: + out << '_'; + break; + default: + break; + } + return out; + } + }; + + +template <class T> +struct TC + { + IDENT i; + + const IDENT& getIdent() const + { + return i; + } + }; + +template <class T> +inline std::ostream& operator<< (std::ostream& out, const TC<T> &c) + { + c.getIdent().printTo(out); + return out; + } + +void foo(const TC<IDENT> &c) + { + std::cerr << c + << ": " // This line is crucial! + << c + << std::endl; + } diff --git a/gcc/testsuite/g++.old-deja/g++.other/inline15.C b/gcc/testsuite/g++.old-deja/g++.other/inline15.C new file mode 100644 index 000000000..43f7f5e30 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/inline15.C @@ -0,0 +1,31 @@ +// { dg-do assemble } +// { dg-options "-O1" } +// Origin: Jakub Jelinek <jakub@redhat.com> + +class Type; +template<class E> +class X +{ +public: + X<E>(); + inline X<E>(int); + inline ~X<E>(); +}; +template<class E> const Type &foo(const X<E> *); +template<class E> inline X<E>::X(int x) +{ + const Type &a = foo(this); +} +template<class E> inline X<E>::~X() +{ + const Type &a = foo(this); +} +class Y +{ + X<Type> a; +public: + Y(const X<Type> &x = X<Type>()); +}; +Y::Y(const X<Type> &x) : a(1) +{ +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/inline16.C b/gcc/testsuite/g++.old-deja/g++.other/inline16.C new file mode 100644 index 000000000..95bfa7aac --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/inline16.C @@ -0,0 +1,24 @@ +// { dg-do assemble } +// { dg-options "-O1" } +// Origin: Jakub Jelinek <jakub@redhat.com> + +struct foo { + bool x; + inline void a (unsigned char y); + inline void b (void); + virtual ~foo (); +}; + +foo::~foo () +{ +} + +void foo::a (unsigned char y) +{ + x = ((y & 2) != 0); +} + +void foo::b (void) +{ + a(0x07); +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/inline17.C b/gcc/testsuite/g++.old-deja/g++.other/inline17.C new file mode 100644 index 000000000..b7890e7ef --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/inline17.C @@ -0,0 +1,22 @@ +// { dg-do assemble } +// { dg-options "-O3" } +// Origin: Jakub Jelinek <jakub@redhat.com> + +struct foo +{ + char a; + foo (); + void bar (); + void baz (char c); +}; + +void foo::baz (char c) +{ + if (c != a) + a = c; +} + +void foo::bar () +{ + baz (1); +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/inline18.C b/gcc/testsuite/g++.old-deja/g++.other/inline18.C new file mode 100644 index 000000000..70c4cf6e0 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/inline18.C @@ -0,0 +1,13 @@ +// { dg-do assemble } +// { dg-options "-O3" } +// Origin: Jakub Jelinek <jakub@redhat.com> + +static void foo (int a) +{ + a = a; +} + +static void bar (void) +{ + foo (-1); +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/inline19.C b/gcc/testsuite/g++.old-deja/g++.other/inline19.C new file mode 100644 index 000000000..76731a56e --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/inline19.C @@ -0,0 +1,22 @@ +// { dg-do assemble } +// { dg-options "-O1" } +// Origin: Scott Snyder <snyder@fnal.gov> via PR 1733. +// + +struct TBtItem +{ + TBtItem(); +}; + + +struct TBtInnerNode +{ + TBtInnerNode(); + int MaxIndex() const { return 10; } +}; + + +TBtInnerNode::TBtInnerNode() +{ + new TBtItem[MaxIndex()+1]; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/inline2.C b/gcc/testsuite/g++.old-deja/g++.other/inline2.C new file mode 100644 index 000000000..f1d196266 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/inline2.C @@ -0,0 +1,11 @@ +// { dg-do assemble } +// { dg-options "-O2 -Winline" } +// Origin: Martin Reinecke <martin@MPA-Garching.MPG.DE> + +#include <cmath> + +int main() +{ + double foo = 4.5; + if (std::abs (0.5-std::abs (foo-0.5)) < 1e-10) foo+=1; +} 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 000000000..0e94291fb --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/inline20.C @@ -0,0 +1,58 @@ +// { dg-do assemble } + +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 000000000..25715acab --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/inline21.C @@ -0,0 +1,40 @@ +// { dg-do run } +// { dg-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 BEHAVIOR + +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/inline23.C b/gcc/testsuite/g++.old-deja/g++.other/inline23.C new file mode 100644 index 000000000..dcb443be1 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/inline23.C @@ -0,0 +1,28 @@ +// { dg-do link } + +struct B +{ + virtual ~B() {} +}; + +struct A : public B +{ + ~A(); + void foo(void); + void bar(void); +}; + +inline void A::foo(void) +{ + static int i; + i++; +} + +void A::bar() +{ + foo(); +} + +int main() +{ +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/inline3.C b/gcc/testsuite/g++.old-deja/g++.other/inline3.C new file mode 100644 index 000000000..a61410015 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/inline3.C @@ -0,0 +1,51 @@ +// { dg-do assemble } +// { dg-options "-O3" } +// Origin: Mark Mitchell <mark@codesourcery.com> + +class ostream; + +struct S +{ + virtual void print(ostream&) const = 0; +}; + +template <class _Tp> +class vector +{ +public: + _Tp& operator[](unsigned __n) const { return *(_M_start + __n); } + _Tp* _M_start; +}; + +class T +{ +public: + + void print(ostream&) const; + + vector<S*> bcList_m; +}; + +void T::print(ostream& o) const +{ + int n = 3; + + for (int i = 0; i < n; ++i) + bcList_m[i]->print(o); + return; +} + +ostream& +operator<<(ostream& o, const T& bcList) +{ + bcList.print(o); + return o; +} + + + + + + + + diff --git a/gcc/testsuite/g++.old-deja/g++.other/inline4.C b/gcc/testsuite/g++.old-deja/g++.other/inline4.C new file mode 100644 index 000000000..b68c7c2c7 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/inline4.C @@ -0,0 +1,25 @@ +// { dg-do assemble } +// { dg-options "-O2" } +// Origin: Mark Mitchell <mark@codesourcery.com> + +inline void f () +{ + return; +} + +inline void g (); + +void (*gp)() = &g; + +inline void g () +{ + f (); +} + +extern int array_size; + +void h () +{ + int lookup_array[array_size]; + g (); +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/inline5.C b/gcc/testsuite/g++.old-deja/g++.other/inline5.C new file mode 100644 index 000000000..b538cdba9 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/inline5.C @@ -0,0 +1,30 @@ +// { dg-do assemble } +// { dg-options "-O2" } +// Origin: Matt Austern <austern@isolde.engr.sgi.com> + +class X; + +extern X* tab1; + +struct Y { + explicit Y(int); +}; + +void* x (); + +Y k (void *); + +inline void f() { k (x ()); } + +inline void* x () +{ + return 0; +} + +static void g() { + f(); +} + +static void h() { + f(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/inline6.C b/gcc/testsuite/g++.old-deja/g++.other/inline6.C new file mode 100644 index 000000000..04de9fce4 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/inline6.C @@ -0,0 +1,19 @@ +// { dg-do assemble } +// { dg-options "-O2" } +// Origin: Mark Mitchell <mark@codesourcery.com> + +struct S +{ +}; + +void f (S s = S ()); + +inline void g () +{ + f (); +} + +void h () +{ + g (); +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/inline7.C b/gcc/testsuite/g++.old-deja/g++.other/inline7.C new file mode 100644 index 000000000..a3723cfba --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/inline7.C @@ -0,0 +1,18 @@ +// { dg-do run } +// { dg-options "-O2" } +// Origin: Mark Mitchell <mark@codesourcery.com> + +#include <list> + +std::list<int*> li; + +void f () +{ + li.size (); +} + +int main () +{ + li.push_back (0); + f (); +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/inline8.C b/gcc/testsuite/g++.old-deja/g++.other/inline8.C new file mode 100644 index 000000000..a46dc382a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/inline8.C @@ -0,0 +1,69 @@ +// { dg-do run } +// { dg-options "-O1" } +// Origin: Gerald Pfeifer <pfeifer@dbai.tuwien.ac.at> + +#include <map> +#include <cstdlib> +#include <cstring> + +using namespace std; + +class NAMES_ITEM + { +public: + char *name; + + NAMES_ITEM(const NAMES_ITEM& item2); + + NAMES_ITEM(const char* name2); + + ~NAMES_ITEM(); + + bool operator==(const NAMES_ITEM& n) const; + }; + + +NAMES_ITEM::NAMES_ITEM (const NAMES_ITEM& item2) + { + size_t length=std::strlen(item2.name); + + name=new char[length+1]; + std::memcpy(name,item2.name,length+1); + } + +NAMES_ITEM::NAMES_ITEM (const char* name2) + { + size_t length=std::strlen(name2); + + name=new char[length+1]; + std::memcpy(name,name2,length+1); + } + +NAMES_ITEM::~NAMES_ITEM () +{ + if (std::strcmp (name, "one") != 0) + abort (); + + name=0; +} + +bool NAMES_ITEM::operator==(const NAMES_ITEM& n) const +{ + return (std::strcmp(name,n.name) == 0); +} + +bool operator<(const NAMES_ITEM& n1, const NAMES_ITEM& n2) + { + return (std::strcmp(n1.name,n2.name) < 0); + } + + typedef map<NAMES_ITEM,size_t,less<NAMES_ITEM> > lookup_t; + + lookup_t lookup; + + NAMES_ITEM item ("one"); +main() + { + lookup.insert(pair<NAMES_ITEM,size_t>(item,0)); + } + diff --git a/gcc/testsuite/g++.old-deja/g++.other/inline9.C b/gcc/testsuite/g++.old-deja/g++.other/inline9.C new file mode 100644 index 000000000..9a82fcf72 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/inline9.C @@ -0,0 +1,20 @@ +// { dg-do assemble } +// { dg-options "-O2" } +// Origin: Mark Mitchell <mitchell@codesourcery.com> + +inline void f () +{ + int n; + int i[n]; +} + +void g () +{ + f (); +} + +void h () +{ + f (); +} + diff --git a/gcc/testsuite/g++.old-deja/g++.other/instan1.C b/gcc/testsuite/g++.old-deja/g++.other/instan1.C new file mode 100644 index 000000000..3c294c396 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/instan1.C @@ -0,0 +1,24 @@ +// { dg-do link } +// { dg-options "-fno-implicit-templates" } +// Origin: Mark Mitchell <mark@codesourcery.com> + +template <class T> +struct U { + static int j; +}; + +template <class T> +struct S { + static const int i = 7; +}; + +template <class T> +const int S<T>::i; + +template <class T> +int U<T>::j = S<T>::i + 5; + +template int U<double>::j; + +int main () { +} 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 000000000..4e172780c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/lex1.C @@ -0,0 +1,12 @@ +// { dg-do assemble } +// +// 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 + // { dg-error "" } stray char +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/lineno1.C b/gcc/testsuite/g++.old-deja/g++.other/lineno1.C new file mode 100644 index 000000000..810052250 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/lineno1.C @@ -0,0 +1,15 @@ +// { dg-do assemble } +// { dg-options "-w" } +// Submitted by Nathan Sidwell <nathan@acm.org> +// Bug: g++ was giving the wrong line number for statics. + +class A +{ + A(); // { dg-error "" } private + ~A(); // { dg-error "" } private +}; + +static A a; // { dg-error "" } here + + + diff --git a/gcc/testsuite/g++.old-deja/g++.other/lineno2.C b/gcc/testsuite/g++.old-deja/g++.other/lineno2.C new file mode 100644 index 000000000..3735d6481 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/lineno2.C @@ -0,0 +1,15 @@ +// { dg-do assemble } +// Submitted by Nathan Sidwell <nathan@acm.org> +// Bug: g++ wasn't listing candidates for a failed conversion. + +void f(int, double); // { dg-error "" } candidate +void f(double, int); // { dg-error "" } candidate +void f(int); // { dg-error "" } candidate + +int +main () +{ + void (*ptr)(int, int); + + ptr = &f; // { dg-error "" } no match +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/lineno3.C b/gcc/testsuite/g++.old-deja/g++.other/lineno3.C new file mode 100644 index 000000000..2b3ba059f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/lineno3.C @@ -0,0 +1,29 @@ +// { dg-do assemble } +// Bug: g++ gets confused by the #line directive within a method. +// Contributed by Mark Mitchell <mark@codesourcery.com> + +struct S +{ + void f () + { + int i; + + + + + + + + + + + + + + + + + + int j; + } +}; diff --git a/gcc/testsuite/g++.old-deja/g++.other/lineno4.C b/gcc/testsuite/g++.old-deja/g++.other/lineno4.C new file mode 100644 index 000000000..ce60e2c0f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/lineno4.C @@ -0,0 +1,7 @@ +// { dg-do assemble } + +#define x \ + y + +int; // { dg-error "" } invalid declaration + 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 000000000..d22733953 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/lineno5.C @@ -0,0 +1,20 @@ +// { dg-do assemble } +// +// 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; // { dg-message "tmp::b" } +} + +class A { + public: + int kaka(tmp::B = b); // { dg-error "" } no b in scope + // { dg-message "suggested alternative" "suggested alternative" { target *-*-* } 18 } +}; diff --git a/gcc/testsuite/g++.old-deja/g++.other/linkage1.C b/gcc/testsuite/g++.old-deja/g++.other/linkage1.C new file mode 100644 index 000000000..556ef9716 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/linkage1.C @@ -0,0 +1,15 @@ +// { dg-do assemble } +typedef struct { + int i; +} *p; + +void f (p) { } // { dg-error "with no linkage" } +p q; // { dg-warning "with no linkage" } + +int main() +{ + extern p j; // { dg-warning "with no linkage" } + struct A { int j; }; + extern A a; // { dg-warning "with no linkage" } + extern void f (A); // { dg-error "with no linkage" } +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/linkage2.C b/gcc/testsuite/g++.old-deja/g++.other/linkage2.C new file mode 100644 index 000000000..2385b2216 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/linkage2.C @@ -0,0 +1,14 @@ +// { dg-do assemble } +// From: Klaus-Georg Adams <Klaus-Georg.Adams@chemie.uni-karlsruhe.de> +extern "C" +{ +typedef struct {int dummy[10];} *GDBM_FILE; +extern GDBM_FILE gdbm_open(); +} + +typedef struct { int dummy[10]; } *FAIL_FILE; +extern FAIL_FILE fail_open(); // { dg-error "" } non-local function + +typedef struct { int dummy[10]; } *SUCCESS_FILE, S; +extern SUCCESS_FILE success_open(); + diff --git a/gcc/testsuite/g++.old-deja/g++.other/linkage3.C b/gcc/testsuite/g++.old-deja/g++.other/linkage3.C new file mode 100644 index 000000000..8ddff82f5 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/linkage3.C @@ -0,0 +1,5 @@ +// { dg-do assemble } +// Origin: Mark Mitchell <mark@codesourcery.com> + +extern "C" void f (); // { dg-error "" } previous declaration +static void f () {} // { dg-error "" } extern redeclared static diff --git a/gcc/testsuite/g++.old-deja/g++.other/linkage4.C b/gcc/testsuite/g++.old-deja/g++.other/linkage4.C new file mode 100644 index 000000000..7531f4516 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/linkage4.C @@ -0,0 +1,11 @@ +// { dg-do assemble } +// Origin: Mark Mitchell <mark@codesourcery.com> + +static int strlen (const char*) { return 0; } + +template <int (*)(const char*)> +void f () {} + +// Check that the strlen declaration here is given internal linkage by +// using it as a non-type template argument, and expecting an error. +template void f<strlen>(); // { dg-error "" } no matching template diff --git a/gcc/testsuite/g++.old-deja/g++.other/linkage5.C b/gcc/testsuite/g++.old-deja/g++.other/linkage5.C new file mode 100644 index 000000000..7c420c116 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/linkage5.C @@ -0,0 +1,6 @@ +// { dg-do assemble } +// Origin: Jason Merrill <jason@cygnus.com> + +static int f (); +int f (); +static int f (); diff --git a/gcc/testsuite/g++.old-deja/g++.other/linkage6.C b/gcc/testsuite/g++.old-deja/g++.other/linkage6.C new file mode 100644 index 000000000..516a24267 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/linkage6.C @@ -0,0 +1,18 @@ +// { dg-do assemble } +// { dg-options "-fno-weak" } +// Origin: Mark Mitchell <mark@codesourcery.com> + +template <typename T> +void f (); + +void h () { f<int> (); } + +template <void (*X)()> +void g () {} + +template <typename T> +void f () +{ + g<&f<T> >(); +} + 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 000000000..d1470a9ed --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/linkage7.C @@ -0,0 +1,14 @@ +// { dg-do link } +// 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/local-alloc1.C b/gcc/testsuite/g++.old-deja/g++.other/local-alloc1.C new file mode 100644 index 000000000..7488f1971 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/local-alloc1.C @@ -0,0 +1,17 @@ +// { dg-do assemble { target fpic } } +// { dg-options "-O0 -fpic" } +// { dg-skip-if "requires unsupported run-time relocation" { spu-*-* } { "*" } { "" } } +// Origin: Jakub Jelinek <jakub@redhat.com> + +struct bar { + bar() {} + double x[3]; +}; + +static bar y[4]; + +void foo(int z) +{ + bar w; + y[z] = w; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/local1.C b/gcc/testsuite/g++.old-deja/g++.other/local1.C new file mode 100644 index 000000000..a51d50be7 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/local1.C @@ -0,0 +1,13 @@ +// { dg-do link } + +struct Outer { + virtual ~Outer() {} +}; + +int +main() +{ + { struct Inner : virtual public Outer {} inner; } + { struct Inner : virtual public Outer {} inner; } +} + diff --git a/gcc/testsuite/g++.old-deja/g++.other/local2.C b/gcc/testsuite/g++.old-deja/g++.other/local2.C new file mode 100644 index 000000000..12b777ce3 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/local2.C @@ -0,0 +1,10 @@ +// { dg-do assemble } +// { dg-options "-O2" } + +void f () +{ + struct Init { + Init () { + } + }; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/local3.C b/gcc/testsuite/g++.old-deja/g++.other/local3.C new file mode 100644 index 000000000..3879b141d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/local3.C @@ -0,0 +1,17 @@ +// { dg-do run } +// Bug: g++ lies about DECL_CONTEXT, so the backend thinks B::f is not +// function-local. +// Contributed by Jason Merrill <jason@cygnus.com> + +struct A { + virtual void f () = 0; +}; + +int main() +{ + struct B : public A { + void f () { } + }; + + B b; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/local4.C b/gcc/testsuite/g++.old-deja/g++.other/local4.C new file mode 100644 index 000000000..b5514a54b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/local4.C @@ -0,0 +1,11 @@ +// { dg-do run } +// Test that a local declaration of one of a global overload set works + +int f () { return 0; } +int f (int); + +int main () +{ + int f (); + return f (); +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/lookup1.C b/gcc/testsuite/g++.old-deja/g++.other/lookup1.C new file mode 100644 index 000000000..c7f220fd6 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/lookup1.C @@ -0,0 +1,9 @@ +// { dg-do assemble } +// simple test for id from base class during class defn + +struct foo { + enum { blah = 1 }; +}; +struct bar : public foo { + char cache[blah]; +}; diff --git a/gcc/testsuite/g++.old-deja/g++.other/lookup10.C b/gcc/testsuite/g++.old-deja/g++.other/lookup10.C new file mode 100644 index 000000000..a60071dab --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/lookup10.C @@ -0,0 +1,10 @@ +// { dg-do assemble } + +struct A { + struct B { + static int i; + }; + enum { a }; +}; + +int A::B::i = a; diff --git a/gcc/testsuite/g++.old-deja/g++.other/lookup11.C b/gcc/testsuite/g++.old-deja/g++.other/lookup11.C new file mode 100644 index 000000000..d7f12ed41 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/lookup11.C @@ -0,0 +1,12 @@ +// { dg-do assemble } + +namespace A { + int i; +} +using namespace A; +namespace B { + int i; +} +using namespace B; + +int i; diff --git a/gcc/testsuite/g++.old-deja/g++.other/lookup12.C b/gcc/testsuite/g++.old-deja/g++.other/lookup12.C new file mode 100644 index 000000000..d283e2c29 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/lookup12.C @@ -0,0 +1,21 @@ +// { dg-do assemble } +// Origin: Mark Mitchell <mark@codesourcery.com> + +struct B { + struct X {}; +}; + + +struct D : public B { + void X(); + + struct X x; + + void f(); +}; + + +void D::f() +{ + struct X y; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/lookup13.C b/gcc/testsuite/g++.old-deja/g++.other/lookup13.C new file mode 100644 index 000000000..872c35ff0 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/lookup13.C @@ -0,0 +1,19 @@ +// { dg-do run } +// Origin: Mark Mitchell <mark@codesourcery.com> + +int main() +{ + typedef double I; + + struct S1 { + typedef char I; + + struct S2; + }; + + struct S1::S2 { + typedef I J; + }; + + return !(sizeof (S1::S2::J) == 1); +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/lookup14.C b/gcc/testsuite/g++.old-deja/g++.other/lookup14.C new file mode 100644 index 000000000..2d2560ee7 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/lookup14.C @@ -0,0 +1,14 @@ +// { dg-do assemble } +// Origin: Mark Mitchell <mark@codesourcery.com> + +union U { + typedef int I; + + struct S { + void f(); + }; +}; + +void U::S::f() { + I i; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/lookup15.C b/gcc/testsuite/g++.old-deja/g++.other/lookup15.C new file mode 100644 index 000000000..4d5ce70c2 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/lookup15.C @@ -0,0 +1,37 @@ +// { dg-do assemble } +// Origin: Benjamin Kosnik <bkoz@cygnus.com> + +class b +{ + int j; +public: + b(int a = 6): j(a) {} + void imbue(int a) {++j;} +}; + +class d: public b +{ + int k; +public: + d(int a = 7): b(a), k(a) {} + void imbue(int a) {++k;} +}; + +//virtual public kills, public ok +class mostd: virtual public d +{ + int l; +public: + mostd(int a = 9): d(a), l(a) {} +}; + +int main() { + + d dobj; + dobj.imbue(5); + + mostd mobj; + mobj.imbue(5); + + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/lookup16.C b/gcc/testsuite/g++.old-deja/g++.other/lookup16.C new file mode 100644 index 000000000..52944530d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/lookup16.C @@ -0,0 +1,31 @@ +// { dg-do assemble } +// Copyright (C) 1999 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 25 Aug 1999 <nathan@acm.org> + +// Bug 3 +// typenames are not injected early enough, [basic.scope.pdecl]3.3.1/4 +// indicates this should compile. + +struct A { +}; + +struct B : A { + typedef A Parent; + struct F { + }; +}; + +struct C : B { + typedef B Parent; + struct G {}; + struct F : C::Parent::F { + typedef C::Parent::F Parent; + }; +}; + +struct D : B { + typedef B Parent; + struct F : D::Parent::F { // finds the wrong Parent + typedef D::Parent::F Parent; + }; +}; diff --git a/gcc/testsuite/g++.old-deja/g++.other/lookup17.C b/gcc/testsuite/g++.old-deja/g++.other/lookup17.C new file mode 100644 index 000000000..80a3b1a87 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/lookup17.C @@ -0,0 +1,15 @@ +// { dg-do run } +// Bug: t->B is resolved to the type instead of the field. + +struct A { + struct B { } *B; + int i, j, k, l, m; +}; + +struct A a; + +int +main () +{ + void *p = a.B; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/lookup18.C b/gcc/testsuite/g++.old-deja/g++.other/lookup18.C new file mode 100644 index 000000000..71124a2f0 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/lookup18.C @@ -0,0 +1,23 @@ +// { dg-do assemble } +// Test that referring to an ambiguous base in name lookup prevents +// access to the field, even though the field is not ambiguous. + + +struct A { + int i; +}; +struct B: virtual A { }; +struct C: public B { }; +struct D: public B { }; +struct E: public C, public D { + void f (); +}; + +void E::f() { + B::i = 0; // { dg-error "" } B is ambiguous +} + +void f () { + E e; + e.B::i = 0; // { dg-error "" } B is ambiguous +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/lookup19.C b/gcc/testsuite/g++.old-deja/g++.other/lookup19.C new file mode 100644 index 000000000..d4104f0fc --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/lookup19.C @@ -0,0 +1,54 @@ +// { dg-do assemble } +// Test for proper handling of type lookup for conversion operator names. + +// Test 1: Only at file scope +typedef int B; +struct A +{ + int B; + operator B *(); // { dg-error "" } +}; + +A::operator B * () // { dg-error "" } +{ + return 0; +} + +// Test 2: Only at class scope +struct C +{ + typedef int D; + operator D *(); +}; + +int D; +C::operator D * () +{ + return 0; +} + +// Test 3: Matching +struct E +{ + typedef int F; + operator F *(); +}; + +typedef int F; +E::operator F * () +{ + return 0; +} + +// Test 4: Conflicting +struct G +{ + typedef int H; + operator H *(); +}; + +typedef double H; +G::operator H * () +{ + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/lookup2.C b/gcc/testsuite/g++.old-deja/g++.other/lookup2.C new file mode 100644 index 000000000..567f7a43a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/lookup2.C @@ -0,0 +1,13 @@ +// { dg-do assemble } + +struct B { + int i; +}; + +struct D: virtual public B { + int i; +}; + +struct D2 : public D { + void f() { i = 3; } +}; diff --git a/gcc/testsuite/g++.old-deja/g++.other/lookup20.C b/gcc/testsuite/g++.old-deja/g++.other/lookup20.C new file mode 100644 index 000000000..ff2352159 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/lookup20.C @@ -0,0 +1,10 @@ +// { dg-do assemble } +// Bug: typename_sub2 returned the type, so we tried to look up "A" in B. + +struct A { struct A1 { }; }; + +struct B { + typedef A Q; +}; + +struct C: public B::Q::A1 { }; diff --git a/gcc/testsuite/g++.old-deja/g++.other/lookup21.C b/gcc/testsuite/g++.old-deja/g++.other/lookup21.C new file mode 100644 index 000000000..3a7795de1 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/lookup21.C @@ -0,0 +1,17 @@ +// { dg-do run } +// Check that we don't complain about ambiguity between the same static +// member function in different subobjects. + +struct A { + static void f() {} +}; + +struct B: public A { }; +struct C: public A { }; +struct D: public B, public C { }; + +int main() +{ + D d; + d.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 000000000..5246fab34 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/lookup22.C @@ -0,0 +1,13 @@ +// { dg-do assemble } +// Origin: GerhardTonn@gmx.de + +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 000000000..64cb9de49 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/lookup23.C @@ -0,0 +1,13 @@ +// { dg-do assemble } +// Test for proper handling of type lookup if base class has field with the +// same name as the containing class. + +struct a { int a; }; +struct b : a {}; + +b x; + +void foo () +{ + x.a = 22; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/lookup3.C b/gcc/testsuite/g++.old-deja/g++.other/lookup3.C new file mode 100644 index 000000000..a2946b7b0 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/lookup3.C @@ -0,0 +1,18 @@ +// { dg-do run } +// Test to make sure that the use of __typeof__ in WIFEXITED works. + +int main () +{ + int stat_loc = 0; + (__extension__ + ({ + union + { + __typeof__ (stat_loc) __in; + int __i; + } __u; + __u.__in = (stat_loc); + __u.__i; + }) + ); +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/lookup4.C b/gcc/testsuite/g++.old-deja/g++.other/lookup4.C new file mode 100644 index 000000000..8fa296892 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/lookup4.C @@ -0,0 +1,22 @@ +// { dg-do run } +// Test for proper handling of references to overloaded member functions. + +struct A { + static void f (int) { } + void f (); +}; + +void (*p)(int) = &A::f; + +void A::f () +{ + p = f; +} + +int main() +{ + A a; + p = &a.f; + (a.f)(); + (a.f)(42); +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/lookup5.C b/gcc/testsuite/g++.old-deja/g++.other/lookup5.C new file mode 100644 index 000000000..65c6402f1 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/lookup5.C @@ -0,0 +1,10 @@ +// { dg-do assemble } +// Simplified from bug report by Paris Smaragdis <paris@media.mit.edu> + + +template <class T> class vector {}; +class foo {}; +int main() { + foo f; + f.vector(); // { dg-error "" } not a method +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/lookup6.C b/gcc/testsuite/g++.old-deja/g++.other/lookup6.C new file mode 100644 index 000000000..a66302b62 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/lookup6.C @@ -0,0 +1,26 @@ +// { dg-do run } +int f(int i) +{ + struct C { + int i; + C () : i(1) {} + int f() { + struct D { + int i; + D () : i(2) {} + int g() { return i; } + } d; + + return d.g(); + } + } c; + + return c.f(); +} + + +int main() +{ + if (f(0) != 2) + return 1; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/lookup7.C b/gcc/testsuite/g++.old-deja/g++.other/lookup7.C new file mode 100644 index 000000000..53c4a3b3b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/lookup7.C @@ -0,0 +1,13 @@ +// { dg-do run } +// Test for handling of type shadowing in function scope. + +int main() +{ + int A = 42; + struct A + { + enum { a }; + }; + A = A::a; + return A; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/lookup8.C b/gcc/testsuite/g++.old-deja/g++.other/lookup8.C new file mode 100644 index 000000000..61c3dd383 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/lookup8.C @@ -0,0 +1,14 @@ +// { dg-do assemble } + +struct S { + int A; + struct A { + enum { a = 0 }; + }; + + void f(); +}; + +void S::f() { + A = A::a; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/lookup9.C b/gcc/testsuite/g++.old-deja/g++.other/lookup9.C new file mode 100644 index 000000000..688b379ca --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/lookup9.C @@ -0,0 +1,9 @@ +// { dg-do assemble } + +struct S { + typedef long I; +}; + +struct D : virtual public S { + I i; +}; diff --git a/gcc/testsuite/g++.old-deja/g++.other/loop1.C b/gcc/testsuite/g++.old-deja/g++.other/loop1.C new file mode 100644 index 000000000..168734c54 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/loop1.C @@ -0,0 +1,31 @@ +// { dg-do run } +// { dg-options "-O2" } +// Test for bad loop optimization of goto fixups. + +typedef bool (*ftype) (); + +int c, d; +struct A { + A() { ++c; } + A(const A&) { ++c; } + ~A() { ++d; } +}; + +void f (ftype func) +{ + A a; + do { + if ((*func)()) return; + } while (true); +} + +bool test () +{ + return true; +} + +main () +{ + f (test); + return (c != d); +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/loop2.C b/gcc/testsuite/g++.old-deja/g++.other/loop2.C new file mode 100644 index 000000000..a9aa4a368 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/loop2.C @@ -0,0 +1,31 @@ +// { dg-do assemble } +// { dg-options "-O" } + +class foo { +public: + operator const char*() const { return a; } + char *a; +}; + +class bar { +public: + ~bar(); + void operator++(int); + bool b() const; +protected: + void* c() const; +}; + +class baz : public bar { +public: + foo const &d() const { return *(foo *)bar::c(); } +}; + +extern int tst (const char *, const char *) throw(); + +void die(const foo& x) +{ + for (baz hi; hi.b(); hi++) + if (tst (hi.d(), x) == 0) + return; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/main1.C b/gcc/testsuite/g++.old-deja/g++.other/main1.C new file mode 100644 index 000000000..c5cfe8b9e --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/main1.C @@ -0,0 +1,12 @@ +// { dg-do compile } + +int main() // { dg-error "previous declaration" } +{ + return 0; +} + + +int main(int, const char**) // { dg-error "conflicts" } +{ + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/main2.C b/gcc/testsuite/g++.old-deja/g++.other/main2.C new file mode 100644 index 000000000..26013e4e7 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/main2.C @@ -0,0 +1,4 @@ +// { dg-do assemble } +// Origin: Mark Mitchell <mark@codesourcery.com> + +double main () {} // { dg-error "" } main must return `int' diff --git a/gcc/testsuite/g++.old-deja/g++.other/mangle10.C b/gcc/testsuite/g++.old-deja/g++.other/mangle10.C new file mode 100644 index 000000000..b24fe716e --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/mangle10.C @@ -0,0 +1,26 @@ +// { dg-do assemble } + +template<int T> +struct A { + char *a; + A (const char* x) + { + a = (char*) x; + } +}; + +template<int U, int V, class T> +struct B { + T a[V-U+1]; + friend A<V-U+1> f (B const &x) + { + return A<V-U+1> ((char*) x.a); + } +}; + +const int a = 8; + +typedef B<1,a,int> C; +struct D { + C x; +}; diff --git a/gcc/testsuite/g++.old-deja/g++.other/mangle2.C b/gcc/testsuite/g++.old-deja/g++.other/mangle2.C new file mode 100644 index 000000000..81cf2f3de --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/mangle2.C @@ -0,0 +1,24 @@ +// { dg-do assemble } +// Test for overloaded operators in "C" linkage + +extern "C" { +typedef struct b +{ + int a; +} c; + +extern const c z; + +inline bool operator!=(const c& x, const c& y) +{ + return x.a != y.a; +} +} + +void foo(); + +void bar(c x) +{ + if (x != z) + foo(); +} 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 000000000..3579ed86f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/mangle3.C @@ -0,0 +1,42 @@ +// { dg-do run } +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/mutable1.C b/gcc/testsuite/g++.old-deja/g++.other/mutable1.C new file mode 100644 index 000000000..0b2dd8d8e --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/mutable1.C @@ -0,0 +1,44 @@ +// { dg-do run } +// Copyright (C) 1999 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 14 Jan 1999 <nathan@acm.org> + +// Make sure objects with mutable members are never placed in a read only +// section. + +// All these are POD structs, and hence do not need ctors +struct A { mutable int i; }; +struct B { A a; }; +struct C { A a[1]; }; +struct D { static A const a; }; + +// all these are static consts and hence naively suitable for a read only +// section. But they contain a mutable, so must be in a writable section. +static int const i = 0; +static A const a = {0}; +static B const b = {{0}}; +static C const c = {{{0}}}; +static A const aa[] = {{0}}; +static B const bb[] = {{{0}}}; +static C const cc[] = {{{{0}}}}; +A const D::a = {0}; + +int main() +{ + a.i = 05; + b.a.i = 05; + c.a[0].i = 05; + aa[0].i = 05; + bb[0].a.i = 05; + cc[0].a[0].i = 05; + D::a.i = 05; + + if(!a.i) return 1; + if(!b.a.i) return 1; + if(!c.a[0].i) return 1; + if(!aa[0].i) return 1; + if(!bb[0].a.i) return 1; + if(!cc[0].a[0].i) return 1; + if(!D::a.i) return 1; + + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/nested1.C b/gcc/testsuite/g++.old-deja/g++.other/nested1.C new file mode 100644 index 000000000..957ad456f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/nested1.C @@ -0,0 +1,19 @@ +// { dg-do assemble } + +struct C +{ + struct D + { + }; +}; + +struct E +{ + C& c; + void g(); +}; + +void E::g() +{ + c.D().f(); // { dg-error "" } no matching function +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/nested2.C b/gcc/testsuite/g++.old-deja/g++.other/nested2.C new file mode 100644 index 000000000..9e2225642 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/nested2.C @@ -0,0 +1,12 @@ +// { dg-do assemble } +// by Bert Bril <bert@dgb.nl> + +struct M1 { + struct I {}; +}; + +struct M2 { + struct I {}; + struct J : virtual public M2::I, + virtual public M1::I {}; +}; diff --git a/gcc/testsuite/g++.old-deja/g++.other/nested3.C b/gcc/testsuite/g++.old-deja/g++.other/nested3.C new file mode 100644 index 000000000..6e43ad350 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/nested3.C @@ -0,0 +1,12 @@ +// { dg-do assemble } +// Origin: Chip Salzenberg <chip@perlsupport.com> + +class Foo { + public: + class Bar; +}; + +class Foo::Bar { + public: + Bar() {} +}; diff --git a/gcc/testsuite/g++.old-deja/g++.other/nested4.C b/gcc/testsuite/g++.old-deja/g++.other/nested4.C new file mode 100644 index 000000000..673fa3cb9 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/nested4.C @@ -0,0 +1,33 @@ +// { dg-do assemble } +// +// Copyright (C) 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 10 Aug 2000 <nathan@codesourcery.com> + +// bug 372 We ICE'd on the out-of-class definition of a nested class of a +// class template. + +struct Bar +{ +}; + +template <class T> +struct Foo +{ + struct Baz; + struct Biz; + struct Boz + : Bar + { + }; +}; + +template <class T> +struct Foo<T>::Biz +{ +}; + +template <class T> +struct Foo<T>::Baz +: Bar +{ +}; diff --git a/gcc/testsuite/g++.old-deja/g++.other/new.C b/gcc/testsuite/g++.old-deja/g++.other/new.C new file mode 100644 index 000000000..3c3494ef7 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/new.C @@ -0,0 +1,60 @@ +// { dg-do assemble } + +#include <new> + +inline void * +operator new(std::size_t alloc_sz, const char *fname, unsigned lineno) +{ + return ::operator new (alloc_sz); +} +inline void * +operator new[](std::size_t alloc_sz, const char *fname, unsigned lineno) +{ + return ::operator new[] (alloc_sz); +} +inline void +operator delete(void *ptr, const char *fname, unsigned lineno) +{ +} +inline void +operator delete[](void *ptr, const char *fname, unsigned lineno) +{ +} + +class DEF { +public: + DEF( DEF *parent=0, const char *name=0 ); +}; + +class ABC +{ +public: + enum stuff { ID0, ID1 }; + ABC( stuff, DEF *parent=0, const char *name=0 ); +}; + +class GHI : public DEF +{ +}; + +class LMNFrame; +class LMN : public DEF +{ + friend class LMNFrame; + public: +public: + LMN(); +private: + LMNFrame *draw_area; + + ABC *scroll_h; +}; +class LMNFrame : public GHI { +}; +LMN::LMN() +{ + draw_area = new ("abc", 69) LMNFrame; + + scroll_h = new ("def", 71) ABC(ABC::ID0, this); +} + diff --git a/gcc/testsuite/g++.old-deja/g++.other/new3.C b/gcc/testsuite/g++.old-deja/g++.other/new3.C new file mode 100644 index 000000000..843756841 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/new3.C @@ -0,0 +1,27 @@ +// { dg-do run } +typedef __SIZE_TYPE__ size_t; + +template <class T> +struct A +{ + int size; + A () + { + size = 20; + T *p; + p = new T[size]; + int foo; + foo = 5 * size; + } +}; + +struct B +{ + virtual ~B() { } + void operator delete [] (void *ptr, size_t size) { } +}; + +int main () +{ + A<B> *p = new A<B>; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/new4.C b/gcc/testsuite/g++.old-deja/g++.other/new4.C new file mode 100644 index 000000000..7b136dbf3 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/new4.C @@ -0,0 +1,11 @@ +// { dg-do assemble } +// Origin: Mark Mitchell <mark@codesourcery.com> + +struct S { + S(); + + virtual int f() { + new S[+f()]; + return 0; + } +}; diff --git a/gcc/testsuite/g++.old-deja/g++.other/new5.C b/gcc/testsuite/g++.old-deja/g++.other/new5.C new file mode 100644 index 000000000..fbb91e87f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/new5.C @@ -0,0 +1,13 @@ +// { dg-do run } +// Test that const-correctness is observed when using new. + +struct A { + A() { } + int f () { return 1; } + int f () const { return 0; } +}; + +int main () +{ + return (new const A)->f (); +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/new6.C b/gcc/testsuite/g++.old-deja/g++.other/new6.C new file mode 100644 index 000000000..3afb2b7e4 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/new6.C @@ -0,0 +1,24 @@ +// { dg-do run } +// Test that we properly default-initialize the new int when () is given. + +#include <new> +using namespace std; +extern "C" void *malloc (size_t); + +int special; +int space = 0xdeadbeef; + +void *operator new (size_t size) throw (bad_alloc) +{ + if (special) + return &space; + return malloc (size); +} + +int main () +{ + special = 1; + int *p = new int(); + special = 0; + return *p != 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 000000000..0c0643e62 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/new7.C @@ -0,0 +1,40 @@ +// { dg-do run } +// 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/null2.C b/gcc/testsuite/g++.old-deja/g++.other/null2.C new file mode 100644 index 000000000..3c8c50a20 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/null2.C @@ -0,0 +1,13 @@ +// { dg-do run } +// Based on a testcase by Eric Dumazet <Eric.Dumazet@COSMOSBAY.COM> + +extern "C" void abort (); + +const char * const foo = ""; // foo is not NULL + +int main() { + if ((foo == 0) ? 0 : foo) // so this should evaluate to `foo' + return 0; + else + abort(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/null3.C b/gcc/testsuite/g++.old-deja/g++.other/null3.C new file mode 100644 index 000000000..6228caabd --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/null3.C @@ -0,0 +1,6 @@ +// { dg-do assemble } + +void x() +{ + int* p = 1==0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/op1.C b/gcc/testsuite/g++.old-deja/g++.other/op1.C new file mode 100644 index 000000000..61af8e17f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/op1.C @@ -0,0 +1,6 @@ +// { dg-do assemble } +// Origin: Mark Mitchell <mark@codesourcery.com> + +struct S { + bool operator! (int, ...); // { dg-error "" } +}; diff --git a/gcc/testsuite/g++.old-deja/g++.other/op2.C b/gcc/testsuite/g++.old-deja/g++.other/op2.C new file mode 100644 index 000000000..52f390281 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/op2.C @@ -0,0 +1,64 @@ +// { dg-do run } +// 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 +// operator. + +#include <stdio.h> + +int value = 0; + +struct A +{ + A() {} + + A( A& arg) + { printf ("%s\n", __PRETTY_FUNCTION__); value = 1;} + + A( const A& arg) + { printf ("%s\n", __PRETTY_FUNCTION__); value = 2;} + + A& operator=( A& ) + { printf ("%s\n", __PRETTY_FUNCTION__); value = 3; return *this; } + + A& operator=( const A& ) + { printf ("%s\n", __PRETTY_FUNCTION__); value = 4; return *this; } +}; + +struct B : A +{ + B () {} +}; + +void foo( A& ) +{ + printf ("%s\n", __PRETTY_FUNCTION__); value = 5; +} + +void foo( const A& ) +{ + printf ("%s\n", __PRETTY_FUNCTION__); value = 6; +} + + +int main() +{ + const A a0; + 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; + 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; + + 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; + + 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 new file mode 100644 index 000000000..33f0af6df --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/op3.C @@ -0,0 +1,64 @@ +// { dg-do run } +// 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 +// source type in copy ctor and assignment op. + +#include <stdio.h> + +int value = 0; + +struct A +{ + A() {} + + A( A& arg) + { printf ("%s\n", __PRETTY_FUNCTION__); value = 1;} + + A( const A& arg) + { printf ("%s\n", __PRETTY_FUNCTION__); value = 2;} + + A& operator=( A& ) + { printf ("%s\n", __PRETTY_FUNCTION__); value = 3; return *this; } + + A& operator=( const A& ) + { printf ("%s\n", __PRETTY_FUNCTION__); value = 4; return *this; } +}; + +struct B +{ + A a; + B () {} +}; + +void foo( A& ) +{ + printf ("%s\n", __PRETTY_FUNCTION__); value = 5; +} + +void foo( const A& ) +{ + printf ("%s\n", __PRETTY_FUNCTION__); value = 6; +} + +int main() +{ + const A a0; + 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; + 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; + + 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; + + 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 000000000..b4707c5af --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/optimize1.C @@ -0,0 +1,71 @@ +// { dg-do run } +// { dg-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 000000000..b34eae05e --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/optimize2.C @@ -0,0 +1,75 @@ +// { dg-do run } +// { dg-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 000000000..3ec438494 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/optimize3.C @@ -0,0 +1,39 @@ +// { dg-do run } +// { dg-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 000000000..f1345e671 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/optimize4.C @@ -0,0 +1,31 @@ +// { dg-do assemble } +// +// 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/overcnv1.C b/gcc/testsuite/g++.old-deja/g++.other/overcnv1.C new file mode 100644 index 000000000..a161e9af1 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/overcnv1.C @@ -0,0 +1,15 @@ +// { dg-do assemble } + +class A { +public: + void f(const char * const * ); +}; +void f(const char * const *) {} + +void g() +{ + char *ar[10]; + A a; + f(ar); + a.f(ar); +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/overcnv2.C b/gcc/testsuite/g++.old-deja/g++.other/overcnv2.C new file mode 100644 index 000000000..9a5c4ca95 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/overcnv2.C @@ -0,0 +1,27 @@ +// { dg-do assemble } +// { dg-options "-Wconversion" } +// Test that we resolve this case as mandated by the standard, but also +// warn about it. We choose op char* not because it is a member of B -- +// the standard says that all conversion ops are treated as coming from +// the type of the argument -- but because it is non-const. + +struct A { + operator const char *() const { return ""; } +}; + +struct B : public A { + operator char *() { return 0; } +}; + +int main() +{ + B b; + if ((const char *)b != 0) // { dg-warning "choosing 'B" "B" } surprising overload resolution + // { dg-warning "for conversion" "conv" { target *-*-* } 19 } + // { dg-message "note" "note" { target *-*-* } 19 } + return 1; + if ((const char *)(const B)b == 0) + return 2; + if ((const char *)(const B &)b == 0) + return 3; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/overload1.C b/gcc/testsuite/g++.old-deja/g++.other/overload1.C new file mode 100644 index 000000000..8a833aa2a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/overload1.C @@ -0,0 +1,12 @@ +// { dg-do run } +struct A { + A operator+ (int) const { return *this; } +}; + +A operator+ (A, float); + +int main () +{ + A a; + a + 1; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/overload10.C b/gcc/testsuite/g++.old-deja/g++.other/overload10.C new file mode 100644 index 000000000..f4652790a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/overload10.C @@ -0,0 +1,11 @@ +// { dg-do assemble } +// Origin: Jason Merrill <jason@cygnus.com> + + const char *pc; + enum A { x } a; + int i; + + int main() + { + return i ? *pc : a; + } diff --git a/gcc/testsuite/g++.old-deja/g++.other/overload11.C b/gcc/testsuite/g++.old-deja/g++.other/overload11.C new file mode 100644 index 000000000..b994b8070 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/overload11.C @@ -0,0 +1,92 @@ +// { dg-do assemble } + +// Copyright (C) 1999 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 5 Sep 1999 <nathan@acm.org> + +// [over.match] 13.3 tells us where overload resolution occurs. +// [over.match.call] 13.3.1.1 says that in +// (...( postfix-expression )...) (expression-list) +// the postfix-expression must be the name of a function (amongst some other +// choices). This means comma and conditional exprs cannot be placed there. +// This clause is the only one I can find which bans +// (cond ? fna : fnb) (arglist) +// which would be a major headache to have to implement. +// [over.over] 13.4 tells us when the use of a function name w/o arguments is +// resolved to the address of a particular function. These are determined by +// the context of the function name, and it does allow more complicated primary +// expressions. + +// Using a naked function name is rather strange, we used to warn about it +// (rather inconsistently), but subsequent changes broke the warning. Make +// sure that doesn't happen again. + + +void ovl (int); // { dg-message "ovl|candidate expects" } candidate +void ovl (float); // { dg-message "ovl|candidate expects" } candidate +void fn (int); +void fna (int); + +int main (int argc, char **argv) +{ + void (*ptr) (int); + void (*vptr) (); + + (ovl) (1); // ok + (&ovl) (1); // { dg-error "" } not suitable for overload resolution + (ovl) (); // { dg-error "" } no matching candidates + // { dg-message "candidate" "candidate note" { target *-*-* } 36 } + (&ovl) (); // { dg-error "" } not suitable for overload resolution + + // 13.3.1.1 indicates that the following are errors -- the primary expression + // is not the name of a function. + (0, ovl) (1); // { dg-error "" } not suitable for overload resolution + (0, &ovl) (1); // { dg-error "" } not suitable for overload resolution + (argc ? ovl : ovl) (1); // { dg-error "" } not suitable for overload resolution + (argc ? &ovl : &ovl) (1); // { dg-error "" } not suitable for overload resolution + + (fn) (1); // ok + (&fn) (1); // ok (no overload resolution) + (0, fn) (1); // ok (no overload resolution) + (0, &fn) (1); // ok (no overload resolution) + (argc ? fna : fn) (1); // ok (no overload resolution) + (argc ? &fna : &fn) (1); // ok (no overload resolution) + + ptr = (ovl); // ok + ptr = (&ovl); // ok + ptr = (0, ovl); // ok { dg-error "no context" } + ptr = (0, &ovl); // ok { dg-error "no context" } + ptr = (argc ? ovl : ovl); // ok { dg-error "no context" } + ptr = (argc ? &ovl : &ovl);// ok { dg-error "no context" } + + vptr = (ovl); // { dg-error "" } no matching candidates + vptr = (&ovl); // { dg-error "" } no matching candidates + vptr = (0, ovl); // { dg-error "" } no matching candidates + vptr = (0, &ovl); // { dg-error "" } no matching candidates + vptr = (argc ? ovl : ovl); // { dg-error "" } no matching candidates + vptr = (argc ? &ovl : &ovl);// { dg-error "" } no matching candidates + + ptr = (fn); + ptr = (&fn); + ptr = (0, fn); + ptr = (0, &fn); + ptr = (argc ? fna : fn); + ptr = (argc ? &fna : &fn); + + f; // { dg-error "" } not a call + ovl; // { dg-error "" } not suitable for overload + &ovl; // { dg-error "" } not suitable for overload + (void)f; // ok + (void)ovl; // { dg-error "" } not suitable for overload + (void)&ovl; // { dg-error "" } not suitable for overload + static_cast<void>(f); // ok + static_cast<void>(ovl); // { dg-error "" } not suitable for overload + static_cast<void>(&ovl); // { dg-error "" } not suitable for overload + ((void)1, f); // { dg-warning "" "" { xfail *-*-* } } not a call + ((void)1, ovl); // { dg-error "" } not suitable for overload + ((void)1, &ovl); // { dg-error "" } not suitable for overload + (void)((void)1, f); // ok + (void)((void)1, ovl); // { dg-error "" } not suitable for overload + (void)((void)1, &ovl); // { dg-error "" } not suitable for overload + + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/overload12.C b/gcc/testsuite/g++.old-deja/g++.other/overload12.C new file mode 100644 index 000000000..2e37f07c9 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/overload12.C @@ -0,0 +1,30 @@ +// { dg-do assemble } +// Origin: Neil Booth <neilb@earthling.net> from bug #27. + +struct A{}; + +struct B:A{}; + +struct C:B{}; + +struct CX +{ + C c; + + operator C&(){return c;} +}; + +// viable functions for call below +void f(A&); +void f(B&); + +int main() +{ + CX cx; + C c; + + f(c); // the standard conversion to B& is better than to A& + + f(cx); // after user defined conversion to C& + // the standard conversion to B& is better than to A& +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/overload13.C b/gcc/testsuite/g++.old-deja/g++.other/overload13.C new file mode 100644 index 000000000..54ab404af --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/overload13.C @@ -0,0 +1,13 @@ +// { dg-do assemble } +// Origin: Nathan Sidwell <nathan@codesourcery.com> + +struct A { + bool operator== (A const &); + operator bool () const; + operator int * () const; +}; + +bool foo (A &a1, A &a2) +{ + return a1 == a2; +} 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 000000000..2a50b1bf5 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/overload14.C @@ -0,0 +1,33 @@ +// { dg-do run } +// { dg-options "-Wconversion" } +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 (); + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/overload2.C b/gcc/testsuite/g++.old-deja/g++.other/overload2.C new file mode 100644 index 000000000..88fe0a218 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/overload2.C @@ -0,0 +1,24 @@ +// { dg-do link } + +template <class T> +class ConstArray { +}; + +template <class T1, class T2> +void operator+(const ConstArray<T1>&, const ConstArray<T2>&) +{ +} + +template <class T1, class T2> +void operator+(const ConstArray<T1>&, T2); + +template <class T1, class T2> +void operator+(T1, const ConstArray<T2>&); + +const ConstArray<int> cai() { return ConstArray<int>(); } +const ConstArray<double> cad() { return ConstArray<double>(); } + +int main() +{ + cai () + cad (); +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/overload3.C b/gcc/testsuite/g++.old-deja/g++.other/overload3.C new file mode 100644 index 000000000..cf5ceeba1 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/overload3.C @@ -0,0 +1,16 @@ +// { dg-do link } + +void f(const int *); +void f(int *) {} + +void f2(const volatile int *); +void f2(volatile int *) {} + +int i; + +int main() +{ + f(&i); + f2(&i); +} + diff --git a/gcc/testsuite/g++.old-deja/g++.other/overload4.C b/gcc/testsuite/g++.old-deja/g++.other/overload4.C new file mode 100644 index 000000000..a81fd2db9 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/overload4.C @@ -0,0 +1,10 @@ +// { dg-do link } + +void f(int* const volatile * const * const*); +void f(int* const * const * const*) {} + +int main() +{ + int*** ip; + f(&ip); +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/overload5.C b/gcc/testsuite/g++.old-deja/g++.other/overload5.C new file mode 100644 index 000000000..929876737 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/overload5.C @@ -0,0 +1,22 @@ +// { dg-do link } + +struct S {}; + +struct T : public S {}; + +struct U : public T {}; + +void f(int T::*) {} +void f(int U::*); + +void g(void (T::*)(int)) {} +void g(void (U::*)(int)); + +int main() +{ + int S::*ip; + void (S::*fp)(int); + + f(ip); + g(fp); +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/overload6.C b/gcc/testsuite/g++.old-deja/g++.other/overload6.C new file mode 100644 index 000000000..fda22838b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/overload6.C @@ -0,0 +1,19 @@ +// { dg-do run } +extern "C" void abort(); + +struct S1 +{ + int f() { return 0; } + int f() const { return 1; } +}; + +struct S2 : public S1 +{ +}; + +int main() +{ + S2 s2; + if (s2.f() != 0) + abort (); +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/overload7.C b/gcc/testsuite/g++.old-deja/g++.other/overload7.C new file mode 100644 index 000000000..c028d5ea1 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/overload7.C @@ -0,0 +1,23 @@ +// { dg-do run } +// Check that object call works when there are multiple conversion ops +// returning the same type. + +typedef int (*pfn)(); + +int zero () { return 0; } +int one () { return 1; } +int two () { return 2; } + +struct A { + A() { } + operator pfn () { return one; } + operator pfn () const { return zero; } + operator pfn () volatile { return two; } +}; + +int +main () +{ + const A a; + return a(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/overload8.C b/gcc/testsuite/g++.old-deja/g++.other/overload8.C new file mode 100644 index 000000000..4615bd848 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/overload8.C @@ -0,0 +1,23 @@ +// { dg-do run } +class a { +public: + int f() { return 0; } + int f() const { return 1; } +}; + +class b : public a { +}; + +int main() +{ + int (b::* ptr1)() = &b::f; + int (b::* ptr2)() const = &b::f; + + b ao; + + if ((ao.*ptr1)() != 0) + return 1; + if ((ao.*ptr2)() != 1) + return 1; +} + diff --git a/gcc/testsuite/g++.old-deja/g++.other/overload9.C b/gcc/testsuite/g++.old-deja/g++.other/overload9.C new file mode 100644 index 000000000..59457e18f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/overload9.C @@ -0,0 +1,32 @@ +// { dg-do run } +struct T { ~T() {} }; + +int g () +{ + foo: + T t; + int f(int); + bar: + T t2; + int f(double); + return f(3); +} + + +int f(int) +{ + return 0; +} + + +int f(double) +{ + return 1; +} + + +int main() +{ + return g(); +} + 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 000000000..62d55a72f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/override1.C @@ -0,0 +1,20 @@ +// { dg-do assemble } +// 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 000000000..01ff84c69 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/override2.C @@ -0,0 +1,10 @@ +// { dg-do assemble } +// 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 {}; // { dg-error "" } no final overrider diff --git a/gcc/testsuite/g++.old-deja/g++.other/parse1.C b/gcc/testsuite/g++.old-deja/g++.other/parse1.C new file mode 100644 index 000000000..8c46f7f0c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/parse1.C @@ -0,0 +1,6 @@ +// { dg-do assemble } +// Test that we save declspecs before a class defn properly. + +static volatile union { + void f() { } +} u; diff --git a/gcc/testsuite/g++.old-deja/g++.other/parse2.C b/gcc/testsuite/g++.old-deja/g++.other/parse2.C new file mode 100644 index 000000000..330b05fb0 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/parse2.C @@ -0,0 +1,11 @@ +// { dg-do assemble } + +// Copyright (C) 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 24 Nov 2000 <nathan@codesourcery.com> + +// Bug 531: We ICEd trying to give a parse error. + +struct X +{ + bool operator (const X &) const; // { dg-error "" } parse error +}; 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 000000000..d75542751 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/perf1.C @@ -0,0 +1,78 @@ +// { dg-do assemble } + +// 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/pmf1.C b/gcc/testsuite/g++.old-deja/g++.other/pmf1.C new file mode 100644 index 000000000..685688e5a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/pmf1.C @@ -0,0 +1,9 @@ +// { dg-do run } +struct foo {}; +typedef long unsigned int & (foo::*pmf)(void); +void fn (...) {} +int main () +{ + pmf y = 0; + fn (y); +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/pmf2.C b/gcc/testsuite/g++.old-deja/g++.other/pmf2.C new file mode 100644 index 000000000..e28a77022 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/pmf2.C @@ -0,0 +1,18 @@ +// { dg-do assemble } + +// submitted by David C Binderman <dcb@pncl.co.uk> + +struct S +{ + void f(); +}; + +void (S ::* pmf) (); + +S * pf; + +void +f() +{ + pmf = & pf->f; // { dg-error "" } not a valid pmf expression +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/pmf3.C b/gcc/testsuite/g++.old-deja/g++.other/pmf3.C new file mode 100644 index 000000000..11e648ed8 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/pmf3.C @@ -0,0 +1,26 @@ +// { dg-do assemble } +// Submitted by Nathan Sidwell <nathan@acm.org> +// Bug: g++ was crashing after giving errors. + +template<class T> + void connect_to_method( // { dg-message "connect_to_method|no known conversion" } + T *receiver, + void (T::*method)()) + {} + +class Gtk_Base +{ +public: + void expose(); + void show(); + void show(int); + Gtk_Base(); +}; + + +Gtk_Base::Gtk_Base() +{ + connect_to_method(this,&show); // { dg-error "no match" } invalid pmf expression + // { dg-message "candidate" "candidate note" { target *-*-* } 23 } + connect_to_method(this,&expose); // { dg-error "pointer to member" } invalid pmf expression +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/pmf4.C b/gcc/testsuite/g++.old-deja/g++.other/pmf4.C new file mode 100644 index 000000000..cefb3616c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/pmf4.C @@ -0,0 +1,39 @@ +// { dg-do run } +// Bug: g++ doesn't compensate for finding a virtual function in a +// non-primary vtable when generating PMFs. +// Submitted by Jason Merrill <jason@cygnus.com> + +struct A { + virtual ~A() {} +}; + +struct B { + virtual void f () = 0; +}; + +struct C : public A, public B { + void f (); +}; + +void (C::* B_f)() = &B::f; // this works +void (C::* C_f)() = &C::f; // this breaks + +C* p; + +void C::f () +{ + p = this; +} + +int main() +{ + C c; + + (c.*B_f)(); + if (p != &c) + return 1; + + (c.*C_f)(); + if (p != &c) + return 1; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/pmf5.C b/gcc/testsuite/g++.old-deja/g++.other/pmf5.C new file mode 100644 index 000000000..73fcedae0 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/pmf5.C @@ -0,0 +1,39 @@ +// { dg-do run } +// Bug: g++ expanded b->member() multiple times, causing the optimizer to +// decide that things weren't related and optimize 'die' into an infinite +// loop. + +struct A { + virtual ~A() { } + void f (bool) { } +}; + +typedef void (A::*pmf_void)(); +typedef void (A::*pmf_bool)(bool); + +struct B { + ~B() {} + pmf_void member() const { return mbr; } + pmf_void mbr; +}; + +A *a; +B *b; + +void die (bool param) { + pmf_bool pmf = (pmf_bool)(b->member()); + (a->*pmf)(param); +} + +int main () +{ + A a2; + B b2; + + b2.mbr = reinterpret_cast<pmf_void>(&A::f); + + a = &a2; + b = &b2; + + die (true); +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/pmf6.C b/gcc/testsuite/g++.old-deja/g++.other/pmf6.C new file mode 100644 index 000000000..4dea63146 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/pmf6.C @@ -0,0 +1,27 @@ +// { dg-do run } +// Test that we only call f once and that pointers to different subobjects +// compare as different. + +struct A { void f() { } }; +struct B: public A { }; +struct C: public A { }; +struct D : public B, public C { }; + +typedef void (B::*bp)(); +typedef void (C::*cp)(); +typedef void (D::*dp)(); + +dp d1; + +int call; + +dp f () { ++call; return d1; } + +int main() +{ + bp b = &A::f; + cp c = &A::f; + d1 = b; + dp d2 = c; + return (f() == d2 || call != 1); +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/pmf7.C b/gcc/testsuite/g++.old-deja/g++.other/pmf7.C new file mode 100644 index 000000000..1968a7997 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/pmf7.C @@ -0,0 +1,16 @@ +// { dg-do assemble } +// Test for proper diagnostics on trying to take the address of a non-static +// member function. + +struct A { + void f (); + void f (int); + void g (); +}; + +int main () +{ + A a; + &a.f; // { dg-error "" } overloaded + &a.g; // { dg-error "" } can't write a pmf like this +} 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 000000000..b70892683 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/pod1.C @@ -0,0 +1,21 @@ +// { dg-do assemble } + +// 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/printf1.C b/gcc/testsuite/g++.old-deja/g++.other/printf1.C new file mode 100644 index 000000000..65fda3fbd --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/printf1.C @@ -0,0 +1,14 @@ +// { dg-do assemble } +// { dg-options "-Wall" } + +struct a +{ + void x(char *f,...) __attribute__((format(printf,2,3))); +}; + +int main() +{ + a A; + A.x("%d"); // { dg-warning "" } too few arguments for format + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/ptrmem1.C b/gcc/testsuite/g++.old-deja/g++.other/ptrmem1.C new file mode 100644 index 000000000..ec73e6221 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/ptrmem1.C @@ -0,0 +1,15 @@ +// { dg-do assemble } + +class x +{ +public: + virtual int is_constant(); +}; + +void foo() +{ + x* y; + if (y->is_constant) // { dg-error "" } assuming & + { + } +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/ptrmem10.C b/gcc/testsuite/g++.old-deja/g++.other/ptrmem10.C new file mode 100644 index 000000000..f6f97d9c0 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/ptrmem10.C @@ -0,0 +1,11 @@ +// { dg-do run } +// Test that we properly convert a constant ptm to bool. + +class A { }; + +int main() +{ + int A::*const p = 0; + if (p) + return 1; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/ptrmem2.C b/gcc/testsuite/g++.old-deja/g++.other/ptrmem2.C new file mode 100644 index 000000000..88c393210 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/ptrmem2.C @@ -0,0 +1,16 @@ +// { dg-do assemble } +class cow { +public: + void moo (char *); +}; + +void f() +{ + cow* c; + + void (cow::*fp0)(char*) = &cow::moo; // OK + void (cow::*fp1)(int) = &cow::moo; // { dg-error "" } conversion + int (cow::*fp2)(char*) = &cow::moo; // { dg-error "" } conversion + int (cow::*fp3)(char*, void*) = fp2; // { dg-error "" } conversion + int (cow::*fp4)(double) = (int (cow::*)(double)) fp2; // OK +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/ptrmem3.C b/gcc/testsuite/g++.old-deja/g++.other/ptrmem3.C new file mode 100644 index 000000000..09ae9db0a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/ptrmem3.C @@ -0,0 +1,7 @@ +// { dg-do assemble } + +class c { + void (c::*x)(); +public: + void f() { this->x(); } // { dg-error "" } pointer-to-member +}; diff --git a/gcc/testsuite/g++.old-deja/g++.other/ptrmem4.C b/gcc/testsuite/g++.old-deja/g++.other/ptrmem4.C new file mode 100644 index 000000000..6df10a99f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/ptrmem4.C @@ -0,0 +1,13 @@ +// { dg-do run } +// Test to make sure g++ can handle target types that aren't identical +// with pointers to members. + +struct A { int i; }; +struct B : public A { }; + +int main () +{ + int A::*p = &A::i; + const int B::*q = &A::i; + return p != q; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/ptrmem5.C b/gcc/testsuite/g++.old-deja/g++.other/ptrmem5.C new file mode 100644 index 000000000..e64f84d26 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/ptrmem5.C @@ -0,0 +1,17 @@ +// { dg-do assemble } +// Bug: g++ doesn't see that A is a vbase of C. +// Submitted by Jason Merrill <jason@cygnus.com> + +struct A { + int i; + void f (); +}; + +struct B: public A { }; +struct C: public virtual B { }; + +void g () +{ + int C::*p = &A::i; // { dg-error "" } conversion from vbase + void (C::*fp)() = &A::f; // { dg-error "" } conversion from vbase +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/ptrmem6.C b/gcc/testsuite/g++.old-deja/g++.other/ptrmem6.C new file mode 100644 index 000000000..7e1a99286 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/ptrmem6.C @@ -0,0 +1,15 @@ +// { dg-do assemble } + +// Copyright (c) 2000, 2001 Free Software Foundation. +// Distilled from a bug report by Eric Ford <eford@princeton.edu> + +extern double *y; +extern double *x; +extern int nPoints; + +void SetInitCond(void) +{ + int i; + for(i = 2; i < nPoints; ++i) + y[i] = y[nPoints] .* (x[i]-x[1]) / (x[nPoints]-x[1]); // { dg-error "" } .* +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/ptrmem7.C b/gcc/testsuite/g++.old-deja/g++.other/ptrmem7.C new file mode 100644 index 000000000..b04f7e265 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/ptrmem7.C @@ -0,0 +1,47 @@ +// { dg-do assemble } +// +// Copyright (C) 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 14 Aug 2000 <nathan@codesourcery.com> + +// A pointer to member can only be formed by `&T::m', however, other forms +// are ok for pointer to static member. Thus the error can only be determined +// after overload resolution. + +struct A +{ + static int ns (short); + static int ns (float); + int ns (int); + int ns (double); + int single (int); + static int sole (short); + void foo (); +}; +void A::foo () +{ + int (A::*ptr1) (int) = &A::ns; + int (A::*ptr2) (int) = A::ns; // { dg-error "pointer to member" "err" } + // { dg-message "pointer to member" "note" { target *-*-* } 23 } + int (A::*ptr3) (int) = &ns; // { dg-error "pointer to member" "err" } + int (A::*ptr4) (int) = ns; // { dg-error "pointer to member" "err" } + + int (*ptr5) (short) = &A::ns; + int (*ptr6) (short) = A::ns; + int (*ptr7) (short) = &ns; + int (*ptr8) (short) = ns; + + int (A::*ptr11) (int) = &A::single; + int (A::*ptr12) (int) = A::single; // { dg-error "match" } + int (A::*ptr13) (int) = &single; // { dg-error "pointer to member" } + int (A::*ptr14) (int) = single; // { dg-error "match" } + + int (A::*ptr20) (int) = &(A::ns); // { dg-error "pointer to member" } + int (A::*ptr21) (int) = &(A::single); // { dg-error "pointer to member" } + + int (*ptr31) (short) = &A::sole; + int (*ptr32) (short) = A::sole; + int (*ptr33) (short) = &sole; + int (*ptr34) (short) = sole; + int (*ptr41) (short) = &(A::sole); + int (*ptr43) (short) = &(sole); +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/ptrmem8.C b/gcc/testsuite/g++.old-deja/g++.other/ptrmem8.C new file mode 100644 index 000000000..aff6ffac0 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/ptrmem8.C @@ -0,0 +1,75 @@ +// { dg-do assemble } +// Copyright (C) 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 22 Nov 2000 <nathan@codesourcery.com> + +// bug 827. We died issuing warnings about dangerous pointer to member +// conversions. + +struct bar +{ + int barm; + static void a(); +}; +struct filler1 {int fm;}; +struct filler2 {int fm;}; +struct filler3 {int fm;}; +struct filler4 {int fm;}; + +struct baz : filler1, bar, filler2 +{ + int bazm; +}; + +struct foo : filler3, virtual baz, filler4 +{ + static void a(); + void b() {} + int m; +}; + +typedef void (bar::*barfPtr)(); +typedef void (foo::*foofPtr)(); +typedef int bar::*barmPtr; +typedef int foo::*foomPtr; + +int main () +{ + foofPtr fp = &foo::b; + barfPtr bp = (barfPtr)fp; // { dg-error "pointer to member" } + foofPtr fp2 = (foofPtr)bp; // { dg-error "pointer to member" } + + if (fp2 != fp) + return 1; + + foo fobj; + fobj.filler1::fm = 1; + fobj.filler2::fm = 2; + fobj.filler3::fm = 3; + fobj.filler4::fm = 4; + fobj.bazm = 5; + fobj.barm = 6; + fobj.m = 78; + + foomPtr fmp = &foo::m; + barmPtr bmp = (barmPtr)fmp; // { dg-error "pointer to member" } + foomPtr fmp2 = (foomPtr)bmp; // { dg-error "pointer to member" } + bar *bptr = &fobj; + + if (fmp != fmp2) + return 2; + + if (bptr->*bmp != 78) + return 3; + + bp = reinterpret_cast <barfPtr> (fp); + fp2 = reinterpret_cast <foofPtr> (bp); + if (fp2 != fp) + return 4; + + bmp = reinterpret_cast <barmPtr> (fmp); + fmp2 = reinterpret_cast <foomPtr> (bmp); + if (fmp != fmp2) + return 5; + + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/ptrmem9.C b/gcc/testsuite/g++.old-deja/g++.other/ptrmem9.C new file mode 100644 index 000000000..67d4f280e --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/ptrmem9.C @@ -0,0 +1,19 @@ +// { dg-do run } +// Test that const-correctness is observed when using pointers-to-members. + +struct A { + int f () { return 1; } + int f () const { return 0; } +}; + +struct B { + A a; + B() { } +}; + +int main () +{ + A B::*bm = &B::a; + const B b; + return (b.*bm).f (); +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/qual1.C b/gcc/testsuite/g++.old-deja/g++.other/qual1.C new file mode 100644 index 000000000..b6eba42dd --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/qual1.C @@ -0,0 +1,21 @@ +// { dg-do assemble } +// { dg-options "-O" } +// Origin: Benjamin Pflugmann <philemon@spin.de> + +// DR 295 allows qualification via typedef + +typedef const char *(func_type)(); + +class C +{ +public: + func_type *Function; + // The following is DR 295 dependent + const func_type* function(void) { return Function; } + volatile func_type* functionv(void); +} action; + +void work(const char *source) +{ + work( action.function()() ); +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/realloc.C b/gcc/testsuite/g++.old-deja/g++.other/realloc.C new file mode 100644 index 000000000..3e50aa804 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/realloc.C @@ -0,0 +1,14 @@ +// { dg-do assemble } + +extern "C" void realloc(); + +class bug { +public: + void realloc(int foo,int bar); +}; + +void f() { + bug c; + c.realloc(50,50); +} + diff --git a/gcc/testsuite/g++.old-deja/g++.other/redecl1.C b/gcc/testsuite/g++.old-deja/g++.other/redecl1.C new file mode 100644 index 000000000..bd6382ee0 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/redecl1.C @@ -0,0 +1,6 @@ +// { dg-do assemble } +struct X{ + void i(); + void i(int); // { dg-error "" } + int i; // { dg-error "" } conflict +}; diff --git a/gcc/testsuite/g++.old-deja/g++.other/redecl2.C b/gcc/testsuite/g++.old-deja/g++.other/redecl2.C new file mode 100644 index 000000000..0d6ccf669 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/redecl2.C @@ -0,0 +1,9 @@ +// { dg-do assemble } + +struct S { + S(int); // { dg-error "with" } + S(int); // { dg-error "overloaded" } already declared + + ~S();// { dg-error "with" } + ~S(); // { dg-error "overloaded" } already declared +}; diff --git a/gcc/testsuite/g++.old-deja/g++.other/redecl3.C b/gcc/testsuite/g++.old-deja/g++.other/redecl3.C new file mode 100644 index 000000000..96940d545 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/redecl3.C @@ -0,0 +1,8 @@ +// { dg-do assemble } +// Bug: g++ thought this was a redeclaration of a local variable. + +int i; +int main () +{ + extern int i; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/redecl4.C b/gcc/testsuite/g++.old-deja/g++.other/redecl4.C new file mode 100644 index 000000000..e3355dafc --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/redecl4.C @@ -0,0 +1,7 @@ +// { dg-do assemble } +int main() { + struct A { + void f(); // { dg-error "with" } already declared + void f(); // { dg-error "overloaded" } already declared + }; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/ref1.C b/gcc/testsuite/g++.old-deja/g++.other/ref1.C new file mode 100644 index 000000000..df4ff470d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/ref1.C @@ -0,0 +1,10 @@ +// { dg-do assemble } + +int f(); + +void g() +{ + const int& i = f(); // OK + int& j = f(); // { dg-error "" } initialization of non-const reference + const volatile int& k = f(); // { dg-error "" } initialization of volatile ref +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/ref2.C b/gcc/testsuite/g++.old-deja/g++.other/ref2.C new file mode 100644 index 000000000..45c0b764d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/ref2.C @@ -0,0 +1,15 @@ +// { dg-do assemble } +// Origin: Jason Merrill <jason@cygnus.com> + + struct A { + int operator * (); + }; + struct B : public A { }; + int operator * (B &); + + int main () + { + B b; + B& br = b; + *br; + } diff --git a/gcc/testsuite/g++.old-deja/g++.other/ref3.C b/gcc/testsuite/g++.old-deja/g++.other/ref3.C new file mode 100644 index 000000000..3a5853c23 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/ref3.C @@ -0,0 +1,31 @@ +// { dg-do run } +// Origin: Mark Mitchell <mark@codesourcery.com> + +struct B1 +{ + int i; +}; + +struct B2 +{ + int j; +}; + +struct D: public B1, B2 +{ +}; + +bool f (B2& b) +{ + return b.j == 7; +} + +int main () +{ + D d; + d.i = 2; + d.j = 7; + if (!f (d)) + return 1; +} + 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 000000000..5eb97b988 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/ref4.C @@ -0,0 +1,28 @@ +// { dg-do assemble } + +// 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/refinit1.C b/gcc/testsuite/g++.old-deja/g++.other/refinit1.C new file mode 100644 index 000000000..e120078e5 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/refinit1.C @@ -0,0 +1,17 @@ +// { dg-do assemble } +// Test that we don't allow multiple user-defined conversions in reference +// initialization. + +struct B { }; + +struct A { + A (const B&); +}; + +struct C { + operator B (); +}; + +C c; + +const A& ref (c); // { dg-error "" } requires two UDCs diff --git a/gcc/testsuite/g++.old-deja/g++.other/refinit2.C b/gcc/testsuite/g++.old-deja/g++.other/refinit2.C new file mode 100644 index 000000000..ab84542d0 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/refinit2.C @@ -0,0 +1,18 @@ +// { dg-do assemble } +// +// Copyright (C) 2000, 2002 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 10 Aug 2000 <nathan@codesourcery.com> + +// bug 381. We gave slightly different diagnostics, when binding an rvalue to +// a non-const reference, depending on the precise type to the rvalue. + +namespace A { +template <class T> void f(T) {} +} +void (* &h)(int) = A::f<int>; // { dg-error "" } rvalue to non-const +void (*const volatile &i)(int) = A::f<int>; // { dg-error "" } rvalue to volatile +void (*const &j)(int) = A::f<int>; + +int &k = 1; // { dg-error "" } rvalue to non-const +int &const volatile l = 1; // { dg-error "" } rvalue to volatile +int const &m = 1; 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 000000000..5b8334733 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/regstack.C @@ -0,0 +1,31 @@ +// { dg-do run { target i?86-*-* x86_64-*-* } } +// { dg-options "-O2" } + +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/reload1.C b/gcc/testsuite/g++.old-deja/g++.other/reload1.C new file mode 100644 index 000000000..635895586 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/reload1.C @@ -0,0 +1,47 @@ +// { dg-do run } +extern "C" void abort (); + +struct A { + unsigned long long u; +} *a; + +struct B { + unsigned long long v; + unsigned long long w () + { + return a->u - v; + } +} b; + +struct C { + static unsigned long long x; + static void y (unsigned long long z); +}; + +unsigned long long C::x = 0; + +int main () +{ + a = new A; + b.v = 333418; + a->u = 1132270; + C::x = 0; + C::y (799016); +} + +void foo (unsigned long long a, unsigned long long b, unsigned long long c) +{ +} + +void C::y (unsigned long long z) +{ + unsigned long long c = b.w () - x; + if (z < b.w ()) + { + if ((long long) c < 0) + { + foo (b.w (), a->u, b.v); + abort (); + } + } +} 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 000000000..61bc3b129 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/return1.C @@ -0,0 +1,18 @@ +// { dg-do assemble } +// Special g++ Option: +// Origin: holmen@mail.nu + +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; // { dg-error "" } +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/rtti1.C b/gcc/testsuite/g++.old-deja/g++.other/rtti1.C new file mode 100644 index 000000000..a49695b5c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/rtti1.C @@ -0,0 +1,122 @@ +// { dg-do run } +// { dg-options "-frtti" } +// test of rtti of non-class types + +#include <typeinfo> + +extern "C" { + int printf(const char *, ...); + void exit(int); +} + +int i; +short s; +char c; +long l; + +unsigned int ui; +unsigned short us; +unsigned char uc; +unsigned long ul; + +float f; +double d; + +int& ri = i; +const volatile int cvi = 10; +volatile const int vci = 20; +const int ci = 100; + +int *pi; +int ai[10]; + +enum color { red, blue, green, yellow}; + +int (*fp)(); +int (*gp)(); +int (*hp)(int); + +class XX { +public: + int xxi; + float xxf; + int xxf1 () { return 0; }; + int xxf2 (int k) { return 0; }; +}; + +class YY { +public: + int yyi; + double yyd; + int yyf1 (float f) { return 0; }; + double yyf2 () {return yyd;}; +}; + +int XX::*ptmd1; +int XX::*ptmd2; +float XX::*ptmd3; +int YY::*ptmd4; + +int (XX::*ptmf1) (); +int (XX::*ptmf2) (); +int (XX::*ptmf3) (int); +int (YY::*ptmf4) (); + +int func1 () +{ return 0;} + +int func2 () +{ return 1;} + +int func3 (int i) +{ return i;} + +short func4 () +{ return 99;} + +void error (int i) +{ + exit(i); +} + +int main () +{ + if (typeid(i) != typeid(int)) error(1); + if (typeid(s) != typeid(short)) error(2); + if (typeid(c) != typeid(char)) error(3); + if (typeid(l) != typeid(long)) error(4); + if (typeid(ui) != typeid(unsigned int)) error(5); + if (typeid(us) != typeid(unsigned short)) error(6); + if (typeid(uc) != typeid(unsigned char)) error(7); + if (typeid(ul) != typeid(unsigned long)) error(8); + if (typeid(f) != typeid(float)) error(9); + if (typeid(d) != typeid(double)) error(10); + + if (typeid(*pi) != typeid(int)) error(51); + if (typeid(pi) == typeid(ai)) error(52); + if (typeid(ri) != typeid(i)) error(53); + if (typeid(cvi) != typeid(vci)) error (54); + if (typeid(vci) != typeid(i)) error(55); + if (typeid(ci) != typeid(cvi)) error (56); + if (typeid(ci) != typeid(const int)) error(57); + + if (typeid(func1) != typeid(func2)) error (81); + if (typeid(func2) == typeid(func3)) error (82); + if (typeid(func1) == typeid(func4)) error (83); + if (typeid(func3) == typeid(func4)) error (84); + + if (typeid(red) != typeid(color)) error (101); + if (typeid(green) != typeid(blue)) error (102); + + if (typeid(fp) != typeid(gp)) error (103); + if (typeid(gp) == typeid(hp)) error (104); + + if (typeid(ptmd1) != typeid(ptmd2)) error (105); + if (typeid(ptmd1) == typeid(ptmd3)) error (106); + if (typeid(ptmd2) == typeid(ptmd4)) error (107); + + if (typeid(ptmf1) != typeid(ptmf2)) error (108); + if (typeid(ptmf2) == typeid(ptmf3)) error (109); + if (typeid(ptmf1) == typeid(ptmf4)) error (110); + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/rtti2.C b/gcc/testsuite/g++.old-deja/g++.other/rtti2.C new file mode 100644 index 000000000..4cc1319c9 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/rtti2.C @@ -0,0 +1,89 @@ +// { dg-do run } +// { dg-options "-frtti" } +// test of rtti of single inheritance and multiple inheritance classes + +#include <typeinfo> + +extern "C" { + int printf(const char *, ...); + void exit(int); +} + +class X { + public: + int xi; +}; + +class Y : public X { + short ys; +}; + +class Z : public Y { + int zi; +}; + +Z z; +Y y; +Y *yp = &z; +X *xp = &z; +Z *zp = &z; + +class A { + public: + int Ai; +}; + +class B { + public: + int Bi; +}; + +class D : public A, public B { + int Di; +}; + +/* +class E : public D, public B { + int Ei; +}; +*/ +class E { + int Ei; +}; + +class F : public E, public D { + int Fi; +}; + +D d; +A *ap = &d; +B *bp = &d; +F f; +A *aap = &f; +D *dp = &f; +B *bbp = dp; + +void *vp = zp; + +void error (int i) +{ + exit(i); +} + +int main () +{ + if (typeid(z) != typeid(Z)) error(1); + if (typeid(*yp) == typeid(Z)) error(2); + if (typeid(*yp) == typeid(*zp)) error(3); + if (typeid(xp) == typeid(yp)) error(4); + + xp = (X *)&y; + if (typeid(*xp) == typeid(*yp)) error(5); + if (typeid(*xp) == typeid(Y)) error(6); + + if (typeid(*ap) == typeid(*bp)) error (31); + if (typeid(*ap) == typeid(D)) error(32); + + if (typeid(*aap) == typeid(*bbp)) error(33); + if (typeid(*dp) == typeid(*aap)) error(34); +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/rtti3.C b/gcc/testsuite/g++.old-deja/g++.other/rtti3.C new file mode 100644 index 000000000..760cc7592 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/rtti3.C @@ -0,0 +1,97 @@ +// { dg-do run } +// { dg-options "-frtti" } +// test of rtti of single inheritance and multiple inheritance with +// virtual functions + +#include <typeinfo> + +extern "C" { + int printf(const char *, ...); + void exit(int); +} + +class X { + public: + int xi; + virtual int f() {return 0;}; +}; + +class Y : public X { + short ys; +}; + +class Z : public Y { + int zi; +}; + +Z z; +Y y; +Y *yp = &z; +X *xp = &z; +Z *zp = &z; + +class A { + public: + int Ai; + virtual int a() {return 0;}; +}; + +class B { + public: + int Bi; + virtual int g() {return 0;}; +}; + +class D : public A, public B { + int Di; +}; + +/* +class E : public D, public B { + int Ei; +}; +*/ +class E { + int Ei; +}; + +class F : public E, public D { + int Fi; +}; + +D d; +A *ap = &d; +B *bp = &d; +D *dp = &d; +F f; +A *aap = &f; +B *bbp = &f; + +void *vp = zp; + +void error (int i) +{ + exit(i); +} + +int main () +{ + if (typeid(z) != typeid(Z)) error(1); + if (typeid(*yp) != typeid(Z)) error(2); + if (typeid(*yp) != typeid(*zp)) error(3); + if (typeid(xp) == typeid(yp)) error(4); + + xp = (X *)&y; + if (typeid(*xp) == typeid(*yp)) error(5); + if (typeid(*xp) != typeid(Y)) error(6); + + if (typeid(*ap) != typeid(*bp)) error (31); + if (typeid(*ap) != typeid(D)) error(32); + vp = dp; + vp = dynamic_cast<void*> ((B *)vp); + if (dp != (D *)vp) error(35); + + dp = (D *)&f; + if (typeid(*aap) != typeid(*bbp)) error(37); + if (typeid(*dp) != typeid(*aap)) error(38); +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/rtti4.C b/gcc/testsuite/g++.old-deja/g++.other/rtti4.C new file mode 100644 index 000000000..b9cb67292 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/rtti4.C @@ -0,0 +1,87 @@ +// { dg-do run } +// { dg-options "-frtti -w" } +// test of rtti of single inheritance and multiple inheritance with +// virtual inheritance + +#include <typeinfo> + +extern "C" { + int printf(const char *, ...); + void exit(int); +} + +class X { + public: + int xi; + virtual int f() {}; +}; + +class Y : public virtual X { + short ys; +}; + +class Z : public virtual Y { + int zi; +}; + +Z z; +Y y; +Y *yp = &z; +X *xp = &z; +Z *zp = &z; + +class A { +public: + int Ai; + virtual int a() {}; +}; + +class B { +public: + int Bi; + virtual int g() {}; +}; + +class D : public virtual A, private B { + int Di; +}; + +class E : public virtual D, public B { + int Ei; +}; + +class F : public E, public virtual D { + int Fi; +}; + +D d; +A *ap = &d; +B *bp = (B *)&d; +F f; +A *aap = &f; +D *dp = &f; +B *bbp = (B *)dp; + +void *vp = zp; + +void error (int i) +{ + exit(i); +} + +int main () +{ + if (typeid(z) != typeid(Z)) error(1); + if (typeid(*yp) != typeid(Z)) error(2); + if (typeid(*yp) != typeid(*zp)) error(3); + if (typeid(xp) == typeid(yp)) error(4); + + xp = (X *)&y; + if (typeid(*xp) == typeid(*yp)) error(5); + if (typeid(*xp) != typeid(Y)) error(6); + + if (typeid(*ap) != typeid(*bp)) error (31); + if (typeid(*ap) != typeid(D)) error(32); + if (typeid(*aap) != typeid(*bbp)) error(33); + if (typeid(*dp) != typeid(*aap)) error(34); +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/rtti5.C b/gcc/testsuite/g++.old-deja/g++.other/rtti5.C new file mode 100644 index 000000000..a8ab88555 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/rtti5.C @@ -0,0 +1,14 @@ +// { dg-do assemble } +// { dg-options "-fno-rtti" } + +// Copyright (C) 1999 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 9 Apr 1999 <nathan@acm.org> +// derrived from bug report from Alexander Zvyagin <zvyagin@mx.ihep.su> + +// check we don't die with disabled rtti + + +int main(void) { + int i; + typeid(i); // { dg-error "" } rtti disabled +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/rttid2.C b/gcc/testsuite/g++.old-deja/g++.other/rttid2.C new file mode 100644 index 000000000..06746506f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/rttid2.C @@ -0,0 +1,101 @@ +// { dg-do run } +// { dg-options "-frtti" } +// test of rtti of single inheritance and multiple inheritance classes +// dynamic casting + +#include <typeinfo> + +extern "C" { + int printf(const char *, ...); + void exit(int); +} + +class X { + public: + int xi; +}; + +class Y : public X { + short ys; +}; + +class Z : public Y { + int zi; +}; + +Z z; +Y y; +Y *yp = &z; +X *xp = &z; +Z *zp = &z; + +class A { + public: + int Ai; +}; + +class B { + public: + int Bi; +}; + +class D : public A, public B { + int Di; +}; + +/* +class E : public D, public B { + int Ei; +}; +*/ +class E { + int Ei; +}; + +class F : public E, public D { + int Fi; +}; + +D d; +A *ap = &d; +B *bp = &d; +F f; +F *fp = &f; +A *aap = &f; +D *dp = &f; +B *bbp = dp; + +void *vp = zp; + +/* +void error (int i) +{ + printf("FAIL\n"); + exit(i); +} +*/ + +void error (int i) +{ + exit(i); +} + +int main () +{ + + vp = (void *)0; + + vp = dynamic_cast<Y *> (&z); + if (vp == 0) error(11); + + vp = dynamic_cast<X *> (yp); + if (vp == 0) error(12); + + vp = dynamic_cast<D *> (dp); + if (vp != (void *)dp) error(21); + + vp = dynamic_cast<B *> (fp); + if (vp != (void *)bbp) error(22); + +} + diff --git a/gcc/testsuite/g++.old-deja/g++.other/rttid3.C b/gcc/testsuite/g++.old-deja/g++.other/rttid3.C new file mode 100644 index 000000000..0e3b97443 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/rttid3.C @@ -0,0 +1,116 @@ +// { dg-do run } +// { dg-options "-frtti" } +// test of rtti of single inheritance and multiple inheritance with +// virtual functions +// dynamic casting + +#include <typeinfo> + +extern "C" { + int printf(const char *, ...); + void exit(int); +} + +class X { + public: + int xi; + virtual int f() {return 0;}; +}; + +class Y : public X { + short ys; +}; + +class Z : public Y { + int zi; +}; + +Z z; +Y y; +Y *yp = &z; +X *xp = &z; +Z *zp = &z; + +class A { + public: + int Ai; + virtual int a() {return 0;}; +}; + +class B { + public: + int Bi; + virtual int g() {return 0;}; +}; + +class D : public A, public B { + int Di; +}; + +/* +class E : public D, public B { + int Ei; +}; +*/ +class E { + int Ei; +}; + +class F : public E, public D { + int Fi; +}; + +D d; +A *ap = &d; +B *bp = &d; +D *dp = &d; +F f; +F *fp = &f; +A *aap = &f; +B *bbp = &f; + +void *vp = zp; + +/* +void error (int i) +{ + printf("FAIL\n"); + exit(i); +} +*/ + +void error (int i) +{ + exit(i); +} + +int main () +{ + vp = (void *)0; + + vp = dynamic_cast<Y *> (&z); + if (vp == 0) error(11); + + vp = dynamic_cast<Z *> (yp); + if (vp == 0) error(11); + + vp = dynamic_cast<X *> (yp); + if (vp == 0) error(12); + + vp = dynamic_cast<D *> (dp); + if (vp != (void *)dp) error(21); + + vp = dynamic_cast<B *> (dp); + if (vp == (void *)dp) error(21); + + vp = dynamic_cast<B *> (fp); + if (vp != (void *)bbp) error(22); + + vp = dynamic_cast<void *> (aap); + if (vp != (void *)fp) error(23); + + vp = dynamic_cast<B *> (aap); + if (vp != (void *)bbp) error(24); + +} + diff --git a/gcc/testsuite/g++.old-deja/g++.other/rttid4.C b/gcc/testsuite/g++.old-deja/g++.other/rttid4.C new file mode 100644 index 000000000..91c426290 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/rttid4.C @@ -0,0 +1,112 @@ +// { dg-do run } +// { dg-options "-w" } +// test of rtti of single inheritance and multiple inheritance with +// virtual inheritance +// dynamic casting + +#include <typeinfo> + +extern "C" { + int printf(const char *, ...); + void exit(int); +} + +class X { + public: + int xi; + virtual int f() {}; +}; + +class Y : public virtual X { + short ys; +}; + +class Z : public virtual Y { + int zi; +}; + +Z z; +Y y; +Y *yp = &z; +X *xp = &z; +Z *zp = &z; + +class A { +public: + int Ai; + virtual int a() {}; +}; + +class B { +public: + int Bi; + virtual int g() {}; +}; + +class D : public virtual A, private B { + int Di; +}; + +class E : public virtual D, public B { + int Ei; +}; + +class F : public E, public virtual D { + int Fi; +}; + +D d; +A *ap = &d; +B *bp = (B *)&d; +F f; +F *fp = &f; +A *aap = &f; +D *dp = &f; +E *ep = &f; +B *bbp = (B *)dp; + +void *vp = zp; + +/* +void error (int i) +{ + printf("FAIL\n"); + exit(i); +} +*/ + +void error (int i) +{ + exit(i); +} + +int main () +{ + vp = (void *)0; + + vp = dynamic_cast<Y *> (&z); + if (vp == 0) error(11); + + vp = dynamic_cast<Z *> (yp); + if (vp == 0) error(11); + + vp = dynamic_cast<X *> (yp); + if (vp == 0) error(12); + + vp = dynamic_cast<D *> (dp); + if (vp != (void *)dp) error(21); + + // Ill-formed: dynamic_cast to private or ambiguous base + // vp = dynamic_cast<B *> (dp); + // if (vp == (void *)dp) error(21); + + // vp = dynamic_cast<B *> (fp); + // if (vp == (void *)bbp) error(22); + + vp = dynamic_cast<void *> (aap); + if (vp != (void *)fp) error(23); + + vp = dynamic_cast<B *> (aap); + if (vp == (void *)bbp) error(24); + +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/sc1.C b/gcc/testsuite/g++.old-deja/g++.other/sc1.C new file mode 100644 index 000000000..054a57a6c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/sc1.C @@ -0,0 +1,10 @@ +// { dg-do assemble } +// Origin: Mark Mitchell <mark@codesourcery.com> + +void f() { + int *i = 0; + const int *c = 0; + + static_cast <const int *>(i); + static_cast <int *>(c); // { dg-error "" } casts away constness +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/scope1.C b/gcc/testsuite/g++.old-deja/g++.other/scope1.C new file mode 100644 index 000000000..0b349f2b2 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/scope1.C @@ -0,0 +1,13 @@ +// { dg-do run } +// Testcase for proper scoping of local externs. + +int x = 1; + +int main() +{ + int x = 2; + { + extern int x; + return (x != 1); + } +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/shadow1.C b/gcc/testsuite/g++.old-deja/g++.other/shadow1.C new file mode 100644 index 000000000..3b67e7775 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/shadow1.C @@ -0,0 +1,12 @@ +// { dg-do assemble } +// Bug: g++ thinks that the i in g() shadows the parm from f() +// Contributed by Jason Merrill <jason@cygnus.com> + +void f (int i) +{ + struct A { + void g () { + int i; + } + }; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/sibcall1.C b/gcc/testsuite/g++.old-deja/g++.other/sibcall1.C new file mode 100644 index 000000000..fa9e37b37 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/sibcall1.C @@ -0,0 +1,14 @@ +// { dg-do run } +// { dg-options "-O2" } + +#include <iostream> + +std::ostream& foo (const char *x, std::ostream &y) +{ + return y << "" << x; +} + +int main () +{ + foo ("", std::cout); +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/sibcall2.C b/gcc/testsuite/g++.old-deja/g++.other/sibcall2.C new file mode 100644 index 000000000..818fa231c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/sibcall2.C @@ -0,0 +1,19 @@ +// { dg-do assemble } +// { dg-options "-O2 -foptimize-sibling-calls -fno-exceptions" } + +struct X +{ + const char *c() const { return b; }; + char *b; +}; +extern "C" int f (const char *); +struct A +{ + X x; + void y(); +}; +void A::y() +{ + const char *const a[] = { x.c() }; + f (a[0]); +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/signed.C b/gcc/testsuite/g++.old-deja/g++.other/signed.C new file mode 100644 index 000000000..2c95f3db4 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/signed.C @@ -0,0 +1,16 @@ +// { dg-do assemble } + +// Copyright (C) 1999 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 24 Mar 1999 <nathan@acm.org> + +// Determine that function style casts are groked + +void fn() +{ + +char(5); + +short(5); + +int(5); + +long(5); + +signed(5); + +unsigned(5); +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/singleton.C b/gcc/testsuite/g++.old-deja/g++.other/singleton.C new file mode 100644 index 000000000..2a27ca3cd --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/singleton.C @@ -0,0 +1,39 @@ +// { dg-do run } +// This tests two things: +// 1. there is an annoying warning. +// singleton.C:26: warning: `class singleton' only defines private constructors and has no friends +// egcs fails to see that there is a public static accessor function. +// 2. the program crashes, because apparently the static variable s in +// singleton::instance() is considered constructed although the ctor +// exited via an exception. (crash changed to nonzero return here) + +class singleton { +public: + static singleton& instance() { + static singleton s; + return s; + } + int check() {return initialized;} + +private: + singleton() : initialized(1) { + if ( counter++ == 0 ) throw "just for the heck of it"; + initialized = 2; + } + singleton( const singleton& rhs ); + void operator=( const singleton& rhs ); + int initialized; + static int counter; +}; + +int singleton::counter; + +int main() +{ + while (1) { + try { + return singleton::instance().check()-2; + } catch (...) { } + } +} + diff --git a/gcc/testsuite/g++.old-deja/g++.other/sizeof1.C b/gcc/testsuite/g++.old-deja/g++.other/sizeof1.C new file mode 100644 index 000000000..b774a04ff --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/sizeof1.C @@ -0,0 +1,12 @@ +// { dg-do assemble } +// Origin: Jason Merrill <jason@cygnus.com> + +struct X { + int f (); + int f (int); +}; + +void f(int i) +{ + i = sizeof(X::f); // { dg-error "" } cannot take sizeof a member function +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/sizeof2.C b/gcc/testsuite/g++.old-deja/g++.other/sizeof2.C new file mode 100644 index 000000000..cb3c9bb72 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/sizeof2.C @@ -0,0 +1,15 @@ +// { dg-do assemble } +// Origin: Mark Mitchell <mark@codesourcery.com> + +struct S +{ + int j; + int i[2]; // { dg-error "" "" { xfail *-*-* } } non-static data member +}; + +void f () +{ + sizeof (S::j); + sizeof (S::i[0]); // { dg-error "" "" { xfail *-*-* } } used here +} + diff --git a/gcc/testsuite/g++.old-deja/g++.other/sizeof3.C b/gcc/testsuite/g++.old-deja/g++.other/sizeof3.C new file mode 100644 index 000000000..bceb7317a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/sizeof3.C @@ -0,0 +1,21 @@ +// { dg-do run } +// Copyright (C) 1999 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 5 Sep 1999 <nathan@acm.org> + +// C++ does not decay lvalues into rvalues until as late as possible. This +// means things like the rhs of a comma operator mustn't decay. This will make +// a difference if it is an array or function. + +extern "C" void abort(); + +int main (int argc, char **argv) +{ + int ary[10]; + int ary1[10]; + + if (sizeof (0,ary) != sizeof (ary)) + abort (); + if (sizeof (argc ? ary : ary1) != sizeof (ary)) + abort (); + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/sizeof4.C b/gcc/testsuite/g++.old-deja/g++.other/sizeof4.C new file mode 100644 index 000000000..325d3d003 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/sizeof4.C @@ -0,0 +1,41 @@ +// { dg-do assemble } + +// Copyright (C) 1999 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 5 Sep 1999 <nathan@acm.org> + +// C++ does not decay lvalues into rvalues until as late as possible. This +// means things like the rhs of a comma operator mustn't decay. This will make +// a difference if it is an array or function. + +struct S; +struct T {int m;}; +extern S s; // an incomplete +extern S arys[20]; // an incomplete array +extern T aryt[]; // an incomplete array; + +void fn () {} + +int main (int argc, char **argv) +{ + sizeof (s); // { dg-error "" } incomplete + sizeof (0, s); // { dg-error "" } incomplete + sizeof (argc ? s : s); // { dg-error "" } incomplete + + sizeof (arys); // { dg-error "" } incomplete + sizeof (0, arys); // { dg-error "" } incomplete + sizeof (argc ? arys : arys); // { dg-error "" } incomplete + + sizeof (aryt); // { dg-error "" } incomplete + sizeof (0, aryt); // { dg-error "" } incomplete + sizeof (argc ? aryt : aryt); // { dg-error "" } incomplete + + sizeof (fn); // { dg-error "" } cannot take size of function + sizeof (0, fn); // { dg-error "" } cannot take size of function + sizeof (argc ? fn : fn); // { dg-error "" } cannot take size of function + + sizeof (&fn); // ok + sizeof (0, &fn); // ok + sizeof (argc ? &fn : &fn); // ok + + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/sizeof5.C b/gcc/testsuite/g++.old-deja/g++.other/sizeof5.C new file mode 100644 index 000000000..ae076205b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/sizeof5.C @@ -0,0 +1,16 @@ +// { dg-do assemble } +// Copyright (C) 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 23 Feb 2000 <nathan@codesourcery.com> +// Derived from a bug report by Marko Maekelae <Marko.Makela@HUT.FI> + + +struct A; +void foo () +{ + sizeof ( void ()); // { dg-error "" } ISO forbids + sizeof ( void (A::*) ()); + sizeof ( void (A::*) () const); + + sizeof (void (*) () const); // { dg-error "" } invalid quals + sizeof ( void () const); // { dg-error "" } ISO forbids, ERROR - invalid quals +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/static1.C b/gcc/testsuite/g++.old-deja/g++.other/static1.C new file mode 100644 index 000000000..2b0425264 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/static1.C @@ -0,0 +1,9 @@ +// { dg-do assemble } +extern "C" void abort(); + +struct S +{ + static const int i = 3; +}; + +const int S::i = 2; // { dg-error "" } duplicate initialization diff --git a/gcc/testsuite/g++.old-deja/g++.other/static10.C b/gcc/testsuite/g++.old-deja/g++.other/static10.C new file mode 100644 index 000000000..16b152453 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/static10.C @@ -0,0 +1,17 @@ +// { dg-do assemble } +// { dg-options "-w" } +// Origin: Ulrich Drepper <drepper@cygnus.com> + +struct st +{ + int a; +}; + +int +foo (int a) +{ + static const st i = { 0 }; + + if (i.a == a) + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/static11.C b/gcc/testsuite/g++.old-deja/g++.other/static11.C new file mode 100644 index 000000000..a3c5bc024 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/static11.C @@ -0,0 +1,15 @@ +// { dg-do assemble } +// Origin: Raja R Harinath <harinath@cs.umn.edu> + +enum ReservedName { + rIGNORE, + rINCLUDE +}; + +void maybeStatusKeyword() +{ + static const ReservedName statusKeywords[] = { rINCLUDE, rIGNORE }; + for (int i = 0; i < 2; i++) { + ReservedName r = statusKeywords[i]; + } +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/static12.C b/gcc/testsuite/g++.old-deja/g++.other/static12.C new file mode 100644 index 000000000..7c3948947 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/static12.C @@ -0,0 +1,8 @@ +// { dg-do assemble } +// Origin: Jason Merrill <jason@redhat.com> + +int main () +{ + static const int n = 10; + static const int *p = &n; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/static13.C b/gcc/testsuite/g++.old-deja/g++.other/static13.C new file mode 100644 index 000000000..fa45e8ae4 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/static13.C @@ -0,0 +1,19 @@ +// { dg-do link } +// Origin: scott snyder <snyder@fnal.gov> + +struct Cleaner +{ + ~Cleaner() {} +}; + +template <class T> +void bar () +{ + static Cleaner cleanup; +} + + +inline +void foo() { bar<int>(); } + +int main () {} diff --git a/gcc/testsuite/g++.old-deja/g++.other/static14.C b/gcc/testsuite/g++.old-deja/g++.other/static14.C new file mode 100644 index 000000000..32f8b3be4 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/static14.C @@ -0,0 +1,19 @@ +// { dg-do link } +// Origin: scott snyder <snyder@fnal.gov> + +struct basic_string +{ + ~basic_string(); +}; + +struct Side +{ + void name() + { + static basic_string sname; + } +}; + +int main () +{ +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/static15.C b/gcc/testsuite/g++.old-deja/g++.other/static15.C new file mode 100644 index 000000000..ecf477f68 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/static15.C @@ -0,0 +1,15 @@ +// { dg-do run } +// Origin: Mark Mitchell <mark@codesourcery.com> +// Special g++ Option: -fdata-sections + +void f() +{ + static int ctors[3] = { 0, 0, 0 }; + + ctors[2] = 7; +} + +int main () +{ + f (); +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/static16.C b/gcc/testsuite/g++.old-deja/g++.other/static16.C new file mode 100644 index 000000000..6425814d0 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/static16.C @@ -0,0 +1,25 @@ +// { dg-do run } +// Test that we properly evaluate the object parameter when accessing static +// members. + +struct A { + static void f () {} + static int i; +}; + +int A::i; + +int c = 0; + +A g () +{ + ++c; + return A(); +} + +int main () +{ + g().f(); + g().i = 42; + return (c != 2); +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/static2.C b/gcc/testsuite/g++.old-deja/g++.other/static2.C new file mode 100644 index 000000000..b68699cf3 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/static2.C @@ -0,0 +1,10 @@ +// { dg-do assemble } +// Based on a test case by Koos Vriezen <koos@polder.ubc.kun.nl> + +struct foo { + static void (*mystatic) (); +}; + +void bar(foo& t) { + t.mystatic (); +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/static20.C b/gcc/testsuite/g++.old-deja/g++.other/static20.C new file mode 100644 index 000000000..17741049d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/static20.C @@ -0,0 +1,13 @@ +// { dg-do link } +struct foo +{ + foo() {} + ~foo() {} + void func() { static foo x; } +}; + +int main() +{ + foo f; + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/static3.C b/gcc/testsuite/g++.old-deja/g++.other/static3.C new file mode 100644 index 000000000..efa094d11 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/static3.C @@ -0,0 +1,14 @@ +// { dg-do assemble } + +class S +{ + ~S(); +public: + friend void f(); +}; + + +S::~S() +{ + static S s; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/static4.C b/gcc/testsuite/g++.old-deja/g++.other/static4.C new file mode 100644 index 000000000..2b7b1faef --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/static4.C @@ -0,0 +1,10 @@ +// { dg-do run } +// { dg-options "-O" } +// Origin: Andrew Pollard <andrew@odie.demon.co.uk> + +struct A { + A(int, int); +}; +A::A(int, int) {} +static A _A(0, 0); +int main() { return(0); } diff --git a/gcc/testsuite/g++.old-deja/g++.other/static5.C b/gcc/testsuite/g++.old-deja/g++.other/static5.C new file mode 100644 index 000000000..b4032bed2 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/static5.C @@ -0,0 +1,16 @@ +// { dg-do assemble } +// Origin: Mark Mitchell <mark@codesourcery.com> + +struct S +{ + ~S(); +}; + +inline void f() +{ + static S s; + atexit (0); // { dg-error "" } implicit declaration +} + + + diff --git a/gcc/testsuite/g++.old-deja/g++.other/static6.C b/gcc/testsuite/g++.old-deja/g++.other/static6.C new file mode 100644 index 000000000..1705c5ced --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/static6.C @@ -0,0 +1,7 @@ +// { dg-do assemble } +// Origin: Jason Merrill <jason@cygnus.com> + +void f (int i) +{ + static int a[] = { i }; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/static7.C b/gcc/testsuite/g++.old-deja/g++.other/static7.C new file mode 100644 index 000000000..548485b82 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/static7.C @@ -0,0 +1,10 @@ +// { dg-do run } +// Origin: Jason Merrill <jason@cygnus.com> + +int j = 42; + +int main () +{ + static int i = j; + return (i != 42); +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/static9.C b/gcc/testsuite/g++.old-deja/g++.other/static9.C new file mode 100644 index 000000000..c37128820 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/static9.C @@ -0,0 +1,17 @@ +// { dg-do assemble } +// Origin: Ulrich Drepper <drepper@cygnus.com> + +struct st +{ + int a, b, c, d; +}; + +void g () +{ + static const st i = { 0,1,2,3 }; +} + +void h () +{ + static const st i = { 0,1,2,3 }; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/std1.C b/gcc/testsuite/g++.old-deja/g++.other/std1.C new file mode 100644 index 000000000..eacf539d4 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/std1.C @@ -0,0 +1,12 @@ +// { dg-do assemble } +// Origin: Mark Mitchell <mark@codesourcery.com> + +extern "C" int memcmp (const void * __s1, + const void * __s2, + __SIZE_TYPE__ __n) throw (); + +namespace std { +void f () { + memcmp (0, 0, 0); +} +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/stmtexpr1.C b/gcc/testsuite/g++.old-deja/g++.other/stmtexpr1.C new file mode 100644 index 000000000..3623865fd --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/stmtexpr1.C @@ -0,0 +1,10 @@ +// { dg-do assemble } +// { dg-options "-O" } +// Origin: Thomas Kunert <kunert@physik.tu-dresden.de> + +#include <ctype.h> + +bool f( char c ) +{ + return tolower( c ); +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/stmtexpr2.C b/gcc/testsuite/g++.old-deja/g++.other/stmtexpr2.C new file mode 100644 index 000000000..cbe6aabfe --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/stmtexpr2.C @@ -0,0 +1,9 @@ +// { dg-do assemble } +// { dg-options "-O2" } +// Origin: Jakub Jelinek <jakub@redhat.com> + +void bar(int); +void foo(int x) +{ + bar(({ int y; y = x; })); +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/store-expr1.C b/gcc/testsuite/g++.old-deja/g++.other/store-expr1.C new file mode 100644 index 000000000..72d30eba2 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/store-expr1.C @@ -0,0 +1,89 @@ +// { dg-do run { target i?86-*-* x86_64-*-* } } +// { dg-require-effective-target ilp32 } +// { dg-require-effective-target fpic } +// { dg-options "-mtune=i686 -O2 -fpic" } +class G {}; + +struct N { + N *a; +}; + +struct V { + typedef N *W; + W *m, *n; + int s() const { return int(n - m); } + const W &operator[](int x) const { return *(m + x); } +}; + +struct H; + +struct J { + N *c; + H *d; + J(N *x, H *y) : c(x), d(y) {} +}; + +struct K { + const N *c; + const H *d; + K(const N *x, const H *y) : c(x), d(y) {} + K(const J &x) : c(x.c), d(x.d) {} +}; + +struct H { + V e; + int f; + + J u() + { + for (int x = 0; x < e.s(); ++x) + if (e[x]) + return J(e[x], this); + return v(); + } + J v() { return J((N*)64, this); } +}; + +struct I { + H d; + J u() { return d.u(); } + J v() { return d.v(); } +}; + +struct bar { + virtual ~bar() {} +}; + +struct E { + K g; + E(K x) : g(x) {} +}; + +struct foo : public bar { + K h; + E i; + foo(const K x, const E &y) : h(x), i(y) {} +}; + +struct A { + I *l; + foo *baz() const; +}; + +foo *A::baz() const +{ + return new foo(l->u(), E(l->v())); +} + +A x; +I i; +foo *f; + +int main () +{ + x.l = &i; + f = x.baz(); + if (f->h.c != f->i.g.c || f->h.d != f->i.g.d) + return 1; + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/store-expr2.C b/gcc/testsuite/g++.old-deja/g++.other/store-expr2.C new file mode 100644 index 000000000..99e0943b3 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/store-expr2.C @@ -0,0 +1,88 @@ +// { dg-do run { target i?86-*-* x86_64-*-*} } +// { dg-require-effective-target ilp32 } +// { dg-options "-mtune=i686 -O2" } +class G {}; + +struct N { + N *a; +}; + +struct V { + typedef N *W; + W *m, *n; + int s() const { return int(n - m); } + const W &operator[](int x) const { return *(m + x); } +}; + +struct H; + +struct J { + N *c; + H *d; + J(N *x, H *y) : c(x), d(y) {} +}; + +struct K { + const N *c; + const H *d; + K(const N *x, const H *y) : c(x), d(y) {} + K(const J &x) : c(x.c), d(x.d) {} +}; + +struct H { + V e; + int f; + + J u() + { + for (int x = 0; x < e.s(); ++x) + if (e[x]) + return J(e[x], this); + return v(); + } + J v() { return J((N*)64, this); } +}; + +struct I { + H d; + J u() { return d.u(); } + J v() { return d.v(); } +}; + +struct bar { + virtual ~bar() {} +}; + +struct E { + K g; + E(K x) : g(x) {} +}; + +struct foo : public bar { + K h; + E i; + foo(const K x, const E &y) : h(x), i(y) {} +}; + +struct A { + I *l; + foo *baz() const; +}; + +foo *A::baz() const +{ + return new foo(l->u(), E(l->v())); +} + +A x; +I i; +foo *f; + +int main () +{ + x.l = &i; + f = x.baz(); + if (f->h.c != f->i.g.c || f->h.d != f->i.g.d) + return 1; + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/string1.C b/gcc/testsuite/g++.old-deja/g++.other/string1.C new file mode 100644 index 000000000..503533a03 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/string1.C @@ -0,0 +1,20 @@ +// { dg-do assemble } +// Origin: mrs@wrs.com (Mike Stump) + +class Wrapper { +public: + static const char msgPtr[]; + static const char *JunkFunc() { + return &msgPtr[0]; + } +}; + +const char Wrapper::msgPtr[] = "Hello world."; + +int main() { + const char *p1 = &Wrapper::msgPtr[0]; + const char *p2 = Wrapper::JunkFunc(); + + if (p1 != p2) + return 1; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/string2.C b/gcc/testsuite/g++.old-deja/g++.other/string2.C new file mode 100644 index 000000000..bf0699a1d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/string2.C @@ -0,0 +1,18 @@ +// { dg-do run } +// Copyright (C) 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 6 Mar 2000 <nathan@codesourcery.com> + +// A char const array should never be confused for a string literal. + +int main () +{ + static const char ary[] = "wibble"; + void const *ptr = 0; + + ptr = ary; + if (ptr == "wibble") + return 1; + if (ptr != ary) + return 1; + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/struct1.C b/gcc/testsuite/g++.old-deja/g++.other/struct1.C new file mode 100644 index 000000000..699d524b9 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/struct1.C @@ -0,0 +1,42 @@ +// { dg-do assemble } + +// Copyright (C) 1999 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 3 Jun 1999 <nathan@acm.org> + +// Duplicate definitions are wrong, we should just cough +// politely, but we used to die horribly. + +class Y // { dg-error "" } previous definition +{ +}; +class Y // { dg-error "" } redefinition +{ +}; + +template<class T> class X // { dg-error "" } previous definition +{ +}; +template<class T> class X // { dg-error "" } redefinition +{ +}; + +template<class T> class X<T *> // { dg-error "" } previous definition +{ +}; +template<class T> class X<T *> // { dg-error "" } redefinition +{ +}; + +template<> class X<int> // { dg-error "" } previous definition +{ +}; +template<> class X<int> // { dg-error "" } redefinition +{ +}; + +template<> class X<int *> // { dg-error "" } previous definition +{ +}; +template<> class X<int *> // { dg-error "" } redefinition +{ +}; diff --git a/gcc/testsuite/g++.old-deja/g++.other/syntax1.C b/gcc/testsuite/g++.old-deja/g++.other/syntax1.C new file mode 100644 index 000000000..f1d3a8654 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/syntax1.C @@ -0,0 +1,17 @@ +// { dg-do assemble } +// { dg-options "-fsyntax-only" } +// Origin: Mark Mitchell <mark@codesourcery.com> + +class AAA{ +public: + virtual void fff(); +}; + +void AAA::fff() {} + +AAA aaa; + +main () +{ + aaa.fff(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/syntax2.C b/gcc/testsuite/g++.old-deja/g++.other/syntax2.C new file mode 100644 index 000000000..159f28f89 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/syntax2.C @@ -0,0 +1,28 @@ +// { dg-do assemble } +// { dg-options "-fsyntax-only" } +// Origin: Mark Mitchell <mark@codesourcery.com> + +struct B +{ + double d; + + virtual void f (); +}; + +struct C: virtual public B +{ + char c; +}; + +struct D: virtual public B +{ + int i; + virtual void f (); +}; + +struct E : public C, public D +{ +}; + +E e; + diff --git a/gcc/testsuite/g++.old-deja/g++.other/syntax3.C b/gcc/testsuite/g++.old-deja/g++.other/syntax3.C new file mode 100644 index 000000000..5ea7d38bf --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/syntax3.C @@ -0,0 +1,21 @@ +// { dg-do assemble } + +// Copyright (C) 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 22 June 2000 <nathan@codesourcery.com> + +// Origin GNATS bug report 262 from Jeremy Sanders <jss@ast.cam.ac.uk> +// and several others. With templates, it's very easy to say something +// erroneous like +// template class X::X<whatever> +// The culprit +// ... class X::X ... +// caused us to ICE as we got confused about pushing and popping scopes. + +class X +{ + public: + X(); +}; + +class X::X () {} // { dg-error "" } parse error +X::X () {} diff --git a/gcc/testsuite/g++.old-deja/g++.other/syntax4.C b/gcc/testsuite/g++.old-deja/g++.other/syntax4.C new file mode 100644 index 000000000..7aed1f5b1 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/syntax4.C @@ -0,0 +1,26 @@ +// { dg-do assemble } + +// Copyright (C) 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 22 June 2000 <nathan@codesourcery.com> + +// Origin GNATS bug report 262 from Jeremy Sanders <jss@ast.cam.ac.uk> +// and several others. With templates, it's very easy to say something +// erroneous like +// template class X::X<whatever> +// The culprit +// ... class X::X ... +// caused us to ICE as we got confused about pushing and popping scopes. + +class X { + X (); +}; + +class Y { + public: + typedef ::X W; // { dg-error "" } previous declaration + class Z; +}; + +class Y::Z {}; +class Y::W () {} // { dg-error "" } parse error +Y::W::X () {} diff --git a/gcc/testsuite/g++.old-deja/g++.other/syshdr1.C b/gcc/testsuite/g++.old-deja/g++.other/syshdr1.C new file mode 100644 index 000000000..89a7fbf73 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/syshdr1.C @@ -0,0 +1,8 @@ +// { dg-do assemble } +// { dg-options "" } +// Origin: Mark Mitchell <mark@codesourcery.com> + +# 1 "foo" 3 +void f () {} +extern "C" void foo(int); +extern "C" void foo(int) throw(); diff --git a/gcc/testsuite/g++.old-deja/g++.other/temporary1.C b/gcc/testsuite/g++.old-deja/g++.other/temporary1.C new file mode 100644 index 000000000..b1c8cd651 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/temporary1.C @@ -0,0 +1,41 @@ +// { dg-do run } +extern "C" int printf (const char *, ...); + +int c, d; +class Foo +{ +public: + Foo() { printf("Foo() 0x%08lx\n", (__SIZE_TYPE__)this); ++c; } + Foo(Foo const &) { printf("Foo(Foo const &) 0x%08lx\n", (__SIZE_TYPE__)this); } + ~Foo() { printf("~Foo() 0x%08lx\n", (__SIZE_TYPE__)this); ++d; } +}; + +// Bar creates constructs a temporary Foo() as a default +class Bar +{ +public: + Bar(Foo const & = Foo()) { printf("Bar(Foo const &) 0x%08lx\n", (__SIZE_TYPE__)this); } +}; + +void fakeRef(Bar *) +{ +} + +int main() +{ + // Create array of Bar. Will use default argument on constructor. + // The old compiler will loop constructing Bar. Each loop will + // construct a temporary Foo() but will not destruct the Foo(). + // The Foo() temporary is destructed only once after the loop + // completes. This could lead to a memory leak if the constructor + // of Foo() allocates memory. + Bar bar[2]; + + fakeRef(bar); + + printf("Done\n"); + + if (c == d && c == 2) + return 0; + return 1; +} 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 000000000..35243f529 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/thunk1.C @@ -0,0 +1,36 @@ +// { dg-do run } +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/type.C b/gcc/testsuite/g++.old-deja/g++.other/type.C new file mode 100644 index 000000000..3c36c47ad --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/type.C @@ -0,0 +1,15 @@ +// { dg-do assemble } + +typedef unsigned short ushort; +class foo { +public: + static ushort a; +}; +extern "C" { +typedef unsigned short ushort; +} +ushort foo::a; +static int baz() +{ + return foo::a; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/typeck1.C b/gcc/testsuite/g++.old-deja/g++.other/typeck1.C new file mode 100644 index 000000000..574fd7e28 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/typeck1.C @@ -0,0 +1,17 @@ +// { dg-do assemble } + +extern int a[][]; // { dg-error "" } invalid multidimensional array +extern int b[7][]; // { dg-error "" } invalid multidimensional array +extern int c[][7]; // OK + +extern int (*i)[]; // { dg-error "" } previous declaration +extern int (*i)[7]; // { dg-error "" } conflicting types for `i' + +extern int m[]; +extern int m[7]; // OK + +void f(int (*j)[3]) +{ + extern int (*k)[]; + f(k); // { dg-error "" } passing wrong type +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/typedef1.C b/gcc/testsuite/g++.old-deja/g++.other/typedef1.C new file mode 100644 index 000000000..38d77e1c6 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/typedef1.C @@ -0,0 +1,13 @@ +// { dg-do assemble } + +typedef const struct { + int x; +} Test; + +static void foo(Test); + +static void foo(Test t) +{ + t.x = 0; // { dg-error "" } assignment of read-only member + return; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/typedef2.C b/gcc/testsuite/g++.old-deja/g++.other/typedef2.C new file mode 100644 index 000000000..8c451304e --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/typedef2.C @@ -0,0 +1,10 @@ +// { dg-do assemble } +struct S{ + + static const int i; + static const int j; +}; + +typedef S T; +const int T::i = 4; +const int T::j = 4; diff --git a/gcc/testsuite/g++.old-deja/g++.other/typedef3.C b/gcc/testsuite/g++.old-deja/g++.other/typedef3.C new file mode 100644 index 000000000..99076b4e6 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/typedef3.C @@ -0,0 +1,14 @@ +// { dg-do assemble } +template<class T> +struct X{ + T v; + X(){} + virtual ~X(){} + virtual inline T f(T x){return x;} +}; + +void f() +{ + typedef int H; + X<H> y; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/typedef4.C b/gcc/testsuite/g++.old-deja/g++.other/typedef4.C new file mode 100644 index 000000000..02aa4a674 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/typedef4.C @@ -0,0 +1,9 @@ +// { dg-do assemble } + +struct A { + void f (); +}; + +typedef A foo; + +void foo::f() { } diff --git a/gcc/testsuite/g++.old-deja/g++.other/typedef5.C b/gcc/testsuite/g++.old-deja/g++.other/typedef5.C new file mode 100644 index 000000000..f9e71479c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/typedef5.C @@ -0,0 +1,16 @@ +// { dg-do assemble } + +// by Alexandre Oliva <oliva@dcc.unicamp.br> + +typedef int t; +typedef t* u; +typedef u v; +typedef v* (*w)(t); +typedef int t; +typedef t* u; +typedef u v; +typedef v* (*w)(t const); // this is ok +typedef v* (*w)(t); // { dg-error "" } covers message `previously declared here' +typedef v* (*const w)(t); // { dg-error "" } invalid redeclaration +typedef v const* (*w)(t); // { dg-error "" } invalid redeclaration +typedef v* const (*w)(t); // { dg-error "" } invalid redeclaration diff --git a/gcc/testsuite/g++.old-deja/g++.other/typedef6.C b/gcc/testsuite/g++.old-deja/g++.other/typedef6.C new file mode 100644 index 000000000..29e9f92f9 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/typedef6.C @@ -0,0 +1,17 @@ +// { dg-do assemble } +// Submitted by Jason Merrill <jason@cygnus.com>. +// Bug: g++ fails to see through the T typedef in the C ctor. + +struct A { + A (int) { } +}; + +typedef A T; + +struct B: public virtual T { + B (): T(1) { } +}; + +struct C: public B { + C (): T(1) { } +}; diff --git a/gcc/testsuite/g++.old-deja/g++.other/typedef7.C b/gcc/testsuite/g++.old-deja/g++.other/typedef7.C new file mode 100644 index 000000000..42cf4f1c5 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/typedef7.C @@ -0,0 +1,20 @@ +// { dg-do assemble } +// Origin: Mark Mitchell <mark@codesourcery.com> + +typedef int I; +typedef int I; + +// DR56 makes clear that duplicate typedefs in class scopes are +// invalid. + +struct A { + typedef int I; // { dg-error "" } + typedef int I; // { dg-error "" } +}; + +template <class T> +struct S { + typedef int I; // { dg-error "" } + typedef int I; // { dg-error "" } +}; + diff --git a/gcc/testsuite/g++.old-deja/g++.other/typedef8.C b/gcc/testsuite/g++.old-deja/g++.other/typedef8.C new file mode 100644 index 000000000..2d3507acc --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/typedef8.C @@ -0,0 +1,26 @@ +// { dg-do assemble } +// +// Copyright (C) 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 17 Aug 2000 <nathan@codesourcery.com> + +// bug 39. We'd generated bogus errors when using a typedef of a nested class. + +struct X1 +{ + typedef struct { + } MyStruct1; + typedef struct M2 { + } MyStruct2; +}; + +X1::MyStruct1 foo() +{ +X1::MyStruct1 m1; +return m1; +} + +X1::MyStruct2 baz() +{ +X1::MyStruct2 m1; +return m1; +} 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 000000000..abe4f9df4 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/typeid1.C @@ -0,0 +1,15 @@ +// { dg-do assemble } +// { dg-options "" } +// Origin: sk@gluit.de + +#include <typeinfo> + +int main () +{ + typeid(char*); + + int len = 1; + char carr[len]; + typeid(typeof(carr)); // { dg-error "" } type has variable size + typeid(carr); // { dg-error "" } type has variable size +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/typeinfo1.C b/gcc/testsuite/g++.old-deja/g++.other/typeinfo1.C new file mode 100644 index 000000000..0674988c5 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/typeinfo1.C @@ -0,0 +1,15 @@ +// { dg-do assemble } + +#include <typeinfo> + +struct S { + S (const char*); +}; + +void f(S s); +void f(std::type_info); + +void g() +{ + f("abc"); +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/typename1.C b/gcc/testsuite/g++.old-deja/g++.other/typename1.C new file mode 100644 index 000000000..4bf3de39f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/typename1.C @@ -0,0 +1,17 @@ +// { dg-do assemble } +// { dg-options "-pedantic -Wno-deprecated" } +// This code snippet should be rejected with -pedantic +// Based on a test case by Louidor Erez <s3824888@techst02.technion.ac.il> + + +template<class T> +class Vector { +public: + typedef T* iterator; +}; + +template<class T> +void f() +{ + Vector<T>::iterator i = 0; // { dg-error "typename" } missing typename +} // { dg-error "expected" "" { target *-*-* } 16 } diff --git a/gcc/testsuite/g++.old-deja/g++.other/typename2.C b/gcc/testsuite/g++.old-deja/g++.other/typename2.C new file mode 100644 index 000000000..7c87c5b09 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/typename2.C @@ -0,0 +1,7 @@ +// { dg-do assemble } + +template<typename T> +void f() +{ + typename T::u; // { dg-error "" } declare anything +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/unchanging1.C b/gcc/testsuite/g++.old-deja/g++.other/unchanging1.C new file mode 100644 index 000000000..6b2999cb9 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/unchanging1.C @@ -0,0 +1,46 @@ +// { dg-do run } +// { dg-options "-O2" } + +#include <iostream> +#include <complex> + +using namespace std; + +class A { +protected: + int a; + complex<double> *b; +public: + A(int n); + inline complex<double>& operator[] (int x); +}; + +A::A(int n) +{ + a = n; + b = new complex<double>[a]; + for (int i=0; i<a; i++) b[i] = complex<double>(0.0,0.0); +} + +inline complex<double>& A::operator[](int x) +{ + if (x < 0 || x >= a) + cout << "x error" << endl; + return b[x]; +} + +void foo () +{ + int n = 5; + A *o = new A(n); + A *p = new A(n); + for (int i = 0; i < n; i++) { + cout << i << endl; + (*o)[i] *= complex<double>((*p)[i].real(), (*p)[i].imag()); + } +} + +int main() +{ + foo(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/union1.C b/gcc/testsuite/g++.old-deja/g++.other/union1.C new file mode 100644 index 000000000..37424a1f4 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/union1.C @@ -0,0 +1,16 @@ +// { dg-do assemble } + +class A +{ + private: + int myInt; + + public: + A& operator = (int right) {myInt = right; return *this;} +}; + +union B +{ + char f1; + A f2; // { dg-bogus "" } non-copy assignment op is OK +}; diff --git a/gcc/testsuite/g++.old-deja/g++.other/union2.C b/gcc/testsuite/g++.old-deja/g++.other/union2.C new file mode 100644 index 000000000..5c2d7dcac --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/union2.C @@ -0,0 +1,39 @@ +// { dg-do run } +// Bug: g++ crashed on empty initializers for unions. +// Bug: gcc and g++ didn't zero unions with empty initializers. +// Submitted by J"orn Rennecke <amylaar@cygnus.co.uk> + +extern "C" void exit (int); + +typedef union u +{ + union u *up; + void *vp; +} u; + +static u v = {}; + +void bar (u); +void baz (u); + +void foo() +{ + u w = {}; + u x = { &v }; + baz (x); + bar (w); +} + +void baz (u w) { } + +void bar (u w) +{ + if (w.up) + exit (1); +} + +int main () +{ + foo (); + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/union3.C b/gcc/testsuite/g++.old-deja/g++.other/union3.C new file mode 100644 index 000000000..67903b761 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/union3.C @@ -0,0 +1,24 @@ +// { dg-do run } +// Origin: Mark Mitchell <mark@codesourcery.com> + +struct A +{ + union + { + int i; + }; + int j; + + A (); +}; + +A::A () + : i (1), j (i = 0) +{ +} + +int main () +{ + A a; + return a.i; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/union4.C b/gcc/testsuite/g++.old-deja/g++.other/union4.C new file mode 100644 index 000000000..26f12e953 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/union4.C @@ -0,0 +1,33 @@ +// { dg-do assemble } +// { dg-options "" } +// Origin: Mark Mitchell <mark@codesourcery.com> + +union A +{ + int i; + int j; + + A () : i (3), j (2) {} // { dg-error "" } multiple initializations +}; + +union B +{ + int i; + union { + int j; + }; + + B () : i (3), j (2) {} // { dg-error "" } multiple initializations +}; + +union C +{ + union { + struct { + int i; + int j; + }; + }; + + C () : i (3), j (2) {} +}; diff --git a/gcc/testsuite/g++.old-deja/g++.other/using1.C b/gcc/testsuite/g++.old-deja/g++.other/using1.C new file mode 100644 index 000000000..d734576ac --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/using1.C @@ -0,0 +1,27 @@ +// { dg-do assemble } +class D2; + +class B { +private: + int a; // { dg-error "" } B::a is private +protected: + int b; + + friend class D2; +}; + +class D : public B { // { dg-error "" } within this context +public: + using B::a; + using B::b; +}; + +class D2 : public B { // { dg-error "" } conflicting access specifications +public: + using B::a; + using B::b; + +private: + using B::b; +}; + diff --git a/gcc/testsuite/g++.old-deja/g++.other/using2.C b/gcc/testsuite/g++.old-deja/g++.other/using2.C new file mode 100644 index 000000000..92c65eb0b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/using2.C @@ -0,0 +1,10 @@ +// { dg-do assemble } +struct X{ + void f(); +}; + +struct Y:X{ + void f(int); + void f(); + using X::f; +}; diff --git a/gcc/testsuite/g++.old-deja/g++.other/using3.C b/gcc/testsuite/g++.old-deja/g++.other/using3.C new file mode 100644 index 000000000..f30ecbc3d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/using3.C @@ -0,0 +1,12 @@ +// { dg-do assemble } +struct A{ + A(); +}; + +typedef struct { + A i; +} S; + +struct B: S{ + using S::S; // { dg-error "" } no such field +}; diff --git a/gcc/testsuite/g++.old-deja/g++.other/using4.C b/gcc/testsuite/g++.old-deja/g++.other/using4.C new file mode 100644 index 000000000..9d6e27e04 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/using4.C @@ -0,0 +1,18 @@ +// { dg-do assemble } + +// Based on a testcase by Martin Bachtold <martinb@coyotesystems.com> + +struct foo { + void m(); +}; + +struct bar : foo { + using foo::m; + void m(int); +}; + +void f() { + bar b; + b.m(); + b.m(1); +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/using5.C b/gcc/testsuite/g++.old-deja/g++.other/using5.C new file mode 100644 index 000000000..672530199 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/using5.C @@ -0,0 +1,15 @@ +// { dg-do assemble } + +// Based on bug report by Klaus-Georg Adams +// <Klaus-Georg.Adams@chemie.uni-karlsruhe.de> + +struct bar { + typedef bar t; +}; + +struct foo : bar { + using bar::t; + t field; + t meth(); + void baz(t arg); +}; diff --git a/gcc/testsuite/g++.old-deja/g++.other/using6.C b/gcc/testsuite/g++.old-deja/g++.other/using6.C new file mode 100644 index 000000000..272c35dff --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/using6.C @@ -0,0 +1,30 @@ +// { dg-do run } +// Test of class-scope using-declaration for functions. + +#define assert(COND) if (!(COND)) return 1 + +struct A { + int f(int) { return 1; } + int f(char) { return 2; } +}; + +struct B { + int f(double) { return 3; } +}; + +struct C : public A, public B { + using A::f; + using B::f; + int f(char) { return 4; } + int f(C) { return 5; } +}; + +int main () +{ + C c; + + assert (c.f(1) == 1); + assert (c.f('a') == 4); + assert (c.f(2.0) == 3); + assert (c.f(c) == 5); +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/using7.C b/gcc/testsuite/g++.old-deja/g++.other/using7.C new file mode 100644 index 000000000..07cf68b0a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/using7.C @@ -0,0 +1,21 @@ +// { dg-do assemble } + +class A { +protected: + static void f() {} +}; + +class B : A { +public: + using A::f; + void g() { + f(); + A::f(); + } + struct C { + void g() { + f(); + A::f(); + } + }; +}; diff --git a/gcc/testsuite/g++.old-deja/g++.other/using8.C b/gcc/testsuite/g++.old-deja/g++.other/using8.C new file mode 100644 index 000000000..2700bb27c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/using8.C @@ -0,0 +1,43 @@ +// { dg-do assemble } + +// Copyright (C) 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 14 Nov 2000 <nathan@codesourcery.com> + +// We rejected using decls bringing in functions from a base which would hide a +// nested class of the same name, but only if we had no functions by that name +// already. Also, we failed to find that using declaration during lookup. Also +// we failed to reject using declarations which matched the constructor name. + +struct A +{ + int f (); + void D (); +}; + +struct A2 { + typedef int f; +}; + +struct B : A +{ + using A::f; + struct f {}; +}; + +struct C : A +{ + using A::f; + int f (int); + struct f {}; +}; + +void foo (B *bp, C* cp) +{ + bp->f (); + cp->f (); +} + +struct D : A +{ + using A::D; // { dg-error "" } names constructor +}; 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 000000000..0e34156d8 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/using9.C @@ -0,0 +1,21 @@ +// { dg-do assemble } +// +// Copyright (C) 2000 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 (); // { dg-error "previous declaration" } + +namespace { + extern "C" int foo (); // { dg-error "C.*linkage" } + using ::foo; // { dg-error "" } already in use +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/vaarg1.C b/gcc/testsuite/g++.old-deja/g++.other/vaarg1.C new file mode 100644 index 000000000..bcc9df389 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/vaarg1.C @@ -0,0 +1,14 @@ +// { dg-do assemble } +// Origin: Mark Mitchell <mark@codesourcery.com> + +#include <stdarg.h> +#include <stdio.h> + +void f (int i, ...) +{ + va_list ap; + + va_start (ap, i); + vprintf ("test", ap); + va_end (ap); +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/vaarg2.C b/gcc/testsuite/g++.old-deja/g++.other/vaarg2.C new file mode 100644 index 000000000..278f5376f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/vaarg2.C @@ -0,0 +1,64 @@ +// { dg-do run } +// { dg-options "-Wno-abi" { target arm_eabi } } +// Copyright (C) 1999, 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 4 Oct 1999 <nathan@acm.org> + +// Make sure we can deal with POD aggregate in va_args + +#include <stdarg.h> +extern "C" void abort (); + +struct X {int m;}; +struct Y {int a; int b; int c; int d; int e; int f;}; + +void fn1(va_list args) +{ + int i = va_arg (args, int); + X x = va_arg (args, X); + Y y = va_arg (args, Y); + if (i != 1) + abort (); + if (x.m != 1) + abort (); + if (y.a != 1 || y.b != 2 || y.c != 3 || y.d != 4 || + y.e != 5 || y.f != 6) + abort (); +} + +void fn2(va_list args) +{ + const int &i = va_arg (args, int); + const X &x = va_arg (args, X); + const Y &y = va_arg (args, Y); + if (i != 1) + abort (); + if (x.m != 1) + abort (); + if (y.a != 1 || y.b != 2 || y.c != 3 || y.d != 4 || + y.e != 5 || y.f != 6) + abort (); +} + +void +dispatch (int t, ...) +{ + va_list args; + + va_start (args, t); + fn1 (args); + va_end (args); + + va_start (args, t); + fn2 (args); + va_end (args); +} + +int main () +{ + X x = {1}; + Y y = {1, 2, 3, 4, 5, 6}; + + dispatch (0, 1, x, y); + + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/vaarg3.C b/gcc/testsuite/g++.old-deja/g++.other/vaarg3.C new file mode 100644 index 000000000..3408a1811 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/vaarg3.C @@ -0,0 +1,32 @@ +// { dg-do assemble } +// { dg-options "-Wno-abi" { target arm_eabi } } + +// Copyright (C) 1999 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 4 Oct 1999 <nathan@acm.org> + +// Make sure we diagnose bad uses of va_arg + +#include <stdarg.h> + +struct X {int m;}; +struct Y { Y(const Y&); }; +struct Z; // { dg-error "forward decl" } +void fn1(va_list args) +{ + int i = va_arg (args, int); + Y x = va_arg (args, Y); // { dg-error "cannot receive" } + Y y = va_arg (args, struct Y); // { dg-error "cannot receive" } + int &r = va_arg (args, int &); // { dg-error "cannot receive" } + + Z z1 = va_arg (args, Z); // { dg-error "incomplete" } + const Z &z2 = va_arg (args, Z); // { dg-error "incomplete" } + + va_arg (args, char); // { dg-warning "promote" } + // { dg-message "should pass" "pass" { target *-*-* } 24 } + // { dg-message "abort" "abort" { target *-*-* } 24 } + va_arg (args, int []); // { dg-error "array with unspecified bounds" } promote + va_arg (args, int ()); // { dg-warning "promoted" } promote + // { dg-message "abort" "abort" { target *-*-* } 28 } + va_arg (args, bool); // { dg-warning "promote" "promote" } + // { dg-message "abort" "abort" { target *-*-* } 30 } +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/vaarg4.C b/gcc/testsuite/g++.old-deja/g++.other/vaarg4.C new file mode 100644 index 000000000..9ea165bda --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/vaarg4.C @@ -0,0 +1,16 @@ +// { dg-do assemble } +// { dg-options "-Wno-abi" { target arm_eabi } } + +// Bug 845. We were treating __builtin_va_arg as a unary expr, not a primary, +// and hence getting parse errors. + +typedef __builtin_va_list __gnuc_va_list; +typedef __gnuc_va_list va_list; + +struct X { int y; }; + +void func(va_list va) +{ + char* a = __builtin_va_arg(va, char**)[0]; + int b = __builtin_va_arg(va, X*)->y; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/vbase1.C b/gcc/testsuite/g++.old-deja/g++.other/vbase1.C new file mode 100644 index 000000000..4392784f9 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/vbase1.C @@ -0,0 +1,52 @@ +// { dg-do run } +// { dg-options "-w" } +// Origin: Mark Mitchell <mark@codesourcery.com> + +int result; + +struct A { + A (); + + int i; +}; + +A* ap; + +A::A () +{ + ap = this; +} + +struct B : virtual public A +{ + B (); + ~B (); + + int j; +}; + +B::B () { + if ((A*) this != ap) + result = 1; +} + +B::~B () { + if ((A*) this != ap) + result = 1; +} + +struct C : public B { +}; + +struct D : public C, public B +{ +}; + +int main () +{ + { + D d; + } + + return result; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/vbase2.C b/gcc/testsuite/g++.old-deja/g++.other/vbase2.C new file mode 100644 index 000000000..812b54764 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/vbase2.C @@ -0,0 +1,37 @@ +// { dg-do run } +// Origin: Mark Mitchell <mark@codesourcery.com> + +int i; + +struct A +{ + ~A (); +}; + +A::~A () { + i = 1; +} + +struct B : virtual public A { +}; + +struct C { + C (); + + B b; +}; + +C::C () { + throw 3; +} + +int main () +{ + try { + C c; + } catch (...) { + } + + if (i != 1) + return 1; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/vbase3.C b/gcc/testsuite/g++.old-deja/g++.other/vbase3.C new file mode 100644 index 000000000..2cdc8050a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/vbase3.C @@ -0,0 +1,21 @@ +// { dg-do assemble } +// Origin: scott snyder <snyder@fnal.gov> + +class d0_Collection_Base {}; + +template <class T> +class d0_List + : virtual public d0_Collection_Base +{ +public: + d0_List (); + + template <class Input_Iterator> + d0_List (Input_Iterator first, Input_Iterator last) + ; +}; + +void tlist () +{ + const d0_List<int> l4 (1, 2); +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/vbase4.C b/gcc/testsuite/g++.old-deja/g++.other/vbase4.C new file mode 100644 index 000000000..178f4b7eb --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/vbase4.C @@ -0,0 +1,27 @@ +// { dg-do assemble } + +// Copyright (C) 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 10 Jan 2001 <nathan@codesourcery.com> +// Origin snyder@fnal.gov + +// Bug 933. Secondary vtables weren't correctly located for non-primary +// virtual bases. Causing us to ICE. + +class d0_Object +{ +public: +virtual ~d0_Object (); +}; + + +class M10 : virtual public d0_Object {}; +class M4 : virtual public M10 {}; + +class M9 +: public M4, virtual public M10 +{ +public: +M9 (); +}; + +M9::M9 () {} diff --git a/gcc/testsuite/g++.old-deja/g++.other/vbase5.C b/gcc/testsuite/g++.old-deja/g++.other/vbase5.C new file mode 100644 index 000000000..10c2f3131 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/vbase5.C @@ -0,0 +1,203 @@ +// { dg-do run } +// Copyright (C) 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 19 Jan 2001 <nathan@codesourcery.com> + +// Bug 1701. building a vbase path was not using the shortest number of +// vbases. Normally that's just a pessimization, unfortunately during +// constructoring it leads to uninitialized reads. + +extern "C" int printf (...); + +int fail = 0; + +/*{{{ struct Base*/ +struct Base +{ + unsigned m; + static Base *addr; + + Base (); + virtual ~Base (); +}; +/*}}}*/ +Base *Base::addr; +/*{{{ Base::Base ()*/ +Base::Base () +{ + printf ("Base (%u) ctor %x\n", sizeof (Base), this); + if (fail) ; + else if (addr) + fail = 1; + else + addr = this; +} +/*}}}*/ +/*{{{ Base::~Base ()*/ +Base::~Base () +{ + printf ("Base dtor %x\n", this); + if (fail) + ; + else if (this != addr) + fail = 2; + else + addr = 0; +} +/*}}}*/ + +/*{{{ struct M10 : virtual Base*/ +struct M10 : virtual Base +{ + int m; + static M10 *addr; + + M10 (); + virtual ~M10 (); +}; +/*}}}*/ +M10 *M10::addr; +/*{{{ M10::M10 ()*/ +M10::M10 () +{ + printf ("M10 (%u) ctor %x\n", sizeof (M10), this); + if (fail) ; + else if (addr) + fail = 3; + else + addr = this; +} +/*}}}*/ +/*{{{ M10::~M10 ()*/ +M10::~M10 () +{ + printf ("M10 dtor %x\n", this); + if (fail) + ; + else if (this != addr) + fail = 4; + else + addr = 0; +} +/*}}}*/ + +/*{{{ struct M4 : virtual Base, virtual M10*/ +struct M4 : virtual Base, virtual M10 +{ + int m; + static M4 *addr; + + M4 (); + virtual ~M4 (); +}; +/*}}}*/ +M4 *M4::addr; +/*{{{ M4::M4 ()*/ +M4::M4 () +{ + printf ("M4 (%u) ctor %x\n", sizeof (M4), this); + if (fail) ; + else if (addr) + fail = 5; + else + addr = this; +} +/*}}}*/ +/*{{{ M4::~M4 ()*/ +M4::~M4 () +{ + printf ("M4 dtor %x\n", this); + if (fail) + ; + else if (this != addr) + fail = 6; + else + addr = 0; +} +/*}}}*/ + +/*{{{ struct M5 : M4*/ +struct M5 : M4 +{ + int m; + static M5 *addr; + + M5 (); + virtual ~M5 (); +}; +/*}}}*/ +M5 *M5::addr; +/*{{{ M5::M5 ()*/ +M5::M5 () +{ + printf ("M5 (%u) ctor %x\n", sizeof (M5), this); + if (fail) ; + else if (addr) + fail = 7; + else + addr = this; +} +/*}}}*/ +/*{{{ M5::~M5 ()*/ +M5::~M5 () +{ + printf ("M5 dtor %x\n", this); + if (fail) + ; + else if (this != addr) + fail = 8; + else + addr = 0; +} +/*}}}*/ + +/*{{{ struct M9 : M5, virtual M10*/ +struct M9 : M5, virtual M10 +{ + int m; + static M9 *addr; + + M9 (); + virtual ~M9 (); +}; +/*}}}*/ +M9 *M9::addr; +/*{{{ M9::M9 ()*/ +M9::M9 () +{ + printf ("M9 (%u), ctor %x\n", sizeof (M9), this); + if (fail) ; + else if (addr) + fail = 9; + else + addr = this; +} +/*}}}*/ +/*{{{ M9::~M9 ()*/ +M9::~M9 () +{ + printf ("M9 dtor %x\n", this); + if (fail) + ; + else if (this != addr) + fail = 10; + else + addr = 0; +} +/*}}}*/ + +int main () +{ + M9 *m9; + Base *r; + + m9 = new M9 (); + r = m9; + if (fail) + return fail; + void *top = dynamic_cast <void *> (r); + if (top != m9) + return 20; + r->~Base (); + + return fail; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/virtual10.C b/gcc/testsuite/g++.old-deja/g++.other/virtual10.C new file mode 100644 index 000000000..ba3dea700 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/virtual10.C @@ -0,0 +1,20 @@ +// { dg-do assemble } + +// Copyright (C) 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 14 Nov 2000 <nathan@codesourcery.com> + +// We failed to spot a static member which overrode a virtual + +struct A +{ + virtual int foo (char); + static int foo (); + virtual int foo (int); // { dg-error "" } this function + static int foo (float); + virtual int foo (double); +}; + +struct B : A +{ + static int foo (int); // { dg-error "" } cannot override +}; diff --git a/gcc/testsuite/g++.old-deja/g++.other/virtual11.C b/gcc/testsuite/g++.old-deja/g++.other/virtual11.C new file mode 100644 index 000000000..8b46dc754 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/virtual11.C @@ -0,0 +1,31 @@ +// { dg-do assemble } + +// Copyright (C) 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 14 Nov 2000 <nathan@codesourcery.com> + +// We failed to check virtual functions hidden by using declarations. + +struct A +{ + virtual int foo (); +}; + +struct B +{ + virtual void foo (); // { dg-error "" } of this function +}; + +struct C : A , B +{ +}; + +struct D : C +{ + void foo (short); + using A::foo; +}; + +struct E : D +{ + virtual int foo (); // { dg-error "" } invalid override +}; diff --git a/gcc/testsuite/g++.old-deja/g++.other/virtual2.C b/gcc/testsuite/g++.old-deja/g++.other/virtual2.C new file mode 100644 index 000000000..c93b89f44 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/virtual2.C @@ -0,0 +1,20 @@ +// { dg-do run } +struct B +{ + virtual int f() volatile + { return 0; } +}; + + +struct D : public B +{ + virtual int f() + { return 1; } +}; + +int main() +{ + volatile D d; + volatile B& b = d; + return b.f(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/virtual3.C b/gcc/testsuite/g++.old-deja/g++.other/virtual3.C new file mode 100644 index 000000000..c62af5444 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/virtual3.C @@ -0,0 +1,25 @@ +// { dg-do run } +struct B +{ + virtual int f() volatile + { return 1; } +}; + +struct D : public B +{ + int f() + { return 0; } +}; + +struct D2 : public D +{ + int f() + { return 2; } +}; + +int main() +{ + D2 d2; + D& d = d2; + return d.f(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/virtual4.C b/gcc/testsuite/g++.old-deja/g++.other/virtual4.C new file mode 100644 index 000000000..6933755ab --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/virtual4.C @@ -0,0 +1,25 @@ +// { dg-do assemble } + +class A { +public: + virtual int foo() = 0; // { dg-error "" } original definition +}; + +class B { +public: + virtual double foo() = 0; +}; + +class C + : public A, public B +{ +public: + virtual double foo() { return 2; } // { dg-error "" } conflicting return type +}; + +class D + : public B, public A +{ +public: + virtual double foo() { return 2; } // { dg-error "" } conflicting return type +}; diff --git a/gcc/testsuite/g++.old-deja/g++.other/virtual5.C b/gcc/testsuite/g++.old-deja/g++.other/virtual5.C new file mode 100644 index 000000000..e163e9e41 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/virtual5.C @@ -0,0 +1,20 @@ +// { dg-do assemble } +// { dg-options "-w" } +// Origin: Derived from code by Andris Pavenis <andris@stargate.astr.lu.lv> + +class vector {}; + +class V +{ +}; + +class A : public vector +{ +}; + +class B : public A, virtual V, public vector +{ + B() {} +}; + + diff --git a/gcc/testsuite/g++.old-deja/g++.other/virtual6.C b/gcc/testsuite/g++.old-deja/g++.other/virtual6.C new file mode 100644 index 000000000..37a1797fb --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/virtual6.C @@ -0,0 +1,14 @@ +// { dg-do assemble } +// { dg-options "-Woverloaded-virtual" } +// Bug: g++ checks certain non-virtual functions to see if they override +// virtual functions. +// Submitted by Jason Merrill <jason@cygnus.com> + +struct A { + virtual void f (int); +}; + +struct B: public A { + static void f (); + void f (int); +}; diff --git a/gcc/testsuite/g++.old-deja/g++.other/virtual7.C b/gcc/testsuite/g++.old-deja/g++.other/virtual7.C new file mode 100644 index 000000000..20845eced --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/virtual7.C @@ -0,0 +1,17 @@ +// { dg-do assemble } +// { dg-options "-fno-rtti" } +// Origin: Anthony Green <green@cygnus.com> + +class _JvObjectPrefix +{ +protected: + virtual void finalize (void) = 0; +}; + +class Object : public _JvObjectPrefix +{ +protected: + virtual void finalize (void); +}; + +Object x; diff --git a/gcc/testsuite/g++.old-deja/g++.other/virtual8.C b/gcc/testsuite/g++.old-deja/g++.other/virtual8.C new file mode 100644 index 000000000..f1ec9ada6 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/virtual8.C @@ -0,0 +1,32 @@ +// { dg-do run } +extern "C" int printf (const char*, ...); + +struct A +{ + virtual void f () { + printf ("%x\n", this); + } +}; + +struct B : public A +{ +}; + +struct C : public A +{ +}; + +struct D : virtual public B, public C +{ +}; + +int main () +{ + D d; + + A* a1 = (A*) (B*) &d; + A* a2 = (A*) (C*) &d; + + a1->f (); + a2->f (); +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/virtual9.C b/gcc/testsuite/g++.old-deja/g++.other/virtual9.C new file mode 100644 index 000000000..c10eef69f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/virtual9.C @@ -0,0 +1,46 @@ +// { dg-do run } +// Source: Neil Booth, from PR #111. + +class A +{ +public : + int i; +}; + +class B : virtual public A +{ +}; + +class C : virtual public A +{ +}; + +class D : public B, public C +{ +public : + int f(void); + int g(void); +}; + +int D::f(void) +{ + return B::i; +} + +int D::g(void) +{ + return this->B::i; +} + +D d; +extern "C" void abort (void); + +int main(void) +{ + d.C::i=325; + + if (d.f() != d.B::i || d.f() != d.g()) + abort (); + + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/volatile1.C b/gcc/testsuite/g++.old-deja/g++.other/volatile1.C new file mode 100644 index 000000000..ca28ec8e4 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/volatile1.C @@ -0,0 +1,21 @@ +// { dg-do assemble } +// Test that failed lvalue-to-rvalue conversion of vf doesn't crash the +// compiler. + +class f_class // { dg-message "note" "candidates" } +{ }; + +volatile f_class +ret_v_f_class() +{ + f_class t; + return t; +} + +int main(void) +{ + volatile f_class vf; + 0 ? ret_v_f_class() : vf; // { dg-error "match" } can't copy volatile lvalue + // { dg-message "candidate" "candidate note" { target *-*-* } 18 } + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/vtbl1.C b/gcc/testsuite/g++.old-deja/g++.other/vtbl1.C new file mode 100644 index 000000000..a8157f43f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/vtbl1.C @@ -0,0 +1,15 @@ +// { dg-do link } +// Origin: DJ Delorie <dj@delorie.com> + +class X { +public: + int i; + X() { i = 0; } + ~X(); + virtual int foo() { return i; } + virtual void bar(); +}; + +int main() +{ +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/vtbl2.C b/gcc/testsuite/g++.old-deja/g++.other/vtbl2.C new file mode 100644 index 000000000..5c7721e42 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/vtbl2.C @@ -0,0 +1,77 @@ +// { dg-do run } +// Copyright (C) 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 8 Feb 2000 <nathan@acm.org> + +// vtable construction reorganisation broke this + +// execution test + +#include <stdio.h> + +static int fail = 0; + +void bad (char const *name) +{ + printf ("Bad %s\n", name); + fail = 1; +} +void ok (char const *name) +{ + printf ("Ok %s\n", name); +} + +struct Core +{ + virtual ~Core (); + virtual void Wibble () {bad (__PRETTY_FUNCTION__);} + virtual void Wobble () {bad (__PRETTY_FUNCTION__);} + virtual void Bogus () {bad (__PRETTY_FUNCTION__);} +}; +struct Side +{ + virtual ~Side (); + virtual void Arfle () {bad (__PRETTY_FUNCTION__);} + virtual void Barfle () {bad (__PRETTY_FUNCTION__);} + virtual void Gloop () {bad (__PRETTY_FUNCTION__);} + virtual void Glorp () {bad (__PRETTY_FUNCTION__);} + virtual void Glump () {bad (__PRETTY_FUNCTION__);} + virtual void Bogus () {bad (__PRETTY_FUNCTION__);} +}; +struct Base : Core +{ + virtual ~Base (); + virtual void Bink () {bad (__PRETTY_FUNCTION__);} + virtual void Bonk () {bad (__PRETTY_FUNCTION__);} + virtual void Bogus () {bad (__PRETTY_FUNCTION__);} +}; +struct Multi : Base, Side +{ + virtual ~Multi (); + virtual void Stomped () {ok (__PRETTY_FUNCTION__);} + virtual void Bunk () {bad (__PRETTY_FUNCTION__);} + virtual void Bogus () {bad (__PRETTY_FUNCTION__);} +}; +struct Trail : Multi +{ + virtual ~Trail (); +}; +Core::~Core () {} +Side::~Side () {} +Base::~Base () {} +Multi::~Multi () {} +Trail::~Trail () {} + +void foo (Multi *ptr) +{ + ptr->Stomped (); +} + +int main () +{ + Multi m; + Trail t; + + foo (&m); + foo (&t); + return fail != 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/warn01.C b/gcc/testsuite/g++.old-deja/g++.other/warn01.C new file mode 100644 index 000000000..3f569421f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/warn01.C @@ -0,0 +1,15 @@ +// { dg-do assemble } +// { dg-options "-W -Wall" } + +typedef unsigned long size_t; +extern void* malloc (size_t); +extern void free (void*); +extern void* realloc (void*, size_t); + +struct vtable { + void* (* _malloc) (size_t); + void (* _free) (void*); + void* (* _realloc) (void*, size_t); +}; + +struct vtable mtable = { malloc, free }; // { dg-warning "" } _realloc diff --git a/gcc/testsuite/g++.old-deja/g++.other/warn3.C b/gcc/testsuite/g++.old-deja/g++.other/warn3.C new file mode 100644 index 000000000..3080f93b9 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/warn3.C @@ -0,0 +1,55 @@ +// { dg-do assemble } +// { dg-options "-Wctor-dtor-privacy" } + +class A { +}; + + +class B { // { dg-warning "" } only private constructors +public: + void f(); + +private: + B (); + B (const B&); +}; + + +class C { // { dg-warning "" } only private destructors +public: + void f(); + +private: + ~C (); +}; + + +class D { // { dg-warning "" } all member functions are private +private: + void f(); +}; + + +template <class T> +class X { // { dg-warning "" } only private destructors +private: + ~X (); +}; + +template class X<int>; +template class X<double>; + + +template <class T> +class Y { // { dg-warning "" } only private constructors +private: + Y (); + Y (const Y&); +}; + + +template <class T> +class Z { // { dg-warning "" } all member functions are private +private: + void f(); +}; diff --git a/gcc/testsuite/g++.old-deja/g++.other/warn4.C b/gcc/testsuite/g++.old-deja/g++.other/warn4.C new file mode 100644 index 000000000..7973c75d0 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/warn4.C @@ -0,0 +1,68 @@ +// { dg-do assemble } +// { dg-options "-Wsign-conversion" } + +// Copyright (C) 1999 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 21 Nov 1999 <nathan@acm.org> + +// make sure we only warn on assigning a negative (signed) value +// to an unsigned type, and don't warn just if the unsigned value +// happens to have the top bit set. + +typedef unsigned U; + +void fn (unsigned); + +void fu () +{ + unsigned s1 = -1u; + unsigned s2(-1u); + unsigned volatile s3 = -1u; + unsigned const s4 = -1u; + unsigned const &s5(-1u); + s1 = -1u; + fn (-1u); +} + +void fU () +{ + U s1 = -1u; + U s2(-1u); + U volatile s3 = -1u; + U const s4 = -1u; + U const &s5(-1u); + s1 = -1u; + fn (-1u); +} + +void fs () +{ + unsigned s1 = -1; // { dg-warning "" } initialization + unsigned s2(-1); // { dg-warning "" } initialization + unsigned volatile s3 = -1;// { dg-warning "" } initialization + unsigned const s4 = -1; // { dg-warning "" } initialization + unsigned const &s5(-1); // { dg-warning "" } initialization + s1 = -1; // { dg-warning "" } assignment + fn (-1); // { dg-warning "" } passing +} + +void fss () +{ + unsigned s1 = -(-1); + unsigned s2(-(-1)); + unsigned volatile s3 = -(-1); + unsigned const s4 = -(-1); + unsigned const &s5(-(-1)); + s1 = -(-1); + fn (-(-1)); +} + +void fsz () +{ + unsigned s1 = -0; + unsigned s2(-0); + unsigned volatile s3 = -0; + unsigned const s4 = -0; + unsigned const &s5(-0); + s1 = -0; + fn (-0); +} 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 000000000..84fa3e426 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/warn5.C @@ -0,0 +1,19 @@ +// { dg-do assemble } +// { dg-options "-W " } +// +// 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 = {}; // { dg-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 000000000..4325df74b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/warn6.C @@ -0,0 +1,17 @@ +// { dg-do assemble } +// { dg-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 000000000..c7684d18c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/warn7.C @@ -0,0 +1,45 @@ +// { dg-do assemble } +// { dg-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) // { dg-warning "unused parameter" } +{ +} +void Y::bar (int i) // { dg-warning "unused parameter" } +{ +} +void bar (int i) // { dg-warning "unused parameter" } +{ +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/alignof.C b/gcc/testsuite/g++.old-deja/g++.pt/alignof.C new file mode 100644 index 000000000..d6af26841 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/alignof.C @@ -0,0 +1,22 @@ +// { dg-do run } +extern "C" void abort(); + +struct S +{ + char c; + double d; +}; + + +template <class T> +void foo(T) +{ + if (__alignof__(T) != __alignof__(S)) + abort(); +} + + +int main() +{ + foo(S()); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/array1.C b/gcc/testsuite/g++.old-deja/g++.pt/array1.C new file mode 100644 index 000000000..50e3724b7 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/array1.C @@ -0,0 +1,11 @@ +// { dg-do run } +template <class T, unsigned N> + unsigned size(T (&)[N]) { return N; } +template <class T, unsigned N> + unsigned size(T const (&)[N]) { return N; } + +int main() { + short iarray[] = { 1, 2, 3, 4, 5 }; + const short carray[] = { 1, 2, 3, 4, 5 }; + return size(iarray) - size(carray); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/array2.C b/gcc/testsuite/g++.old-deja/g++.pt/array2.C new file mode 100644 index 000000000..edab15bbe --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/array2.C @@ -0,0 +1,14 @@ +// { dg-do assemble } + +template<int N, class C> +class Bar {}; + +template<class C> +class Huh {}; + +template<int N> +void foo(const Bar<N,Huh<float[1]> > &x) {} + +int main() { + foo(Bar<3,Huh<float[1]> >()); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/array3.C b/gcc/testsuite/g++.old-deja/g++.pt/array3.C new file mode 100644 index 000000000..4f9d89486 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/array3.C @@ -0,0 +1,5 @@ +// { dg-do assemble } +// Origin: Brendan Kehoe <brendan@cygnus.com> + + template <int x> int foo(char[4][x]) { return x; } + int (*bar)(char[4][3]) = &foo; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/array4.C b/gcc/testsuite/g++.old-deja/g++.pt/array4.C new file mode 100644 index 000000000..0bd580af3 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/array4.C @@ -0,0 +1,14 @@ +// { dg-do assemble } +// Test to make sure that the array bounds are treated as an expression +// in template parm substitution. + +// Written by Jason Merrill <jason@cygnus.com> + + +template <class T> void f (T t) { int ar[sizeof (T)]; } + +int +main () +{ + f (1); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/array5.C b/gcc/testsuite/g++.old-deja/g++.pt/array5.C new file mode 100644 index 000000000..87bd0a2cd --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/array5.C @@ -0,0 +1,21 @@ +// { dg-do assemble } +// Origin: Mark Mitchell <mark@codesourcery.com> + +template <class T> +void h(T&); + +template <class T> +void g () +{ + h ("abcdefghi"); +} + +template void g<int>(); + +template <class T> +void h(T&) +{ + T t = {}; +} + + diff --git a/gcc/testsuite/g++.old-deja/g++.pt/array6.C b/gcc/testsuite/g++.old-deja/g++.pt/array6.C new file mode 100644 index 000000000..b48cabd4d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/array6.C @@ -0,0 +1,16 @@ +// { dg-do assemble } +// { dg-options "" } +// Origin: Alfred Minarik <a8601248@unet.univie.ac.at> + +template<typename _CharT> +struct basic_filebuf +{ + virtual void + underflow() + { + int __size = 5; + char __conv_buf[__size]; + } +}; + +template class basic_filebuf<char>; 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 000000000..c045a349d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/array7.C @@ -0,0 +1,11 @@ +// { dg-do assemble } +// 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/asm1.C b/gcc/testsuite/g++.old-deja/g++.pt/asm1.C new file mode 100644 index 000000000..8e54a8ed5 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/asm1.C @@ -0,0 +1,17 @@ +// { dg-do assemble { target i?86-*-linux* x86_64-*-linux* } } +// We'd use ebx with 32-bit pic code, so skip. +// { dg-skip-if "" { ilp32 && { ! nonpic } } { "*" } { "" } } +// Origin: "Weidmann, Nicholas" <nicholas.weidmann@swx.ch> + +template<int i> int foo(int v) +{ + __asm__ __volatile__("addl %1, %0" : "=a" (v) : "b" (i)); + + return v; +} + +int bar(int i) +{ + return foo<123>(i); +} + diff --git a/gcc/testsuite/g++.old-deja/g++.pt/asm2.C b/gcc/testsuite/g++.old-deja/g++.pt/asm2.C new file mode 100644 index 000000000..7a7063790 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/asm2.C @@ -0,0 +1,25 @@ +// { dg-do assemble { target i?86-*-linux* x86_64-*-linux* } } +// { dg-require-effective-target ilp32 } +// We'd use ebx with 32-bit pic code, so require nonpic. +// { dg-require-effective-target nonpic } +// Origin: "Weidmann, Nicholas" <nicholas.weidmann@swx.ch> + +typedef void (function_ptr)(int); + +void foo(int) +{ +} + +template<function_ptr ptr> void doit(int i) +{ + __asm__("pushl %0\n\t" + "call *%1\n\t" + "popl %0" + : + : "a" (i), "b" (ptr)); +} + +void bar() +{ + doit<foo>(123); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/assign1.C b/gcc/testsuite/g++.old-deja/g++.pt/assign1.C new file mode 100644 index 000000000..854d8ee27 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/assign1.C @@ -0,0 +1,14 @@ +// { dg-do compile } +// Origin: Mark Mitchell <mark@codesourcery.com> + +template <class T> +struct S { // { dg-error "const|operator=" } + S(); + T t; +}; + +void f() +{ + S<const int> s; + s = s; // { dg-message "synthesized|deleted" } +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/auto_ptr.C b/gcc/testsuite/g++.old-deja/g++.pt/auto_ptr.C new file mode 100644 index 000000000..ecfa4de18 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/auto_ptr.C @@ -0,0 +1,56 @@ +// { dg-do assemble } +template <typename Y> struct auto_ptr_ref { + Y* py; + auto_ptr_ref(Y* p) : py(p) {} +}; +template<typename X> struct auto_ptr { + X* px; + public: + typedef X element_type; + + explicit auto_ptr(X* p =0) throw() : px(p) {} + auto_ptr(auto_ptr& r) throw() : px(r.release()) {} // { dg-message "note" } candidate + template<typename Y> + auto_ptr(auto_ptr<Y>& r) throw() : px(r.release()) {}// { dg-message "note" } candidate + + auto_ptr& operator=(auto_ptr& r) throw() { + reset(r.release()); + return *this; + } + template<typename Y> auto_ptr& operator=(auto_ptr<Y>& r) throw() { + reset(r.release()); + return *this; + } + + ~auto_ptr() { delete px; } + + X& operator*() const throw() { return *px; } + X* operator->() const throw() { return px; } + X* get() const throw() { return px; } + X* release() throw() { X* p=px; px=0; return p; } + void reset(X* p=0) throw() { if (px != p) delete px, px = p; } + + auto_ptr(auto_ptr_ref<X> r) throw() : px(r.py) {} // { dg-message "note" } + template<typename Y> operator auto_ptr_ref<Y>() throw() { + return auto_ptr_ref<Y>(release()); + } + template<typename Y> operator auto_ptr<Y>() throw() { + return auto_ptr<Y>(release()); + } +}; + +struct Base { Base() {} virtual ~Base() {} }; +struct Derived : Base { Derived() {} }; + +auto_ptr<Derived> f() { auto_ptr<Derived> null(0); return null; } +void g(auto_ptr<Derived>) { } +void h(auto_ptr<Base>) { } // { dg-error "initializing" } + +int main() { + auto_ptr<Base> x(f()); + auto_ptr<Derived> y(f()); + x = y; + g(f()); + h(f()); // { dg-error "match" "match" } no usable copy ctor + // { dg-message "candidate" "candidate note" { target *-*-* } 54 } +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/bad-type.C b/gcc/testsuite/g++.old-deja/g++.pt/bad-type.C new file mode 100644 index 000000000..fffa8c531 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/bad-type.C @@ -0,0 +1,20 @@ +// { dg-do assemble } +template<class Type> +class A +{ +public: + Type m; +}; + +template<class Type> +void f(A<Type>& a, Type d) +{ + A.m=d; // { dg-error "" } invalid use of template +} + +int main() +{ + A<int> a; + f(a,2); +} + diff --git a/gcc/testsuite/g++.old-deja/g++.pt/builtin.C b/gcc/testsuite/g++.old-deja/g++.pt/builtin.C new file mode 100644 index 000000000..0a2e241de --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/builtin.C @@ -0,0 +1,10 @@ +// { dg-do assemble } +// { dg-options "-Wno-abi" { target arm_eabi } } +// Bug: Checking whether A depends on template parms, we crash because +// __builtin_va_list lacks TYPE_LANG_SPECIFIC. + + +void f (__builtin_va_list arg) +{ + enum { a } A; +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/call1.C b/gcc/testsuite/g++.old-deja/g++.pt/call1.C new file mode 100644 index 000000000..26a49b507 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/call1.C @@ -0,0 +1,15 @@ +// { dg-do assemble } + +struct IsCompressed { }; +struct Field { + bool IsCompressed() const { return true; } +}; + +template<class C> +inline bool +for_each(const Field& p, IsCompressed, C) +{ + return p.IsCompressed(); +} + +template bool for_each<int>(const Field& p, IsCompressed, int); diff --git a/gcc/testsuite/g++.old-deja/g++.pt/call2.C b/gcc/testsuite/g++.old-deja/g++.pt/call2.C new file mode 100644 index 000000000..94e4928b4 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/call2.C @@ -0,0 +1,14 @@ +// { dg-do assemble } + +struct IsCompressed { }; +struct Field { +}; + +template<class C> +inline bool +for_each(const Field& p, IsCompressed, C) +{ + return p.IsCompressed(); // { dg-error "" } calling type like a method +} + +template bool for_each<int>(const Field& p, IsCompressed, int); diff --git a/gcc/testsuite/g++.old-deja/g++.pt/cast1.C b/gcc/testsuite/g++.old-deja/g++.pt/cast1.C new file mode 100644 index 000000000..ab27e65fe --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/cast1.C @@ -0,0 +1,7 @@ +// { dg-do assemble } +// Origin: Mark Mitchell <mark@codesourcery.com> + +template <class T> +void f (T t) { + const_cast<T>(t); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/cast2.C b/gcc/testsuite/g++.old-deja/g++.pt/cast2.C new file mode 100644 index 000000000..ec1c6b27f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/cast2.C @@ -0,0 +1,32 @@ +// { dg-do assemble } + +// Copyright (C) 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 10 Jan 2001 <nathan@codesourcery.com> + +// Bug 1588. We ICE'd on reparsing an absdcl as a cast inside a template +// function. + +class A { +public: + template <class T> void f(void *CLUTp); +}; + +template <class T> void A::f(void *CLUTp) +{ + void *CLUT; + + CLUT = (unsigned char [3][256])CLUTp; // { dg-error "" } cast to array + + return; +} + + +int main() +{ + A myobj; + unsigned char t[3][256]; + + myobj.f<unsigned char>(t); + + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/codegen1.C b/gcc/testsuite/g++.old-deja/g++.pt/codegen1.C new file mode 100644 index 000000000..c07083a0a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/codegen1.C @@ -0,0 +1,24 @@ +// { dg-do assemble } +// Origin: Mark Mitchell <mark@codesourcery.com> + +int i; + +struct S +{ + ~S () + { + } +}; + +template <class T> +void f (T, S) +{ + i = 0; +} + +int main () +{ + i = 1; + f (3, S ()); + return i; +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/cond2.C b/gcc/testsuite/g++.old-deja/g++.pt/cond2.C new file mode 100644 index 000000000..37bc1466a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/cond2.C @@ -0,0 +1,18 @@ +// { dg-do assemble } +// Origin: Mark Mitchell <mark@codesourcery.com> + +struct S +{ + S (int); + operator bool () const; +}; + +template <class T> +void f () +{ + if (const S &s = 3) { + } +} + +template void f<int>(); + diff --git a/gcc/testsuite/g++.old-deja/g++.pt/cond3.C b/gcc/testsuite/g++.old-deja/g++.pt/cond3.C new file mode 100644 index 000000000..e82b686e9 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/cond3.C @@ -0,0 +1,25 @@ +// { dg-do assemble } +// Origin: Loring Holden <lsh@lsh.cs.brown.edu> + +template <class T> +class REFptr { + public: + operator T* () const; +}; + +class CamFocus; +typedef REFptr<CamFocus> CamFocusptr; + +class CamFocus { + protected: + static CamFocusptr _focus; + public : + static CamFocusptr &cur() { return _focus; } +}; + +void +test() +{ + if (CamFocus::cur()) { + } +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/const1.C b/gcc/testsuite/g++.old-deja/g++.pt/const1.C new file mode 100644 index 000000000..6c6182284 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/const1.C @@ -0,0 +1,4 @@ +// { dg-do assemble } +template <class T> struct B { static const int i = 3; }; +template <class T> struct A { static const int i = B<T>::i; }; +enum { i = A<int>::i }; 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 000000000..3ca4a532b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/const2.C @@ -0,0 +1,14 @@ +// { dg-do link } +// This test should get a linker error for the reference to A<int>::i. +// { dg-prune-output "ld: symbol" } +// { dg-message "i" "" { target *-*-* } 0 } + +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 () +{ + // Examine p to prevent optimising linkers from discarding it. + return (p != 0); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/conv1.C b/gcc/testsuite/g++.old-deja/g++.pt/conv1.C new file mode 100644 index 000000000..7909e3f69 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/conv1.C @@ -0,0 +1,19 @@ +// { dg-do assemble } + +template <class T> +struct S1 {}; + +struct S2 +{ + template <class T> + operator S1<T>*(); +}; + +struct D: public S1<int> { +}; + +void f() +{ + S2 s; + (D*) s; // { dg-error "" } cannot convert +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/conv2.C b/gcc/testsuite/g++.old-deja/g++.pt/conv2.C new file mode 100644 index 000000000..d668a5451 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/conv2.C @@ -0,0 +1,15 @@ +// { dg-do assemble } + +template<class T> +class A { +public: + operator const T*() const; + const T* cast() const; +}; + +template<class T> +const T* A<T>::cast() const { + return operator const T*(); +} + +template class A<char>; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/conv3.C b/gcc/testsuite/g++.old-deja/g++.pt/conv3.C new file mode 100644 index 000000000..78cf5ce0f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/conv3.C @@ -0,0 +1,10 @@ +// { dg-do assemble } +// Origin: Chris Heath <cheath@math.lsa.umich.edu> + +struct A { + template<typename T> explicit A(T t) {} +}; + +void f(A a) {} + +int main() {f(1);} // { dg-error "" } no conversion from int to A. diff --git a/gcc/testsuite/g++.old-deja/g++.pt/copy1.C b/gcc/testsuite/g++.old-deja/g++.pt/copy1.C new file mode 100644 index 000000000..24aa5e035 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/copy1.C @@ -0,0 +1,30 @@ +// { dg-do run } +int i = 0; + +template <class T> +class F +{ +public: + F() {} + + template <class T2> F(F<T2>) + { + i = 1; + } +}; + + +F<int> +foo() +{ + F<int> f1; + F<int> f2(f1); + return f1; +} + +int +main() +{ + return i; +} + diff --git a/gcc/testsuite/g++.old-deja/g++.pt/crash1.C b/gcc/testsuite/g++.old-deja/g++.pt/crash1.C new file mode 100644 index 000000000..f9a6e16e4 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/crash1.C @@ -0,0 +1,12 @@ +// { dg-do assemble } +template<class T> class A { + public: + class subA {}; +}; + + +template<class T> class B : public A<T> { + public: + class subB : public A::subA {}; // { dg-error "" } not a class or namespace +}; + diff --git a/gcc/testsuite/g++.old-deja/g++.pt/crash10.C b/gcc/testsuite/g++.old-deja/g++.pt/crash10.C new file mode 100644 index 000000000..86f386150 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/crash10.C @@ -0,0 +1,13 @@ +// { dg-do assemble } + +template<int M, int N> +class GCD { +public: + enum { val = (N == 0) ? M : GCD<N, M % N>::val }; // { dg-warning "division" "division" } +// { dg-error "constant expression" "valid" { target *-*-* } 6 } +// { dg-message "template argument" "valid" { target *-*-* } 6 } +}; + +int main() { + GCD< 1, 0 >::val; // { dg-message "instantiated" } +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/crash11.C b/gcc/testsuite/g++.old-deja/g++.pt/crash11.C new file mode 100644 index 000000000..5f372d3a3 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/crash11.C @@ -0,0 +1,13 @@ +// { dg-do assemble } + +class A +{ + class A_impl; + public: + A(){} +}; + + +template <class j> class A::A_impl // { dg-error "non-template" } +{ +}; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/crash12.C b/gcc/testsuite/g++.old-deja/g++.pt/crash12.C new file mode 100644 index 000000000..37388c82e --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/crash12.C @@ -0,0 +1,13 @@ +// { dg-do assemble } +// { dg-options "-g" } + +template <class C> +class CenteringTag { +}; + +struct S { + template <class B, class C> + static void f() { + CenteringTag<C> ctag; + } +}; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/crash13.C b/gcc/testsuite/g++.old-deja/g++.pt/crash13.C new file mode 100644 index 000000000..010808136 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/crash13.C @@ -0,0 +1,6 @@ +// { dg-do assemble } + +template <class T> struct A {}; +template <class T> struct A<T>; // { dg-error "" } does not specialize args +template <class T> const struct A; // { dg-error "" } parse error +template <class T> template A<int>; // { dg-error "" } .* diff --git a/gcc/testsuite/g++.old-deja/g++.pt/crash14.C b/gcc/testsuite/g++.old-deja/g++.pt/crash14.C new file mode 100644 index 000000000..773ed28b2 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/crash14.C @@ -0,0 +1,5 @@ +// { dg-do assemble } + +template <class T> struct A {}; +template <class T> struct A<T*>; +A<int*> ai; // { dg-error "" } incomplete type diff --git a/gcc/testsuite/g++.old-deja/g++.pt/crash15.C b/gcc/testsuite/g++.old-deja/g++.pt/crash15.C new file mode 100644 index 000000000..446a256b3 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/crash15.C @@ -0,0 +1,10 @@ +// { dg-do assemble } + +template <class T> +template <class U> +struct A { // { dg-error "" } too many template parameter lists +public: + A() {} + + A(const A<T>& b) {} +}; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/crash16.C b/gcc/testsuite/g++.old-deja/g++.pt/crash16.C new file mode 100644 index 000000000..aa25c22b8 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/crash16.C @@ -0,0 +1,30 @@ +// { dg-do assemble } +// { dg-xfail-if "" { xstormy16-*-* } { "*" } { "" } } +// { dg-options "" } + +extern "C" void qsort(void *base, __SIZE_TYPE__ nmemb, __SIZE_TYPE__ size, + int (*compar)(const void *, const void *)); + +struct R { + int count; + int state1; + int state2; +}; + +int cmp_d(const R* a, const R* b) { + return a->count > b->count; +} + +namespace CXX { + template<class T, int i1, int i2> + inline void qsort (T b[i1][i2], int (*cmp)(const T*, const T*)) { + ::qsort ((void*)b, i1*i2, sizeof(T), (int (*)(const void *, const void *))cmp); + } +} + +using namespace CXX; + +void sort_machine() { + struct R d[256][256]; + qsort<R,256> (d, cmp_d); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/crash17.C b/gcc/testsuite/g++.old-deja/g++.pt/crash17.C new file mode 100644 index 000000000..bd9e20b4a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/crash17.C @@ -0,0 +1,10 @@ +// { dg-do assemble } + +template <int B> +class foo; + +template <class U> +class bar +{ + typedef foo<(U::id > 0)> foobar; +}; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/crash18.C b/gcc/testsuite/g++.old-deja/g++.pt/crash18.C new file mode 100644 index 000000000..a331dd4e5 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/crash18.C @@ -0,0 +1,23 @@ +// { dg-do link } + +template<class T> +class foo { + T deft; + + template<class U> int priv (U u, T t) { return u - t; } +public: + foo (T t) : deft (t) {} + + template<class U> int pub (U u) { + int (foo::*fn) (U, T); + fn = &foo<T>::template priv<U>; + return (this->*fn) (u, deft); + } +}; + +int +main () +{ + foo<long> fff (5); + return fff.pub (3); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/crash19.C b/gcc/testsuite/g++.old-deja/g++.pt/crash19.C new file mode 100644 index 000000000..09e57d1d3 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/crash19.C @@ -0,0 +1,19 @@ +// { dg-do assemble } + +template <int I> +void f() +{ + class C { public: int c; }; + + struct S { + void g() { + C e; + e.c = 3; + } + }; + + S s; + s.g(); +} + +template void f<7>(); diff --git a/gcc/testsuite/g++.old-deja/g++.pt/crash2.C b/gcc/testsuite/g++.old-deja/g++.pt/crash2.C new file mode 100644 index 000000000..dfccc95b8 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/crash2.C @@ -0,0 +1,14 @@ +// { dg-do assemble } + +template <class T> +struct S1 +{ + T* t; + static int foo; +}; + + +struct S2 : public S1<S2> +{ + S2* s; +}; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/crash20.C b/gcc/testsuite/g++.old-deja/g++.pt/crash20.C new file mode 100644 index 000000000..a5175b990 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/crash20.C @@ -0,0 +1,16 @@ +// { dg-do compile } + +template <class T = int> +struct A { // { dg-message "const|operator=" "assignment" } + const T x; + A() : x(0) { } A(T x) : x(x) { } +}; + +template <class B> +void func () +{ + B y; + y = B(); // { dg-message "synthesized|deleted" } +} + +int main (void) { func< A<> >(); } diff --git a/gcc/testsuite/g++.old-deja/g++.pt/crash21.C b/gcc/testsuite/g++.old-deja/g++.pt/crash21.C new file mode 100644 index 000000000..05654b5c5 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/crash21.C @@ -0,0 +1,26 @@ +// { dg-do assemble } +// { dg-options "" } + +class Pooled +{ +}; + +class RefCounted +{ +}; + +class BrickExpressionBase : public RefCounted, public Pooled +{ +}; + +template<unsigned Dim, class LHS, class RHS, class OP> +class BrickExpression : public BrickExpressionBase +{ +}; + +template <unsigned Dim, class T> +void f() +{ + typedef BrickExpression<Dim, T, T, T> ExprT; + ExprT(3).apply; +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/crash22.C b/gcc/testsuite/g++.old-deja/g++.pt/crash22.C new file mode 100644 index 000000000..c1d81b4fb --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/crash22.C @@ -0,0 +1,9 @@ +// { dg-do assemble } + +template <class T> +struct S1 {}; + +template <class T, class U = S1<T> > +struct S2 {}; + +template struct S2<100>; // { dg-error "" } type/value mismatch diff --git a/gcc/testsuite/g++.old-deja/g++.pt/crash23.C b/gcc/testsuite/g++.old-deja/g++.pt/crash23.C new file mode 100644 index 000000000..242624eeb --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/crash23.C @@ -0,0 +1,16 @@ +// { dg-do assemble } + +template <class A, class B> void foo(); +template <class C> class bar { +public: + int i; + template <class B> friend void foo<C,B>(); // { dg-error "" } template-id +}; +template <class A, class B> void foo() { + bar<A> baz; baz.i = 1; + bar<int> buz; buz.i = 1; +} +int main() { + foo<void,void>(); + foo<int,void>(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/crash24.C b/gcc/testsuite/g++.old-deja/g++.pt/crash24.C new file mode 100644 index 000000000..8b0a87e44 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/crash24.C @@ -0,0 +1,11 @@ +// { dg-do assemble } + +template<typename T, template <class> class U> void template_fn (T); +template<typename T> void callme ( void (*)(T)); + +template<typename T> struct S1; + +int main() +{ + callme(&template_fn<double, S1>); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/crash25.C b/gcc/testsuite/g++.old-deja/g++.pt/crash25.C new file mode 100644 index 000000000..7c9791d4d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/crash25.C @@ -0,0 +1,7 @@ +// { dg-do assemble } + +template <class T> +void f() +{ + int i[1 << 3]; +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/crash26.C b/gcc/testsuite/g++.old-deja/g++.pt/crash26.C new file mode 100644 index 000000000..94682dde1 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/crash26.C @@ -0,0 +1,15 @@ +// { dg-do assemble } +// Origin: Theodore Papadopoulo <Theodore.Papadopoulo@sophia.inria.fr> + +double f(double); +typedef double (*M)(double); + +class A { +public: + template <const M n> void g(); +}; + +class B: public A { +public: + void g() { A::g<f>(); } +}; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/crash27.C b/gcc/testsuite/g++.old-deja/g++.pt/crash27.C new file mode 100644 index 000000000..ccc002d15 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/crash27.C @@ -0,0 +1,13 @@ +// { dg-do assemble } + +template<int i> int f (void) +{ + if (__extension__ ({ 1; })) + return 0; + return 1; +} + +void g (void) +{ + f<1> (); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/crash28.C b/gcc/testsuite/g++.old-deja/g++.pt/crash28.C new file mode 100644 index 000000000..2cfed9308 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/crash28.C @@ -0,0 +1,15 @@ +// { dg-do assemble } +// { dg-options "" } + +template <class ARRY> +inline unsigned int asize(ARRY &a) // { dg-message "note" } +{ + return sizeof(a) / sizeof(a[0]); +} + +void f(unsigned int n) { + int x[n]; + + asize(x); // { dg-error "" } no matching function + // { dg-message "candidate" "candidate note" { target *-*-* } 13 } +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/crash29.C b/gcc/testsuite/g++.old-deja/g++.pt/crash29.C new file mode 100644 index 000000000..0aee9c3b5 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/crash29.C @@ -0,0 +1,70 @@ +// { dg-do assemble } +// Origin: Steven Parkes <parkes@sierravista.com> + +typedef __SIZE_TYPE__ size_t; + +class UUId {}; + +template <class T> class MetaClass; + +class TypeInfo; + +struct MetaClassGeneric +{ + MetaClassGeneric( TypeInfo& ); +}; + +struct TypeInfo +{ + void (*constructor)( void* ); + void initialize( void* ); +}; + +template <class T> +class TypeIDInit { +public: + TypeIDInit(); + static void initialize(); + static TypeInfo info; + static int storage[]; + static void metaclassConstructor( void* ); +}; + +template <class T> +TypeInfo TypeIDInit<T>::info = +{ + TypeIDInit<T>::metaclassConstructor +}; + +template <class T> +inline +TypeIDInit<T>::TypeIDInit() +{ + info.initialize(storage); +} + +template <class T> +class NameInfo : public MetaClassGeneric { +public: + NameInfo() + : MetaClassGeneric( TypeIDInit<T>::info ) {} +}; + +template <> +class MetaClass<UUId> +: public NameInfo<UUId> +{ +}; + +extern "C++" +inline void *operator new(size_t, void *place) throw() { return place; } + +template <class T> +void +TypeIDInit<T>::metaclassConstructor( void* place ) +{ + new ( place ) MetaClass<T>; +} + +template class TypeIDInit<UUId> ; + diff --git a/gcc/testsuite/g++.old-deja/g++.pt/crash3.C b/gcc/testsuite/g++.old-deja/g++.pt/crash3.C new file mode 100644 index 000000000..160cbe541 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/crash3.C @@ -0,0 +1,16 @@ +// { dg-do assemble } + +template <class Type> +class CVector { +public: + CVector<int> f() const + { + CVector<int> v(); + return v; + } + CVector<long> g() const + { + CVector<long> v(); + return v; + } +}; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/crash30.C b/gcc/testsuite/g++.old-deja/g++.pt/crash30.C new file mode 100644 index 000000000..dfbef1003 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/crash30.C @@ -0,0 +1,15 @@ +// { dg-do assemble } + +extern "C" int printf(const char *, ...); +template <class T> struct A { + typedef typename T::X B; // { dg-error "" } not a class + A(double); +}; + +template <class T> void xxx(typename A<T>::B); + +template <class T> struct B { + friend void xxx<T>(T); // { dg-error "" } does not match any template +}; + +template struct B<double>; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/crash31.C b/gcc/testsuite/g++.old-deja/g++.pt/crash31.C new file mode 100644 index 000000000..9c9ce15e9 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/crash31.C @@ -0,0 +1,19 @@ +// { dg-do assemble } +// Origin: Corey Kosak + +struct cow_t { + template<bool Q> + static void tfunc(cow_t *cowp) {} + + void moo() { + cow_t *cowp; + cow_t::tfunc<true>(cowp); + } +}; + + +int main() +{ + cow_t *cowp; + cow_t::tfunc<true>(cowp); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/crash32.C b/gcc/testsuite/g++.old-deja/g++.pt/crash32.C new file mode 100644 index 000000000..64ed2290f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/crash32.C @@ -0,0 +1,13 @@ +// { dg-do assemble } +// Origin: Jason Merrill <jason@cygnus.com> + +template <class T> struct A +{ + struct B; +}; + +template<class T> struct C +{ + friend typename A<T>::B; // { dg-error "" } `typename' not allowed +}; + diff --git a/gcc/testsuite/g++.old-deja/g++.pt/crash33.C b/gcc/testsuite/g++.old-deja/g++.pt/crash33.C new file mode 100644 index 000000000..e2a59eb18 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/crash33.C @@ -0,0 +1,17 @@ +// { dg-do assemble } +// Origin: Theodore Papadopoulo <Theodore.Papadopoulo@sophia.inria.fr> + +class A { +public: + template <class T> T& f(T& t) const; +}; + +class B { +public: + template <class T> T& f(T& t) const; +}; + +class C: public A,B { +public: + template <class T> T& f(T& t) const; +}; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/crash34.C b/gcc/testsuite/g++.old-deja/g++.pt/crash34.C new file mode 100644 index 000000000..31f89c8cc --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/crash34.C @@ -0,0 +1,20 @@ +// { dg-do assemble } +// Origin: Theodore Papadopoulo <Theodore.Papadopoulo@sophia.inria.fr> + +template <class T> +class A { +public: + class B { }; + class C: public B { + public: + C(A&):B() { } + }; + C f() { return C(*this); } +}; + +int +main() +{ + A<int> a; + a.f(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/crash35.C b/gcc/testsuite/g++.old-deja/g++.pt/crash35.C new file mode 100644 index 000000000..6e2cd7440 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/crash35.C @@ -0,0 +1,11 @@ +// { dg-do assemble } +// Origin: Miniussi <miniussi@ilog.fr> + +template <class O> +struct Str { + Str(int& val= (*new int())); +}; + +template<class O> +Str<O>::Str(int& val) {} + diff --git a/gcc/testsuite/g++.old-deja/g++.pt/crash36.C b/gcc/testsuite/g++.old-deja/g++.pt/crash36.C new file mode 100644 index 000000000..fa9401bee --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/crash36.C @@ -0,0 +1,35 @@ +// { dg-do assemble } +// Origin: Andreas Kloeckner <ak@ixion.net> + +template<class Iterator> struct iterator_traits { + typedef typename Iterator::iterator_category + iterator_category; // { dg-error "" } no type iterator_category +}; + +template<class Category> +struct iterator { + typedef Category iterator_category; +}; + + +template <class Iterator> +struct reverse_iterator : public // { dg-message "instantiated" } no type iterator_category +iterator<typename iterator_traits<Iterator>::iterator_category> { + protected: + Iterator current; + +}; +class tag { }; + +template <class T> +struct list { + template <class Item> + struct list_iterator { + }; + + reverse_iterator<list_iterator<T> > rbegin() + { return reverse_iterator<list_iterator<T> > + (list_iterator<T>(Head->next())); } // { dg-error "" } not declared +}; + +template class list<int>; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/crash37.C b/gcc/testsuite/g++.old-deja/g++.pt/crash37.C new file mode 100644 index 000000000..c07ccd591 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/crash37.C @@ -0,0 +1,22 @@ +// { dg-do assemble } +// Origin: Jens Maurer <jmaurer@menuett.rhein-main.de> + +template<class T, void (T::*f)(int)> +class C { }; + +template<class T> +C<T, &T::output> call(T& obj) +{ return C<T, &T::output>(); +} + +class Test { +public: + void output(int); +}; + +void sub() +{ + Test t; + call(t); +} + diff --git a/gcc/testsuite/g++.old-deja/g++.pt/crash38.C b/gcc/testsuite/g++.old-deja/g++.pt/crash38.C new file mode 100644 index 000000000..4fc658eb1 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/crash38.C @@ -0,0 +1,18 @@ +// { dg-do assemble } +// Origin: Mark Mitchell <mark@codesourcery.com> + +template <class T> +struct S { + typedef typename T::Y<T>::Z X; // { dg-error "non-template" "non-template" } No Y in A +// { dg-message "note" "note" { target *-*-* } 6 } +// { dg-error "does not declare" "not declare" { target *-*-* } 6 } + X x; // { dg-error "does not name a type" } No Y in A +}; + +struct A { + struct Y { + typedef A Z; + }; +}; + +template struct S<A>; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/crash39.C b/gcc/testsuite/g++.old-deja/g++.pt/crash39.C new file mode 100644 index 000000000..a8f70aa30 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/crash39.C @@ -0,0 +1,19 @@ +// { dg-do assemble } +// Origin: Ian Nixon <ian@tharas.com> + +class Action { +public: + virtual void action () = 0; +}; + +class Var { +public: + + template<class Base> void Add() { + struct tmp : public Action { + void action () {} + }; + tmp *tp = new tmp; + } + +}; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/crash4.C b/gcc/testsuite/g++.old-deja/g++.pt/crash4.C new file mode 100644 index 000000000..9bdc51f24 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/crash4.C @@ -0,0 +1,11 @@ +// { dg-do assemble } + +template <unsigned rank> +class Tensor +{ +}; + +template <unsigned rank> +class Tensor<2> : Tensor<rank> { // { dg-error "" } template parameters not used +}; + diff --git a/gcc/testsuite/g++.old-deja/g++.pt/crash40.C b/gcc/testsuite/g++.old-deja/g++.pt/crash40.C new file mode 100644 index 000000000..c075757d2 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/crash40.C @@ -0,0 +1,19 @@ +// { dg-do assemble } +// Origin: rch@larissa.sd.bi.ruhr-uni-bochum.de + +template< class X > +struct VB: public virtual X +{}; + +template< class MOPTerm1, class MOPTerm2 > +struct MOPTermUnify +{ + struct MO: + public VB<MOPTerm1>, + public VB<MOPTerm2> + { + void fix() + { + } + }; +}; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/crash41.C b/gcc/testsuite/g++.old-deja/g++.pt/crash41.C new file mode 100644 index 000000000..452ba91dc --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/crash41.C @@ -0,0 +1,13 @@ +// { dg-do compile } +// Origin: Mark Mitchell <mark@codesourcery.com> + +template <int> struct S1{}; + +struct S2 { int i; }; + +template <class T> +void f(S2 s2) { + S1<s2.i> s1; // { dg-error "" } +} + +template void f<int>(S2); diff --git a/gcc/testsuite/g++.old-deja/g++.pt/crash42.C b/gcc/testsuite/g++.old-deja/g++.pt/crash42.C new file mode 100644 index 000000000..65365857d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/crash42.C @@ -0,0 +1,14 @@ +// { dg-do assemble } +// Origin: Walter Brisken <walterfb@puppsr14.princeton.edu> + +template <class T> class list {}; + +class newtype +{ +}; + +void crash() +{ + newtype* n; + n->list.size (); // { dg-error "" } invalid use of template +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/crash43.C b/gcc/testsuite/g++.old-deja/g++.pt/crash43.C new file mode 100644 index 000000000..5172bbca2 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/crash43.C @@ -0,0 +1,24 @@ +// { dg-do assemble } +// Origin: Mark Mitchell <mark@codesourcery.com> + +template <int T> +struct S { + struct X {}; + struct Y {}; + + template <int U> + friend struct S<U>::X; + + template <int U> + friend typename S<U>::Y; // { dg-error "" } typename as friend +}; + +struct T { + template <int T> + friend struct S<T>::X; +}; + +struct U { + template <int T> + friend typename S<T>::X; // { dg-error "" } typename as friend +}; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/crash44.C b/gcc/testsuite/g++.old-deja/g++.pt/crash44.C new file mode 100644 index 000000000..4aea2149d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/crash44.C @@ -0,0 +1,11 @@ +// { dg-do assemble } +// Origin: Mark Mitchell <mark@codesourcery.com> + +template <class T> +struct S +{ + template <class U> + friend S<U>; // { dg-error "" } friend must use tag +}; + +template struct S<int>; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/crash45.C b/gcc/testsuite/g++.old-deja/g++.pt/crash45.C new file mode 100644 index 000000000..0251d0bbc --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/crash45.C @@ -0,0 +1,13 @@ +// { dg-do assemble } +// Origin: Jason Merrill <jason@cygnus.com> + +template <class T> void f() +{ + extern void g (); +} + +int main() +{ + f<int>(); +} + diff --git a/gcc/testsuite/g++.old-deja/g++.pt/crash46.C b/gcc/testsuite/g++.old-deja/g++.pt/crash46.C new file mode 100644 index 000000000..bfdddaeaa --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/crash46.C @@ -0,0 +1,8 @@ +// { dg-do assemble } +// Origin: Leon Bottou <leonb@research.att.com> + +class AA { protected: + template <class T> struct BB { T x; BB(const T &x) : x(x) { } }; + template <class T> struct CC : public BB<T> { CC(const T &x) : BB<T>(x) { } +}; +}; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/crash47.C b/gcc/testsuite/g++.old-deja/g++.pt/crash47.C new file mode 100644 index 000000000..212bedaac --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/crash47.C @@ -0,0 +1,17 @@ +// { dg-do assemble } +// Origin: Rick Campbell <rick.campbell@db.com> + +template <class Owner, typename Type> +struct DataMember +{ + inline DataMember (Type Owner::* data_member); + + Type Owner::* _data_member; +}; + +template <class Owner, typename Type> +inline +DataMember<Owner,Type>::DataMember (Type Owner::* data_member) + : _data_member (data_member) +{ +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/crash48.C b/gcc/testsuite/g++.old-deja/g++.pt/crash48.C new file mode 100644 index 000000000..2785cdd39 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/crash48.C @@ -0,0 +1,8 @@ +// { dg-do assemble } +// Origin: Jean-Francois Panisset <panisset@discreet.com> + +template<class T> +void foo(T *data) +{ + ((char *)data)->~T(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/crash49.C b/gcc/testsuite/g++.old-deja/g++.pt/crash49.C new file mode 100644 index 000000000..a3e3effdf --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/crash49.C @@ -0,0 +1,37 @@ +// { dg-do assemble } +// Origin: Loring Holden <lsh@cs.brown.edu> + +template <class T> +class REFptr { + public: + virtual ~REFptr(); + REFptr<T> &operator = (const REFptr<T>& p); +}; + +class STR { }; +class str_ptr : public REFptr<STR> { }; + +template <class T> +class ARRAY { + protected: + T *_array; + int _num; + int _max; + public: + virtual void realloc(int new_max) { + _max = new_max; + T *tmp = new T [_max]; + if (tmp == 0) return; + for (int i=0; i<_num; i++) { + tmp[i] = _array[i]; + } + delete [] _array; + _array = tmp; + } +}; + +int +main() +{ + ARRAY<str_ptr> tags; +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/crash5.C b/gcc/testsuite/g++.old-deja/g++.pt/crash5.C new file mode 100644 index 000000000..2c50dde5c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/crash5.C @@ -0,0 +1,12 @@ +// { dg-do assemble } + +template <class T, int i> +struct K { + void f(); +}; + +template <class T> +void +K<T, i>::f() // { dg-error "" } i has not been declared +{ +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/crash50.C b/gcc/testsuite/g++.old-deja/g++.pt/crash50.C new file mode 100644 index 000000000..02cf6c084 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/crash50.C @@ -0,0 +1,10 @@ +// { dg-do assemble } +// Origin: Mark Mitchell <mark@codesourcery.com> + +template <class T> +void f () +{ + __extension__ ( { if (3); }); +} + +template void f<int>(); diff --git a/gcc/testsuite/g++.old-deja/g++.pt/crash51.C b/gcc/testsuite/g++.old-deja/g++.pt/crash51.C new file mode 100644 index 000000000..a3fbc17f1 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/crash51.C @@ -0,0 +1,13 @@ +// { dg-do assemble } +// { dg-options "-fpermissive -w" } +// Origin: Mark Mitchell <mark@codesourcery.com> + +char foo[26]; + +template <class T> +void f () +{ + foo = "0123456789012345678901234"; // { dg-error "array" } +} + +template void f<int>(); diff --git a/gcc/testsuite/g++.old-deja/g++.pt/crash52.C b/gcc/testsuite/g++.old-deja/g++.pt/crash52.C new file mode 100644 index 000000000..f2c31672d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/crash52.C @@ -0,0 +1,25 @@ +// { dg-do assemble } +// Origin: Mark Mitchell <mark@codesourcery.com> + +template <class T> +struct S1 +{ + template <class U> + struct S2 + { + S2(U); + }; + + template <class U> + void f(U u) + { + S2<U> s2u(u); + } +}; + +void g() +{ + S1<int> s1; + s1.f(3.0); +} + diff --git a/gcc/testsuite/g++.old-deja/g++.pt/crash53.C b/gcc/testsuite/g++.old-deja/g++.pt/crash53.C new file mode 100644 index 000000000..909b86689 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/crash53.C @@ -0,0 +1,16 @@ +// { dg-do assemble } +// Origin: Mark Mitchell <mark@codesourcery.com> + +struct S +{ +}; + +S g (); + +template <class T> +void f () +{ + const S& s = g (); +} + +template void f<int>(); diff --git a/gcc/testsuite/g++.old-deja/g++.pt/crash54.C b/gcc/testsuite/g++.old-deja/g++.pt/crash54.C new file mode 100644 index 000000000..72f92d128 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/crash54.C @@ -0,0 +1,29 @@ +// { dg-do assemble } +// Origin: Mark Mitchell <mark@codesourcery.com> + +template <class T> +int g (T); + +int j = g (3); + +template <class T> +inline T f (T) +{ + return 2; +} + +template <class T> +struct S +{ + static const int i; +}; + +template <class T> +const int S<T>::i = f (3); + +template <class T> +int g (T) +{ + return S<double>::i; +} + diff --git a/gcc/testsuite/g++.old-deja/g++.pt/crash55.C b/gcc/testsuite/g++.old-deja/g++.pt/crash55.C new file mode 100644 index 000000000..57a6606fc --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/crash55.C @@ -0,0 +1,26 @@ +// { dg-do assemble } +// Origin: Jakub Jelinek <jakub@redhat.com> + +template<class T> struct foo { + foo(); + void c(); + static void d(foo* x) { x->c(); } +}; +template<class T> struct bar { + bar(); +}; +template <class T> struct baz { + typedef foo<T> t; + t *e; + baz(); + ~baz() { t::d(e); } +}; +template <class T> void foo<T>::c() +{ + bar<T>* x = (bar<T>*)this; + x->bar<T>::~bar(); +} +void a(void) +{ + baz<char> b; +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/crash56.C b/gcc/testsuite/g++.old-deja/g++.pt/crash56.C new file mode 100644 index 000000000..7de57426a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/crash56.C @@ -0,0 +1,19 @@ +// { dg-do assemble } +// +// Copyright (C) 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 1 Sep 2000 <nathan@codesourcery.com> + +// bug 127. We ICE'd when given a non-template TYPE_DECL as a template name. + +template <class charT> +class basic_string +{ +public: + typedef charT* iterator; + explicit basic_string (); + ~basic_string (); +}; + +void foo () { + basic_string<char>::iterator<char> p; // { dg-error "" } not a template // ERROR - no type +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/crash57.C b/gcc/testsuite/g++.old-deja/g++.pt/crash57.C new file mode 100644 index 000000000..eb6d61595 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/crash57.C @@ -0,0 +1,12 @@ +// { dg-do assemble } +// +// Copyright (C) 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 11 Aug 2000 <nathan@codesourcery.com> + +// bug 382. We ICE'd rather than decay to an address. + +struct A { +template <class T> static void f(T) {} +}; +void (*h)(int) = A::f<int>; +void (*i)(int) = &A::f<int>; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/crash58.C b/gcc/testsuite/g++.old-deja/g++.pt/crash58.C new file mode 100644 index 000000000..0ce3d8172 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/crash58.C @@ -0,0 +1,33 @@ +// { dg-do assemble } +// +// Copyright (C) 2000, 2002 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 5 Sept 2000 <nathan@codesourcery.com> + +// bug 147. We ICE'd on an unprocessed LOOKUP_EXPR during tsubsting + +namespace EManip { + template <class T> void do_assign(T* d); // { dg-error "" } candidate +} +template <class T> void do_assign(T* d); // { dg-error "" } candidate + +template <class T> +struct MatrixC +{ + void foo () { + EManip::do_assign<T> (0); + &EManip::do_assign<T>; // { dg-bogus "" } unresolved + &do_assign<T>; // { dg-bogus "" } unresolved + EManip::do_assign<T>; // { dg-bogus "" } unresolved + do_assign<T>; // { dg-bogus "" } unresolved + } +}; +void foo(MatrixC <double> *ptr) +{ + EManip::do_assign<double>; // { dg-bogus "" } unresolved + &EManip::do_assign<double>; // { dg-bogus "" } unresolved + ptr->foo (); + void (*p1) (int *) = &do_assign<double>; // { dg-error "" } cannot convert + void (*p2) (int *) = &EManip::do_assign<double>; // { dg-error "" } cannot convert + void (*p3) (int *) = &do_assign; + void (*p4) (int *) = &EManip::do_assign; +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/crash59.C b/gcc/testsuite/g++.old-deja/g++.pt/crash59.C new file mode 100644 index 000000000..37a2fc531 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/crash59.C @@ -0,0 +1,21 @@ +// { dg-do assemble } +// Copyright (C) 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 4 Oct 2000 <nathan@codesourcery.com> +// Origin: Bug 543 Gerald Pfeifer <pfeifer@dbai.tuwien.ac.at> + +// Bug 532. We failed to bail out when tsubsting a _DECL failed + +class ATOMSET +{ +}; + +template <class T> +void addConstsTo(const T &container) +{ +typename T::const_iterator l = 0; // { dg-error "" } no type const_iterator +} + +void tallyConstants() +{ +addConstsTo(ATOMSET()); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/crash6.C b/gcc/testsuite/g++.old-deja/g++.pt/crash6.C new file mode 100644 index 000000000..34bd56409 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/crash6.C @@ -0,0 +1,23 @@ +// { dg-do assemble } + +template <class T> class List; + +template <class T> +struct ListIterator +{ + ListIterator (); + ListIterator (const ListIterator<T>& rhs); +}; + +template <class T> +struct List +{ + void length () const { + for (ListIterator<T> li; li; ); // { dg-error "" } used where a `bool' + } +}; + +void test(List<int>& vals) +{ + vals.length(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/crash60.C b/gcc/testsuite/g++.old-deja/g++.pt/crash60.C new file mode 100644 index 000000000..893ac31cb --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/crash60.C @@ -0,0 +1,19 @@ +// { dg-do assemble } +// Copyright (C) 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 7 Nov 2000 <nathan@codesourcery.com> + +// We ICE'd rather than fail to instantiate. + +template< typename SID, class SDR > +void k( SID sid, SDR* p, // { dg-message "note" } + void (SDR::*) + ( typename SID::T ) ); + +struct E { }; +struct S { void f( int ); }; + +void f() +{ + k( E(), (S*)0, &S::f ); // { dg-error "" } no match + // { dg-message "candidate" "candidate note" { target *-*-* } 17 } +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/crash61.C b/gcc/testsuite/g++.old-deja/g++.pt/crash61.C new file mode 100644 index 000000000..212450429 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/crash61.C @@ -0,0 +1,30 @@ +// { dg-do assemble } +// Source: Neil Booth, from PR # 106. 4 Dec 2000. + +template <bool b> class bar +{ +}; + +class A_a +{ + public: + static const bool b = true; +}; + +class B_b +{ + public: + static const bool b = false; +}; + +template <class A, class B> class foo +{ +}; + +template <class A, class B> +bar<(A::b || B::b)> do_funky(const foo<A, B>&); + +int main() +{ + bar<true> a_bar = do_funky(foo<A_a, B_b>()); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/crash62.C b/gcc/testsuite/g++.old-deja/g++.pt/crash62.C new file mode 100644 index 000000000..b4b90e4c2 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/crash62.C @@ -0,0 +1,8 @@ +// { dg-do assemble } + +// Copyright (C) 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 5 Jan 2001 <nathan@codesourcery.com> + +// Bug 911, ICE on bogus template declaration + +template <class T> class A<T>; // { dg-error "" } not a template diff --git a/gcc/testsuite/g++.old-deja/g++.pt/crash63.C b/gcc/testsuite/g++.old-deja/g++.pt/crash63.C new file mode 100644 index 000000000..15d26b619 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/crash63.C @@ -0,0 +1,9 @@ +// { dg-do assemble } + +// Copyright (C) 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 10 Jan 2001 <nathan@codesourcery.com> + +// Bug 1585. We ICEd on a template template parm with no parms. + +template<template<class> class C> class B; +template<template<> class C> class D; // { dg-error "" } parse error diff --git a/gcc/testsuite/g++.old-deja/g++.pt/crash64.C b/gcc/testsuite/g++.old-deja/g++.pt/crash64.C new file mode 100644 index 000000000..d2457e858 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/crash64.C @@ -0,0 +1,24 @@ +// { dg-do assemble } + +// Copyright (C) 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 10 Jan 2001 <nathan@codesourcery.com> + +// Bug 1546. We ICE'd trying to unify an array of unknown bound, +// checking to see if it was a variable sized array. + +template <class _Tp> class allocator {}; + +template <class _Tp, class _Allocator> +struct _Alloc_traits +{ + static const bool _S_instanceless = false; +}; + +template <class _Tp, class _Tp1> +struct _Alloc_traits<_Tp, allocator<_Tp1> > +{ + static const bool _S_instanceless = true; +}; + +typedef char state []; +bool y = _Alloc_traits<state, allocator<state> >::_S_instanceless; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/crash65.C b/gcc/testsuite/g++.old-deja/g++.pt/crash65.C new file mode 100644 index 000000000..a7df70cec --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/crash65.C @@ -0,0 +1,12 @@ +// { dg-do assemble } + +// Copyright (C) 2000, 2002 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 11 Jan 2001 <nathan@codesourcery.com> + +// Bug 1506. We ICE'd on a struct definition inside a template parms. +// This is still not completely fixed, but now issues a diagnostic + + +template<class T = +struct W {}; // { dg-error "inside template parameter list|before" } +> struct S{}; // { dg-error "before" } diff --git a/gcc/testsuite/g++.old-deja/g++.pt/crash66.C b/gcc/testsuite/g++.old-deja/g++.pt/crash66.C new file mode 100644 index 000000000..cbcef1886 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/crash66.C @@ -0,0 +1,40 @@ +// { dg-do assemble } +// +// Copyright (C) 2001 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 7 May 2001 <nathan@codesourcery.com> + +// Bug 2525. We ICEd when a namespace scope template was erroneously +// given as a base member init. + +namespace N1 +{ + template<typename T> + struct B + { + B (T); + }; + + template<typename T> + struct D : B<T> + { + D (T r) + : B (r) // { dg-error "" } no field named B + {} + }; +} + +template<typename T> +struct D1 : N1::B<T> +{ + D1 (T r) + : N1::B<T> (r) + {} +}; + +template<typename T> +struct D2 : N1::B<T> +{ + D2 (T r) + : N1::B (r) // { dg-error "" } no field named N1::B + {} +}; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/crash67.C b/gcc/testsuite/g++.old-deja/g++.pt/crash67.C new file mode 100644 index 000000000..6325c7282 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/crash67.C @@ -0,0 +1,20 @@ +// { dg-do assemble } +// { dg-options "" } +// +// Copyright (C) 2001, 2003 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 6 May 2001 <nathan@codesourcery.com> + +// Bug 2526. We ICE'd after diagnosing dependent name confusion in +// friendliness when not being pedantic. + +template<typename T> +struct B +{ + typedef B<T> Mother; +}; + +template<typename T> +struct D : B<T> +{ + friend class Mother; +}; 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 000000000..9afeae09a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/crash68.C @@ -0,0 +1,71 @@ +// { dg-do assemble } +// { dg-prune-output "mangled name" } +// +// 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/crash7.C b/gcc/testsuite/g++.old-deja/g++.pt/crash7.C new file mode 100644 index 000000000..e575bca20 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/crash7.C @@ -0,0 +1,10 @@ +// { dg-do assemble } + +class foo +{ +}; + +template <class T : public foo> // { dg-error "" } base clause +struct bar +{ +}; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/crash8.C b/gcc/testsuite/g++.old-deja/g++.pt/crash8.C new file mode 100644 index 000000000..de2dd9dc7 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/crash8.C @@ -0,0 +1,34 @@ +// { dg-do assemble } + +template<class T> +class TestClass1 { +public: + TestClass1() { } +}; + +template<class T> +class TestClass2 { +public: + TestClass2() { } + T operator()(int) { } +}; + +template<class T> +void doit(T x) { + TestClass1<T> q1; + q1 = TestClass1<T>(); + TestClass2<T> q2; + q2 = TestClass2<T>(); + + TestClass1<T> p1; + p1 = TestClass1(); // { dg-error "" } template used as expression + + TestClass2<T> p2; + p2 = TestClass2(); // { dg-error "" } template used as expression +} + +int main() { + double x; + doit(x); +} + diff --git a/gcc/testsuite/g++.old-deja/g++.pt/crash9.C b/gcc/testsuite/g++.old-deja/g++.pt/crash9.C new file mode 100644 index 000000000..f2d811dda --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/crash9.C @@ -0,0 +1,11 @@ +// { dg-do assemble } + +template <class T> +void f(T) {} // { dg-error "initializing" } + +class C; // { dg-error "forward declaration" } + +void g(const C& c) +{ + f(c); // { dg-error "invalid use of incomplete type" } +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/ctor1.C b/gcc/testsuite/g++.old-deja/g++.pt/ctor1.C new file mode 100644 index 000000000..c711da62e --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/ctor1.C @@ -0,0 +1,10 @@ +// { dg-do assemble } + +template <typename _CharT> + struct moneypunct +{ + moneypunct (); +}; + +template <> + moneypunct<char>::moneypunct (); diff --git a/gcc/testsuite/g++.old-deja/g++.pt/ctor2.C b/gcc/testsuite/g++.old-deja/g++.pt/ctor2.C new file mode 100644 index 000000000..a8be91ddb --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/ctor2.C @@ -0,0 +1,13 @@ +// { dg-do assemble } +// Test for use of template parms in constructor name. +// Submitted by Jason Merrill <jason@cygnus.com> + +template <class T> +struct A { + A<T>(); +}; + +template <class T> +A<T>::A<T>() // { dg-error "constructor|qualified name" } +{ +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/debug1.C b/gcc/testsuite/g++.old-deja/g++.pt/debug1.C new file mode 100644 index 000000000..774634637 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/debug1.C @@ -0,0 +1,8 @@ +// { dg-do assemble } +// { dg-options "-g" } +// Origin: Jim Wilson <wilson@cygnus.com> + +template<template<class> class _Oper, + template<class, class> class _Meta1, + template<class, class> class _Meta2, + class _Dom1, class _Dom2> class _BinClos; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/decl1.C b/gcc/testsuite/g++.old-deja/g++.pt/decl1.C new file mode 100644 index 000000000..34b3b13f5 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/decl1.C @@ -0,0 +1,20 @@ +// { dg-do assemble } +struct S { + template <class T> + int f(T), g(T); // { dg-error "" } more than one declarator +}; + +template <class T> +void x(T), y(T); // { dg-error "" } more than one declarator + +template <class T> +struct S2 +{ + static int i, j; // OK. +}; + +template <class T> +int S2<T>::i, S2<T>::j; // { dg-error "" } more than one declarator + +template <> +int S2<int>::i, S2<double>::i; // { dg-error "" } more than one declarator diff --git a/gcc/testsuite/g++.old-deja/g++.pt/decl2.C b/gcc/testsuite/g++.old-deja/g++.pt/decl2.C new file mode 100644 index 000000000..b671213ad --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/decl2.C @@ -0,0 +1,7 @@ +// { dg-do assemble } + +// Simplified from testcase by Christophe Boyanique <boyan@imac.u-paris2.fr> + +template <class T> struct foo { foo(); }; +template<class T> foo<T>::foo() {} +T; // { dg-error "" } no type diff --git a/gcc/testsuite/g++.old-deja/g++.pt/decl3.C b/gcc/testsuite/g++.old-deja/g++.pt/decl3.C new file mode 100644 index 000000000..194d9a837 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/decl3.C @@ -0,0 +1,5 @@ +// { dg-do assemble } +// Origin: Jason Merrill <jason@cygnus.com> + +template <class T, class U = int> struct A; +template <class T = int, class U> struct A { }; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/decl4.C b/gcc/testsuite/g++.old-deja/g++.pt/decl4.C new file mode 100644 index 000000000..94f29391f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/decl4.C @@ -0,0 +1,7 @@ +// { dg-do assemble } + +// by Paul Burchard <burchard@pobox.com>, Level Set Systems, Inc. +// Copyright (C) 1999 Free Software Foundation + +typedef std::vector<int>::iterator iter; // { dg-error "" } syntax error before `::' + diff --git a/gcc/testsuite/g++.old-deja/g++.pt/deduct1.C b/gcc/testsuite/g++.old-deja/g++.pt/deduct1.C new file mode 100644 index 000000000..c48fa0808 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/deduct1.C @@ -0,0 +1,27 @@ +// { dg-do assemble } + +template<class CoordinateSystem, class MeshTag> +struct Mesh { }; + +struct RectGrid { }; + +struct RectMesh { }; + +struct Cartesian { }; + +template<class CS> +struct Mesh<CS, RectGrid> { }; + +template<class CS> +struct Mesh<CS, RectMesh> : public Mesh<CS, RectGrid> { }; + +template<class CS> +void foo(const Mesh<CS, RectGrid> &) +{ +} + +int main() +{ + Mesh<Cartesian, RectMesh> m; + foo(m); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/deduct2.C b/gcc/testsuite/g++.old-deja/g++.pt/deduct2.C new file mode 100644 index 000000000..5501f363d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/deduct2.C @@ -0,0 +1,21 @@ +// { dg-do assemble } +// +// Copyright (C) 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 5 Sept 2000 <nathan@codesourcery.com> + +// bug 79 & 59. We failed to tsubst non-type template parms which used +// (previously deduced) type parms. + +struct C {}; + +template< class T, T *G > struct S {}; +template< class T, T *G > void boz ( S<T,G> s1); + +C c1Gen; + +void foo () +{ + S< C, &c1Gen > s1; + + boz (s1); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/deduct3.C b/gcc/testsuite/g++.old-deja/g++.pt/deduct3.C new file mode 100644 index 000000000..b54c5a153 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/deduct3.C @@ -0,0 +1,22 @@ +// { dg-do assemble } + +// Copyright (C) 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 18 Jan 2001 <nathan@codesourcery.com> + +// Bug 1694. We complained during deduction, rather than reject the deduction. + +template <class T, T d> class X {}; + +template <class T> X<T,0> Foo (T *); +template <class T> int Foo (T const *); + +void Baz (int *p1, int const *p2) +{ + int i = Foo (p1); // { dg-error "" } cannot convert + int j = Foo (p2); +} +void Baz (float *p1, float const *p2) +{ + int i = Foo (p1); // ok, deduction fails on X<T,0> Foo (T *) + int j = Foo (p2); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/deduct4.C b/gcc/testsuite/g++.old-deja/g++.pt/deduct4.C new file mode 100644 index 000000000..02d6b2c31 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/deduct4.C @@ -0,0 +1,12 @@ +// { dg-do run } +// Test that we can deduce t even though T is deduced from a later argument. + +template <int I> struct A { }; + +template <class T, T t> void f (A<t> &, T) { } + +int main () +{ + A<42> a; + f (a, 24); +} 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 000000000..c29510772 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/deduct5.C @@ -0,0 +1,34 @@ +// { dg-do run } +// 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; + + 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 000000000..94c6c6600 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/deduct6.C @@ -0,0 +1,24 @@ +// { dg-do assemble } +// 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 000000000..99f96966c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/deduct7.C @@ -0,0 +1,15 @@ +// { dg-do run } +// 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/defarg.C b/gcc/testsuite/g++.old-deja/g++.pt/defarg.C new file mode 100644 index 000000000..833b98f06 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/defarg.C @@ -0,0 +1,11 @@ +// { dg-do run } +template <class T> +void f(T t, int i = 10); + +template <class T> +void f(T t, int i) {} + +int main() +{ + f(3); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/defarg10.C b/gcc/testsuite/g++.old-deja/g++.pt/defarg10.C new file mode 100644 index 000000000..bd830522b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/defarg10.C @@ -0,0 +1,11 @@ +// { dg-do assemble } +// Origin: Ian Nixon <ian@tharas.com> + +struct A {}; + +template<class M, class T = A, class C> class Tc {}; // { dg-error "" } no defarg + +int main () +{ + Tc<int> oops; // { dg-error "" } using template +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/defarg11.C b/gcc/testsuite/g++.old-deja/g++.pt/defarg11.C new file mode 100644 index 000000000..5f189b111 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/defarg11.C @@ -0,0 +1,5 @@ +// { dg-do assemble } +// Origin: Jason Merrill <jason@cygnus.com> + +template <class T, class U = int> struct A; +template <class T = int, class U> struct A; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/defarg12.C b/gcc/testsuite/g++.old-deja/g++.pt/defarg12.C new file mode 100644 index 000000000..8d1da09d0 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/defarg12.C @@ -0,0 +1,12 @@ +// { dg-do assemble } +// Origin: Mark Mitchell <mark@codesourcery.com> + +template <class T = int> +struct S +{ + void f () + { + struct U { + }; + } +}; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/defarg13.C b/gcc/testsuite/g++.old-deja/g++.pt/defarg13.C new file mode 100644 index 000000000..83539f50c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/defarg13.C @@ -0,0 +1,13 @@ +// { dg-do assemble } +// Origin: Mark Mitchell <mark@codesourcery.com> + +template <class T> +void f (int i) +{ + struct S { void g (int j = i) {} }; // { dg-error "" } default argument uses local + + S s; +} + +template void f<double>(int); + diff --git a/gcc/testsuite/g++.old-deja/g++.pt/defarg14.C b/gcc/testsuite/g++.old-deja/g++.pt/defarg14.C new file mode 100644 index 000000000..c4e206136 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/defarg14.C @@ -0,0 +1,18 @@ +// { dg-do assemble } + +// Origin: Larry Evans <jcampbell3@prodigy.net> + +// Bug: enum in default template arguments are not properly handled. + +enum Enum0 { E0, E1, E2 }; +enum Enum1 { E3=E2+1, E4=E3+1 }; + +template <Enum0 Out_FARG0> class OutTmpl +{ + public: + template <Enum0 In_FARG0, Enum1 In_FARG1=E4> class InTmpl + { + }; +}; + +OutTmpl<E1> m; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/defarg2.C b/gcc/testsuite/g++.old-deja/g++.pt/defarg2.C new file mode 100644 index 000000000..ff036f1f0 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/defarg2.C @@ -0,0 +1,18 @@ +// { dg-do run } +template <int S=0, class T=int> +struct X +{}; + +template <> +struct X<0,int> +{}; + +template <int S> +struct X<S,int> +: X<> +{}; + +int main() +{ + X<1,int> x; +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/defarg3.C b/gcc/testsuite/g++.old-deja/g++.pt/defarg3.C new file mode 100644 index 000000000..feb4eaeb2 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/defarg3.C @@ -0,0 +1,16 @@ +// { dg-do assemble } + +template <class T> +struct S; + +template <class T = int> +struct S {}; + +template <class T> +struct S; + +void f() +{ + S<> s; +} + diff --git a/gcc/testsuite/g++.old-deja/g++.pt/defarg4.C b/gcc/testsuite/g++.old-deja/g++.pt/defarg4.C new file mode 100644 index 000000000..ddc24c938 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/defarg4.C @@ -0,0 +1,32 @@ +// { dg-do assemble } + +template <class T> +struct S1 +{ + void foo(T = t()); + + static T t(); +}; + + +template <class T> +struct S2 +{ + void bar(); +}; + + +template <class T> +void S2<T>::bar () +{ + S1<T> st; + st.foo(); +} + + +int main() +{ + S2<int> s2i; + s2i.bar(); +} + diff --git a/gcc/testsuite/g++.old-deja/g++.pt/defarg5.C b/gcc/testsuite/g++.old-deja/g++.pt/defarg5.C new file mode 100644 index 000000000..661cb8ff4 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/defarg5.C @@ -0,0 +1,24 @@ +// { dg-do assemble } + +template <int dim> +class Point { + public: + Point (Point<dim> &); + Point<dim> & operator = (Point<dim> &); +}; + + + +template <int dim> +class bar{ + public: + void foo (Point<dim> p = Point<dim>()); +}; + + + +template <> +void bar<2>::foo (Point<2> p) { + const int dim = 2; + Point<dim> q = p; +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/defarg6.C b/gcc/testsuite/g++.old-deja/g++.pt/defarg6.C new file mode 100644 index 000000000..f5f7b7b22 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/defarg6.C @@ -0,0 +1,28 @@ +// { dg-do assemble } +// { dg-options "-std=gnu++98" } + +template <class T> +struct C { + template <class U> + void f(U); // OK + + template <class V = int> + struct I {}; // OK + + template <class W = int> + void h(W); // { dg-error "" } default argument + + template <class Y> + void k(Y); +}; + +template <class T> +template <class U = double> +void C<T>::f(U) {} // { dg-error "" } default argument + +template <class X = void*> +void g(X); // { dg-error "" } default argument + +template <class T = double> +template <class Y> +void C<T>::k(Y) {} // { dg-error "" } default argument diff --git a/gcc/testsuite/g++.old-deja/g++.pt/defarg7.C b/gcc/testsuite/g++.old-deja/g++.pt/defarg7.C new file mode 100644 index 000000000..5cf0286da --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/defarg7.C @@ -0,0 +1,11 @@ +// { dg-do assemble } + +template <int Dim, class T, class EngineTag> +class Engine {}; + +struct Brick; + +template<int Dim, class T = double , class EngineTag = Brick > +struct ConstArray { + static const int dimensions = Engine<Dim, T, EngineTag>::dimensions; +}; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/defarg8.C b/gcc/testsuite/g++.old-deja/g++.pt/defarg8.C new file mode 100644 index 000000000..a72e85c43 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/defarg8.C @@ -0,0 +1,17 @@ +// { dg-do assemble } + +// Default arguments containing more than one non-nested explicit +// template argument leads to parse error + +// This might be ill formed. See DR 325 (one proposed resolution is to make +// it so) + +template <class T> class foo1; +template <class T, class U> class foo2; + +struct bar { + template <class T, class U> + bar(int i = foo1<T>::baz, // { dg-bogus "" } - + int j = int(foo2<T, U>::baz), // ok + int k = foo2<T, U>::baz) {} // ok? +}; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/defarg9.C b/gcc/testsuite/g++.old-deja/g++.pt/defarg9.C new file mode 100644 index 000000000..2f0dbba8f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/defarg9.C @@ -0,0 +1,15 @@ +// { dg-do assemble } +// Origin: Mark Mitchell <mark@codesourcery.com> + +template <class T = int> +struct S +{ + void g () + { + } + + friend void f (double) + { + } +}; + diff --git a/gcc/testsuite/g++.old-deja/g++.pt/derived1.C b/gcc/testsuite/g++.old-deja/g++.pt/derived1.C new file mode 100644 index 000000000..aebb3d59a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/derived1.C @@ -0,0 +1,24 @@ +// { dg-do assemble } + +class A +{ +public: + typedef int Info; +}; + +template <class T> +class B : public A +{ +public: + typedef struct{ + int a; + int b; + } Info; +}; + +void f() +{ + B<A>::Info ie; + ie.a=1; + ie.b=2; +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/derived2.C b/gcc/testsuite/g++.old-deja/g++.pt/derived2.C new file mode 100644 index 000000000..7335369a2 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/derived2.C @@ -0,0 +1,35 @@ +// { dg-do assemble } +// { dg-options "" } + +template <typename T> +void f(T); +template <> +void f(int) {} + +struct B { + typedef int I; +}; + +template <typename T> +struct D1 : virtual public B { + typedef T I; +}; + + +template <typename T> +struct D : virtual public B, public D1<T> +{ + void g() + { + I i; + f(i); + } +}; + +int +main() +{ + D<double> d; + d.g(); +} + diff --git a/gcc/testsuite/g++.old-deja/g++.pt/derived3.C b/gcc/testsuite/g++.old-deja/g++.pt/derived3.C new file mode 100644 index 000000000..b0d1d3bb2 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/derived3.C @@ -0,0 +1,16 @@ +// { dg-do compile } + +// by Paul Burchard <burchard@pobox.com>, Level Set Systems, Inc. +// Copyright (C) 1999, 2002 Free Software Foundation + +template<class T> +class X { + class Y : public T // { dg-error "base type .* fails to be" } + { + }; + Y y; // { dg-message "instantiated" } +}; +int main() { + X<int> x; // { dg-message "instantiated" } +} + diff --git a/gcc/testsuite/g++.old-deja/g++.pt/dynarray.C b/gcc/testsuite/g++.old-deja/g++.pt/dynarray.C new file mode 100644 index 000000000..7376f9165 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/dynarray.C @@ -0,0 +1,22 @@ +// { dg-do assemble } +// { dg-options "" } +// Origin: Theo Papadopoulo <Theodore.Papadopoulo@sophia.inria.fr> + +inline const unsigned& f(unsigned const& a) { + return a; +} + +template <class T> +void +g(const unsigned n) +{ + double D[f(n)]; +} + +template <class T,class U> +void g(unsigned const int) { } + +int main() +{ + g<double>(18); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/ehspec1.C b/gcc/testsuite/g++.old-deja/g++.pt/ehspec1.C new file mode 100644 index 000000000..e75704e77 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/ehspec1.C @@ -0,0 +1,6 @@ +// { dg-do assemble } +// Bug: g++ forgets to instantiate A<int> +// Contributed by Jason Merrill <jason@cygnus.com> + +template <class T> struct A { }; +void f () throw (A<int>); diff --git a/gcc/testsuite/g++.old-deja/g++.pt/eichin01.C b/gcc/testsuite/g++.old-deja/g++.pt/eichin01.C new file mode 100644 index 000000000..435fecd64 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/eichin01.C @@ -0,0 +1,27 @@ +// { dg-do link } + +/* + + +*/ + + +template <class X> class TC { +public: + X aaa; + static X sss; + TC(X a) { aaa = a; } + TC(X a, X s) { aaa = a; sss = s; } + void sz(X s) { sss = s; } +}; + +template <> float TC<float>::sss = 0.0; +template <> long TC<long>::sss = 0; + +TC<long> xjj(1,2); + +int main(int,char**) { + TC<float> xff(9.9,3.14); + xjj.sz(123); + xff.sz(2.71828); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/eichin01a.C b/gcc/testsuite/g++.old-deja/g++.pt/eichin01a.C new file mode 100644 index 000000000..de9b1ba4a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/eichin01a.C @@ -0,0 +1,22 @@ +// { dg-do run } +template <class X> class TC { +public: + X aaa; + static X sss; + TC(X a) {aaa = a; } + TC(X a, X s) {aaa = a; sss = s; } + void sz(X s) { sss = s; } +}; + + +template <> long TC<long>::sss = 0; +template <> float TC<float>::sss = 0.0; + +TC<long> xjj(1,2); + +int main(int,char**) { + TC<float> xff(9.9,3.14); + xjj.sz(123); + xff.sz(2.71828); + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/eichin01b.C b/gcc/testsuite/g++.old-deja/g++.pt/eichin01b.C new file mode 100644 index 000000000..79902de69 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/eichin01b.C @@ -0,0 +1,22 @@ +// { dg-do run } +template <class X> class TC { +public: + X aaa; + static X sss; + TC(X a) {aaa = a; } + TC(X a, X s) {aaa = a; sss = s; } + void sz(X s) { sss = s; } + void syy(X syarg) { sss = syarg; } +}; + +template <> long TC<long>::sss = 0; +template <> float TC<float>::sss = 0.0; + +TC<long> xjj(1,2); + +int main(int,char**) { + TC<float> xff(9.9,3.14); + xjj.sz(123); + xff.sz(2.71828); + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/enum.C b/gcc/testsuite/g++.old-deja/g++.pt/enum.C new file mode 100644 index 000000000..f2192e794 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/enum.C @@ -0,0 +1,18 @@ +// { dg-do assemble } +// GROUPS passed enums +template<class T> +struct templ +{ + enum { val = 0 }; +}; +struct Foo +{ + enum { + bar = 0, + len = templ<int>::val + }; +}; +void func() +{ + int s = Foo::bar; // Ensure that expansion of templ did not erase bar +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/enum10.C b/gcc/testsuite/g++.old-deja/g++.pt/enum10.C new file mode 100644 index 000000000..b5cf3f3eb --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/enum10.C @@ -0,0 +1,12 @@ +// { dg-do assemble } + +template <class T> +struct S { + enum E { a = (int) T::b }; +}; + +struct S2 { + enum E2 { b }; +}; + +template class S<S2>; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/enum11.C b/gcc/testsuite/g++.old-deja/g++.pt/enum11.C new file mode 100644 index 000000000..d64fab2fc --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/enum11.C @@ -0,0 +1,10 @@ +// { dg-do assemble } + +template <class T> void f1() +{ + struct foo { enum T2 { + un, du, toi }; + }; +} + +void f2() { f1<int>(); } diff --git a/gcc/testsuite/g++.old-deja/g++.pt/enum12.C b/gcc/testsuite/g++.old-deja/g++.pt/enum12.C new file mode 100644 index 000000000..595954b91 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/enum12.C @@ -0,0 +1,16 @@ +// { dg-do assemble } + +template <int I> +struct S1 { }; + +template <class T> +struct S2 { + enum { x = 3 }; + + void f(S1<x>&); +}; + +template <class T> +void S2<T>::f(S1<x>&) +{ +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/enum13.C b/gcc/testsuite/g++.old-deja/g++.pt/enum13.C new file mode 100644 index 000000000..1c8364702 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/enum13.C @@ -0,0 +1,9 @@ +// { dg-do assemble } +// Origin: Theodore Papadopoulo <Theodore.Papadopoulo@sophia.inria.fr> + +template <typename T> +struct foo { + enum { A = 4 >= 4, B = (1 ? true : A) }; +}; + +foo<int> bar; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/enum14.C b/gcc/testsuite/g++.old-deja/g++.pt/enum14.C new file mode 100644 index 000000000..2405cc8f8 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/enum14.C @@ -0,0 +1,36 @@ +// { dg-do assemble } +// Copyright (C) 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 4 Oct 2000 <nathan@codesourcery.com> +// Origin: bug 511 malte.starostik@t-online.de + +// Bug 511. We failed to set access correctly for enumeration members of +// template classes + +template <class> +class A +{ + public: + enum foo {bar}; + typedef int baz; +}; + +struct C: public A<int> +{ + void choke (foo); + void choke (baz); +}; + +template <class> +struct B +{ + private: + enum foo {bar}; // { dg-error "" } private + typedef int baz; // { dg-error "" } private +}; + +struct D: public B<int> +{ + void choke (foo); // { dg-error "" } within this context + void choke (baz); // { dg-error "" } within this context +}; + diff --git a/gcc/testsuite/g++.old-deja/g++.pt/enum2.C b/gcc/testsuite/g++.old-deja/g++.pt/enum2.C new file mode 100644 index 000000000..c313970bb --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/enum2.C @@ -0,0 +1,17 @@ +// { dg-do assemble } + +struct U { + static int STATIC; +}; + +template <int* x> class FOO { +public: + enum { n = 0 }; +}; + +template <class A> class BAR { +public: + enum { n = FOO<&A::STATIC>::n }; +}; + +int n = BAR<U>::n; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/enum3.C b/gcc/testsuite/g++.old-deja/g++.pt/enum3.C new file mode 100644 index 000000000..2e43608db --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/enum3.C @@ -0,0 +1,15 @@ +// { dg-do run } +struct S { enum en { s0, s1, s2 }; }; + +template<typename S::en e> +int val( ) +{ + return e; +} + + +int main() +{ + return val<S::s0>( ); +} + diff --git a/gcc/testsuite/g++.old-deja/g++.pt/enum4.C b/gcc/testsuite/g++.old-deja/g++.pt/enum4.C new file mode 100644 index 000000000..6e9f1e090 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/enum4.C @@ -0,0 +1,16 @@ +// { dg-do assemble } + +template <class T> +struct U +{ + T mT; +}; + +template <class H> +struct M +{ + enum FLAG {On, Off}; + U<FLAG> mUF; +}; + +M<char> gm; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/enum5.C b/gcc/testsuite/g++.old-deja/g++.pt/enum5.C new file mode 100644 index 000000000..a7c5ea3e5 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/enum5.C @@ -0,0 +1,4 @@ +// { dg-do assemble } + +template <> +enum E {e}; // { dg-error "" } template declaration of enum diff --git a/gcc/testsuite/g++.old-deja/g++.pt/enum6.C b/gcc/testsuite/g++.old-deja/g++.pt/enum6.C new file mode 100644 index 000000000..254b48bc7 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/enum6.C @@ -0,0 +1,14 @@ +// { dg-do assemble } + +template <class T> +struct vector {}; + +template<class T> +void fn(T) +{ + enum tern { H, L, X, U }; + + vector<tern> ternvec; // { dg-error "" } composed from a local type +} + +template void fn(int); diff --git a/gcc/testsuite/g++.old-deja/g++.pt/enum7.C b/gcc/testsuite/g++.old-deja/g++.pt/enum7.C new file mode 100644 index 000000000..e81376124 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/enum7.C @@ -0,0 +1,28 @@ +// { dg-do run } +template <int I> +int f() +{ + enum E { a = I }; + + struct S { + int g() { + E e; + e = a; + return (int) e; + } + }; + + S s; + + return s.g(); +} + + +int main() +{ + if (f<7>() != 7) + return 1; + if (f<-3>() != -3) + return 1; + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/enum8.C b/gcc/testsuite/g++.old-deja/g++.pt/enum8.C new file mode 100644 index 000000000..e62428f2c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/enum8.C @@ -0,0 +1,18 @@ +// { dg-do assemble } + +template <int I> +void f(); + +template <> +void f<4>() {} + +template <class T> +struct S +{ + enum E { a = 1, b = a + 3 }; +}; + +int main() +{ + f<S<int>::b>(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/enum9.C b/gcc/testsuite/g++.old-deja/g++.pt/enum9.C new file mode 100644 index 000000000..9bb19da4e --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/enum9.C @@ -0,0 +1,13 @@ +// { dg-do assemble } + +template <typename _CharT> +class _Format_cache +{ +public: + enum { + _S_digits, _S_digits_end = _S_digits+10, + _S_xdigits = _S_digits_end + }; +}; + +template class _Format_cache<int>; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/error1.C b/gcc/testsuite/g++.old-deja/g++.pt/error1.C new file mode 100644 index 000000000..c94fd65d3 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/error1.C @@ -0,0 +1,19 @@ +// { dg-do assemble } +// Origin: Mark Mitchell <mark@codesourcery.com> + +template <class T> +struct S +{ + template <class U> + void f (); + +}; + +template <class T> +template <class U> +void S<T>::f () +{ + U& u; // { dg-error "" } uninitialized reference +} + +template void S<int>::f<double>(); diff --git a/gcc/testsuite/g++.old-deja/g++.pt/error2.C b/gcc/testsuite/g++.old-deja/g++.pt/error2.C new file mode 100644 index 000000000..6cb67ddec --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/error2.C @@ -0,0 +1,15 @@ +// { dg-do assemble } +// Origin: Carl Nygard <cnygard@bellatlantic.net> + +template <class RT> +class Test { +public: + Test(const RT& c = RT()) {} // { dg-error "reference to void" } +}; + +void f () +{ + Test<void> c; // { dg-message "instantiated" } +} + + diff --git a/gcc/testsuite/g++.old-deja/g++.pt/error3.C b/gcc/testsuite/g++.old-deja/g++.pt/error3.C new file mode 100644 index 000000000..a6588c9bf --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/error3.C @@ -0,0 +1,18 @@ +// { dg-do assemble } + +// Copyright (C) 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 10 Jan 2001 <nathan@codesourcery.com> + +// Bug 1606. We sorry'd issuing an error. + +struct A {}; +template <class T = A> class Tpl {}; + +struct B { + Tpl<int> s; +}; + +void foo (B *ptr) +{ + ptr->Tpl.t (); // { dg-error "" } template as expression +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/explarg1.C b/gcc/testsuite/g++.old-deja/g++.pt/explarg1.C new file mode 100644 index 000000000..b78b483a2 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/explarg1.C @@ -0,0 +1,22 @@ +// { dg-do run } +// Bug: g++ generates an error trying to generate the first foo<int>, when +// it should silently fail and go on to the next one. + +template<class T, typename U> class A { }; + +template<class T> void +foo(const A<T,typename T::N>&); + +template<typename T> +class B { }; + +template<typename T> void +foo(B<T> const &) { } + +int +main(void) +{ + B<int> sa; + + foo<int> (sa); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/explicit1.C b/gcc/testsuite/g++.old-deja/g++.pt/explicit1.C new file mode 100644 index 000000000..85997b3d6 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/explicit1.C @@ -0,0 +1,9 @@ +// { dg-do assemble } +// GROUPS passed templates +template <class T> +void foo(T t) {} + +void bar() +{ + (void (*)(double)) &foo<double>; +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/explicit10.C b/gcc/testsuite/g++.old-deja/g++.pt/explicit10.C new file mode 100644 index 000000000..b88dfd3b2 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/explicit10.C @@ -0,0 +1,10 @@ +// { dg-do assemble } +// { dg-options "-ansi -pedantic-errors -w" } +// GROUPS passed templates +template <class T> +void foo(T t); + +int main() +{ + foo<int>(3.0); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/explicit11.C b/gcc/testsuite/g++.old-deja/g++.pt/explicit11.C new file mode 100644 index 000000000..7f4d85fc2 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/explicit11.C @@ -0,0 +1,14 @@ +// { dg-do assemble } +// GROUPS passed templates +template <class T> +void foo(T t); + +template <class T> +struct S {}; + +int main() +{ + S<int> si; + + foo<S<int> >(si); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/explicit12.C b/gcc/testsuite/g++.old-deja/g++.pt/explicit12.C new file mode 100644 index 000000000..ac8b7c5aa --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/explicit12.C @@ -0,0 +1,20 @@ +// { dg-do link } +// { dg-options "-ansi -pedantic-errors -w" } +// GROUPS passed templates +template <class U> +struct S +{ + template <class T> + void foo(T t); +}; + + +template <> +template <> +void S<char*>::foo<int>(int) {} + +int main() +{ + S<char*> s; + s.foo<int>(3.0); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/explicit13.C b/gcc/testsuite/g++.old-deja/g++.pt/explicit13.C new file mode 100644 index 000000000..a0dbfaa60 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/explicit13.C @@ -0,0 +1,23 @@ +// { dg-do link } +// { dg-options "-ansi -pedantic-errors -w" } +// GROUPS passed templates + +template <class U> +struct S +{ + template <class T> + void foo(T t); + + template <class T> + void bar(T t) { this->template foo<U>(3.74); } +}; + +template <> +template <> +void S<int>::foo(int) { } + +int main() +{ + S<int> s; + s.bar(3); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/explicit14.C b/gcc/testsuite/g++.old-deja/g++.pt/explicit14.C new file mode 100644 index 000000000..132845d85 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/explicit14.C @@ -0,0 +1,14 @@ +// { dg-do assemble } +// GROUPS passed templates +template <class T> +struct S +{ + template <class U> + typename U::R foo(U u); +}; + + +void bar() +{ + S<int> si; +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/explicit15.C b/gcc/testsuite/g++.old-deja/g++.pt/explicit15.C new file mode 100644 index 000000000..e3d598b0e --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/explicit15.C @@ -0,0 +1,30 @@ +// { dg-do assemble } +// GROUPS passed templates +template<int N_rank> +class Array; + + +template<class T> +class ArraySectionInfo { +public: + enum { rank = 0 }; +}; + + +template<class T1> +class SliceInfo { +public: + enum { + rank = ArraySectionInfo<T1>::rank + }; + + typedef Array<rank> T_slice; +}; + +template<class T2> +typename SliceInfo<T2>::T_slice +foo(T2 r2) +{ + return SliceInfo<T2>::T_slice(); +} + diff --git a/gcc/testsuite/g++.old-deja/g++.pt/explicit16.C b/gcc/testsuite/g++.old-deja/g++.pt/explicit16.C new file mode 100644 index 000000000..6ae273a14 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/explicit16.C @@ -0,0 +1,28 @@ +// { dg-do assemble } +// GROUPS passed templates +template<int N_rank> +class Array; + + +template<class T> +class ArraySectionInfo { +public: + enum { rank = 0 }; +}; + + +template<class T1> +class SliceInfo { +public: + static const int rank = ArraySectionInfo<T1>::rank; + + typedef Array<rank> T_slice; +}; + +template<class T2> +typename SliceInfo<T2>::T_slice +foo(T2 r2) +{ + return SliceInfo<T2>::T_slice(); +} + diff --git a/gcc/testsuite/g++.old-deja/g++.pt/explicit17.C b/gcc/testsuite/g++.old-deja/g++.pt/explicit17.C new file mode 100644 index 000000000..9a83fb0c4 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/explicit17.C @@ -0,0 +1,23 @@ +// { dg-do assemble } +// { dg-options "-ansi -pedantic-errors -w" } +// GROUPS passed templates +template <class T, class U> +void foo(U u, T t); + +template <class T> +void foo(T t); + +template <class T> +struct S {}; + +template <class T> +void foo(const S<T>&); + +void bar() +{ + void (*fn)(double, int) = + (void (*)(double, int)) &foo<int>; + void (*fn2)(double) = foo<double>; + foo<int>(3, 3.0); + foo<int>(S<int>()); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/explicit18.C b/gcc/testsuite/g++.old-deja/g++.pt/explicit18.C new file mode 100644 index 000000000..fff27f001 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/explicit18.C @@ -0,0 +1,12 @@ +// { dg-do link } +// { dg-options "-ansi -pedantic-errors -w" } +// GROUPS passed templates +template <class T> +int foo(T t) { return 0; } + +int foo(int i); + +int main() +{ + return foo<int>(3.0); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/explicit19.C b/gcc/testsuite/g++.old-deja/g++.pt/explicit19.C new file mode 100644 index 000000000..053629ad7 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/explicit19.C @@ -0,0 +1,13 @@ +// { dg-do link } +// { dg-options "-ansi -pedantic-errors -w" } +// GROUPS passed templates +template <class T> +int foo(T t); + +template <> +int foo<int>(int i) { return 0; } + +int main() +{ + return foo<int>(3.0); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/explicit2.C b/gcc/testsuite/g++.old-deja/g++.pt/explicit2.C new file mode 100644 index 000000000..14d9f4674 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/explicit2.C @@ -0,0 +1,9 @@ +// { dg-do assemble } +// GROUPS passed templates +template <class T> +void foo(T t) {} + +void bar() +{ + (void (*)(int)) (void (*)(double)) &foo<double>; +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/explicit20.C b/gcc/testsuite/g++.old-deja/g++.pt/explicit20.C new file mode 100644 index 000000000..a3feaa697 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/explicit20.C @@ -0,0 +1,7 @@ +// { dg-do assemble } +// GROUPS passed templates +template <class T> +T foo(T t); + +template <> +int foo<char>(char c); // { dg-error "" } does not match any template declaration diff --git a/gcc/testsuite/g++.old-deja/g++.pt/explicit21.C b/gcc/testsuite/g++.old-deja/g++.pt/explicit21.C new file mode 100644 index 000000000..8d22f3ec2 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/explicit21.C @@ -0,0 +1,10 @@ +// { dg-do assemble } +// GROUPS passed templates +template <class T> +T foo(T* t); + +template <> +int foo<char>(char c); // { dg-error "" } does not match declaration. + +template <> +int bar<char>(); // { dg-error "" } no template bar. diff --git a/gcc/testsuite/g++.old-deja/g++.pt/explicit22.C b/gcc/testsuite/g++.old-deja/g++.pt/explicit22.C new file mode 100644 index 000000000..49b4f748e --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/explicit22.C @@ -0,0 +1,10 @@ +// { dg-do assemble } +// GROUPS passed templates +template <class T, class U> +T foo(T t, U* u); + +template <class T> +T foo(T t, T* u); + +template <> +int foo<int>(int, int*); diff --git a/gcc/testsuite/g++.old-deja/g++.pt/explicit23.C b/gcc/testsuite/g++.old-deja/g++.pt/explicit23.C new file mode 100644 index 000000000..bf6a52632 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/explicit23.C @@ -0,0 +1,13 @@ +// { dg-do link } +// { dg-options "-ansi -pedantic-errors -w" } +// GROUPS passed templates +template <class T> +int foo(T t) { return 1; } + +template <> +int foo<int>(int i) { return 0; } + +int main() +{ + return foo<int>(3.0); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/explicit24.C b/gcc/testsuite/g++.old-deja/g++.pt/explicit24.C new file mode 100644 index 000000000..855422b7e --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/explicit24.C @@ -0,0 +1,7 @@ +// { dg-do assemble } +// GROUPS passed templates +template <class T> +int foo(T t); + +int foo<int>(int i) { return 0; } // { dg-error "" } missing template <> + diff --git a/gcc/testsuite/g++.old-deja/g++.pt/explicit25.C b/gcc/testsuite/g++.old-deja/g++.pt/explicit25.C new file mode 100644 index 000000000..0175d9f4f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/explicit25.C @@ -0,0 +1,13 @@ +// { dg-do assemble } +// GROUPS passed templates +template <int I> +class S {}; + +template <int I, class T> +void foo(T t, S<I>); + +void bar() +{ + S<3> s3; + foo<3>("abc", s3); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/explicit26.C b/gcc/testsuite/g++.old-deja/g++.pt/explicit26.C new file mode 100644 index 000000000..ba50fac1c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/explicit26.C @@ -0,0 +1,12 @@ +// { dg-do link } +// GROUPS passed templates +template <class T> +int foo(T t) { return 1; } + +template <> +int foo(int i) { return 0; } + +int main() +{ + (int (*)(int)) &foo<int>; +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/explicit27.C b/gcc/testsuite/g++.old-deja/g++.pt/explicit27.C new file mode 100644 index 000000000..368510513 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/explicit27.C @@ -0,0 +1,12 @@ +// { dg-do link } +// GROUPS passed templates +template <class T> +void foo(T t); + +template <> +void foo(int i) {} + +int main() +{ + (void (*)(int)) &foo<int>; +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/explicit28.C b/gcc/testsuite/g++.old-deja/g++.pt/explicit28.C new file mode 100644 index 000000000..79d8dd01d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/explicit28.C @@ -0,0 +1,12 @@ +// { dg-do link } +// GROUPS passed templates +template <class T> +int foo(T t) { return 1; } + +template <> +int foo(int i) { return 0; } + +int main() +{ + return (*((int (*)(int)) &foo<int>))(3); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/explicit29.C b/gcc/testsuite/g++.old-deja/g++.pt/explicit29.C new file mode 100644 index 000000000..b402cd3c3 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/explicit29.C @@ -0,0 +1,12 @@ +// { dg-do link } +// GROUPS passed templates +template <class T> +int foo(T) { return 0; } + +int foo(int); + +int main() +{ + return foo<int>(3); +} + diff --git a/gcc/testsuite/g++.old-deja/g++.pt/explicit3.C b/gcc/testsuite/g++.old-deja/g++.pt/explicit3.C new file mode 100644 index 000000000..ef3e1b4c1 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/explicit3.C @@ -0,0 +1,9 @@ +// { dg-do assemble } +// GROUPS passed templates +template <class T, class U> +void foo(T t, U u) {} + +void bar() +{ + (void (*)(double, int)) &foo<double>; +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/explicit30.C b/gcc/testsuite/g++.old-deja/g++.pt/explicit30.C new file mode 100644 index 000000000..d9b51b885 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/explicit30.C @@ -0,0 +1,11 @@ +// { dg-do assemble } +// GROUPS passed templates +template <class T> +void foo(T, T*); + + +void bar() +{ + double d; + (*((void (*)(int, double*)) (void (*)(int, int*)) &foo<int>))(3, &d); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/explicit31.C b/gcc/testsuite/g++.old-deja/g++.pt/explicit31.C new file mode 100644 index 000000000..e4f6a5b13 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/explicit31.C @@ -0,0 +1,17 @@ +// { dg-do link } +// { dg-options "-ansi -pedantic-errors -w" } +// GROUPS passed templates +template <class T> +struct S +{ + template <class U> + static double foo(U u) { return (double) u; } +}; + + +int main() +{ + double d = S<int>::foo<char>(3.3); + + return (d >= 3.1); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/explicit32.C b/gcc/testsuite/g++.old-deja/g++.pt/explicit32.C new file mode 100644 index 000000000..e8e496fe3 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/explicit32.C @@ -0,0 +1,25 @@ +// { dg-do assemble } +// GROUPS passed templates +template <class T> +struct S +{ +}; + + +template <> +struct S<int> +{ + void foo(); +}; + + +void S<int>::foo() +{ +} + + +void bar() +{ + S<int> si; + si.foo(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/explicit33.C b/gcc/testsuite/g++.old-deja/g++.pt/explicit33.C new file mode 100644 index 000000000..c6f5472c3 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/explicit33.C @@ -0,0 +1,9 @@ +// { dg-do assemble } +// GROUPS passed templates +template <class T> +void foo(T t); + +template <> +void foo(int) {} + +void foo(int) {} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/explicit34.C b/gcc/testsuite/g++.old-deja/g++.pt/explicit34.C new file mode 100644 index 000000000..ea32cf6ea --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/explicit34.C @@ -0,0 +1,11 @@ +// { dg-do assemble } +// { dg-options "-fshow-column" } +// GROUPS passed templates +template <class T> +void foo(T t); + +template <> +void foo(int) {}; // { dg-error "6:previously declared here" } + +template <> +void foo<int>(int) {} // { dg-error "6:redefinition" } diff --git a/gcc/testsuite/g++.old-deja/g++.pt/explicit35.C b/gcc/testsuite/g++.old-deja/g++.pt/explicit35.C new file mode 100644 index 000000000..f174e8f9d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/explicit35.C @@ -0,0 +1,17 @@ +// { dg-do link } +// { dg-options "-ansi -pedantic-errors -w" } +// GROUPS passed templates +struct S +{ + template <class T> + void foo(T t); +}; + +template <> +void S::foo<int>(int i) { } + +int main() +{ + S s; + s.foo<int>(3.0); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/explicit36.C b/gcc/testsuite/g++.old-deja/g++.pt/explicit36.C new file mode 100644 index 000000000..4a4f63668 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/explicit36.C @@ -0,0 +1,24 @@ +// { dg-do link } +// GROUPS passed templates +template <class T> +void foo(T); + +class S { + friend void foo<>(int); + + int i; +}; + + +template <> +void foo(int) +{ + S s; + s.i = 3; +} + + +int main() +{ + foo(3); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/explicit37.C b/gcc/testsuite/g++.old-deja/g++.pt/explicit37.C new file mode 100644 index 000000000..f3d9f64d6 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/explicit37.C @@ -0,0 +1,23 @@ +// { dg-do link } +// GROUPS passed templates +class ostream {}; + +template <class T> +class S; + +template <class T> +void operator<<(ostream&, S<T>) {} + +template <class T> +class S +{ + friend void operator<<<>(ostream&, const S<T>); +}; + + +int main() +{ + ostream o; + + o << S<int>(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/explicit38.C b/gcc/testsuite/g++.old-deja/g++.pt/explicit38.C new file mode 100644 index 000000000..1831e45a3 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/explicit38.C @@ -0,0 +1,9 @@ +// { dg-do assemble } +template <int I> +void f(int j); // { dg-message "note" } + +void g() +{ + f<7, 12>(3); // { dg-error "" } no matching function. + // { dg-message "candidate" "candidate note" { target *-*-* } 7 } +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/explicit39.C b/gcc/testsuite/g++.old-deja/g++.pt/explicit39.C new file mode 100644 index 000000000..995d8c075 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/explicit39.C @@ -0,0 +1,9 @@ +// { dg-do assemble } +template <class T> +void f(int i); // { dg-message "note" } + +void g() +{ + f<7>(3); // { dg-error "" } no matching function. + // { dg-message "candidate" "candidate note" { target *-*-* } 7 } +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/explicit4.C b/gcc/testsuite/g++.old-deja/g++.pt/explicit4.C new file mode 100644 index 000000000..f7e19d201 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/explicit4.C @@ -0,0 +1,19 @@ +// { dg-do assemble } +// GROUPS passed templates +template <class T> +void foo(T t); + +template <class T> +struct S {}; + +template <class T> +void bar(T t) +{ + void (*f)(S<T> ) = &foo<S<T> >; +} + + +void baz() +{ + bar(3); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/explicit40.C b/gcc/testsuite/g++.old-deja/g++.pt/explicit40.C new file mode 100644 index 000000000..71807b365 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/explicit40.C @@ -0,0 +1,28 @@ +// { dg-do run } +extern "C" void abort(); + +template <void* P> +void f(int j); + +template <unsigned int I> +void f(int j); + + +template <void* P> +void f(int j) +{ + abort(); +} + + +template <unsigned int I> +void f(int j) +{ +} + + +int main() +{ + f<3>(7); +} + diff --git a/gcc/testsuite/g++.old-deja/g++.pt/explicit41.C b/gcc/testsuite/g++.old-deja/g++.pt/explicit41.C new file mode 100644 index 000000000..560370a8b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/explicit41.C @@ -0,0 +1,10 @@ +// { dg-do assemble } +template <int I> +void f(int i); // { dg-message "note" } + +void g() +{ + int i; + f<i>(7); // { dg-error "" } template argument 1 is invalid. + // { dg-message "candidate" "candidate note" { target *-*-* } 8 } +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/explicit42.C b/gcc/testsuite/g++.old-deja/g++.pt/explicit42.C new file mode 100644 index 000000000..770fbbeea --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/explicit42.C @@ -0,0 +1,18 @@ +// { dg-do run } +extern "C" void abort(void); + +template <int I> +void f(int i) +{ +} + +template <void*> +void f(int i) +{ + abort(); +} + +int main() +{ + f<0>(3); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/explicit43.C b/gcc/testsuite/g++.old-deja/g++.pt/explicit43.C new file mode 100644 index 000000000..199bcc137 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/explicit43.C @@ -0,0 +1,24 @@ +// { dg-do run } +extern "C" void abort(void); + +void F(int) +{ +} + + +void F(double) +{ + abort(); +} + +template <void (*F)(int)> +void g() +{ + (*F)(3); +} + + +int main() +{ + g<&F>(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/explicit5.C b/gcc/testsuite/g++.old-deja/g++.pt/explicit5.C new file mode 100644 index 000000000..26b549088 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/explicit5.C @@ -0,0 +1,19 @@ +// { dg-do assemble } +// GROUPS passed templates +template <class T> +void foo(T t) {} + +template <class T> +struct S {}; + +template <class T> +void bar(T t) +{ + void (*f)(S<T> ) = &foo<S<T> >; +} + + +void baz() +{ + bar(3); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/explicit50.C b/gcc/testsuite/g++.old-deja/g++.pt/explicit50.C new file mode 100644 index 000000000..4f11eda6e --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/explicit50.C @@ -0,0 +1,16 @@ +// { dg-do run } +extern "C" void abort (); + +template <class T> int f () +{ + return sizeof(T); +} + +int main () +{ + if (f<long> () != sizeof(long) + || f<char> () != sizeof(char) + || f<long> () != sizeof(long) + || f<long int> () != sizeof(long int)) + abort (); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/explicit51.C b/gcc/testsuite/g++.old-deja/g++.pt/explicit51.C new file mode 100644 index 000000000..dbac95523 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/explicit51.C @@ -0,0 +1,19 @@ +// { dg-do run } +extern "C" void abort (); + +template <int a> int fact () +{ + return 0; +} + +template <> int fact<1> () +{ + return 1; +} + +int main() +{ + if (fact<3> () != 0 || fact<1> () != 1 + || fact<3> () != 0 || fact<1> () != 1 || fact<1+0> () != 1) + abort (); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/explicit52.C b/gcc/testsuite/g++.old-deja/g++.pt/explicit52.C new file mode 100644 index 000000000..71182714c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/explicit52.C @@ -0,0 +1,19 @@ +// { dg-do run } +extern "C" void abort (); + +template <int a> inline int fact () +{ + return a * fact<a-1> (); +} + +template <> inline int fact<1> () +{ + return 1; +} + +int main() +{ + if (fact<3> () != 6 || fact<1> () != 1 + || fact<3> () != 6 || fact<1> () != 1 || fact<1+0> () != 1) + abort (); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/explicit53.C b/gcc/testsuite/g++.old-deja/g++.pt/explicit53.C new file mode 100644 index 000000000..29c970397 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/explicit53.C @@ -0,0 +1,22 @@ +// { dg-do run } +extern "C" void abort (); + +template <int a> inline int fact (); +template <> inline int fact<1> (); + +template <int a> inline int fact () +{ + return a * fact<a-1> (); +} + +template <> inline int fact<1> () +{ + return 1; +} + +int main() +{ + if (fact<3> () != 6 || fact<1> () != 1 + || fact<3> () != 6 || fact<1> () != 1 || fact<1+0> () != 1) + abort (); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/explicit54.C b/gcc/testsuite/g++.old-deja/g++.pt/explicit54.C new file mode 100644 index 000000000..71d8d9356 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/explicit54.C @@ -0,0 +1,36 @@ +// { dg-do run } +extern "C" void abort (); + +template <int a> inline int fact2 (); + +template <int a> inline int fact () +{ + return a * fact2<a-1> (); +} + +template <> inline int fact<1> () +{ + return 1; +} + +template <int a> inline int fact2 () +{ + return a*fact<a-1>(); +} + +template <> inline int fact2<1> () +{ + return 1; +} + +int main() +{ + if (fact<3> () != 6 || fact<1> () != 1 + || fact<3> () != 6 || fact<1> () != 1 || fact<1+0> () != 1) + abort (); + if (fact2<3> () != 6 || fact2<1> () != 1 + || fact2<3> () != 6 || fact2<1> () != 1 || fact2<1+0> () != 1) + abort (); + if (fact2<4> () != 24 || fact<4> () != 24) + abort (); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/explicit55.C b/gcc/testsuite/g++.old-deja/g++.pt/explicit55.C new file mode 100644 index 000000000..c71f9d440 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/explicit55.C @@ -0,0 +1,15 @@ +// { dg-do run } +template <class T> T* create () +{ + return new T; +} + +template <class T> T* create2() +{ + return create<T>(); +} + +int main() +{ + int *p = create2<int>(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/explicit56.C b/gcc/testsuite/g++.old-deja/g++.pt/explicit56.C new file mode 100644 index 000000000..f3e3ed30b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/explicit56.C @@ -0,0 +1,17 @@ +// { dg-do run } +template <class T> T* create (); + +template <class T> T* create2() +{ + return create<T>(); +} + +template <class T> T* create () +{ + return new T; +} + +int main() +{ + int *p = create2<int>(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/explicit57.C b/gcc/testsuite/g++.old-deja/g++.pt/explicit57.C new file mode 100644 index 000000000..ba841021e --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/explicit57.C @@ -0,0 +1,43 @@ +// { dg-do run } +extern "C" void abort (); + +int a = 0; + +template <class T> void f (); +template <class T> void g () +{ + if (a) + abort (); +} + +template <> void g<char> () +{ +} + +template <class T> class C +{ + public: + void ff () { f<T> (); } + void gg () { g<T> (); } +}; + +template <class T> void f () +{ + if (a) + abort (); +} + +template <> void f<char> () +{ +} + +int main () +{ + C<int> c; + c.ff(); + c.gg(); + a = 1; + C<char> d; + d.ff(); + d.gg(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/explicit58.C b/gcc/testsuite/g++.old-deja/g++.pt/explicit58.C new file mode 100644 index 000000000..72f012165 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/explicit58.C @@ -0,0 +1,42 @@ +// { dg-do run } +extern "C" void abort (); + +template <class T> void f (); +template <class T> void g () +{ + abort (); +} + +template <> void g<char> () +{ + abort (); +} + +template <class T> class C +{ + public: + template <class U> void f () {} + template <class U> void g () {} + void ff () { f<T> (); } + void gg () { g<T> (); } +}; + +template <class T> void f () +{ + abort (); +} + +template <> void f<char> () +{ + abort (); +} + +int main () +{ + C<int> c; + c.ff(); + c.gg(); + C<char> d; + d.ff(); + d.gg(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/explicit59.C b/gcc/testsuite/g++.old-deja/g++.pt/explicit59.C new file mode 100644 index 000000000..24c0e1586 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/explicit59.C @@ -0,0 +1,42 @@ +// { dg-do run } +extern "C" void abort (); + +template <class T> void f (); +template <class T> void g () +{ + abort (); +} + +template <> void g<char> () +{ + abort (); +} + +template <class T> class C +{ + public: + void ff () { f<T> (); } + void gg () { g<T> (); } + template <class U> void f () {} + template <class U> void g () {} +}; + +template <class T> void f () +{ + abort (); +} + +template <> void f<char> () +{ + abort (); +} + +int main () +{ + C<int> c; + c.ff(); + c.gg(); + C<char> d; + d.ff(); + d.gg(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/explicit6.C b/gcc/testsuite/g++.old-deja/g++.pt/explicit6.C new file mode 100644 index 000000000..ea1f97a74 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/explicit6.C @@ -0,0 +1,13 @@ +// { dg-do link } +// { dg-options "-ansi -pedantic-errors -w" } +// GROUPS passed templates +template <class T> +int foo(T t); + +template <> +int foo(int i) { return 0; } + +int main() +{ + return foo<int>(3.0); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/explicit60.C b/gcc/testsuite/g++.old-deja/g++.pt/explicit60.C new file mode 100644 index 000000000..7b1f958b7 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/explicit60.C @@ -0,0 +1,44 @@ +// { dg-do run } +extern "C" void abort (); + +template <class T> void f (); +template <class T> void g () +{ + abort (); +} + +template <> void g<char> () +{ + abort (); +} + +template <class T> class C +{ + public: + void ff () { f<T> (); } + void gg () { g<T> (); } + template <class U> void f () {} + template <class U> void g () {} + template <class U> void f (int) { abort(); } + template <class U> void g (int) { abort(); } +}; + +template <class T> void f () +{ + abort (); +} + +template <> void f<char> () +{ + abort (); +} + +int main () +{ + C<int> c; + c.ff(); + c.gg(); + C<char> d; + d.ff(); + d.gg(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/explicit61.C b/gcc/testsuite/g++.old-deja/g++.pt/explicit61.C new file mode 100644 index 000000000..73f83a478 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/explicit61.C @@ -0,0 +1,44 @@ +// { dg-do run } +extern "C" void abort (); + +template <class T> void f (); +template <class T> void g () +{ + abort (); +} + +template <> void g<char> () +{ + abort (); +} + +template <class T> class C +{ + public: + void ff () { f<T> (0); } + void gg () { g<T> (1); } + template <class U> void f () { abort(); } + template <class U> void g () { abort(); } + template <class U> void f (int) {} + template <class U> void g (int) {} +}; + +template <class T> void f () +{ + abort (); +} + +template <> void f<char> () +{ + abort (); +} + +int main () +{ + C<int> c; + c.ff(); + c.gg(); + C<char> d; + d.ff(); + d.gg(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/explicit62.C b/gcc/testsuite/g++.old-deja/g++.pt/explicit62.C new file mode 100644 index 000000000..534b4ec92 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/explicit62.C @@ -0,0 +1,20 @@ +// { dg-do run } +extern "C" void abort (); + +template <class T> void f () +{ +} + + +template <class T> class C +{ + friend void f<char> (); + public: + void ff () { f<char> (); } +}; + +int main () +{ + C<int> c; + c.ff(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/explicit63.C b/gcc/testsuite/g++.old-deja/g++.pt/explicit63.C new file mode 100644 index 000000000..46751a69d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/explicit63.C @@ -0,0 +1,20 @@ +// { dg-do run } +extern "C" void abort (); + +template <class T> void f () +{ +} + + +template <class T> class C +{ + friend void f<T> (); + public: + void ff () { f<T> (); } +}; + +int main () +{ + C<int> c; + c.ff(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/explicit64.C b/gcc/testsuite/g++.old-deja/g++.pt/explicit64.C new file mode 100644 index 000000000..63a05f66d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/explicit64.C @@ -0,0 +1,24 @@ +// { dg-do run } +extern "C" void abort (); + +template <class T> void f () +{ + abort (); +} + +template <> void f<char> () +{ +} + +template <class T> class C +{ + friend void f<char> (); + public: + void ff () { f<char> (); } +}; + +int main () +{ + C<int> c; + c.ff(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/explicit65.C b/gcc/testsuite/g++.old-deja/g++.pt/explicit65.C new file mode 100644 index 000000000..20cda6384 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/explicit65.C @@ -0,0 +1,34 @@ +// { dg-do run } +extern "C" void abort (); + +template <class T> void f () +{ + abort (); +} + +template <> void f<char> () +{ + abort (); +} + +template <class T> void f (int) +{ + abort (); +} + +template <> void f<char> (int) +{ +} + +template <class T> class C +{ + friend void f<char> (int); + public: + void ff () { f<char> (0); } +}; + +int main () +{ + C<int> c; + c.ff(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/explicit66.C b/gcc/testsuite/g++.old-deja/g++.pt/explicit66.C new file mode 100644 index 000000000..2745cce34 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/explicit66.C @@ -0,0 +1,12 @@ +// { dg-do run } +void f(int) {} +void f(double); + +template <void (*fn)(int)> +void foo() {} + +int main() +{ + foo<f>(); +} + diff --git a/gcc/testsuite/g++.old-deja/g++.pt/explicit67.C b/gcc/testsuite/g++.old-deja/g++.pt/explicit67.C new file mode 100644 index 000000000..c0863a072 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/explicit67.C @@ -0,0 +1,23 @@ +// { dg-do assemble } +struct S +{ + void f(int); + void f(double); +}; + +void g(int); +void g(double); + +template <int* IP> +void foo(); // { dg-message "note" } +template <long l> +void foo(); // { dg-message "note" } + +void bar() +{ + foo<S::f>(); // { dg-error "" } no matching function + // { dg-message "candidate" "candidate note" { target *-*-* } 18 } + foo<g>(); // { dg-error "" } no matching function + // { dg-message "candidate" "candidate note" { target *-*-* } 20 } + +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/explicit68.C b/gcc/testsuite/g++.old-deja/g++.pt/explicit68.C new file mode 100644 index 000000000..efbf0ff52 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/explicit68.C @@ -0,0 +1,24 @@ +// { dg-do assemble } + +template <bool B> +struct S +{ + static void g(); +}; + +template <bool B> +void g(); + +template<unsigned Length> +void f() +{ + const bool b = true; + g<b>(); + const bool b1 = (Length == 2); + S<b1>::g(); +} + +void h() +{ + f<3>(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/explicit69.C b/gcc/testsuite/g++.old-deja/g++.pt/explicit69.C new file mode 100644 index 000000000..7742e6125 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/explicit69.C @@ -0,0 +1,2 @@ +// { dg-do assemble } +template class x {}; // { dg-error "" } not a template instantiation diff --git a/gcc/testsuite/g++.old-deja/g++.pt/explicit70.C b/gcc/testsuite/g++.old-deja/g++.pt/explicit70.C new file mode 100644 index 000000000..5724f6d7d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/explicit70.C @@ -0,0 +1,44 @@ +// { dg-do assemble } + +template <class T> +void f(T) {} + +template <class T> +struct S { + static T t; +}; + +template <class T> +T S<T>::t; + +template void f(int); +template void f(int); // { dg-error "duplicate explicit instantiation" } +template int S<int>::t; +template int S<int>::t; // { dg-error "duplicate explicit instantiation" } +template class S<double>; +template class S<double>; // { dg-error "duplicate explicit instantiation" } + +extern template void f(double); // { dg-error "extern" } extern not allowed +inline template class S<float>; // { dg-error "inline" } inline not allowed + +template <class T> +struct S<T*> {}; + +template class S<void*>; // OK - explicit instantiation of partial + // specialization + +template <> +struct S<long double> {}; + +template class S<long double>; // OK - explicit instantiation after + +template <> +void f(long double) {} + +template void f(long double); // OK - explicit instantiation after + +template <class T> +void g(T); + +template void g(int); // { dg-error "no definition available" "no def" } +// { dg-message "instantiated" "inst" { target *-*-* } 43 } diff --git a/gcc/testsuite/g++.old-deja/g++.pt/explicit71.C b/gcc/testsuite/g++.old-deja/g++.pt/explicit71.C new file mode 100644 index 000000000..03b879433 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/explicit71.C @@ -0,0 +1,15 @@ +// { dg-do assemble } +// by Alexandre Oliva <oliva@dcc.unicamp.br> +// Based on a testcase by Reid M. Pinchback <reidmp@MIT.EDU> +// According to the C++ Standard [temp.expl.spec]/17-18, explicit +// specializations are only valid if all enclosing template classes +// of the specialized template are fully specialized too + +template <class X> +class bug { + template <class Y> + class a {}; +}; +template <class X> +template <> // { dg-error "" } invalid specialization +class bug<X>::a<char> {}; // { dg-error "" } diff --git a/gcc/testsuite/g++.old-deja/g++.pt/explicit72.C b/gcc/testsuite/g++.old-deja/g++.pt/explicit72.C new file mode 100644 index 000000000..f0e88acfc --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/explicit72.C @@ -0,0 +1,21 @@ +// { dg-do assemble } +// Contributed by Reid M. Pinchback <reidmp@MIT.EDU> +// Adapted by Alexandre Oliva <oliva@dcc.unicamp.br> +// plain char, signed char and unsigned char are distinct types + +template <class X, class Y> struct bug {}; +template <class X> struct bug<X,char> { typedef char t; }; +template <class X> struct bug<X,unsigned char> { typedef unsigned char t; }; +template <class X> struct bug<X,signed char> { typedef signed char t; }; +template <class X> struct bug<char,X> { typedef char t; }; +template <class X> struct bug<unsigned char,X> { typedef unsigned char t; }; +template <class X> struct bug<signed char,X> { typedef signed char t; }; + +void foo() { + bug<int,char>::t(); + bug<int,signed char>::t(); + bug<int,unsigned char>::t(); + bug<char,int>::t(); + bug<signed char,int>::t(); + bug<unsigned char,int>::t(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/explicit73.C b/gcc/testsuite/g++.old-deja/g++.pt/explicit73.C new file mode 100644 index 000000000..1d83e3468 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/explicit73.C @@ -0,0 +1,15 @@ +// { dg-do assemble } + +// by Alexandre Oliva <oliva@dcc.unicamp.br> + +// According to [temp.expl.spec]/2, a template explicit specialization +// must be declared in the namespace that contains the declaration of +// the template + +namespace N { + template <class T> class foo; // { dg-error "" } referenced below +} + +using namespace N; + +template <> class foo<void>; // { dg-error "" } invalid specialization diff --git a/gcc/testsuite/g++.old-deja/g++.pt/explicit74.C b/gcc/testsuite/g++.old-deja/g++.pt/explicit74.C new file mode 100644 index 000000000..66d481b03 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/explicit74.C @@ -0,0 +1,11 @@ +// { dg-do run } +// Reduced from a testcase by Yotam Medini <yotam@avanticorp.com> + +// egcs 1.1 seems to generate code that deletes a NULL pointer. + +template <class bar> struct foo { void fuz(); ~foo(); }; +struct baz { int i; foo<baz> j; } *p = 0; +template <class bar> void foo<bar>::fuz() { delete p; } +template <class bar> foo<bar>::~foo() { delete p; } +template class foo<baz>; +int main() { foo<baz>(); } diff --git a/gcc/testsuite/g++.old-deja/g++.pt/explicit75.C b/gcc/testsuite/g++.old-deja/g++.pt/explicit75.C new file mode 100644 index 000000000..aed69aa1f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/explicit75.C @@ -0,0 +1,11 @@ +// { dg-do assemble } +// Test for not complaining about mismatches during unification. + +template <void (*F)(int)> void f(); +template <void (*F)(double)> void f(); +extern void g(double); + +void h () +{ + f<g>(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/explicit76.C b/gcc/testsuite/g++.old-deja/g++.pt/explicit76.C new file mode 100644 index 000000000..15f680c80 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/explicit76.C @@ -0,0 +1,10 @@ +// { dg-do assemble } + +// Based on bug report by Simon A. Crase <s.crase@ieee.org> + + +struct foo { + template <class T> void bar(); +}; + +template void foo::bar<void>(); // { dg-bogus "" "" { xfail *-*-* } } - ICE - diff --git a/gcc/testsuite/g++.old-deja/g++.pt/explicit77.C b/gcc/testsuite/g++.old-deja/g++.pt/explicit77.C new file mode 100644 index 000000000..1213a1511 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/explicit77.C @@ -0,0 +1,19 @@ +// { dg-do assemble } + +template <int I, int J, int K> +struct S {}; + +template <int I, int J> +struct S<I, J, 2> : public S<I, I, I>, S<J, J, J> {}; + +template <int I, int J, int K> +void f(S<I, J, K>, S<I, I, I>); // { dg-message "note" } + +void g() { + S<0, 0, 0> s0; + S<0, 1, 2> s2; + + f<0>(s0, s2); + f(s0, s2); // { dg-error "" } no matching function + // { dg-message "candidate" "candidate note" { target *-*-* } 17 } +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/explicit78.C b/gcc/testsuite/g++.old-deja/g++.pt/explicit78.C new file mode 100644 index 000000000..34e4c758f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/explicit78.C @@ -0,0 +1,28 @@ +// { dg-do assemble } + +template <int I> +struct A { +}; + +template <int I, int J> +struct B { + operator A<3> (); + operator B<3, 7> (); +}; + + +template <int I, int J> +void f(B<I, J>); + +template <int I> +void f(A<I>) +{ +} + +int main() +{ + // Deduction fails with the first `f'. Since `3' is explicitly + // specified, we don't try any deduction with the second `f'. So, + // we call the second `f'. + f<3>(B<2, 7>()); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/explicit79.C b/gcc/testsuite/g++.old-deja/g++.pt/explicit79.C new file mode 100644 index 000000000..9d62ca40e --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/explicit79.C @@ -0,0 +1,12 @@ +// { dg-do assemble } + +template <int I> +void f(int (*)[I] = 0); + +template <int J> +void f(); + +void g() +{ + f<-1>(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/explicit8.C b/gcc/testsuite/g++.old-deja/g++.pt/explicit8.C new file mode 100644 index 000000000..3a75aa0db --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/explicit8.C @@ -0,0 +1,13 @@ +// { dg-do assemble } +// GROUPS passed templates +template <class T, class U> +void foo(T t, U u); + +template <class U> +void foo(double, U) {} + +void baz() +{ + foo<const char*>(3.0, "abc"); + foo<const char*, double>("abc", 3.0); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/explicit80.C b/gcc/testsuite/g++.old-deja/g++.pt/explicit80.C new file mode 100644 index 000000000..4e37971cd --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/explicit80.C @@ -0,0 +1,16 @@ +// { dg-do assemble } +// Bug: We were complaining about explicit instantiation of A<T>::B. + +template <class T> +struct A +{ + public: + ~A() { } + + class B; +}; + +template <> class A<int>::B { }; + +template class A<int>; +template class A<double>; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/explicit81.C b/gcc/testsuite/g++.old-deja/g++.pt/explicit81.C new file mode 100644 index 000000000..576ba5439 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/explicit81.C @@ -0,0 +1,43 @@ +// { dg-do assemble } +// +// Copyright (C) 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 10 Aug 2000 <nathan@codesourcery.com> + +// bug 371 We failed to subst explicit template args before trying to +// deduce the template. + +namespace N +{ +enum E { e0 }; + +template< E e > void nf(); + +} + +template< N::E e > void gf(); + +struct X { + template<N::E e> void xfn (); + template<N::E e> static void sfn (); +}; + +template < class C > +void tf(C *ptr) +{ + N::nf<N::e0>(); + gf<N::e0>(); + ptr->X::xfn <N::e0> (); + ptr->C::template xfn <N::e0> (); + ptr->template xfn <N::e0> (); + ptr->X::sfn <N::e0> (); + ptr->C::template sfn <N::e0> (); + ptr->template sfn <N::e0> (); + X::sfn <N::e0> (); + C::template sfn <N::e0> (); +} + +void f(X *ptr) +{ + ptr->xfn <N::e0> (); + tf(ptr); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/explicit82.C b/gcc/testsuite/g++.old-deja/g++.pt/explicit82.C new file mode 100644 index 000000000..e8423f82c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/explicit82.C @@ -0,0 +1,18 @@ +// { dg-do assemble } +// Copyright (C) 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 7 Sep 2000 <nathan@codesourcery.com> + +// Bug 508. We failed to set/clear lastiddecl appropriately for +// operator names. + +struct A {}; + +template <typename N> void foo (A, int); +template <typename N> void operator<< (A, int); + +int main() +{ + A a; + operator<< <bool>(a, 0); + foo <bool>(a, 0); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/explicit9.C b/gcc/testsuite/g++.old-deja/g++.pt/explicit9.C new file mode 100644 index 000000000..f30060329 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/explicit9.C @@ -0,0 +1,8 @@ +// { dg-do assemble } +// GROUPS passed templates +void foo(int); + +void bar() +{ + foo<int>(3); // { dg-error "" } foo is not a template. +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/export1.C b/gcc/testsuite/g++.old-deja/g++.pt/export1.C new file mode 100644 index 000000000..53e7e9b16 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/export1.C @@ -0,0 +1,18 @@ +// { dg-do assemble } +// Copyright (C) 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 17 Nov 2000 <nathan@codesourcery.com> + + +// bug 721, we died horribly when export was used wrongly + +struct test { +int export(void); // { dg-error "" } parse error +}; + +int test::export(void) // { dg-error "" } parse error +{ +return 0; +} + +template <class T> class Y; +export template <class T> class X; // { dg-warning "" } export not implemented diff --git a/gcc/testsuite/g++.old-deja/g++.pt/expr1.C b/gcc/testsuite/g++.old-deja/g++.pt/expr1.C new file mode 100644 index 000000000..124d265dd --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/expr1.C @@ -0,0 +1,34 @@ +// { dg-do run } +template <int n> class vec { + double x[n]; + + public: + vec() { + for (int i=0; i<n-1; ++i) x[i]=0; + } + + vec(const vec<n>& v) { + for (int i=0; i<n; ++i) x[i]=v(i); + } + + vec(const vec<n-1>& v, const double& y) { + for (int i=0; i<n-1; ++i) x[i]=v(i); + x[n-1]=y; + } + + inline double operator()(const int i) const { + return x[i]; + } +}; + + +template <int n> vec<n + 1>& operator,(const vec<n>& v, const double& y) { + return *(new vec<n + 1>(v, y)); +} + + +int main() { + vec<4> v; + vec<5> w; + w=(v,3.); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/expr2.C b/gcc/testsuite/g++.old-deja/g++.pt/expr2.C new file mode 100644 index 000000000..0dcc65f6f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/expr2.C @@ -0,0 +1,13 @@ +// { dg-do assemble } + +template <int I> +struct S {}; + +template <int J> +void foo(S<J + 2>); // { dg-message "note" } + +void bar() +{ + foo(S<3>()); // { dg-error "" } no way to deduce J from this. + // { dg-message "candidate" "candidate note" { target *-*-* } 11 } +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/expr3.C b/gcc/testsuite/g++.old-deja/g++.pt/expr3.C new file mode 100644 index 000000000..c7269f130 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/expr3.C @@ -0,0 +1,20 @@ +// { dg-do assemble } + +template <int I> +struct S {}; + +template <int J> +void foo(S<J - 1>); + +template <class T> +void baz(S<sizeof(T)>); + +template <int J> +void fun(S<J>, S<J * 2>); + +void bar() +{ + foo<5>(S<4>()); // OK - 4 is 5 - 1. + baz<int>(S<sizeof(int)>()); // OK + fun(S<4>(), S<8>()); // OK - deduce J from first argument. +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/expr5.C b/gcc/testsuite/g++.old-deja/g++.pt/expr5.C new file mode 100644 index 000000000..8bf8d423c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/expr5.C @@ -0,0 +1,10 @@ +// { dg-do assemble } + +template <class T, int i> +struct S1; + +template <class T, int i, int j> +struct S2 +{ + typedef typename S1<T, (i >= j ? 0 : 1) >::type type; +}; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/expr6.C b/gcc/testsuite/g++.old-deja/g++.pt/expr6.C new file mode 100644 index 000000000..55da97d53 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/expr6.C @@ -0,0 +1,7 @@ +// { dg-do assemble } + +// Based on a bug report by tveldhui <tveldhui@extreme.indiana.edu> + +template <int X> class foo {}; + +foo< true ? 1 : 0 > bar; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/expr7.C b/gcc/testsuite/g++.old-deja/g++.pt/expr7.C new file mode 100644 index 000000000..81d977e3c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/expr7.C @@ -0,0 +1,8 @@ +// { dg-do assemble } + +template<int I> struct A { }; +template<int I, int J> int f(A<I+J>); +int g() { + A<3> a; + return f<1,2>(a); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/expr8.C b/gcc/testsuite/g++.old-deja/g++.pt/expr8.C new file mode 100644 index 000000000..3a5c3dcfc --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/expr8.C @@ -0,0 +1,26 @@ +// { dg-do assemble } + +// Copyright (C) 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 23 June 2000 <nathan@codesourcery.com> + +// Origin GNATS bug report 10 from Ewgenij Gawrilow <gawrilow@math.TU-Berlin.DE> +// There is a grammar ambiguity with greater-than compare as a default +// template parameter value or template arg list. 14.2/2 and 14.1/15 +// say how to resolve it, but we'd sometimes get it wrong. + +template <int> class C { }; + +void f() +{ +C<1> c1; +C<1 & 2> c2; +C<1>2> c3; // { dg-error "" } parse error +C<(1>2)> c4; +C<1 & 2>2> c5; // { dg-error "" } parse error +C<1 & (2>2)> c6; +} + +template <int i = 3>4 > class X1 {}; // { dg-error "" } parse error +template <int i = 3&&4>0 > class X2 {}; // { dg-error "" } parse error +template <int i = 3&&4 > class X3 {}; +template <int i = (3>4) > class X4 {}; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/extern1.C b/gcc/testsuite/g++.old-deja/g++.pt/extern1.C new file mode 100644 index 000000000..91b47c1dd --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/extern1.C @@ -0,0 +1,13 @@ +// { dg-do assemble } +// Origin: Mark Mitchell <mark@codesourcery.com> + +template <class T> +void f () +{ + extern int i; + extern T j; + + i = j; +} + +template void f<int>(); diff --git a/gcc/testsuite/g++.old-deja/g++.pt/fntry1.C b/gcc/testsuite/g++.old-deja/g++.pt/fntry1.C new file mode 100644 index 000000000..9a5d993be --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/fntry1.C @@ -0,0 +1,10 @@ +// { dg-do run } +// Bug: g++ silently ignores function-try-blocks in templates. +// Submitted by Jason Merrill <jason@cygnus.com> + +template <class T> void f (T) try { throw 1; } catch (...) { } + +int main () +{ + f (1); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/friend1.C b/gcc/testsuite/g++.old-deja/g++.pt/friend1.C new file mode 100644 index 000000000..d177a8045 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/friend1.C @@ -0,0 +1,25 @@ +// { dg-do run } +template <class T> +void f(T); + +class C +{ + template <class T> + friend void f(T); + + int i; +}; + + +template <class T> +void f(T) +{ + C c; + c.i = 3; +} + + +int main() +{ + f(7); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/friend10.C b/gcc/testsuite/g++.old-deja/g++.pt/friend10.C new file mode 100644 index 000000000..d784eaf47 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/friend10.C @@ -0,0 +1,30 @@ +// { dg-do run } +template <class T> +void f(T); + +template <class U> +class C +{ + template <class T> + friend void f(T) + { + C<U> c; + c.i = 3; + } + +public: + + void g() + { + f(3.0); + } + + int i; +}; + +int main() +{ + f(7); + C<double> c; + c.g(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/friend11.C b/gcc/testsuite/g++.old-deja/g++.pt/friend11.C new file mode 100644 index 000000000..04dbf2569 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/friend11.C @@ -0,0 +1,32 @@ +// { dg-do assemble } +template <class T> +class C; + +template <class T> +struct S +{ + template <class U> + void f(U u) + { + C<U> cu; + cu.i = 3; // { dg-error "" } S<double>::f<U> is a friend, but this is + // S<int>::f<double>. + } +}; + + +template <class T> +class C +{ + template <class U> + friend void S<T>::f(U); + + int i; // { dg-error "" } private +}; + + +int main() +{ + S<int> si; + si.f(3.0); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/friend12.C b/gcc/testsuite/g++.old-deja/g++.pt/friend12.C new file mode 100644 index 000000000..0c4275151 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/friend12.C @@ -0,0 +1,34 @@ +// { dg-do run } +template <class T> +class C; + +template <class T> +struct S +{ + template <class U> + void f(U u1, U u2) {} + + template <class U> + void f(U u) + { + C<T> ct; + ct.i = 3; + } +}; + + +template <class T> +class C +{ + template <class U> + friend void S<T>::f(U); + + int i; +}; + + +int main() +{ + S<int> si; + si.f(3.0); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/friend13.C b/gcc/testsuite/g++.old-deja/g++.pt/friend13.C new file mode 100644 index 000000000..0bdd477a1 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/friend13.C @@ -0,0 +1,34 @@ +// { dg-do run } +template <class T> +class C; + +template <class U> +struct S +{ + template <class V> + void f(V v) + { + C<V> cv; + cv.i = 3; + } +}; + + +template <class T> +class C +{ + template <class U> + template <class V> + friend void S<U>::f(V); + + int i; +}; + + +int main() +{ + S<int> si; + si.f(3.0); + S<long> sl; + sl.f('c'); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/friend14.C b/gcc/testsuite/g++.old-deja/g++.pt/friend14.C new file mode 100644 index 000000000..69491fadf --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/friend14.C @@ -0,0 +1,25 @@ +// { dg-do assemble } + +template <class U> +class S1 +{ + template <class T> + friend class S2; + + static int i; +}; + + +template <class T> +class S2 +{ +public: + static void f() { S1<T>::i = 3; } +}; + + +void g() +{ + S2<double>::f(); + S2<long>::f(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/friend15.C b/gcc/testsuite/g++.old-deja/g++.pt/friend15.C new file mode 100644 index 000000000..875be81d4 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/friend15.C @@ -0,0 +1,24 @@ +// { dg-do assemble } + +class S1 +{ + template <class T> + friend class S2; + + static int i; +}; + + +template <class T> +class S2 +{ +public: + static void f() { S1::i = 3; } +}; + + +void g() +{ + S2<double>::f(); + S2<char>::f(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/friend16.C b/gcc/testsuite/g++.old-deja/g++.pt/friend16.C new file mode 100644 index 000000000..1b51f248e --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/friend16.C @@ -0,0 +1,31 @@ +// { dg-do assemble } + +template <class T> +class S2 +{ +public: + static void f(); +}; + + +template <class U> +class S1 +{ + template <class T> + friend class S2; + + static int i; +}; + + +template <class T> +void S2<T>::f() +{ + S1<T>::i = 3; +} + +void g() +{ + S2<double>::f(); + S2<char>::f(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/friend17.C b/gcc/testsuite/g++.old-deja/g++.pt/friend17.C new file mode 100644 index 000000000..ae93cffc7 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/friend17.C @@ -0,0 +1,28 @@ +// { dg-do assemble } + +template <class T> +class S2 +{ +public: + static void f(); +}; + +class S1 +{ + template <class T> + friend class S2; + + static int i; +}; + +template <class T> +void S2<T>::f() +{ + S1::i = 3; +} + +void g() +{ + S2<double>::f(); + S2<char>::f(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/friend18.C b/gcc/testsuite/g++.old-deja/g++.pt/friend18.C new file mode 100644 index 000000000..4b58f94d3 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/friend18.C @@ -0,0 +1,26 @@ +// { dg-do assemble } + +template <class U> +class S1 +{ + template <class T> + friend class S2; + + static int i; +}; + + +template <class T> +class S2 +{ +public: + static void f() { S1<T>::i = 3; } +}; + + +void g() +{ + S2<double>::f(); + S2<long>::f(); +} + diff --git a/gcc/testsuite/g++.old-deja/g++.pt/friend20.C b/gcc/testsuite/g++.old-deja/g++.pt/friend20.C new file mode 100644 index 000000000..11cb291f1 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/friend20.C @@ -0,0 +1,10 @@ +// { dg-do assemble } + +template <class T = int> struct A; + +template <class T> struct B +{ + friend class A<T>; +}; + +template class B<int>; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/friend21.C b/gcc/testsuite/g++.old-deja/g++.pt/friend21.C new file mode 100644 index 000000000..762ea9bae --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/friend21.C @@ -0,0 +1,30 @@ +// { dg-do assemble } + +template <class T> struct A { + static void f(); +}; + +template <class T> class B +{ + friend class A<T>; + static int i; // { dg-error "" } private +}; + +template <class T> class C +{ + template <class U> + friend class A; + + static int i; +}; + +template <class T> +void A<T>::f() +{ + B<T>::i = 3; + C<T>::i = 3; + C<double>::i = 3; + B<double>::i = 3; // { dg-error "" } member `i' is private +} + +template void A<int>::f(); diff --git a/gcc/testsuite/g++.old-deja/g++.pt/friend22.C b/gcc/testsuite/g++.old-deja/g++.pt/friend22.C new file mode 100644 index 000000000..3dcfa0e61 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/friend22.C @@ -0,0 +1,10 @@ +// { dg-do assemble } + +template <class T = int> +struct S +{ + template <class U> + friend class S; +}; + +template struct S<int>; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/friend23.C b/gcc/testsuite/g++.old-deja/g++.pt/friend23.C new file mode 100644 index 000000000..93ce72e30 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/friend23.C @@ -0,0 +1,10 @@ +// { dg-do assemble } + +template <class T = int> // { dg-message "note: original definition" } +struct S +{ + template <class U = int> + friend class S; // { dg-error "redefinition of default argument" } +}; + +template struct S<int>; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/friend24.C b/gcc/testsuite/g++.old-deja/g++.pt/friend24.C new file mode 100644 index 000000000..5a4116fd4 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/friend24.C @@ -0,0 +1,18 @@ +// { dg-do assemble } + +template <class T> +struct S +{ + template <class U = T> + friend class S; + + void f(T); +}; + +template struct S<int>; + +void g() +{ + S<> s; + s.f(3); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/friend25.C b/gcc/testsuite/g++.old-deja/g++.pt/friend25.C new file mode 100644 index 000000000..405ac801d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/friend25.C @@ -0,0 +1,15 @@ +// { dg-do assemble } + +template <class T> struct A; + +struct B +{ + template <class U> + friend class A<U>; // { dg-error "" } does not specialize any args +}; + +struct C +{ + template <class U> + friend class A<U*>; // { dg-error "" } partial specialization +}; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/friend26.C b/gcc/testsuite/g++.old-deja/g++.pt/friend26.C new file mode 100644 index 000000000..dcc77a494 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/friend26.C @@ -0,0 +1,6 @@ +// { dg-do assemble } + +struct S +{ + friend void f<>(int); // { dg-error "" } does not match any template +}; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/friend27.C b/gcc/testsuite/g++.old-deja/g++.pt/friend27.C new file mode 100644 index 000000000..c23d07004 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/friend27.C @@ -0,0 +1,7 @@ +// { dg-do assemble } + +class S +{ + friend void f<>(int); // { dg-error "" } does not match any template + int i; +}; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/friend28.C b/gcc/testsuite/g++.old-deja/g++.pt/friend28.C new file mode 100644 index 000000000..5e06e2167 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/friend28.C @@ -0,0 +1,24 @@ +// { dg-do assemble } + +class mystream; + +template <class T> class a; + +template <class T> mystream& operator>>( mystream& s, a<T>& thea ); + +template <class T> class a { +public: + friend mystream& operator>> <>( mystream&, a<T>& thea ); +private: + T amember; +}; + +template<> mystream& operator>> <int>( mystream& s, a<int>& thea ); + +template class a<int>; + +template<> mystream& operator>> <int>( mystream& s, a<int>& thea ) +{ + thea.amember = 0; + return s; +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/friend29.C b/gcc/testsuite/g++.old-deja/g++.pt/friend29.C new file mode 100644 index 000000000..95cbb0e6a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/friend29.C @@ -0,0 +1,20 @@ +// { dg-do assemble } + +template <class T> class a; + +template <class T> void foo( a<T>& thea ); + +template <class T> class a { +public: + friend void foo<>( a<T>& thea ); +private: + T amember; +}; + +template <class T> void foo( a<T>& thea ) +{ + thea.amember = 0; +} + +template class a<int>; + diff --git a/gcc/testsuite/g++.old-deja/g++.pt/friend3.C b/gcc/testsuite/g++.old-deja/g++.pt/friend3.C new file mode 100644 index 000000000..11b4064f4 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/friend3.C @@ -0,0 +1,25 @@ +// { dg-do assemble } + +template <class T> +void f(T); + +class C +{ + friend void f<>(double); + + int i; // { dg-error "" } private +}; + + +template <class T> +void f(T) +{ + C c; + c.i = 3; // { dg-error "" } f<double> is a friend, this is f<int>. +} + + +int main() +{ + f(7); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/friend30.C b/gcc/testsuite/g++.old-deja/g++.pt/friend30.C new file mode 100644 index 000000000..ed492ed18 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/friend30.C @@ -0,0 +1,18 @@ +// { dg-do assemble } + +template <class T, class U> +struct S { + template <class X, class Y, class Z> + friend X f(X, Y, Z); +}; + +template <class X, class Y, class Z> +X f(X x, Y, Z) { + return x; +} + +template char f(char, long, short); +template char* f(char*, long*, short*); +template class S<int, double>; +template class S<void*, double>; +template double* f(double*, long*, short*); diff --git a/gcc/testsuite/g++.old-deja/g++.pt/friend31.C b/gcc/testsuite/g++.old-deja/g++.pt/friend31.C new file mode 100644 index 000000000..071025df4 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/friend31.C @@ -0,0 +1,12 @@ +// { dg-do assemble } + +template <class T> +struct S1 { +}; + +template <> +struct S1<int> {}; + +struct S2 { + friend class S1<int>; +}; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/friend32.C b/gcc/testsuite/g++.old-deja/g++.pt/friend32.C new file mode 100644 index 000000000..512a69a09 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/friend32.C @@ -0,0 +1,16 @@ +// { dg-do assemble } + +template <class T, class U> +struct S { + template <class X, class Y, class Z> + friend X f(X, Y, Z); +}; + +template class S<int, double>; +template char f(char, long, short); +template char* f(char*, long*, short*); + +template <class X, class Y, class Z> +X f(X x, Y, Z) { + return x; +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/friend33.C b/gcc/testsuite/g++.old-deja/g++.pt/friend33.C new file mode 100644 index 000000000..016be7013 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/friend33.C @@ -0,0 +1,28 @@ +// { dg-do link } +// { dg-options "-g" } + +template <class P1> +struct S1 +{ + struct SS1 + { + }; + friend void Foo (const SS1& ss1) + { + } +}; + +template <class P1> +void Foo(const S1<P1>& s1) +{ + typedef typename S1<P1>::SS1 TYPE; + TYPE t; + Foo(t); +} + +int main () +{ + S1<double> obj; + Foo(obj); +} + diff --git a/gcc/testsuite/g++.old-deja/g++.pt/friend34.C b/gcc/testsuite/g++.old-deja/g++.pt/friend34.C new file mode 100644 index 000000000..5e80ab98b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/friend34.C @@ -0,0 +1,14 @@ +// { dg-do assemble } + +// This testcase won't fail if class ::foo is forward-declared in the +// global namespace, nor if class bar is not a template class. + +template <typename T = void> +class bar { +public: + friend class foo; // this is not bar::foo, it forward-declares ::foo + class foo {}; + bar() { foo(); } // but this should refer to bar::foo +}; + +bar<> baz; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/friend35.C b/gcc/testsuite/g++.old-deja/g++.pt/friend35.C new file mode 100644 index 000000000..b2cd266a4 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/friend35.C @@ -0,0 +1,7 @@ +// { dg-do assemble } + +class foo { + friend void bar<int>(int); // { dg-error "" } must be declared first +}; + +template <typename T> void bar(T); diff --git a/gcc/testsuite/g++.old-deja/g++.pt/friend36.C b/gcc/testsuite/g++.old-deja/g++.pt/friend36.C new file mode 100644 index 000000000..f5cb8d40a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/friend36.C @@ -0,0 +1,12 @@ +// { dg-do assemble } + +template <class T> +void f(T) {} // { dg-error "previously" } + +template <class U> +struct S { + template <class T> + friend void f(T) {} // { dg-error "redefinition" } +}; + +S<int> si; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/friend37.C b/gcc/testsuite/g++.old-deja/g++.pt/friend37.C new file mode 100644 index 000000000..a0c65ad2b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/friend37.C @@ -0,0 +1,7 @@ +// { dg-do assemble } +// Simplified from report by Volker Dobler <volker@hugo.physik.uni-konstanz.de> + +template <class T> class A { + friend int ice<>( int k=0 ); // { dg-error "" } default argument + friend inline int f<>(double); // { dg-error "" } inline +}; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/friend38.C b/gcc/testsuite/g++.old-deja/g++.pt/friend38.C new file mode 100644 index 000000000..429e421b8 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/friend38.C @@ -0,0 +1,9 @@ +// { dg-do assemble } + +// Overly simplified from testcase by "B. K. Oxley" <binkley@bigfoot.com> + +template<class P, class Q> struct foo { + typedef P parent_type; + friend parent_type; // { dg-error "" } template parameters cannot be friends + friend Q; // { dg-error "" } template parameters cannot be friends +}; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/friend39.C b/gcc/testsuite/g++.old-deja/g++.pt/friend39.C new file mode 100644 index 000000000..986f27095 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/friend39.C @@ -0,0 +1,23 @@ +// { dg-do assemble } + +template <class T> +struct S; + +template <class T> +class C +{ + friend void S<T>::f(); + + int i; +}; + +template <class T> +struct S +{ + void f() { + C<T> c; + c.i = 3; + } +}; + +template void S<int>::f(); diff --git a/gcc/testsuite/g++.old-deja/g++.pt/friend4.C b/gcc/testsuite/g++.old-deja/g++.pt/friend4.C new file mode 100644 index 000000000..a1b8d32f1 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/friend4.C @@ -0,0 +1,22 @@ +// { dg-do run } +class C +{ + template <class T> + friend void f(T); + + int i; +}; + + +template <class T> +void f(T) +{ + C c; + c.i = 3; +} + + +int main() +{ + f(7); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/friend40.C b/gcc/testsuite/g++.old-deja/g++.pt/friend40.C new file mode 100644 index 000000000..646087630 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/friend40.C @@ -0,0 +1,12 @@ +// { dg-do assemble } +// { dg-options "-Wno-non-template-friend" } +// Origin: Jason Merrill <jason@cygnus.com> + +template<class T> struct A +{ + friend void f (); +}; + +A<short> a; +A<int> b; + diff --git a/gcc/testsuite/g++.old-deja/g++.pt/friend41.C b/gcc/testsuite/g++.old-deja/g++.pt/friend41.C new file mode 100644 index 000000000..e3a6c0c3f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/friend41.C @@ -0,0 +1,21 @@ +// { dg-do assemble } +// Origin: Mark Mitchell <mark@codesourcery.com> + +template <class T> +class S { +public: + template <class U> + class C { + public: + void f() { S::i = 3; } + }; + + template <class U> + friend class C; + +private: + static int i; +}; + + +template void S<int>::C<double>::f(); diff --git a/gcc/testsuite/g++.old-deja/g++.pt/friend42.C b/gcc/testsuite/g++.old-deja/g++.pt/friend42.C new file mode 100644 index 000000000..3c353e53d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/friend42.C @@ -0,0 +1,10 @@ +// { dg-do assemble } +// Origin: Mark Mitchell <mark@codesourcery.com> + +template <class T> +struct S { + template <class U> + friend struct S2; +}; + +template struct S<int>; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/friend43.C b/gcc/testsuite/g++.old-deja/g++.pt/friend43.C new file mode 100644 index 000000000..5a62efb6c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/friend43.C @@ -0,0 +1,19 @@ +// { dg-do assemble } +// Origin: Matt Austern <austern@isolde.engr.sgi.com> + +class A { +public: + static void f(); +}; + +template <class T> +class B : public A { + friend void A::f(); +}; + +template <class T> +class C : public B<T> +{ +}; + +template class C<char>; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/friend44.C b/gcc/testsuite/g++.old-deja/g++.pt/friend44.C new file mode 100644 index 000000000..1d2c1d1f9 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/friend44.C @@ -0,0 +1,44 @@ +// { dg-do compile } +// Test that template friends referring to class template members are +// respected. + + +template <class T> struct A +{ + int f (T); + struct AI { + int f (T); + }; +}; + +class B +{ + template <class T> friend int A<T>::f (T); + template <class T> friend struct A<T>::AI; + int a; +public: + B(): a(0) { } +}; + +template <class T> int A<T>::f (T) +{ + B b; + return b.a; +} + +template <class T> int A<T>::AI::f (T) +{ + B b; + return b.a; +} + +int main () +{ + A<int> a; + A<int>::AI ai; + + int r = a.f (0); + r |= ai.f (0); + + return r; +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/friend45.C b/gcc/testsuite/g++.old-deja/g++.pt/friend45.C new file mode 100644 index 000000000..720dfeba0 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/friend45.C @@ -0,0 +1,13 @@ +// { dg-do assemble } +// +// Copyright (C) 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 14 Aug 2000 <nathan@codesourcery.com> + +// bug 42. We ICE'd on instantiating a template with a bogus templated friend. + +template<typename T> struct X +{ + template<typename D> friend X<D>; // { dg-error "" } friend must use aggr tag +}; + +X<int> g; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/friend46.C b/gcc/testsuite/g++.old-deja/g++.pt/friend46.C new file mode 100644 index 000000000..b8695ccda --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/friend46.C @@ -0,0 +1,29 @@ +// { dg-do assemble } +// Copyright (C) 2000, 2002 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 17 Nov 2000 <nathan@codesourcery.com> + +// bug 43. Two failings, bison parser ickiness caused us to find the member +// named the same as a friend, and then when instantiating, we'd lookup in +// the wrong scope. + +namespace X { + template <class T> class P; + + template <class T> void operator- (const P<T>&); + + template <class T> + struct V + { + V (const T&); + + void operator- (); + friend void X::operator-<> (const P<T>& a); + }; +} + +int main() +{ + X::V<double> b(1.0); + + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/friend47.C b/gcc/testsuite/g++.old-deja/g++.pt/friend47.C new file mode 100644 index 000000000..66b214d1f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/friend47.C @@ -0,0 +1,14 @@ +// { dg-do assemble } + +// Copyright (C) 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 7 Jan 2001 <nathan@codesourcery.com> + +// Bug 1033. We ICE'd when trying to make a non template class a templated +// friend. + +class A {}; +class B { + template<class T> friend class A; // { dg-error "" } not a template +}; + + 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 000000000..1e2367850 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/friend48.C @@ -0,0 +1,17 @@ +// { dg-do assemble } +// 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 000000000..745819af5 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/friend49.C @@ -0,0 +1,26 @@ +// { dg-do assemble } + +// 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/friend5.C b/gcc/testsuite/g++.old-deja/g++.pt/friend5.C new file mode 100644 index 000000000..3feeb684e --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/friend5.C @@ -0,0 +1,18 @@ +// { dg-do run } +class C +{ + template <class T> + friend void f(T) + { + C c; + c.i = 3; + } + + int i; +}; + + +int main() +{ + f(7); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/friend6.C b/gcc/testsuite/g++.old-deja/g++.pt/friend6.C new file mode 100644 index 000000000..8bb5e0224 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/friend6.C @@ -0,0 +1,29 @@ +// { dg-do run } +template <class T> +void f(T); + +class C +{ + template <class T> + friend void f(T) + { + C c; + c.i = 3; + } + +public: + + void g() + { + f(3.0); + } + + int i; +}; + +int main() +{ + f(7); + C c; + c.g(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/friend7.C b/gcc/testsuite/g++.old-deja/g++.pt/friend7.C new file mode 100644 index 000000000..de834bc4e --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/friend7.C @@ -0,0 +1,26 @@ +// { dg-do run } +template <class T> +void f(T); + +template <class U> +class C +{ + template <class T> + friend void f(T); + + int i; +}; + + +template <class T> +void f(T) +{ + C<T> c; + c.i = 3; +} + + +int main() +{ + f(7); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/friend8.C b/gcc/testsuite/g++.old-deja/g++.pt/friend8.C new file mode 100644 index 000000000..b87aefeb0 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/friend8.C @@ -0,0 +1,19 @@ +// { dg-do run } +template <class T> +class C +{ + friend void f (C<T> c) + { + c.i = 3; + } + + int i; +}; + + +int main() +{ + C<int> ci; + + f(ci); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/friend9.C b/gcc/testsuite/g++.old-deja/g++.pt/friend9.C new file mode 100644 index 000000000..5eb52b7ef --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/friend9.C @@ -0,0 +1,23 @@ +// { dg-do run } +template <class U> +class C +{ + template <class T> + friend void f(T); + + int i; +}; + + +template <class T> +void f(T) +{ + C<int> c; + c.i = 3; +} + + +int main() +{ + f(7); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/goto.C b/gcc/testsuite/g++.old-deja/g++.pt/goto.C new file mode 100644 index 000000000..f138ec2be --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/goto.C @@ -0,0 +1,12 @@ +// { dg-do assemble } + +template<class T> +void compute(T) { + goto Exit; +Exit: ; + } + +int main() +{ + compute(0); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/goto2.C b/gcc/testsuite/g++.old-deja/g++.pt/goto2.C new file mode 100644 index 000000000..5e4b4f0e3 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/goto2.C @@ -0,0 +1,17 @@ +// { dg-do assemble } +// Origin: Mark Mitchell <mark@codesourcery.com> + +int i = 1; + +template <class T> void test() +{ + goto lab; + lab: + --i; +} + +int main () +{ + test<int>(); + return i; +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/incomplete1.C b/gcc/testsuite/g++.old-deja/g++.pt/incomplete1.C new file mode 100644 index 000000000..36a9f5ee4 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/incomplete1.C @@ -0,0 +1,11 @@ +// { dg-do assemble } + +// Copyright (C) 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 28 Nov 2000 <nathan@codesourcery.com> + +// Inspired by 756. We'd ICE when trying to define a member of an +// incomplete template type. + +template<class X> struct ObjCount; + +template<class X> int ObjCount<X>::m; // { dg-error "" } undefined type diff --git a/gcc/testsuite/g++.old-deja/g++.pt/infinite1.C b/gcc/testsuite/g++.old-deja/g++.pt/infinite1.C new file mode 100644 index 000000000..919445be5 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/infinite1.C @@ -0,0 +1,21 @@ +// { dg-do assemble } +// { dg-options "-ftemplate-depth-10" } +// Test for catching infinitely recursive instantiations. +// Origin: Jason Merrill <jason@redhat.com> + + +template <int i> void f() +{ + f<i+1>(); // { dg-error "" } excessive recursion +} + +// We should never need this specialization because we should issue an +// error first about the recursive template instantions. But, in case +// the compiler fails to catch the error, this will keep it from +// running forever instantiating more and more templates. +template <> void f<11>(); + +int main() +{ + f<0>(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/inherit1.C b/gcc/testsuite/g++.old-deja/g++.pt/inherit1.C new file mode 100644 index 000000000..71269a921 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/inherit1.C @@ -0,0 +1,26 @@ +// { dg-do run } +// Origin: Wolfgang Bangerth <wolf@gaia.iwr.uni-heidelberg.de> + +int i = 1; + +struct Base1 { int local1; }; +struct Base2 { int local2; }; + +template <int dim> class Derived; + +template <> +class Derived<1> : public Base1, public Base2 {}; + +template <int dim> +class FinalClass : public Derived<dim> { +public: + FinalClass () { + if (&this->local1 != &this->local2) + i = 0; + } +}; + +int main () { + FinalClass<1> a1; + return i; +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/inherit2.C b/gcc/testsuite/g++.old-deja/g++.pt/inherit2.C new file mode 100644 index 000000000..136050d45 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/inherit2.C @@ -0,0 +1,67 @@ +// { dg-do assemble } + +// Make sure we make the right unqualified class a friend +// See PR c++/4403 + +template <class T> struct A +{ + struct AA; + struct AC; +}; + +template <class T> class B + :public A<T> +{ + friend struct B::AA; // OK, this has an implicit typename + // as if it is 'friend struct typename B::AA' + // (I think there's a defect report + // about that) + friend struct AC; // this makes ::AC a friend *not* A<T>::AC + + private: // only our friends can get out values + static T valueA_AA; + static T valueA_AC; + static T value_AC; +}; +template <typename T> T B<T>::valueA_AA; +template <typename T> T B<T>::valueA_AC;// { dg-error "" "" } private - +template <typename T> T B<T>::value_AC; // { dg-bogus "" "" } - + +// this one is a friend +template <class T> struct A<T>::AA +{ + int M () + { + return B<T>::valueA_AA; + } +}; + +// this is not a friend +template <class T> struct A<T>::AC +{ + T M () + { + return B<T>::valueA_AC; // { dg-error "" "" } within this context - + } +}; + +// this is a friend +struct AC +{ + int M () + { + return B<int>::value_AC; // { dg-bogus "" "" } - + } +}; + +B<int> b; +A<int>::AA a_aa; +A<int>::AC a_ac; +AC ac; + +int main () +{ + a_aa.M (); + a_ac.M (); + ac.M (); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/inject1.C b/gcc/testsuite/g++.old-deja/g++.pt/inject1.C new file mode 100644 index 000000000..05f4ef235 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/inject1.C @@ -0,0 +1,11 @@ +// { dg-do assemble } +// Origin: Mark Mitchell <mark@codesourcery.com> + +template <int I> +struct S { + struct T* x; +}; + +template struct S<2>; + +T* t; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/inject2.C b/gcc/testsuite/g++.old-deja/g++.pt/inject2.C new file mode 100644 index 000000000..3437ab15e --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/inject2.C @@ -0,0 +1,15 @@ +// { dg-do assemble } +// { dg-options "-Wno-non-template-friend" } +// Origin: Mark Mitchell <mark@codesourcery.com> + +template<int I> +class C { + friend void f(struct X *); +}; + +template class C<0>; + +class D { + friend void f(struct X*); +}; + diff --git a/gcc/testsuite/g++.old-deja/g++.pt/inline1.C b/gcc/testsuite/g++.old-deja/g++.pt/inline1.C new file mode 100644 index 000000000..ea028d845 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/inline1.C @@ -0,0 +1,14 @@ +// { dg-do assemble } +// { dg-options "-O2 -Winline" } +// Origin: Mark Mitchell <mark@codesourcery.com> + +template <class T> +inline void f () +{ + +} + +void g () +{ + f<int> (); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/inline2.C b/gcc/testsuite/g++.old-deja/g++.pt/inline2.C new file mode 100644 index 000000000..1ca2a3cd9 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/inline2.C @@ -0,0 +1,16 @@ +// { dg-do assemble } +// { dg-options "-O" } +// Origin: Mark Mitchell <mitchell@codesourcery.com> + +template <class T> +struct S { + inline ~S () {} +}; + +template <class T> +void f () +{ + static S<T> s; +} + +template void f<int>(); diff --git a/gcc/testsuite/g++.old-deja/g++.pt/instantiate1.C b/gcc/testsuite/g++.old-deja/g++.pt/instantiate1.C new file mode 100644 index 000000000..e44b06353 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/instantiate1.C @@ -0,0 +1,22 @@ +// { dg-do assemble } + +template <class T> +void f(T t) {} + +template void f<int>(int); +template void f<>(long); + +template <class T> +struct S +{ + void bar(int) {} + + template <class U> + void baz(U u) {} +}; + + +template struct S<char>; +template void S<int>::bar(int); +template void S<double>::baz<short>(short); +template void S<long>::baz<>(char); diff --git a/gcc/testsuite/g++.old-deja/g++.pt/instantiate10.C b/gcc/testsuite/g++.old-deja/g++.pt/instantiate10.C new file mode 100644 index 000000000..7d922a87a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/instantiate10.C @@ -0,0 +1,15 @@ +// { dg-do assemble } +// Origin: Neil Booth, from bug report #44 + +#include <iterator> + +template<class T> +struct X +{ +}; + +template<class T> +X<T> operator+(const X<T>&, const X<T>&); + +template<> +X<int> operator+<int>(const X<int>&, const X<int>&); diff --git a/gcc/testsuite/g++.old-deja/g++.pt/instantiate11.C b/gcc/testsuite/g++.old-deja/g++.pt/instantiate11.C new file mode 100644 index 000000000..6832d1760 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/instantiate11.C @@ -0,0 +1,65 @@ +// { dg-do assemble } +// Origin: Neil Booth, from bug report #36 + +template <typename t> class vect; +template <typename t> vect<t> operator-( const vect<t>&, const vect<t>& ); + +template <typename t> +class vect +{ +public: + vect( t a ); + + vect( const vect<t>& v ); + ~vect(); + + vect<t>& operator=( const vect<t>& v ); + vect<t> operator-( void ) const; + friend vect<t> (::operator- <>)( const vect<t>&, const vect<t>& ); + +private: + t a_; +}; + +template <typename t> inline +vect<t>::vect( t a ) +: a_(a) +{ +} + +template <typename t> inline +vect<t>::vect( const vect<t>& v ) +: a_(v.a_) +{ +} + +template <typename t> inline +vect<t>::~vect() +{ +} + +template <typename t> inline vect<t>& +vect<t>::operator=( const vect<t>& v ) +{ + a_ = v.a_; + return *this; +} + +template <typename t> inline vect<t> +vect<t>::operator-( void ) const +{ + return vect<t>( -a_ ); +} + +template <typename t> inline vect<t> +operator-( const vect<t>& u, const vect<t>& v ) +{ + return vect<t>( u.a_ - v.a_ ); +} + +int +main( void ) +{ + vect<double> a( 1.0 ), b( 0.0 ); + b = -a; +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/instantiate12.C b/gcc/testsuite/g++.old-deja/g++.pt/instantiate12.C new file mode 100644 index 000000000..9596bfbf6 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/instantiate12.C @@ -0,0 +1,61 @@ +// { dg-do run } + +// Copyright (C) 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 14 Nov 2000 <nathan@codesourcery.com> + +// Bug 635. We failed to emit initializer code for out-of-class defined +// static const members of template instantiations. + +static int inited = 0; + +static bool setFlag() +{ + inited++; + return true; +} + +template<typename T> struct X +{ + static const bool cflag; + static bool flag; + static const bool iflag = true; + static const bool jflag = true; +}; + +template<typename T> const bool X<T>::cflag (setFlag ()); +template<typename T> bool X<T>::flag (setFlag ()); +template<typename T> const bool X<T>::iflag; + +int main () +{ + X<int> a; + if (!a.flag) + return 1; + if (!a.cflag) + return 2; + if (!a.iflag) + return 3; + if (!a.jflag) + return 5; + if (!X<float>::flag) + return 5; + if (!X<float>::cflag) + return 6; + if (!X<float>::iflag) + return 7; + if (!X<float>::jflag) + return 8; + if (inited != 4) + return 9; + return 0; +} + +// On platforms that do not have weak symbols, these static data +// members must be explicitly instantiated. The iflag and jflag data +// members should not have to be explicitly instantiated because their +// const-ness should allow the compiler to elide references to the +// actual variables. +template const bool X<int>::cflag; +template bool X<int>::flag; +template const bool X<float>::cflag; +template bool X<float>::flag; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/instantiate13.C b/gcc/testsuite/g++.old-deja/g++.pt/instantiate13.C new file mode 100644 index 000000000..efbc93798 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/instantiate13.C @@ -0,0 +1,25 @@ +// { dg-do assemble } + +// Copyright (C) 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 11 Jan 2001 <nathan@codesourcery.com> + +// Bug 1551. We were accessing some uninitialized memory, causing us +// to reject this. + +template <typename T> +struct base +{ +base(); +base(unsigned); +}; + +template <typename V> +struct Y +{ +Y(unsigned = 0); +}; + +template <> +Y<char>::Y(unsigned) { } + +base<double> x; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/instantiate2.C b/gcc/testsuite/g++.old-deja/g++.pt/instantiate2.C new file mode 100644 index 000000000..60d5bd52c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/instantiate2.C @@ -0,0 +1,12 @@ +// { dg-do assemble } + +template<class T> +struct X_two { + template <class T2> T2 conv_compare_ge(T2 test) { + T2 tmp_value = T2 (0); + return (tmp_value > test ? tmp_value : test); + } +}; + +template int X_two<double>::conv_compare_ge(int); + diff --git a/gcc/testsuite/g++.old-deja/g++.pt/instantiate3.C b/gcc/testsuite/g++.old-deja/g++.pt/instantiate3.C new file mode 100644 index 000000000..b40e684f3 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/instantiate3.C @@ -0,0 +1,10 @@ +// { dg-do assemble } + +template <class T> +struct S +{ + S(const T&) {} + S(int, long); +}; + +template S<double>::S(const double&); diff --git a/gcc/testsuite/g++.old-deja/g++.pt/instantiate4.C b/gcc/testsuite/g++.old-deja/g++.pt/instantiate4.C new file mode 100644 index 000000000..d7a8cab31 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/instantiate4.C @@ -0,0 +1,31 @@ +// { dg-do link } +// { dg-options "-frepo -Werror" } +// { dg-require-host-local "" } +// { dg-skip-if "dkms are not final links" { vxworks_kernel } } + + +// Submitted by Melissa O'Neill <oneill@cs.sfu.ca> +// the vtable of Foo<int> wouldn't be generated + +template <typename A> +struct Foo { + virtual void foo() {} +}; + +template <typename A> +struct Bar { + void bar(); +}; + +template <typename A> +void Bar<A>::bar() { + Foo<A> oof; +} + +int main () { + Bar<int> rab; + + rab.bar(); +} + +// { dg-final { cleanup-repo-files } } diff --git a/gcc/testsuite/g++.old-deja/g++.pt/instantiate5-main.cc b/gcc/testsuite/g++.old-deja/g++.pt/instantiate5-main.cc new file mode 100644 index 000000000..be64bdbc4 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/instantiate5-main.cc @@ -0,0 +1,3 @@ +// this file is part of testcase instantiate5.C + +int main() {} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/instantiate5.C b/gcc/testsuite/g++.old-deja/g++.pt/instantiate5.C new file mode 100644 index 000000000..21d8b3347 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/instantiate5.C @@ -0,0 +1,13 @@ +// { dg-do link } +// { dg-additional-sources " instantiate5.cc instantiate5-main.cc" } + +// `global constructors' are given the same name, based on foo(), on +// both translation units, which is wrong, because it must be possible +// to define template functions in multiple translation units, as long +// as they're given the same definition + +// simplified from test case submitted by Daniel X. Pape <dpape@canis.uiuc.edu> + +template <class T> void foo() { } +inline int bar() { foo<void>(); return 1; } +static int i = bar(); diff --git a/gcc/testsuite/g++.old-deja/g++.pt/instantiate5.cc b/gcc/testsuite/g++.old-deja/g++.pt/instantiate5.cc new file mode 100644 index 000000000..fc86e0f83 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/instantiate5.cc @@ -0,0 +1,5 @@ +// this file is part of testcase instantiate5.C + +template <class T> void foo() { } +inline int bar() { foo<void>(); return 1; } +static int i = bar(); diff --git a/gcc/testsuite/g++.old-deja/g++.pt/instantiate6.C b/gcc/testsuite/g++.old-deja/g++.pt/instantiate6.C new file mode 100644 index 000000000..6726b2166 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/instantiate6.C @@ -0,0 +1,29 @@ +// { dg-do link } +// { dg-options "-frepo" } +// { dg-require-host-local "" } +// { dg-skip-if "dkms are not final links" { vxworks_kernel } } + +// Simplified from testcase by Erez Louidor Lior <s3824888@techst02.technion.ac.il> + +template <class T> +class foo{ +public: + void g(); + void h(); +}; + +template <class T> +void foo<T>::g() { + h(); +} + +template <class T> +void foo<T>::h() { +} + +int main() { + foo<int> f; + f.g(); +} + +// { dg-final { cleanup-repo-files } } diff --git a/gcc/testsuite/g++.old-deja/g++.pt/instantiate7.C b/gcc/testsuite/g++.old-deja/g++.pt/instantiate7.C new file mode 100644 index 000000000..b0145028b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/instantiate7.C @@ -0,0 +1,18 @@ +// { dg-do assemble } + +// Copyright (C) 2000 Free Software Foundation +// Contributed by Nathan Sidwell 6 July 2000 <nathan@codesourcery.com> + +template <class T> +void Wibble (void (*fn) (), T *const __restrict__ &p2) +{} +template<class T1, class T2> +void Wibble (T1 *const __restrict__ &p1, T2 *const __restrict__ &p2) +{} + +void Baz (); + +void Foo (void const *ptr) +{ + Wibble (&Baz, ptr); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/instantiate8.C b/gcc/testsuite/g++.old-deja/g++.pt/instantiate8.C new file mode 100644 index 000000000..ba3b7479b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/instantiate8.C @@ -0,0 +1,40 @@ +// { dg-do assemble } +// Copyright (C) 2000, 2002 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 14 Nov 2000 <nathan@codesourcery.com> + +// bug 616. We failed to complete the type of decls in templates, leading to +// bogus errors. + +struct Z; +struct Y +{ + Y (int i = 1); +}; +void g () +{ + const Y y; + Z z; // { dg-error "" } incomplete +} + +template <int dim> +struct X +{ + X (int i=1); +}; + +void h () +{ + const X<2> z; + Z z1; // { dg-error "" } incomplete +} + +template <int dim> +void f() +{ + const X<dim> x; + const X<dim+1> y[3]; + Z z2; // { dg-error "" } incomplete + typedef Z z3; // ok +} + +template void f<3> (); diff --git a/gcc/testsuite/g++.old-deja/g++.pt/instantiate9.C b/gcc/testsuite/g++.old-deja/g++.pt/instantiate9.C new file mode 100644 index 000000000..14c529fca --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/instantiate9.C @@ -0,0 +1,25 @@ +// { dg-do assemble } + +// Copyright (C) 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 22 Nov 2000 <nathan@codesourcery.com> + +// Bug 789. We ICE'd trying to instantiate B<float> because there was no +// existing partial specialization of C in A<float>. + +template <typename T> +struct A { + template <typename D1> + struct C { }; +}; + +template <typename T1> +struct B { + typename A<T1>::template C<int> s1; +}; + +int main() +{ + B<float> b; + + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/koenig1.C b/gcc/testsuite/g++.old-deja/g++.pt/koenig1.C new file mode 100644 index 000000000..03b58587c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/koenig1.C @@ -0,0 +1,22 @@ +// { dg-do assemble } +// +// Copyright (C) 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 18 Aug 2000 <nathan@codesourcery.com> + +// bug 123. We ICEd when koenig lookup found a COMPONENT_REF inside a +// TEMPLATE_ID_EXPR. + +void foo(void (*f)()); + +struct A { +template <int s> +static void g(); +template <int s> +void f(); // { dg-error "" } candiate + +static void f_plus () + { + foo (f<0>); // { dg-error "" } no match + foo (g<0>); + } +}; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/label1.C b/gcc/testsuite/g++.old-deja/g++.pt/label1.C new file mode 100644 index 000000000..a8baa0812 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/label1.C @@ -0,0 +1,25 @@ +// { dg-do assemble } + +template <class T> +struct S {}; + +template <class T> +inline void g(T t) +{ + here: + S<T> st; + goto here; +} + +template <class T> +void f(T t) +{ + here: + g(t); + goto here; +} + +void h() +{ + f(3); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/link1.C b/gcc/testsuite/g++.old-deja/g++.pt/link1.C new file mode 100644 index 000000000..4e31c28bd --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/link1.C @@ -0,0 +1,29 @@ +// { dg-do link } +// Origin: Mark Mitchell <mark@codesourcery.com> + +template <class T> +int f(T); + +template <class T> +struct S { + template <class U> + friend int f(U) { return 0; } +}; + +int k = f(2); + +template <class T> +int g(T); + +int h = g(7); + +template <class T> +int g(T) { + S<T> si; + return 0; +} + +int main() +{ +} + diff --git a/gcc/testsuite/g++.old-deja/g++.pt/local1.C b/gcc/testsuite/g++.old-deja/g++.pt/local1.C new file mode 100644 index 000000000..d73a03001 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/local1.C @@ -0,0 +1,22 @@ +// { dg-do run } +template <class STRUCT, class MEMBER> inline STRUCT * +setback(MEMBER *bp, MEMBER STRUCT::*offset) +{ + if(!bp) return 0; + union { int i; MEMBER STRUCT::*of; } u; + u.of = offset; + return (STRUCT *) ((__SIZE_TYPE__) bp - u.i); +} + + +struct S +{ + int i; +}; + +int main() +{ + S s; + + S* sp = setback (&s.i, &S::i); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/local2.C b/gcc/testsuite/g++.old-deja/g++.pt/local2.C new file mode 100644 index 000000000..9dee5e56e --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/local2.C @@ -0,0 +1,21 @@ +// { dg-do run } +extern "C" void abort(); + +template <class T> +void f(T) +{ + struct S { + int i; + } s; + + s.i = 3; + + if (s.i != 3) + abort(); +} + + +int main() +{ + f(7); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/local3.C b/gcc/testsuite/g++.old-deja/g++.pt/local3.C new file mode 100644 index 000000000..6c0fe4573 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/local3.C @@ -0,0 +1,27 @@ +// { dg-do run } +extern "C" void abort(); + +template <class T> +void f(T) +{ + int j; + + j = 6; + + struct S { + int i; + }; + + S s; + + s.i = j; + + if (s.i != 6) + abort(); +} + + +int main() +{ + f(7); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/local4.C b/gcc/testsuite/g++.old-deja/g++.pt/local4.C new file mode 100644 index 000000000..b199f1010 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/local4.C @@ -0,0 +1,26 @@ +// { dg-do run } +extern "C" void abort(); + +template <class T> +struct S {}; + +S<int> si; + +template <class T> +int f(T t) +{ + struct S { + int g(int i) { return i + 2; } + }; + + S s; + + return s.g(t) + s.g(t); +} + + +int main() +{ + if (f(3) != 10) + abort(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/local5.C b/gcc/testsuite/g++.old-deja/g++.pt/local5.C new file mode 100644 index 000000000..851032ab3 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/local5.C @@ -0,0 +1,25 @@ +// { dg-do run } +template <class INT> +class b +{ +private: + char a(int x) + { + union { + int i; + char c; + } val; + val.i = x; + return val.c; + } + +public: + b() { + } +}; + +int main() { + b<int> n; + return 0; +} + diff --git a/gcc/testsuite/g++.old-deja/g++.pt/local6.C b/gcc/testsuite/g++.old-deja/g++.pt/local6.C new file mode 100644 index 000000000..c03c6cd7b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/local6.C @@ -0,0 +1,25 @@ +// { dg-do run } +extern "C" void abort(); + +template <class T> +int f(T) +{ + struct S1 { + virtual int foo() { return 1; } + }; + + struct S2 : public S1 { + int foo() { return 2; } + }; + + S1* s2 = new S2; + + return s2->foo(); +} + + +int main() +{ + if (f(3) != 2) + abort(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/local7.C b/gcc/testsuite/g++.old-deja/g++.pt/local7.C new file mode 100644 index 000000000..96b19fc64 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/local7.C @@ -0,0 +1,23 @@ +// { dg-do assemble } + +template <class STRUCT, class MEMBER> inline STRUCT * +setback(MEMBER *bp, MEMBER STRUCT::*offset) +{ + if(!bp) return 0; + union { int i; MEMBER STRUCT::*of; } u; + u.of = offset; + return (STRUCT *) ((__SIZE_TYPE__) bp - u.i); +} + + +struct S +{ + int i; +}; + +int main() +{ + S s; + + S* sp = setback (&s.i, &S::i); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/lookup1.C b/gcc/testsuite/g++.old-deja/g++.pt/lookup1.C new file mode 100644 index 000000000..81417fe63 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/lookup1.C @@ -0,0 +1,14 @@ +// { dg-do assemble } + +template <class T, class Allocator> + struct __vector_alloc_base +{ + typedef int allocator_type; +}; + +template <class T> + struct vector : __vector_alloc_base<T,int> +{ + typedef short allocator_type; + explicit vector(const allocator_type& a = allocator_type()) {} +}; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/lookup10.C b/gcc/testsuite/g++.old-deja/g++.pt/lookup10.C new file mode 100644 index 000000000..1c04250fc --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/lookup10.C @@ -0,0 +1,20 @@ +// { dg-do assemble } + +// Copyright (C) 2000 Free Software Foundation +// Contributed by Nathan Sidwell 3 July 2000 <nathan@codesourcery.com> +// We'd get confused entering a namespace via an alias + +namespace Outer { + namespace Render_Real { + typedef void Type; + } + + namespace Core_Real {} + namespace Core = Core_Real; + + namespace Core_Real { + template<class T> void Foo (T *) {} // { dg-error "definition" } + } + + template<> void Core::Foo<> (Render_Real::Type *) {} // { dg-error "" } +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/lookup2.C b/gcc/testsuite/g++.old-deja/g++.pt/lookup2.C new file mode 100644 index 000000000..3d9f0605a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/lookup2.C @@ -0,0 +1,20 @@ +// { dg-do assemble } +// { dg-options "-fpermissive" } + +class A +{ +protected: + void f1() {}; +}; + +template <class T> class B : private A { +protected: + using A::f1; +}; + +template <class T> class D : private B<T> +{ +public: + void f2() { f1(); }; // { dg-warning "" } +}; + diff --git a/gcc/testsuite/g++.old-deja/g++.pt/lookup3.C b/gcc/testsuite/g++.old-deja/g++.pt/lookup3.C new file mode 100644 index 000000000..5a7a03722 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/lookup3.C @@ -0,0 +1,18 @@ +// { dg-do run } +template<class T> +class A { +public: + void f() { } +}; + +class B : public A<int> { +public: + void f(); +}; + +int main() +{ + B b; + B& b1 = b; + b1.A<int>::f(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/lookup4.C b/gcc/testsuite/g++.old-deja/g++.pt/lookup4.C new file mode 100644 index 000000000..3fd447cee --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/lookup4.C @@ -0,0 +1,24 @@ +// { dg-do assemble } + +void h(int); + +template <class T> +class i {}; + +struct B +{ + int i; +}; + +template <class T> +struct D : public B +{ + void f(); + void g() { h(i); } +}; + +template <class T> +void D<T>::f() +{ + h(i); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/lookup5.C b/gcc/testsuite/g++.old-deja/g++.pt/lookup5.C new file mode 100644 index 000000000..f3a5d0059 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/lookup5.C @@ -0,0 +1,14 @@ +// { dg-do assemble } + +struct B { + int i; +}; + +struct D: public B { + int i; +}; + +template <class T> +struct D2 : public D { + void f() { i = 3; } +}; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/lookup6.C b/gcc/testsuite/g++.old-deja/g++.pt/lookup6.C new file mode 100644 index 000000000..001fedd3d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/lookup6.C @@ -0,0 +1,15 @@ +// { dg-do assemble } + +// Based on bug report by Miniussi <miniussi@ilog.fr> + +class t {}; + +template <class T> struct A { typedef T t; typedef T u; }; + +template <class T> struct B : public A<T> { + // according to [temp.dep.type], `t' and `u' cannot be dependent types, + // and so there's no reason to delay lookup to specialization time. + void f(t p); // this is ::t [temp.dep]/3 + void f(typename A<T>::t p); // { dg-bogus "" } redefinition + void g(u p); // { dg-error "" } unknown type name +}; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/lookup7.C b/gcc/testsuite/g++.old-deja/g++.pt/lookup7.C new file mode 100644 index 000000000..eacdc8972 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/lookup7.C @@ -0,0 +1,14 @@ +// { dg-do assemble } +// Origin: Jason Merrill <jason@cygnus.com> + +struct A { typedef int B; }; +template <int B> struct C : public A { + B b; + void f(); +}; + + +template <int B> +void C<B>::f() { + B b; +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/lookup8.C b/gcc/testsuite/g++.old-deja/g++.pt/lookup8.C new file mode 100644 index 000000000..1662f68c7 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/lookup8.C @@ -0,0 +1,15 @@ +// { dg-do assemble } +// Origin: Mark Mitchell <mark@codesourcery.com> + +template <class T> +class X{}; + +class Y : public X<int> +{ + void f(); +}; + +void Y::f() +{ + X x; +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/lookup9.C b/gcc/testsuite/g++.old-deja/g++.pt/lookup9.C new file mode 100644 index 000000000..683182c38 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/lookup9.C @@ -0,0 +1,16 @@ +// { dg-do assemble } +// Origin: "Artem Hodyush" <artem@duma.gov.ru> + +struct B { int m; }; + +template< class T > +void +q( T& t ) { + t.T::m=1; +} + +void f() { + B b; + b.B::m=1; + q( b ); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/m1.C b/gcc/testsuite/g++.old-deja/g++.pt/m1.C new file mode 100644 index 000000000..ac60535b9 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/m1.C @@ -0,0 +1,16 @@ +// { dg-do assemble } + +int f1 () { + struct A { + A() : b (2) { } + int fred () { return b.hi_mom; } + struct B { + int hi_mom; + B (int a) { hi_mom = a; } + }; + B b; + }; + A aa; + return aa.fred(); +} +/* crashes with signal 11 */ diff --git a/gcc/testsuite/g++.old-deja/g++.pt/m2.C b/gcc/testsuite/g++.old-deja/g++.pt/m2.C new file mode 100644 index 000000000..75346739a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/m2.C @@ -0,0 +1,9 @@ +// { dg-do assemble } + +struct A { A() { a = 2; } int a; }; + +int f1 () { + struct A { A() { a = 2; } int a; }; + A aa; + return aa.a; +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/m3.C b/gcc/testsuite/g++.old-deja/g++.pt/m3.C new file mode 100644 index 000000000..788a021ce --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/m3.C @@ -0,0 +1,9 @@ +// { dg-do assemble } + +struct A { A() { a = 2; } int a; }; + +struct B { + struct A { A() { a = 2; } int a; }; + A aa; +}; +char xx[]="../tests/m3.cc:4: redefinition of `struct A'"; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/m4.C b/gcc/testsuite/g++.old-deja/g++.pt/m4.C new file mode 100644 index 000000000..19d5bc638 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/m4.C @@ -0,0 +1,7 @@ +// { dg-do assemble } + +struct A1 { struct B { B(); } b; }; +struct A2 { struct B { ~B(); } b; }; +char xx[] ="../tests/m4.cc:1: warning: return type specification for constructor invalid"; + + diff --git a/gcc/testsuite/g++.old-deja/g++.pt/m5.C b/gcc/testsuite/g++.old-deja/g++.pt/m5.C new file mode 100644 index 000000000..7a78cbe74 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/m5.C @@ -0,0 +1,6 @@ +// { dg-do assemble } + +struct B { struct A { A(); int a; } aa; }; +struct A { A(); int a; }; +B::A::A () { a = 37; } +char xx[]="../tests/m5.cc:3: Segmentation violation"; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/m6.C b/gcc/testsuite/g++.old-deja/g++.pt/m6.C new file mode 100644 index 000000000..24c65b22a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/m6.C @@ -0,0 +1,14 @@ +// { dg-do assemble } + +struct B { struct A { A(); int a; } aa; }; +B::A::A () { a = 37; } +const char* xx[] = { +"../tests/m6.cc:1: warning: return type specification for constructor invalid", +"../tests/m6.cc:2: semicolon missing after declaration of `A'", +"../tests/m6.cc:2: warning: empty declaration", +"../tests/m6.cc: In function int A ():", +"../tests/m6.cc:2: `a' undeclared (first use this function)", +"../tests/m6.cc:2: (Each undeclared identifier is reported only once", +"../tests/m6.cc:2: for each function it appears in.)", +"../tests/m6.cc:2: warning: control reaches end of non-void function" }; + diff --git a/gcc/testsuite/g++.old-deja/g++.pt/m7.C b/gcc/testsuite/g++.old-deja/g++.pt/m7.C new file mode 100644 index 000000000..4c7fdd5e9 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/m7.C @@ -0,0 +1,13 @@ +// { dg-do assemble } + +struct B { struct A { A(); int a; }; A aa; }; +B::A::A () { a = 37; } +const char *xx[]= {"/*", +"../tests/m7.cc:1: warning: return type specification for constructor invalid", +"../tests/m7.cc: In function struct A A ():", +"../tests/m7.cc:2: `a' undeclared (first use this function)", +"../tests/m7.cc:2: (Each undeclared identifier is reported only once", +"../tests/m7.cc:2: for each function it appears in.)", +"../tests/m7.cc:2: warning: control reaches end of non-void function", + "*/" }; + diff --git a/gcc/testsuite/g++.old-deja/g++.pt/m8.C b/gcc/testsuite/g++.old-deja/g++.pt/m8.C new file mode 100644 index 000000000..f87623339 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/m8.C @@ -0,0 +1,22 @@ +// { dg-do assemble } + +class A { + int a; + public: + A (int aa = 3); +}; + +class B { + class A { + public: + A (int, int); + }; + A aa; + public: + B (int); +}; + +extern void foo(); +B::B (int z) : aa (1, z) { + foo (); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/m9.C b/gcc/testsuite/g++.old-deja/g++.pt/m9.C new file mode 100644 index 000000000..1fd5a3adb --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/m9.C @@ -0,0 +1,16 @@ +// { dg-do assemble } + +struct A { A() { a = 1; } int a; }; +struct Q { + struct A { A() { a = 2; } int a; }; + struct R { + struct A { A() { a = 3; } int a; }; + A aaz; + }; + R rrr; + A aay; +} +; + +Q qqq; +A aav; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/m9a.C b/gcc/testsuite/g++.old-deja/g++.pt/m9a.C new file mode 100644 index 000000000..05d2484c9 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/m9a.C @@ -0,0 +1,5 @@ +// { dg-do assemble } + +struct A { A() { a = 1; } int a; }; // { dg-error "" } +struct A { A() { a = 2; } int a; }; // { dg-error "" } +A aavv; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/mangle1.C b/gcc/testsuite/g++.old-deja/g++.pt/mangle1.C new file mode 100644 index 000000000..d7be4fbf0 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/mangle1.C @@ -0,0 +1,10 @@ +// { dg-do assemble } +// Origin: Mark Mitchell <mark@codesourcery.com> + +typedef enum {} i; + +template <int II> +class Bar {}; + +void f (Bar<21>, int) {} +void f (Bar<2>, i) {} 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 000000000..1bd0e1330 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/mangle2.C @@ -0,0 +1,40 @@ +// { dg-do assemble } +// +// 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/memclass1.C b/gcc/testsuite/g++.old-deja/g++.pt/memclass1.C new file mode 100644 index 000000000..e1d748a3c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/memclass1.C @@ -0,0 +1,14 @@ +// { dg-do run } +template <class T> struct A { + template <class U> struct B { + template <class V> void f (V) { } + void g () { } + }; +}; + +int main () +{ + A<int>::B<char> b; + b.f (42); + b.g (); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/memclass10.C b/gcc/testsuite/g++.old-deja/g++.pt/memclass10.C new file mode 100644 index 000000000..92bd3d383 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/memclass10.C @@ -0,0 +1,10 @@ +// { dg-do assemble } + +struct S1 +{ + template <class T> + struct S2 {}; // { dg-error "" } previous definition + + template <class T> + struct S2 {}; // { dg-error "" } redefinition +}; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/memclass11.C b/gcc/testsuite/g++.old-deja/g++.pt/memclass11.C new file mode 100644 index 000000000..47e52c498 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/memclass11.C @@ -0,0 +1,14 @@ +// { dg-do assemble } + +struct S1 +{ + template <class T> + struct S2; + + template <class T> + struct S2 { + enum E { a }; + }; +}; + +int i = (int) S1::S2<double>::a; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/memclass12.C b/gcc/testsuite/g++.old-deja/g++.pt/memclass12.C new file mode 100644 index 000000000..330416a59 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/memclass12.C @@ -0,0 +1,6 @@ +// { dg-do assemble } + +struct outer { + template <class T> struct inner; +} o; +template <class T> struct outer::inner {}; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/memclass13.C b/gcc/testsuite/g++.old-deja/g++.pt/memclass13.C new file mode 100644 index 000000000..39a3d97b8 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/memclass13.C @@ -0,0 +1,16 @@ +// { dg-do assemble } + +template <class X, class Y> +struct Inner; + +template <class T> +struct S +{ + template <class U> + struct Inner + { + }; +}; + + +S<double>::Inner<int> si; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/memclass14.C b/gcc/testsuite/g++.old-deja/g++.pt/memclass14.C new file mode 100644 index 000000000..d6dc5e0a5 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/memclass14.C @@ -0,0 +1,15 @@ +// { dg-do assemble } + +template <class X, class Y> +struct Inner; + +struct S +{ + template <class U> + struct Inner + { + }; +}; + + +S::Inner<int> si; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/memclass15.C b/gcc/testsuite/g++.old-deja/g++.pt/memclass15.C new file mode 100644 index 000000000..fd68256aa --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/memclass15.C @@ -0,0 +1,27 @@ +// { dg-do assemble } + +template <class T> +struct S1 +{ + template <class U> + struct S2 {}; + + template <class X, class Y, class Z> + void f(X, Y, Z) + { + S2<Z> s2z; + } + + template <class X, class Z> + void g(X, Z) + { + S2<Z> s2z; + } +}; + + +void h() +{ + S1<int> si; + si.g(3, 4); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/memclass16.C b/gcc/testsuite/g++.old-deja/g++.pt/memclass16.C new file mode 100644 index 000000000..9528a2ceb --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/memclass16.C @@ -0,0 +1,13 @@ +// { dg-do assemble } + +template <class Q> +class A { +public: + + typedef enum { X, Y } B; + template <B c> class Traits{ }; +}; + + +template class A<int>; +template class A<double>::Traits<A<double>::X>; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/memclass17.C b/gcc/testsuite/g++.old-deja/g++.pt/memclass17.C new file mode 100644 index 000000000..0750ded61 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/memclass17.C @@ -0,0 +1,22 @@ +// { dg-do assemble } + +template <class T> struct S +{ + template <class U> struct I + { + }; + + S(); + S(S& s); + S(I<T>); + + template <class U> operator I<U>(); +}; + +S<int> f(); +void g(S<int>); + +void h() +{ + g(f()); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/memclass18.C b/gcc/testsuite/g++.old-deja/g++.pt/memclass18.C new file mode 100644 index 000000000..df9a12976 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/memclass18.C @@ -0,0 +1,9 @@ +// { dg-do assemble } + +template <class T> struct A { + template <class U> struct B; +}; + +template <class T> template <class U> struct A<T>::B { }; + +A<int>::B<int> b; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/memclass19.C b/gcc/testsuite/g++.old-deja/g++.pt/memclass19.C new file mode 100644 index 000000000..d345e5814 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/memclass19.C @@ -0,0 +1,9 @@ +// { dg-do assemble } + +template <class T> struct A { + template <class U> struct B; +}; + +template <class T> template <class U> struct A<T>::B<U*> { }; + +A<int>::B<int*> b; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/memclass2.C b/gcc/testsuite/g++.old-deja/g++.pt/memclass2.C new file mode 100644 index 000000000..bfad59687 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/memclass2.C @@ -0,0 +1,19 @@ +// { dg-do run } +template <class T> struct A { + template <class U> struct B { + template <class V> void f (V) { } + void g () { } + }; + template <class W> struct B<W*> { + void h () { } + }; +}; + +int main () +{ + A<int>::B<char> b; + b.f (42); + b.g (); + A<double>::B<void*> b2; + b2.h (); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/memclass20.C b/gcc/testsuite/g++.old-deja/g++.pt/memclass20.C new file mode 100644 index 000000000..f543be6af --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/memclass20.C @@ -0,0 +1,18 @@ +// { dg-do assemble } +// Origin: Mark Mitchell <mark@codesourcery.com> + +template <class X, class Y> +struct S{}; + +template <class X> +struct S<int, X> { + template <class W> + struct I {}; +}; + +template <class T> +void f() { + typename S<T, T>::template I<T> si; +} + +template void f<int>(); diff --git a/gcc/testsuite/g++.old-deja/g++.pt/memclass21.C b/gcc/testsuite/g++.old-deja/g++.pt/memclass21.C new file mode 100644 index 000000000..7ac87a785 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/memclass21.C @@ -0,0 +1,11 @@ +// { dg-do assemble } +// Origin: <Corey Kosak> kosak@cs.cmu.edu + +struct moo { + template<bool x> struct cow {}; + + template<bool x> + struct moo2 { + void func(cow<x> &c) { } + }; +}; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/memclass3.C b/gcc/testsuite/g++.old-deja/g++.pt/memclass3.C new file mode 100644 index 000000000..d2f0449fa --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/memclass3.C @@ -0,0 +1,22 @@ +// { dg-do run } +template <class T> struct A { + template <class U> struct B { + template <class V> struct C { + template <class W> struct D { + template <class X> struct E { + template <class Y> struct F { + template <class Z> void f (Z) { } + void g () { } + }; + }; + }; + }; + }; +}; + +int main () +{ + A<int>::B<int>::C<int>::D<int>::E<int>::F<int> b; + b.f (42); + b.g (); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/memclass4.C b/gcc/testsuite/g++.old-deja/g++.pt/memclass4.C new file mode 100644 index 000000000..04e3acef9 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/memclass4.C @@ -0,0 +1,24 @@ +// { dg-do run } +#include <typeinfo> + +template <class T> +struct allocator { + typedef T* pointer; + + template <class U> struct rebind { + typedef allocator<U> other; + }; +}; + +template <class T, class Allocator> +struct alloc_traits +{ + typedef typename Allocator::template rebind<T>::other allocator_type; +}; + +int main () +{ + typedef alloc_traits<int, allocator<void> >::allocator_type at; + + return typeid (at) != typeid (allocator <int>); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/memclass5.C b/gcc/testsuite/g++.old-deja/g++.pt/memclass5.C new file mode 100644 index 000000000..95dffba5b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/memclass5.C @@ -0,0 +1,23 @@ +// { dg-do run } +template <class T> struct A { + template <class U> struct B { + template <class V> static void f () { } + void g () { } + }; +}; + +template <class T, class U> +void f () +{ + A<T>::template B<U>::template f<T> (); + typename A<T>::template B<U> b; + typename A<T>::template B<U> b2; + b.A<T>::template B<U>::~B(); +} + +template <class T> struct C: public A<T>::template B<T> { }; + +int main () +{ + f<int, char>(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/memclass6.C b/gcc/testsuite/g++.old-deja/g++.pt/memclass6.C new file mode 100644 index 000000000..b462b920f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/memclass6.C @@ -0,0 +1,19 @@ +// { dg-do run } +// Compiler: egcs-2.91.12 980302 +// Error: compiler error in ctor of 'foo::bar<T>::bar(T const &)' + +struct foo +{ + template <typename T> + struct bar + { + bar(T const &t) : tt(t) {} + T tt; + }; +}; + +int main() +{ + foo::bar<int> fb(3); + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/memclass7.C b/gcc/testsuite/g++.old-deja/g++.pt/memclass7.C new file mode 100644 index 000000000..ec9c58cc0 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/memclass7.C @@ -0,0 +1,20 @@ +// { dg-do run } +// { dg-options "-ansi -pedantic-errors -w" } +struct S +{ + template <class U> + struct Y { + template <class T> + void foo(T t); + }; +}; + +template <> +template <> +void S::Y<char>::foo<int>(int i) { } + +int main() +{ + S::Y<char> s; + s.foo<int>(3.0); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/memclass8.C b/gcc/testsuite/g++.old-deja/g++.pt/memclass8.C new file mode 100644 index 000000000..1e757e7ca --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/memclass8.C @@ -0,0 +1,11 @@ +// { dg-do assemble } + +template <class T> +class S +{ + template <class U> + struct S2 { + S2(const S2<U>& s2u) {} + }; +}; + diff --git a/gcc/testsuite/g++.old-deja/g++.pt/memclass9.C b/gcc/testsuite/g++.old-deja/g++.pt/memclass9.C new file mode 100644 index 000000000..0795d69bf --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/memclass9.C @@ -0,0 +1,32 @@ +// { dg-do assemble } + +template <class T> +struct S1 +{ + template <class U> + struct S2 + { + S2(U); + + void g() + { + S2<U> s2u (u); + } + + U& u; + }; + + template <class U> + void f(U u) + { + S2<U> s2u(u); + s2u.g(); + } +}; + +void g() +{ + S1<int> s1; + s1.f(3.0); +} + diff --git a/gcc/testsuite/g++.old-deja/g++.pt/memtemp1.C b/gcc/testsuite/g++.old-deja/g++.pt/memtemp1.C new file mode 100644 index 000000000..5aa83dd42 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/memtemp1.C @@ -0,0 +1,15 @@ +// { dg-do assemble } +// GROUPS passed templates membertemplates +struct S { + template <class T> + void foo(T&); +}; + + +template <class T> +void S::foo(T&) +{ +} + + + diff --git a/gcc/testsuite/g++.old-deja/g++.pt/memtemp10.C b/gcc/testsuite/g++.old-deja/g++.pt/memtemp10.C new file mode 100644 index 000000000..d97f949de --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/memtemp10.C @@ -0,0 +1,24 @@ +// { dg-do link } +// GROUPS passed templates membertemplates +extern "C" int printf(const char*, ...); + +struct S { + template <class T> + operator T*(); +}; + + +template <class T> +S::operator T*() +{ + printf("Hello, world.\n"); + return 0; +} + + +int main() +{ + S s; + + char* cp = s.operator char*(); +} 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 000000000..c0495233a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/memtemp100.C @@ -0,0 +1,40 @@ +// { dg-do assemble } +// { dg-options "" } +// Origin: philippeb@videotron.ca + +#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/memtemp11.C b/gcc/testsuite/g++.old-deja/g++.pt/memtemp11.C new file mode 100644 index 000000000..8e8c3c1ac --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/memtemp11.C @@ -0,0 +1,27 @@ +// { dg-do link } +// GROUPS passed templates membertemplates +extern "C" int printf(const char*, ...); + +struct S +{ + template <class U> + S(U u, int i) {} + + template <class T> + T foo(T t) + { + printf("Hello, world.\n"); + return t; + } +}; + + +int main() +{ + S s(3, 4); + int i = s.foo(3); + s.foo("hello"); + s.foo(s); + + S s2("hello", 5); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/memtemp12.C b/gcc/testsuite/g++.old-deja/g++.pt/memtemp12.C new file mode 100644 index 000000000..b390becb9 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/memtemp12.C @@ -0,0 +1,13 @@ +// { dg-do assemble } +// GROUPS passed templates membertemplates +template <class T> +struct S +{ + template <class U> + void foo(U); +}; + +void f() +{ + S<int> s; +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/memtemp13.C b/gcc/testsuite/g++.old-deja/g++.pt/memtemp13.C new file mode 100644 index 000000000..3a19f65e7 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/memtemp13.C @@ -0,0 +1,15 @@ +// { dg-do assemble } +// GROUPS passed templates membertemplates +template <class T> +struct S +{ + template <class U> + void foo(U); +}; + +void f() +{ + S<int> s; + s.foo(3); + s.foo("hello"); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/memtemp14.C b/gcc/testsuite/g++.old-deja/g++.pt/memtemp14.C new file mode 100644 index 000000000..015aa25dc --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/memtemp14.C @@ -0,0 +1,30 @@ +// { dg-do link } +// GROUPS passed templates membertemplates +extern "C" int printf (const char *, ...); + +template <class T> +struct S +{ + template <class U, class V> + void foo(U, V); +}; + + +template <class T> +template <class U, class V> +void S<T>::foo(U, V) +{ + printf("Hello, world.\n"); +} + + +int main() +{ + S<int> s; + s.foo(3, 3); + s.foo("hello", s); + + S<char*> s2; + s2.foo(3, 3); + s2.foo("hello", s); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/memtemp15.C b/gcc/testsuite/g++.old-deja/g++.pt/memtemp15.C new file mode 100644 index 000000000..b9b69873a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/memtemp15.C @@ -0,0 +1,16 @@ +// { dg-do assemble } +// GROUPS passed templates membertemplates +template <class T> +struct S +{ + template <class U> + void foo(U) {} +}; + + +void f() +{ + S<int> s; + s.foo(3); + s.foo("hello"); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/memtemp16.C b/gcc/testsuite/g++.old-deja/g++.pt/memtemp16.C new file mode 100644 index 000000000..c5597eab7 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/memtemp16.C @@ -0,0 +1,30 @@ +// { dg-do link } +// GROUPS passed templates membertemplates +extern "C" int printf(const char*, ...); + +template <class U> +struct S { + template <class T> + void operator+(T); +}; + +template <class U> +template <class T> +void S<U>::operator+(T) +{ + printf("Hello, world.\n"); +} + + +int main() +{ + S<int> s; + s + 3; + s + s; + s.operator+("Hi"); + + S<S<int> > s2; + s2 + 3; + s2 + s; + s2.operator+("Hi"); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/memtemp17.C b/gcc/testsuite/g++.old-deja/g++.pt/memtemp17.C new file mode 100644 index 000000000..4e8442457 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/memtemp17.C @@ -0,0 +1,26 @@ +// { dg-do link } +// GROUPS passed templates membertemplates +extern "C" int printf(const char*, ...); + +template <class V> +struct S { + template <class T, class U> + S(T, U, T); +}; + + +template <class V> +template <class T, class U> +S<V>::S(T t1, U u1, T t2) +{ + printf("Hello, world.\n"); +} + + +int main() +{ + S<int> s1(3, "abc", 3); + S<int> s2('a', s1, 'a'); + + S<char> s3("abc", 3, "abc"); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/memtemp18.C b/gcc/testsuite/g++.old-deja/g++.pt/memtemp18.C new file mode 100644 index 000000000..b51f4dbe7 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/memtemp18.C @@ -0,0 +1,16 @@ +// { dg-do assemble } +// GROUPS passed templates membertemplates +struct S +{ + template <class T> + void foo(T) {} +}; + +template void S::foo(int); + +int main() +{ + S s; + s.foo(3); +} + diff --git a/gcc/testsuite/g++.old-deja/g++.pt/memtemp19.C b/gcc/testsuite/g++.old-deja/g++.pt/memtemp19.C new file mode 100644 index 000000000..2f9dec9ae --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/memtemp19.C @@ -0,0 +1,25 @@ +// { dg-do link } +// GROUPS passed templates membertemplates +extern "C" int printf(const char*, ...); + +struct S { + template <class T> + operator T(); +}; + +template <class T> +S::operator T() +{ + printf("Hello, world.\n"); + return T(); +} + + +template S::operator int(); + +int main() +{ + S s; + + int i = s.operator int(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/memtemp2.C b/gcc/testsuite/g++.old-deja/g++.pt/memtemp2.C new file mode 100644 index 000000000..5c870fe52 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/memtemp2.C @@ -0,0 +1,15 @@ +// { dg-do assemble } +// GROUPS passed templates membertemplates +struct S { + template <class T> + void foo(T&); +}; + + +template <class U> +void S::foo(U&) +{ +} + + + diff --git a/gcc/testsuite/g++.old-deja/g++.pt/memtemp20.C b/gcc/testsuite/g++.old-deja/g++.pt/memtemp20.C new file mode 100644 index 000000000..0295c9786 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/memtemp20.C @@ -0,0 +1,43 @@ +// { dg-do link } +// GROUPS passed templates membertemplates +extern "C" int printf(const char*, ...); + +struct S +{ + template <class T, class U> + void foo(T t, U u); + + template <class U> + void foo(char*, U); + + void foo(int i); +}; + +template <class T, class U> +void S::foo(T t, U u) +{ + printf ("T,U version\n"); +} + + +template <class U> +void S::foo(char*, U u) +{ + printf ("char*,U version\n"); +} + + +void S::foo(int i) +{ + printf ("int version\n"); +} + + +int main() +{ + S s; + s.foo(3); + s.foo(3, 3); + s.foo("abc", s); +} + diff --git a/gcc/testsuite/g++.old-deja/g++.pt/memtemp23.C b/gcc/testsuite/g++.old-deja/g++.pt/memtemp23.C new file mode 100644 index 000000000..3111f41b5 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/memtemp23.C @@ -0,0 +1,24 @@ +// { dg-do link } +// GROUPS passed templates membertemplates +extern "C" int printf(const char*, ...); + +template <class X> +struct S +{ + S() + { printf ("In S::S()\n"); f(3); } + + S(char) + { printf ("In S::S(char)\n"); f(*this); } + + template <class U> + void f(U u) + { printf ("In S::f(U)\nsizeof(U) == %d\n", sizeof(u)); } + + int c[16]; +}; + +int main() +{ + S<char*> s; +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/memtemp24.C b/gcc/testsuite/g++.old-deja/g++.pt/memtemp24.C new file mode 100644 index 000000000..4e81d015d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/memtemp24.C @@ -0,0 +1,25 @@ +// { dg-do link } +// GROUPS passed templates membertemplates +extern "C" int printf(const char*, ...); + +template <class X> +struct S +{ + S() + { printf ("In S::S()\n"); f(3); } + + S(char) + { printf ("In S::S(char)\n"); f(*this); } + + template <class U> + void f(U u) + { printf ("In S::f(U)\nsizeof(U) == %d\n", sizeof(u)); } + + int c[16]; +}; + +int main() +{ + S<char*> s; + S<char*> s2('a'); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/memtemp25.C b/gcc/testsuite/g++.old-deja/g++.pt/memtemp25.C new file mode 100644 index 000000000..6c196f5d4 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/memtemp25.C @@ -0,0 +1,20 @@ +// { dg-do link } +// GROUPS passed templates membertemplates +extern "C" int printf(const char*, ...); + +template <class X> +struct S +{ + template <class U> + void f(U u) { printf ("%d\n", sizeof (U)); } + + int i[4]; +}; + + +int main() +{ + S<char*> s; + s.f(3); + s.f(s); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/memtemp26.C b/gcc/testsuite/g++.old-deja/g++.pt/memtemp26.C new file mode 100644 index 000000000..3eb5f287d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/memtemp26.C @@ -0,0 +1,28 @@ +// { dg-do link } +// GROUPS passed templates membertemplates +extern "C" int printf(const char*, ...); + +template <class X> +struct S +{ + template <class U> + void f(U u); + + int i[4]; +}; + + +template <class X> +template <class U> +void S<X>::f(U u) +{ + printf ("%d\n", sizeof (U)); +} + + +int main() +{ + S<char*> s; + s.f(3); + s.f(s); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/memtemp28.C b/gcc/testsuite/g++.old-deja/g++.pt/memtemp28.C new file mode 100644 index 000000000..4be565a04 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/memtemp28.C @@ -0,0 +1,28 @@ +// { dg-do run } +extern "C" void abort(); + +int k; + +template <class X> +struct S +{ + template <class U> + void f(U u) + { ++k; g(u); } + + template <class U> + void g(U u) + { ++k; } + + int c[16]; +}; + +int main() +{ + S<char*> s; + s.f(3); + s.f("adf"); + + if (k != 4) + abort(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/memtemp29.C b/gcc/testsuite/g++.old-deja/g++.pt/memtemp29.C new file mode 100644 index 000000000..808f233c6 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/memtemp29.C @@ -0,0 +1,32 @@ +// { dg-do link } +// GROUPS passed templates membertemplates +extern "C" int printf(const char*, ...); + +template <class X> +struct S +{ + template <class U> + void f(U u); + + template <class U> + void g(U u); + + int c[16]; +}; + +template <class X> +template <class U> +void S<X>::f(U u) + { printf ("In S::f(U)\n"); g(u); } + +template <class X> +template <class U> +void S<X>::g(U u) + { printf ("In S::g(U)\n"); } + +int main() +{ + S<char*> s; + s.f(3); + s.f("adf"); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/memtemp3.C b/gcc/testsuite/g++.old-deja/g++.pt/memtemp3.C new file mode 100644 index 000000000..c3b78533f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/memtemp3.C @@ -0,0 +1,24 @@ +// { dg-do link } +// GROUPS passed templates membertemplates +extern "C" int printf(const char*, ...); + +struct S { + template <class T> + void foo(T); +}; + + +template <class T> +void S::foo(T) +{ + printf("Hello, world.\n"); +} + + + +int main() +{ + S s; + s.foo(3); + s.foo(s); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/memtemp30.C b/gcc/testsuite/g++.old-deja/g++.pt/memtemp30.C new file mode 100644 index 000000000..6a24d2e25 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/memtemp30.C @@ -0,0 +1,17 @@ +// { dg-do link } +// GROUPS passed templates membertemplates +extern "C" int printf(const char*, ...); + +template <class X> +struct S +{ + template <class U> + void g(U u) { this; } +}; + + +int main() +{ + S<char*> s; + s.g(3); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/memtemp31.C b/gcc/testsuite/g++.old-deja/g++.pt/memtemp31.C new file mode 100644 index 000000000..ad6688718 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/memtemp31.C @@ -0,0 +1,16 @@ +// { dg-do link } +// GROUPS passed templates membertemplates +extern "C" int printf(const char*, ...); + +struct S +{ + template <class U> + void g(U u) + { this; } +}; + +int main() +{ + S s; + s.g(3); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/memtemp32.C b/gcc/testsuite/g++.old-deja/g++.pt/memtemp32.C new file mode 100644 index 000000000..6dca7e5a0 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/memtemp32.C @@ -0,0 +1,18 @@ +// { dg-do link } +// GROUPS passed templates membertemplates +extern "C" int printf(const char*, ...); + +struct S +{ + template <class U> + void g(U u) + { i = 3; } + + int i; +}; + +int main() +{ + S s; + s.g(3); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/memtemp33.C b/gcc/testsuite/g++.old-deja/g++.pt/memtemp33.C new file mode 100644 index 000000000..917da1ef2 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/memtemp33.C @@ -0,0 +1,19 @@ +// { dg-do link } +// GROUPS passed templates membertemplates +extern "C" int printf(const char*, ...); + +template <class T> +struct S +{ + template <class U> + void g(U u) + { i; } + + int i; +}; + +int main() +{ + S<char> s; + s.g(3); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/memtemp34.C b/gcc/testsuite/g++.old-deja/g++.pt/memtemp34.C new file mode 100644 index 000000000..178baceb9 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/memtemp34.C @@ -0,0 +1,16 @@ +// { dg-do link } +// GROUPS passed templates membertemplates +template <class T> +struct S +{ + template <class U> + static void f(U u) + {} +}; + +int main() +{ + S<int>::f(3); + S<char>::f("abc"); + S<int>::f("abc"); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/memtemp35.C b/gcc/testsuite/g++.old-deja/g++.pt/memtemp35.C new file mode 100644 index 000000000..11cc223ad --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/memtemp35.C @@ -0,0 +1,21 @@ +// { dg-do assemble } +// GROUPS passed templates membertemplates +template <class T> +struct S +{ + S(const S& s) {} + + template <class U> + S(S<U>& s) + { + S<U> s2(s); + } +}; + + +extern S<int>& si; + +void foo() +{ + S<char*> sc(si); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/memtemp36.C b/gcc/testsuite/g++.old-deja/g++.pt/memtemp36.C new file mode 100644 index 000000000..ab035a700 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/memtemp36.C @@ -0,0 +1,21 @@ +// { dg-do assemble } +// GROUPS passed templates membertemplates +template <class X> +struct R +{ +}; + + +template <class T> +struct S +{ + template <class U> + S(R<U> r); +}; + + +void foo() +{ + R<int> r; + S<char*> s(r); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/memtemp37.C b/gcc/testsuite/g++.old-deja/g++.pt/memtemp37.C new file mode 100644 index 000000000..6299b0da7 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/memtemp37.C @@ -0,0 +1,20 @@ +// { dg-do assemble } +// GROUPS passed templates membertemplates +template <class T> +struct S +{ + template <class U> + void f(U u); +}; + + +template <class T> +template <class U> +void S<T>::f(U) +{ +} + +enum +{ + a = 3 +}; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/memtemp39.C b/gcc/testsuite/g++.old-deja/g++.pt/memtemp39.C new file mode 100644 index 000000000..f74deb49d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/memtemp39.C @@ -0,0 +1,17 @@ +// { dg-do assemble } +// GROUPS passed templates membertemplates +template <class T> +struct S +{ + template <class U> + void f(U u) { g(u); } + + template <class U> + void g(U u) { f(u); } +}; + +void foo() +{ + S<int> si; + si.f(3); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/memtemp4.C b/gcc/testsuite/g++.old-deja/g++.pt/memtemp4.C new file mode 100644 index 000000000..9dca76a3a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/memtemp4.C @@ -0,0 +1,12 @@ +// { dg-do assemble } +// GROUPS passed templates membertemplates +struct S { + template <class T> + void operator+(T); +}; + + +template <class T> +void S::operator+(T) +{ +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/memtemp40.C b/gcc/testsuite/g++.old-deja/g++.pt/memtemp40.C new file mode 100644 index 000000000..40ae3e6ea --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/memtemp40.C @@ -0,0 +1,21 @@ +// { dg-do assemble } +// GROUPS passed templates membertemplates +template <class T> +struct R +{ + template <class U> + void g(U u) {} +}; + +template <class T> +struct S +{ + template <class U> + void f(U u) { R<T> r; r.g(u); } +}; + +void foo() +{ + S<int> si; + si.f("abc"); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/memtemp41.C b/gcc/testsuite/g++.old-deja/g++.pt/memtemp41.C new file mode 100644 index 000000000..539b8451c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/memtemp41.C @@ -0,0 +1,7 @@ +// { dg-do assemble } +// GROUPS passed templates membertemplates +template <int i> +struct S +{ + static void foo() {} +}; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/memtemp42.C b/gcc/testsuite/g++.old-deja/g++.pt/memtemp42.C new file mode 100644 index 000000000..ea68f49fd --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/memtemp42.C @@ -0,0 +1,22 @@ +// { dg-do link } +// GROUPS passed templates membertemplates +template<class T, int N> +class Foo { + +public: + template<int N2> + Foo<T,N> operator=(const Foo<T,N2>& z) + { + return Foo<T,N>(); + } +}; + +int main() +{ + Foo<double,4> x; + Foo<double,7> y; + x = y; + + return 0; +} + diff --git a/gcc/testsuite/g++.old-deja/g++.pt/memtemp43.C b/gcc/testsuite/g++.old-deja/g++.pt/memtemp43.C new file mode 100644 index 000000000..417317118 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/memtemp43.C @@ -0,0 +1,16 @@ +// { dg-do link } +// GROUPS passed templates membertemplates +template<class T, int N> +class A +{ +public: + template<class U> + void operator=(A<U, N> const & a) { return; } +}; + +int main() +{ + A<float, 3> a; + A<double, 3> b; + a = b; +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/memtemp44.C b/gcc/testsuite/g++.old-deja/g++.pt/memtemp44.C new file mode 100644 index 000000000..a4a37df91 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/memtemp44.C @@ -0,0 +1,20 @@ +// { dg-do link } +// GROUPS passed templates membertemplates +template<class T> +class A +{ +}; + +template<> +class A<float> +{ +public: + template<class U> + void func(U v1) {} +}; + +int main() +{ + A<float> a; + a.func(3); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/memtemp45.C b/gcc/testsuite/g++.old-deja/g++.pt/memtemp45.C new file mode 100644 index 000000000..935e8621d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/memtemp45.C @@ -0,0 +1,20 @@ +// { dg-do link } +// GROUPS passed templates membertemplates +template<class T> +class A +{ +}; + +template<> +class A<float> +{ +public: + template<class U> + void func(U v1 = 0) {} +}; + +int main() +{ + A<float> a; + a.func(3); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/memtemp46.C b/gcc/testsuite/g++.old-deja/g++.pt/memtemp46.C new file mode 100644 index 000000000..6afbc6541 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/memtemp46.C @@ -0,0 +1,20 @@ +// { dg-do link } +// GROUPS passed templates membertemplates +template<class T, class U> +class A +{ +}; + +template<class U> +class A<float, U> +{ +public: + template <class V> + void func(V v1 = 0) {} +}; + +int main() +{ + A<float, int> a; + a.func("abc"); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/memtemp47.C b/gcc/testsuite/g++.old-deja/g++.pt/memtemp47.C new file mode 100644 index 000000000..7ed5a2492 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/memtemp47.C @@ -0,0 +1,29 @@ +// { dg-do link } +// GROUPS passed templates membertemplates +extern "C" int printf(const char*, ...); + +template <class X> +struct S +{ + template <class U> + void g(U u) + { printf ("In S::g(U)\n"); } + + int c[16]; +}; + + +template <class X> +struct T : public S<X> +{ + template <class U> + void f(U u) + { printf ("In T::f(U)\n"); g(u); } +}; + +int main() +{ + T<char*> t; + t.f(3); + t.f("adf"); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/memtemp48.C b/gcc/testsuite/g++.old-deja/g++.pt/memtemp48.C new file mode 100644 index 000000000..619ca66cd --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/memtemp48.C @@ -0,0 +1,15 @@ +// { dg-do assemble } +// GROUPS passed templates membertemplates +struct S +{ + template <class T> + void f(T t1, T t = T()) + {} +}; + + +void foo() +{ + S si; + si.f(3); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/memtemp49.C b/gcc/testsuite/g++.old-deja/g++.pt/memtemp49.C new file mode 100644 index 000000000..381510b15 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/memtemp49.C @@ -0,0 +1,16 @@ +// { dg-do assemble } +// GROUPS passed templates membertemplates +template <class X> +struct S +{ + template <class T> + void f(T t1, T t = T()) + {} +}; + + +void foo() +{ + S<int> si; + si.f(3); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/memtemp5.C b/gcc/testsuite/g++.old-deja/g++.pt/memtemp5.C new file mode 100644 index 000000000..faff68714 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/memtemp5.C @@ -0,0 +1,25 @@ +// { dg-do link } +// GROUPS passed templates membertemplates +extern "C" int printf(const char*, ...); + +struct S { + template <class T> + void operator+(T); +}; + + +template <class T> +void S::operator+(T) +{ + printf("Hello, world.\n"); +} + + + +int main() +{ + S s; + s + 3; + s + s; + s.operator+("Hi"); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/memtemp52.C b/gcc/testsuite/g++.old-deja/g++.pt/memtemp52.C new file mode 100644 index 000000000..f8ae90618 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/memtemp52.C @@ -0,0 +1,20 @@ +// { dg-do assemble } +// GROUPS passed templates membertemplates +template<class T, int N> +class A { }; + +template<int N> +struct X { + template<class T2, int N2> + void f(A<T2,N>&, A<int,N2>&) + { } +}; + + +void foo() +{ + X<3> x; + A<char*, 3> a1; + A<int, 2> a2; + x.f(a1, a2); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/memtemp53.C b/gcc/testsuite/g++.old-deja/g++.pt/memtemp53.C new file mode 100644 index 000000000..688f480d0 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/memtemp53.C @@ -0,0 +1,36 @@ +// { dg-do link } +// GROUPS passed templates membertemplates +template<int N> +struct I { +}; + +template<class T> +struct A { + + int r; + + template<class T1, class T2> + void operator()(T1, T2) + { r = 0; } + + template<int N1, int N2> + void operator()(I<N1>, I<N2>) + { r = 1; } +}; + +int main() +{ + A<float> x; + I<0> a; + I<1> b; + + x(a,b); + if (x.r != 1) + return 1; + + x(float(), double()); + if (x.r != 0) + return 1; + + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/memtemp55.C b/gcc/testsuite/g++.old-deja/g++.pt/memtemp55.C new file mode 100644 index 000000000..5c799198b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/memtemp55.C @@ -0,0 +1,10 @@ +// { dg-do assemble } +// GROUPS passed templates membertemplates +template<class X> class _bz_update { }; + +template<class T> +struct S { +template<int N_destRank> +void foo() { _bz_update<int>(); } +}; + diff --git a/gcc/testsuite/g++.old-deja/g++.pt/memtemp56.C b/gcc/testsuite/g++.old-deja/g++.pt/memtemp56.C new file mode 100644 index 000000000..2000a351c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/memtemp56.C @@ -0,0 +1,15 @@ +// { dg-do assemble } +// GROUPS passed templates membertemplates +template<class P_numtype, int N_length> +class TinyVector {}; + +template<class P_numtype, int N_rank> +struct Array +{ + template<int N_rank2> + Array() {} + + template<int N_rank2> + P_numtype operator()(const TinyVector<int,N_rank2>& index) const {} +}; + diff --git a/gcc/testsuite/g++.old-deja/g++.pt/memtemp58.C b/gcc/testsuite/g++.old-deja/g++.pt/memtemp58.C new file mode 100644 index 000000000..78111c710 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/memtemp58.C @@ -0,0 +1,30 @@ +// { dg-do assemble } +// GROUPS passed templates membertemplates +template<int N, class T> +struct B { +}; + +template<int N1, int N2, int N3> +struct D { + struct E { + template<int N4, class T> + static void f(B<N4,T>) + { } + }; +}; + +template<int N> +struct A { + template<int N2, class T, int N3> + static void f(B<N2,T>, B<N3,T> b) + { + typedef typename D<N2,N3,N>::E E; + E::f(b); + } +}; + +void foo() +{ + A<5>::f(B<5,float>(),B<3,float>()); +} + diff --git a/gcc/testsuite/g++.old-deja/g++.pt/memtemp59.C b/gcc/testsuite/g++.old-deja/g++.pt/memtemp59.C new file mode 100644 index 000000000..4ac85f5ee --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/memtemp59.C @@ -0,0 +1,22 @@ +// { dg-do assemble } +// GROUPS passed templates membertemplates +template <int N> +struct IndexPlaceholder {}; + +template <int N1, int N2, int N3> +struct ArrayIndexMapping {}; + +template <class T_numtype, int N_rank> +struct Array +{ + template<int N0, int N1> + ArrayIndexMapping<N_rank, N0, N1> + f(IndexPlaceholder<N0>, IndexPlaceholder<N1>); +}; + + +template <class T_numtype> +void foo(T_numtype) +{ + Array<T_numtype, 1> t; +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/memtemp6.C b/gcc/testsuite/g++.old-deja/g++.pt/memtemp6.C new file mode 100644 index 000000000..d7675cb8e --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/memtemp6.C @@ -0,0 +1,13 @@ +// { dg-do assemble } +// GROUPS passed templates membertemplates +struct S { + template <class T, class U> + S(T, U, T); +}; + + +template <class T, class U> +S::S(T, U, T) +{ +} + diff --git a/gcc/testsuite/g++.old-deja/g++.pt/memtemp60.C b/gcc/testsuite/g++.old-deja/g++.pt/memtemp60.C new file mode 100644 index 000000000..d0d5b0b65 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/memtemp60.C @@ -0,0 +1,10 @@ +// { dg-do assemble } +// GROUPS passed membertemplates +template <class T> +struct S +{ + S(const S<T>& x) {} + + template <class U> + S(const S<U>& x) {} +}; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/memtemp61.C b/gcc/testsuite/g++.old-deja/g++.pt/memtemp61.C new file mode 100644 index 000000000..2e65e817b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/memtemp61.C @@ -0,0 +1,20 @@ +// { dg-do link } +// GROUPS passed membertemplates +struct S +{ + template <class T> + void foo(T t); +}; + + +template <> +void S::foo(int i) +{ +} + + +int main() +{ + S s; + s.foo(3); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/memtemp62.C b/gcc/testsuite/g++.old-deja/g++.pt/memtemp62.C new file mode 100644 index 000000000..d25ddfa9a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/memtemp62.C @@ -0,0 +1,20 @@ +// { dg-do link } +// GROUPS passed membertemplates +struct S +{ + template <class T> + void foo(T t); +}; + + +template <> +void S::foo<int>(int i) +{ +} + + +int main() +{ + S s; + s.foo(3); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/memtemp63.C b/gcc/testsuite/g++.old-deja/g++.pt/memtemp63.C new file mode 100644 index 000000000..62a52a16d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/memtemp63.C @@ -0,0 +1,14 @@ +// { dg-do run } +template <class T> struct A { + template <class U> void f (U u); +}; + +A<int> a; + +template <class T> template <class U> void A<T>::f (U u) { } + +int main() +{ + a.f (24); +} + diff --git a/gcc/testsuite/g++.old-deja/g++.pt/memtemp64.C b/gcc/testsuite/g++.old-deja/g++.pt/memtemp64.C new file mode 100644 index 000000000..dda0a63b4 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/memtemp64.C @@ -0,0 +1,21 @@ +// { dg-do assemble } + +template <class T> +struct S1 {}; + +template <class T> +void f(T); + +template <class C> +struct S2 +{ + template <class T> + void f<S1<T> >(T) {} // { dg-error "" } bad specialization. +}; + + +template <class T> +struct S3 +{ + friend class S2<T>; +}; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/memtemp65.C b/gcc/testsuite/g++.old-deja/g++.pt/memtemp65.C new file mode 100644 index 000000000..76eab7f1f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/memtemp65.C @@ -0,0 +1,23 @@ +// { dg-do assemble } + +template<unsigned int n> struct PartialDotProduct { + template<class T> + static T Expand(T* a, T* b) { return T(); } +}; + +const int N = 10; + +template<class In1, class In2> +void +dot(In1 f1, In2 f2) +{ + PartialDotProduct<N>::Expand(f1, f2); + +} + +int main() +{ + double a[N], b[N]; + + dot(&a[0], &b[0]); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/memtemp66.C b/gcc/testsuite/g++.old-deja/g++.pt/memtemp66.C new file mode 100644 index 000000000..b6e8b6ff4 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/memtemp66.C @@ -0,0 +1,15 @@ +// { dg-do assemble } + +template <class T> +struct S +{ + template <class U> + void f(U u) { this->template f<>(3); } +}; + + +void g() +{ + S<char> s; + s.f(1.0); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/memtemp67.C b/gcc/testsuite/g++.old-deja/g++.pt/memtemp67.C new file mode 100644 index 000000000..1f25dcd4d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/memtemp67.C @@ -0,0 +1,20 @@ +// { dg-do run } +template <class T> +struct A +{ + template <class T2> + operator A<T2>() const { return A<T2>(); } +}; + +int main() +{ + A<int> a1; + A<long> a2; + A<double> a3; + A<char> a4; + + a2 = a1.operator A<long>(); + a3 = (A<double>) a1; + a4 = a1; +} + diff --git a/gcc/testsuite/g++.old-deja/g++.pt/memtemp68.C b/gcc/testsuite/g++.old-deja/g++.pt/memtemp68.C new file mode 100644 index 000000000..63a7014a4 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/memtemp68.C @@ -0,0 +1,9 @@ +// { dg-do assemble } + + struct locale + { + template<class _Facet> + locale (const locale&, _Facet*); + locale(int*) throw(); + }; + void f(int* p) { locale keep (p); } diff --git a/gcc/testsuite/g++.old-deja/g++.pt/memtemp69.C b/gcc/testsuite/g++.old-deja/g++.pt/memtemp69.C new file mode 100644 index 000000000..9b47d441e --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/memtemp69.C @@ -0,0 +1,36 @@ +// { dg-do run } +struct S +{ + template <class T> + void f(T (&i)[7]) + {} + + void g() + { + int i[] = {1, 2, 3, 4, 5, 6, 7}; + f(i); + int j[7]; + f(j); + } +}; + +struct foo { + template <typename T, int N> + static T* array_end(T(&array)[N]) { return &array[N]; } +}; + +struct X +{ + template <class T1> + void f(const T1&) {} +}; + +int main(int ac, char* av[]) { + S s; + s.g(); + int i[] = {1,2,3,4,5}; + int* e = foo::array_end(i); + X x; + x.f("hello"); +} + diff --git a/gcc/testsuite/g++.old-deja/g++.pt/memtemp7.C b/gcc/testsuite/g++.old-deja/g++.pt/memtemp7.C new file mode 100644 index 000000000..02b1fc6bd --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/memtemp7.C @@ -0,0 +1,22 @@ +// { dg-do link } +// GROUPS passed templates membertemplates +extern "C" int printf(const char*, ...); + +struct S { + template <class T, class U> + S(T, U, T); +}; + + +template <class T, class U> +S::S(T t1, U u1, T t2) +{ + printf("Hello, world.\n"); +} + + +int main() +{ + S s1(3, "abc", 3); + S s2('a', s1, 'a'); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/memtemp70.C b/gcc/testsuite/g++.old-deja/g++.pt/memtemp70.C new file mode 100644 index 000000000..8873a3954 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/memtemp70.C @@ -0,0 +1,24 @@ +// { dg-do assemble } + +template <class T> +class X { +public: + T x; +}; + +class Y { +public: + template <class T> static void f(X<T>& a) {} + + void g(void); +}; + +void +Y::g(void) +{ + X<int> a; + + f(a); +} + + diff --git a/gcc/testsuite/g++.old-deja/g++.pt/memtemp71.C b/gcc/testsuite/g++.old-deja/g++.pt/memtemp71.C new file mode 100644 index 000000000..74149a005 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/memtemp71.C @@ -0,0 +1,6 @@ +// { dg-do assemble } + +class A +{ + template<class T>T epsilon; // { dg-error "" } invalid member template +}; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/memtemp72.C b/gcc/testsuite/g++.old-deja/g++.pt/memtemp72.C new file mode 100644 index 000000000..26bd4bc18 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/memtemp72.C @@ -0,0 +1,17 @@ +// { dg-do assemble } + +template<class P> struct B +{ + template<class T> void f(T& t) { t = T(); } +}; + +enum ptype { t1, t2}; + +struct D : public B<ptype> +{ + void g(double& d) { f(d); } +}; + + +D d; + diff --git a/gcc/testsuite/g++.old-deja/g++.pt/memtemp73.C b/gcc/testsuite/g++.old-deja/g++.pt/memtemp73.C new file mode 100644 index 000000000..5580d9063 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/memtemp73.C @@ -0,0 +1,19 @@ +// { dg-do run } +template <class T> struct A { + template <class U> void f(U); +}; + +template <int i> struct B { }; + +template <class T> template <class U> +void A<T>::f (U) +{ + enum { foo }; + B<foo> b; +} + +int main () +{ + A<char> a; + a.f (42); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/memtemp74.C b/gcc/testsuite/g++.old-deja/g++.pt/memtemp74.C new file mode 100644 index 000000000..1b64a6509 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/memtemp74.C @@ -0,0 +1,21 @@ +// { dg-do assemble } + +template <class T> +class S +{ +protected: + template <class U> + void f(U); // { dg-error "" } is protected + +private: + template <class U> + void g(U); // { dg-error "" } is private +}; + + +void f() +{ + S<double> s; + s.f(3); // { dg-error "" } within this context + s.g(2.0); // { dg-error "" } within this context +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/memtemp75.C b/gcc/testsuite/g++.old-deja/g++.pt/memtemp75.C new file mode 100644 index 000000000..54e8bc7bb --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/memtemp75.C @@ -0,0 +1,25 @@ +// { dg-do assemble } + +void +print(const int& i) +{ +} + +template<class A> +class bar +{ +public: + template<void (*B)(const A& a)> + void doit(const A& a) + { + B(a); + } +}; + + +int +main() +{ + bar<int> b; + b.doit<print>(2); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/memtemp76.C b/gcc/testsuite/g++.old-deja/g++.pt/memtemp76.C new file mode 100644 index 000000000..e11fe02b3 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/memtemp76.C @@ -0,0 +1,17 @@ +// { dg-do assemble } + +class base +{ +public: + virtual void method()=0; +}; + +class der: public base +{ +public: + template<class C> + void method() + { + C foo; + } +}; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/memtemp77.C b/gcc/testsuite/g++.old-deja/g++.pt/memtemp77.C new file mode 100644 index 000000000..e3ca5298d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/memtemp77.C @@ -0,0 +1,26 @@ +// { dg-do run } +extern "C" int strcmp(const char*, const char*); + +template <class T> +struct S3 +{ + template <class U> + static const char* h(U); +}; + +template <> +template <> +const char* S3<double>::h(int) { return __PRETTY_FUNCTION__; } + +template <> +template <> +const char* S3<char>::h(int) { return __PRETTY_FUNCTION__; } + +int main() +{ + if (strcmp (S3<double>::h(7), + "static const char* S3<T>::h(U) [with U = int, T = double]") == 0) + return 0; + else + return 1; +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/memtemp78.C b/gcc/testsuite/g++.old-deja/g++.pt/memtemp78.C new file mode 100644 index 000000000..73348351f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/memtemp78.C @@ -0,0 +1,56 @@ +// { dg-do assemble } + +struct A +{ + void f() {} + + template <class U> + void f() {} +}; + + +template <class T> +struct B +{ + void f() {} + + template <class U> + void f() {} +}; + +template struct B<int>; + +struct C +{ + template <class U> + void f() {} // { dg-error "with" } redeclaration + + template <class U> + void f() {} // { dg-error "overloaded" } redeclaration +}; + + +template <class T, class U> +struct D +{ + void f(T); + void f(U); +}; + +template struct D<int, double>; + +template <class T, class U> +struct D2 +{ + void f(T); // { dg-error "with" } redeclaration + void f(U); // { dg-error "overloaded" } redeclaration +}; + +template struct D2<int, int>; + +struct E +{ + void f(); // { dg-error "with" } redeclaration + void f(); // { dg-error "overloaded" } redeclaration +}; + diff --git a/gcc/testsuite/g++.old-deja/g++.pt/memtemp79.C b/gcc/testsuite/g++.old-deja/g++.pt/memtemp79.C new file mode 100644 index 000000000..7d31184aa --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/memtemp79.C @@ -0,0 +1,6 @@ +// { dg-do assemble } + +struct foo { + template<typename T> static void bar( foo* ); + template<typename T> void bar() const; // { dg-bogus "" } quals +}; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/memtemp8.C b/gcc/testsuite/g++.old-deja/g++.pt/memtemp8.C new file mode 100644 index 000000000..d2b0e8670 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/memtemp8.C @@ -0,0 +1,13 @@ +// { dg-do assemble } +// GROUPS passed templates membertemplates +struct S { + template <class T> + operator T(); +}; + + +template <class T> +S::operator T() +{ +} + diff --git a/gcc/testsuite/g++.old-deja/g++.pt/memtemp80.C b/gcc/testsuite/g++.old-deja/g++.pt/memtemp80.C new file mode 100644 index 000000000..878a3dfa0 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/memtemp80.C @@ -0,0 +1,16 @@ +// { dg-do assemble } + +template<typename T> T baz() { return 0; } + +struct foo { + template<typename T> static T staticbar() { return 0; } + template<typename T> T bar() { return 0; } +}; + +void f() +{ + foo t; + int i = baz<int>(); + int j = foo::staticbar<int>(); + int k = t.bar<int>(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/memtemp81.C b/gcc/testsuite/g++.old-deja/g++.pt/memtemp81.C new file mode 100644 index 000000000..37a3417bf --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/memtemp81.C @@ -0,0 +1,24 @@ +// { dg-do assemble } + +template <int i> class a +{ +public : +int k; + +template <int j> int f() const { return this->f<j-1>(); } + +int g() const { return f<i>(); } +}; + +template <> +template <> +int a<2>::f<0>() const { + return 0; +} + +int main() +{ +a<2> x; +return x.g(); +} + diff --git a/gcc/testsuite/g++.old-deja/g++.pt/memtemp82.C b/gcc/testsuite/g++.old-deja/g++.pt/memtemp82.C new file mode 100644 index 000000000..2bb6552f2 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/memtemp82.C @@ -0,0 +1,12 @@ +// { dg-do assemble } + +struct foo { + template<typename T> T bar() { return staticbar<T>( this ); } + template<typename T> static T staticbar( foo* ) { return 0; } +}; + +void f() +{ + foo t; + int k = t.bar<int>(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/memtemp83.C b/gcc/testsuite/g++.old-deja/g++.pt/memtemp83.C new file mode 100644 index 000000000..f73436c90 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/memtemp83.C @@ -0,0 +1,19 @@ +// { dg-do assemble } +// Origin: Corey Kosak <kosak@cs.cmu.edu> + +struct cow_t { + template<bool Q> + static void tfunc(cow_t *cowp) {} + + void moo() { + cow_t *cowp; + tfunc<true>(cowp); + } +}; + + +int main() +{ + cow_t *cowp; + cow_t::tfunc<true>(cowp); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/memtemp84.C b/gcc/testsuite/g++.old-deja/g++.pt/memtemp84.C new file mode 100644 index 000000000..6ebade28d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/memtemp84.C @@ -0,0 +1,18 @@ +// { dg-do assemble } + +// Copyright (C) 1999 Free Software Foundation + +// by Alexandre Oliva <oliva@dcc.unicamp.br> +// simplified from bug report by redleaf <e1wwater@dingo.cc.uq.edu.au> + +struct B { + template <class> void bar(); +} b; + +template <class T> void foo() { + b.bar<T>(); // { dg-bogus "" } bar undeclared + b.template bar<T>(); // { dg-bogus "" } ditto + b.B::bar<T>(); +} + +template void foo<void>(); // { dg-bogus "" } diff --git a/gcc/testsuite/g++.old-deja/g++.pt/memtemp85.C b/gcc/testsuite/g++.old-deja/g++.pt/memtemp85.C new file mode 100644 index 000000000..03e3d4675 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/memtemp85.C @@ -0,0 +1,15 @@ +// { dg-do assemble } + +// by Paul Burchard <burchard@pobox.com>, Level Set Systems, Inc. +// Copyright (C) 1999 Free Software Foundation + +struct Q { + template<class> + class X { + }; +}; +template<template<class> class> +class Y { +}; +Y<Q::X> y1; + diff --git a/gcc/testsuite/g++.old-deja/g++.pt/memtemp86.C b/gcc/testsuite/g++.old-deja/g++.pt/memtemp86.C new file mode 100644 index 000000000..382590683 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/memtemp86.C @@ -0,0 +1,15 @@ +// { dg-do assemble } + +// by Paul Burchard <burchard@pobox.com>, Level Set Systems, Inc. +// Copyright (C) 1999 Free Software Foundation + +struct Q { + template<class> + class X { + }; +}; +template<template<class> class> +class Y { +}; +Y<typename Q::X> y; // { dg-error "" } typename out of template context + diff --git a/gcc/testsuite/g++.old-deja/g++.pt/memtemp87.C b/gcc/testsuite/g++.old-deja/g++.pt/memtemp87.C new file mode 100644 index 000000000..99b4cd384 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/memtemp87.C @@ -0,0 +1,16 @@ +// { dg-do assemble } + +// by Paul Burchard <burchard@pobox.com>, Level Set Systems, Inc. +// Copyright (C) 1999, 2002 Free Software Foundation + +class Q { +public: + template<class> + class X { + }; +}; +template<template<class> class> +class Y { +}; +Q::template X<int> x; // { dg-error "" } template syntax + diff --git a/gcc/testsuite/g++.old-deja/g++.pt/memtemp88.C b/gcc/testsuite/g++.old-deja/g++.pt/memtemp88.C new file mode 100644 index 000000000..98de9aa4d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/memtemp88.C @@ -0,0 +1,15 @@ +// { dg-do assemble } + +// by Paul Burchard <burchard@pobox.com>, Level Set Systems, Inc. +// Copyright (C) 1999 Free Software Foundation + +struct Q { + template<class> + class X { + }; + template<template<class> class XX = X> // { dg-bogus "" } (original definition appeared here) + class Y { + }; // { dg-bogus "" } redefinition of default argument for `template <class> XX' + Y<> y; +}; + diff --git a/gcc/testsuite/g++.old-deja/g++.pt/memtemp89.C b/gcc/testsuite/g++.old-deja/g++.pt/memtemp89.C new file mode 100644 index 000000000..d4d560eed --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/memtemp89.C @@ -0,0 +1,15 @@ +// { dg-do assemble } + +// by Paul Burchard <burchard@pobox.com>, Level Set Systems, Inc. +// Copyright (C) 1999, 2000 Free Software Foundation + +class Q { + template<class T> + class X { // { dg-error "" } Q::X private + }; +}; +template<template<class> class XX> +class Y { + XX<int> x_; +}; +Y<Q::X> y; // { dg-error "" } instantiated from here diff --git a/gcc/testsuite/g++.old-deja/g++.pt/memtemp9.C b/gcc/testsuite/g++.old-deja/g++.pt/memtemp9.C new file mode 100644 index 000000000..5522d94f9 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/memtemp9.C @@ -0,0 +1,22 @@ +// { dg-do link } +// GROUPS passed templates membertemplates +extern "C" int printf(const char*, ...); + +struct S { + template <class T> + operator T(); +}; + +template <class T> +S::operator T() +{ + printf("Hello, world.\n"); + return T(); +} + +int main() +{ + S s; + + int i = s.operator int(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/memtemp90.C b/gcc/testsuite/g++.old-deja/g++.pt/memtemp90.C new file mode 100644 index 000000000..3e24a6879 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/memtemp90.C @@ -0,0 +1,19 @@ +// { dg-do assemble } +// regression test - + +// by Paul Burchard <burchard@pobox.com>, Level Set Systems, Inc. +// Copyright (C) 1999 Free Software Foundation +// related to bug report by Leon Bottou <leonb@research.att.com> + +struct A { + template<class T> + struct B { + }; + template<class T> + struct C { + B<T> b; // { dg-bogus "" } B is not a template + // but removing wrapper A gets rid of complaint + // also, replacing B<T> with A::B<T> also gets rid of complaint + }; +}; + diff --git a/gcc/testsuite/g++.old-deja/g++.pt/memtemp91.C b/gcc/testsuite/g++.old-deja/g++.pt/memtemp91.C new file mode 100644 index 000000000..18b52a433 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/memtemp91.C @@ -0,0 +1,19 @@ +// { dg-do assemble } +// regression test - + +// simplified from bug report by Leon Bottou <leonb@research.att.com> +// by Paul Burchard <burchard@pobox.com>, Level Set Systems, Inc. +// Copyright (C) 1999 Free Software Foundation + +struct A { + template <class T> + struct B { + T x; + }; + template <class T> + struct C : B<T> { + C() {} + }; +}; + + diff --git a/gcc/testsuite/g++.old-deja/g++.pt/memtemp92.C b/gcc/testsuite/g++.old-deja/g++.pt/memtemp92.C new file mode 100644 index 000000000..ad86f79af --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/memtemp92.C @@ -0,0 +1,30 @@ +// { dg-do assemble } +// Origin: "Adam J. Richter" <adam@yggdrasil.com> + +template <class Style, class Base> +class theme_map { +}; + +class QWidget { +protected: + virtual void *harmony_get_list_for_signal(const char *) const; + +public: + static theme_map<int, QWidget> ContentsThemes; + +protected: + virtual void updateDrawingObjects (void) + { + update_dro (QWidget::ContentsThemes); + } + + template <class S, class B> + void update_dro (theme_map<S, B>& themes) + { + } +}; + +void *QWidget::harmony_get_list_for_signal(const char *sig) const +{ + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/memtemp93.C b/gcc/testsuite/g++.old-deja/g++.pt/memtemp93.C new file mode 100644 index 000000000..d5cba8cfa --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/memtemp93.C @@ -0,0 +1,16 @@ +// { dg-do link } +// Origin: Mark Mitchell <mark@codesourcery.com> + +template <int n> struct A { + template <class T> A (T t); + template <class T> int f(T t) const; +}; + +template <> template<class T> int A<1>::f(T t) const {return 1;} +template <> template<class T> A<1>::A (T t) {} + +int main() { + A<1> a (3); + a.f(1); + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/memtemp94.C b/gcc/testsuite/g++.old-deja/g++.pt/memtemp94.C new file mode 100644 index 000000000..b933a73ef --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/memtemp94.C @@ -0,0 +1,9 @@ +// { dg-do assemble } +// Origin: Theodore Papadopoulo <Theodore.Papadopoulo@sophia.inria.fr> + +struct H { + template <class T> void k() const { } + typedef void (H::*pmf)() const; + + pmf f() const { return &H::k<int>; } +}; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/memtemp95.C b/gcc/testsuite/g++.old-deja/g++.pt/memtemp95.C new file mode 100644 index 000000000..ea70393a5 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/memtemp95.C @@ -0,0 +1,20 @@ +// { dg-do assemble } +// Origin: Mark Mitchell <mitchell@codesourcery.com> + +template <class T, class V> +struct S +{ +}; + +template <class T> +struct S<T, int> +{ + template <class U> + void f (U); +}; + +template <class T> +template <class U> +void S<T, int>::f (U) +{ +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/memtemp96.C b/gcc/testsuite/g++.old-deja/g++.pt/memtemp96.C new file mode 100644 index 000000000..52519fad6 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/memtemp96.C @@ -0,0 +1,34 @@ +// { dg-do run } +// Test for partial specialization of a member function template. +// Origin: Jason Merrill <jason@cygnus.com> + +template <class T> struct A { + template <class U> int f(U) { return 42; } +}; + +template <> +template <class U> +int A<char>::f(U); + +template <> +template <class U> +int A<double>::f(U) { return 24; } + +int main () +{ + A<int> ai; + if (ai.f(0) != 42) + return 1; + + A<double> ad; + if (ad.f(0) != 24) + return 1; + + A<char> ac; + if (ac.f(0) != 36) + return 1; +} + +template <> +template <class U> +int A<char>::f(U) { return 36; } diff --git a/gcc/testsuite/g++.old-deja/g++.pt/memtemp97.C b/gcc/testsuite/g++.old-deja/g++.pt/memtemp97.C new file mode 100644 index 000000000..e00c3bb28 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/memtemp97.C @@ -0,0 +1,17 @@ +// { dg-do run } +// Origin: Mark Mitchell <mark@codesourcery.com> + +template <class T> struct A { + template <class U> int f(U) { return 1; } +}; + +template <> +template <class U> +int A<int>::f(U) { return 0; } + +A<int> a; + +int main () +{ + return a.f (3); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/memtemp98.C b/gcc/testsuite/g++.old-deja/g++.pt/memtemp98.C new file mode 100644 index 000000000..e8e977070 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/memtemp98.C @@ -0,0 +1,23 @@ +// { dg-do assemble } +//Purpose: +// Test nested template as template template arg. +//Result: +// Before the patch, got: +// `C' is not a template + +template <template <typename S> class T> +struct A +{ + T<int> m_t; +}; + +struct B +{ + template <typename V> + struct C + { + V m_v; + }; +}; + +A<B::C> z; 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 000000000..056157cb4 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/memtemp99.C @@ -0,0 +1,10 @@ +// { dg-do assemble } +// Origin: bitti@cs.tut.fi + +template<typename T, unsigned int N> +class Vector +{ +public: + template<unsigned int I> + class Vector<T,N>::CommaInit { }; // { dg-error "" } invalid definition +}; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/mi1.C b/gcc/testsuite/g++.old-deja/g++.pt/mi1.C new file mode 100644 index 000000000..8d622ef6f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/mi1.C @@ -0,0 +1,76 @@ +// { dg-do run } +// Test that binfos aren't erroneously shared between instantiations. + +class PK_CryptoSystem +{ +}; +class PK_Encryptor : public virtual PK_CryptoSystem +{ +}; +class PK_FixedLengthCryptoSystem : public virtual PK_CryptoSystem +{ +public: + virtual unsigned int CipherTextLength() const =0; +}; +class PK_FixedLengthEncryptor : public virtual PK_Encryptor, public virtual PK_FixedLengthCryptoSystem +{ +}; +class PK_SignatureSystem +{ +public: + virtual ~PK_SignatureSystem() {} +}; +class PK_Signer : public virtual PK_SignatureSystem +{ +public: + virtual void Sign() = 0; +}; +class PK_Verifier : public virtual PK_SignatureSystem +{ +}; +class PK_Precomputation +{ +}; +template <class T> class +PK_WithPrecomputation : public T, public virtual PK_Precomputation +{ +}; +typedef PK_WithPrecomputation<PK_FixedLengthEncryptor> PKWPFLE; +typedef PK_WithPrecomputation<PK_Signer> PKWPS; +template <class EC> class +ECPublicKey : public PKWPFLE +{ +public: + unsigned int CipherTextLength() const { return 1; } + EC ec; +}; +template <class EC> +class ECPrivateKey : public ECPublicKey<EC>, public PKWPS +{ + void Sign() {} + int d; +}; +template <class EC> +class ECKEP : public ECPrivateKey<EC> +{ +}; +class GF2NT : public PK_CryptoSystem +{ + int t1; +}; +class EC2N : public PK_CryptoSystem +{ + GF2NT field; + int a; +}; +template class ECKEP<EC2N>; +template class ECKEP<int>; + +int +main () +{ + ECKEP<EC2N> foo; + + return 0; +} + diff --git a/gcc/testsuite/g++.old-deja/g++.pt/nested1.C b/gcc/testsuite/g++.old-deja/g++.pt/nested1.C new file mode 100644 index 000000000..e50481545 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/nested1.C @@ -0,0 +1,47 @@ +// { dg-do assemble } + +template <class T1,class T2> +struct X +{ + T1 a; + + struct Y + { + T2 x; + Y (T2 _x) { x=_x; } + }; + +}; + +template <class T1> +struct X<T1,int> +{ + T1 a; + + struct Y + { + int x; + Y (int _x) { x=_x; } + }; + +}; + +template <> +struct X<int,int> +{ + int a; + + struct Y + { + int x; + Y (int _x) { x=_x; } + }; + +}; + +void f () +{ + X<char,char> t1; + X<char,int> t2; + X<int,int> t3; +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/nested2.C b/gcc/testsuite/g++.old-deja/g++.pt/nested2.C new file mode 100644 index 000000000..2eb8ad5b0 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/nested2.C @@ -0,0 +1,15 @@ +// { dg-do assemble } +// Origin: Mathias Doreille <Mathias.Doreille@imag.fr> + +template<class T> +struct a { + struct b { + T operator()(); + }; +}; + + +template<class T> +T a<T>::b::operator()() { return T(0); } + +template<> int a<int>::b::operator()() { return 1; } diff --git a/gcc/testsuite/g++.old-deja/g++.pt/niklas01.C b/gcc/testsuite/g++.old-deja/g++.pt/niklas01.C new file mode 100644 index 000000000..2c59d543e --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/niklas01.C @@ -0,0 +1,6 @@ +// { dg-do assemble } + +template <class T> struct A {}; +template <class T> struct B : A<B<T> > {}; + +B<int> x; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/niklas01a.C b/gcc/testsuite/g++.old-deja/g++.pt/niklas01a.C new file mode 100644 index 000000000..eec11ab00 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/niklas01a.C @@ -0,0 +1,9 @@ +// { dg-do assemble } +// { dg-options "-fshow-column" } + +struct A { // { dg-error "" } forward declaration + friend struct B : A { // { dg-error "invalid use of incomplete type 'struct A" } + int x; + }; // { dg-error "class definition may not be declared a friend" "" { target *-*-* } { 5 } } + int y; +}; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/niklas01b.C b/gcc/testsuite/g++.old-deja/g++.pt/niklas01b.C new file mode 100644 index 000000000..e17b92935 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/niklas01b.C @@ -0,0 +1,6 @@ +// { dg-do assemble } + +template <class T> struct A { T *t; inline A() { t = 0; } }; +template <class T> struct B : A<B<T> > { int x; inline B() { x = 3; } }; + +B<int> x; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/niklas02.C b/gcc/testsuite/g++.old-deja/g++.pt/niklas02.C new file mode 100644 index 000000000..d47b5d1e1 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/niklas02.C @@ -0,0 +1,15 @@ +// { dg-do assemble } + +struct B { int foo (); }; +int B::foo() { return 37; } + +template <class A> struct X { + void f(int); +}; + +template <class A> void X<A>::f (int jj) +{} + +X<int> x; + +void xxx () { x.f (1); } diff --git a/gcc/testsuite/g++.old-deja/g++.pt/niklas03.C b/gcc/testsuite/g++.old-deja/g++.pt/niklas03.C new file mode 100644 index 000000000..7ecf0ede5 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/niklas03.C @@ -0,0 +1,12 @@ +// { dg-do assemble } + +template <class A> struct X { + A operator[] (int); +}; + +template <class A> A X<A>::operator[] (int i) +{ + return A(); // { dg-bogus "" } +} + +X<int> x; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/nontype1.C b/gcc/testsuite/g++.old-deja/g++.pt/nontype1.C new file mode 100644 index 000000000..95c683f49 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/nontype1.C @@ -0,0 +1,19 @@ +// { dg-do assemble } + +template<int N_length> +struct B +{ + B(); + ~B(); +}; +template<class P, int N> +struct D +{ + D(int r0); + D(B<N-1> &, int); +}; +template<class T> +void func() +{ + D<T,1> tmp; +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/nontype2.C b/gcc/testsuite/g++.old-deja/g++.pt/nontype2.C new file mode 100644 index 000000000..ee233f28b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/nontype2.C @@ -0,0 +1,20 @@ +// { dg-do assemble } + +enum E { }; + +template <const E* ep> +struct S1 +{ +}; + + +struct S2 +{ + static E es[1]; +}; + + +struct S3 +{ + typedef S1<S2::es> S3_Type; +}; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/nontype3.C b/gcc/testsuite/g++.old-deja/g++.pt/nontype3.C new file mode 100644 index 000000000..f48d00010 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/nontype3.C @@ -0,0 +1,28 @@ +// { dg-do assemble } + +enum E { e }; + +template <const E* ep> +struct S1 +{ + static const char* s; +}; + +template <int D> +struct S2 {}; + +template <> +struct S2<1> +{ + static E es[1]; +}; + +struct S3 +{ + typedef S1<S2<1>::es> S3_Type; +}; + +E S2<1>::es[1] = {e}; + +template <> +const char* S1<S2<1>::es>::s = "abc"; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/nontype4.C b/gcc/testsuite/g++.old-deja/g++.pt/nontype4.C new file mode 100644 index 000000000..9ad0ff4f4 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/nontype4.C @@ -0,0 +1,31 @@ +// { dg-do assemble } + +template <class R, void (R::* A) (void)> +class s +{ +public: + s (R &r) : _r (r) {} + + void e (void) { (_r.*A) (); } + +private: + R &_r; +}; + +class x +{ +public: + void test1 (void) { int j = 0; } + void test2 (void) { int j = 1; } +}; + +int +main (void) +{ + x r; + + s<x, &x::test1> c4 (r); + s<x, &x::test2> c5 (r); + + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/nontype5.C b/gcc/testsuite/g++.old-deja/g++.pt/nontype5.C new file mode 100644 index 000000000..2678cf78a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/nontype5.C @@ -0,0 +1,23 @@ +// { dg-do assemble } + +// Copyright (C) 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 10 Jan 2001 <nathan@codesourcery.com> + +// Bug 1509. We ICE'd on trying to coerce a non-type template parm +// that wouldn't. + +template<class T> +struct A { +typedef int F(); +}; + +template<class T, typename A<T>::F f> +struct B { +static int g() { return f(); } +}; + +int f() { return 0; } + +int main() { +return B<int,&f>::g(); // { dg-error "" } could not convert arg +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/nttp1.C b/gcc/testsuite/g++.old-deja/g++.pt/nttp1.C new file mode 100644 index 000000000..3af938b70 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/nttp1.C @@ -0,0 +1,22 @@ +// { dg-do run } +// Test for nested template template parameter feature + +template <template<template <class> class> class TTT> struct C +{ + int f(); +}; + +template <template<template <class> class> class TTT> int C<TTT>::f() +{ + return 0; +} + +template <template <class> class TT> struct D +{ +}; + +int main() +{ + C<D> c; + c.f(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/nttp2.C b/gcc/testsuite/g++.old-deja/g++.pt/nttp2.C new file mode 100644 index 000000000..b850f48e8 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/nttp2.C @@ -0,0 +1,31 @@ +// { dg-do run } +// Test for nested template template parameter feature + +template <template<template <class> class> class TTT> struct C +{ + int f() { return 0; } +}; + +template <template <class> class TT> struct D +{ + int a; +}; + +template <template <class> class TT> struct E +{ + int a; + int b; +}; + +template <template <template <template<class> class> class> class TTT> +int g(TTT<E> t) +{ + TTT<D> tt; + return tt.f(); +} + +int main() +{ + C<E> c; + g(c); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/operator1.C b/gcc/testsuite/g++.old-deja/g++.pt/operator1.C new file mode 100644 index 000000000..0894b1e23 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/operator1.C @@ -0,0 +1,11 @@ +// { dg-do assemble } +// Copyright (C) 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 7 Nov 2000 <nathan@codesourcery.com> +// Origin: bug 510 wolfgang.bangerth@iwr.uni-heidelberg.de + +struct Example { +template <class U> void operator= (U); +}; + +template <> +void Example::operator=<double> (double); diff --git a/gcc/testsuite/g++.old-deja/g++.pt/overload1.C b/gcc/testsuite/g++.old-deja/g++.pt/overload1.C new file mode 100644 index 000000000..10b9f055c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/overload1.C @@ -0,0 +1,16 @@ +// { dg-do run } +template <class T> struct B { }; + +template <class T> struct A { + template <class U, class V> int operator () (U u, V v); + template <class U, class V> void operator () (B<U> u, B<V> v) { } +}; + +int +main () +{ + A<int> a; + B<char> b1; + B<short> b2; + a (b1, b2); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/overload10.C b/gcc/testsuite/g++.old-deja/g++.pt/overload10.C new file mode 100644 index 000000000..cdb0d3e22 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/overload10.C @@ -0,0 +1,17 @@ +// { dg-do run } +struct B { + int f(int) { return 1; } +}; + +struct D { + template <class T> + int f(T) { return 0; } +}; + +int main() +{ + int (D::*g)(int) = &D::f; + + D d; + return (d.*g)(0); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/overload11.C b/gcc/testsuite/g++.old-deja/g++.pt/overload11.C new file mode 100644 index 000000000..12b4978b9 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/overload11.C @@ -0,0 +1,27 @@ +// { dg-do link } + +template <class T> +int f(int (*fn)(T)) +{ + return (*fn)(3); +} + +struct S { + static int g(int) { return 1; } + static void g(); + + int h(); +}; + +int S::h() +{ + return f(&g); +} + + +int main() +{ + S s; + if (s.h () != 1) + return 1; +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/overload12.C b/gcc/testsuite/g++.old-deja/g++.pt/overload12.C new file mode 100644 index 000000000..9da3d32e2 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/overload12.C @@ -0,0 +1,22 @@ +// { dg-do run } +// Testcase for not trying a candidate that would generate an ill-formed +// instantiation. + +template <int N> struct A { + int ar[N]; +}; + +template <int N> struct B { + B () { } + B (const A<N> &) { } + B (const A<N-1> &, int); +}; + +int +main () +{ + A<1> a; + B<1> b1; + B<1> b2 (a); +} + diff --git a/gcc/testsuite/g++.old-deja/g++.pt/overload13.C b/gcc/testsuite/g++.old-deja/g++.pt/overload13.C new file mode 100644 index 000000000..f66f1038c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/overload13.C @@ -0,0 +1,11 @@ +// { dg-do assemble } +struct A { + template <class T> int f (T) { return 0; } + int f (int) { return 1; } +}; + +int main () +{ + A a; + return a.template f (0); // { dg-error "" } +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/overload14.C b/gcc/testsuite/g++.old-deja/g++.pt/overload14.C new file mode 100644 index 000000000..92142d2fc --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/overload14.C @@ -0,0 +1,20 @@ +// { dg-do assemble } +// +// Copyright (C) 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 18 Jan 2001 <nathan@codesourcery.com> + +// Bug 1639. We failed to have builtin relop candidates with enumeral type. + +template <typename T1, typename T2> void operator == (T1, T2); + +enum E {e1}; +void operator != (E, E); + +bool Foo (E e) +{ + return e == e1; +} +bool Baz (E e) +{ + return e != e1; // { dg-error "" } void not ignored. +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/overload15.C b/gcc/testsuite/g++.old-deja/g++.pt/overload15.C new file mode 100644 index 000000000..debad8857 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/overload15.C @@ -0,0 +1,25 @@ +// { dg-do assemble } +// Test resolution of templatized overloaded constructors. +// The more specialized constructor, i.e., A (const B<Dim1,Dim2> &b) +// should be chosen per \S 14.5.5.2/2 [temp.func.order/2]. + +template <int Dim1, int Dim2> +struct B { + int f; +}; + +struct A { + template <int Dim1, int Dim2> + A (const B<Dim1,Dim2> &b) {} + + template <typename T> + A (const T &b) {} +}; + +int +main () +{ + B<2,3> b; + A a (b); + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/overload2.C b/gcc/testsuite/g++.old-deja/g++.pt/overload2.C new file mode 100644 index 000000000..e53df3e35 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/overload2.C @@ -0,0 +1,16 @@ +// { dg-do assemble } +template<class T> +class C +{ +public: + C<T*> O(); + C<T*> O() const; +}; + + +int +main() +{ + C<char*> c; + char* p = Z(c.O); //{ dg-error "" } ambiguous c.O +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/overload3.C b/gcc/testsuite/g++.old-deja/g++.pt/overload3.C new file mode 100644 index 000000000..4d2317339 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/overload3.C @@ -0,0 +1,18 @@ +// { dg-do assemble } + +template <class T> +void g(T, T); + +template <class T> +void g(int*, T); + +struct S +{ + void f() const + { + g(X, X+3); + } + + double X[3]; +}; + diff --git a/gcc/testsuite/g++.old-deja/g++.pt/overload4.C b/gcc/testsuite/g++.old-deja/g++.pt/overload4.C new file mode 100644 index 000000000..3dcb39704 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/overload4.C @@ -0,0 +1,12 @@ +// { dg-do assemble } + +template <class T> void foo(T); + +template <class T> void bar(void (*)(T), T); + +void baz() { + bar<int>(foo, 1); + bar(foo<int>, 1); + bar<int>(foo<int>, 1); + bar(foo, 1); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/overload5.C b/gcc/testsuite/g++.old-deja/g++.pt/overload5.C new file mode 100644 index 000000000..1bb2d448f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/overload5.C @@ -0,0 +1,6 @@ +// { dg-do assemble } + +template <class T> void foo(); // { dg-error "" } candidate + +void (*bar)() = foo<void>; +void (*baz)() = foo; // { dg-error "" } can't deduce T diff --git a/gcc/testsuite/g++.old-deja/g++.pt/overload6.C b/gcc/testsuite/g++.old-deja/g++.pt/overload6.C new file mode 100644 index 000000000..c7a4e2994 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/overload6.C @@ -0,0 +1,14 @@ +// { dg-do run } +// Check that foo<int> isn't resolved too early. + +template <class T> void foo(T*); +template <class T, class U> void foo(T*, U) { } + +template <class T, class U> void bar(void (*)(T, U), U) { } + +int main() { + bar<int*>(&foo, 1); + bar<int*>(&foo<int>, 1); + bar<int*>(foo, 1); + bar<int*>(foo<int>, 1); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/overload7.C b/gcc/testsuite/g++.old-deja/g++.pt/overload7.C new file mode 100644 index 000000000..6f5dff0a2 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/overload7.C @@ -0,0 +1,21 @@ +// { dg-do assemble } +// { dg-prune-output "note" } + +// Adapted from testcase by Corey Kosak <kosak@cs.cmu.edu> + +template<class T> +struct moo_t { + struct cow_t {}; +}; + +template<class T> void foo(typename moo_t<T>::cow_t) {} + +template<class T> void foo(moo_t<T>) { + typename moo_t<T>::cow_t p; + foo(p); // { dg-bogus "" "" { xfail *-*-* } } - no matching function for call - +} + +int main() { + moo_t<int> x; + foo(x); // { dg-bogus "" "" { xfail *-*-* } } - instantiated from here - +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/overload8.C b/gcc/testsuite/g++.old-deja/g++.pt/overload8.C new file mode 100644 index 000000000..5c2d8bc02 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/overload8.C @@ -0,0 +1,12 @@ +// { dg-do assemble } + +// Simplified from bug report by Tim Rowley <tor@cs.brown.edu> + +struct baz; + +void operator*(baz&, double); + +template <class T> inline T operator*(double s, const T &p) + ; // { dg-bogus "" "" } - must have argument of class type - + +void m(baz& a) { a * .5; } diff --git a/gcc/testsuite/g++.old-deja/g++.pt/overload9.C b/gcc/testsuite/g++.old-deja/g++.pt/overload9.C new file mode 100644 index 000000000..f73acc7f2 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/overload9.C @@ -0,0 +1,22 @@ +// { dg-do run } +template <class T> +int f(T) +{ + return 1; +} + + +template <class T> +int f(T*) +{ + return 0; +} + + +int main() +{ + int (*h)(int*) = &f; + int (&k)(int*) = f; + + return (*h)(0) || (*k)(0); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/parms1.C b/gcc/testsuite/g++.old-deja/g++.pt/parms1.C new file mode 100644 index 000000000..b8a5dda1c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/parms1.C @@ -0,0 +1,32 @@ +// { dg-do run } +// Testcase for use of template parms as types for other template parms. + +template <class T, T t> +class A { + T a; +public: + A(): a(t) {} + + operator T () { return a; } +}; + +template <class S, S s> +class B { + A<S,s> a; +public: + B(A<S,s>& b): a(b) {} + + operator S () { return a*20; } +}; + +int +main() +{ + A<int, 5> a; + B<int, 5> b(a); + + if (b * a == 500) + return 0; + else + return 1; +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/parms2.C b/gcc/testsuite/g++.old-deja/g++.pt/parms2.C new file mode 100644 index 000000000..673427e6c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/parms2.C @@ -0,0 +1,39 @@ +// { dg-do assemble } +// +// Copyright (C) 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 5 Sept 2000 <nathan@codesourcery.com> + +// bug 73. We failed to compare explicit arguments for a TEMPLATE_ID_EXPR in a +// TYPENAME_TYPE. + +struct Plus { + template <class T> + struct Sig { typedef int Third;}; +}; + + +template <class T> +struct Ethel { + typedef int WrappedType; +}; + +struct Fred { + + template <class Q, class LA, class LB> + Ethel<typename Q::template Sig<typename LA::WrappedType>::Third> baz (); + + + template <class Z, class A, class B> + Ethel<typename Z::template Sig<A>::Third> + foo ( const Z&, const Ethel<A>&, const Ethel<B>&) const; +}; + +int main() { + Fred f; + Ethel<int> e; + Plus p; + + f.foo (p, e, e); + + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/parms3.C b/gcc/testsuite/g++.old-deja/g++.pt/parms3.C new file mode 100644 index 000000000..1eba279aa --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/parms3.C @@ -0,0 +1,8 @@ +// { dg-do assemble } +// Test that we can represent static_casts in template arg lists. + +template <int I> struct A { }; + +template <class T> struct B { + A<static_cast<T>(3.14)> a; +}; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/parse2.C b/gcc/testsuite/g++.old-deja/g++.pt/parse2.C new file mode 100644 index 000000000..10f79d939 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/parse2.C @@ -0,0 +1,8 @@ +// { dg-do assemble } +// Origin: Jason Merrill <jason@cygnus.com> + +template <class T> struct A { + A (const A&) { } +}; + +template A<int>::A (const A&); diff --git a/gcc/testsuite/g++.old-deja/g++.pt/partial1.C b/gcc/testsuite/g++.old-deja/g++.pt/partial1.C new file mode 100644 index 000000000..1f9ae551b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/partial1.C @@ -0,0 +1,27 @@ +// { dg-do run } +template<class T_type, int N> +class foo { +public: + enum bar { z = 0 }; +}; + +template<int N> +class foo<double, N> { +public: + enum bar { z = 1 }; +}; + +template<class T_type> +class foo<T_type, 2> { +public: + enum bar { z = 2 }; +}; + +int main() +{ + if ((foo<int,3>::z == 0) && (foo<double,3>::z == 1) + && (foo<float,2>::z == 2)) + return 0; + else + return 1; +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/partial2.C b/gcc/testsuite/g++.old-deja/g++.pt/partial2.C new file mode 100644 index 000000000..6a8a60a2f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/partial2.C @@ -0,0 +1,23 @@ +// { dg-do assemble } +// Tests partial specialization +template<class T> struct foo1 {}; +template<class T, int n> struct foo1<T[n]>; +foo1<char> bar1; +foo1<char[10]> baz1; // { dg-error "" } incomplete type + +template<class T> struct foo2 {}; +template<class T, unsigned n> struct foo2<T[n]>; +foo2<char> bar2; +foo2<char[10]> baz2; // { dg-error "" } incomplete type + +typedef unsigned int other1_t; +template<class T> struct foo3 {}; +template<class T, other1_t n> struct foo3<T[n]>; +foo3<char> bar3; +foo3<char[10]> baz3; // { dg-error "" } incomplete type - + +typedef int other2_t; +template<class T> struct foo4 {}; +template<class T, other1_t n> struct foo4<T[n]>; +foo4<char> bar4; +foo4<char[10]> baz4; // { dg-error "" } incomplete type - diff --git a/gcc/testsuite/g++.old-deja/g++.pt/partial3.C b/gcc/testsuite/g++.old-deja/g++.pt/partial3.C new file mode 100644 index 000000000..f62f91566 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/partial3.C @@ -0,0 +1,17 @@ +// { dg-do run } +// Test that partial ordering works between conversion ops from different +// classes. +// From Jason Merrill <jason@cygnus.com> + +struct A { + template <class T> operator T*() { return 0; } +}; +struct B : public A { + template <class T> operator T(); +}; + +int main() +{ + B b; + (void*) b; +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/partial4.C b/gcc/testsuite/g++.old-deja/g++.pt/partial4.C new file mode 100644 index 000000000..fd3554e55 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/partial4.C @@ -0,0 +1,24 @@ +// { dg-do assemble } +// Origin: Gabriel Dos Reis <Gabriel.Dos-Reis@cmla.ens-cachan.fr> + +// Bug 29. We failed to verify that template argument deduction +// produces a valid result in nondeduce context. + +template<class T> struct Y { typedef T X; }; + +template<class T, class U> struct Base {}; + +template<class T> struct Base<T, typename T::X> {}; + +template<class T> struct Base<typename T::X, T> {}; + +template<class T, class U> struct Derived : Base <T, U> {}; + +struct A {}; + +template<class T> struct Derived<A, T> : Base< Y<T>, Y<T> > {}; + +int main() +{ + Derived<A, int> d; +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/partial5.C b/gcc/testsuite/g++.old-deja/g++.pt/partial5.C new file mode 100644 index 000000000..64f46d48c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/partial5.C @@ -0,0 +1,19 @@ +// { dg-do run } +// Test that partial ordering ignores defaulted parms and 'this'. + +struct A { + template<class T> int f(T) { return 1; } + template<class T> int f(T*, int=0) { return 0; } + template<class T> int g(T*) { return 0; } + template<class T> static int g(T, int=0) { return 1; } + template<class T> int h(T*) { return 0; } + template<class T> static int h(T, int=0) { return 1; } + template<class T> static int j(T*, short y=0) { return 0; } + template<class T> static int j(T, int=0) { return 1; } +}; + +int main(void) { + A a; + int *p; + return (a.f(p) || a.g(p) || a.h(p) || a.j(p)); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/poi1.C b/gcc/testsuite/g++.old-deja/g++.pt/poi1.C new file mode 100644 index 000000000..b6bcad364 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/poi1.C @@ -0,0 +1,15 @@ +// { dg-do assemble } +// Origin: Gerald Pfeifer <pfeifer@dbai.tuwien.ac.at> + +template <class T> +class TLITERAL : public T + { + int x; + }; + +class GATOM; + +typedef TLITERAL<GATOM> x; +extern TLITERAL<GATOM> y; + + diff --git a/gcc/testsuite/g++.old-deja/g++.pt/pointer1.C b/gcc/testsuite/g++.old-deja/g++.pt/pointer1.C new file mode 100644 index 000000000..0b1e3ae07 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/pointer1.C @@ -0,0 +1,17 @@ +// { dg-do assemble } + +template <class T> +struct S1 +{ +}; + +template <class T> +struct S2 +{ + typedef T* pointer_t; +}; + +int f(S2<S1<int> >::pointer_t p1, S2<S1<int> >::pointer_t p2) +{ + return (int) (p1 - p2); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/ptrmem1.C b/gcc/testsuite/g++.old-deja/g++.pt/ptrmem1.C new file mode 100644 index 000000000..8ebc61c51 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/ptrmem1.C @@ -0,0 +1,19 @@ +// { dg-do run } +class foo +{ +public: + template<class T> + T bar() { return 7; } +}; + +int +main() +{ + foo f; + + int (foo::*s)() = &foo::bar<int>; + if ((f.*s)() == 7) + return 0; + else + return 1; +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/ptrmem10.C b/gcc/testsuite/g++.old-deja/g++.pt/ptrmem10.C new file mode 100644 index 000000000..6d61079b4 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/ptrmem10.C @@ -0,0 +1,30 @@ +// { dg-do assemble } +// +// Copyright (C) 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 14 Aug 2000 <nathan@codesourcery.com> + +// A pointer to member can only be formed by `&T::m', however, other forms +// are ok for pointer to static member. Thus the error can only be determined +// after overload resolution. In template deduction, this can disambiguate +// otherwise ambiguous cases. + +struct A +{ + static int f (int); + int f (short); + void baz (); +}; + +template <typename T> void foo (int (*)(T)); // { dg-message "note" } +template <typename T> void foo (int (A::*)(T)); // { dg-message "note" } candidate + + +void A::baz () +{ + foo (&A::f); // { dg-error "ambiguous" } + // { dg-message "candidate" "candidate note" { target *-*-* } 24 } + foo (A::f); + foo (&(A::f)); + foo (f); + foo (&f); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/ptrmem2.C b/gcc/testsuite/g++.old-deja/g++.pt/ptrmem2.C new file mode 100644 index 000000000..f14611c1a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/ptrmem2.C @@ -0,0 +1,49 @@ +// { dg-do run } +struct S; + +template <S* (S::*p)()> +struct F { + S* f (S& s) + { + return (s.*p)(); + } +}; + +template <int S::*p> +struct D { + void d (S& s) + { + (s.*p) = 3; + } +}; + +struct S { + S* g (); + int i; + F<&S::g> fg; + D<&S::i> di; + S* h(), k(F<&S::h>); + F<&S::g> fg2; + D<&S::i> di2; +}; + +S* S::g() +{ + return this; +} + +S* S::h() +{ + return this; +} + +int main() +{ + S s; + s.i = 2; + s.di.d (s); + if (s.i != 3) + return 1; + if (s.fg2.f(s) != &s) + return 1; +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/ptrmem3.C b/gcc/testsuite/g++.old-deja/g++.pt/ptrmem3.C new file mode 100644 index 000000000..039d5dc65 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/ptrmem3.C @@ -0,0 +1,12 @@ +// { dg-do assemble } + +template <class T> +struct S : public S<T*> {}; +template <> +struct S<int**> {}; + +void g() +{ + int S<int*>::*p; + int S<int>::*q = p; +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/ptrmem4.C b/gcc/testsuite/g++.old-deja/g++.pt/ptrmem4.C new file mode 100644 index 000000000..70ac25eb2 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/ptrmem4.C @@ -0,0 +1,28 @@ +// { dg-do link } + +template<class T,class T1> +int connect_to_method(T* receiver, + int (T1::*method)()) +{ + return (receiver->*method)(); +} + +class Gtk_Container +{ +public: + int remove_callback() { return 1; } + void remove_callback(int); + int f(); +}; + +int Gtk_Container::f() +{ + return connect_to_method(this, &Gtk_Container::remove_callback); +} + +int main() +{ + Gtk_Container gc; + if (gc.f () != 1) + return 1; +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/ptrmem5.C b/gcc/testsuite/g++.old-deja/g++.pt/ptrmem5.C new file mode 100644 index 000000000..54e975eda --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/ptrmem5.C @@ -0,0 +1,17 @@ +// { dg-do assemble } + +// Based on testcase by adriang@campbellsoft.com + +struct Null { + template <typename T> operator T*() { return 0; } + template <typename C, typename T> operator T C::*() { return 0; } +#if WORK_AROUND + typedef int pmf(); + template <typename C> operator pmf C::* () { return 0; } +#endif +} NULL; + +int *pd = NULL; +int (*pf)() = NULL; +int Null::*pmd = NULL; +int (Null::*pmf)() = NULL; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/ptrmem6.C b/gcc/testsuite/g++.old-deja/g++.pt/ptrmem6.C new file mode 100644 index 000000000..85d3e7378 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/ptrmem6.C @@ -0,0 +1,42 @@ +// { dg-do assemble } + +class A { +public: + virtual void f(); + int i; +}; + +class B : public A { +public: + void f(); + int j; +}; + +template <void (A::*)() > +void g() {} // { dg-message "note" } +template <int A::*> +void h() {} // { dg-message "note" } + + +int main() { + g<&A::f>(); + h<&A::i>(); + g<&B::f>(); // { dg-error "" } + // { dg-message "candidate" "candidate note" { target *-*-* } 24 } + h<&B::j>(); // { dg-error "" } + // { dg-message "candidate" "candidate note" { target *-*-* } 26 } + g<(void (A::*)()) &A::f>(); // { dg-error "" } + // { dg-message "candidate" "candidate note" { target *-*-* } 28 } + h<(int A::*) &A::i>(); // { dg-error "" } + // { dg-message "candidate" "candidate note" { target *-*-* } 30 } + g<(void (A::*)()) &B::f>(); // { dg-error "" } + // { dg-message "candidate" "candidate note" { target *-*-* } 32 } + h<(int A::*) &B::j>(); // { dg-error "" } + // { dg-message "candidate" "candidate note" { target *-*-* } 34 } + g<(void (A::*)()) 0>(); // { dg-error "" } + // { dg-message "candidate" "candidate note" { target *-*-* } 36 } + h<(int A::*) 0>(); // { dg-error "" } + // { dg-message "candidate" "candidate note" { target *-*-* } 38 } + + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/ptrmem7.C b/gcc/testsuite/g++.old-deja/g++.pt/ptrmem7.C new file mode 100644 index 000000000..2e6b2db09 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/ptrmem7.C @@ -0,0 +1,14 @@ +// { dg-do assemble } +// Origin: Jason Merrill <jason@cygnus.com> + +struct A { + int i; +}; + +template<const int A::* P> +struct B { }; + +int main() +{ + B<&A::i> b; +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/ptrmem8.C b/gcc/testsuite/g++.old-deja/g++.pt/ptrmem8.C new file mode 100644 index 000000000..e6715f336 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/ptrmem8.C @@ -0,0 +1,18 @@ +// { dg-do assemble } +// Origin: Mark Mitchell <mark@codesourcery.com> + +template <class T> +struct S +{ + void f (const T&); + void f (T&); +}; + +class C +{ +}; + +typedef int (C::*cp)(); + +template struct S<cp>; + diff --git a/gcc/testsuite/g++.old-deja/g++.pt/ptrmem9.C b/gcc/testsuite/g++.old-deja/g++.pt/ptrmem9.C new file mode 100644 index 000000000..768024f1e --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/ptrmem9.C @@ -0,0 +1,6 @@ +// { dg-do assemble } +// Origin: Jason Merrill <jason@cygnus.com> + +struct A; +template <class T> void f (void (A::* const)(T)) {} +void (*p)(void (A::* const)(int)) = f; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/recursion.C b/gcc/testsuite/g++.old-deja/g++.pt/recursion.C new file mode 100644 index 000000000..30e1805bd --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/recursion.C @@ -0,0 +1,31 @@ +// { dg-do assemble } + +const double M_PI=3.14159265358979323846; + +template<int N,int I,int J,int K> +inline double SineSeries() +{ + const double x=I*2*M_PI/N; + const bool go=K+1!=J; + return 1.0-x*x/(2*K+2)/(2*K+3)*SineSeries<N*go,I*go,J*go,(K+1)*go>(); +} + +template<> +inline double SineSeries<0,0,0,0>() +{ + return 1.0; +} + +template<int N,int I> +inline double Sine() +{ + const double x=(I*2*M_PI/N); + return x * SineSeries<N,I,10,0>(); +} + +int main() +{ + double f=Sine<32,5>(); + return 0; +} + diff --git a/gcc/testsuite/g++.old-deja/g++.pt/recursion2.C b/gcc/testsuite/g++.old-deja/g++.pt/recursion2.C new file mode 100644 index 000000000..47dd5522d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/recursion2.C @@ -0,0 +1,26 @@ +// { dg-do run } +template< int i > struct T : +public T< i-1 > +{ +}; + +template<> struct T< 0 > +{ +}; + +template< class F > struct T1 : +public T< F::dim > +{ +}; + +template< int i > struct S +{ + enum { dim = i } ; +}; + +int main() +{ + T1< S< 4 > > t ; + return( 0 ) ; +} + diff --git a/gcc/testsuite/g++.old-deja/g++.pt/redecl1.C b/gcc/testsuite/g++.old-deja/g++.pt/redecl1.C new file mode 100644 index 000000000..4a580e177 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/redecl1.C @@ -0,0 +1,22 @@ +// { dg-do assemble } + +template <class T> +struct S1; // { dg-message "previous declaration" } + +template <class T, class U> +struct S1 {}; // { dg-error "redeclared" } used 1 template parameter + +template <class T = int> // { dg-message "original definition" } +struct S2; + +template <class T = int> +struct S2; // { dg-error "redefinition of default" } + +template <class T> // { dg-error "template parameter" } +struct S3; + +template <int I> +struct S3; // { dg-error "redeclared here" } + +template <template <class T> class C> +struct S3; // { dg-error "redeclared here" } diff --git a/gcc/testsuite/g++.old-deja/g++.pt/redecl2.C b/gcc/testsuite/g++.old-deja/g++.pt/redecl2.C new file mode 100644 index 000000000..d8837f6b9 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/redecl2.C @@ -0,0 +1,14 @@ +// { dg-do assemble } + +struct A +{ + template <class A> + void f(A) {} +}; + +void g() +{ + A a; + a.f(3); +} + diff --git a/gcc/testsuite/g++.old-deja/g++.pt/ref1.C b/gcc/testsuite/g++.old-deja/g++.pt/ref1.C new file mode 100644 index 000000000..cb3ffc452 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/ref1.C @@ -0,0 +1,17 @@ +// { dg-do assemble } +// { dg-prune-output "mangled name" } + +int i; + +template <void (&FN)()> +void g () +{ + FN (); +} + +void h () +{ + i = 7; +} + +template void g<h>(); diff --git a/gcc/testsuite/g++.old-deja/g++.pt/ref2.C b/gcc/testsuite/g++.old-deja/g++.pt/ref2.C new file mode 100644 index 000000000..912a7721f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/ref2.C @@ -0,0 +1,12 @@ +// { dg-do assemble } +// Origin: Mark Mitchell <mark@codesourcery.com> + +template <class T, T&> +class C; + +template <int& I> +class C<int, I> {}; + +int i; + +C<int, i> c; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/ref3.C b/gcc/testsuite/g++.old-deja/g++.pt/ref3.C new file mode 100644 index 000000000..68372b227 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/ref3.C @@ -0,0 +1,23 @@ +// { dg-do run } +// { dg-prune-output "mangled name" } +// Origin: John Wilkinson <jfw@sgi.com> + +template <class T, int& Size> +struct Base { + Base() : obj(Size) {} + T obj; +}; + +int globalInt = 5; + +struct A { + A(int arg) : ia(arg) {} + int ia; +}; + +int main() +{ + Base<A, globalInt> ob; + if (ob.obj.ia != 5) + return 1; +} 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 000000000..d0fbf0024 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/ref4.C @@ -0,0 +1,26 @@ +// { dg-do assemble } +// { dg-prune-output "mangled name" } +// +// 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/repo1.C b/gcc/testsuite/g++.old-deja/g++.pt/repo1.C new file mode 100644 index 000000000..bdfe306b4 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/repo1.C @@ -0,0 +1,24 @@ +// { dg-do link } +// { dg-options "-frepo" } +// { dg-require-host-local "" } +// { dg-skip-if "dkms are not final links" { vxworks_kernel } } + +// Bug: g++ complains about duplicate explicit instantiations with -frepo. +// From Jason Merrill <jason@cygnus.com> + +// Build then link: + +template <class T> struct A { + virtual ~A () { } +}; + +template <class T> void g (T t) { } + +template class A<int>; + +int main () +{ + g (42); +} + +// { dg-final { cleanup-repo-files } } diff --git a/gcc/testsuite/g++.old-deja/g++.pt/repo2.C b/gcc/testsuite/g++.old-deja/g++.pt/repo2.C new file mode 100644 index 000000000..a8d8b1217 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/repo2.C @@ -0,0 +1,28 @@ +// { dg-do link } +// { dg-options "-frepo" } +// { dg-require-host-local "" } +// { dg-skip-if "dkms are not final links" { vxworks_kernel } } + +// Test that collect2 isn't confused by GNU ld's "In function `foo':" message. +// Contributed by Jason Merrill <jason@cygnus.com> + +// Build then link: + +template <class T> +T f (T t) +{ + return t; +} + +template <class T> +T g (T t) +{ + return f (t); +} + +int main () +{ + int i = g (42); +} + +// { dg-final { cleanup-repo-files } } diff --git a/gcc/testsuite/g++.old-deja/g++.pt/repo3.C b/gcc/testsuite/g++.old-deja/g++.pt/repo3.C new file mode 100644 index 000000000..53baf29f3 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/repo3.C @@ -0,0 +1,37 @@ +// { dg-do link } +// { dg-options "-frepo" } +// { dg-require-host-local "" } +// { dg-skip-if "dkms are not final links" { vxworks_kernel } } + +// Test that we properly generate the vtable and such for C. +// Contributed by scott snyder <snyder@fnal.gov> + +// Build then link: + +struct A +{ + virtual ~A () {} +}; + +template <typename T> +struct B : virtual public A +{ + virtual void foo () {} +}; + +template <typename T> +struct C : virtual public A +{ +}; + +template <typename T> +struct D : public B<T>, public C<T> +{ +}; + +main () +{ + D<int> x; +} + +// { dg-final { cleanup-repo-files } } 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 000000000..84575cd94 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/repo4.C @@ -0,0 +1,19 @@ +// { dg-do link } +// { dg-options "-frepo" } +// { dg-require-host-local "" } +// { dg-skip-if "dkms are not final links" { vxworks_kernel } } + +template <class T> +struct S { + ~S (); +}; + +template <class T> +S<T>::~S () {} + +int main () +{ + S<int> s; +} + +// { dg-final { cleanup-repo-files } } diff --git a/gcc/testsuite/g++.old-deja/g++.pt/scope1.C b/gcc/testsuite/g++.old-deja/g++.pt/scope1.C new file mode 100644 index 000000000..1425a9d4b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/scope1.C @@ -0,0 +1,13 @@ +// { dg-do assemble } + +template<class X, class Z> +class foo +{ +public: + typedef X y; + + class bar { + public: + void blah () { y Y; } + }; +}; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/shadow1.C b/gcc/testsuite/g++.old-deja/g++.pt/shadow1.C new file mode 100644 index 000000000..9fa40dfce --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/shadow1.C @@ -0,0 +1,19 @@ +// { dg-do assemble } + +template <class T> +struct S { + typedef T X; + + class C { + typedef T X; + }; +}; + +template <int I> +struct S2 { + enum { A = I }; + + void f() { + int A; + } +}; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/shadow2.C b/gcc/testsuite/g++.old-deja/g++.pt/shadow2.C new file mode 100644 index 000000000..11d6a9b07 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/shadow2.C @@ -0,0 +1,10 @@ +// { dg-do assemble } +// Origin: Jason Merrill <jason@cygnus.com> + +template <class T> struct A { // { dg-error "" } shadowed parameter + struct B { + void T(); // { dg-error "" } shadows template parameter + }; +}; +A<int> a; + diff --git a/gcc/testsuite/g++.old-deja/g++.pt/sizeof.C b/gcc/testsuite/g++.old-deja/g++.pt/sizeof.C new file mode 100644 index 000000000..159c55400 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/sizeof.C @@ -0,0 +1,18 @@ +// { dg-do run } +extern "C" void abort(); + +template <int I> +int bar() { return I; } + +template <class T> +int foo(T) +{ + return bar<sizeof(T) + 4>() + bar<sizeof(long) + 7>(); +} + + +int main() +{ + if (foo(2) != sizeof(int) + 4 + sizeof(long) + 7) + abort(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/sizeof2.C b/gcc/testsuite/g++.old-deja/g++.pt/sizeof2.C new file mode 100644 index 000000000..97127ea0f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/sizeof2.C @@ -0,0 +1,21 @@ +// { dg-do run } +// Although template class B is not used at all, it causes the +// incorrect specialization of A to be selected + +// Adapted from testcase by Oskar Enoksson <osken393@student.liu.se> + +extern "C" void abort(); + +template<int N, class T> // Base class +class A { public: static int n() { return sizeof(T); } }; + +template<int N> // Derived #1 +class B: public A<N,char[N]> {}; + +template<int N, int M> // Derived #2 (wrong!) +class C: public A<N,char[M]> {}; + +int main() { + if (C<1,2>::n() != 2) + abort(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/sizeof3.C b/gcc/testsuite/g++.old-deja/g++.pt/sizeof3.C new file mode 100644 index 000000000..fb65a32c1 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/sizeof3.C @@ -0,0 +1,26 @@ +// { dg-do run } +// Adapted from testcase by Oskar Enoksson <osken393@student.liu.se> + +extern "C" void abort(); + +template<class T0> +class A { +public: + typedef T0 T; +}; + +template<int K> +class B { + typedef A<char[K]> BC; +}; + +template<int N, int M> +class C { +public: + typedef A<char[M]> AC; +}; + +int main() { + if (sizeof(C<3,7>::AC::T) != 7) + abort(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/spec1.C b/gcc/testsuite/g++.old-deja/g++.pt/spec1.C new file mode 100644 index 000000000..7b173cffd --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/spec1.C @@ -0,0 +1,21 @@ +// { dg-do assemble } + +template <class S, class T> +class mem_fun1_t { +public: + mem_fun1_t(S (T::*pf)(double)) {} +}; + +template <class T> +class mem_fun1_t<void, T> { +public: + mem_fun1_t(void (T::*pf)(double)) {} +}; + +struct Operation { + double eval(double) { return 0; } +}; + +int main() { + mem_fun1_t<double, Operation> m(&Operation::eval); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/spec10.C b/gcc/testsuite/g++.old-deja/g++.pt/spec10.C new file mode 100644 index 000000000..e9d36ec31 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/spec10.C @@ -0,0 +1,28 @@ +// { dg-do run } +extern "C" void abort(); + +template <class T> +struct S +{ + template <int i> + int f(int j) { abort(); return 0; } +}; + +template <> +template <> +int S<double>::f<7>(int j) { return j + 7; } + +template <> +template <> +int S<double>::f<8>(int j) { return j + 8; } + +int main() +{ + S<double> s; + + if (s.f<7>(3) != 10) + abort(); + + if (s.f<8>(3) != 11) + abort(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/spec11.C b/gcc/testsuite/g++.old-deja/g++.pt/spec11.C new file mode 100644 index 000000000..8d7a04e55 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/spec11.C @@ -0,0 +1,21 @@ +// { dg-do run } +extern "C" void abort(); + +template <class T> +struct S +{ + template <class U> + int f(U u); +}; + +template <> +template <> +int S<char>::f(int i) { return 1; } + +int main() +{ + S<char> sc; + + if (sc.f(3) != 1) + abort(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/spec12.C b/gcc/testsuite/g++.old-deja/g++.pt/spec12.C new file mode 100644 index 000000000..2e2c6ae7c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/spec12.C @@ -0,0 +1,22 @@ +// { dg-do run } +extern "C" void abort(); + +template <class T> +struct S +{ + template <class U> + int f(U u); +}; + + +template <> +template <> +int S<char>::f<int>(int i) { return 1; } + +int main() +{ + S<char> sc; + + if (sc.f(3) != 1) + abort(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/spec13.C b/gcc/testsuite/g++.old-deja/g++.pt/spec13.C new file mode 100644 index 000000000..b72794acd --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/spec13.C @@ -0,0 +1,44 @@ +// { dg-do run } +template <class T> +void f(T t); + +template <class T> +void f(T* t); + +template <> +void f(int* ip) {} + +struct S1 +{ + template <class T> + void f(T t); + + template <class T> + void f(T* t); +}; + +template <> +void S1::f(int* ip) {} + +template <class U> +struct S2 +{ + template <class T> + void f(T t); + + template <class T> + void f(T* t); +}; + +template <> +template <> +void S2<double>::f(int* ip) {} + +int main() +{ + int* ip; + S1 s1; + s1.f(ip); + S2<double> s2; + s2.f(ip); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/spec14.C b/gcc/testsuite/g++.old-deja/g++.pt/spec14.C new file mode 100644 index 000000000..045865f45 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/spec14.C @@ -0,0 +1,10 @@ +// { dg-do assemble } +class X +{ +public: + template <typename A, typename B, typename C> + X() {} + + template <typename A, typename B> + X::X<A, void, B>() {} // { dg-error "" } non-template type used as a template +}; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/spec15.C b/gcc/testsuite/g++.old-deja/g++.pt/spec15.C new file mode 100644 index 000000000..c812da068 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/spec15.C @@ -0,0 +1,50 @@ +// { dg-do run } +extern "C" void abort(); + +template <class T> +struct S1 +{ + static void f(); +}; + +template <> +void S1<int>::f() {} + +struct S2 +{ + template <class T> + static void g(T); +}; + +template <> +void S2::g(double) {} + +template <> +void S2::g<int>(int) {} + +template <class T> +struct S3 +{ + template <class U> + static int h(U); +}; + +template <> +template <> +int S3<double>::h(int) { return 0; } + +template <> +template <> +int S3<char>::h(int) { return 1; } + +int main() +{ + S1<int>::f(); + S2::g(3.0); + S2::g(7); + + if (S3<double>::h(7) != 0) + abort(); + if (S3<char>::h(7) != 1) + abort(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/spec16.C b/gcc/testsuite/g++.old-deja/g++.pt/spec16.C new file mode 100644 index 000000000..dbe44269a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/spec16.C @@ -0,0 +1,21 @@ +// { dg-do assemble } + +template<class K> +struct A { + int foo(const K&); + int bar(const K&); +}; + +template<class K> +int +A<K>::bar(const K& k) +{ + return(foo(k)); +} + +template<> +int +A<const char*>::foo(const char*const& k) +{ + return((__SIZE_TYPE__)k); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/spec17.C b/gcc/testsuite/g++.old-deja/g++.pt/spec17.C new file mode 100644 index 000000000..e70d36923 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/spec17.C @@ -0,0 +1,44 @@ +// { dg-do assemble } + +template<class T> +struct Foo { }; + +template<class T1, class T2> +struct BT { }; + +template<class T1, class T2> +struct BT< Foo<T1>, Foo<T2> > { static const int i = 1; }; + +template<class T1, class T2> +struct BT< T1, Foo<T2> > { static const int i = 2; }; + +template<class T1, class T2> +struct BT< Foo<T1>, T2 > { static const int i = 3; }; + +template<class T1, class T2> +int foo(Foo<T1>, Foo<T2>) +{ + return 1; +} + +template<class T1, class T2> +int foo(T1, Foo<T2>) +{ + return 2; +} + +template<class T1, class T2> +int foo(Foo<T1>, T2) +{ + return 3; +} + +void f() +{ + BT< double, Foo<int> >::i; + BT< Foo<int>, Foo<int> >::i; + BT< Foo<int>, float >::i; + foo(1.0, Foo<int>()); + foo(Foo<int>(), Foo<int>()); + foo(Foo<int>(), 1.0); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/spec18.C b/gcc/testsuite/g++.old-deja/g++.pt/spec18.C new file mode 100644 index 000000000..aec979a81 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/spec18.C @@ -0,0 +1,30 @@ +// { dg-do assemble } + +template<class A, class B> +void foo(const A& a, const B& b) +{ +} + +template<class A, class B> +void foo(const A& a, const int& b) +{ +} + +template<class A*, class B> +void foo(const A*& a, const B& b) +{ +} + +template<> +void foo(const int&, const double&) +{ +} + + +int +main() +{ + foo("98239", 23); + foo(232, 1.022); +} + diff --git a/gcc/testsuite/g++.old-deja/g++.pt/spec19.C b/gcc/testsuite/g++.old-deja/g++.pt/spec19.C new file mode 100644 index 000000000..ff8a26f2d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/spec19.C @@ -0,0 +1,5 @@ +// { dg-do assemble } + +template<class T> T f(T o) { return o; } +template<> int f(int o) { return o; } +template int f(int); diff --git a/gcc/testsuite/g++.old-deja/g++.pt/spec2.C b/gcc/testsuite/g++.old-deja/g++.pt/spec2.C new file mode 100644 index 000000000..68c680e53 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/spec2.C @@ -0,0 +1,27 @@ +// { dg-do assemble } + +class X +{ + public: + virtual void f() const = 0; +}; + +template <class T> +class Y: public X +{ + public: + virtual void f() const; +}; + +template <class T> +void Y<T>::f() const +{ +} + +template <> +void Y<bool>::f() const; + +template <> +void Y<bool>::f() const +{ +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/spec20.C b/gcc/testsuite/g++.old-deja/g++.pt/spec20.C new file mode 100644 index 000000000..b6148e5de --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/spec20.C @@ -0,0 +1,16 @@ +// { dg-do assemble } + +// According to the non-normative example in +// [temp.class.spec.mfunc]/2, these should be valid, but the grammar +// in the Standard does not allow partial nor full specializations as +// member-declarations, so we'd better not support them. + +template <class T> +struct S { + template <class U> void f(U); + template <> void f<int>(int); // { dg-error "" } invalid specialization + + template <class V> struct I {}; // { dg-error "template" } + template <class V> struct I<V*> {}; // { dg-error "template" } + template <> struct I<int>; // { dg-error "" } invalid specialization +}; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/spec21.C b/gcc/testsuite/g++.old-deja/g++.pt/spec21.C new file mode 100644 index 000000000..4107306d1 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/spec21.C @@ -0,0 +1,16 @@ +// { dg-do assemble } + +template <class T> struct S {}; +template <class T = int> struct S<T*> {}; // { dg-error "" } default argument + +template <int I, int J> struct A {}; +template <int I> struct A<I+5, I*2> {}; // { dg-error "" } argument involves parameter + +template <class T, T t> struct C {}; +template <class T> struct C<T, 1>; // { dg-error "" } type depends on parameter +int i; +template <class T> struct C<T*, &i>; // { dg-error "" } type depends on parameter + +template< int X, int (*array_ptr)[X] > class B {}; +int array[5]; +template< int X > class B<X,&array> { }; // { dg-error "" } type depends on parameter diff --git a/gcc/testsuite/g++.old-deja/g++.pt/spec22.C b/gcc/testsuite/g++.old-deja/g++.pt/spec22.C new file mode 100644 index 000000000..41aab394d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/spec22.C @@ -0,0 +1,15 @@ +// { dg-do assemble } + +template <class T> +struct S +{ + template <class U> + void f(); +}; + + +template <class T> +template <> // { dg-error "enclosing class templates|invalid explicit specialization" } +void S<T>::f<int> () // { dg-error "does not match|invalid function declaration" } +{ +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/spec23.C b/gcc/testsuite/g++.old-deja/g++.pt/spec23.C new file mode 100644 index 000000000..33e97a074 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/spec23.C @@ -0,0 +1,11 @@ +// { dg-do assemble } +/* [temp.expl.spec] p18. */ + +template<class T> +struct A { + template <class U> class B { }; +}; + +template<class T> +class A<T>::B<void> { // { dg-error "" } only one template header +}; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/spec24.C b/gcc/testsuite/g++.old-deja/g++.pt/spec24.C new file mode 100644 index 000000000..37b76cb2b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/spec24.C @@ -0,0 +1,5 @@ +// { dg-do assemble } + +template <class T> class A; +// template <> +class A<int>; // { dg-error "" "" { xfail *-*-* } } missing template header - diff --git a/gcc/testsuite/g++.old-deja/g++.pt/spec25.C b/gcc/testsuite/g++.old-deja/g++.pt/spec25.C new file mode 100644 index 000000000..d056f03b1 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/spec25.C @@ -0,0 +1,15 @@ +// { dg-do assemble } + +template <class T, int I> +struct S { +}; + +template <int I> +struct S <double, I> { +}; + +template <class T> +void f () +{ + S<double, T::x> s; +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/spec26.C b/gcc/testsuite/g++.old-deja/g++.pt/spec26.C new file mode 100644 index 000000000..9c8c30a48 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/spec26.C @@ -0,0 +1,11 @@ +// { dg-do assemble } +// From: lat@iki.fi (Lassi A. Tuura) +// Test that a specialization without an initializer is not a definition, +// as specified in [temp.expl.spec]. + + +struct X; +template <class T> struct Y { static const X array[]; }; +template <> const X Y<int>::array []; +struct X { int i; }; +template <> const X Y<int>::array [] = { 0, 1, 2, 3 }; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/spec27.C b/gcc/testsuite/g++.old-deja/g++.pt/spec27.C new file mode 100644 index 000000000..2401fe246 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/spec27.C @@ -0,0 +1,18 @@ +// { dg-do assemble } + +template <class T, class U> +struct Y {}; + +template <class T> +struct X {}; + +template <class T, class U> +void f() +{ + typename X<Y<T, U> >::A a; +} + +template <class T, class U> +struct X<Y<T, U> > +{ +}; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/spec28.C b/gcc/testsuite/g++.old-deja/g++.pt/spec28.C new file mode 100644 index 000000000..3cecaf79d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/spec28.C @@ -0,0 +1,25 @@ +// { dg-do assemble } + +template <class T> +bool f(T); + +template <class T> +struct S1 { + typedef T X; + friend bool f<>(const S1&); +}; + +template <class T> +struct S2 { +}; + +template <class T> +struct S2<S1<T> > { + typedef typename S1<T>::X Y; +}; + +template <class T> +typename S2<S1<T> >::Y +f(const S1<T>&); + +template struct S1<int>; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/spec29.C b/gcc/testsuite/g++.old-deja/g++.pt/spec29.C new file mode 100644 index 000000000..ff5d433ac --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/spec29.C @@ -0,0 +1,32 @@ +// { dg-do run } +char c; + +struct S { + template <typename T> + operator T*(); + + template <typename T> + operator T(); +}; + +template <> +S::operator int() +{ + return 2; +} + +template <> +S::operator char*() +{ + return &c; +} + +int main() +{ + S s; + int i = s; + char* cp = s; + + if (i != 2 || cp != &c) + return 1; +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/spec3.C b/gcc/testsuite/g++.old-deja/g++.pt/spec3.C new file mode 100644 index 000000000..cce36d273 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/spec3.C @@ -0,0 +1,38 @@ +// { dg-do run } +extern "C" void abort(); + +class X +{ + public: + virtual int f() const = 0; +}; + +template <class T> +class Y: public X +{ + public: + virtual int f() const; +}; + +template <class T> +int Y<T>::f() const +{ + abort(); + return 0; +} + +template <> +int Y<bool>::f() const; + +template <> +int Y<bool>::f() const +{ + return 0; +} + +int main() +{ + Y<bool> yb; + + yb.f(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/spec30.C b/gcc/testsuite/g++.old-deja/g++.pt/spec30.C new file mode 100644 index 000000000..c3174d166 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/spec30.C @@ -0,0 +1,42 @@ +// { dg-do run } +#include <cstddef> + +template <class T> +struct S { + void *operator new (size_t); + void *operator new (size_t, int); + void operator delete (void*); +}; + +static void* s[2]; + +template <> +void* S<int>::operator new (size_t b) +{ + s[0] = ::operator new(b); + return s[0]; +} + +template <> +void* S<int>::operator new (size_t b, int) +{ + s[1] = ::operator new(b); + return s[1]; +} + +template <> +void S<int>::operator delete (void*) +{ +} + +int main() +{ + S<int>* s1 = new S<int>; + S<int>* s2 = new(3) S<int>; + + if (s1 != s[0] || s2 != s[1]) + return 1; + + delete s1; + delete s2; +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/spec31.C b/gcc/testsuite/g++.old-deja/g++.pt/spec31.C new file mode 100644 index 000000000..1d236219f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/spec31.C @@ -0,0 +1,3 @@ +// { dg-do assemble } +template <> struct A {}; // { dg-error "" } not a specialization +template <> void f (); // { dg-error "" } not a specialization diff --git a/gcc/testsuite/g++.old-deja/g++.pt/spec32.C b/gcc/testsuite/g++.old-deja/g++.pt/spec32.C new file mode 100644 index 000000000..f2c4dd74a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/spec32.C @@ -0,0 +1,5 @@ +// { dg-do assemble } +// Origin: Raja R Harinath <harinath@cs.umn.edu> + +template<class T1, class T2> class foo; +template<class T> struct foo<T,typename T::bar>; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/spec33.C b/gcc/testsuite/g++.old-deja/g++.pt/spec33.C new file mode 100644 index 000000000..d4d70f1dc --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/spec33.C @@ -0,0 +1,26 @@ +// { dg-do link } +// Origin: James McKelvey <mckelvey@fafnir.com> + +class A +{ + public: + template <class T> A(T x, bool y = false); +}; + +template <class T> A::A(T, bool) +{ +} + +template <> A::A(char, bool) +{ +} + +int main() +{ + int b; + char c; + + A x(b); + A y(c); + A z(c, false); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/spec34.C b/gcc/testsuite/g++.old-deja/g++.pt/spec34.C new file mode 100644 index 000000000..01fc61d29 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/spec34.C @@ -0,0 +1,19 @@ +// { dg-do assemble } + +// Copyright (C) 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 17 Jan 2001 <nathan@codesourcery.com> + +// Bug 1632. In copying default args from a template to a specialization, we +// lost the object's CV quals, leading to an utterly confusing error message. + +struct X; + +template <int dim> struct Y +{ + X *f (int i = 0) const; +}; + +template <> X *Y<2>::f (int i) const +{ + return f (i); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/spec35.C b/gcc/testsuite/g++.old-deja/g++.pt/spec35.C new file mode 100644 index 000000000..fc5d5262b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/spec35.C @@ -0,0 +1,35 @@ +// { dg-do assemble } +// +// Copyright (C) 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 18 Jan 2001 <nathan@codesourcery.com> + +// Bug 1617. We didn't resolve partial ordering properly. The std is rather +// vague about it anyway, DR 214 talks about this. + +extern "C" int puts (char const *); + +template <typename T> int Foo (T); // { dg-message "note" } +template <typename T> int Foo (T &); // { dg-message "note" } candidate + +template <typename T> int Qux (T); // { dg-message "note" } +template <typename T> int Qux (T const &); // { dg-message "note" } candidate + +template <typename T> int Bar (T const *const &); // { dg-message "note" } +template <typename T> int Bar (T *const &); // { dg-message "note" } candidate +template <typename T> int Bar (T *); // { dg-message "note" } candidate + +template <typename T> int Baz (T *const &); // { dg-message "note" } +template <typename T> int Baz (T *); // { dg-message "note" } candidate + +int Baz (int const *ptr, int *ptr2) +{ + Baz (ptr2); // { dg-error "ambiguous" } + // { dg-message "candidate" "candidate note" { target *-*-* } 26 } + Bar (ptr2); // { dg-error "ambiguous" } + // { dg-message "candidate" "candidate note" { target *-*-* } 28 } + Foo (ptr2); // { dg-error "ambiguous" } + // { dg-message "candidate" "candidate note" { target *-*-* } 30 } + Qux (ptr2); // { dg-error "ambiguous" } + // { dg-message "candidate" "candidate note" { target *-*-* } 32 } + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/spec36.C b/gcc/testsuite/g++.old-deja/g++.pt/spec36.C new file mode 100644 index 000000000..e52323b6b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/spec36.C @@ -0,0 +1,47 @@ +// { dg-do run } +// Copyright (C) 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 18 Jan 2001 <nathan@codesourcery.com> + +// Bug 1617. We didn't resolve partial ordering properly. The std is rather +// vague about it anyway, DR 214 talks about this. + +extern "C" int puts (char const *); + +template <typename T> int Foo (T *) {puts (__PRETTY_FUNCTION__); return 1;} +template <typename T> int Foo (T &) {puts (__PRETTY_FUNCTION__); return 2;} +template <typename T> int Foo (T const &) {puts (__PRETTY_FUNCTION__); return 3;} + +template <typename T> int Bar (T const *const &) {puts (__PRETTY_FUNCTION__); return 4;} +template <typename T> int Bar (T *const &) {puts (__PRETTY_FUNCTION__); return 5;} +template <typename T> int Bar (T *) {puts (__PRETTY_FUNCTION__); return 6;} + +template <typename T> int Quux (T *const &) {puts (__PRETTY_FUNCTION__); return 7;} +template <typename T> int Quux (T const &) {puts (__PRETTY_FUNCTION__); return 8;} + + +int Baz (int const *ptr, int *ptr2) +{ + if (Foo (ptr) != 1) + return 1; + if (Foo (ptr2) != 1) + return 2; + if (Foo (*ptr) != 3) + return 3; + if (Foo (*ptr2) != 2) + return 4; + + if (Bar (ptr) != 4) + return 5; + + if (Quux (ptr) != 7) + return 5; + if (Quux (ptr2) != 7) + return 6; + + return 0; +} + +int main () +{ + return Baz (0, 0); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/spec37.C b/gcc/testsuite/g++.old-deja/g++.pt/spec37.C new file mode 100644 index 000000000..1fd9ef929 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/spec37.C @@ -0,0 +1,25 @@ +// { dg-do assemble } +// +// Copyright (C) 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 21 Jan 2001 <nathan@codesourcery.com> + +// Bug 1728. We started sorting things when there were 7 fields. Our +// template_count algorithm was rather fragile ... + +template <int dim> struct X +{ + struct Y + { + int x1; + int x2; + int x3; + int x4; + int x5; + int x6; + int x7; + + void Foo (); + }; +}; + +template <> void X<1>::Y::Foo () {} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/spec38.C b/gcc/testsuite/g++.old-deja/g++.pt/spec38.C new file mode 100644 index 000000000..75095575b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/spec38.C @@ -0,0 +1,17 @@ +// { dg-do assemble } +// +// Copyright (C) 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 19 Jan 2001 <nathan@codesourcery.com> + +// Bug 1638. We failed to check if a function instantiation produced a void +// parameter type. + +template <class T> struct S +{ + int f (T); // { dg-error "" } void type +}; + +void foo () +{ + S<void> s; +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/spec39.C b/gcc/testsuite/g++.old-deja/g++.pt/spec39.C new file mode 100644 index 000000000..8b4e76745 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/spec39.C @@ -0,0 +1,43 @@ +// { dg-do assemble } +// +// Copyright (C) 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 19 Jan 2001 <nathan@codesourcery.com> + +// Bug 1656. We failed to make sure that a template-id was built +// from a primary template. + +template <int dim> struct Outer +{ + struct Inner {}; + + void f() + { + Inner<dim> i; // { dg-error "" } non-template + Inner<> j; // { dg-error "" } non-template + } +}; +struct O {}; +void foo () +{ + Outer<1> x; + x.f (); + Outer<1>::Inner<2> z; // { dg-error "" } non-template + O<1> w; // { dg-error "" } non-template +} + +template <typename T, template <typename C> class TPL> +struct X +{ + TPL<T> t; + T<int> s; // { dg-error "" } non-template +}; + +template <typename T> struct Y +{ +}; + +void bar () +{ + X<int, Y> a; + X<int, O> b; // { dg-error "" } non-template +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/spec4.C b/gcc/testsuite/g++.old-deja/g++.pt/spec4.C new file mode 100644 index 000000000..d7ef63c31 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/spec4.C @@ -0,0 +1,16 @@ +// { dg-do assemble } + +template <class T> +struct S {}; + +template <> +struct S<int> +{ + void f(); + void g(); +}; + +void S<int>::f() {} + +template <> +void S<int>::g() {} // { dg-error "" } does not match any template declaration 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 000000000..70abb6fc5 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/spec40.C @@ -0,0 +1,14 @@ +// { dg-do run } +// 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/spec41.C b/gcc/testsuite/g++.old-deja/g++.pt/spec41.C new file mode 100644 index 000000000..9e22d7df8 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/spec41.C @@ -0,0 +1,10 @@ +// { dg-do assemble } + +// Origin: <mikes@nilenet.com> + +// Bug: Specialization of implicitly created function should be +// rejected. + +template<class T> class blah{}; +blah<char>::blah(){} // { dg-error "" } invalid specialization +int main(){} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/spec5.C b/gcc/testsuite/g++.old-deja/g++.pt/spec5.C new file mode 100644 index 000000000..df7112ad0 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/spec5.C @@ -0,0 +1,22 @@ +// { dg-do assemble } + +template <class T> +void f(T t1, T t2); // { dg-message "note" } + +template <> +void f(int i, int j); + +template <class T> +void g(T t1, T t2) {} // { dg-message "note" } + +template void g(int i, int j); + +void h() +{ + f(3, 'c'); // { dg-error "" } no matching function + // { dg-message "candidate" "candidate note" { target *-*-* } 16 } + g(3, 'c'); // { dg-error "" } no matching function + // { dg-message "candidate" "candidate note" { target *-*-* } 18 } +} + + diff --git a/gcc/testsuite/g++.old-deja/g++.pt/spec6.C b/gcc/testsuite/g++.old-deja/g++.pt/spec6.C new file mode 100644 index 000000000..fc19c3cf5 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/spec6.C @@ -0,0 +1,33 @@ +// { dg-do assemble } + +struct S1 +{ + template <class T> + void f(T t1, T t2); // { dg-message "note" } +}; + + +template <> +void S1::f(int i1, int i2); + +template <class U> +struct S2 +{ + template <class T> + void f(T t1, T t2); // { dg-message "note" } +}; + +template <> +template <> +void S2<char>::f(int i1, int i2); + +void h() +{ + S1 s1; + s1.f(3, 'c'); // { dg-error "" } no matching function + // { dg-message "candidate" "candidate note" { target *-*-* } 27 } + + S2<char> s2; + s2.f(3, 'c'); // { dg-error "" } no matching function + // { dg-message "candidate" "candidate note" { target *-*-* } 31 } +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/spec7.C b/gcc/testsuite/g++.old-deja/g++.pt/spec7.C new file mode 100644 index 000000000..81be8f1d5 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/spec7.C @@ -0,0 +1,20 @@ +// { dg-do run } +extern "C" void abort(); + +template <class T> +void f(T t1, T t2); + +template <> +void f(int i, int j) +{ + abort(); +} + +void f(short s, char c) +{ +} + +int main() +{ + f(3, 'c'); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/spec8.C b/gcc/testsuite/g++.old-deja/g++.pt/spec8.C new file mode 100644 index 000000000..f06f31352 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/spec8.C @@ -0,0 +1,28 @@ +// { dg-do run } +extern "C" void abort(); + +template <void* P> +void f(int j); + +template <int I> +void f(int j); + + +template <void* P> +void f(int j) +{ + abort(); +} + + +template <int I> +void f(int j) +{ +} + + +int main() +{ + f<3>(7); +} + diff --git a/gcc/testsuite/g++.old-deja/g++.pt/spec9.C b/gcc/testsuite/g++.old-deja/g++.pt/spec9.C new file mode 100644 index 000000000..e2c5b4e52 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/spec9.C @@ -0,0 +1,22 @@ +// { dg-do assemble } +extern "C" void abort(); + +template <class T> +inline int f(T t) +{ + return 0; +} + +int main() +{ + if (!f(3)) + abort(); +} + +template <> +int f(int i) // { dg-error "specialization\[^\n\]*after instantiation" } +{ + return 1; +} + + diff --git a/gcc/testsuite/g++.old-deja/g++.pt/static1.C b/gcc/testsuite/g++.old-deja/g++.pt/static1.C new file mode 100644 index 000000000..aafd0091d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/static1.C @@ -0,0 +1,22 @@ +// { dg-do run } +extern "C" void abort(); + +template <class T> +class A +{ + public: + static int foo(int); +}; + +template <> +int A<int>::foo(int i) +{ + return i; +} + + +int main() +{ + if (A<int>::foo(22) != 22) + abort(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/static10.C b/gcc/testsuite/g++.old-deja/g++.pt/static10.C new file mode 100644 index 000000000..591312190 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/static10.C @@ -0,0 +1,17 @@ +// { dg-do assemble } +// regression test - + +// by Paul Burchard <burchard@pobox.com>, Level Set Systems, Inc. +// Copyright (C) 1999 Free Software Foundation + +template<class A> +struct X { + X(A) { + } +}; +template<class A> +struct Y { + static X<A> x(A(1)); // { dg-error "" } ANSI C++ forbids in-class initialization of non-const static member `x' +}; +Y<int> y; + diff --git a/gcc/testsuite/g++.old-deja/g++.pt/static11.C b/gcc/testsuite/g++.old-deja/g++.pt/static11.C new file mode 100644 index 000000000..867436a65 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/static11.C @@ -0,0 +1,35 @@ +// Some targets (e.g. those with "set_board_info needs_status_wrapper 1" +// in their dejagnu baseboard description) require that the status is +// final when exit is entered (or main returns), and not "overruled" by a +// destructor calling _exit. It's not really worth it to handle that. +// { dg-do run { target unwrapped } } + +// Bug: g++ was failing to destroy C<int>::a because it was using two +// different sentry variables for construction and destruction. + +extern "C" void _exit (int); + +int r = 1; + +struct A +{ + void f(){} + A(){ ++r; } + ~A(){ r -= 2; _exit (r); } +}; + +template<class T> +struct C +{ + C(){ a.f(); } + static A a; +}; + +template <class T> A C<T>::a; +typedef C<int> B; + +int main() +{ + C<int> c; + return r; +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/static2.C b/gcc/testsuite/g++.old-deja/g++.pt/static2.C new file mode 100644 index 000000000..d75caf457 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/static2.C @@ -0,0 +1,21 @@ +// { dg-do assemble } + +template <class A> +class TEST +{ +public: + TEST (A) {} +}; + +template <class A> +class TEST2 +{ + static A i; +}; + +template <class A> +A TEST2 <A>::i (0); + +TEST2 <TEST <int> > a; + +template class TEST2 <TEST <int> >; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/static3.C b/gcc/testsuite/g++.old-deja/g++.pt/static3.C new file mode 100644 index 000000000..5a638b1f7 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/static3.C @@ -0,0 +1,17 @@ +// { dg-do run } +// On targets that don't support weak symbols, we require an explicit +// instantiation of arr. +// { dg-require-weak "" } + +template<class T> +struct A { + static T arr[5]; +}; + +template <class T> +T A<T>::arr[5] = { 0, 1, 2, 3, 4 }; + +int main () +{ + return A<int>::arr[0]; +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/static4.C b/gcc/testsuite/g++.old-deja/g++.pt/static4.C new file mode 100644 index 000000000..e582740aa --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/static4.C @@ -0,0 +1,8 @@ +// { dg-do assemble } + +template <class T> +struct S +{ + static const T t = 3; +}; + diff --git a/gcc/testsuite/g++.old-deja/g++.pt/static5.C b/gcc/testsuite/g++.old-deja/g++.pt/static5.C new file mode 100644 index 000000000..aed6208d5 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/static5.C @@ -0,0 +1,9 @@ +// { dg-do assemble } + +template <class T> +struct S +{ + static const T t = 3; // { dg-error "" } initializing non-integral type +}; + +double d = S<double>::t; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/static6.C b/gcc/testsuite/g++.old-deja/g++.pt/static6.C new file mode 100644 index 000000000..3ff41fead --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/static6.C @@ -0,0 +1,15 @@ +// { dg-do link } +// { dg-xfail-if "" { *-*-aout *-*-coff *-*-hms } { "*" } { "" } } + +// Simplified from testcase by Erez Louidor Lior <s3824888@techst02.technion.ac.il> + +template <class T> struct A { + static const int l[1]; +}; + +template<class T> +const int A<T>::l[1] = {1}; + +int i = A<int>::l[0]; + +int main(){} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/static7.C b/gcc/testsuite/g++.old-deja/g++.pt/static7.C new file mode 100644 index 000000000..49c558c3a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/static7.C @@ -0,0 +1,14 @@ +// { dg-do assemble } +// Origin: Mark Mitchell <mark@codesourcery.com> + +template <class T> +struct S { + S() {} + + static S s; +}; + +template <class T> +S<T> S<T>::s; + +S<int> si; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/static8.C b/gcc/testsuite/g++.old-deja/g++.pt/static8.C new file mode 100644 index 000000000..9b2ca8283 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/static8.C @@ -0,0 +1,33 @@ +// { dg-do run } +// Origin: Mark Mitchell <mark@codesourcery.com> + +int i; + +template <class T> +struct S { + S() { ++i; } + + virtual void g() {} + virtual void f(); + + static S s; +}; + +template <class T> +void S<T>::f() { + s.f(); +} + +S<int> si; + +template <class T> +S<T> S<T>::s; + +int main () +{ + si.g(); + if (i != 2) + return 1; + else + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/static9.C b/gcc/testsuite/g++.old-deja/g++.pt/static9.C new file mode 100644 index 000000000..f23741cd3 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/static9.C @@ -0,0 +1,27 @@ +// { dg-do assemble } +// Origin: Mark Mitchell <mark@codesourcery.com> + +template <class T> +struct S { + int i; +}; + +template <class T> +struct X { + static S<T> s[]; +}; + +template <class T> +S<T> X<T>::s[] = { + { 3 } +}; + +struct Z {}; + +void f(S<Z>* s); + +void g() +{ + f (X<Z>::s); +} + diff --git a/gcc/testsuite/g++.old-deja/g++.pt/static_cast.C b/gcc/testsuite/g++.old-deja/g++.pt/static_cast.C new file mode 100644 index 000000000..89e794ab7 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/static_cast.C @@ -0,0 +1,22 @@ +// { dg-do assemble } + +template <class InputIterator, class BinaryOperation> +void accumulate(InputIterator first, + BinaryOperation binary_op) { +} + + +template<class R> int p( int val, R& r ) +{ + return val + r; +} + +template<class R> void f(R) +{ + accumulate(0, static_cast<int (*)(int, R&)>(p) ); +} + +int main() +{ + f(0); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/stmtexpr.C b/gcc/testsuite/g++.old-deja/g++.pt/stmtexpr.C new file mode 100644 index 000000000..2d5ecbd16 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/stmtexpr.C @@ -0,0 +1,17 @@ +// { dg-do run } +extern "C" void abort(); + +template <class T> +T f(T) +{ + T t = __extension__ ({ T j = 4; j + 3; }); + return t; +} + + +int main() +{ + if (f(3) != 7) + abort(); +} + diff --git a/gcc/testsuite/g++.old-deja/g++.pt/stmtexpr2.C b/gcc/testsuite/g++.old-deja/g++.pt/stmtexpr2.C new file mode 100644 index 000000000..36c0fcceb --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/stmtexpr2.C @@ -0,0 +1,25 @@ +// { dg-do run } +extern "C" void abort(); + +int i; + +void g() +{ + i++; +} + +template <class T> +void f(T) +{ + __extension__ ({g();}); +} + +int main() +{ + f(3.0); + if (i != 1) + abort(); + + return 0; +} + diff --git a/gcc/testsuite/g++.old-deja/g++.pt/switch1.C b/gcc/testsuite/g++.old-deja/g++.pt/switch1.C new file mode 100644 index 000000000..45bc9510b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/switch1.C @@ -0,0 +1,15 @@ +// { dg-do assemble } +// Origin: Mark Mitchell <mark@codesourcery.com> + +template <class T> +void f () +{ + int i; + + switch (int i = 3) { + } +} + +template void f<int>(); + + diff --git a/gcc/testsuite/g++.old-deja/g++.pt/syntax1.C b/gcc/testsuite/g++.old-deja/g++.pt/syntax1.C new file mode 100644 index 000000000..4400ae297 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/syntax1.C @@ -0,0 +1,26 @@ +// { dg-do assemble } + +// Copyright (C) 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 22 June 2000 <nathan@codesourcery.com> + +// Origin GNATS bug report 262 from Jeremy Sanders <jss@ast.cam.ac.uk> +// and several others. With templates, it's very easy to say something +// erroneous like +// template class X::X<whatever> +// The culprit +// ... class X::X ... +// caused us to ICE as we got confused about pushing and popping scopes. + + + +class Y +{ + public: + template <class T> Y(T &); +}; +template <class T> Y::Y(T &) {} + +template class Y::Y (int); // { dg-error "" } parse error +template Y::Y (int); // { dg-error "" } template-id does not match +template Y::Y (int &); + diff --git a/gcc/testsuite/g++.old-deja/g++.pt/syntax2.C b/gcc/testsuite/g++.old-deja/g++.pt/syntax2.C new file mode 100644 index 000000000..17a642e2f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/syntax2.C @@ -0,0 +1,27 @@ +// { dg-do assemble } + +// Copyright (C) 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 22 June 2000 <nathan@codesourcery.com> + +// Origin GNATS bug report 262 from Jeremy Sanders <jss@ast.cam.ac.uk> +// and several others. With templates, it's very easy to say something +// erroneous like +// template class X::X<whatever> +// The culprit +// ... class X::X ... +// caused us to ICE as we got confused about pushing and popping scopes. + +template <class T> class image +{ +public: + template <class U> image(const image<U> ©); +}; + +template <class T> template <class U> image<T>::image(const image<U> ©) +{ +} + +template class image<double>; +template class image<double>::image (const image<int> &); // { dg-error "" } parse error +template class image<double>::image (image<int>); // { dg-error "" } specified as declarator-id +template image<double>::image (const image<int> &); diff --git a/gcc/testsuite/g++.old-deja/g++.pt/t00.C b/gcc/testsuite/g++.old-deja/g++.pt/t00.C new file mode 100644 index 000000000..ad3b9ad72 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/t00.C @@ -0,0 +1,12 @@ +// { dg-do assemble } + +int f1 () { + struct A { A() { a = 2; } int a; } ; + A aa; + return aa.a; +} +int f2 () { + struct A { A() { a = 2; } int a; } ; + A ab; + return ab.a; +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/t01.C b/gcc/testsuite/g++.old-deja/g++.pt/t01.C new file mode 100644 index 000000000..70943b993 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/t01.C @@ -0,0 +1,6 @@ +// { dg-do assemble } + +template <class A> class B { public: A a; }; +static B<int> b_int; + +int foo () { return b_int.a; } diff --git a/gcc/testsuite/g++.old-deja/g++.pt/t03.C b/gcc/testsuite/g++.old-deja/g++.pt/t03.C new file mode 100644 index 000000000..7e64060e4 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/t03.C @@ -0,0 +1,7 @@ +// { dg-do assemble } + +template <class A> class B { public: A a; }; +static B<int> b_int; +static B<char> b_char; + +int foo () { return b_int.a + b_char.a; } diff --git a/gcc/testsuite/g++.old-deja/g++.pt/t04.C b/gcc/testsuite/g++.old-deja/g++.pt/t04.C new file mode 100644 index 000000000..087c5755d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/t04.C @@ -0,0 +1,8 @@ +// { dg-do assemble } + +template <class A> class B { public: A a; }; +static B<int> b_int; +static B<char> b_char; +static B<unsigned char> b_uchar; + +int foo () { return b_int.a + b_char.a + b_uchar.a; } diff --git a/gcc/testsuite/g++.old-deja/g++.pt/t05.C b/gcc/testsuite/g++.old-deja/g++.pt/t05.C new file mode 100644 index 000000000..bf4f1ea8d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/t05.C @@ -0,0 +1,10 @@ +// { dg-do assemble } + +template <class A> class B { // { dg-message "note" } + A a; + public: + B(A&aa); // { dg-message "note" } + ~B(); +}; +static B<int> b_int (3); // { dg-error "no matching function" } +// { dg-message "candidate" "candidate note" { target *-*-* } 9 } diff --git a/gcc/testsuite/g++.old-deja/g++.pt/t06.C b/gcc/testsuite/g++.old-deja/g++.pt/t06.C new file mode 100644 index 000000000..d3a65b3c3 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/t06.C @@ -0,0 +1,25 @@ +// { dg-do assemble } + +typedef int I; +int i; + +template <class A> class B { + A a; + public: + B(A&aa); + B(); + ~B(); +}; + +template <class B> class C { public: B b; }; + +template <class I, class i> class D : I { public: i ii; }; + +typedef B<int> b_int; +typedef C<int> c_int; +typedef C<b_int> c_b_int2; + +c_b_int2 x2; +int z; +D<c_b_int2,b_int> d; +int q; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/t07.C b/gcc/testsuite/g++.old-deja/g++.pt/t07.C new file mode 100644 index 000000000..d144cad77 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/t07.C @@ -0,0 +1,10 @@ +// { dg-do assemble } + +template <class A> class B { + A a; + public: + const A& value () { return a; } +}; +static B<int> b_int; + +int foo () { return b_int.value(); } diff --git a/gcc/testsuite/g++.old-deja/g++.pt/t08.C b/gcc/testsuite/g++.old-deja/g++.pt/t08.C new file mode 100644 index 000000000..8f8f37b73 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/t08.C @@ -0,0 +1,10 @@ +// { dg-do assemble } + +template <class A> class B { + A a; + public: + B (); + ~B (); +}; +B<int> b_int; +B<int> *bp = &b_int; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/t09.C b/gcc/testsuite/g++.old-deja/g++.pt/t09.C new file mode 100644 index 000000000..98c855d39 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/t09.C @@ -0,0 +1,6 @@ +// { dg-do assemble } + +struct bs_1 { + typedef int (*pfi) (void); +}; +static bs_1::pfi fp; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/t10.C b/gcc/testsuite/g++.old-deja/g++.pt/t10.C new file mode 100644 index 000000000..560812c91 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/t10.C @@ -0,0 +1,6 @@ +// { dg-do assemble } + +template <class A> class B { public: A a; B(); }; +template <> class B<char> { public: int y[10]; }; +static B<int> bi; +static B<char> bc; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/t11.C b/gcc/testsuite/g++.old-deja/g++.pt/t11.C new file mode 100644 index 000000000..07abc716c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/t11.C @@ -0,0 +1,9 @@ +// { dg-do assemble } + +template <class A> +class B { +public: + A a; + B() { x = 2; } // { dg-error "" } no x +}; +static B<int> bi; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/t11a.C b/gcc/testsuite/g++.old-deja/g++.pt/t11a.C new file mode 100644 index 000000000..178f093d7 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/t11a.C @@ -0,0 +1,9 @@ +// { dg-do assemble } + +template <class A> +class B { +public: + A a; + B() { a = 2; } +}; +static B<int> bi; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/t12.C b/gcc/testsuite/g++.old-deja/g++.pt/t12.C new file mode 100644 index 000000000..86b65e21f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/t12.C @@ -0,0 +1,25 @@ +// { dg-do assemble } + +class OBJECT {int a;}; +class STDFILE {int b;}; + +template <class T> class VECTOR { + T *v; + int sz; +public: + T& elem(int i) { return v[i]; } + T& operator[] (int i); +}; + +template <class T> +class PVECTOR : VECTOR<void *> { +public: + T*& elem(int i) + {return (T*&) VECTOR<void *>::elem(i); } + T*& operator[] (int i) + {return (T*&) VECTOR<void *>::operator[](i);} +}; + +PVECTOR<OBJECT *> *foo; + +PVECTOR<STDFILE *> *goo; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/t12a.C b/gcc/testsuite/g++.old-deja/g++.pt/t12a.C new file mode 100644 index 000000000..623f01407 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/t12a.C @@ -0,0 +1,5 @@ +// { dg-do assemble } + +int a (void * x) { return 1; } +typedef void *T; +int b (T x) { return 2; } diff --git a/gcc/testsuite/g++.old-deja/g++.pt/t13.C b/gcc/testsuite/g++.old-deja/g++.pt/t13.C new file mode 100644 index 000000000..f2c5180d4 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/t13.C @@ -0,0 +1,19 @@ +// { dg-do assemble } + +template <class A> class B { +public: + B(); + A a; + int i; +}; + +void *f () { + return new B<char *>; +} + +struct foo { int i[10]; }; +extern B<foo> *foop; + +void f2 () { + foop = new B<foo>; +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/t14.C b/gcc/testsuite/g++.old-deja/g++.pt/t14.C new file mode 100644 index 000000000..68443a0fe --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/t14.C @@ -0,0 +1,24 @@ +// { dg-do assemble } + +class OBJECT +{ + int a; +}; + + + +template <class T> class TESTA +{ +public: + TESTA(); + T foo(int i) {T t = 0; return t}; // { dg-error "" } no semi +}; + + + +void foo() +{ + TESTA<OBJECT *> *foo; + + foo = new TESTA<OBJECT *>; +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/t14a.C b/gcc/testsuite/g++.old-deja/g++.pt/t14a.C new file mode 100644 index 000000000..c3a330a85 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/t14a.C @@ -0,0 +1,25 @@ +// { dg-do assemble } + +class OBJECT +{ + int a; +}; + + + +template <class T> class TESTA +{ +public: + TESTA(); + T foo(int i) {T t = 0; return t;} +}; + + + +void foo() +{ + TESTA<OBJECT *> *foo; + + foo = new TESTA<OBJECT *>; +} + diff --git a/gcc/testsuite/g++.old-deja/g++.pt/t16.C b/gcc/testsuite/g++.old-deja/g++.pt/t16.C new file mode 100644 index 000000000..e865bdf3d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/t16.C @@ -0,0 +1,31 @@ +// { dg-do run } +extern "C" int printf (const char *, ...); +template <class T> T max (const T&x, const T&y) +{ + return (x>y)?x:y; +} +int min (const float&, const float&); +int min (const int& i1, const int& i2) { + return (i1 < i2) ? i1 : i2; +} + +class complex +{ + double re, im; + public: + complex (double r, double i=0) { re = r; im = i; } + friend int operator > (const complex& x, const complex &y) { return 0; } + void print () { } +}; + +int main () +{ + complex c1 (1, 0); + complex c2 (2, 0); + + int j = max (1, 37); + complex m1 = max (c1, c2); + m1.print (); + printf ("j=%d\n", j); + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/t18.C b/gcc/testsuite/g++.old-deja/g++.pt/t18.C new file mode 100644 index 000000000..de7a381c6 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/t18.C @@ -0,0 +1,19 @@ +// { dg-do assemble } + +extern void byebye (); +template <class T1, class T2> +struct A +{ + T1 t1; + T2 t2; + A() { t1 = 0; t2 = 0; } + ~A() { byebye(); } +}; + +template <class Q> +int f (A<int, Q> a) { + return a.t1; +} + +extern A<int,double*> aa; +int foop () { return f(aa); } diff --git a/gcc/testsuite/g++.old-deja/g++.pt/t20.C b/gcc/testsuite/g++.old-deja/g++.pt/t20.C new file mode 100644 index 000000000..2e985d806 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/t20.C @@ -0,0 +1,15 @@ +// { dg-do assemble } + +template <class X> class A { +public: + X aaa; + int foo(); +}; + +template <class X> A<X> f(X); + +void frep() { + int x; + x = f(6.4).foo(); +} + diff --git a/gcc/testsuite/g++.old-deja/g++.pt/t21.C b/gcc/testsuite/g++.old-deja/g++.pt/t21.C new file mode 100644 index 000000000..e91e56786 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/t21.C @@ -0,0 +1,8 @@ +// { dg-do assemble } + +template <class X> class A { public: int a; X x; }; +template <class X> X f (A<X> a) { return a.x; } + +extern A<double> a_dbl; + +double fred () { return f (a_dbl); } diff --git a/gcc/testsuite/g++.old-deja/g++.pt/t22.C b/gcc/testsuite/g++.old-deja/g++.pt/t22.C new file mode 100644 index 000000000..fe7a61a38 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/t22.C @@ -0,0 +1,10 @@ +// { dg-do assemble } + +class AA { public: static int xx; }; +template <class X> class A { + public: + static int x; +}; + +int AA::xx; +template <class Y> int A<Y>::x; // { dg-bogus "" } diff --git a/gcc/testsuite/g++.old-deja/g++.pt/t23.C b/gcc/testsuite/g++.old-deja/g++.pt/t23.C new file mode 100644 index 000000000..2e6488af1 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/t23.C @@ -0,0 +1,18 @@ +// { dg-do assemble } + +template <class T> class temp1 +{ +public: + T tvar; +}; + + +template <class T2> class temp2 +{ +public : + temp1<T2> t1var; +}; + + +temp1<int> temp1var; +temp2<int> temp2var; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/t24.C b/gcc/testsuite/g++.old-deja/g++.pt/t24.C new file mode 100644 index 000000000..77d1c9909 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/t24.C @@ -0,0 +1,9 @@ +// { dg-do assemble } +// { dg-options "" } + +template <class X> int f (X x, X y) { return 23; } // { dg-message "note" } + +int foo () { + return f (7); // { dg-error "" } + // { dg-message "candidate" "candidate note" { target *-*-* } 7 } +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/t25.C b/gcc/testsuite/g++.old-deja/g++.pt/t25.C new file mode 100644 index 000000000..6c7db9122 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/t25.C @@ -0,0 +1,8 @@ +// { dg-do assemble } + +template <class X> int f (X x, X y) { return 23; } +template <class X> int f (X x, int j = 3) { return 29; } + +int foo () { + return f (7); // { dg-bogus "" } +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/t26.C b/gcc/testsuite/g++.old-deja/g++.pt/t26.C new file mode 100644 index 000000000..181419bf0 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/t26.C @@ -0,0 +1,8 @@ +// { dg-do assemble } + +template <class X> int f (X x, unsigned int j = 3) { return 29; } +template <class X> int f (X x, X y) { return 23; } + +int foo () { + return f (7.0, 9.0); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/t27.C b/gcc/testsuite/g++.old-deja/g++.pt/t27.C new file mode 100644 index 000000000..ed7c4b262 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/t27.C @@ -0,0 +1,8 @@ +// { dg-do assemble } + +template <class X> int f (X x, int * j) { return 29; } +template <class X> int f (X x, ...) { return 23; } + +int foo () { + return f (7.0, 9.0); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/t28.C b/gcc/testsuite/g++.old-deja/g++.pt/t28.C new file mode 100644 index 000000000..64b1a56e8 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/t28.C @@ -0,0 +1,10 @@ +// { dg-do assemble } + +template <class X> class B; +template <class X> int f (B<X> b) { return 37; } +template <class Y> class B { public: Y y; B() { y = 1; } }; + +int foo () { + B<double> bd; + return f(bd); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/t29.C b/gcc/testsuite/g++.old-deja/g++.pt/t29.C new file mode 100644 index 000000000..bcc94a387 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/t29.C @@ -0,0 +1,8 @@ +// { dg-do assemble } + +template <class X, int n> X f (auto X (*x)[n]) { return (*x)[n/2]; } +extern int i[30]; +extern double d[99]; + +int foo (int ii) { return f (&i); } // causes abort +double foo (double dd) { return f (&d); } diff --git a/gcc/testsuite/g++.old-deja/g++.pt/t30.C b/gcc/testsuite/g++.old-deja/g++.pt/t30.C new file mode 100644 index 000000000..45da04c63 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/t30.C @@ -0,0 +1,8 @@ +// { dg-do assemble } + +template <class X, int n> X f (auto X (*x)[n]) { return (*x)[n/2]; } +extern int i[30], i2[33]; +extern double d[99]; + +int foo (int ii) { return f (&i) + f(&i2); } // causes abort +double foo (double dd) { return f (&d); } diff --git a/gcc/testsuite/g++.old-deja/g++.pt/t31.C b/gcc/testsuite/g++.old-deja/g++.pt/t31.C new file mode 100644 index 000000000..4e3718bc7 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/t31.C @@ -0,0 +1,17 @@ +// { dg-do assemble } + +struct B { int foo (); }; +int B::foo() { return 37; } + +template <class A> struct X { + void f(); +}; + +template <class A> void X<A>::f () +{} + +X<int> x; + +void xyzzy () { + x.f (); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/t32.C b/gcc/testsuite/g++.old-deja/g++.pt/t32.C new file mode 100644 index 000000000..2e906baae --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/t32.C @@ -0,0 +1,14 @@ +// { dg-do assemble } + +template <class X> struct A { + int fooo (int x); + int x; + inline int y () { return 3; } + inline int z () { return 5; } +}; + +template <class Y> int A<Y>::fooo (int t) { return (this->*(x?&A<Y>::y : &A<Y>::z))() + t; } // { dg-bogus "" } + +A<int> ai; + +int frop () { return ai.fooo (100); } diff --git a/gcc/testsuite/g++.old-deja/g++.pt/t32a.C b/gcc/testsuite/g++.old-deja/g++.pt/t32a.C new file mode 100644 index 000000000..d4456d9bf --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/t32a.C @@ -0,0 +1,10 @@ +// { dg-do assemble } + +struct A { + int x; + int y (); + int z (); + int foo (int j); +}; + +int A::foo (int q) { return q + (this->*(x ? &A::y : &A::z)) (); } // { dg-bogus "" } diff --git a/gcc/testsuite/g++.old-deja/g++.pt/t34.C b/gcc/testsuite/g++.old-deja/g++.pt/t34.C new file mode 100644 index 000000000..db591ea7d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/t34.C @@ -0,0 +1,8 @@ +// { dg-do assemble } + +template <class X> struct A { int operator [] (int); }; +template <class Y> int A<Y>::operator[] (int j) { return j * j; } + +extern A<void **> avpp; + +int q () { return avpp[99]; } diff --git a/gcc/testsuite/g++.old-deja/g++.pt/t34a.C b/gcc/testsuite/g++.old-deja/g++.pt/t34a.C new file mode 100644 index 000000000..be082876b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/t34a.C @@ -0,0 +1,16 @@ +// { dg-do assemble } + +struct A { + int operator[] (int); +}; + +//int A::operator[] (int); + +int A::operator[] (int j) +{ + return j * j; +} + +extern A a; + +int q () { return a[99]; } diff --git a/gcc/testsuite/g++.old-deja/g++.pt/t35.C b/gcc/testsuite/g++.old-deja/g++.pt/t35.C new file mode 100644 index 000000000..70d8846f9 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/t35.C @@ -0,0 +1,12 @@ +// { dg-do assemble } +// { dg-options "" } +template<class X> struct A { + A (); + ~A(); + int x, y, z; +}; + +template <class Y> inline A<Y>::A () { x = y = 3; z = 99; } +template <class Z> inline A<Z>::~A() { y = 9999; } + +A<int> ai; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/t35a.C b/gcc/testsuite/g++.old-deja/g++.pt/t35a.C new file mode 100644 index 000000000..48f4ca6cf --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/t35a.C @@ -0,0 +1,5 @@ +// { dg-do assemble } + +template <class X> struct A { }; +template <> struct A<int> { int foo (); }; +int A<int>::foo () { return 37; } diff --git a/gcc/testsuite/g++.old-deja/g++.pt/t36.C b/gcc/testsuite/g++.old-deja/g++.pt/t36.C new file mode 100644 index 000000000..b6bfe0d12 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/t36.C @@ -0,0 +1,6 @@ +// { dg-do assemble } + +void * foo () { + typedef int * ip; + return new ip; +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/t37.C b/gcc/testsuite/g++.old-deja/g++.pt/t37.C new file mode 100644 index 000000000..99348c050 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/t37.C @@ -0,0 +1,17 @@ +// { dg-do assemble } + +class A { // { dg-error "" } synthesized copy ctor +public: + A(int); // { dg-error "" } referenced below + A(float); // { dg-error "" } referenced below + ~A(); +}; + +A::A() { // { dg-error "" } +} + +A::A(int) { +} + +A::~A() { +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/t37a.C b/gcc/testsuite/g++.old-deja/g++.pt/t37a.C new file mode 100644 index 000000000..b3f78c6f6 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/t37a.C @@ -0,0 +1,18 @@ +// { dg-do assemble } + +class A { +public: + A(int); + A(float); + ~A(); +}; + +A::A(float f) { +} + +A::A(int i) { +} + +A::~A() { +} + diff --git a/gcc/testsuite/g++.old-deja/g++.pt/t38.C b/gcc/testsuite/g++.old-deja/g++.pt/t38.C new file mode 100644 index 000000000..5a9da92f8 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/t38.C @@ -0,0 +1,19 @@ +// { dg-do assemble } +// { dg-options "" } +extern "C" int printf (const char *, ...); + +template<class X> struct A { + A (int, char); + ~A (); + A (X *, float); +}; + +template<class Y> inline A<Y>::A (int i, char c) { + printf ("%d, %d\n", i, c); +} +template<class Z> A<Z>::~A() {} +template<class W> A<W>::A (W * d, float f) { + printf ("%x, %e\n", d, f); +} + +A<void> avoid (9, 0); diff --git a/gcc/testsuite/g++.old-deja/g++.pt/t39.C b/gcc/testsuite/g++.old-deja/g++.pt/t39.C new file mode 100644 index 000000000..8f9bead3a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/t39.C @@ -0,0 +1,26 @@ +// { dg-do run } +extern "C" int printf (const char *, ...); + +template <class T> +struct frob { + T *ptr; + void print (); + frob (T* init) { ptr = init; } +}; + +template <class T> +void frob<T>::print () { + printf ("this = %08x\n", this); + printf (" ptr = %08x\n", ptr); + printf (" values = %x %x %x ...\n", ptr[0], ptr[1], ptr[2]); +} + + static int x[10]; + frob<const char> fc ("hello"); + frob<int> fi (x); + +int main () { + fc.print (); + fi.print (); + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/t40.C b/gcc/testsuite/g++.old-deja/g++.pt/t40.C new file mode 100644 index 000000000..e518ed294 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/t40.C @@ -0,0 +1,11 @@ +// { dg-do assemble } + +struct A { + struct B { + B (int); + }; + static int foop (B); + static int splat () { + return foop (B (1)); + } +}; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/t41.C b/gcc/testsuite/g++.old-deja/g++.pt/t41.C new file mode 100644 index 000000000..4bf91cc78 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/t41.C @@ -0,0 +1,11 @@ +// { dg-do assemble } + +struct A { + struct B { + B (int); + }; + static int foop (B); + int splat () { + return foop (B (1)); + } +}; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/t42.C b/gcc/testsuite/g++.old-deja/g++.pt/t42.C new file mode 100644 index 000000000..ca76d5218 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/t42.C @@ -0,0 +1,18 @@ +// { dg-do run } +extern "C" void abort (); + +struct A { + struct stat { + int x; + stat (int j) { abort (); } + }; + static int stat (double d) { return 0; } // { dg-bogus "" } cfront takes it + static int zap () { + stat (0); + return stat (1); // { dg-bogus "" } this should work + } +}; + +int main () { + return A::zap (); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/test4.C b/gcc/testsuite/g++.old-deja/g++.pt/test4.C new file mode 100644 index 000000000..1beac031c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/test4.C @@ -0,0 +1,4 @@ +// { dg-do assemble } + +class B { }; +template <class x, int b> class X : public B { int y[b]; }; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/test5.C b/gcc/testsuite/g++.old-deja/g++.pt/test5.C new file mode 100644 index 000000000..cb9de7e6a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/test5.C @@ -0,0 +1,3 @@ +// { dg-do assemble } + +template <char *a, const char *b, char *const c> class A{int x;}; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/tiemann1r.C b/gcc/testsuite/g++.old-deja/g++.pt/tiemann1r.C new file mode 100644 index 000000000..89b5453b4 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/tiemann1r.C @@ -0,0 +1,8 @@ +// { dg-do assemble } + +struct bs_1 +{ + typedef int (*p_user_hashf)(int); +}; + +bs_1::p_user_hashf i_user_hashf; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/tiemann2.C b/gcc/testsuite/g++.old-deja/g++.pt/tiemann2.C new file mode 100644 index 000000000..2b1a12f88 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/tiemann2.C @@ -0,0 +1,35 @@ +// { dg-do run } +extern "C" int printf (const char *, ...); +template <class T> T max (const T&x, const T&y) +{ + return (x>y)?x:y; +} + +class complex +{ + double re, im; + public: + complex (double r, double i=0) { re = r; im = i; } + friend int operator > (const complex& x, const complex &y); + void print () { printf ("re = %g; im = %g;\n", re, im); } +}; +int operator >(const complex& x, const complex &y) +{ + double c1 = x.re * x.re + x.im * x.im; + double c2 = y.re * y.re + y.im * y.im; + return c1 > c2; +} + +int main () +{ + complex c1 (1, 0); + complex c2 (2, 0); + complex c3 (2, 3); + complex c4 (2, 1); + + complex m1 = max (c1, c2); + complex m2 = max (c3, c4); + m1.print (); + m2.print (); + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/to2.C b/gcc/testsuite/g++.old-deja/g++.pt/to2.C new file mode 100644 index 000000000..e3667c9e4 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/to2.C @@ -0,0 +1,7 @@ +// { dg-do assemble } + +template <class A> class B { public: A a; }; +static B<int> b_int; +static B<int> b_int2; + +int foo () { return b_int.a + b_int2.a; } diff --git a/gcc/testsuite/g++.old-deja/g++.pt/tt.C b/gcc/testsuite/g++.old-deja/g++.pt/tt.C new file mode 100644 index 000000000..68b647cef --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/tt.C @@ -0,0 +1,33 @@ +// { dg-do assemble } + +#define DEF_A struct A { A() { a = 2; } int a; } + +#if 1 +int f1 () { + DEF_A; + A aa; + return aa.a; +} + +int f2 () { + DEF_A; + A ab; + return ab.a; +} +/* results: +tt.cc: In function int f2 (): +tt.cc:9: conflicting types for `A::A ()' +tt.cc:3: previous declaration of `A::A ()' +/u2/projects/gcc2/src/cplus-cvt.c:1149: failed assertion `distance >= 0' +gcc2: Program cc1plus got fatal signal 6. +*/ +#else + +struct B1 { DEF_A; A aa; }; + +struct B2 { DEF_A; A aa; }; +/* results: +/u2/projects/gcc2/src/cplus-decl.c:5469: failed assertion `return_type == return_ctor' +gcc2: Program cc1plus got fatal signal 6. +*/ +#endif diff --git a/gcc/testsuite/g++.old-deja/g++.pt/tt2.C b/gcc/testsuite/g++.old-deja/g++.pt/tt2.C new file mode 100644 index 000000000..694007beb --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/tt2.C @@ -0,0 +1,27 @@ +// { dg-do assemble } + +int f1 () { + struct A { + A() : b (2) { } + int fred () { return b.hi_mom; } + struct B { + int hi_mom; + B (int a) { hi_mom = a; } + }; + B b; + }; + A aa; + return aa.fred(); +} + +int f2 () { + struct A { + ~A() { a = 3; } + int a; + int fred () { return a + 1; } + }; + + A ab; + ab.a = 12; + return ab.fred(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/ttp1.C b/gcc/testsuite/g++.old-deja/g++.pt/ttp1.C new file mode 100644 index 000000000..af3f8f760 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/ttp1.C @@ -0,0 +1,14 @@ +// { dg-do assemble } + +template<class E> class D +{ +}; + +template<template<class> class D,class E> class C +{ +}; + +int main() +{ + C<int,D> c; // { dg-error "" } args not match +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/ttp10.C b/gcc/testsuite/g++.old-deja/g++.pt/ttp10.C new file mode 100644 index 000000000..ca04f907f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/ttp10.C @@ -0,0 +1,30 @@ +// { dg-do assemble } + +template<class T> class D +{ + public: + int f(); +}; + +template<class T> int D<T>::f() +{ + return sizeof(T); +} + +template<template<class> class D,class E> class C +{ + D d; // { dg-error "" } D is a template + public: + int f(); +}; + +template<template<class> class D,class E> int C<D,E>::f() +{ + return d.f(); // { dg-error "" } d not properly declared +} + +int main() +{ + C<D,int> c; + c.f(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/ttp11.C b/gcc/testsuite/g++.old-deja/g++.pt/ttp11.C new file mode 100644 index 000000000..06f5e0bf4 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/ttp11.C @@ -0,0 +1,26 @@ +// { dg-do run } +template<class T> class D +{ + public: + int f(); +}; + +template<class T> int D<T>::f() +{ + return sizeof(T); +} + +template<template<class> class D,class E> class C +{ + D<E> d; + public: + int f() { return d.f(); } +}; + +int main() +{ + C<D,int> c; + C<D,char> d; + c.f(); + d.f(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/ttp12.C b/gcc/testsuite/g++.old-deja/g++.pt/ttp12.C new file mode 100644 index 000000000..e0dae91ef --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/ttp12.C @@ -0,0 +1,29 @@ +// { dg-do run } +template<class T> class D +{ + public: + int f(); +}; + +template<class T> int D<T>::f() +{ + return sizeof(T); +} + +template<template<class> class E,class D> class C +{ + E<D> d; + public: + int f(); +}; + +template<template<class> class E,class D> int C<E,D>::f() +{ + return d.f(); +} + +int main() +{ + C<D,int> c; + c.f(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/ttp13.C b/gcc/testsuite/g++.old-deja/g++.pt/ttp13.C new file mode 100644 index 000000000..dd8675af3 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/ttp13.C @@ -0,0 +1,29 @@ +// { dg-do run } +template<class T> class D +{ + public: + int f(); +}; + +template<class T> int D<T>::f() +{ + return sizeof(T); +} + +template<template<class> class D,class E> class C +{ + D<E> d; + public: + int f(); +}; + +template<template<class> class D,class E> int C<D,E>::f() +{ + return d.f(); +} + +int main() +{ + C<D,int> c; + c.f(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/ttp14.C b/gcc/testsuite/g++.old-deja/g++.pt/ttp14.C new file mode 100644 index 000000000..96f170fd5 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/ttp14.C @@ -0,0 +1,31 @@ +// { dg-do run } +template<class T> class D +{ + T a; + public: + int f(); +}; + +template<class T> int D<T>::f() +{ + return sizeof(T); +} + +template<class E,template<class> class DD = D> class C +{ + DD<E> d; + public: + int f(); +}; + +template<class E,template<class> class DD> int C<E,DD>::f() +{ + DD<E> d2; + return d2.f(); +} + +int main() +{ + C<int> c; + c.f(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/ttp15.C b/gcc/testsuite/g++.old-deja/g++.pt/ttp15.C new file mode 100644 index 000000000..b66470235 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/ttp15.C @@ -0,0 +1,30 @@ +// { dg-do run } +template<class T> class D +{ + public: + int f(); +}; + +template<class T> int D<T>::f() +{ + return sizeof(T); +} + +template<template<class> class D,class E> class C +{ + D<E> d; + public: + int f(); +}; + +template<template<class> class D,class E> int C<D,E>::f() +{ + D<E> d2; + return d2.f(); +} + +int main() +{ + C<D,int> c; + c.f(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/ttp16.C b/gcc/testsuite/g++.old-deja/g++.pt/ttp16.C new file mode 100644 index 000000000..07ed77aab --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/ttp16.C @@ -0,0 +1,31 @@ +// { dg-do run } +template<class T> class D +{ + T a; + public: + int f(); +}; + +template<class T> int D<T>::f() +{ + return sizeof(T); +} + +template<template<class> class D,class E> class C +{ + D<E> d; + public: + int f(); +}; + +template<template<class> class D,class E> int C<D,E>::f() +{ + D<E> d2; + return d2.f(); +} + +int main() +{ + C<D,int> c; + c.f(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/ttp17.C b/gcc/testsuite/g++.old-deja/g++.pt/ttp17.C new file mode 100644 index 000000000..65e5e8f65 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/ttp17.C @@ -0,0 +1,31 @@ +// { dg-do run } +template<class T> class D +{ + public: + int f(); +}; + +template<class T> int D<T>::f() +{ + return sizeof(T); +} + +template<template<class> class D,class E> class C +{ + D<E> d; + public: + int f(); + int g() { return 0; } +}; + +template<template<class> class D,class E> int C<D,E>::f() +{ + C<D,E> d2; + return d2.g(); +} + +int main() +{ + C<D,int> c; + c.f(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/ttp18.C b/gcc/testsuite/g++.old-deja/g++.pt/ttp18.C new file mode 100644 index 000000000..e3f096969 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/ttp18.C @@ -0,0 +1,31 @@ +// { dg-do run } +template<class T> class D +{ + public: + int f(); +}; + +template<class T> int D<T>::f() +{ + return sizeof(T); +} + +template<template<class> class D,class E> class C +{ + D<E> d; + public: + int f(); + int g() { return 0; } +}; + +template<template<class> class D,class E> int C<D,E>::f() +{ + C<D,char> d2; + return d2.g(); +} + +int main() +{ + C<D,int> c; + c.f(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/ttp2.C b/gcc/testsuite/g++.old-deja/g++.pt/ttp2.C new file mode 100644 index 000000000..ccfa9014b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/ttp2.C @@ -0,0 +1,14 @@ +// { dg-do assemble } + +template<class E> class D +{ +}; + +template<template<class> class D,int> class C +{ +}; + +int main() +{ + C<1,D> c; // { dg-error "" } args not match +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/ttp20.C b/gcc/testsuite/g++.old-deja/g++.pt/ttp20.C new file mode 100644 index 000000000..c54119efd --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/ttp20.C @@ -0,0 +1,28 @@ +// { dg-do run } +template<class T> class D +{ + public: + int f(); +}; + +template<class T> int D<T>::f() +{ + return sizeof(T); +} + +template<template<class> class D,class E> class C : D<E> +{ + public: + int g(); +}; + +template<template<class> class D,class E> int C<D,E>::g() +{ + return this->f(); +} + +int main() +{ + C<D,int> c; + c.g(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/ttp21.C b/gcc/testsuite/g++.old-deja/g++.pt/ttp21.C new file mode 100644 index 000000000..f0b41bf3f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/ttp21.C @@ -0,0 +1,34 @@ +// { dg-do run } +template<class T> class D +{ + public: + int f(); +}; + +template<class T> int D<T>::f() +{ + return sizeof(T); +} + +template<template<class> class D,class E> class C : D<E> +{ + public: + int g(); +}; + +template<template<class> class D,class E> int C<D,E>::g() +{ + return this->f(); +} + +class E : C<D,int> +{ + public: + int h() { return this->g(); } +}; + +int main() +{ + E c; + c.h(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/ttp22.C b/gcc/testsuite/g++.old-deja/g++.pt/ttp22.C new file mode 100644 index 000000000..de3334e79 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/ttp22.C @@ -0,0 +1,34 @@ +// { dg-do run } +template<class T> class D +{ + public: + int f(); +}; + +template<class T> int D<T>::f() +{ + return sizeof(T); +} + +template<template<class> class DD,class EE> class C : DD<EE> +{ + public: + int f(); +}; + +template<template<class> class DD,class EE> int C<DD,EE>::f() +{ + return DD<EE>::f(); +} + +class E : C<D,int> +{ + public: + int f() { return C< ::D,int>::f(); } +}; + +int main() +{ + E c; + c.f(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/ttp23.C b/gcc/testsuite/g++.old-deja/g++.pt/ttp23.C new file mode 100644 index 000000000..051a3f330 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/ttp23.C @@ -0,0 +1,34 @@ +// { dg-do run } +template<class T> class D +{ + public: + int f(); +}; + +template<class T> int D<T>::f() +{ + return sizeof(T); +} + +template<template<class> class E,class D> class C : E<D> +{ + public: + int f(); +}; + +template<template<class> class E,class D> int C<E,D>::f() +{ + return E<D>::f(); +} + +class E : C<D,int> +{ + public: + int f() { return C< ::D,int>::f(); } +}; + +int main() +{ + E c; + c.f(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/ttp24.C b/gcc/testsuite/g++.old-deja/g++.pt/ttp24.C new file mode 100644 index 000000000..999ec6cbe --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/ttp24.C @@ -0,0 +1,23 @@ +// { dg-do run } +template<class T> class D +{ + public: + int f(); +}; + +template<class T> int D<T>::f() +{ + return sizeof(T); +} + +template<template<class> class D,class E> int f() +{ + D<E> d; + return d.f(); +} + +int main() +{ + f<D,int>(); + f<D,char>(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/ttp25.C b/gcc/testsuite/g++.old-deja/g++.pt/ttp25.C new file mode 100644 index 000000000..4464b6feb --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/ttp25.C @@ -0,0 +1,34 @@ +// { dg-do run } +template<class T> class D +{ + public: + int f(); +}; + +template<class T> int D<T>::f() +{ + return sizeof(T); +} + +template<template<class> class D,class E> class C +{ + D<E> d; + public: + int f() { return d.f(); } +}; + +template<template<class> class D,class E> int f(D<E> &d1) +{ + d1.f(); + C<D,E> d2; + d2.f(); + return 0; +} + +int main() +{ + D<int> c1; + D<char> c2; + f(c1); + f(c2); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/ttp27.C b/gcc/testsuite/g++.old-deja/g++.pt/ttp27.C new file mode 100644 index 000000000..e29b83e23 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/ttp27.C @@ -0,0 +1,36 @@ +// { dg-do run } +template<class T> class D +{ + public: + int f() const; +}; + +template<class T> int D<T>::f() const +{ + return sizeof(T); +} + +template<template<class> class D,class E> class C +{ + D<E> d; + public: + int f() const { return d.f(); } +}; + +template<template<class> class D,class E> int f(const D<E> &d1) +{ + d1.f(); + C<D,E> d2; + d2.f(); + return 0; +} + +int main() +{ + D<const int> c1; + D<char> c2; + const D<char> c3(c2); + f(c1); + f(c2); + f(c3); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/ttp28.C b/gcc/testsuite/g++.old-deja/g++.pt/ttp28.C new file mode 100644 index 000000000..91480ca59 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/ttp28.C @@ -0,0 +1,40 @@ +// { dg-do run } +template<class T> class D +{ + public: + int f(); +}; + +template<class T> int D<T>::f() +{ + return sizeof(T); +} + +template<template<class> class D,class E> class C +{ + D<E> d; + public: + int f() { return d.f(); } +}; + +template<template<class> class D,class E> int f(D<E> &d1) +{ + d1.f(); + C<D,E> d2; + d2.f(); + return 0; +} + +template<> int f<>(D<char> &d1) +{ + d1.f(); + return 0; +} + +int main() +{ + D<int> c1; + D<char> c2; + f(c1); + f(c2); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/ttp29.C b/gcc/testsuite/g++.old-deja/g++.pt/ttp29.C new file mode 100644 index 000000000..cdf542af6 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/ttp29.C @@ -0,0 +1,33 @@ +// { dg-do run } +template<class T> class D +{ + public: + int f(); +}; + +template<class T> int D<T>::f() +{ + return sizeof(T); +} + +extern "C" void abort(); + +template<template<class> class D,class E> class C +{ + D<E> d; + public: + int f() { abort(); return 0; } +}; + +template<class E> class C<D,E> +{ + D<E> d; + public: + int f() { return d.f(); } +}; + +int main() +{ + C<D,int> c; + c.f(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/ttp3.C b/gcc/testsuite/g++.old-deja/g++.pt/ttp3.C new file mode 100644 index 000000000..2350104cb --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/ttp3.C @@ -0,0 +1,14 @@ +// { dg-do assemble } + +template<class E,class F> class D +{ +}; + +template<template<class> class D,class E> class C +{ +}; + +int main() +{ + C<D,int> c; // { dg-error "" } param list not match/sees it as not having a type +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/ttp30.C b/gcc/testsuite/g++.old-deja/g++.pt/ttp30.C new file mode 100644 index 000000000..6e5724e0e --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/ttp30.C @@ -0,0 +1,38 @@ +// { dg-do run } +template<class T> class D +{ + public: + int f(); +}; + +template<class T> int D<T>::f() +{ + return sizeof(T); +} + +extern "C" void abort(); + +template<template<class> class D,class E> class C +{ + D<E> d; + public: + int f() { abort(); return 0; } +}; + +template<class E> class C<D,E> +{ + D<E> d; + public: + int f(); +}; + +template<class E> int C<D,E>::f() +{ + return d.f(); +} + +int main() +{ + C<D,int> c; + c.f(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/ttp31.C b/gcc/testsuite/g++.old-deja/g++.pt/ttp31.C new file mode 100644 index 000000000..25dcc81c5 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/ttp31.C @@ -0,0 +1,33 @@ +// { dg-do run } +template<class T> class D +{ + public: + int f(); +}; + +template<class T> int D<T>::f() +{ + return sizeof(T); +} + +extern "C" void abort(); + +template<template<class> class D,class E> class C +{ + D<E> d; + public: + int f() { abort(); return 0; } +}; + +template<template <class> class F> class C<F,int> +{ + F<int> d; + public: + int f() { return d.f(); } +}; + +int main() +{ + C<D,int> c; + c.f(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/ttp32.C b/gcc/testsuite/g++.old-deja/g++.pt/ttp32.C new file mode 100644 index 000000000..a03dba2e8 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/ttp32.C @@ -0,0 +1,38 @@ +// { dg-do run } +template<class T> class D +{ + public: + int f(); +}; + +template<class T> int D<T>::f() +{ + return sizeof(T); +} + +extern "C" void abort(); + +template<template<class> class D,class E> class C +{ + D<E> d; + public: + int f() { abort(); return 0; } +}; + +template<template <class> class F> class C<F,int> +{ + F<int> d; + public: + int f(); +}; + +template<template<class>class F> int C<F,int>::f() +{ + return d.f(); +} + +int main() +{ + C<D,int> c; + c.f(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/ttp33.C b/gcc/testsuite/g++.old-deja/g++.pt/ttp33.C new file mode 100644 index 000000000..c5e26646f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/ttp33.C @@ -0,0 +1,32 @@ +// { dg-do run } +template<class T> class D +{ + public: + int f(); +}; + +template<class T> int D<T>::f() +{ + return sizeof(T); +} + +template<template<class> class D,class E> class C +{ + D<E> d; + public: + template<template<class> class F> int f(F<int>); +}; + +template<template<class> class D,class E> +template<template<class> class F> int C<D,E>::f(F<int>) +{ + F<E> d2; + return d2.f(); +} + +int main() +{ + C<D,int> c; + D<int> d; + c.f(d); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/ttp34.C b/gcc/testsuite/g++.old-deja/g++.pt/ttp34.C new file mode 100644 index 000000000..469d20d52 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/ttp34.C @@ -0,0 +1,32 @@ +// { dg-do run } +template<class T> class D +{ + public: + int f(); +}; + +template<class T> int D<T>::f() +{ + return sizeof(T); +} + +template<template<class> class D,class E> class C +{ + D<E> d; + public: + int f(); +}; + +template<template<class> class D,class E> int C<D,E>::f() +{ + D<E> d2; + return d2.f(); +} + +template class C<D,int>; + +int main() +{ + C<D,int> c; + c.f(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/ttp4.C b/gcc/testsuite/g++.old-deja/g++.pt/ttp4.C new file mode 100644 index 000000000..0b65ad6d5 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/ttp4.C @@ -0,0 +1,15 @@ +// { dg-do assemble } + +template<class E> class D +{ +}; + +template<template<class> class D,class E> class C +{ + D<1> d; // { dg-error "" } arg not match +}; + +int main() +{ + C<D,int> c; +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/ttp41.C b/gcc/testsuite/g++.old-deja/g++.pt/ttp41.C new file mode 100644 index 000000000..564294e38 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/ttp41.C @@ -0,0 +1,25 @@ +// { dg-do compile } +// { dg-options "" } +template<template<class> class D,class E> class C +{ + public: + int g() { return 1; } +}; + +template<class T> class D +{ + public: + int f(); +}; + +template<class T> int D<T>::f() +{ + C<D,D> c; + return c.g(); +} + +int main() +{ + D<char> d; + d.f(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/ttp42.C b/gcc/testsuite/g++.old-deja/g++.pt/ttp42.C new file mode 100644 index 000000000..53bdae1e9 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/ttp42.C @@ -0,0 +1,22 @@ +// { dg-do run } +template <class T, template <class T> class C> +struct X +{}; + +template <class T> +struct Y +{}; + +template <class T> +struct Z +{}; + +template <class T> +struct X<T,Y> +{}; + +int main() +{ + X<int,Y> a; + X<int,Z> b; +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/ttp43.C b/gcc/testsuite/g++.old-deja/g++.pt/ttp43.C new file mode 100644 index 000000000..e1bc4cee6 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/ttp43.C @@ -0,0 +1,30 @@ +// { dg-do assemble } + +template < class T, template <class> class E1, template <class> class E2 > +struct Add { + Add(const E1<T>& e1, const E2<T>& e2) {} +}; + + +template < class T, template <class> class E1, template <class> class E2 > +struct Mul { + Mul(const E1<T>& e1, const E2<T>& e2) {} +}; + + +template < class T > +struct Lit { + Lit(const T& t) {} +}; + + +template < class T > +struct Id { + Add < T, ::Id, Lit > operator+(const T& t) const { + return Add < T, ::Id, Lit >(*this, Lit<T>(t)); + } + + Mul < T, ::Id, Lit > operator*(const T& t) const { + return Mul < T, ::Id, Lit >(*this, Lit<T>(t)); + } +}; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/ttp44.C b/gcc/testsuite/g++.old-deja/g++.pt/ttp44.C new file mode 100644 index 000000000..08eb3077f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/ttp44.C @@ -0,0 +1,17 @@ +// { dg-do assemble } + +template < class T, template < class > class E1, template < class > class E2 > +class Add { +public: + Add(const E1<T>& e1, const E2<T>& e2) {} +}; + +template < class T > +struct Id { + template < template < class > class E > + Add < T, ::Id, E > operator+(const E<T>& e) const { + return Add < T, ::Id, E >(*this, e); + } +}; + +template struct Id<double>; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/ttp45.C b/gcc/testsuite/g++.old-deja/g++.pt/ttp45.C new file mode 100644 index 000000000..9ff2aa78a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/ttp45.C @@ -0,0 +1,7 @@ +// { dg-do assemble } + +template<class M, class T> struct temp2; +template<template<class> class M, class T> struct temp2<M<T>, T> {}; + +template<class M> struct temp1; +template<template<class> class M, class T> struct temp1<M<T> > {}; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/ttp46.C b/gcc/testsuite/g++.old-deja/g++.pt/ttp46.C new file mode 100644 index 000000000..b741179b1 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/ttp46.C @@ -0,0 +1,4 @@ +// { dg-do assemble } + +template <template<class> class TT> void f() {} +template <template<class,class> class TT> void f() {} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/ttp47.C b/gcc/testsuite/g++.old-deja/g++.pt/ttp47.C new file mode 100644 index 000000000..268ce877b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/ttp47.C @@ -0,0 +1,17 @@ +// { dg-do run } +template <template<class,class> class TT, class T> void f(T) +{ +} + +template <template<class> class TT, class T> void f(T) +{ +} + +template <class T> class C {}; +template <class T,class U> class D {}; + +int main() +{ + f<C>(1); + f<D>(1); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/ttp48.C b/gcc/testsuite/g++.old-deja/g++.pt/ttp48.C new file mode 100644 index 000000000..355caf501 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/ttp48.C @@ -0,0 +1,17 @@ +// { dg-do run } +template <template<int> class TT, class T> void f(T) +{ +} + +template <template<class> class TT, class T> void f(T) +{ +} + +template <class T> class C {}; +template <int> class D {}; + +int main() +{ + f<C>(1); + f<D>(1); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/ttp49.C b/gcc/testsuite/g++.old-deja/g++.pt/ttp49.C new file mode 100644 index 000000000..844984954 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/ttp49.C @@ -0,0 +1,9 @@ +// { dg-do assemble } + +template <int i> class C {}; +template <template <long> class TT> class D {}; + +int main() +{ + D<C> d; // { dg-error "" } args not match +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/ttp5.C b/gcc/testsuite/g++.old-deja/g++.pt/ttp5.C new file mode 100644 index 000000000..155f12596 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/ttp5.C @@ -0,0 +1,15 @@ +// { dg-do assemble } + +template<int> class D +{ +}; + +template<template<int> class D,class E> class C +{ + D<int> d; // { dg-error "" } arg not match +}; + +int main() +{ + C<D,int> c; +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/ttp50.C b/gcc/testsuite/g++.old-deja/g++.pt/ttp50.C new file mode 100644 index 000000000..365cfaf69 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/ttp50.C @@ -0,0 +1,8 @@ +// { dg-do run } +template <class T, template <T> class TT> class C {}; +template <int> class D {}; + +int main() +{ + C<int,D> c; +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/ttp52.C b/gcc/testsuite/g++.old-deja/g++.pt/ttp52.C new file mode 100644 index 000000000..4a9b7ee39 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/ttp52.C @@ -0,0 +1,16 @@ +// { dg-do assemble } + +template<class A,class B> class mymap {}; + +template<class Key, + class Value, + template<class, class > class MapT> +class base +{ +}; + +// specialization +template<class Key, class Value> +class base<Key, Value, mymap<int, int > > // { dg-error "type/value|class template" } +{ +}; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/ttp53.C b/gcc/testsuite/g++.old-deja/g++.pt/ttp53.C new file mode 100644 index 000000000..b43771c8c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/ttp53.C @@ -0,0 +1,35 @@ +// { dg-do assemble } + +// Submitted by Erez Louidor Lior <s3824888@techst02.technion.ac.il> + +template <typename> class H; +template <typename Target, typename Source> +H<Target> foo(const H<Source>&); + +template <typename Type> +class H{ + +#ifdef OK +public: +#endif + template<template<class, class> class Caster, typename Source> + static H<Type> cast(const H<Source>& s); + +#ifndef OK + template <typename Target, typename Source> + friend H<Target> foo(const H<Source>&); +#endif + +}; + +template <class, class> class caster; + +template <typename Target, typename Source> +H<Target> foo(const H<Source>& s){ + return H<Target>::template cast<caster, Source>(s); +} + +int main(){ + H<int> i; + foo<const int>(i); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/ttp54.C b/gcc/testsuite/g++.old-deja/g++.pt/ttp54.C new file mode 100644 index 000000000..a789e934e --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/ttp54.C @@ -0,0 +1,20 @@ +// { dg-do assemble } + +// Reported by Bruce Eckel <Bruce@EckelObjects.com> + +// [temp.deduct.type] +// Make sure we treat <T> in the construct TT<T> as any type containing T. + +template <class T> class C +{ +}; + +template <class T, template <class> class TT> void f (TT<T *> &t) +{ +} + +int main () +{ + C<char *> c; + f(c); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/ttp55.C b/gcc/testsuite/g++.old-deja/g++.pt/ttp55.C new file mode 100644 index 000000000..d04dbb8b0 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/ttp55.C @@ -0,0 +1,23 @@ +// { dg-do assemble } + +// Testing overloading of function argument involving template template +// parameters + +// Reported by Thomus Kunert <kunert@physik.tu-dresden.de> + +template<class A> +class H{}; + +template <class T> +void f( const T& ){} // #1 + +template< template<class, class> class X, + class A, class B> +void f( const X<A,B> & x ) // #2 +{} + +int main() +{ + H<int> h; + f(h); // #3 +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/ttp56.C b/gcc/testsuite/g++.old-deja/g++.pt/ttp56.C new file mode 100644 index 000000000..70c2312ac --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/ttp56.C @@ -0,0 +1,26 @@ +// { dg-do assemble } + +// by Paul Burchard <burchard@pobox.com>, Level Set Systems, Inc. +// Copyright (C) 1999 Free Software Foundation + +template<class X> +class A { +}; +template<class Y> +class B { +}; + +template<template<class XX> class AA> // { dg-bogus "" } `template <class XX> template <class X> class A<X>' previously declared here +class C { + class D { + }; + D d; + class E : public B<D> { + }; + E e; +}; + +int main() { + C<A> c; // { dg-bogus "" } redefinition of `template <class XX> template <class X> class A<X>' +} + diff --git a/gcc/testsuite/g++.old-deja/g++.pt/ttp57.C b/gcc/testsuite/g++.old-deja/g++.pt/ttp57.C new file mode 100644 index 000000000..3fe33a851 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/ttp57.C @@ -0,0 +1,45 @@ +// { dg-do assemble } +// Origin: Alex Samuel <samuel@codesourcery.com> + +namespace NS +{ + +template <class T, int V> +struct Base +{ +}; + +template <class T> +struct Z +{ + const static int value_ = false; +}; + +template <class T> +struct A : + public Base <T, Z<T>::value_> +{ +}; + +template <class T> +void f(T) +{ +} + +} + + +template <template <class T> class U> +struct B +{ +}; + + +int +main () +{ + B<NS::A> ba; + f (ba); // Koenig lookup + return 0; +} + diff --git a/gcc/testsuite/g++.old-deja/g++.pt/ttp58.C b/gcc/testsuite/g++.old-deja/g++.pt/ttp58.C new file mode 100644 index 000000000..4a3188c8f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/ttp58.C @@ -0,0 +1,48 @@ +// { dg-do assemble } +// Origin: Alex Samuel <samuel@codesourcery.com> + +namespace NS +{ + +template <class T, int V> +struct Base +{ +}; + +template <class T> +struct Z +{ + const static int value_ = false; +}; + +struct Outer +{ + template <class T> + struct A : + public Base <T, Z<T>::value_> + { + }; +}; + +template <class T> +void f(T) +{ +} + +} + + +template <template <class T> class U> +struct B +{ +}; + + +int +main () +{ + B<NS::Outer::A> ba; + f (ba); // Koenig lookup + return 0; +} + diff --git a/gcc/testsuite/g++.old-deja/g++.pt/ttp59.C b/gcc/testsuite/g++.old-deja/g++.pt/ttp59.C new file mode 100644 index 000000000..740484662 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/ttp59.C @@ -0,0 +1,13 @@ +// { dg-do assemble } +// Origin: Marcin Kowalczyk <qrczak@knm.org.pl> + +template<template<typename> class t1, typename t0> void single() +{ + single<t1,t0>(); +} + +template<typename a> class T1 {}; +int main() +{ + single<T1,int>(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/ttp6.C b/gcc/testsuite/g++.old-deja/g++.pt/ttp6.C new file mode 100644 index 000000000..e527dc521 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/ttp6.C @@ -0,0 +1,14 @@ +// { dg-do run } +template<int> class F +{ +}; + +template<template<int> class D,class E> class C +{ + D<1> d; +}; + +int main() +{ + C<F,int> c; +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/ttp60.C b/gcc/testsuite/g++.old-deja/g++.pt/ttp60.C new file mode 100644 index 000000000..a34d08910 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/ttp60.C @@ -0,0 +1,14 @@ +// { dg-do assemble } +// Origin: "Marcin 'Qrczak' Kowalczyk" <qrczak@knm.org.pl> + +template<template<typename> class t1, typename t0> t1<t0> single() +{ + return single<t1,t0>(); +} + +template<typename a> class T1 {}; +int main() +{ + single<T1,int>(); +} + diff --git a/gcc/testsuite/g++.old-deja/g++.pt/ttp61.C b/gcc/testsuite/g++.old-deja/g++.pt/ttp61.C new file mode 100644 index 000000000..90ee042c1 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/ttp61.C @@ -0,0 +1,9 @@ +// { dg-do assemble } +// Origin: grg at ai dot mit dot edu + +class A; +template<template<class Ignored> class base> class C : + public base<A> { + public: + C(A& newa) : base<A>(newa) {} +}; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/ttp62.C b/gcc/testsuite/g++.old-deja/g++.pt/ttp62.C new file mode 100644 index 000000000..6faabe194 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/ttp62.C @@ -0,0 +1,30 @@ +// { dg-do run } +// Origin: Ewgenij Gawrilow <gawrilow@math.TU-Berlin.DE> + +extern "C" void abort (); + +template <template <class X> class B, class A> +struct is_instance_of { + enum { answer=false }; +}; + +template <template <class X> class B, class T> +struct is_instance_of<B, B<T> > { + enum { answer=true }; +}; + +template <class X> struct C { }; +template <class X> struct D { }; + +template <class T> +bool is_C (const T&) { + return is_instance_of<C,T>::answer; +} + +int main() { + if (!is_C(C<int>())) + abort (); + if (is_C(D<int>())) + abort (); + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/ttp63.C b/gcc/testsuite/g++.old-deja/g++.pt/ttp63.C new file mode 100644 index 000000000..75453de4a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/ttp63.C @@ -0,0 +1,7 @@ +// { dg-do assemble } +// Origin: Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net> + +template <template <class> class TT> class X {}; +template <class T> class Y { + X< ::Y> x; +}; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/ttp64.C b/gcc/testsuite/g++.old-deja/g++.pt/ttp64.C new file mode 100644 index 000000000..4cc1b98ae --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/ttp64.C @@ -0,0 +1,58 @@ +// { dg-do assemble } + +// Origin: David Margery <David.Margery@irisa.fr> + +// Bug: We fail to set DECL_TEMPLATE_PARM_P when reducing template +// parameter level. + +template <class T> class A2 { +public: + A2() {} + virtual ~A2() {} + template <class other> A2 & operator=(const A2<other> o) { + i=o.i; + return *this; + } + T i; + T j; +}; + +template <class T> class A1 { +public: + A1() {} + virtual ~A1() {} + template <class other> A1 & operator=(const A1<other> o) { + i=o.i; + return *this; + } + template <class other> A1 & operator=(const A2<other> o) { + i=o.i; + return *this; + } + T i; +}; + +template <template <class U> class T> class B { +public: + B(){} + virtual ~B(){} + template <template <class U2> class O> struct rebind { typedef B<O> other ;}; + template <template <class U2> class O> B & operator=(const B<O> o) { + i=o.i; + return *this; + } + T<int> i; +}; + +int main(int argc, char *argv[]) { + + A1<int> a1; + A1<long> a2; + a1=a2; + + B<A1 > b1; + B<A2 > b2; + b1=b2; + + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/ttp65.C b/gcc/testsuite/g++.old-deja/g++.pt/ttp65.C new file mode 100644 index 000000000..fbc7deed3 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/ttp65.C @@ -0,0 +1,38 @@ +// { dg-do assemble } + +// Copyright (C) 2000 Free Software Foundation +// Contributed by Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net> + +// Bug: We used reject template unification of two bound template template +// parameters. + +template <class T, class U=int> class C +{ +}; + +template <class T, class U> void f(C<T,U> c) +{ +} + +template <class T> void f(C<T> c) +{ +} + +template <template<class,class=int> class C, class T, class U> +void g(C<T,U> c) +{ +} + +template <template<class,class=int> class C, class T> void g(C<T> c) +{ +} + +int main() +{ + C<int,char> c1; + f(c1); + g(c1); + C<int,int> c2; + f(c2); + g(c2); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/ttp7.C b/gcc/testsuite/g++.old-deja/g++.pt/ttp7.C new file mode 100644 index 000000000..729452be0 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/ttp7.C @@ -0,0 +1,15 @@ +// { dg-do assemble } + +template<class E> class D +{ +}; + +template<template<class> class D,class E> class C // { dg-error "" } ref below +{ + D<int,int> d; // { dg-error "" } arg not match +}; + +int main() +{ + C<D,int> c; +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/ttp8.C b/gcc/testsuite/g++.old-deja/g++.pt/ttp8.C new file mode 100644 index 000000000..b376d1bb4 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/ttp8.C @@ -0,0 +1,18 @@ +// { dg-do run } +template<class E> class DD +{ +}; + +template<int> class D +{ +}; + +template<template<class> class D,class E> class C +{ + D<E> d; +}; + +int main() +{ + C<DD,int> c; +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/typedef1.C b/gcc/testsuite/g++.old-deja/g++.pt/typedef1.C new file mode 100644 index 000000000..4d6a1e438 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/typedef1.C @@ -0,0 +1,18 @@ +// { dg-do assemble } +// Testcase for handling of typedef wierdness. + +template <class T> +struct A +{ + typedef enum + { + foo + } B; + + A (B b); +}; + +template <class T> +A<T>::A (B b) +{ +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/typedef2.C b/gcc/testsuite/g++.old-deja/g++.pt/typedef2.C new file mode 100644 index 000000000..89fabaf54 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/typedef2.C @@ -0,0 +1,20 @@ +// { dg-do assemble } + +typedef const int cint; + +template<class T> +class A +{ +public: + T f(cint i); +}; + +template <class T> +T A<T>::f(cint i) +{ +} + +int main() +{ + A<int> a; +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/typedef3.C b/gcc/testsuite/g++.old-deja/g++.pt/typedef3.C new file mode 100644 index 000000000..3787deada --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/typedef3.C @@ -0,0 +1,25 @@ +// { dg-do assemble } + +template <class T> +void f(T, T) +{ +} + +struct A { + typedef enum { + VAL1 + } result_t; +}; + +struct B { + typedef enum { + VAL2 + } result_t; +}; + + +void g() +{ + f(A::VAL1, A::VAL1); + f(B::VAL2, B::VAL2); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/typedef4.C b/gcc/testsuite/g++.old-deja/g++.pt/typedef4.C new file mode 100644 index 000000000..4ccd24663 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/typedef4.C @@ -0,0 +1,17 @@ +// { dg-do assemble } +// Origin: Mark Mitchell <mark@codesourcery.com> + +struct B1 { + typedef int X; +}; + +struct B2 { + typedef int X; +}; + +template <class T> +struct D : public B1, public B2 { + typedef int X; +}; + +template struct D<int>; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/typename1.C b/gcc/testsuite/g++.old-deja/g++.pt/typename1.C new file mode 100644 index 000000000..c3b07ff80 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/typename1.C @@ -0,0 +1,27 @@ +// { dg-do assemble } + +template<class T> +struct A { + typedef T T1; +}; + +template<class T> +struct B { + typedef T T2; +}; + +template<class T> +struct C { +}; + +template<class E> +C<typename E::T2::T1> +foo (E) +{ + return C<typename E::T2::T1>(); +} + +void test() +{ + foo(B<A<int> >()); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/typename10.C b/gcc/testsuite/g++.old-deja/g++.pt/typename10.C new file mode 100644 index 000000000..cdd9850ac --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/typename10.C @@ -0,0 +1,7 @@ +// { dg-do assemble } + +struct S { + typedef int I; +}; + +void f(typename S::I); diff --git a/gcc/testsuite/g++.old-deja/g++.pt/typename11.C b/gcc/testsuite/g++.old-deja/g++.pt/typename11.C new file mode 100644 index 000000000..a22bd6ca7 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/typename11.C @@ -0,0 +1,14 @@ +// { dg-do assemble } + +template <class T, int I> +struct S { + struct X {}; +}; + +template <class T, class U, int I> +typename S<T,I>::X f(T, U) { + typename S<T, I>::X(); + return typename S<T, I>::X(); +} + +template S<int, 3>::X f<int, double, 3>(int, double); diff --git a/gcc/testsuite/g++.old-deja/g++.pt/typename12.C b/gcc/testsuite/g++.old-deja/g++.pt/typename12.C new file mode 100644 index 000000000..d6b6fe151 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/typename12.C @@ -0,0 +1,31 @@ +// { dg-do run } +// { dg-options "" } +// execution test + +int i = 0; + +template <class T> +struct S { + struct X {}; +}; + +template <class T> +void f(T) +{ + S<T>::X(); +} + +template <> +struct S<int> { + static void X() { i = 1; } +}; + +int main() +{ + f(3); + if (i != 1) + return 1; + else + return 0; +} + diff --git a/gcc/testsuite/g++.old-deja/g++.pt/typename13.C b/gcc/testsuite/g++.old-deja/g++.pt/typename13.C new file mode 100644 index 000000000..385834b95 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/typename13.C @@ -0,0 +1,36 @@ +// { dg-do assemble } +// { dg-options "-fpermissive" } + +template <class T> +struct B +{ + typedef int I; +}; + + +template <class T> +struct D : public B<T> +{ + void f(); +}; + + +template <class T> +void D<T>::f() +{ + I(); // { dg-warning "" } +} + + +template <> +struct B<int> +{ + void I(); +}; + + +int main() +{ + D<int> di; + di.f(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/typename14.C b/gcc/testsuite/g++.old-deja/g++.pt/typename14.C new file mode 100644 index 000000000..2e3938329 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/typename14.C @@ -0,0 +1,15 @@ +// { dg-do assemble } +// { dg-options "-Wno-deprecated" } + +template <class T> +struct B { + typedef T X; +}; + +template <class T> +struct S : public B<T> +{ + struct I { + void f(X x); // { dg-error "'X' has not been declared" } implicit typename + }; +}; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/typename15.C b/gcc/testsuite/g++.old-deja/g++.pt/typename15.C new file mode 100644 index 000000000..aee28ce7b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/typename15.C @@ -0,0 +1,18 @@ +// { dg-do assemble } +// { dg-options "" } + +template <class T, bool B> +struct R { + struct X {}; +}; + +template <class T, bool B = false> +struct S : public R <T, B> { +}; + +template <class T> void f() +{ + typename S<T>::X(); +} + +template void f<int>(); diff --git a/gcc/testsuite/g++.old-deja/g++.pt/typename16.C b/gcc/testsuite/g++.old-deja/g++.pt/typename16.C new file mode 100644 index 000000000..34021950d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/typename16.C @@ -0,0 +1,31 @@ +// { dg-do link } +// { dg-options "-Wno-deprecated" } + +struct B { + typedef int I; +}; + +template <class T> +struct D1 : public B { +}; + +template <class T> +struct D2 : public D1<T> { + I i; // { dg-error "" } not a type +}; + +template <> +struct D1<int> { + typedef double I; +}; + +template <class T> +void f(T); +template <> +void f(double) {} + +int main() +{ + D2<int> d2i; + f(d2i.i); // { dg-error "" } no member i +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/typename17.C b/gcc/testsuite/g++.old-deja/g++.pt/typename17.C new file mode 100644 index 000000000..a235d60e1 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/typename17.C @@ -0,0 +1,20 @@ +// { dg-do assemble } + +template <class T> +struct A +{ + typedef T A_Type; +}; + + +template <class U> +struct B : public A<U> +{ + typename B<U>::A_Type Func(); +}; + + +template <class U> +typename B<U>::A_Type B<U>::Func() +{ +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/typename18.C b/gcc/testsuite/g++.old-deja/g++.pt/typename18.C new file mode 100644 index 000000000..ac875f53a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/typename18.C @@ -0,0 +1,21 @@ +// { dg-do assemble } +// { dg-options "" } +// Origin: Mark Mitchell <mark@codesourcery.com> + +void X(); + +template <class T> +struct J { + typedef T X; +}; + +template <class T> +struct S { + typedef T X; + + struct I : public J<X> { + static X* f(); + }; +}; + +S<int> si; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/typename19.C b/gcc/testsuite/g++.old-deja/g++.pt/typename19.C new file mode 100644 index 000000000..5733c9b5b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/typename19.C @@ -0,0 +1,27 @@ +// { dg-do run } +// { dg-options "" } +// Origin: Mark Mitchell <mark@codesourcery.com> + +template <class T> +struct O { + typedef char X; +}; + +template <class T> +struct S { + typedef double X; + + template <class U> + struct I : public O<U> { + static X x; + }; +}; + +template <class T> +template <class U> +typename S<T>::X S<T>::I<U>::x; + +int main() +{ + return sizeof (S<int>::I<double>::x) == 1; +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/typename2.C b/gcc/testsuite/g++.old-deja/g++.pt/typename2.C new file mode 100644 index 000000000..d91774c76 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/typename2.C @@ -0,0 +1,21 @@ +// { dg-do assemble } + +class Base { +public: + class Bar { public: virtual ~Bar() {} }; +}; + +class Derived : public Base { +public: + class Bar : public Base::Bar {}; +}; + +template <class T> +struct XYZ : public T::Bar { + XYZ(): T::Bar() { } +}; + +void test() { + XYZ<Base> b; + XYZ<Derived> d; +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/typename20.C b/gcc/testsuite/g++.old-deja/g++.pt/typename20.C new file mode 100644 index 000000000..215ded440 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/typename20.C @@ -0,0 +1,16 @@ +// { dg-do assemble } +// { dg-options "" } +// Origin: Mark Mitchell <mark@codesourcery.com> + +template <class T> +struct B { + typedef int I; +}; + +template <class T, class X = int> +struct S : public B <T> { + struct I { + }; + + void f(int i = true) {} +}; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/typename21.C b/gcc/testsuite/g++.old-deja/g++.pt/typename21.C new file mode 100644 index 000000000..bd15b567a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/typename21.C @@ -0,0 +1,25 @@ +// { dg-do assemble } +// { dg-options "" } +// Origin: Mark Mitchell <mark@codesourcery.com> + +template <class T> +struct S1 { + typedef T X; +}; + +template <class T> +struct B { + typedef T I; +}; + +template <class T> +struct S2 : public B<T> { + struct I {}; + + typedef typename S1<I>::X IX; + + void f(IX); +}; + +template <class T> +void S2<T>::f(IX) {} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/typename22.C b/gcc/testsuite/g++.old-deja/g++.pt/typename22.C new file mode 100644 index 000000000..ce411bb6c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/typename22.C @@ -0,0 +1,17 @@ +// { dg-do assemble } +// Origin: Mark Mitchell <mark@codesourcery.com> + +template <class T> +struct S { + template <class U> + struct I { + typedef U X; + + X f(); + }; +}; + + +template <class T> +template <class U> +typename S<T>::template I<U>::X S<T>::I<U>::f() {} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/typename23.C b/gcc/testsuite/g++.old-deja/g++.pt/typename23.C new file mode 100644 index 000000000..33030c71e --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/typename23.C @@ -0,0 +1,15 @@ +// { dg-do assemble } +template<class T> +void value_type(T){} + +template <class T> +struct B{ + typedef T value_type; +}; + +template<class>class Vector{}; + +template<class T> +struct D:B<T>{ + Vector<value_type> r; // { dg-error "" } value_type is not a type +}; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/typename24.C b/gcc/testsuite/g++.old-deja/g++.pt/typename24.C new file mode 100644 index 000000000..a376f2459 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/typename24.C @@ -0,0 +1,26 @@ +// { dg-do assemble } +// Origin: Mark Mitchell <mark@codesourcery.com> + +class ostream; + +extern ostream& cout; + +class Foo { }; + +ostream &operator<<(ostream &os, const Foo &) +{ + return os; +} + +template<class T> +const typename T::fooz &operator<<(const Foo &, const T &t) +{ + return t; +} + +int main() +{ + Foo foo; + + cout << foo; +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/typename25.C b/gcc/testsuite/g++.old-deja/g++.pt/typename25.C new file mode 100644 index 000000000..aa1d10902 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/typename25.C @@ -0,0 +1,32 @@ +// { dg-do assemble } +// { dg-options "" } +// Copyright (C) 2000 Free Software Foundation +// Adapted by Nathan Sidwell 1 July 2000 <nathan@codesourcery.com> +// Derived from a bug report by scott snyder <snyder@fnal.gov> +// Our implicit typename extension was causing this pedantically +// correct program to fail + +struct list +{ + typedef int reference; +}; + +class d0_Collection_Base {}; + + +template <class T> +class d0_List_1 + : virtual public d0_Collection_Base, + public list +{ +public: + typedef int reference; +}; + +template <class T> +class d0_List +{ +public: + typedef d0_List_1<T> Base; + typedef typename Base::reference reference; +}; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/typename26.C b/gcc/testsuite/g++.old-deja/g++.pt/typename26.C new file mode 100644 index 000000000..14476b1a8 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/typename26.C @@ -0,0 +1,19 @@ +// { dg-do assemble } +// +// Copyright (C) 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 9 Aug 2000 <nathan@codesourcery.com> + +// We failed to spot where a typename T::t didn't actually declare +// anything. [7.1.5.3]/1 + +template<class LB> struct C +{ + typename LB::DataType; // { dg-error "" } does not declare anything + typename LB::DataType m; +}; + +struct B {}; +struct A { + B; // { dg-error "" } does not declare anything + B m; +}; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/typename27.C b/gcc/testsuite/g++.old-deja/g++.pt/typename27.C new file mode 100644 index 000000000..ae89a67ce --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/typename27.C @@ -0,0 +1,21 @@ +// { dg-do assemble } +// +// Copyright (C) 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 9 Aug 2000 <nathan@codesourcery.com> + +// bugs 173, 174 & 406 all ICE'd due to Koenig lookup involving +// typename T::t. + +struct A +{ + typedef int type; +}; + +template<typename T> void same_key (T, typename T::type); + +template <class T> void foo (T *, void (*) (T, int)); + +void baz (A *ptr) +{ + foo (ptr, same_key); +} 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 000000000..0f2ae51f4 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/typename28.C @@ -0,0 +1,27 @@ +// { dg-do assemble } +// +// 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/typename3.C b/gcc/testsuite/g++.old-deja/g++.pt/typename3.C new file mode 100644 index 000000000..ad026a770 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/typename3.C @@ -0,0 +1,21 @@ +// { dg-do assemble } +// { dg-options "-Wno-deprecated" } + +template <class T> +struct A +{ + typedef T A_Type; +}; + + +template <class U> +struct B : public A<U> +{ + A_Type Func(); // { dg-error "does not name a type" "err" } implicit typename + // { dg-message "note" "note" { target *-*-* } 14 } +}; + + +template <class U> +B<U>::A_Type B<U>::Func() { // { dg-error "typename" } implicit typename +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/typename4.C b/gcc/testsuite/g++.old-deja/g++.pt/typename4.C new file mode 100644 index 000000000..47fb250a9 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/typename4.C @@ -0,0 +1,26 @@ +// { dg-do assemble } +// { dg-options "-Wno-deprecated" } + +template <class T> +struct A +{ + typedef T A_Type; +}; + + +template <class U> +struct B : public A<U> +{ +}; + + +template <class U> +struct C : public B<U> +{ + A_Type Func(); // { dg-error "does not name a type" } implicit typename +}; + + +template <class U> +C<U>::A_Type C<U>::Func() { // { dg-error "typename" } implicit typename +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/typename5.C b/gcc/testsuite/g++.old-deja/g++.pt/typename5.C new file mode 100644 index 000000000..bf3acc991 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/typename5.C @@ -0,0 +1,27 @@ +// { dg-do assemble } +// { dg-options "-Wno-deprecated" } + +template <class T> +struct A +{ + typedef T A_Type; +}; + + +template <class U> +struct B : public A<U> +{ +}; + + +template <class U> +struct C : public B<U> +{ + void Func(A_Type); // { dg-error "has not been declared" } implicit typename +}; + + +template <class U> +void C<U>::Func(A_Type) { // { dg-error "declared void" "void" } implicit typename +// { dg-error "not declared" "decl" { target *-*-* } 25 } +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/typename6.C b/gcc/testsuite/g++.old-deja/g++.pt/typename6.C new file mode 100644 index 000000000..734781202 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/typename6.C @@ -0,0 +1,20 @@ +// { dg-do assemble } + +template <class T> +struct A +{ + typedef T A_Type; +}; + + +template <class U> +struct B : public A<U> +{ + A_Type Func(); // { dg-error "does not name a type" "err" } + // { dg-message "note" "note" { target *-*-* } 13 } +}; + +template <class U> +A<U>::A_Type B<U>::Func() // { dg-error "typename" } function +{ +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/typename7.C b/gcc/testsuite/g++.old-deja/g++.pt/typename7.C new file mode 100644 index 000000000..9bdc4b20c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/typename7.C @@ -0,0 +1,22 @@ +// { dg-do assemble } +// { dg-options "" } +// Test for implicit typename + +template <class T> +struct A { +protected: + typedef struct B { } B; +}; + +template <class T> +struct C { }; + +template <class T> +struct D : public A <C <T> > { + void f () + { + B* new_entries = (B *) 0; // { dg-error "'B' was not declared in this scope" "B" } + // { dg-error "'new_entries' was not declared in this scope" "new_entries" { target *-*-* } 18 } + // { dg-error "expected" "exp" { target *-*-* } 18 } + } +}; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/typename8.C b/gcc/testsuite/g++.old-deja/g++.pt/typename8.C new file mode 100644 index 000000000..4861cf301 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/typename8.C @@ -0,0 +1,28 @@ +// { dg-do assemble } + +template < class T > class A +{ +public: + typedef typename T::myT anotherT; // { dg-error "" } undefined type + + anotherT t; + + A() { } + A(anotherT _t) { + t=_t; + } + + anotherT getT() { + return t; + } +}; + +class B : public A< B > // { dg-error "" } forward declaration +{ +public: + typedef int myT; +}; + +int main() { + B b; +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/typename9.C b/gcc/testsuite/g++.old-deja/g++.pt/typename9.C new file mode 100644 index 000000000..d619b583f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/typename9.C @@ -0,0 +1,17 @@ +// { dg-do run } +// { dg-options "-w" } +// Test to make sure that implicit typename doesn't break name binding rules. + +typedef double A; +template<class T> class B { + typedef char A; +}; +template<class T> struct X : B<T> { + A a; +}; + +int main() +{ + X<char*> x; + return sizeof (x.a) != sizeof (double); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/unify1.C b/gcc/testsuite/g++.old-deja/g++.pt/unify1.C new file mode 100644 index 000000000..2413ab000 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/unify1.C @@ -0,0 +1,14 @@ +// { dg-do assemble } +// Tests non-unification of parms that don't use template parms. + +enum kind {a, b}; + +class C { public: C () {} }; + +template<class P> +void f (P c, kind k) {} + +template<class P> +void f (P c, P d, kind k) {} + +template void f (C c, C, kind k); diff --git a/gcc/testsuite/g++.old-deja/g++.pt/unify2.C b/gcc/testsuite/g++.old-deja/g++.pt/unify2.C new file mode 100644 index 000000000..5a9b2d26e --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/unify2.C @@ -0,0 +1,27 @@ +// { dg-do assemble } + +template <class T> +struct S +{ + typedef T S_Type; +}; + + +template <class T> +void foo(typename S<T>::S_Type) +{ +} + + +template <class T> +void foo(T) +{ +} + + +struct S2 {}; + +void bar() +{ + foo(S2()); // We can't unify with the first foo, so we get the second. +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/unify3.C b/gcc/testsuite/g++.old-deja/g++.pt/unify3.C new file mode 100644 index 000000000..848aca763 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/unify3.C @@ -0,0 +1,22 @@ +// { dg-do assemble } + +template <class T1, class T2> +struct ComputeBinaryType +{ +}; + +template<class T1> +struct ComputeBinaryType<T1, double> { + void g(); +}; + +template<class T1> +struct ComputeBinaryType<T1&, double> { + void h(); +}; + +void f() +{ + ComputeBinaryType<double, double> cb; + cb.g(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/unify4.C b/gcc/testsuite/g++.old-deja/g++.pt/unify4.C new file mode 100644 index 000000000..6dd996108 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/unify4.C @@ -0,0 +1,13 @@ +// { dg-do assemble } +template <class T> void f (T); // { dg-message "note" } + +void g (); +void g (int); + +int +main () +{ + f (g); // { dg-error "" } ambiguous unification + // { dg-message "candidate" "candidate note" { target *-*-* } 10 } + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/unify6.C b/gcc/testsuite/g++.old-deja/g++.pt/unify6.C new file mode 100644 index 000000000..0e5c03495 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/unify6.C @@ -0,0 +1,41 @@ +// { dg-do assemble } + +// Copyright (C) 1999 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 21 May 1999 <nathan@acm.org> + +// Template deduction and type unification should not issue diagnostics when +// they're trying to see if it's possible. Here deduction fails in some cases +// because you cant cv qualify a function type. + +template<class T> void fn(){} // A + +template<class T> void fn(T const *){} // B + +// these next two specializations need to know if they're specializing A or B. +// They specialize A, because they can't instantiate B. + +template<> void fn<int &>() {} // ok, specialize A + +template<> void fn<void ()>() {} // ok, specialize A + +// now make sure we moan when we really should +template<class T> void foo(T const *){} // { dg-message "note" } + +void f() +{ + foo<int &>(); // { dg-error "" } attempt to build int & const * + // { dg-message "candidate" "candidate note" { target *-*-* } 26 } + foo<void ()>(); // { dg-error "" } attempt to build void (const *)() + // { dg-message "candidate" "candidate note" { target *-*-* } 28 } +} + +typedef void (*Fptr)(); + +template<class T> void PV(Fptr const &, T const * const &); +template<class T1, class T2> void PV(T1 const * const &, T2 const * const &); + +void baz() +{ + void *t; + PV(&baz, t); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/unify7.C b/gcc/testsuite/g++.old-deja/g++.pt/unify7.C new file mode 100644 index 000000000..fb7e6b026 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/unify7.C @@ -0,0 +1,15 @@ +// { dg-do assemble } + +// Copyright (C) 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 26 Feb 2000 <nathan@codesourcery.com> + +// template functions can be distinguished by return type alone. The return +// type may also be a template parameter. + +template <typename C> C foo (); // { dg-bogus "" } + +void g () +{ + int (*pfn1) () = &foo; // { dg-bogus "" } + void (*pfn2) () = &foo; // { dg-bogus "" } +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/unify8.C b/gcc/testsuite/g++.old-deja/g++.pt/unify8.C new file mode 100644 index 000000000..320926092 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/unify8.C @@ -0,0 +1,21 @@ +// { dg-do assemble } + +// Copyright (C) 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 12 Jan 2001 <nathan@codesourcery.com> + +// Bug 1630. Template deduction at a call allowed conversions more lenient than +// qualification conversions. That would lead to misleading diagnostics during +// overload resolution. + + +template <typename T> void Foo (T const **); // { dg-message "note" } +template <typename T> void Bar (T const * const *); +void Foo (int); // { dg-message "note" } +void Foo (float); // { dg-message "note" } candidate + +void baz (int **p1) +{ + Foo (p1); // { dg-error "match" } no such function + // { dg-message "candidate" "candidate note" { target *-*-* } 18 } + Bar (p1); // OK +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/union1.C b/gcc/testsuite/g++.old-deja/g++.pt/union1.C new file mode 100644 index 000000000..6f17cf18d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/union1.C @@ -0,0 +1,18 @@ +// { dg-do assemble } + +union Un {int i;}; + +template<class T1, class T2> struct St1 {}; +template<class T> struct St1<Un,T> {}; + +template<class T> struct St2 {}; +template<> struct St2<Un> {}; + +template<class T1, class T2> struct St3 {}; +template<> struct St3<Un,int> {}; + +void f() { + St1<int,int> s1; + St2<int> s2; + St3<int,int> s3; +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/union2.C b/gcc/testsuite/g++.old-deja/g++.pt/union2.C new file mode 100644 index 000000000..fdb038f20 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/union2.C @@ -0,0 +1,18 @@ +// { dg-do assemble } +// Origin: David Mazieres <dm@amsterdam.lcs.mit.edu> + +template<class T> struct vector_base { + typedef T elm_t; +protected: + union { + double alignment_hack; + char defbuf_space[2 * sizeof (elm_t)]; + }; + elm_t *def_basep () { return reinterpret_cast<elm_t *> (defbuf_space); } +}; + +template<class T> struct vector : public vector_base<T> { + vector () { this->def_basep (); } +}; + +vector<int> iv; 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 000000000..8147b2b7c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/using1.C @@ -0,0 +1,37 @@ +// { dg-do run } +// Copyright (C) 2001, 2002 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 000000000..27ae74a0f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/using2.C @@ -0,0 +1,26 @@ +// { dg-do assemble } +// +// 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++.pt/vaarg.C b/gcc/testsuite/g++.old-deja/g++.pt/vaarg.C new file mode 100644 index 000000000..c5a8c804e --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/vaarg.C @@ -0,0 +1,29 @@ +// { dg-do run } +#include <stdarg.h> + +extern "C" void abort(); + +template <class T> +T* f(T t, ...) +{ + va_list ap; + + va_start(ap, t); + T* r = va_arg(ap, T*); + va_end(ap); + + return r; +} + + +struct S +{ +}; + +int main() +{ + S s; + + if (f(s, &s) != &s) + abort(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/vaarg2.C b/gcc/testsuite/g++.old-deja/g++.pt/vaarg2.C new file mode 100644 index 000000000..ebdc5d7ec --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/vaarg2.C @@ -0,0 +1,26 @@ +// { dg-do assemble } +// Copyright (C) 2000 Free Software Foundation +// Contributed by Nathan Sidwell 22 June 2000 <nathan@codesourcery.com> + +// Origin GNATS bug report 63 from Kurt Garloff <garloff@tue.nl> +// We attempted to expand va_arg prematurely in a template function. + +#include <stdarg.h> + +template <class Type> +void PrintArgs (Type somearg, ...) +{ +va_list argp; +va_start (argp, somearg); +Type value; +while ( ( value = va_arg (argp, Type) ) > 0.0) + continue; +va_end (argp); +} + +int main (void) +{ +double dummy = 0; +PrintArgs (dummy, 1.0, 2.0, 3.0, -1.0); +return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/vaarg3.C b/gcc/testsuite/g++.old-deja/g++.pt/vaarg3.C new file mode 100644 index 000000000..07fb18d77 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/vaarg3.C @@ -0,0 +1,27 @@ +// { dg-do assemble } +// Copyright (C) 2000 Free Software Foundation +// Contributed by Nathan Sidwell 22 June 2000 <nathan@codesourcery.com> + +#include <stdarg.h> + +struct A { + virtual ~A () {} +}; + +template <class Type> +void PrintArgs (Type somearg, ...) +{ +va_list argp; +va_start (argp, somearg); +Type value; +value = va_arg (argp, Type); // { dg-error "cannot receive" } cannot pass non-POD +va_end (argp); +} + +int main (void) +{ +A dummy; +PrintArgs (dummy, dummy); // { dg-error "cannot pass" } cannot pass non-POD +// { dg-message "instantiated" "inst" { target *-*-* } 24 } +return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/var1.C b/gcc/testsuite/g++.old-deja/g++.pt/var1.C new file mode 100644 index 000000000..a15743d3e --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/var1.C @@ -0,0 +1,4 @@ +// { dg-do assemble } +// Origin: Jason Merrill <jason@cygnus.com> + +template <class T> T t; // { dg-error "" } template declaration of t diff --git a/gcc/testsuite/g++.old-deja/g++.pt/vbase1.C b/gcc/testsuite/g++.old-deja/g++.pt/vbase1.C new file mode 100644 index 000000000..ddffa93d3 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/vbase1.C @@ -0,0 +1,34 @@ +// { dg-do run } +// Check that template classes handle inherited virtual bases +// properly, initializing them before direct non-virtual bases. + +extern "C" void exit (int); + +int aflag; + +struct A +{ + A() { aflag = 1; } +}; + +struct B : virtual public A +{ + B() { } +}; + +struct C +{ + C() { if (!aflag) exit (1); } +}; + +template<class Parent> +struct D : public C, public Parent +{ + D() { } +}; + +int +main () +{ + D<B> c; +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/virtual1.C b/gcc/testsuite/g++.old-deja/g++.pt/virtual1.C new file mode 100644 index 000000000..f30730f29 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/virtual1.C @@ -0,0 +1,7 @@ +// { dg-do run } + struct V { virtual ~V() {} }; + template <class T> struct A : virtual V { }; + template <class T> struct B { + virtual void f() { T foo; } + }; + int main() { B< A<int> > bar; } diff --git a/gcc/testsuite/g++.old-deja/g++.pt/virtual2.C b/gcc/testsuite/g++.old-deja/g++.pt/virtual2.C new file mode 100644 index 000000000..a056a159a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/virtual2.C @@ -0,0 +1,21 @@ +// { dg-do assemble } +// Origin: Mark Mitchell <mark@codesourcery.com> + +template <class T> +struct B +{ + virtual void f() = 0; +}; + +template <class T> +struct D : public B<T> { + virtual void f(); +}; + +void g() { + B<int>* bi = new D<int>; +} + +template <class T> +void B<T>::f() {} + diff --git a/gcc/testsuite/g++.old-deja/g++.pt/virtual3.C b/gcc/testsuite/g++.old-deja/g++.pt/virtual3.C new file mode 100644 index 000000000..c34f508f3 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/virtual3.C @@ -0,0 +1,15 @@ +// { dg-do assemble } +// Origin: Mark Mitchell <mark@codesourcery.com> + +struct S +{ + int i; +}; + +template <typename T> +struct X : virtual public T, virtual public S +{ + int i; + + X () : i (3) {} +}; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/virtual4.C b/gcc/testsuite/g++.old-deja/g++.pt/virtual4.C new file mode 100644 index 000000000..0cbd23c36 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/virtual4.C @@ -0,0 +1,41 @@ +// { dg-do run } +// Origin: Mark Mitchell <mark@codesourcery.com> + +struct B +{ + B (); + virtual void f () = 0; +}; + +B::B () +{ +} + +extern B* bp; + +template <class T> +struct C : public B +{ + virtual void f () + { + } +}; + +template <class T> +struct D : public B +{ + virtual void f () + { + bp = new C<T*>; + } +}; + +B* bp = new D<int>; + +int main () +{ + bp->f (); + bp->f (); +} + + diff --git a/gcc/testsuite/g++.old-deja/g++.pt/warn1.C b/gcc/testsuite/g++.old-deja/g++.pt/warn1.C new file mode 100644 index 000000000..de9e7bb40 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/warn1.C @@ -0,0 +1,27 @@ +// { dg-do assemble } +// { dg-options "-Wunused" } + +template <class T> +struct S +{ + struct R + { + R(); + ~R(); + }; + + void foo() + { + R r; // no warning + int i; // { dg-warning "" } unused + } + + S(); + ~S(); +}; + +void f() +{ + S<int> si; + si.foo(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/warn2.C b/gcc/testsuite/g++.old-deja/g++.pt/warn2.C new file mode 100644 index 000000000..95514c942 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/warn2.C @@ -0,0 +1,19 @@ +// { dg-do assemble } +// { dg-options "-Wall" } +// Origin: Jeroen@MMR.be + +template <typename T> +void f() +{ + for(;;) + for(;;) + goto a; + + a: + ; +} + +void g() +{ + f<long>(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.rfg/00321_01-.C b/gcc/testsuite/g++.old-deja/g++.rfg/00321_01-.C new file mode 100644 index 000000000..dcc607e32 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.rfg/00321_01-.C @@ -0,0 +1,14 @@ +// { dg-do assemble } +// Here is a simple one. GCC correctly gives errors for this code when the +// - -pedantic-errors option is used, whereas g++ doesn't. + + +int (*p1)[3]; +int (*p2)[5]; + +void +test () +{ + p1 == p2; // { dg-error "comparison between distinct pointer types" } comparison.* + p1 > p2; // { dg-error "comparison between distinct pointer types" } comparison.* +} diff --git a/gcc/testsuite/g++.old-deja/g++.rfg/00324_02-.C b/gcc/testsuite/g++.old-deja/g++.rfg/00324_02-.C new file mode 100644 index 000000000..1e742cb0d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.rfg/00324_02-.C @@ -0,0 +1,16 @@ +// { dg-do assemble } +// Another simple one. GCC corerctly gives errors for this code when the +// - -pedantic-errors options is used. g++ doesn't. + + +void f (int i) { } + +void (*fp)(void); + +int i; + +void +test () +{ + i ? f : fp; // { dg-error "conditional expression|invalid conversion" } +} diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/980310-1.C b/gcc/testsuite/g++.old-deja/g++.robertl/980310-1.C new file mode 100644 index 000000000..860080ea9 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/980310-1.C @@ -0,0 +1,44 @@ +// { dg-do run } +// { dg-options "-g" } +// Internal compiler error on egcs 1.0.1 i586-pc-linux-gnulibc1. +// From: Max Lawson <mlawson@drfmc.ceng.cea.fr> +// Message-Id: <9803091022.AA07520@drfmc.ceng.cea.fr> + + +typedef __SIZE_TYPE__ size_t; + +struct dummy { }; + +struct arrrrrgh { }; + +template<class Par,class Rand = arrrrrgh> +struct whyyyyyyy { }; + +template<class T, class S =dummy> +struct grrrrrrrr { }; + +template<class Par, class Par2 =Par, class Rand =arrrrrgh> +class no_future +{ +public: + + template<class S> + no_future(const grrrrrrrr<whyyyyyyy<Par,Rand>*,S>& man ) { } + + ~no_future( ) { } + +private: + + no_future(const no_future&); + no_future& operator=(const no_future&); +}; + +int main( ) +{ + grrrrrrrr<whyyyyyyy<double>*> man; + + no_future<double> here(man); + + return 0; +} + diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/README b/gcc/testsuite/g++.old-deja/g++.robertl/README new file mode 100644 index 000000000..220d57d3d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/README @@ -0,0 +1,25 @@ +This directory contains a hodgepodge of problem reports that appeared on +the egcs-bugs or egcs mailing lists. Just like the reports themselves, +they tend to be poorly understood and poorly organized. However, we +drop them into the testsuite on the premise that internal compiler errors +are always bad - no matter how bogus the source. + +If you really understand C++ (and you know who you are) if you find +entries in this area that are bogus, feel free to just fix them or nuke +them. You don't need my permission. + +Many of the first entries in this area were done in "block mode" by +whipping through many months of archives. In hindsight, some important +information was lost, but being picky on over 8,000 messages is a sure +way to never get out of the gate. + +We'll do better now. + +Robert Lipe + + +Copyright (C) 1998 Free Software Foundation, Inc. + +Copying and distribution of this file, with or without modification, +are permitted in any medium without royalty provided the copyright +notice and this notice are preserved. diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb10.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb10.C new file mode 100644 index 000000000..ba9c6db7d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb10.C @@ -0,0 +1,30 @@ +// { dg-do assemble } +template <int object_size> +class _fixed_size_allocator +{ + private: + + struct something { }; + static something * asdf; + + public: + + static void delete_object (); +}; + + +template <class T> +class object_allocator +{ + private: + + typedef _fixed_size_allocator<sizeof (T)> allocator; + + public: + + static void deallocate (T * p) + { + allocator::delete_object (reinterpret_cast<void *> (p)); + } +}; + diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb102.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb102.C new file mode 100644 index 000000000..c82fd56d9 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb102.C @@ -0,0 +1,35 @@ +// { dg-do run } +// Error: intenral compiler error on 1998/05/28 snapshot. +#include <stdio.h> +#include <stdlib.h> + +void evilRises (void **ptr) +{ + int *pi; + + pi = new int; + + *pi = 0; + + *ptr = (void *)pi; +} + +int main (int argc, char *argv[]) +{ +#ifdef WORKAROUND + union foo +#else + union +#endif + { + int a; + int b; + int c; + } *fred, barney; + + evilRises((void **)&fred); + + barney = *fred; + + return EXIT_SUCCESS; +} diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb103.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb103.C new file mode 100644 index 000000000..c272d9403 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb103.C @@ -0,0 +1,11 @@ +// { dg-do assemble } +// Error: Internal compiler error in 2.7.2 & EGCS 1.0.0 + +template <int nlimb, int i> +inline unsigned f (unsigned* ptr); +template <int nlimb> +inline unsigned f<nlimb,nlimb> (unsigned* ptr) // { dg-error "function template partial specialization" } +{ + return 1; +} + diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb104.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb104.C new file mode 100644 index 000000000..d399a5f84 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb104.C @@ -0,0 +1,30 @@ +// { dg-do run } +#include <string.h> + +class SomeClass_t { +public: + SomeClass_t () : x (11) {} +protected: + float x; +}; + +class DynamicOnly_t { +public: + static DynamicOnly_t* create (const char* name = "UNDEF", + const SomeClass_t& somec = *(new SomeClass_t +())) { + return new DynamicOnly_t (name, somec); + } + DynamicOnly_t (const char* name, const SomeClass_t& somec) : + m_somec (somec) { + strncpy (m_Name, name, sizeof (m_Name)); + } +private: + SomeClass_t m_somec; + char m_Name[255]; +}; + +int main (int argc, char* argv[]) { + DynamicOnly_t* ptr = DynamicOnly_t::create (); + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb105.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb105.C new file mode 100644 index 000000000..400b15b95 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb105.C @@ -0,0 +1,13 @@ +// { dg-do assemble } +template< class T > +void sort( T* t, int n ) + { + struct +/*line5*/ { + int operator()(T i, T j) + { + return (i < j) ? -1 : ((j < i) ? 1 : 0) ; + } + } c ; + sort(t, n, c, 0) ; + } diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb106.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb106.C new file mode 100644 index 000000000..b341cff55 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb106.C @@ -0,0 +1,36 @@ +// { dg-do assemble { target native } } +// { dg-options "-O2 -fPIC " } +struct T +{ + const char* f1; + int f2; +}; + +void f(T*); +int g(); + +extern char a1[]; + +inline int m(int a, int b) {return b < a ? 2 : 1;} + +void +h() +{ + T a[10]; + int i(0); + + bool c; + if (c) + { + a[i++].f1 = "asf"; + f(a); + i = 0; + } + + a[i].f1 = &a1[1]; + a[i].f2 = m(1, g()); + i++; + + a[i].f1 = "zxv"; + a[i].f2 = 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb107.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb107.C new file mode 100644 index 000000000..3e90a9cc1 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb107.C @@ -0,0 +1,20 @@ +// { dg-do assemble } +template <class T> +struct X +{ + virtual void f(int) const; +}; + +template <class T> +struct Y: public X<T> +{ + virtual void f(int) const; +}; + +template <class T> +void Y<T>::f(int) const +{ +} + +template <> +void Y<bool>::f(int) const; diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb108.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb108.C new file mode 100644 index 000000000..3f19c2ad7 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb108.C @@ -0,0 +1,21 @@ +// { dg-do assemble } +class X +{ + public: + virtual void f() const = 0; +}; + +template <class T> +class Y: public X +{ + public: + virtual void f() const; +}; + +template <class T> +void Y<T>::f() const +{ +} + +template <> +void Y<bool>::f() const; diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb109.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb109.C new file mode 100644 index 000000000..f34907626 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb109.C @@ -0,0 +1,75 @@ +// { dg-do assemble } +#include<map> +#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 +{ + public: + Empty(int=0) {} + bool operator<(const Empty&) const { return true;} +}; +inline ostream& operator<<(ostream& os, const Empty&) { return os;} +inline istream& operator>>(istream& is, Empty& ) { return is;} + + +template<class VertexType, class EdgeType> +class Graph // { dg-message "note" } candidates +{ + public: + // public type interface + typedef std::map<int, EdgeType > Successor; + typedef std::pair<VertexType, Successor> vertex; + typedef std::vector<vertex> GraphType; + typedef typename GraphType::iterator iterator; + typedef typename GraphType::const_iterator const_iterator; + + // a lot of stuff deleted .... + + private: + bool directed; + GraphType C; // container + ostream* pOut; +}; + +// all graph-methods delet +template<class VertexType, class EdgeType> +ostream& operator<<(ostream& os, Graph<VertexType,EdgeType>& G) +{ + // display of vertices with successors + for(int i = 0; i < G.size(); ++i) // { dg-error "no member" } no size function + { + os << G[i].first << " <"; // { dg-error "no match" } no index operator + + // The compiler does not like this line!!!!!! + typename Graph<VertexType, EdgeType>::Successor::iterator + startN = G[i].second.begin(), // { dg-error "no match" } no index operator + endN = G[i].second.end(); // { dg-error "no match" } no index operator + + while(startN != endN) + { + os << G[(*startN).first].first << ' ' // { dg-error "no match" } no index operator + << (*startN).second << ' '; + ++startN; + } + os << ">\n"; + } + return os; +} + +int main() +{ + // no edge weighting, therefore type Empty: + Graph<std::string, Empty> V(true); // { dg-error "no match" } no bool constructor + // { dg-message "candidate" "candidate note" { target *-*-* } 68 } + // ReadGraph(V, "gra1.dat"); + + // display of vertices with successors + cout << V; + +} diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb11.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb11.C new file mode 100644 index 000000000..e5f29a157 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb11.C @@ -0,0 +1,29 @@ +// { dg-do assemble } + +template<int N1, int N2> +struct meta_max { + enum { max = (N1 > N2) ? N1 : N2 }; +}; + +struct X { + enum { + a = 0, + n = 0 + }; +}; + +template<class T1, class T2> +struct Y { + + enum { + a = T1::a + T2::a, + + // NB: if the next line is changed to + // n = (T1::n > T2::n) ? T1::n : T2::n + // the problem goes away. + + n = meta_max<T1::n,T2::n>::max + }; +}; + +int z = Y<X,X>::a; diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb110.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb110.C new file mode 100644 index 000000000..96b085f9b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb110.C @@ -0,0 +1,26 @@ +// { dg-do assemble } +class X +{ + public: + virtual void f() const = 0; +}; + +template <class T> +class Y: public X +{ + public: + virtual void f() const; +}; + +template <class T> +void Y<T>::f() const +{ +} + +template <> +void Y<bool>::f() const; + +template <> +void Y<bool>::f() const +{ +} diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb111.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb111.C new file mode 100644 index 000000000..c671de459 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb111.C @@ -0,0 +1,7 @@ +// { dg-do run } + int main() { + for(int i=1; i < 9; i++); + for(int i=1; i < 9; i++); + + return 0; + } diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb112.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb112.C new file mode 100644 index 000000000..69ee83c7d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb112.C @@ -0,0 +1,11 @@ +// { dg-do assemble } +template <class STRUCT, class MEMBER> inline STRUCT * +setback(MEMBER *bp, MEMBER STRUCT::*offset) +{ + // The implementation of this function may be platform dependend + if(!bp) return 0; // NULL pointers remain NULL + union { int i; MEMBER STRUCT::*of; } u; // Switch types. Casting won't work. + u.of = offset; + return (STRUCT *) ((int) bp - u.i); +} + diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb113.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb113.C new file mode 100644 index 000000000..9c7ca6bfa --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb113.C @@ -0,0 +1,6 @@ +// { dg-do assemble } +#include <iostream> + +class X : public std::streambuf +{ +} ; diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb114.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb114.C new file mode 100644 index 000000000..265d16c5e --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb114.C @@ -0,0 +1,30 @@ +// { dg-do run } +#include <string.h> + +class SomeClass_t { +public: + SomeClass_t () : x (11) {} +protected: + float x; +}; + +class DynamicOnly_t { +public: + static DynamicOnly_t* create (const char* name = "UNDEF", + const SomeClass_t& somec = *(new SomeClass_t +())) { + return new DynamicOnly_t (name, somec); + } + DynamicOnly_t (const char* name, const SomeClass_t& somec) : + m_somec (somec) { + strncpy (m_Name, name, sizeof (m_Name)); + } +private: + SomeClass_t m_somec; + char m_Name[255]; +}; + +int main (int argc, char* argv[]) { + DynamicOnly_t* ptr = DynamicOnly_t::create (); //* + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb115.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb115.C new file mode 100644 index 000000000..e7065b269 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb115.C @@ -0,0 +1,10 @@ +// { dg-do run } +// { dg-options "-O" } + +#include <iostream> +#include <typeinfo> + +int main() { + int *i1, *i2; + std::cerr << (typeid(i1)==typeid(i2)) << std::endl; +} diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb116.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb116.C new file mode 100644 index 000000000..be5973a52 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb116.C @@ -0,0 +1,24 @@ +// { dg-do run } +template <class INT> +class b +{ +private: + char a(int x) + { + union { + int i; + char c; + } val; + val.i = x; + return val.c; + } + +public: + b() { + } +}; + +int main() { + b<int> n; + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb119.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb119.C new file mode 100644 index 000000000..329393aea --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb119.C @@ -0,0 +1,12 @@ +// { dg-do assemble } +template<bool B> +void f() // { dg-message "note" } +{ +} + +int main() +{ + f<bool>(); // { dg-error "" } .* + // { dg-message "candidate" "candidate note" { target *-*-* } 9 } +} + diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb12.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb12.C new file mode 100644 index 000000000..9b34944b7 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb12.C @@ -0,0 +1,32 @@ +// { dg-do assemble } +// Error: Internal Compiler Error in 2.7.2. & egcs 1.0.0 + +#ifndef NO_META_MAX +template<int N1, int N2> +struct meta_max { + enum { max = (N1 > N2) ? N1 : N2 }; +}; +#endif + +struct X { + enum { + a = 0, + n = 0 + }; +}; + +template<class T1, class T2> +struct Y { + + enum { + a = T1::a + T2::a, + + // NB: if the next line is changed to + // n = (T1::n > T2::n) ? T1::n : T2::n + // the problem goes away. + + n = meta_max<T1::n,T2::n>::max + }; +}; + +int z = Y<X,X>::a; diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb120.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb120.C new file mode 100644 index 000000000..b261802b9 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb120.C @@ -0,0 +1,23 @@ +// { dg-do run } +template<double functionToIntegrate(double)> +double integrate(double a, double b, int numSamplePoints) +{ + // PRECONDITION(numSamplePoints > 1); + double delta = (b-a) / (numSamplePoints-1); + double sum = 0.; + for (int i=0; i < numSamplePoints; ++i) + sum += functionToIntegrate(a + i*delta); + return sum * (b-a) / numSamplePoints; +} + +inline double myFunction(double x) +{ + return 1 / (1 + x); +} + +// Example use +int main() { +double z = integrate<myFunction>(0.0, 1.0, 50); + return 0 ; +} + diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb121.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb121.C new file mode 100644 index 000000000..e01d74788 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb121.C @@ -0,0 +1,21 @@ +// { dg-do assemble } +class A { +private: + int i1_; +public: + void f(int const i1 = 1); // { dg-error "previous specification" } +}; + +void +A::f(int const i1 = 1) // { dg-error "default argument given" } +{ + i1_ = i1; +} + +int +main() +{ + A a; + a.f(); + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb122.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb122.C new file mode 100644 index 000000000..f52017194 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb122.C @@ -0,0 +1,10 @@ +// { dg-do assemble } +// { dg-options "" } +// Disable -ansi -pedantic-errors because of GNU extension +template<class foo> +class bar { +public: + void baz() { (({ while( foo::baz() );})); } +}; +template<class foo> +void baz() { (({ while( foo::baz() );})); } diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb123.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb123.C new file mode 100644 index 000000000..cb4505f7e --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb123.C @@ -0,0 +1,10 @@ +// { dg-do assemble } +// { dg-options "-O2 -W " } +#include "stdio.h" + +void writeNote() throw( int ) +{ + printf( "hello world\n" ); + try { } + catch( int ){ throw; } +} diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb124.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb124.C new file mode 100644 index 000000000..0be035ae8 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb124.C @@ -0,0 +1,5 @@ +// { dg-do assemble } +#include <stdexcept> +class X : public std::runtime_error { + X (); +}; diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb125.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb125.C new file mode 100644 index 000000000..f2352c222 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb125.C @@ -0,0 +1,22 @@ +// { dg-do assemble } + +struct test_box + { + void print(void); + }; + +void test<class BOX> (test_box *); // { dg-error "" } illegal code + +class test_square + { + friend void test<class BOX> (test_box *); // { dg-error "" } does not match + } // { dg-error "after class definition" } + + + +template <class BOX> void test(BOX *the_box) + {x // { dg-error "not declared in this scope" } + the_box->print(); // { dg-error "before" } + } + +template void test<> (test_box *); diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb126.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb126.C new file mode 100644 index 000000000..c6c66c387 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb126.C @@ -0,0 +1,30 @@ +// { dg-do run } +#include <string.h> + +class SomeClass_t { +public: + SomeClass_t () : x (11) {} +protected: + float x; +}; + +class DynamicOnly_t { +public: + static DynamicOnly_t* create (const char* name = "UNDEF", + const SomeClass_t& somec = *(new SomeClass_t +())) { + return new DynamicOnly_t (name, somec); + } + DynamicOnly_t (const char* name, const SomeClass_t& somec) : + m_somec (somec) { + strncpy (m_Name, name, sizeof (m_Name)); + } +private: + SomeClass_t m_somec; + char m_Name[255]; +}; + +int main (int argc, char* argv[]) { + DynamicOnly_t* ptr = DynamicOnly_t::create (); + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb127.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb127.C new file mode 100644 index 000000000..d8d28b36a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb127.C @@ -0,0 +1,61 @@ +// { dg-do assemble } +// Gets ICE 40. + +#include <vector> +#include<string> +#include <iostream> + +using namespace std; + +class ODEsolver +{ + private: + void eulerODE(vector<double>& y, double& t, double& dt); + void midpointODE(vector<double>& y, double& t, double& dt); + + protected: + void (ODEsolver::*useMethod)(vector<double>&, double&, double&); + void init(); + + public: + ODEsolver(); + void timeloop(vector<double>& y, double ts, double te, double dt); +}; + + +ODEsolver::ODEsolver() +{ + init(); +} + + +void ODEsolver::eulerODE(vector<double>& y, double& t, double& dt) +{ + y[0] = dt * 2.; +} + +void ODEsolver::midpointODE(vector<double>& y, double& t, double& dt) +{ + y[0] = dt * 3.; +} + + + +void ODEsolver::init() +{ + ODEsolver::useMethod = &ODEsolver::midpointODE; +} + +void ODEsolver::timeloop(vector<double>& y, double ts, double te, double dt) +{ + (ODEsolver::useMethod)(y,ts,dt); // { dg-error "" } should use this->* +} + +int main (int nargs, char** args) +{ + ODEsolver solver; + vector<double> y(2); double t_start=5.; double t_end=7.; double dt=2.; + solver.timeloop(y,t_start,t_end,dt); + cout << y[0] << endl; + return(0); +} diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb128.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb128.C new file mode 100644 index 000000000..d3d48e18a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb128.C @@ -0,0 +1,12 @@ +// { dg-do assemble } +template<class T> +struct A { + typedef T* iterator; // { dg-error "" } pointer to reference +public: + A(){} +}; + +void f() +{ + A<int&> a; +} diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb129.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb129.C new file mode 100644 index 000000000..83fb86bb9 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb129.C @@ -0,0 +1,23 @@ +// { dg-do assemble } +// Gives ICE on EGCS release branch as of 98/06/08 on i686-pc-linux-gnulibc1) +// From: Klaus-Georg Adams <Klaus-Georg.Adams@chemie.uni-karlsruhe.de> +// Message-Id: <199806081358.PAA02505@achibm5.chemie.uni-karlsruhe.de> +#include <list> +#include <functional> +#include <algorithm> +#include <cassert> +using namespace std; +int main() +{ + list<int> l; + l.push_back(1); + l.push_back(2); + + list<int>::iterator it = + find_if( l.begin(), l.end(), + // This is a typo, it should be bind2nd, but an + // ICE is not a very helpful diagnostic! + binder2nd( equal_to<int>(), 2 ) ); // { dg-error "" } + assert( *(it) == 2 ); +} + diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb129a.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb129a.C new file mode 100644 index 000000000..bba5ff067 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb129a.C @@ -0,0 +1,22 @@ +// { dg-do assemble } +// Gives ICE on EGCS release branch as of 98/06/08 on i686-pc-linux-gnulibc1) +// From: Klaus-Georg Adams <Klaus-Georg.Adams@chemie.uni-karlsruhe.de> +// Message-Id: <199806081358.PAA02505@achibm5.chemie.uni-karlsruhe.de> +#include <list> +#include <functional> +#include <algorithm> +#include <cassert> +int main() +{ + std::list<int> l; + l.push_back(1); + l.push_back(2); + + std::list<int>::iterator it = + std::find_if( l.begin(), l.end(), + // This is a typo, it should be bind2nd, but an + // ICE is not a very helpful diagnostic! + std::binder2nd( std::equal_to<int>(), 2 ) ); // { dg-error "" } + assert( *(it) == 2 ); +} + diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb13.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb13.C new file mode 100644 index 000000000..40c454aae --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb13.C @@ -0,0 +1,16 @@ +// { dg-do assemble } +template<class T> +class Array { +public: + typedef T T_numtype; +}; + +template<class T_array> +void f(T_array, typename T_array::T_numtype) +{ +} + +void g() +{ + f(Array<float>(), float()); +} diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb130.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb130.C new file mode 100644 index 000000000..20175cd9d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb130.C @@ -0,0 +1,11 @@ +// { dg-do assemble } +// { dg-options "-Wall -Wno-deprecated" } +// Gives spurious warnings when compiled with -Wall +// EGCS 06/08/98 i686-pc-linux-gnulibc1 +// Message-Id: <199806081358.PAA02505@achibm5.chemie.uni-karlsruhe.de> +// From: Klaus-Georg Adams <Klaus-Georg.Adams@chemie.uni-karlsruhe.de> + + +#include <backward/hash_set> +__gnu_cxx::hash_set<int> foo; + diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb131.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb131.C new file mode 100644 index 000000000..67445308c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb131.C @@ -0,0 +1,22 @@ +// { dg-do assemble } +// From: Klaus-Georg Adams <Klaus-Georg.Adams@chemie.uni-karlsruhe.de> +// Reported against EGCS snaps 98/06/18. + +struct a { + a(); + void junk( float ); + void junk( double ); + + void bar( double ); + void bar( float ); + + void foo( void (a::*member)(float) ); // { dg-message "void a::foo|no known conversion" } +}; + +a::a() +{ + foo( &junk ); // { dg-error "match" } junk is an unqualified-id. + // { dg-message "candidate" "candidate note" { target *-*-* } 18 } + foo( &bar ); // { dg-error "match" } bar is an unqualified-id. + // { dg-message "candidate" "candidate note" { target *-*-* } 20 } +} diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb132.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb132.C new file mode 100644 index 000000000..e5992aa66 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb132.C @@ -0,0 +1,28 @@ +// { dg-do assemble } +// { dg-options "-O -Wall -fgcse" } +// From: Klaus-Georg Adams <Klaus-Georg.Adams@chemie.uni-karlsruhe.de> +// Reported against EGCS snaps 98/06/28. +// +// Compilation of this program with the flags g++ -Wall -O -fgcse +// or -O2 produces spurious warnings in the standard +// header <std/bastring.h>. +// +// They vanish if the declaration of a::b is taken out. + +#include <string> + +std::string foo(); +struct a { + void bar(); + enum b { c, d }; + b theb; + std::string baz; +}; + +void +a::bar() +{ + baz += foo() + foo(); + baz += foo() + foo() + "foo"; +} + diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb133a.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb133a.C new file mode 100644 index 000000000..eb6c72d20 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb133a.C @@ -0,0 +1,16 @@ +// { dg-do assemble } +// Gives ICE 109 +// From: Klaus-Georg Adams <Klaus-Georg.Adams@chemie.uni-karlsruhe.de> +// Reported against EGCS snaps 98/06/28. + +int main() +{ + try { + } + catch (std::bad_alloc) { // { dg-error "" } parse error + return 1; + } + return 0; +} + + diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb133b.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb133b.C new file mode 100644 index 000000000..544544b71 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb133b.C @@ -0,0 +1,16 @@ +// { dg-do assemble } +// Gives ICE 109 +// From: Klaus-Georg Adams <Klaus-Georg.Adams@chemie.uni-karlsruhe.de> +// Reported against EGCS snaps 98/06/28. + +using namespace std; // { dg-error "" "" { xfail *-*-* } } + +int main() +{ + try { + } + catch (bad_alloc) { // { dg-error "" } + return 1; + } + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb133c.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb133c.C new file mode 100644 index 000000000..86acdc6bf --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb133c.C @@ -0,0 +1,17 @@ +// { dg-do assemble } +// Gives ICE 109 +// From: Klaus-Georg Adams <Klaus-Georg.Adams@chemie.uni-karlsruhe.de> +// Reported against EGCS snaps 98/06/28. + +namespace std { } +using namespace std; + +int main() +{ + try { + } + catch (bad_alloc) { // { dg-error "" } + return 1; + } + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb14.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb14.C new file mode 100644 index 000000000..0218a7eaa --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb14.C @@ -0,0 +1,40 @@ +// { dg-do run } + +extern "C" void abort (); + +template<int N> +struct I { +}; + +template<class T> +struct A { + + int r; + + template<class T1, class T2> + void operator()(T1, T2) + { r = 0; } + + template<int N1, int N2> + void operator()(I<N1>, I<N2>) + { r = 1; } +}; + +int main() +{ + A<float> x; + I<0> a; + I<1> b; + + x(a,b); + if (x.r != 1) + abort(); + + x(float(), double()); + if (x.r != 0) + abort(); + + return 0; +} + + diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb15.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb15.C new file mode 100644 index 000000000..1cb9fd15c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb15.C @@ -0,0 +1,28 @@ +// { dg-do assemble } +#include<iostream> +#include<cstddef> + +struct A { + A() { + std::cerr<<"A constructing\n"; + throw 1; + } + void *operator new(size_t sz) { + std::cerr<<"A allocated\n"; + return ::operator new(sz); + } + void operator delete (void *p) { + std::cerr<<"A deleted\n"; + ::operator delete (p); + } +}; + +int main() { + try { + new A(); + } catch (...) { + } +} + + + diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb16.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb16.C new file mode 100644 index 000000000..533b13449 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb16.C @@ -0,0 +1,14 @@ +// { dg-do assemble } +template<class T> +struct A { + typedef T T1; +}; + +template<class T> +struct B : T::T1 { // insert `typename' before T::T1 +}; + +struct C { }; + +B<A<C> > z; + diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb17.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb17.C new file mode 100644 index 000000000..4163399fb --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb17.C @@ -0,0 +1,59 @@ +// { dg-do run } +#include <stdio.h> + +class A { +public: + virtual void print(); + virtual A * clone(); +}; + +struct Pad { + virtual void f () {} +}; + +class B : public Pad, virtual public A { +public: + void print(); + B * clone(); +}; + +void A::print() +{ + printf("A\n"); +} + +void B::print() +{ + printf("B\n"); +} + + +A * A::clone() +{ + return this; +} + +B * B::clone() +{ + return this; +} + + +int main() +{ + A * a = new B; + B * b = dynamic_cast<B *>(a); + + printf("%p\n",b); // (*2*) + b->print(); + + a = b; + printf("%p\n",a); + a->print(); + + a = a->clone(); + printf("%p\n",a); + a->print(); // (*1*) + + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb18.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb18.C new file mode 100644 index 000000000..8f0a82937 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb18.C @@ -0,0 +1,8 @@ +// { dg-do assemble } +class C { }; + +void foo() +{ + C c; + void * v = static_cast<void *>(c); // { dg-error "" } illegal cast +} diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb19.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb19.C new file mode 100644 index 000000000..60f4aa1d6 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb19.C @@ -0,0 +1,16 @@ +// { dg-do assemble } + +#define CRASH 1 +#ifdef CRASH +#define VIRTUAL virtual +#else +#define VIRTUAL +#endif + +class A {}; +class B : public VIRTUAL A {}; +template <class Imp> class C : public /*virtual*/ Imp {}; +// define CRASH and uncomment here ^^^^^^^^^^^ +// and the crash goes away!!!! + +template class C<B>; diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb2.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb2.C new file mode 100644 index 000000000..e40afbec2 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb2.C @@ -0,0 +1,17 @@ +// { dg-do assemble } +typedef __SIZE_TYPE__ size_t; +inline void *operator new(size_t, void *place) throw() { return place; } + +struct A +{ + A(); + ~A(); +}; + +void testfunc( void ) +{ + A* mybuf; + A v[1]; + + new (mybuf) A(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb20.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb20.C new file mode 100644 index 000000000..c15d4afcb --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb20.C @@ -0,0 +1,33 @@ +// { dg-do assemble } +// Error: ICE on 2.7.2.3 and EGCS 1.0.0. + +template<int N1, int N2> +struct meta_max { + enum { max = (N1 > N2) ? N1 : N2 }; +}; + +struct X { + enum { + a = 0, + n = 0 + }; +}; + +template<class T1, class T2, class T3> +struct Y { + + enum { + a = T1::a + T2::a + T3::a, + n = meta_max<meta_max<T1::n,T2::n>::max, T3::n>::max + }; +}; + +template<class T> +struct Z { + enum { + a = T::a, + n = T::n + }; +}; + +Z<Y<X,X,X> > z; diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb21.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb21.C new file mode 100644 index 000000000..a061fc016 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb21.C @@ -0,0 +1,25 @@ +// { dg-do run } +#include <vector> + +#include <sstream> + +using namespace std; + +/*----------------------------------------*/ + +struct connection_t { + connection_t() {} +}; + +std::vector<connection_t> connections; + +/*----------------------------------------*/ + +int +main() { + ostringstream str; + + connections.insert(connections.end(), connection_t()); + + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb22.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb22.C new file mode 100644 index 000000000..a78ea4108 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb22.C @@ -0,0 +1,29 @@ +// { dg-do assemble } +// Ambiguous conversion, three candidates: +// builtin == (int, int), and the two user-defined operators +// Each one requires a user-defined ICS where another uses builtin conversions, +// so none is the best viable function. + +class MyInt +{ +public: + MyInt(int = 0) {} + operator int() const {return 2;} +}; + +bool operator==(const MyInt& a, const int& b) // { dg-message "operator==" } candidate +{ + return (int)a == b; +} + +bool operator==(const MyInt& a, const MyInt& b) // { dg-message "operator==" } candidate +{ + return (int)a == (int)b; +} + +bool f() +{ + return 3 == MyInt(); // { dg-error "ambiguous" "err" } + // { dg-message "operator==" "match candidate text" { target *-*-* } 26 } + // { dg-message "candidates" "note" { target *-*-* } 26 } +} diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb23.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb23.C new file mode 100644 index 000000000..920f4587b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb23.C @@ -0,0 +1,20 @@ +// { dg-do assemble } +class foo { +protected: + void __duplicate (); + +}; + +class bar : public virtual foo { +protected: + void __duplicate() { + foo::__duplicate (); + } +}; + +class oops : public virtual bar { +protected: + void __duplicate() { + foo::__duplicate (); + } +}; diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb24.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb24.C new file mode 100644 index 000000000..5e2a3ee45 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb24.C @@ -0,0 +1,23 @@ +// { dg-do assemble } +#include <iostream> + +template < class T > +class X +{ + protected: + + union { + int x; + double y; + }; +}; + +template < class T > +class Y : public X<T> +{ + public: + + using X<T>::x; + + void f () { std::cout << this->x << std::endl; } +}; diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb26.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb26.C new file mode 100644 index 000000000..b43f21a7f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb26.C @@ -0,0 +1,31 @@ +// { dg-do run } +// +// egcs-2.90.06 +// cannot declare friend of enclosing class using its scope, works fine +// without scope or for definition of foo::bar::f +// + +class foo +{ +public: + static int f(); + class bar { + friend int foo::f(); +// friend int f(); + static int x; + public: + static int f() {return foo::f();} + }; +}; + +int foo::bar::x; + +int foo::f() { + return bar::x; +} + +int +main () +{ + return foo::bar::f (); +} diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb27.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb27.C new file mode 100644 index 000000000..204a143d6 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb27.C @@ -0,0 +1,42 @@ +// { dg-do assemble } +// { dg-options "-Wno-deprecated" } +/* bug.cc */ +/* simple program to demonstrate the bug with named return values in gcc +*/ +/* (w) 4.9.97 by Kurt Garloff <K.Garloff@ping.de> */ +// 8/28/1998 - This dies in add_conversions from dfs_walk, null CLASSTYPE_METHOD_VEC +// for the test<T> record_type. This is marked as an expected failure for now, +// until we actually fix it. + +#include <iostream> + +template <class T> class test; +template <class T> test<T> operator + (const test<T>& a, const test<T>& b); + +// A simple numerical class +template <class T> +class test +{ + T elem; + public: + test () { elem = 0; }; + 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 std::ostream& operator << (std::ostream& os, const test<T>& a) + { return os << a.elem; }; +}; + +// named return value version +template <class T> +test<T> operator + (const test<T>& a, const test<T>& b) return c(a);// { dg-error "" } named return value +{ c += b; } // { dg-error "" } c undeclared + +int main() +{ + test<int> x, y; + 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/eb28.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb28.C new file mode 100644 index 000000000..89f19d57c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb28.C @@ -0,0 +1,20 @@ +// { dg-do assemble } +#include <vector> + +using namespace std; + +enum s { S }; +class a +{ + vector<s> vs; + friend class b; +}; +struct b +{ + vector<a> va; + operator vector< vector<s> >() + { + vector< vector<s> > vvs(va.size()); + return vvs; + } +}; diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb29.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb29.C new file mode 100644 index 000000000..bea0d12e1 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb29.C @@ -0,0 +1,19 @@ +// { dg-do assemble } +#include <vector> + +using namespace std; + +enum s { S }; +class a +{ + vector<s> vs; + friend class b; +}; +struct b +{ + vector<a> va; + operator vector< vector<s> >() + { + return vector< vector<s> >(va.size()); + } +}; diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb3.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb3.C new file mode 100644 index 000000000..b7487e97b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb3.C @@ -0,0 +1,11 @@ +// { dg-do assemble } +#include <complex> +template<class T> +class Vec { +public: + Vec() { data = new T; } + Vec<T> split() { Vec<T> tmp; operator=(tmp); return tmp; } + void operator=(const Vec<T> &v) { data = new T; } + T *data; +}; +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 new file mode 100644 index 000000000..e0f290b7f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb30.C @@ -0,0 +1,16 @@ +// { dg-do assemble } +#include <fstream> + +class bifstream : public std::ifstream { +public: + bifstream(); +// ~bifstream(); +}; + +void load_bin() +{ + bifstream InFile; + + 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 new file mode 100644 index 000000000..1e3c8f02d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb31.C @@ -0,0 +1,20 @@ +// { dg-do run } +#include<iostream> + +int main() { + try { + throw 1; + } catch(...) { + try { + throw; + } catch(int) { + } + try { + throw; + } catch(int) { + } + } + return 0; +} + + diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb32.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb32.C new file mode 100644 index 000000000..a70c8f970 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb32.C @@ -0,0 +1,12 @@ +// { dg-do assemble } +class A { +public: + void malloc(unsigned int); +}; + +void A::malloc(unsigned int) {} + +void foo() { + A a; + a.malloc(3); // <-- line 10 +} diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb33.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb33.C new file mode 100644 index 000000000..50328ad49 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb33.C @@ -0,0 +1,12 @@ +// { dg-do run } +#include <fstream> +#include <cstdio> + +int +main() +{ + std::printf("If you see this, you don't have a problem!\n"); +#ifdef EXPOSE_BUG + std::ifstream a; +#endif +} diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb34.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb34.C new file mode 100644 index 000000000..0d9b474d9 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb34.C @@ -0,0 +1,19 @@ +// { dg-do assemble } +class Base { +public: + class Bar { public: virtual ~Bar() {} }; +}; + +class Derived : public Base { +public: + class Bar : public Base::Bar {}; +}; + +template <class T> +class XYZ : public T::Bar { +}; + +void test() { + XYZ<Base> b; + XYZ<Derived> d; +} diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb35.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb35.C new file mode 100644 index 000000000..6546d7c42 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb35.C @@ -0,0 +1,38 @@ +// { dg-do assemble } + +class string +{ +public: + string(); + string(const string& x); + string(const char* t); + + ~string(); +}; + +void set_status(string message); + +class StatusDelay { +private: + string cause; + +public: + StatusDelay(const string& c) + : cause(c) + { + set_status(cause); + } + + ~StatusDelay() + { + set_status(cause); + } +}; + +static char delay_message[] = "Filtering files"; + +static void searchRemote() +{ + StatusDelay delay(delay_message); + return; +} diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb36.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb36.C new file mode 100644 index 000000000..56e67b300 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb36.C @@ -0,0 +1,19 @@ +// { dg-do assemble } +#include <vector> +using namespace std; + +template <typename T=float> class foo { +public: + foo(); + foo(vector<int> v); +private: + vector<int> v; + T t; +}; + +template <typename T> +foo<T>::foo() :v(), t() {} +template <typename T=float> +foo<T>::foo(vector<int> v_) :v(v_), t() {} // { dg-error "" } default arg for member template + +foo<float> a; diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb37.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb37.C new file mode 100644 index 000000000..185b632f8 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb37.C @@ -0,0 +1,26 @@ +// { dg-do assemble } +template<class T> +struct A { + typedef T T1; +}; + +template<class T> +struct B { + typedef T T2; +}; + +template<class T> +struct C { +}; + +template<class E> +C<typename E::T2::T1> +foo (E) +{ + return C<typename E::T2::T1>(); +} + +void test() +{ + foo(B<A<int> >()); +} diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb38.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb38.C new file mode 100644 index 000000000..e4bcf32b6 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb38.C @@ -0,0 +1,37 @@ +// { dg-do assemble } +class string +{ +public: + string(); + string(const string& x); + string(const char* t); + + ~string(); +}; + +void set_status(string message); + +class StatusDelay { +private: + string cause; + +public: + StatusDelay(const string& c) + : cause(c) + { + set_status(cause); + } + + ~StatusDelay() + { + set_status(cause); + } +}; + +static char delay_message[] = "Filtering files"; + +static void searchRemote() +{ + StatusDelay delay(delay_message); + return; +} diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb39.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb39.C new file mode 100644 index 000000000..144d3fff7 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb39.C @@ -0,0 +1,18 @@ +// { dg-do assemble } +#include <cctype> +#include <iostream> +#include <sstream> +#include <cstring> + +using namespace std; + +extern bool foo2 (ostream &out, istream &in); + +bool +foo1 (ostream &out, const char *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 new file mode 100644 index 000000000..dfd3d6ced --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb4.C @@ -0,0 +1,50 @@ +// { dg-do assemble } +// Error: Internal Compiler Error in GCC 2.7.2 and EGCS 1998/05/28 snapshot. + +#include <iostream> + +class some_base + { +public: + class base_func_args; + virtual void func(base_func_args &) = 0; // { dg-message "note" } referenced below + }; + +class some_base::base_func_args + { +public: + int i; + }; + +class some_derived : public some_base // { dg-message "note" } + { +public: + class derived_func_args; + void func(derived_func_args &); + }; + + +class derived_func_args : public some_base::base_func_args + { +public: + float f; + }; + +class some_derived::func(derived_func_args &a) // { dg-error "does not name a type" "type" } illegal member syntax +// { dg-error "expected" "exp" { target *-*-* } 33 } + { + std::cout << a.i << ' ' << a.f << std::endl; + } + +int +main() + { + some_derived d; // { dg-error "abstract type" } + some_derived::derived_func_args dfa; // { dg-error "incomplete type" } + some_base *b = &d; + + dfa.i = 10; + dfa.f = 20; + b->func(dfs); // { dg-error "'dfs' was not declared" } + return 0; + } diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb41.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb41.C new file mode 100644 index 000000000..9f6ee5f43 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb41.C @@ -0,0 +1,14 @@ +// { dg-do run } +#include <iostream> +#include <iterator> +#include <string> + +std::ostream_iterator<std::string> oo(std::cout); + +int main() +{ + *oo = "Hello, "; + ++oo; + *oo = "world!\n"; +} + diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb43.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb43.C new file mode 100644 index 000000000..1dc43284c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb43.C @@ -0,0 +1,44 @@ +// { dg-do assemble } +// All the pointer_to_binary_function cases used to fail because g++ +// couldn't handle converting an overloaded function to a class type. +// The first one should still fail because it requires an implicit conversion +// to pointer_to_binary_function, which has an `explicit' constructor. + +// { dg-prune-output "note" } + +#include <vector> +#include <algorithm> +#include <functional> + +using namespace std; + +template <class T> class Expr +{ +public : + Expr(){} + Expr(const T&){} +}; + +template <class T > +inline bool compare(const Expr<T> a, const Expr<T> b){ return true; } + +int main() +{ + vector<int> a(3); + sort( a.begin(), a.end(), + static_cast<bool (*)(const Expr<int>,const Expr<int>)>(compare) ); + sort( a.begin(), a.end(), compare<int> ); + sort<vector<int>::iterator, + pointer_to_binary_function<const Expr<int>, const Expr<int>, bool> > + ( a.begin(), a.end(), compare ); // { dg-error "" } constructor is explicit + sort( a.begin(), a.end(), + ptr_fun<const Expr<int>, const Expr<int>, bool> (compare) ); + sort( a.begin(), a.end(), + ptr_fun(compare<int>) ); + sort( a.begin(), a.end(), + pointer_to_binary_function<const Expr<int>, const Expr<int>, bool>(compare) ); + sort( a.begin(), a.end(), + pointer_to_binary_function<const Expr<int>, const Expr<int>, bool>(compare<int>) ); + sort( a.begin(), a.end(), + pointer_to_binary_function<const Expr<int>, const Expr<int>, bool>(compare<>) ); +} diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb44.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb44.C new file mode 100644 index 000000000..a7e61804c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb44.C @@ -0,0 +1,39 @@ +// { dg-do assemble } +// spurious 'const' in error. +// For egcs-2.91.34, the warning message refers to +// class ostream & operator <<(class ostream &, const class Vector<T> &) +// Also, the template instantiation does not provide the missing +// friend function, the non-template function does + +#include <cstdio> +#include <cstdlib> +#include <iostream> + +using namespace std; + +template <class T> +class Vector +{ + friend ostream& operator<< (ostream& out, const Vector<T> & vec); // { dg-warning "non-template" "warn" } + // { dg-message "note" "note" { target *-*-* } 17 } +}; + +template <class T> +ostream& operator<< (ostream& out, const Vector<T> & vec) +{ + abort(); // this should not be called +} + +template class Vector<char>; +template ostream& operator<< (ostream& out, const Vector<char> &); + +ostream& operator<< (ostream& out, const Vector<char>&) +{ + return out; +} + +int main() +{ + Vector<char> vc; + cout << vc; +} diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb45.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb45.C new file mode 100644 index 000000000..d6c0a40f6 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb45.C @@ -0,0 +1,6 @@ +// { dg-do assemble } +class A {}; +class B : public virtual A {}; +template <class Imp> class C : public Imp {}; + +template class C<B>; diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb46.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb46.C new file mode 100644 index 000000000..cbe482e90 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb46.C @@ -0,0 +1,31 @@ +// { dg-do run } +#include <iostream> + +class A1 { + friend class B; + public: + virtual void foo() {} +}; + +class A2 : public virtual A1 {friend class B;}; + +class A3 : public virtual A1, private A2 {friend class B;}; + +class B +{ + public: + B(A1* a) : itsA(dynamic_cast<A2*>(a)) {} + A2* itsA; +}; + +int main() +{ + A1* a=new A3; + B b(a); + + 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/eb48.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb48.C new file mode 100644 index 000000000..3b98a3504 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb48.C @@ -0,0 +1,10 @@ +// { dg-do assemble } +char *t1 (const char *s) +{ + return const_cast<char *>(s); +} + +char *&t1 (const char *&s) +{ + return const_cast<char *&>(s); +} diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb49.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb49.C new file mode 100644 index 000000000..c1d70a035 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb49.C @@ -0,0 +1,48 @@ +// { dg-do assemble } + +// Here we declare ::S +typedef struct s1 *S; + +struct s1 +{ + int s; +}; + +struct A +{ + // Here we declare A::S + typedef struct s1 *S; +}; + +template<class T, class U> class XX; + +template<class T, class U> +class X +{ +public: + static T *do_something (); + friend class T; // { dg-error "" } `T' is a template parameter + friend class XX<T, U>; +}; + +struct N +{ + // Here we declare N::S + class S + { + }; + + // Should use N::S and A::S. + typedef X<S, A::S> X_S; + + void bug (); +}; + +void +N::bug () +{ + // X_S is template class X<N::S, A::S> + // `s' is N::S. + S *s = X_S::do_something (); +} + diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb5.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb5.C new file mode 100644 index 000000000..06e31b611 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb5.C @@ -0,0 +1,13 @@ +// { dg-do assemble } +enum { a, b }; + +class Bug { + int pri:8; + int flags:15; +public: + void bug() { + flags |= a; // this does not work + } +}; + +void dummy(Bug x) { x.bug(); } diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb50.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb50.C new file mode 100644 index 000000000..8d2c4033f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb50.C @@ -0,0 +1,17 @@ +// { dg-do run } +struct foo { }; +int f(int a, int b) +{ + if (b == 0) + throw foo(); + return a / b; +} +int main() +{ + try { + f(0, 0); + return 1; + } catch (foo x) { + return 0; + } +} diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb51.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb51.C new file mode 100644 index 000000000..3f421b019 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb51.C @@ -0,0 +1,36 @@ +// { dg-do assemble } +typedef unsigned long Xv_opaque; + +class DynaString +{ +public: + DynaString(); + DynaString( const DynaString& dynaStr ); + DynaString( const long n ); + ~DynaString(); + + int operator ==( const char* const string ) const; +}; + +class DDE_Defaults +{ +public: + DynaString GetHost(); + DynaString GetService(); + DynaString GetDatabase(); +}; + +extern DDE_Defaults* ddeDefaults; + +void +f() +{ + DynaString tempHost, tempService, tempDatabase; + if( (tempHost = ddeDefaults->GetHost()) == 0 + || (tempService = ddeDefaults->GetService()) == 0 + || (tempDatabase = ddeDefaults->GetDatabase()) == 0 + ) + { + } +} + diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb52.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb52.C new file mode 100644 index 000000000..4607c1c23 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb52.C @@ -0,0 +1,37 @@ +// { dg-do assemble } +class base { +protected: + virtual void f(); +}; + +class d1 : public virtual base { +protected: + void f(); +}; + +void d1::f() +{ + base::f(); +} + +class dd1 : public virtual d1 { +protected: + void f(); +}; + +void dd1::f() +{ + d1::f(); + base::f(); +} + +class d1_and_base : public virtual d1, public virtual base { +protected: + void f(); +}; + +void d1_and_base::f() +{ + d1::f(); + base::f(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb54.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb54.C new file mode 100644 index 000000000..1e71ca82e --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb54.C @@ -0,0 +1,10 @@ +// { dg-do run } +#include <iomanip> +#include <iostream> +#include <cstdlib> + +int main() +{ + 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 new file mode 100644 index 000000000..c1e2400ed --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb55.C @@ -0,0 +1,12 @@ +// { dg-do assemble } +// Since the constructor is in streambuf.h, additional diagnostics are +// produced, which are not really supported in the old-deja framework + +#include <sstream> + +void +t( char* buf ) +{ + std::istrstream str = buf; //{ dg-error "" } inaccessible copy constructor +} + diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb56.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb56.C new file mode 100644 index 000000000..90932de46 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb56.C @@ -0,0 +1,10 @@ +// { dg-do assemble } +// Error: Internal compiler error on 1998/05/28 snapshot. + +class foo { + public: + typedef int sometype; +}; + +struct die : public foo::sometype { // { dg-error "" } invalid base type +}; diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb57.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb57.C new file mode 100644 index 000000000..b7879fa7f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb57.C @@ -0,0 +1,7 @@ +// { dg-do assemble } +#include <exception> +//using namespace std; +class A { + class B : public std::exception {} + ; +}; diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb58.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb58.C new file mode 100644 index 000000000..04ec92a30 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb58.C @@ -0,0 +1,15 @@ +// { dg-do run } +// { dg-options "-w -fpermissive" } +// Test for g++ array init extension + +class A { +public: + A(int i) {} +private: + A( const A & ) {} +}; + +main() +{ + A *list = new A[10](4); +} diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb59.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb59.C new file mode 100644 index 000000000..84ccff26d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb59.C @@ -0,0 +1,31 @@ +// { dg-do run } +#define INC_FUNCTIONAL 1 +#define USE_STATIC_CAST 1 + +#include <vector> +#include <numeric> +#ifdef INC_FUNCTIONAL +#include <functional> +#endif + +using namespace std; + +template<class R> int p( int val, R& r ) +{ + return val + r; +} + +template<class R> void f( vector<R>& v ) +{ +#ifdef USE_STATIC_CAST + accumulate( v.begin(), v.end(), 0, static_cast<int (*)(int, R&)>(p) ); +#else + accumulate( v.begin(), v.end(), 0, p<R> ); +#endif +} + +int main() +{ + vector<int> r; + f( r ); +} diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb6.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb6.C new file mode 100644 index 000000000..6fddb8557 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb6.C @@ -0,0 +1,14 @@ +// { dg-do assemble } +class A { +public: + A() { t=0; } + double t; +}; +template <class T> +class B { +public: + void f1() { new T; f2(); } + void f2() { new T; } +}; +template class B<A>; + diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb60.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb60.C new file mode 100644 index 000000000..ea80a4ce2 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb60.C @@ -0,0 +1,18 @@ +// { dg-do assemble } +#include <string> + +class t { +public: + t(const std::string& s) : s_(s) {} + std::string s_; + static t* t_; +}; + +t* t::t_; + +t* makeT() +{ + return new t("test"); + return t::t_ ? t::t_ : + t::t_ = new t("test"); +} diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb61.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb61.C new file mode 100644 index 000000000..68344a6bf --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb61.C @@ -0,0 +1,8 @@ +// { dg-do assemble } +void +action0(float& arg1) +{ + long cn0 = 1; + + arg1 = cn0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb62.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb62.C new file mode 100644 index 000000000..bffba0480 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb62.C @@ -0,0 +1,7 @@ +// { dg-do assemble } +#include <vector> + +void f(void) +{ + std::vector<int> l(5, 0); +} diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb63.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb63.C new file mode 100644 index 000000000..a49fb0264 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb63.C @@ -0,0 +1,17 @@ +// { dg-do run } +// { dg-options "-w -fpermissive" } +//This uses GNU extensions, so disable -ansi +#include <stdio.h> +#include <stdlib.h> + +class A { +public: + A(bool b) { abort(); } + A(int a, bool b) { printf("cool\n"); } +}; + +main() { + A* a; + + a = new A[2](1,false); +} diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb64.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb64.C new file mode 100644 index 000000000..16f52e0de --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb64.C @@ -0,0 +1,25 @@ +// { dg-do assemble } +template <class A> +class B:public A { + B(){} +}; + +template <class A> +class C:public B<A> { + C(){} +}; + +/* +g++ bugsol.C +bugsol.C:9: Internal compiler error. +bugsol.C:9: Please submit a full bug report to `egcs-bugs@cygnus.com'. + +g++ -v +Reading specs from +/home/pierre/local/lib/gcc-lib/i586-pc-linux-gnulibc1/egcs-2.90.16/specs +gcc version egcs-2.90.16 971105 (gcc2-970802 experimental) + +egcc compiled with gcc version 2.7.2.1 on debian 1.3.1 + +*/ + diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb65.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb65.C new file mode 100644 index 000000000..b7b535d5a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb65.C @@ -0,0 +1,25 @@ +// { dg-do run } +#include <iterator> + +using namespace std; + +template<size_t n, size_t i> struct PartialDotProduct { + template<class T> + static T Expand(T* a, T* b) { return T(); } +}; + +const int N = 10; + +template<class In1, class In2> +typename iterator_traits<In1>::value_type +dot(In1 f1, In2 f2) +{ + return PartialDotProduct<N, 0>::Expand(f1, f2); // line 14 +} + +int main() +{ + double a[N], b[N]; + + double s = dot(&a[0], &b[0]); +} diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb66.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb66.C new file mode 100644 index 000000000..308859365 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb66.C @@ -0,0 +1,27 @@ +// { dg-do run } +#include <cassert> +#include <iostream> + +int bar () +{ + throw 100; +} + +int main () +{ + int i = 0; + try + { + i = bar (); + } + catch (...) + { + } + +// std::cout << "i = " << i << std::endl; + assert (i == 0) ; +} + + + + diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb67.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb67.C new file mode 100644 index 000000000..bebe99598 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb67.C @@ -0,0 +1,6 @@ +// { dg-do assemble } +/* +Check whether a typedef for a basic type as a baseclass is diagnosed. +*/ +typedef int an_int; +class bar : public an_int {}; // { dg-error "" } not an aggregate diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb69.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb69.C new file mode 100644 index 000000000..1ada91234 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb69.C @@ -0,0 +1,23 @@ +// { dg-do assemble } +// Test that g++ complains about referring to a builtin type in a +// mem-initializer. +// Contributed by Kevin Buhr <buhr@stat.wisc.edu> + +int r = 0; + +struct foo { // { dg-message "note" } candidate + foo(int x) { r = 1; } // { dg-message "note" } +}; + +struct bar : foo { + typedef int an_int; + bar() : bar::an_int(3) {} // { dg-error "match" "match" } not a base + // { dg-message "candidate" "candidate note" { target *-*-* } 14 } + // { dg-message "expected" "exp" { target *-*-* } 14 } +}; + +int +main() { + bar b; + return r; +} diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb7.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb7.C new file mode 100644 index 000000000..4785305ff --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb7.C @@ -0,0 +1,16 @@ +// { dg-do assemble } +#include <vector> + +class T +{ + public: + T(); + +}; + +std::vector <T> tp; + +void f() +{ + tp.insert(tp.begin(), 10 , T()); +} diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb70.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb70.C new file mode 100644 index 000000000..b17dc10dc --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb70.C @@ -0,0 +1,17 @@ +// { dg-do assemble } +// conversion ops should be treated as coming from the most derived class +// for overload resolution. See [over.match.funcs]. + +class X { +public: + operator bool() const; +}; + +class Y : public X { +private: + operator void*() const; +}; + +int f(Y const& y) { + return bool(y); +} diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb71.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb71.C new file mode 100644 index 000000000..b1288e238 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb71.C @@ -0,0 +1,37 @@ +// { dg-do assemble } +typedef __SIZE_TYPE__ size_t; + +class A { + +public: + void operator delete(void*, size_t); + void* operator new(size_t); +}; + +class B : public A { +friend class D; + + B(); + unsigned counter; +}; + +class D { + + int ins( B*&); +}; + +int +D::ins( B*& tempN) +{ + unsigned i; + + if (i == 10) { + } + else { + } + + tempN = new B(); + tempN->counter = 20; + + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb73.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb73.C new file mode 100644 index 000000000..bf9cf598d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb73.C @@ -0,0 +1,15 @@ +// { dg-do run } +// { dg-options "-O -Wall" } +// Depletes VM. + +#include <iostream> +#include <list> +#include <algorithm> +using namespace std; + +int main() +{ + int daten [16] = { 1, 4, 4, 6, 1, 2, 2, 3, 6, 6, 6, 5, 7, 5, 4, 4}; + list<int> menge; + copy (daten, daten+16, back_inserter(menge)); +} diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb74.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb74.C new file mode 100644 index 000000000..5fb821119 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb74.C @@ -0,0 +1,33 @@ +// { dg-do assemble } +class base { +public: + virtual ~base(); +}; + + +class foo : public base { + +public : + + foo (char *cs); + + virtual void op (unsigned char dummy = false); + unsigned char m_dummy; +}; + + +void foo :: op ( unsigned char dummy) + +{ + bool bar; + + if (dummy) { + foo IT_tempPhase( 0 ); + return; + } + + if ((m_dummy || bar)) { + + } + +} diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb75.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb75.C new file mode 100644 index 000000000..c032c2a78 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb75.C @@ -0,0 +1,19 @@ +// { dg-do assemble } +int*& foo (int const *& x) +{ + return const_cast<int*&> (x); +} + +/* +If the references in this example are changed to pointers (change +all `&''s to `*'), no warnings result. + +I think this is incorrect according to CD2 5.2.11, para 4: + +4 An lvalue of type T1 can be explicitly converted to an lvalue of type + T2 using the cast const_cast<T2&> (where T1 and T2 are object types) + if a pointer to T1 can be explicitly converted to the type pointer to + T2 using a const_cast. The result of a reference const_cast refers to + the original object. + +*/ diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb76.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb76.C new file mode 100644 index 000000000..c74e7bd81 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb76.C @@ -0,0 +1,18 @@ +// { dg-do assemble } +// the template operator!= interferes. It should be in a namespace. + +#include <utility> + +enum T { + V1 +}; + +struct X { + T t : 31; +}; + +void +f(X& v) { + if( v.t != V1 ) { // complains about taking address of bitfield + } +} diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb77.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb77.C new file mode 100644 index 000000000..358c186ab --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb77.C @@ -0,0 +1,33 @@ +// { dg-do run } +#include <iostream> +#include <sstream> + +using namespace std; + +int +main(int, char* []) +{ + stringstream s; + + s << "line 1\nline 2\n\nline 4"; + s << std::ends; + + int nLine = 0; + + while( true ) { + char line[100]; + s.get(line, 100); + + if( ! line ) { + break; + } + + ++nLine; + std::cout << nLine << ": " << line << std::endl; + + if( nLine > 10 ) { // stop infinite loop + break; + } + } + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb79.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb79.C new file mode 100644 index 000000000..1c1ad3e30 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb79.C @@ -0,0 +1,33 @@ +// { dg-do assemble } +// { dg-prune-output "note" } +// Makes bogus x86 assembly code. +#include <iostream> + +// The VxWorks kernel-mode headers define a macro named "max", which is not +// ISO-compliant, but is part of the VxWorks API. +#if defined __vxworks && !defined __RTP__ +#undef max +#endif + +using namespace std; + +template<class T> +T max(T a, T b) +{ + return (a > b) ? a : b; +} + +// Prototypes (enable one or the other) +double max<>(double, double); // { dg-error "" } bogus code +// int max(int, int); + +int main() +{ + int i = 123; + double d = 1234.5678; + + cout.precision(12); + cout << max(d, i) << endl; // { dg-error "" } + cout << max(i, d) << endl; // { dg-error "" } + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb8.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb8.C new file mode 100644 index 000000000..c66005062 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb8.C @@ -0,0 +1,14 @@ +// { dg-do assemble } + +class foo { +public: + operator <<(const void *); //{ dg-error "" } no return type + operator <<(char *); //{ dg-error "" } no return type +}; + +void main() // { dg-error "must return .int" } +{ + foo f; + f << (void*)0; +} + diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb80.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb80.C new file mode 100644 index 000000000..e30f7ef2c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb80.C @@ -0,0 +1,7 @@ +// { dg-do assemble } +#include <exception> + +class A { + class B : public std::exception {} + ; +}; diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb81.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb81.C new file mode 100644 index 000000000..1f05c602c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb81.C @@ -0,0 +1,42 @@ +// { dg-do assemble } +class x +{ +public: + x (int init_buffer_size=0); + ~x (); +}; + + + +class xSequence +{ +public: + xSequence (); + ~xSequence (); + x Get(int index)const; +}; + + + +class foo +{ +public: + bool bar(const x & name, x & value); + +}; + + + +bool foo::bar(const x & name, x & value) +{ + bool result = false; + + xSequence seq; + x v1, v2; + if(result ? bar(seq.Get(1),v2) : bar(seq.Get(2),v2)) + + ; + + return result; +} + diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb82.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb82.C new file mode 100644 index 000000000..9bf0398cd --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb82.C @@ -0,0 +1,13 @@ +// { dg-do assemble } +#include <stdio.h> + +template <int n1> +double val <int> () // { dg-error "" } bogus code +{ + return (double) n1; +} + +int main () +{ + printf ("%d\n", val<(int)3> ()); // { dg-error "" } val undeclared +} diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb83.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb83.C new file mode 100644 index 000000000..ecdb6bed7 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb83.C @@ -0,0 +1,18 @@ +// { dg-do run { target native } } +// { dg-options "-fprofile-arcs -ftest-coverage" } +void +test_swap(int& x, int& y) throw() +{ + int tmp = x; + x = y; + y = tmp; +} + +main() +{ + int i = 5; + int j = 7; + test_swap(i, j); +} + +/* { dg-final { cleanup-coverage-files } } */ diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb84.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb84.C new file mode 100644 index 000000000..0d09059b3 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb84.C @@ -0,0 +1,18 @@ +// { dg-do run } +// Error: Internal Compiler error on GCC 2.7.2.3 & EGCS 1998/05/23 snapshot. + +class A { +public: + enum { ONE, TWO, THREE }; +}; + +template <const unsigned c1,const unsigned c2,const unsigned c3> +void f() { + +} + +int +main() +{ + f<A::ONE,A::TWO,A::THREE>(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb86.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb86.C new file mode 100644 index 000000000..d854afe16 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb86.C @@ -0,0 +1,7 @@ +// { dg-do assemble } +template <class T> void foo (); + +template <class T> +class Q { + friend void foo<T> (); +}; diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb87.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb87.C new file mode 100644 index 000000000..7d288bc2f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb87.C @@ -0,0 +1,7 @@ +// { dg-do assemble } +template <unsigned X, class T> struct Foo { + friend void operator<<(int, Foo const &) {} +}; +template <unsigned X> class Bar : public Foo<X,int> {}; +inline Bar<0> bar(int,int,int) { return Bar<3>(); } // { dg-error "" } no conversion + diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb88.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb88.C new file mode 100644 index 000000000..cb604bc80 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb88.C @@ -0,0 +1,16 @@ +// { dg-do run } +// { dg-options "-w" } +// Another magic NULL problem. + +#include <stddef.h> + +int main() +{ + try + { + throw(NULL); + } + catch (...) + { + } +} diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb9.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb9.C new file mode 100644 index 000000000..a64380d98 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb9.C @@ -0,0 +1,22 @@ +// { dg-do assemble } +template <class Key> +class d0om_Hashmap +{ +public: + typedef int value_type; + + class iterator + { + public: + value_type* operator-> () const; + }; + +}; + + +template <class Key> +typename d0om_Hashmap<Key>::value_type* +d0om_Hashmap<Key>::iterator::operator-> () const +{ + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb90.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb90.C new file mode 100644 index 000000000..062324112 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb90.C @@ -0,0 +1,22 @@ +// { dg-do assemble } +// { dg-options "-O2" } + +#ifdef HIDE_BUG +#define realloc Realloc +#endif + +class TmpRgn { +public: + void + realloc(); +}; + +class TmpActor { + TmpRgn tmpRgn; + +public: + void + realloc() { + tmpRgn.realloc(); + } +}; diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb91.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb91.C new file mode 100644 index 000000000..abfe9face --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb91.C @@ -0,0 +1,86 @@ +// { dg-do run } +#include <sys/types.h> +#include <algorithm> +typedef short _eb91_int16_t; +typedef char _eb91_int8_t; +typedef unsigned char _eb91_u_int8_t; +typedef unsigned short _eb91_u_int16_t; + +template <class INT> +class other_endian +{ +private: + + INT value; + + + _eb91_u_int16_t change_endian(_eb91_u_int16_t x) + { + union { + _eb91_u_int16_t i; + _eb91_u_int8_t c[2]; + } val; + val.i = x; + std::swap(val.c[0], val.c[1]); + return val.i; + } + + _eb91_int16_t change_endian(_eb91_int16_t x) + { + union { + _eb91_int16_t i; + _eb91_int8_t c[2]; + } val; + val.i = x; + std::swap(val.c[0], val.c[1]); + return val.i; + } +public: + other_endian(const INT i = 0) + { + value = change_endian(i); + } + + operator INT() + { + return change_endian(value); + } +}; + +template <class INT> +class same_endian +{ + INT value; + +public: + same_endian(const INT i = 0) + { + value = i; + } + + operator INT() + { + return value; + } +}; + + + + + + + + + + + + + + + + + +int main() { + other_endian <_eb91_u_int16_t> little_endian_16_bit_int; + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb92.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb92.C new file mode 100644 index 000000000..a9660e4cc --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb92.C @@ -0,0 +1,2 @@ +// { dg-do assemble } +template<int N> f<0>(){} // { dg-error "" } invalid code diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb93.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb93.C new file mode 100644 index 000000000..da5e7bdd7 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb93.C @@ -0,0 +1,31 @@ +// { dg-do assemble } +// Error: Internal compiler error on egcs 1998/05/28 snapshot. + +const double M_PI=3.14159265358979323846; + +template<int N,int I,int J,int K> +inline double SineSeries() +{ + const double x=I*2*M_PI/N; + const bool go=K+1!=J; + return 1.0-x*x/(2*K+2)/(2*K+3)*SineSeries<N*go,I*go,J*go,(K+1)*go>(); +} + +template<> +inline double SineSeries<0,0,0,0>() +{ + return 1.0; +} + +template<int N,int I> +inline double Sine() +{ + const double x=(I*2*M_PI/N); + return x * SineSeries<N,I,10,0>(); +} + +int main() +{ + double f=Sine<32,5>() + return 0; // { dg-error "" } parse error +} diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb94.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb94.C new file mode 100644 index 000000000..535023606 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb94.C @@ -0,0 +1,16 @@ +// { dg-do assemble } + + +class baseClass +{ +private: +static int variable; +}; + +class myClass : public baseClass +{ +private: +static int variable; // { dg-error "private" } +}; + +myClass::variable = 0; //{ dg-error "" } no type diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb95.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb95.C new file mode 100644 index 000000000..51d8cffe9 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb95.C @@ -0,0 +1,18 @@ +// { dg-do run } +struct A {}; + +template <class T> +void operator+ (A &i, T &b) {} + +template<class T> +void func (A &a, T &b) {} + +int main() +{ + A a; + +#if STRANGE + func(a, "egcs"); +#endif + a+"egcs"; +} diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb97.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb97.C new file mode 100644 index 000000000..e273dab5d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb97.C @@ -0,0 +1,25 @@ +// { dg-do run } +// Creates bad assembly on sparc and x86 +template<unsigned long SIZE> +struct Array { }; + +template<unsigned long SIZE> +Array<SIZE> test_ok(const Array<SIZE>& a) { + Array<SIZE> result; + return(result); +} + +template<unsigned long SIZE> +Array<SIZE + 1> test_error(const Array<SIZE>& a) { + Array<SIZE + 1> result; + return(result); +} + +int main(int argc, char* argv[]) { + Array<2> a; + + test_ok(a); + test_error(a); // <<< MARKED LINE! + + return(0); +} diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb98.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb98.C new file mode 100644 index 000000000..c5620316e --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb98.C @@ -0,0 +1,19 @@ +// { dg-do assemble } +// Error: Internal compiler error in egcs 1998/05/28 snapshot. + + + template<class T, unsigned int Length> + inline + unsigned int + extent(T (&x)[Length]) // { dg-message "note" } + { + return Length; + } + + extern int b[]; + + void f() + { + extent(b); // { dg-error "" } no matching function + // { dg-message "candidate" "candidate note" { target *-*-* } 17 } + } diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb99.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb99.C new file mode 100644 index 000000000..7f2c83c2e --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb99.C @@ -0,0 +1,135 @@ +// { dg-do assemble } + + + + + + + + + + + + + + + + + +class ref_counted +{ + +protected: + ref_counted( void ) : _count( 0 ) {} + +public: + + unsigned int add_ref( void ) { return ++_count; } + unsigned int release( void ) { return --_count; } + unsigned int count( void ) const { return _count; } + + +protected: + unsigned int _count; +}; + + + + + +template < class T > +class ref_ptr +{ + +public: + ref_ptr( T* ptr = 0 ) : _ptr( ptr ) + { + add_ref(); + } + + ref_ptr( const ref_ptr & rptr ) : _ptr( rptr.get() ) + { + add_ref(); + } + + ~ref_ptr( void ) { release(); } + + + T* get( void ) const { return _ptr; } + T* operator->( void ) const { return get(); } + T& operator*( void ) const { return *get(); } + + bool operator!( void ) const { return get() == 0; } + bool operator==( const ref_ptr & rptr ) const { return *get() == *rptr; +} + bool operator<( const ref_ptr & rptr ) const { return *get() < *rptr; } + + + bool operator==( T* ptr ) const { return *get() == *ptr; } + bool operator<( T* ptr ) const { return *get() < *ptr; } + + const ref_ptr & operator=( const ref_ptr & rptr ) + { + release(); + _ptr = rptr.get(); + add_ref(); + + return *this; + } + + T* operator=( T* ptr ) + { + release(); + _ptr = ptr; + add_ref(); + + return _ptr; + } + +protected: + void add_ref( void ) + { + if( _ptr ) + _ptr->add_ref(); + } + + void release( void ) + { + if( _ptr && 0 == _ptr->release() ) + { + delete _ptr; + _ptr = 0; + } + } + + +protected: + T * _ptr; +}; + + +template< class T > +bool operator==( T* ptr, const ref_ptr< T > & rptr ) +{ + return *ptr == *rptr; +} + +template< class T > +bool operator<( T* ptr, const ref_ptr< T > & rptr ) +{ + return *ptr < *rptr; +} + + + +class Baz : public ref_counted { + int dummy; +}; + + +class Bar; + +int main() { + ref_ptr<Baz> foo; + static_cast<Bar *> (foo)->DoSomething; //{ dg-error "" } invalid cast +} diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/ebnull-cast.C b/gcc/testsuite/g++.old-deja/g++.robertl/ebnull-cast.C new file mode 100644 index 000000000..d4c0a46c8 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/ebnull-cast.C @@ -0,0 +1,19 @@ +// { dg-do run } +class null { + null (null const&); + void operator& (); + + public: + null () {} + + template <typename T> + operator T* () const { return 0; } +} const null; + + +int main () +{ + int *p = static_cast<int*>(null); + + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/ebnull-oldcast.C b/gcc/testsuite/g++.old-deja/g++.robertl/ebnull-oldcast.C new file mode 100644 index 000000000..be3a5644f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/ebnull-oldcast.C @@ -0,0 +1,18 @@ +// { dg-do run } +class null { + null (null const&); + void operator& (); + + public: + null () {} + + template <typename T> + operator T* () const { return 0; } +} const null; + +int main () +{ + int *p = (int*) null; + + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/ebnull.C b/gcc/testsuite/g++.old-deja/g++.robertl/ebnull.C new file mode 100644 index 000000000..fda61cc1a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/ebnull.C @@ -0,0 +1,18 @@ +// { dg-do run } +class null { + null (null const&); + void operator& (); + + public: + null () {} + + template <typename T> + operator T* () const { return 0; } +} const null; + +int main () +{ + int *p = null; + + return 0; +} diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eh990323-1.C b/gcc/testsuite/g++.old-deja/g++.robertl/eh990323-1.C new file mode 100644 index 000000000..221a6d79c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eh990323-1.C @@ -0,0 +1,77 @@ +// { dg-do run } +// check cleanup of template temporaries +extern "C" void abort (); +extern "C" void exit (int); + +int ctor = 0; +int dtor = 0; + +template <class T> struct A { + A() {ctor++;} + A(int) {ctor++;} + A(const A&) {ctor++;} + ~A() {dtor++;} + operator int() {return 0;} +}; + +template <class T> void ff(T); + +template <class T> void ff(T) +{ +} + +void g(int) +{ +} + +void f() +{ + int x; + + A<int> a1; + A<double> a2(37); + A<long> a3 = A<long>(47); + A<short> a4 = 97; + + g(A<char*>()); + + A<char**>(); + + x ? A<char*>() : A<char*>(); + + x = 47, A<double*>(), A<int>(39), A<void>(23), -17; + + while (A<short>()) + ; + for (;A<unsigned>(3);) + ; + if (A<A<double> >()) + ; + + ff(A<double>()); + + throw 59; +} + +int +main() +{ + int flag = 0; + + try { + A<unsigned long>(); + f(); + } + catch (int) { + A<float>(34); + flag = 1; + } + + if (!flag) + abort(); + + if (!ctor || ctor != dtor) + abort(); + + exit(0); +} diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eh990323-2.C b/gcc/testsuite/g++.old-deja/g++.robertl/eh990323-2.C new file mode 100644 index 000000000..2c2e4bd22 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eh990323-2.C @@ -0,0 +1,103 @@ +// { dg-do run } +// check MI and VBC offsets on throw +extern "C" void abort (); +extern "C" void exit (int); + +struct A { + int x[23]; +}; + +struct B : virtual public A { + int y[33]; +}; + +struct C : virtual public A, public B { + int z[43]; +}; + +struct D { + int xx[53]; +}; + +struct E : public D, public A { + int yy[63]; +}; + +C c; + +E e; + +void f1() +{ + throw (C*)0; +} + +void f2() +{ + throw &c; +} + +void f3() +{ + throw (E*)0; +} + +void f4() +{ + throw &e; +} + +int main() +{ + int flag; + + flag = 0; + try { + f1(); + } + catch (A* p) { + if (p) + abort(); + flag = 1; + } + if (!flag) + abort(); + + flag = 0; + try { + f2(); + } + catch (A* p) { + if (!p || (void*)p == (void*)&c) + abort(); + flag = 1; + } + if (!flag) + abort(); + + flag = 0; + try { + f3(); + } + catch (A* p) { + if (p) + abort(); + flag = 1; + } + if (!flag) + abort(); + + flag = 0; + try { + f4(); + } + catch (A* p) { + if (!p || (void*)p == (void*)&e) + abort(); + flag = 1; + } + if (!flag) + abort(); + + exit(0); +} diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eh990323-3.C b/gcc/testsuite/g++.old-deja/g++.robertl/eh990323-3.C new file mode 100644 index 000000000..e8369ca76 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eh990323-3.C @@ -0,0 +1,30 @@ +// { dg-do run } +// try throwing 0 cast to a class object +extern "C" void abort (); +extern "C" void exit (int); + +struct A {}; + +void f() +{ + throw (A*)0; +} + +int +main() +{ + int flag; + + flag = 0; + try { + f(); + } + catch (A*) { + flag = 1; + } + + if (!flag) + abort(); + + exit (0); +} diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eh990323-4.C b/gcc/testsuite/g++.old-deja/g++.robertl/eh990323-4.C new file mode 100644 index 000000000..24c740dd1 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eh990323-4.C @@ -0,0 +1,104 @@ +// { dg-do run } +// check MI and VBC offsets on throw +extern "C" void abort (); +extern "C" void exit (int); + +struct A { + int x[23]; +}; + +struct B : virtual public A { + int y[33]; +}; + +struct C : virtual public A, public B { + int z[43]; +}; + +struct D { + int xx[53]; +}; + +struct E : public D, public A { + int yy[63]; +}; + +C c; + +E e; + +void f1() +{ + throw (C*)0; +} + +void f2() +{ + throw &c; +} + +void f3() +{ + throw (E*)0; +} + +void f4() +{ + throw &e; +} + +int +main() +{ + int flag; + + flag = 0; + try { + f1(); + } + catch (void* p) { + if (p) + abort(); + flag = 1; + } + if (!flag) + abort(); + + flag = 0; + try { + f2(); + } + catch (void* p) { + if (!p || (void*)p != (void*)&c) + abort(); + flag = 1; + } + if (!flag) + abort(); + + flag = 0; + try { + f3(); + } + catch (void* p) { + if (p) + abort(); + flag = 1; + } + if (!flag) + abort(); + + flag = 0; + try { + f4(); + } + catch (void* p) { + if (!p || (void*)p != (void*)&e) + abort(); + flag = 1; + } + if (!flag) + abort(); + + exit(0); +} diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eh990323-5.C b/gcc/testsuite/g++.old-deja/g++.robertl/eh990323-5.C new file mode 100644 index 000000000..7913c09ae --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eh990323-5.C @@ -0,0 +1,68 @@ +// { dg-do run } +// check cleanup of partial array objects +extern "C" void abort (void); +extern "C" void exit (int); + +int ctor = 0; +int dtor = 0; + +int cnt = 1; + +struct A { + int x; + A(); + A(const A&); + ~A(); +}; + +A::A() +{ + if (cnt == 10) + throw 57; + x = cnt++; + ctor++; +} + +A::A(const A&) +{ + if (cnt == 10) + throw 57; + x = cnt++; + ctor++; +} + +A::~A() +{ + if (x + 1 != cnt--) + abort(); + dtor++; +} + +void f() +{ + A a[] = {A(), A(), A(), A(), A(), A(), A(), A(), A(), A(), A(), A()}; + + throw -1066; +} + +int +main() +{ + int flag; + + flag = 0; + try { + f(); + } + catch (int) { + flag = 1; + } + if (!flag) + abort(); + if (ctor != 9) + abort(); + if (dtor != 9) + abort(); + + exit(0); +} diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/ice990323-1.C b/gcc/testsuite/g++.old-deja/g++.robertl/ice990323-1.C new file mode 100644 index 000000000..41fed6ff5 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/ice990323-1.C @@ -0,0 +1,9 @@ +// { dg-do assemble } + +//test 2 +struct A {}; +void f() +{ + struct A; // { dg-error "" } forward ref + throw *(new A); // { dg-error "" } invalid use of undefined type +} diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/ice990323-2.C b/gcc/testsuite/g++.old-deja/g++.robertl/ice990323-2.C new file mode 100644 index 000000000..cefef7750 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/ice990323-2.C @@ -0,0 +1,88 @@ +// { dg-do run } +// check EH with templates +extern "C" void abort (); +extern "C" void exit (int); + +template <class T, int n, class U> struct A { + A() {} + A(const char*) {} +}; + +void f1() +{ + throw *(new A<double, 47, A<int, 37, short> >); +} + +void f2() +{ + throw *(new A<double, 47, A<int, 36, short> >); +} + +void f3() +{ + throw A<double, 47, A<int, 37, short> > ("howdy"); +} + +void f4() +{ + throw A<double, 47, A<int, 36, short> > ("hi michey"); +} + +int main() +{ + int flag; + + flag = 0; + try { + f1(); + } + catch (A<double, 47, A<int, 36, short> >) { + abort(); + } + catch (A<double, 47, A<int, 37, short> >) { + flag = 1; + } + if (!flag) + abort(); + + flag = 0; + try { + f2(); + } + catch (A<double, 47, A<int, 36, short&> >) { + abort(); + } + catch (A<double, 47, A<int, 36, short> >) { + flag = 1; + } + if (!flag) + abort(); + + flag = 0; + try { + f3(); + } + catch (A<double, 47, A<int, 36, short> >) { + abort(); + } + catch (A<double, 47, A<int, 37, short> >) { + flag = 1; + } + if (!flag) + abort(); + + flag = 0; + try { + f4(); + } + catch (A<double, 47, A<int, 36, short&> >) { + abort(); + } + catch (A<double, 47, A<int, 36, short> >) { + flag = 1; + } + if (!flag) + abort(); + + exit(0); +} diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/ice990323-3.C b/gcc/testsuite/g++.old-deja/g++.robertl/ice990323-3.C new file mode 100644 index 000000000..37d5b6939 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/ice990323-3.C @@ -0,0 +1,15 @@ +// { dg-do assemble } +// try throwing overloaded function + +void f(int) +{ +} + +void f(long) +{ +} + +void g() +{ + throw &f; // { dg-error "" } insufficient contextual information +} diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/ice990323-4.C b/gcc/testsuite/g++.old-deja/g++.robertl/ice990323-4.C new file mode 100644 index 000000000..4332e0fce --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/ice990323-4.C @@ -0,0 +1,13 @@ +// { dg-do assemble } +// try throwing template function name + +template <class T> void f(T); + +template <class T> void f(T) +{ +} + +void g() +{ + throw &f; // { dg-error "" } insufficient contextual information +} diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/ice990323-5.C b/gcc/testsuite/g++.old-deja/g++.robertl/ice990323-5.C new file mode 100644 index 000000000..c0dfcd592 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.robertl/ice990323-5.C @@ -0,0 +1,12 @@ +// { dg-do assemble } +// check attempting to throw an overloaded function + +struct A { + void f(int); + void f(long); +}; + +void g() +{ + throw &A::f; // { dg-error "" } insufficient context +} diff --git a/gcc/testsuite/g++.old-deja/g++.warn/cast-align1.C b/gcc/testsuite/g++.old-deja/g++.warn/cast-align1.C new file mode 100644 index 000000000..43cecab23 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.warn/cast-align1.C @@ -0,0 +1,27 @@ +// { dg-do assemble { target sparc-*-* } } +// { dg-options "-ansi -pedantic-errors -Wcast-align" } + + +// Copyright (C) 1999 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 7 Dec 1999 <nathan@acm.org> + +// converting a T * to void * does not need a complete T, and doesn't +// increase alignment requirements. + +struct X; +struct Y; +struct Z {double m;}; + +void f3 (X *xp, Z *zp) +{ + (void *)xp; + (void *)zp; + (Y *)xp; + (Y *)zp; + (Z *)xp; +} + +void f4 (char *ptr) +{ + (Z *)ptr; // { dg-warning "" } alignment +} diff --git a/gcc/testsuite/g++.old-deja/g++.warn/flow1.C b/gcc/testsuite/g++.old-deja/g++.warn/flow1.C new file mode 100644 index 000000000..61f6a5549 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.warn/flow1.C @@ -0,0 +1,14 @@ +// { dg-do assemble } +// { dg-options "-Wreturn-type" } +// Test that we don't get a warning about flowing off the end. + +struct A { + ~A (); +}; + +int f() +{ + A a1[2]; + A a2[2]; + return 1234567; +} diff --git a/gcc/testsuite/g++.old-deja/g++.warn/impint.C b/gcc/testsuite/g++.old-deja/g++.warn/impint.C new file mode 100644 index 000000000..1c7f0eb66 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.warn/impint.C @@ -0,0 +1,56 @@ +// { dg-do assemble } +// { dg-options "-Wconversion" } +// Copyright (C) 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 24 Feb 2000 <nathan@codesourcery.com> + +// derived from a bug report by Johan Kuipers <j.kuipers@chello.nl> +// initialization to 'int' from to 'double' We expect consistent warnings +// whenever a float is implicitly truncated to int + +struct X +{ + X (int); + X (int, int); +}; + +void foo (int); +void wibble (int); +void wibble (int, int); +void punk (int = 3.5); +void rock (); +void rock (int, int = 3.5); + +void fn () +{ + X x1(3.5); // { dg-warning "" } double to int + X x2(3.5f); // { dg-warning "" } float to int + X x3(1, 3.5); // { dg-warning "" } double to int + X x4(1, 3.5f); // { dg-warning "" } float to int + X x5(3.5, 1); // { dg-warning "" } double to int + X x6(3.5f, 1); // { dg-warning "" } float to int + + X y1 = 3.5; // { dg-warning "" } double to int + X y2 = 3.5f; // { dg-warning "" } float to int + + int j1 (3.5); // { dg-warning "" } double to int + int j2 (3.5f); // { dg-warning "" } float to int + + int k1 = 3.5; // { dg-warning "" } double to int + int k2 = 3.5f; // { dg-warning "" } float to int + + j1 = 3.5; // { dg-warning "" } double to int + j2 = 3.5f; // { dg-warning "" } float to int + + foo (3.5); // { dg-warning "" } double to int + foo (3.5f); // { dg-warning "" } float to int + + wibble (3.5); // { dg-warning "" } double to int + wibble (3.5f); // { dg-warning "" } float to int + wibble (1, 3.5); // { dg-warning "" } double to int + wibble (1, 3.5f); // { dg-warning "" } float to int + wibble (3.5, 1); // { dg-warning "" } double to int + wibble (3.5f, 1); // { dg-warning "" } float to int + + punk (); // { dg-warning "" } double to int + rock (1); // { dg-warning "" } double to int +} diff --git a/gcc/testsuite/g++.old-deja/g++.warn/impint2.C b/gcc/testsuite/g++.old-deja/g++.warn/impint2.C new file mode 100644 index 000000000..d5fbc5554 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.warn/impint2.C @@ -0,0 +1,69 @@ +// { dg-do assemble } +// { dg-options "-Wconversion" } + +// Copyright (C) 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 6 Mar 2000 <nathan@codesourcery.com> + +// initialization to 'int' from to 'double' We expect consistent warnings +// whenever a float is implicitly truncated to int, make sure references +// don't confuse us, as Gerald Pfeifer <pfeifer@dbai.tuwien.ac.at> found out. + +struct X +{ + X (int const &); + X (int const &, int const &); +}; + +void foo (int const &); +void wibble (int const &); +void wibble (int const &, int const &); +void punk (int const & = 3.5f); // { dg-warning "" } in passing +void rock (); +void rock (int const &, int const & = 3.5f); // { dg-warning "" } in passing + +void fn () +{ + X x2(3.5f); // { dg-warning "" } float to int + X x4(1, 3.5f); // { dg-warning "" } float to int + X x6(3.5f, 1); // { dg-warning "" } float to int + + X y2 = 3.5f; // { dg-warning "" } float to int + + int j2 (3.5f); // { dg-warning "" } float to int + + int k2 = 3.5f; // { dg-warning "" } float to int + + j2 = 3.5f; // { dg-warning "" } float to int + + foo (3.5f); // { dg-warning "" } float to int + + wibble (3.5f); // { dg-warning "" } float to int + wibble (1, 3.5f); // { dg-warning "" } float to int + wibble (3.5f, 1); // { dg-warning "" } float to int + + punk (); // { dg-warning "" } float to int + rock (1); // { dg-warning "" } float to int +} + +// and make sure we really know when something's unsigned +void foo () +{ + X x2(-1); + X x4(1, -1); + X x6(-1, 1); + + X y2 = -1; + + int j2 (-1); + + int k2 = -1; + + j2 = -1; + + foo (-1); + + wibble (-1); + wibble (1, -1); + wibble (-1, 1); + +} diff --git a/gcc/testsuite/g++.old-deja/g++.warn/inline.C b/gcc/testsuite/g++.old-deja/g++.warn/inline.C new file mode 100644 index 000000000..51fbabdc2 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.warn/inline.C @@ -0,0 +1,69 @@ +// { dg-do assemble } +// { dg-options "-ansi -pedantic-errors -Winline -O1" } + +// Copyright (C) 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 9 Mar 2000 <nathan@codesourcery.com> + +// derived from a bug report by Benjamin Kosnik <bkoz@cygnus.com> + +// __FUNCTION__ was erroneously causing us to issue a `cannot inline' +// diagnostic, even though we'd (a) inlined it, (b) been forced to issue an +// out of line body by taking it's address, (c) not used __FUNCTION__. + +inline void wibble () +{} + +inline void wobble () +{} // { dg-bogus "" } cannot inline + +void bar (void (*)()); + +void bar1 () +{ + wibble (); // can be inlined + void (*ptr) () = wobble; // force out of line issue + + bar (ptr); // make sure we make use of it +} + +struct B +{ + void mwibble () + {} + void mwobble () + {} // { dg-bogus "" } cannot inline + + static void swibble () + {} + static void swobble () + {} // { dg-bogus "" } cannot inline +}; + +void bar (void (B::*)()); + +void bar2 () +{ + B::swibble (); // can be inlined + void (*ptr) () = &B::swobble; // force out of line issue + + bar (ptr); // make sure we make use of it +} + +void bar3 (B *b) +{ + b->mwibble (); // can be inlined + void (B::*ptr) () = &B::mwobble; // force out of line issue + + bar (ptr); // make sure we make use of it +} + +struct C +{ + virtual void vwobble () + {} // { dg-bogus "" } cannot inline +}; + +void bar4 () +{ + C c; // force issue of C's vtable etc +} diff --git a/gcc/testsuite/g++.old-deja/g++.warn/iomanip.C b/gcc/testsuite/g++.old-deja/g++.warn/iomanip.C new file mode 100644 index 000000000..c437b26db --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.warn/iomanip.C @@ -0,0 +1,13 @@ +// { dg-do assemble } +// { dg-options "-O -Winline" } +// Bug: g++ wouldn't inline op<< because it was an explicit instantiation. +// Origin: Jason Merrill <jason@cygnus.com> + +#include <iomanip> +#include <iostream> + +void +f() +{ + 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 000000000..4550dd5e0 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.warn/virt1.C @@ -0,0 +1,10 @@ +// { dg-do assemble } +// { dg-options "-Woverloaded-virtual" } + +struct A { + virtual void f(); // { dg-warning "" } hidden +}; + +struct B: public A { + void f(int); // { dg-warning "" } by this +}; diff --git a/gcc/testsuite/g++.old-deja/old-deja.exp b/gcc/testsuite/g++.old-deja/old-deja.exp new file mode 100644 index 000000000..ce53b5fe4 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/old-deja.exp @@ -0,0 +1,38 @@ +# Copyright (C) 1988, 90, 91, 92, 1994, 1997, 2000, 2003, 2007 +# Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GCC; see the file COPYING3. If not see +# <http://www.gnu.org/licenses/>. + +# Load support procs. +load_lib g++-dg.exp + +# If a testcase doesn't have special options, use these. +global DEFAULT_CXXFLAGS +if ![info exists DEFAULT_CXXFLAGS] then { + set DEFAULT_CXXFLAGS " -ansi -pedantic-errors -Wno-long-long" +} + +# Initialize `dg'. +dg-init + +# Gather a list of all tests, with the exception of those in directories +# that are handled specially. +set tests [lsort [find $srcdir/$subdir *.C]] + +# Main loop. +dg-runtest $tests "" $DEFAULT_CXXFLAGS + +# All done. +dg-finish |