diff options
Diffstat (limited to 'gcc/testsuite/g++.old-deja/g++.pt')
87 files changed, 1596 insertions, 0 deletions
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 00000000000..6c5810ed77b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/array2.C @@ -0,0 +1,14 @@ +// Build don't link: + +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 00000000000..ec5e1e0e3a7 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/array3.C @@ -0,0 +1,5 @@ +// Build don't link: +// 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 00000000000..fab2d5b1527 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/array4.C @@ -0,0 +1,14 @@ +// Test to make sure that the array bounds are treated as an expression +// in template parm substitution. + +// Written by Jason Merrill <jason@cygnus.com> + +// Build don't link: + +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/copy1.C b/gcc/testsuite/g++.old-deja/g++.pt/copy1.C new file mode 100644 index 00000000000..7981530f697 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/copy1.C @@ -0,0 +1,29 @@ +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/crash25.C b/gcc/testsuite/g++.old-deja/g++.pt/crash25.C new file mode 100644 index 00000000000..f5875854562 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/crash25.C @@ -0,0 +1,7 @@ +// Build don't link: + +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 00000000000..d2101bd3b63 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/crash26.C @@ -0,0 +1,15 @@ +// Build don't link: +// 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 00000000000..f52f1ba9e02 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/crash27.C @@ -0,0 +1,13 @@ +// Build don't link: + +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 00000000000..752c9706990 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/crash28.C @@ -0,0 +1,14 @@ +// Build don't link: +// Special g++ Options: + +template <class ARRY> +inline unsigned int asize(ARRY &a) +{ + return sizeof(a) / sizeof(a[0]); +} + +int f(unsigned int n) { + int x[n]; + + asize(x); // ERROR - no matching function +}; 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 00000000000..05bef969836 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/crash29.C @@ -0,0 +1,69 @@ +// Build don't link: +// 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 ) {} +}; + +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/crash30.C b/gcc/testsuite/g++.old-deja/g++.pt/crash30.C new file mode 100644 index 00000000000..13dc37af68d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/crash30.C @@ -0,0 +1,15 @@ +// Build don't link: + +extern "C" int printf(const char *, ...); +template <class T> struct A { + typedef typename T::X B; // 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); // ERROR - does not match any template +}; + +template struct B<double>; // ERROR - 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 00000000000..34758967c2e --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/crash31.C @@ -0,0 +1,19 @@ +// Build don't link: +// 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/decl2.C b/gcc/testsuite/g++.old-deja/g++.pt/decl2.C new file mode 100644 index 00000000000..2e2b91cde86 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/decl2.C @@ -0,0 +1,9 @@ +// Build don't link: + +// Simplified from testcase by Christophe Boyanique <boyan@imac.u-paris2.fr> + +// crash test - XFAIL *-*-* + +template <class T> struct foo { foo(); }; +template<class T> foo<T>::foo() {} +T // ERROR - currently an ICE 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 00000000000..a87b2a7566e --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/deduct1.C @@ -0,0 +1,27 @@ +// Build don't link: + +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/defarg5.C b/gcc/testsuite/g++.old-deja/g++.pt/defarg5.C new file mode 100644 index 00000000000..6a68bad8251 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/defarg5.C @@ -0,0 +1,24 @@ +// Build don't link: + +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 00000000000..0094c5ca7e0 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/defarg6.C @@ -0,0 +1,27 @@ +// Build don't link: + +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); // ERROR - default argument + + template <class Y> + void k(Y); +}; + +template <class T> +template <class U = double> +void C<T>::f(U) {} // ERROR - default argument + +template <class X = void*> +void g(X); // ERROR - default argument + +template <class T = double> +template <class Y> +void C<T>::k(Y) {} // 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 00000000000..0db043fb633 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/defarg7.C @@ -0,0 +1,11 @@ +// Build don't link: + +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 00000000000..6bb1125259c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/defarg8.C @@ -0,0 +1,14 @@ +// Build don't link: + +// Default arguments containing more than one non-nested explicit +// template argument leads to parse error + +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, // ok + int j = int(foo2<T, U>::baz), // ok + int k = foo2<T, U>::baz) {} // gets bogus error - before > - XFAIL *-*-* +}; 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 00000000000..e2275f4328d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/derived1.C @@ -0,0 +1,24 @@ +// Build don't link: + +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 00000000000..737792cab9f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/derived2.C @@ -0,0 +1,35 @@ +// Build don't link: +// Special g++ 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/explicit74.C b/gcc/testsuite/g++.old-deja/g++.pt/explicit74.C new file mode 100644 index 00000000000..c49d16919a8 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/explicit74.C @@ -0,0 +1,10 @@ +// 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 00000000000..433f0b193e3 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/explicit75.C @@ -0,0 +1,11 @@ +// Test for not complaining about mismatches during unification. +// Build don't link: + +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 00000000000..18c161c6e27 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/explicit76.C @@ -0,0 +1,11 @@ +// Build don't link: + +// Based on bug report by Simon A. Crase <s.crase@ieee.org> + +// crash test - XFAIL *-*-* + +struct foo { + template <class T> void bar(); +}; + +template void foo::bar<void>(); // gets bogus error - ICE - XFAIL *-*-* 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 00000000000..5a07f8e0168 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/explicit77.C @@ -0,0 +1,18 @@ +// Build don't link: + +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>); + +void g() { + S<0, 0, 0> s0; + S<0, 1, 2> s2; + + f<0>(s0, s2); + f(s0, s2); // ERROR - no matching function +} 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 00000000000..2375816af87 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/explicit78.C @@ -0,0 +1,28 @@ +// Build don't link: + +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 00000000000..16429ba6213 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/explicit79.C @@ -0,0 +1,12 @@ +// Build don't link: + +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/expr6.C b/gcc/testsuite/g++.old-deja/g++.pt/expr6.C new file mode 100644 index 00000000000..e1d38de7e56 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/expr6.C @@ -0,0 +1,9 @@ +// Build don't link: + +// Based on a bug report by tveldhui <tveldhui@extreme.indiana.edu> + +// excess errors test - XFAIL *-*-* + +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 00000000000..5fb567b5b77 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/expr7.C @@ -0,0 +1,8 @@ +// Build don't link: + +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/friend36.C b/gcc/testsuite/g++.old-deja/g++.pt/friend36.C new file mode 100644 index 00000000000..4a9042ad3ec --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/friend36.C @@ -0,0 +1,12 @@ +// Build don't link: + +template <class T> +void f(T) {} // ERROR - previously defined here + +template <class U> +struct S { + template <class T> + friend void f(T) {} // ERROR - redeclaration +}; + +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 00000000000..2379d5f1da7 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/friend37.C @@ -0,0 +1,8 @@ +// Build don't link: +// Simplified from report by Volker Dobler <volker@hugo.physik.uni-konstanz.de> + +// crash test - XFAIL *-*-* + +template <class T> class A { + friend int ice<>( int k=0 ); // ERROR - undeclared +}; 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 00000000000..e3a6a060ef6 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/friend38.C @@ -0,0 +1,8 @@ +// Build don't link: + +// Overly simplified from testcase by "B. K. Oxley" <binkley@bigfoot.com> + +template<class P> struct foo { + typedef P parent_type; + friend parent_type; // ERROR - template parameters cannot be friends - XFAIL *-*-* +}; 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 00000000000..836c83054bb --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/friend39.C @@ -0,0 +1,23 @@ +// Build don't link: + +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/friend40.C b/gcc/testsuite/g++.old-deja/g++.pt/friend40.C new file mode 100644 index 00000000000..90288e8a336 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/friend40.C @@ -0,0 +1,12 @@ +// Build don't link: +// Origin: Jason Merrill <jason@cygnus.com> +// Special g++ Options: -Wno-non-template-friend + +template<class T> struct A +{ + friend void f (); +}; + +A<short> a; +A<int> b; + 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 00000000000..6ae70c1bb9e --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/inherit1.C @@ -0,0 +1,25 @@ +// 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 (&local1 != &local2) + i = 0; + } +}; + +int main () { + FinalClass<1> a1; + return i; +} 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 00000000000..296356b713f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/instantiate4.C @@ -0,0 +1,27 @@ +// Build then link: + +// Special g++ Options: -frepo -Werror + +// 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(); +} 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 00000000000..be64bdbc4c2 --- /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 00000000000..70eefcbb455 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/instantiate5.C @@ -0,0 +1,14 @@ +// Build don't run: + +// 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 00000000000..fc86e0f8309 --- /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 00000000000..e896ed32570 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/instantiate6.C @@ -0,0 +1,26 @@ +// Build then link: +// Special g++ Options: -frepo + +// Simplified from testcase by Erez Louidor Lior <s3824888@techst02.technion.ac.il> +// excess errors test - XFAIL *-*-* + +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(); +} 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 00000000000..ae1f5ca2c5b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/lookup6.C @@ -0,0 +1,15 @@ +// Build don't link: + +// 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); // gets bogus error - redefinition + void g(u p); // ERROR - unknown type name +}; 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 00000000000..96024e21859 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/memclass17.C @@ -0,0 +1,22 @@ +// Build don't link: + +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 00000000000..bb7f6f12b99 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/memclass18.C @@ -0,0 +1,9 @@ +// Build don't link: + +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 00000000000..6a8b0a7d11c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/memclass19.C @@ -0,0 +1,9 @@ +// Build don't link: + +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/memtemp78.C b/gcc/testsuite/g++.old-deja/g++.pt/memtemp78.C new file mode 100644 index 00000000000..945e7ff68f0 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/memtemp78.C @@ -0,0 +1,56 @@ +// Build don't link: + +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() {} + + template <class U> + void f() {} // ERROR - 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); + void f(U); // ERROR - redeclaration +}; + +template struct D2<int, int>; + +struct E +{ + void f(); + void f(); // ERROR - 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 00000000000..4eeffde4e7c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/memtemp79.C @@ -0,0 +1,6 @@ +// Build don't link: + +struct foo { + template<typename T> static void bar( foo* ); + template<typename T> void bar() const; // gets bogus error - quals XFAIL *-*-* +}; 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 00000000000..61a2fb87033 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/memtemp80.C @@ -0,0 +1,16 @@ +// Build don't link: + +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 00000000000..1584f88b802 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/memtemp81.C @@ -0,0 +1,24 @@ +// Build don't link: + +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 00000000000..d4bb37aa410 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/memtemp82.C @@ -0,0 +1,13 @@ +// Build don't link: +// excess errors test + +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 00000000000..69ab94820b0 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/memtemp83.C @@ -0,0 +1,19 @@ +// Build don't link: +// 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/nttp1.C b/gcc/testsuite/g++.old-deja/g++.pt/nttp1.C new file mode 100644 index 00000000000..36b743848c4 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/nttp1.C @@ -0,0 +1,21 @@ +// 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 00000000000..08781daf516 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/nttp2.C @@ -0,0 +1,30 @@ +// 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/overload10.C b/gcc/testsuite/g++.old-deja/g++.pt/overload10.C new file mode 100644 index 00000000000..19dd174a019 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/overload10.C @@ -0,0 +1,16 @@ +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 00000000000..300d91ea2b8 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/overload11.C @@ -0,0 +1,27 @@ +// Build don't run: + +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 00000000000..bf37bb66867 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/overload12.C @@ -0,0 +1,21 @@ +// 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/overload6.C b/gcc/testsuite/g++.old-deja/g++.pt/overload6.C new file mode 100644 index 00000000000..10f793a8633 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/overload6.C @@ -0,0 +1,13 @@ +// 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 00000000000..bfd8b5a5eb4 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/overload7.C @@ -0,0 +1,20 @@ +// Build don't link: + +// 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); // gets bogus error - no matching function for call - XFAIL *-*-* +} + +int main() { + moo_t<int> x; + foo(x); // gets bogus error - instantiated from here - XFAIL *-*-* +} 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 00000000000..9f38a5cb256 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/overload8.C @@ -0,0 +1,12 @@ +// Build don't link: + +// 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) + ; // gets bogus error - must have argument of class type - XFAIL *-*-* + +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 00000000000..bd9eeb1791a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/overload9.C @@ -0,0 +1,21 @@ +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/ptrmem3.C b/gcc/testsuite/g++.old-deja/g++.pt/ptrmem3.C new file mode 100644 index 00000000000..8b7c373c1b7 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/ptrmem3.C @@ -0,0 +1,12 @@ +// Build don't link: + +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 00000000000..139be923550 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/ptrmem4.C @@ -0,0 +1,28 @@ +// Build don't run: + +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 00000000000..c9e6c9b9841 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/ptrmem5.C @@ -0,0 +1,17 @@ +// Build don't link: + +// 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; // gets bogus error - cannot convert - XFAIL *-*-* 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 00000000000..946e6244f4a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/ptrmem6.C @@ -0,0 +1,34 @@ +// Build don't link: + +class A { +public: + virtual void f(); + int i; +}; + +class B : public A { +public: + void f(); + int j; +}; + +template <void (A::*)() > +void g() {} +template <int A::*> +void h() {} + + +int main() { + g<&A::f>(); + h<&A::i>(); + g<&B::f>(); // ERROR - + h<&B::j>(); // ERROR - + g<(void (A::*)()) &A::f>(); // ERROR - XFAIL *-*-* + h<(int A::*) &A::i>(); // ERROR - + g<(void (A::*)()) &B::f>(); // ERROR - + h<(int A::*) &B::j>(); // ERROR - + g<(void (A::*)()) 0>(); // ERROR - + h<(int A::*) 0>(); // ERROR - + + 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 00000000000..9efeec87a68 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/ptrmem7.C @@ -0,0 +1,14 @@ +// Build don't link: +// 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/redecl2.C b/gcc/testsuite/g++.old-deja/g++.pt/redecl2.C new file mode 100644 index 00000000000..0b65e1ec957 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/redecl2.C @@ -0,0 +1,14 @@ +// Build don't link: + +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 00000000000..8b117a5fffb --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/ref1.C @@ -0,0 +1,16 @@ +// Build don't link: + +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/shadow1.C b/gcc/testsuite/g++.old-deja/g++.pt/shadow1.C new file mode 100644 index 00000000000..dfe99c7b22d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/shadow1.C @@ -0,0 +1,19 @@ +// Build don't link: + +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/sizeof2.C b/gcc/testsuite/g++.old-deja/g++.pt/sizeof2.C new file mode 100644 index 00000000000..566665af23c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/sizeof2.C @@ -0,0 +1,20 @@ +// 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 00000000000..cd5f701f20f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/sizeof3.C @@ -0,0 +1,25 @@ +// 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/spec23.C b/gcc/testsuite/g++.old-deja/g++.pt/spec23.C new file mode 100644 index 00000000000..0e9ee61d253 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/spec23.C @@ -0,0 +1,10 @@ +/* [temp.expl.spec] p18. */ + +template<class T> +struct A { + template <class U> class B { }; +}; + +template<class T> +class A<T>::B<void> { // 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 00000000000..2b7d336698f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/spec24.C @@ -0,0 +1,5 @@ +// Build don't link: + +template <class T> class A; +// template <> +class A<int>; // ERROR - missing template header - XFAIL *-*-* 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 00000000000..884abf07dee --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/spec25.C @@ -0,0 +1,15 @@ +// Build don't link: + +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 00000000000..1bd40b6083c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/spec26.C @@ -0,0 +1,11 @@ +// From: lat@iki.fi (Lassi A. Tuura) +// Test that a specialization without an initializer is not a definition, +// as specified in [temp.expl.spec]. + +// Build don't link: + +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 00000000000..63aae4c9bf6 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/spec27.C @@ -0,0 +1,18 @@ +// Build don't link: + +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 00000000000..d63e7967672 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/spec28.C @@ -0,0 +1,25 @@ +// Build don't link: + +template <class T> +struct S1 { + friend bool f<>(const S1&); + typedef T X; +}; + +template <class T> +struct S2 { +}; + +template <class T> +struct S2<S1<T> > { + typedef typename S1<T>::X Y; +}; + +template <class T> +bool f(T); + +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 00000000000..9f27a8e53a3 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/spec29.C @@ -0,0 +1,31 @@ +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/spec30.C b/gcc/testsuite/g++.old-deja/g++.pt/spec30.C new file mode 100644 index 00000000000..5d36e254a40 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/spec30.C @@ -0,0 +1,41 @@ +#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 00000000000..a66e03f62eb --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/spec31.C @@ -0,0 +1,2 @@ +template <> struct A {}; // ERROR - not a specialization +template <> void f (); // ERROR - not a specialization 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 00000000000..f6e125dbfb7 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/static5.C @@ -0,0 +1,9 @@ +// Build don't link: + +template <class T> +struct S +{ + static const T t = 3; // 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 00000000000..c52c3cb2af5 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/static6.C @@ -0,0 +1,14 @@ +// Build don't run: + +// 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/ttp53.C b/gcc/testsuite/g++.old-deja/g++.pt/ttp53.C new file mode 100644 index 00000000000..e5e87b46089 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/ttp53.C @@ -0,0 +1,35 @@ +// Build don't link: + +// 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 00000000000..bae649a3dfa --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/ttp54.C @@ -0,0 +1,20 @@ +// Build don't link: + +// 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 00000000000..10af608bcba --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/ttp55.C @@ -0,0 +1,23 @@ +// Build don't link: + +// 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/typename14.C b/gcc/testsuite/g++.old-deja/g++.pt/typename14.C new file mode 100644 index 00000000000..7365b66801d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/typename14.C @@ -0,0 +1,15 @@ +// Build don't link: +// Special g++ Options: + +template <class T> +struct B { + typedef T X; +}; + +template <class T> +struct S : public B<T> +{ + struct I { + void f(X x); + }; +}; 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 00000000000..8e26057922e --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/typename15.C @@ -0,0 +1,18 @@ +// Build don't link: +// Special g++ 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() +{ + 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 00000000000..51a8765e9ac --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/typename16.C @@ -0,0 +1,31 @@ +// Build don't run: +// Special g++ Options: + +struct B { + typedef int I; +}; + +template <class T> +struct D1 : public B { +}; + +template <class T> +struct D2 : public D1<T> { + I i; +}; + +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); +} 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 00000000000..87b0ab3b905 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/typename17.C @@ -0,0 +1,20 @@ +// Build don't link: + +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/unify4.C b/gcc/testsuite/g++.old-deja/g++.pt/unify4.C new file mode 100644 index 00000000000..259920d4565 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/unify4.C @@ -0,0 +1,11 @@ +template <class T> void f (T); + +void g (); +void g (int); + +int +main () +{ + f (g); // ERROR - ambiguous unification + return 0; +} 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 00000000000..a1da446e570 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/union1.C @@ -0,0 +1,18 @@ +// Build don't link: + +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; +} |