This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

template test cases


I hope the following test cases will be useful for improving template
handling in gcc.  (I know the testuite is currently frozen, but...)

The collection includes some well-formed C++ that still crashes gcc
in version 2.95 (with Martin's template patch installed).  Some of
the problems displayed are also regressions from egcs-1.1.2.


*** /dev/null	Tue May  5 13:32:27 1998
--- gcc/testsuite/g++.pt/lss-001.cc	Wed Aug 11 18:03:23 1999
***************
*** 0 ****
--- 1,16 ----
+ // Build don't link:
+ // crash test -
+ 
+ // by Paul Burchard <burchard@pobox.com>, Level Set Systems, Inc.
+ // Copyright (C) 1999 Free Software Foundation
+ 
+ template<class T>
+ class X {
+ 	class Y : public T {
+ 	}; // ERROR - base type `int' fails to be a struct or class type.
+ 	Y y;
+ };
+ int main() {
+ 	X<int> x; // ERROR - (instantiated from here)
+ }
+ 
*** /dev/null	Tue May  5 13:32:27 1998
--- gcc/testsuite/g++.pt/lss-002.cc	Wed Aug 11 18:03:04 1999
***************
*** 0 ****
--- 1,26 ----
+ // Build don't link:
+ 
+ // 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> // gets bogus error - `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; // gets bogus error - redefinition of `template <class XX> template <class X> class A<X>'
+ }
+ 
*** /dev/null	Tue May  5 13:32:27 1998
--- gcc/testsuite/g++.pt/lss-003.cc	Wed Aug 11 18:05:21 1999
***************
*** 0 ****
--- 1,8 ----
+ // Build don't link:
+ // crash test -
+ 
+ // by Paul Burchard <burchard@pobox.com>, Level Set Systems, Inc.
+ // Copyright (C) 1999 Free Software Foundation
+ 
+ typedef std::vector<int>::iterator iter; // ERROR - syntax error before `::'
+ 
*** /dev/null	Tue May  5 13:32:27 1998
--- gcc/testsuite/g++.pt/lss-004.cc	Wed Aug 11 18:06:21 1999
***************
*** 0 ****
--- 1,16 ----
+ // Build don't link:
+ // crash test - XFAIL *-*-*
+ 
+ // by Paul Burchard <burchard@pobox.com>, Level Set Systems, Inc.
+ // Copyright (C) 1999 Free Software Foundation
+ 
+ class Q {
+ 	template<class>
+ 	class X {
+ 	};
+ };
+ template<template<class> class>
+ class Y {
+ };
+ Y<Q::X> y1;
+ 
*** /dev/null	Tue May  5 13:32:27 1998
--- gcc/testsuite/g++.pt/lss-005.cc	Wed Aug 11 18:07:03 1999
***************
*** 0 ****
--- 1,16 ----
+ // Build don't link:
+ // crash test - XFAIL *-*-*
+ 
+ // by Paul Burchard <burchard@pobox.com>, Level Set Systems, Inc.
+ // Copyright (C) 1999 Free Software Foundation
+ 
+ class Q {
+ 	template<class>
+ 	class X {
+ 	};
+ };
+ template<template<class> class>
+ class Y {
+ };
+ Y<typename Q::X> y; // ERROR - typename out of template context
+ 
*** /dev/null	Tue May  5 13:32:27 1998
--- gcc/testsuite/g++.pt/lss-006.cc	Wed Aug 11 18:08:27 1999
***************
*** 0 ****
--- 1,16 ----
+ // Build don't link:
+ // crash test - XFAIL *-*-*
+ 
+ // by Paul Burchard <burchard@pobox.com>, Level Set Systems, Inc.
+ // Copyright (C) 1999 Free Software Foundation
+ 
+ class Q {
+ 	template<class>
+ 	class X {
+ 	};
+ };
+ template<template<class> class>
+ class Y {
+ };
+ Q::template X<int> x; // ERROR - template syntax
+ 
*** /dev/null	Tue May  5 13:32:27 1998
--- gcc/testsuite/g++.pt/lss-007.cc	Wed Aug 11 18:10:20 1999
***************
*** 0 ****
--- 1,18 ----
+ // Build don't link:
+ // crash test - XFAIL *-*-*
+ // 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)); // ERROR - ANSI C++ forbids in-class initialization of non-const static member `x'
+ };
+ Y<int> y;
+ 
*** /dev/null	Tue May  5 13:32:27 1998
--- gcc/testsuite/g++.pt/lss-008.cc	Wed Aug 11 18:12:48 1999
***************
*** 0 ****
--- 1,16 ----
+ // Build don't link:
+ // crash test - XFAIL *-*-*
+ 
+ // 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> // gets bogus error - (original definition appeared here)
+ 	class Y {
+ 	}; // gets bogus error - redefinition of default argument for `template <class> XX'
+ 	Y<> y;
+ };
+ 
*** /dev/null	Tue May  5 13:32:27 1998
--- gcc/testsuite/g++.pt/lss-009.cc	Wed Aug 11 18:13:33 1999
***************
*** 0 ****
--- 1,17 ----
+ // Build don't link:
+ // crash test - XFAIL *-*-*
+ 
+ // by Paul Burchard <burchard@pobox.com>, Level Set Systems, Inc.
+ // Copyright (C) 1999 Free Software Foundation
+ 
+ class Q {
+ 	template<class T>
+ 	class X {
+ 	};
+ };
+ template<template<class> class XX>
+ class Y {
+ 	XX<int> x_;
+ };
+ Y<Q::X> y;
+ 
*** /dev/null	Tue May  5 13:32:27 1998
--- gcc/testsuite/g++.pt/lss-010.cc	Wed Aug 11 18:04:14 1999
***************
*** 0 ****
--- 1,19 ----
+ // Build don't link:
+ // 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; // gets bogus error - B is not a template - XFAIL *-*-*
+ 			// but removing wrapper A gets rid of complaint
+ 			// also, replacing B<T> with A::B<T> also gets rid of complaint
+ 	};
+ };
+ 
*** /dev/null	Tue May  5 13:32:27 1998
--- gcc/testsuite/g++.pt/lss-011.cc	Wed Aug 11 17:59:45 1999
***************
*** 0 ****
--- 1,20 ----
+ // Build don't link:
+ // crash test - XFAIL *-*-*
+ // 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() {}
+ 	};
+ };
+ 
+ 

-- 
----------------------------------------------------------------------
Paul Burchard   <burchard@pobox.com>   http://www.pobox.com/~burchard/
----------------------------------------------------------------------


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]