From ad1a6d451fc204825c147a83195b545e6ac3f423 Mon Sep 17 00:00:00 2001 From: Nathan Sidwell Date: Wed, 12 Dec 2001 10:32:03 +0000 Subject: [PATCH] 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 --- gcc/ChangeLog | 6 ++ gcc/cp/ChangeLog | 4 ++ gcc/cp/decl.c | 15 ++++ gcc/doc/extend.texi | 16 +++-- gcc/testsuite/ChangeLog | 21 ++++++ .../g++.old-deja/g++.brendan/crash56.C | 13 ++-- gcc/testsuite/g++.old-deja/g++.jason/2371.C | 15 +--- .../g++.old-deja/g++.jason/template33.C | 2 +- .../g++.old-deja/g++.jason/template34.C | 2 +- .../g++.old-deja/g++.jason/template36.C | 11 ++- .../g++.old-deja/g++.oliva/typename1.C | 3 +- .../g++.old-deja/g++.other/typename1.C | 4 +- gcc/testsuite/g++.old-deja/g++.pt/inherit2.C | 71 +++++++++++++++---- gcc/testsuite/g++.old-deja/g++.pt/nontype5.C | 6 +- .../g++.old-deja/g++.pt/typename11.C | 5 +- .../g++.old-deja/g++.pt/typename14.C | 4 +- .../g++.old-deja/g++.pt/typename16.C | 4 +- gcc/testsuite/g++.old-deja/g++.pt/typename3.C | 7 +- gcc/testsuite/g++.old-deja/g++.pt/typename4.C | 7 +- gcc/testsuite/g++.old-deja/g++.pt/typename5.C | 7 +- gcc/testsuite/g++.old-deja/g++.pt/typename7.C | 2 +- gcc/testsuite/g++.old-deja/g++.robertl/eb9.C | 3 +- 22 files changed, 161 insertions(+), 67 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 430f628b36d..8aa25f0e958 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2001-12-12 Nathan Sidwell + + * doc/extend.texi (Deprecated Features): Deprecate implicit + typename. Document that named return and initializer lists are now + removed. + 2001-12-11 Roger Sayle * except.c (reachable_next_level): Handle ERT_UNKNOWN to avoid diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 71186885f32..0676fb14845 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,7 @@ +2001-12-12 Nathan Sidwell + + * decl.c (grokdeclarator): Deprecated implicit typename use. + 2001-12-11 Nathan Sidwell PR g++/51 diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 690e34c7a8d..30050fe0dea 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 10524a58363..80addd33160 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::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 1ff35b297dd..534af00eea3 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,24 @@ +2001-12-12 Nathan Sidwell + + * 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 * 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 b5e997cc6ee..4aeb330274d 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::length; ListD::empty; ListD::clear; - typedef ListD::Vix Vix; + typedef typename ListD::Vix Vix; ListD::first; ListD::next; ListD::operator(); + + using ListD::NORMAL; + using ListD::REMOVE_CURRENT; }; extern "C" { extern void __eprintf (const char *, const char *, unsigned, const char *); @@ -255,7 +258,7 @@ template void SetLD::add(const ListD& other) { - ListD::Vix x; + typename ListD::Vix x; for (first(x); 0 != x; next(x)) add(other(x)); } @@ -270,7 +273,7 @@ template void SetLD::remove(const T& item) { - Action a = NORMAL; + typename ListD::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& a, const SetLD& b) { if (a.length() != b.length()) return FALSE; - SetLD::Vix x; + typename SetLD::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& a, const SetLD& b) { if (a.length() > b.length()) return FALSE; - SetLD::Vix x; + typename SetLD::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 a982d4042e4..70ca0548aa4 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 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::remove_head_filling(T* fill) } -# 40 "../../templates/SetLS.h" 2 -# 62 "../../templates/SetLS.h" template class SetLS { @@ -361,11 +351,11 @@ public: private: friend class SetLS; - Vix(const SetLS *o, const ListS::Vix& x): owner(o), vix(x) + Vix(const SetLS *o, const typename ListS::Vix& x): owner(o), vix(x) { } const SetLS *owner; - ListS::Vix vix; + typename ListS::Vix vix; }; friend class Vix; @@ -422,7 +412,6 @@ SetLS::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 35a63aad3da..1ceb56b8c00 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 -A::muni A::f() { return X; } +typename A::muni A::f() { return X; } template class A; diff --git a/gcc/testsuite/g++.old-deja/g++.jason/template34.C b/gcc/testsuite/g++.old-deja/g++.jason/template34.C index 177286f4abb..e601b1e7d8c 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 -Set::Compare Set::cmp1 = &gen_cmp; +typename Set::Compare Set::cmp1 = &gen_cmp; template int (*Set::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 807af75e0d2..04d31602230 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 { typedef base2 base; }; @@ -25,7 +26,7 @@ struct base_trait { template class weird : public base_trait::base { public: - typedef base_trait::base base; + typedef typename base_trait::base base; base f (); int base::* g (); @@ -35,14 +36,18 @@ public: }; template -weird::base weird::f () +typename weird::base weird::f () { return base(); } +// The standard does not allow this case; the `typename' keyword may +// not appear in a ptr-operator. +#if 0 template -int weird::base::* weird::g () +int typename weird::base::* weird::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 d46ec603286..bd536e357b9 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 struct bar { }; template struct baz { - typedef bar::foo foo; // ERROR - missing typename - XFAIL *-*-* - void m(foo); + typedef bar::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 2921b3d3c02..271fd57acbc 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 // Build don't link: -// Special g++ Options: -pedantic +// Special g++ Options: -pedantic -Wno-deprecated template class Vector { @@ -13,5 +13,5 @@ public: template void f() { - Vector::iterator i = 0; // ERROR - missing typename - XFAIL *-*-* + Vector::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 5198a6436e2..30cbebe1a1e 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 struct A { - struct AA { }; - struct AB { }; - struct AC { }; +// Make sure we make the right unqualified class a friend +// See PR c++/4403 + +template struct A +{ + struct AA; + struct AC; +}; + +template class B + :public A +{ + 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::AC + + private: // only our friends can get out values + static T valueA_AA; + static T valueA_AC; + static T value_AC; +}; +template T B::valueA_AA; +template T B::valueA_AC;// ERROR - private - XFAIL *-*-* +template T B::value_AC; // gets bogus error - XFAIL *-*-* + +// this one is a friend +template struct A::AA +{ + int M () + { + return B::valueA_AA; + } +}; + +// this is not a friend +template struct A::AC +{ + T M () + { + return B::valueA_AC; // ERROR - within this context - XFAIL *-*-* + } }; -template struct B: public A { - 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::value_AC; // gets bogus error - XFAIL *-*-* + } }; B b; +A::AA a_aa; +A::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 1268f05bcef..ada6bb1db13 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::F f> +template::F f> struct B { static int g() { return f(); }; }; -int f() { return 0; }; +int f() { return 0; } int main() { return B::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 41774a3e0c8..cfc9f131ee9 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 struct S { @@ -7,8 +7,7 @@ struct S { }; template -S::X f(T, U) -{ +S::X f(T, U) { // WARNING - implicit typename S::X(); return S::X(); } diff --git a/gcc/testsuite/g++.old-deja/g++.pt/typename14.C b/gcc/testsuite/g++.old-deja/g++.pt/typename14.C index 7365b66801d..d2783abe169 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 struct B { @@ -10,6 +10,6 @@ template struct S : public B { 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 51a8765e9ac..225cc894a05 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 struct D2 : public D1 { - 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 55d6430f2ef..8aea4463971 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 struct A @@ -11,11 +11,10 @@ struct A template struct B : public A { - A_Type Func(); + A_Type Func(); // WARNING - implicit typename }; template -B::A_Type B::Func() -{ +B::A_Type B::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 6f9362fe8e7..07719e051a2 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 struct A @@ -17,11 +17,10 @@ struct B : public A template struct C : public B { - A_Type Func(); + A_Type Func(); // WARNING - implicit typename }; template -C::A_Type C::Func() -{ +C::A_Type C::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 e967d143f37..bbf4af744d2 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 struct A @@ -17,11 +17,10 @@ struct B : public A template struct C : public B { - void Func(A_Type); + void Func(A_Type); // WARNING - implicit typename }; template -void C::Func(A_Type) -{ +void C::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 5c89603c8aa..6b4ef223bd6 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 struct D : public A > { 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 cec700220cb..968c9428efe 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 -d0om_Hashmap::value_type* d0om_Hashmap::iterator::operator-> () const +typename d0om_Hashmap::value_type* +d0om_Hashmap::iterator::operator-> () const { return 0; } -- 2.30.2