From: Jason Merrill Date: Tue, 20 Jan 1998 00:57:39 +0000 (-0500) Subject: tests from mark X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a6475d981a93c26c665ae66278524bcc13c5852d;p=platform%2Fupstream%2Fgcc.git tests from mark From-SVN: r17427 --- diff --git a/gcc/testsuite/g++.old-deja/g++.mike/p5840.C b/gcc/testsuite/g++.old-deja/g++.mike/p5840.C index 46a161b..53b9510 100644 --- a/gcc/testsuite/g++.old-deja/g++.mike/p5840.C +++ b/gcc/testsuite/g++.old-deja/g++.mike/p5840.C @@ -17,17 +17,19 @@ public: int value (Foo* a) { return (a->*Id)(); } }; -template class Bar ; +/* The following line is illegal under the new rules for non-type + template arguments in the standard, so it is commented out. */ +/* template class Bar ; */ template class Bar ; template class Bar ; Derived a; -Bar dispatcher1; +/* Bar dispatcher1; */ Bar dispatcher2; main() { - int i1 = dispatcher1.value(&a); + /* int i1 = dispatcher1.value(&a); */ int i2 = dispatcher2.value(&a); - return i1 != 1 || i2 != 2; + return /* i1 != 1 || */ i2 != 2; } diff --git a/gcc/testsuite/g++.old-deja/g++.mike/pt3.C b/gcc/testsuite/g++.old-deja/g++.mike/pt3.C index b2abc2bd..a61d902 100644 --- a/gcc/testsuite/g++.old-deja/g++.mike/pt3.C +++ b/gcc/testsuite/g++.old-deja/g++.mike/pt3.C @@ -15,11 +15,14 @@ syHandle::~syHandle() } typedef char * char_ptr_t; + +template <> syHandle::syHandle() { _repr = 0; } +template <> syHandle::~syHandle() { _repr = 0; diff --git a/gcc/testsuite/g++.old-deja/g++.mike/pt4.C b/gcc/testsuite/g++.old-deja/g++.mike/pt4.C index 00e8ad0..7c1563e 100644 --- a/gcc/testsuite/g++.old-deja/g++.mike/pt4.C +++ b/gcc/testsuite/g++.old-deja/g++.mike/pt4.C @@ -1,4 +1,4 @@ // Build don't link: template struct B { B() { } }; -B<0> bnull; +B<0> bnull; // ERROR - could not convert template argument diff --git a/gcc/testsuite/g++.old-deja/g++.other/static1.C b/gcc/testsuite/g++.old-deja/g++.other/static1.C new file mode 100644 index 0000000..c18e55c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/static1.C @@ -0,0 +1,8 @@ +extern "C" void abort(); + +struct S +{ + static const int i = 3; +}; + +const int S::i = 2; // ERROR - duplicate initialization 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 0000000..6b22b86 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/bad-type.C @@ -0,0 +1,19 @@ +template +class A +{ +public: + Type m; +}; + +template +void f(A& a, Type d) +{ + A.m=d; // ERROR - invalid use of template +} + +int main() +{ + A a; + f(a,2); +} + diff --git a/gcc/testsuite/g++.old-deja/g++.pt/explicit32.C b/gcc/testsuite/g++.old-deja/g++.pt/explicit32.C index 7c0e285..5942fe7 100644 --- a/gcc/testsuite/g++.old-deja/g++.pt/explicit32.C +++ b/gcc/testsuite/g++.old-deja/g++.pt/explicit32.C @@ -12,7 +12,7 @@ struct S void foo(); }; -template <> + void S::foo() { } diff --git a/gcc/testsuite/g++.old-deja/g++.pt/explicit34.C b/gcc/testsuite/g++.old-deja/g++.pt/explicit34.C index 40c1da0..487525e 100644 --- a/gcc/testsuite/g++.old-deja/g++.pt/explicit34.C +++ b/gcc/testsuite/g++.old-deja/g++.pt/explicit34.C @@ -4,7 +4,7 @@ template void foo(T t); template <> -void foo(int) {}; // ERROR - redefinition. +void foo(int) {}; template <> -void foo(int) {} // ERROR - redefinition. +void foo(int) {} // ERROR - duplicate specialization. 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 0000000..27121b6 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/explicit38.C @@ -0,0 +1,7 @@ +template +void f(int j); + +void g() +{ + f<7, 12>(3); // ERROR - no matching function. +} 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 0000000..906ef30 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/explicit39.C @@ -0,0 +1,7 @@ +template +void f(int i); + +void g() +{ + f<7>(3); // ERROR - no matching function. +} 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 0000000..d237924 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/explicit40.C @@ -0,0 +1,27 @@ +extern "C" void abort(); + +template +void f(int j); + +template +void f(int j); + + +template +void f(int j) +{ + abort(); +} + + +template +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 0000000..b5ca475 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/explicit41.C @@ -0,0 +1,8 @@ +template +void f(int i); + +void g() +{ + int i; + f(7); // ERROR - template argument 1 is invalid. +} 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 0000000..c19ffd0 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/explicit42.C @@ -0,0 +1,17 @@ +extern "C" void abort(void); + +template +void f(int i) +{ +} + +template +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 0000000..6396f09 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/explicit43.C @@ -0,0 +1,23 @@ +extern "C" void abort(void); + +void F(int) +{ +} + + +void F(double) +{ + abort(); +} + +template +void g() +{ + (*F)(3); +} + + +int main() +{ + g<&F>(); +} 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 0000000..1d9c758 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/instantiate1.C @@ -0,0 +1,22 @@ +// Build don't link: + +template +void f(T t); + +template void f(int); +template void f<>(long); + +template +struct S +{ + void bar(int) {} + + template + void baz(U u) {} +}; + + +template S; +template void S::bar(int); +template void S::baz(short); +template void S::baz<>(char); 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 0000000..1b9e515 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/local1.C @@ -0,0 +1,21 @@ +template inline STRUCT * +setback(MEMBER *bp, MEMBER STRUCT::*offset) +{ + if(!bp) return 0; + union { int i; MEMBER STRUCT::*of; } u; + u.of = offset; + return (STRUCT *) ((int) 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 0000000..4aafc69 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/local2.C @@ -0,0 +1,20 @@ +extern "C" void abort(); + +template +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 0000000..58c2627 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/local3.C @@ -0,0 +1,22 @@ +extern "C" void abort(); + +template +void f(T) +{ + struct S { + int i; + }; + + S s; + + s.i = 3; + + if (s.i != 3) + 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 0000000..6a7eb341 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/local4.C @@ -0,0 +1,25 @@ +extern "C" void abort(); + +template +struct S {}; + +S si; + +template +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 0000000..b49525c --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/local5.C @@ -0,0 +1,24 @@ +template +class b +{ +private: + char a(int x) + { + union { + int i; + char c; + } val; + val.i = x; + return val.c; + }; + +public: + b() { + } +}; + +int main() { + b n; + return 0; +} + diff --git a/gcc/testsuite/g++.old-deja/g++.pt/memtemp28.C b/gcc/testsuite/g++.old-deja/g++.pt/memtemp28.C index ab3ce2d..37e79c8 100644 --- a/gcc/testsuite/g++.old-deja/g++.pt/memtemp28.C +++ b/gcc/testsuite/g++.old-deja/g++.pt/memtemp28.C @@ -1,17 +1,17 @@ -// Build don't run: -// GROUPS passed templates membertemplates -extern "C" int printf(const char*, ...); +extern "C" void abort(); + +int k; template struct S { template void f(U u) - { printf ("In S::f(U)\n"); g(u); } + { ++k; g(u); } template void g(U u) - { printf ("In S::g(U)\n"); } + { ++k; } int c[16]; }; @@ -21,4 +21,7 @@ int main() S s; s.f(3); s.f("adf"); + + if (k != 4) + abort(); } 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 0000000..ef49d84 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/memtemp65.C @@ -0,0 +1,23 @@ +// Build don't link: + +template struct PartialDotProduct { + template + static T Expand(T* a, T* b) { return T(); } +}; + +const int N = 10; + +template +void +dot(In1 f1, In2 f2) +{ + PartialDotProduct::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 0000000..d7c1f57 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/memtemp66.C @@ -0,0 +1,15 @@ +// Build don't link: + +template +struct S +{ + template + void f(U u) { this->template f<>(3); } +}; + + +void g() +{ + S 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 0000000..bcf5960 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/memtemp67.C @@ -0,0 +1,19 @@ +template +struct A +{ + template + operator A() const { return A(); } +}; + +main() +{ + A a1; + A a2; + A a3; + A a4; + + a2 = a1.operator A(); + a3 = (A) a1; + a4 = a1; +} + 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 0000000..7efaeb0 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/recursion.C @@ -0,0 +1,31 @@ +// Build don't link: + +const double M_PI=3.14159265358979323846; + +template +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(); +} + +template<> +inline double SineSeries<0,0,0,0>() +{ + return 1.0; +} + +template +inline double Sine() +{ + const double x=(I*2*M_PI/N); + return x * SineSeries(); +} + +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 0000000..8cb3a2b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/recursion2.C @@ -0,0 +1,25 @@ +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/spec10.C b/gcc/testsuite/g++.old-deja/g++.pt/spec10.C new file mode 100644 index 0000000..10947aa --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/spec10.C @@ -0,0 +1,26 @@ +extern "C" void abort(); + +template +struct S +{ + template + int f(int j) { abort(); return 0; } + + template <> + int f<7>(int j) { return j + 7; } + + template <> + int f<8>(int j) { return j + 8; } +}; + + +int main() +{ + S s; + + if (s.template f<7>(3) != 10) + abort(); + + if (s.template 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 0000000..4369f18 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/spec11.C @@ -0,0 +1,20 @@ +extern "C" void abort(); + +template +struct S +{ + template + int f(U u); +}; + +template +template <> +int S::f(int i) { return 1; } + +int main() +{ + S sc; + + if (sc.f(3) != 1) + abort(); +} 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 0000000..338c69e --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/spec2.C @@ -0,0 +1,27 @@ +// Build don't link: + +class X +{ + public: + virtual void f() const = 0; +}; + +template +class Y: public X +{ + public: + virtual void f() const; +}; + +template +void Y::f() const +{ +} + +template <> +void Y::f() const; + +template <> +void Y::f() const +{ +} 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 0000000..b0e710f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/spec3.C @@ -0,0 +1,37 @@ +extern "C" void abort(); + +class X +{ + public: + virtual int f() const = 0; +}; + +template +class Y: public X +{ + public: + virtual int f() const; +}; + +template +int Y::f() const +{ + abort(); + return 0; +} + +template <> +int Y::f() const; + +template <> +int Y::f() const +{ + return 0; +} + +int main() +{ + Y yb; + + yb.f(); +} 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 0000000..b6e6858 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/spec4.C @@ -0,0 +1,16 @@ +// Build don't link: + +template +struct S {}; + +template <> +struct S +{ + void f(); + void g(); +}; + +void S::f() {} + +template <> +void S::g() {} // ERROR - does not match any template declaration 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 0000000..553d956 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/spec5.C @@ -0,0 +1,20 @@ +// Build don't link: + +template +void f(T t1, T t2); + +template <> +void f(int i, int j); + +template +void g(T t1, T t2) {} + +template void g(int i, int j); + +void h() +{ + f(3, 'c'); // ERROR - no matching function + g(3, 'c'); // ERROR - no matching function +} + + 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 0000000..b41ad9d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/spec6.C @@ -0,0 +1,29 @@ +// Build don't link: + +struct S1 +{ + template + void f(T t1, T t2); + + template <> + void f(int i1, int i2); +}; + +template +struct S2 +{ + template + void f(T t1, T t2); + + template <> + void f(int i1, int i2); +}; + +void h() +{ + S1 s1; + s1.f(3, 'c'); // ERROR - no matching function + + S2 s2; + s2.f(3, 'c'); // ERROR - no matching function +} 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 0000000..81358d9 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/spec7.C @@ -0,0 +1,19 @@ +extern "C" void abort(); + +template +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 0000000..966f69f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/spec8.C @@ -0,0 +1,27 @@ +extern "C" void abort(); + +template +void f(int j); + +template +void f(int j); + + +template +void f(int j) +{ + abort(); +} + + +template +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 0000000..e2a2208 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/spec9.C @@ -0,0 +1,21 @@ +extern "C" void abort(); + +template +inline int f(T t) +{ + return 0; +} + +int main() +{ + if (!f(3)) + abort(); +} + +template <> +int f(int i) +{ // ERROR - specialization of f(int) after instantiation + return 1; +} + + 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 0000000..f4c334e --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/static_cast.C @@ -0,0 +1,22 @@ +// Build don't link: + +template +void accumulate(InputIterator first, + BinaryOperation binary_op) { +} + + +template int p( int val, R& r ) +{ + return val + r; +} + +template void f(R) +{ + accumulate(0, static_cast(p) ); +} + +main() +{ + f(0); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/typename3.C b/gcc/testsuite/g++.old-deja/g++.pt/typename3.C index 13a1fcc..4a8f05b 100644 --- a/gcc/testsuite/g++.old-deja/g++.pt/typename3.C +++ b/gcc/testsuite/g++.old-deja/g++.pt/typename3.C @@ -1,17 +1,20 @@ // Build don't link: -// GROUPS passed templates + template -struct bar { - typedef typename T::baz baz; +struct A +{ + typedef T A_Type; }; -template -void foo(T) + +template +struct B : public A { - bar::baz(); // ERROR - T is int. -} + A_Type Func(); +}; + -void foobar() +template +A::A_Type B::Func() { - foo(3); }