From 554fd8c5195424bdbcabf5de30fdc183aba391bd Mon Sep 17 00:00:00 2001 From: upstream source tree Date: Sun, 15 Mar 2015 20:14:05 -0400 Subject: obtained gcc-4.6.4.tar.bz2 from upstream website; 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. --- gcc/testsuite/g++.old-deja/g++.benjamin/tem03.C | 209 ++++++++++++++++++++++++ 1 file changed, 209 insertions(+) create mode 100644 gcc/testsuite/g++.old-deja/g++.benjamin/tem03.C (limited to 'gcc/testsuite/g++.old-deja/g++.benjamin/tem03.C') diff --git a/gcc/testsuite/g++.old-deja/g++.benjamin/tem03.C b/gcc/testsuite/g++.old-deja/g++.benjamin/tem03.C new file mode 100644 index 000000000..fb9830e68 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.benjamin/tem03.C @@ -0,0 +1,209 @@ +// { dg-do assemble } +// 980808-980824 bkoz +// template parameter redeclaration bugs + +// 14.1 Template parameters +// p 13 +// The scope of a template-parameter extens from its point of +// declartion until the end of its template. In particular, a +// template-parameter can be used in the declaration of subsequent +// template-parameters and their default arguments. + +// 14.6.1 Locally declared names +// p 4 +// A template-parameter shall not be redeclared within its scope +// (including nested scopes). A template-parameter shall not have the +// sname name as the template name. + + +// 01 +// declared friend template +template // { dg-error "" } .* +class Xone { +protected: + T4* next; + T4* prev; + T4 value; +public: + Xone(): next(0), prev(0), value(1999){} + Xone(T4 init): value(init) {} + + // these are ok: + // can also do template-decl and then can ditch the foward-declaration + // template friend bool isequal (Xone& lhs, Xone& rhs); + // this is not ok: + template friend bool isequal (Xone& lhs, Xone& rhs);// { dg-error "" } .* +}; + + +// 02 +// nested template class +template // { dg-error "" } .* +class Xtwo { +protected: + T6* next; + T6* prev; + T6 value; +public: + Xtwo(): next(0), prev(0), value(1999){} + Xtwo(T6 init): value(init) {} + + template class nested {// { dg-error "" } .* + T6 value; + public: + nested(): value( T6(0)) {} + }; +}; + + +// 03 +// member templates +template // { dg-error "" } .* +class Xthree { +protected: + T8* next; + T8* prev; + T8 value; +public: + Xthree(): next(0), prev(0), value(1999){} + Xthree(T8 init): value(init) {} + + template T8 comp_ge(T8 test) {// { dg-error "" } .* + T8 local_value; + if (local_value > value) + return local_value; + else + return value; + } +}; + + +// 04 +// local names (14.6.1 p 4) +template struct Xfour {// { dg-error "" } .* + int T10; // { dg-error "" } .* + void f(){ + char T10; // { dg-error "declaration of 'char T10'" } + } +}; + + +// 05 +// using different tempate-parms for out-of-line defs +template struct Xfive { + void f(); +}; + +template void Xfive::f() {// { dg-error "" } .* + int T13; // { dg-error "" } .* + int T12; //should be ok +} + + +// 06 +// multiple names at the same level +template class Xsix { // { dg-error "" } .* +private: +public: + void f(); +}; + + +// 07 +// multiple names, one in template parameter one in class-name +template class T12; // { dg-error "" } .* + + +// 08 +// with multiple template params, and second (third) one is redeclared +template class Xseven { // { dg-error "" } .* +private: + char T161; // { dg-error "" } .* +public: + template + friend bool fooy(U u); + + template // { dg-error "declaration of 'class T161'" } + friend bool foo(T161 u) + { + Xseven obj; + return (obj.inst == u.inst); + } + +}; + + +// 09 +// check for correct scoping of member templates +template +struct S1 +{ + template + void f(U u) + { + S1 s2u(u); + s2u.g(); + } + + template //ok + void f2(U u) + { + S1 s2u(u); + s2u.g(); + } + +}; + + +// 10 +// check for non-type parameters, should still be able to redeclare? +// local names (14.6.1 p 4) +template class Xten {// { dg-error "" } .* + float i; // { dg-error "" } .* +}; + + +// 11 +// declared friend template, non-type parameters +template // { dg-error "" } .* +class Xeleven { +public: + template friend bool isequal (Xeleven<5> lhs, Xeleven<5> rhs); // { dg-error "" } .* +}; + + + +// 12 +// nested template class, non-type parameters +template // { dg-error "" } .* +class Xtwelve { +public: + template class nested {// { dg-error "" } . + long value; + public: + nested(): value(0) {} + }; +}; + + +// 13 +// member templates, non-type parameters +template // { dg-error "" } .* +struct Xthirteen { + template long comp_ge(long test) {// { dg-error "" } . + long local_value; + if (local_value > value) // { dg-error "" } .* + return local_value; + else + return value; + } +}; + + + + + + + + + -- cgit v1.2.3