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/g++.pt | |
download | cbb-gcc-4.6.4-upstream.tar.bz2 cbb-gcc-4.6.4-upstream.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/g++.pt')
740 files changed, 14687 insertions, 0 deletions
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>(); +} |