diff options
author | Nathan Sidwell <nathan@codesourcery.com> | 2001-12-12 10:32:03 +0000 |
---|---|---|
committer | Nathan Sidwell <nathan@gcc.gnu.org> | 2001-12-12 10:32:03 +0000 |
commit | ad1a6d451fc204825c147a83195b545e6ac3f423 (patch) | |
tree | 99b2a32054b3589da751ba02c5758f319cb48548 /gcc | |
parent | 3f2c5d1a0d08e8d9b3048a71c56de9ddc4293924 (diff) | |
download | gcc-ad1a6d451fc204825c147a83195b545e6ac3f423.zip gcc-ad1a6d451fc204825c147a83195b545e6ac3f423.tar.gz gcc-ad1a6d451fc204825c147a83195b545e6ac3f423.tar.bz2 |
extend.texi (Deprecated Features): Deprecate implicit typename.
* doc/extend.texi (Deprecated Features): Deprecate implicit
typename. Document that named return and initializer lists are now
removed.
cp:
* decl.c (grokdeclarator): Deprecated implicit typename use.
testsuite:
* g++.old-deja/g++.brendan/crash56.C: Adjust implicit typename.
* g++.old-deja/g++.jason/2371.C: Likewise.
* g++.old-deja/g++.jason/template33.C: Likewise.
* g++.old-deja/g++.jason/template34.C: Likewise.
* g++.old-deja/g++.jason/template36.C: Likewise.
* g++.old-deja/g++.oliva/typename1.C: Likewise.
* g++.old-deja/g++.oliva/typename2.C: Likewise.
* g++.old-deja/g++.other/typename1.C: Likewise.
* g++.old-deja/g++.pt/inherit2.C: Likewise.
* g++.old-deja/g++.pt/nontype5.C: Likewise.
* g++.old-deja/g++.pt/typename11.C: Likewise.
* g++.old-deja/g++.pt/typename14.C: Likewise.
* g++.old-deja/g++.pt/typename16.C: Likewise.
* g++.old-deja/g++.pt/typename3.C: Likewise.
* g++.old-deja/g++.pt/typename4.C: Likewise.
* g++.old-deja/g++.pt/typename5.C: Likewise.
* g++.old-deja/g++.pt/typename7.C: Likewise.
* g++.old-deja/g++.robertl/eb9.C: Likewise.
From-SVN: r47927
Diffstat (limited to 'gcc')
22 files changed, 161 insertions, 67 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 430f628..8aa25f0 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2001-12-12 Nathan Sidwell <nathan@codesourcery.com> + + * doc/extend.texi (Deprecated Features): Deprecate implicit + typename. Document that named return and initializer lists are now + removed. + 2001-12-11 Roger Sayle <roger@eyesopen.com> * except.c (reachable_next_level): Handle ERT_UNKNOWN to avoid diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 7118688..0676fb1 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,7 @@ +2001-12-12 Nathan Sidwell <nathan@codesourcery.com> + + * decl.c (grokdeclarator): Deprecated implicit typename use. + 2001-12-11 Nathan Sidwell <nathan@codesourcery.com> PR g++/51 diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 690e34c..30050fe 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -10137,6 +10137,21 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist) type = integer_type_node; } + + if (type && TREE_CODE (type) == TYPENAME_TYPE && TREE_TYPE (type)) + { + /* The implicit typename extension is deprecated and will be + removed. Warn about its use now. */ + cp_warning ("`%T' is implicitly a typename", type); + cp_deprecated ("implicit typename"); + + /* Now remove its implicitness, so that we don't warn again. + For instance this might be a typedef, and we do not want to + warn on uses of the typedef itself. Simply clearing the + TREE_TYPE is insufficient. */ + type = copy_node (type); + TREE_TYPE (type) = NULL_TREE; + } ctype = NULL_TREE; diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi index 10524a5..80addd3 100644 --- a/gcc/doc/extend.texi +++ b/gcc/doc/extend.texi @@ -5450,11 +5450,19 @@ parameters, as C++ demands. This feature has been removed, except where it is required for backwards compatibility @xref{Backwards Compatibility}. @end table -The named return value extension has been deprecated, and will be -removed from g++ at some point. +The named return value extension has been deprecated, and is now +removed from g++. The use of initializer lists with new expressions has been deprecated, -and will be removed from g++ at some point. +and is now removed from g++. + +Floating and complex non-type template parameters have been deprecated, +and are now removed from g++. + +The implicit typename extension has been deprecated and will be removed +from g++ at some point. In some cases g++ determines that a dependant +type such as @code{TPL<T>::X} is a type without needing a +@code{typename} keyword, contrary to the standard. @node Backwards Compatibility @section Backwards Compatibility @@ -5477,7 +5485,7 @@ the end of the scope which contained the for statement (rather than just within the for scope). G++ retains this, but issues a warning, if such a variable is accessed outside the for scope. -@item implicit C language +@item Implicit C language Old C system header files did not contain an @code{extern "C" @{@dots{}@}} scope to set the language. On such systems, all header files are implicitly scoped inside a C language scope. Also, an empty prototype diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 1ff35b2..534af00 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,24 @@ +2001-12-12 Nathan Sidwell <nathan@codesourcery.com> + + * g++.old-deja/g++.brendan/crash56.C: Adjust implicit typename. + * g++.old-deja/g++.jason/2371.C: Likewise. + * g++.old-deja/g++.jason/template33.C: Likewise. + * g++.old-deja/g++.jason/template34.C: Likewise. + * g++.old-deja/g++.jason/template36.C: Likewise. + * g++.old-deja/g++.oliva/typename1.C: Likewise. + * g++.old-deja/g++.oliva/typename2.C: Likewise. + * g++.old-deja/g++.other/typename1.C: Likewise. + * g++.old-deja/g++.pt/inherit2.C: Likewise. + * g++.old-deja/g++.pt/nontype5.C: Likewise. + * g++.old-deja/g++.pt/typename11.C: Likewise. + * g++.old-deja/g++.pt/typename14.C: Likewise. + * g++.old-deja/g++.pt/typename16.C: Likewise. + * g++.old-deja/g++.pt/typename3.C: Likewise. + * g++.old-deja/g++.pt/typename4.C: Likewise. + * g++.old-deja/g++.pt/typename5.C: Likewise. + * g++.old-deja/g++.pt/typename7.C: Likewise. + * g++.old-deja/g++.robertl/eb9.C: Likewise. + 2001-12-11 Nathan Sidwell <nathan@codesourcery.com> * g++.dg/other/linkage1.C: New test. diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash56.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash56.C index b5e997c..4aeb330 100644 --- a/gcc/testsuite/g++.old-deja/g++.brendan/crash56.C +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash56.C @@ -140,10 +140,13 @@ public: ListD<T>::length; ListD<T>::empty; ListD<T>::clear; - typedef ListD<T>::Vix Vix; + typedef typename ListD<T>::Vix Vix; ListD<T>::first; ListD<T>::next; ListD<T>::operator(); + + using ListD<T>::NORMAL; + using ListD<T>::REMOVE_CURRENT; }; extern "C" { extern void __eprintf (const char *, const char *, unsigned, const char *); @@ -255,7 +258,7 @@ template<class T> void SetLD<T>::add(const ListD<T>& other) { - ListD<T>::Vix x; + typename ListD<T>::Vix x; for (first(x); 0 != x; next(x)) add(other(x)); } @@ -270,7 +273,7 @@ template<class T> void SetLD<T>::remove(const T& item) { - Action a = NORMAL; + typename ListD<T>::Action a = NORMAL; Vix x; for (first(x); 0 != x && REMOVE_CURRENT != a; next(x, a)) a = operator()(x) == item ? REMOVE_CURRENT: NORMAL;// ERROR - .* @@ -292,7 +295,7 @@ operator==(const SetLD<T>& a, const SetLD<T>& b) { if (a.length() != b.length()) return FALSE; - SetLD<T>::Vix x; + typename SetLD<T>::Vix x; for (a.first(x); 0 != x; a.next(x)) { if ( ! b.contains(a(x)) ) return FALSE; @@ -313,7 +316,7 @@ operator<=(const SetLD<T>& a, const SetLD<T>& b) { if (a.length() > b.length()) return FALSE; - SetLD<T>::Vix x; + typename SetLD<T>::Vix x; for (x=a.first(); 0 != x; a.next(x)) { if ( ! b.contains(a(x)) ) return FALSE; diff --git a/gcc/testsuite/g++.old-deja/g++.jason/2371.C b/gcc/testsuite/g++.old-deja/g++.jason/2371.C index a982d40..70ca054 100644 --- a/gcc/testsuite/g++.old-deja/g++.jason/2371.C +++ b/gcc/testsuite/g++.old-deja/g++.jason/2371.C @@ -1,4 +1,3 @@ -# 1 "SetLS.cc" // GROUPS passed templates nested-classes // Special g++ Options: // @@ -14,7 +13,6 @@ #include <iostream> using namespace std; -# 1 "../../templates/SetLS.h" 1 // -*- C++ -*- @@ -38,10 +36,8 @@ using namespace std; #define XTRUE true #define XFALSE false -# 37 "../../templates/SetLS.h" -# 1 "../../templates/ListS.h" 1 // -*- C++ -*- @@ -63,7 +59,6 @@ using namespace std; -# 1 "/projects/gnu-cygnus/gnu-cygnus-14/mips/lib/gcc-lib/decstation/cygnus-reno-1/g++-include/bool.h" 1 3 // Defining XTRUE and XFALSE is usually a Bad Idea, // because you will probably be inconsistent with anyone // else who had the same clever idea. @@ -77,9 +72,7 @@ using namespace std; -# 23 "../../templates/ListS.h" 2 -# 37 "../../templates/ListS.h" @@ -189,7 +182,6 @@ public: { check(x); return x.index->item; } protected: -# 154 "../../templates/ListS.h" unsigned count; @@ -320,10 +312,8 @@ ListS<T>::remove_head_filling(T* fill) } -# 40 "../../templates/SetLS.h" 2 -# 62 "../../templates/SetLS.h" template<class T> class SetLS { @@ -361,11 +351,11 @@ public: private: friend class SetLS<T>; - Vix(const SetLS<T> *o, const ListS<T>::Vix& x): owner(o), vix(x) + Vix(const SetLS<T> *o, const typename ListS<T>::Vix& x): owner(o), vix(x) { } const SetLS<T> *owner; - ListS<T>::Vix vix; + typename ListS<T>::Vix vix; }; friend class Vix; @@ -422,7 +412,6 @@ SetLS<T>::contains(const T& item) const } -# 17 "SetLS.cc" 2 diff --git a/gcc/testsuite/g++.old-deja/g++.jason/template33.C b/gcc/testsuite/g++.old-deja/g++.jason/template33.C index 35a63aa..1ceb56b 100644 --- a/gcc/testsuite/g++.old-deja/g++.jason/template33.C +++ b/gcc/testsuite/g++.old-deja/g++.jason/template33.C @@ -12,6 +12,6 @@ public: }; template <class T> -A<T>::muni A<T>::f() { return X; } +typename A<T>::muni A<T>::f() { return X; } template class A<int>; diff --git a/gcc/testsuite/g++.old-deja/g++.jason/template34.C b/gcc/testsuite/g++.old-deja/g++.jason/template34.C index 177286f..e601b1e 100644 --- a/gcc/testsuite/g++.old-deja/g++.jason/template34.C +++ b/gcc/testsuite/g++.old-deja/g++.jason/template34.C @@ -14,7 +14,7 @@ int gen_cmp(const T& a, const T& b) { } template<class T> -Set<T>::Compare Set<T>::cmp1 = &gen_cmp; +typename Set<T>::Compare Set<T>::cmp1 = &gen_cmp; template<class T> int (*Set<T>::cmp2)(const T&, const T&) = &gen_cmp; diff --git a/gcc/testsuite/g++.old-deja/g++.jason/template36.C b/gcc/testsuite/g++.old-deja/g++.jason/template36.C index 807af75..04d3160 100644 --- a/gcc/testsuite/g++.old-deja/g++.jason/template36.C +++ b/gcc/testsuite/g++.old-deja/g++.jason/template36.C @@ -18,6 +18,7 @@ struct base_trait { typedef base1 base; }; +template<> struct base_trait<float> { typedef base2 base; }; @@ -25,7 +26,7 @@ struct base_trait<float> { template<class T> class weird : public base_trait<T>::base { public: - typedef base_trait<T>::base base; + typedef typename base_trait<T>::base base; base f (); int base::* g (); @@ -35,14 +36,18 @@ public: }; template <class T> -weird<T>::base weird<T>::f () +typename weird<T>::base weird<T>::f () { return base(); } +// The standard does not allow this case; the `typename' keyword may +// not appear in a ptr-operator. +#if 0 template <class T> -int weird<T>::base::* weird<T>::g () +int typename weird<T>::base::* weird<T>::g () { return 0; } +#endif int main() { diff --git a/gcc/testsuite/g++.old-deja/g++.oliva/typename1.C b/gcc/testsuite/g++.old-deja/g++.oliva/typename1.C index d46ec60..bd536e3 100644 --- a/gcc/testsuite/g++.old-deja/g++.oliva/typename1.C +++ b/gcc/testsuite/g++.old-deja/g++.oliva/typename1.C @@ -12,6 +12,5 @@ template <class T> struct bar { }; template <class T> struct baz { - typedef bar<T>::foo foo; // ERROR - missing typename - XFAIL *-*-* - void m(foo); + typedef bar<T>::foo foo; // ERROR - missing typename }; diff --git a/gcc/testsuite/g++.old-deja/g++.other/typename1.C b/gcc/testsuite/g++.old-deja/g++.other/typename1.C index 2921b3d..271fd57 100644 --- a/gcc/testsuite/g++.old-deja/g++.other/typename1.C +++ b/gcc/testsuite/g++.old-deja/g++.other/typename1.C @@ -2,7 +2,7 @@ // Based on a test case by Louidor Erez <s3824888@techst02.technion.ac.il> // Build don't link: -// Special g++ Options: -pedantic +// Special g++ Options: -pedantic -Wno-deprecated template<class T> class Vector { @@ -13,5 +13,5 @@ public: template<class T> void f() { - Vector<T>::iterator i = 0; // ERROR - missing typename - XFAIL *-*-* + Vector<T>::iterator i = 0; // WARNING - missing typename } diff --git a/gcc/testsuite/g++.old-deja/g++.pt/inherit2.C b/gcc/testsuite/g++.old-deja/g++.pt/inherit2.C index 5198a64..30cbebe 100644 --- a/gcc/testsuite/g++.old-deja/g++.pt/inherit2.C +++ b/gcc/testsuite/g++.old-deja/g++.pt/inherit2.C @@ -1,20 +1,67 @@ -// Test that we warn about unqualified references to implicit typenames. - -// Special g++ Options: // Build don't link: -template <class T> struct A { - struct AA { }; - struct AB { }; - struct AC { }; +// 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;// ERROR - private - XFAIL *-*-* +template <typename T> T B<T>::value_AC; // gets bogus error - XFAIL *-*-* + +// 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; // ERROR - within this context - XFAIL *-*-* + } }; -template <class T> struct B: public A<T> { - friend struct B::AA; // OK - friend AB; // WARNING - needs class-key - friend struct AC; // WARNING - refers to ::AC +// this is a friend +struct AC +{ + int M () + { + return B<int>::value_AC; // gets bogus error - XFAIL *-*-* + } }; B<int> b; +A<int>::AA a_aa; +A<int>::AC a_ac; +AC ac; -int main () { } +int main () +{ + a_aa.M (); + a_ac.M (); + ac.M (); +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/nontype5.C b/gcc/testsuite/g++.old-deja/g++.pt/nontype5.C index 1268f05..ada6bb1 100644 --- a/gcc/testsuite/g++.old-deja/g++.pt/nontype5.C +++ b/gcc/testsuite/g++.old-deja/g++.pt/nontype5.C @@ -11,13 +11,13 @@ struct A { typedef int F(); }; -template<class T, A<T>::F f> +template<class T, typename A<T>::F f> struct B { static int g() { return f(); }; }; -int f() { return 0; }; +int f() { return 0; } int main() { return B<int,&f>::g(); // ERROR - could not convert arg -}; +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/typename11.C b/gcc/testsuite/g++.old-deja/g++.pt/typename11.C index 41774a3..cfc9f13 100644 --- a/gcc/testsuite/g++.old-deja/g++.pt/typename11.C +++ b/gcc/testsuite/g++.old-deja/g++.pt/typename11.C @@ -1,5 +1,5 @@ // Build don't link: -// Special g++ Options: +// Special g++ Options: -Wno-deprecated template <class T, int I> struct S { @@ -7,8 +7,7 @@ struct S { }; template <class T, class U, int I> -S<T,I>::X f(T, U) -{ +S<T,I>::X f(T, U) { // WARNING - implicit typename S<T, I>::X(); return S<T, I>::X(); } diff --git a/gcc/testsuite/g++.old-deja/g++.pt/typename14.C b/gcc/testsuite/g++.old-deja/g++.pt/typename14.C index 7365b66..d2783ab 100644 --- a/gcc/testsuite/g++.old-deja/g++.pt/typename14.C +++ b/gcc/testsuite/g++.old-deja/g++.pt/typename14.C @@ -1,5 +1,5 @@ // Build don't link: -// Special g++ Options: +// Special g++ Options: -Wno-deprecated template <class T> struct B { @@ -10,6 +10,6 @@ template <class T> struct S : public B<T> { struct I { - void f(X x); + void f(X x); // WARNING - implicit typename }; }; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/typename16.C b/gcc/testsuite/g++.old-deja/g++.pt/typename16.C index 51a8765..225cc89 100644 --- a/gcc/testsuite/g++.old-deja/g++.pt/typename16.C +++ b/gcc/testsuite/g++.old-deja/g++.pt/typename16.C @@ -1,5 +1,5 @@ // Build don't run: -// Special g++ Options: +// Special g++ Options: -Wno-deprecated struct B { typedef int I; @@ -11,7 +11,7 @@ struct D1 : public B { template <class T> struct D2 : public D1<T> { - I i; + I i; // WARNING - implicit typename }; template <> diff --git a/gcc/testsuite/g++.old-deja/g++.pt/typename3.C b/gcc/testsuite/g++.old-deja/g++.pt/typename3.C index 55d6430..8aea446 100644 --- a/gcc/testsuite/g++.old-deja/g++.pt/typename3.C +++ b/gcc/testsuite/g++.old-deja/g++.pt/typename3.C @@ -1,5 +1,5 @@ // Build don't link: -// Special g++ Options: +// Special g++ Options: -Wno-deprecated template <class T> struct A @@ -11,11 +11,10 @@ struct A template <class U> struct B : public A<U> { - A_Type Func(); + A_Type Func(); // WARNING - implicit typename }; template <class U> -B<U>::A_Type B<U>::Func() -{ +B<U>::A_Type B<U>::Func() { // WARNING - implicit typename } diff --git a/gcc/testsuite/g++.old-deja/g++.pt/typename4.C b/gcc/testsuite/g++.old-deja/g++.pt/typename4.C index 6f9362f..07719e0 100644 --- a/gcc/testsuite/g++.old-deja/g++.pt/typename4.C +++ b/gcc/testsuite/g++.old-deja/g++.pt/typename4.C @@ -1,5 +1,5 @@ // Build don't link: -// Special g++ Options: +// Special g++ Options: -Wno-deprecated template <class T> struct A @@ -17,11 +17,10 @@ struct B : public A<U> template <class U> struct C : public B<U> { - A_Type Func(); + A_Type Func(); // WARNING - implicit typename }; template <class U> -C<U>::A_Type C<U>::Func() -{ +C<U>::A_Type C<U>::Func() { // WARNING - implicit typename } diff --git a/gcc/testsuite/g++.old-deja/g++.pt/typename5.C b/gcc/testsuite/g++.old-deja/g++.pt/typename5.C index e967d14..bbf4af7 100644 --- a/gcc/testsuite/g++.old-deja/g++.pt/typename5.C +++ b/gcc/testsuite/g++.old-deja/g++.pt/typename5.C @@ -1,5 +1,5 @@ // Build don't link: -// Special g++ Options: +// Special g++ Options: -Wno-deprecated template <class T> struct A @@ -17,11 +17,10 @@ struct B : public A<U> template <class U> struct C : public B<U> { - void Func(A_Type); + void Func(A_Type); // WARNING - implicit typename }; template <class U> -void C<U>::Func(A_Type) -{ +void C<U>::Func(A_Type) { // WARNING - implicit typename } diff --git a/gcc/testsuite/g++.old-deja/g++.pt/typename7.C b/gcc/testsuite/g++.old-deja/g++.pt/typename7.C index 5c89603..6b4ef22 100644 --- a/gcc/testsuite/g++.old-deja/g++.pt/typename7.C +++ b/gcc/testsuite/g++.old-deja/g++.pt/typename7.C @@ -15,6 +15,6 @@ template <class T> struct D : public A <C <T> > { void f () { - B* new_entries = (B *) 0; + B* new_entries = (B *) 0; // WARNING - implicit typename } }; diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb9.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb9.C index cec7002..968c942 100644 --- a/gcc/testsuite/g++.old-deja/g++.robertl/eb9.C +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb9.C @@ -15,7 +15,8 @@ public: template <class Key> -d0om_Hashmap<Key>::value_type* d0om_Hashmap<Key>::iterator::operator-> () const +typename d0om_Hashmap<Key>::value_type* +d0om_Hashmap<Key>::iterator::operator-> () const { return 0; } |