+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
+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
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;
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
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
+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.
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 *);
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));
}
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 - .*
{
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;
{
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;
-# 1 "SetLS.cc"
// GROUPS passed templates nested-classes
// Special g++ Options:
//
#include <iostream>
using namespace std;
-# 1 "../../templates/SetLS.h" 1
// -*- C++ -*-
#define XTRUE true
#define XFALSE false
-# 37 "../../templates/SetLS.h"
-# 1 "../../templates/ListS.h" 1
// -*- C++ -*-
-# 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.
-# 23 "../../templates/ListS.h" 2
-# 37 "../../templates/ListS.h"
{ check(x);
return x.index->item; }
protected:
-# 154 "../../templates/ListS.h"
unsigned count;
}
-# 40 "../../templates/SetLS.h" 2
-# 62 "../../templates/SetLS.h"
template<class T>
class SetLS {
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;
}
-# 17 "SetLS.cc" 2
};
template <class T>
-A<T>::muni A<T>::f() { return X; }
+typename A<T>::muni A<T>::f() { return X; }
template class A<int>;
}
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;
typedef base1 base;
};
+template<>
struct base_trait<float> {
typedef base2 base;
};
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 ();
};
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()
{
};
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
};
// 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 {
template<class T>
void f()
{
- Vector<T>::iterator i = 0; // ERROR - missing typename - XFAIL *-*-*
+ Vector<T>::iterator i = 0; // WARNING - missing typename
}
-// 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 ();
+}
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
-};
+}
// Build don't link:
-// Special g++ Options:
+// Special g++ Options: -Wno-deprecated
template <class T, int I>
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();
}
// Build don't link:
-// Special g++ Options:
+// Special g++ Options: -Wno-deprecated
template <class T>
struct B {
struct S : public B<T>
{
struct I {
- void f(X x);
+ void f(X x); // WARNING - implicit typename
};
};
// Build don't run:
-// Special g++ Options:
+// Special g++ Options: -Wno-deprecated
struct B {
typedef int I;
template <class T>
struct D2 : public D1<T> {
- I i;
+ I i; // WARNING - implicit typename
};
template <>
// Build don't link:
-// Special g++ Options:
+// Special g++ Options: -Wno-deprecated
template <class T>
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
}
// Build don't link:
-// Special g++ Options:
+// Special g++ Options: -Wno-deprecated
template <class T>
struct A
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
}
// Build don't link:
-// Special g++ Options:
+// Special g++ Options: -Wno-deprecated
template <class T>
struct A
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
}
struct D : public A <C <T> > {
void f ()
{
- B* new_entries = (B *) 0;
+ B* new_entries = (B *) 0; // WARNING - implicit typename
}
};
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;
}