re PR c++/5507 (Overzealous implicit typename warning)
authorNathan Sidwell <nathan@codesourcery.com>
Wed, 10 Apr 2002 09:40:18 +0000 (09:40 +0000)
committerNathan Sidwell <nathan@gcc.gnu.org>
Wed, 10 Apr 2002 09:40:18 +0000 (09:40 +0000)
cp:
        PR c++/5507
        * decl.c (make_typename_type): Remove implicit typenameness.
testsuite:
        PR c++/5507
        * g++.dg/template/typename2.C: New test.

From-SVN: r52124

gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/template/typename2.C [new file with mode: 0644]

index 1f30899d9353dcf0bcf51930cc8ccaabd22d54c2..a2d8b8f394338c1f28e53bdf1575e1ccb11d615b 100644 (file)
@@ -1,3 +1,8 @@
+2002-04-10  Nathan Sidwell  <nathan@codesourcery.com>
+
+       PR c++/5507
+       * decl.c (make_typename_type): Remove implicit typenameness.
+
 2002-04-09  Jason Merrill  <jason@redhat.com>
 
        PR optimization/6189
index 383991f0924a5c01dacd7aa2001ba780a626362b..dc9d37313e71e1c42fce4feeb4e0a4c29dcec248 100644 (file)
@@ -5699,6 +5699,17 @@ make_typename_type (context, name, complain)
            {
              if (DECL_ARTIFICIAL (t) || !(complain & tf_keep_type_decl))
                t = TREE_TYPE (t);
+             if (IMPLICIT_TYPENAME_P (t))
+               {
+                 /* Lookup found an implicit typename that we had
+                    injected into the current scope. Doing things
+                    properly would have located the exact same type,
+                    so there is no error here.  We must remove the
+                    implicitness so that we do not warn about it.  */
+                 t = copy_node (t);
+                 TREE_TYPE (t) = NULL_TREE;
+               }
+             
              return t;
            }
        }
index fae1c9bdd059f310f0607cbb4d20392b734d8cff..5e82ca50d4b8df693642a968d815b66531aafa49 100644 (file)
@@ -1,3 +1,8 @@
+2002-04-10  Nathan Sidwell  <nathan@codesourcery.com>
+
+       PR c++/5507
+       * g++.dg/template/typename2.C: New test.
+
 2002-04-10  Alan Modra  <amodra@bigpond.net.au>
 
        * gcc.c-torture/execute/loop-12.c: New.
diff --git a/gcc/testsuite/g++.dg/template/typename2.C b/gcc/testsuite/g++.dg/template/typename2.C
new file mode 100644 (file)
index 0000000..4a4e40f
--- /dev/null
@@ -0,0 +1,25 @@
+// { dg-do compile }
+// { dg-options "" }
+
+// Copyright (C) 2001 Free Software Foundation, Inc.
+// Contributed by Nathan Sidwell 21 Mar 2002 <nathan@codesourcery.com>
+
+// PR 5507. Overzealous implicit typename warning
+
+template<typename _CharT>
+class __ctype_abstract_base
+{
+  typedef int mask;
+};
+
+template<typename _CharT>
+class ctype : public __ctype_abstract_base<_CharT>
+{
+  typedef typename ctype::mask mask;
+};
+
+template<typename _CharT>
+class ctype2 : public __ctype_abstract_base<_CharT>
+{
+  typedef mask mask; // { dg-warning "(`typename )|(implicit typename)" "" }
+};