re PR c++/72 (aggressive type analysis in template-class's template-member-function)
authorNathan Sidwell <nathan@codesourcery.com>
Mon, 10 Dec 2001 22:49:13 +0000 (22:49 +0000)
committerNathan Sidwell <nathan@gcc.gnu.org>
Mon, 10 Dec 2001 22:49:13 +0000 (22:49 +0000)
cp:
PR g++/72
* decl.c (add_binding): Don't reject duplicate typedefs involving
template parameters.
testsuite:
* g++.dg/template/typedef1.C: New test.

From-SVN: r47854

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

index a8c08a215f7141e924f64fcbed71d5f7f6076464..880ef3fd021062f5db770244b006116d5aed5b1e 100644 (file)
@@ -1,8 +1,14 @@
+2001-12-10  Nathan Sidwell  <nathan@codesourcery.com>
+
+       PR g++/72
+       * decl.c (add_binding): Don't reject duplicate typedefs involving
+       template parameters.
+
 2001-12-10  Neil Booth  <neil@daikokuya.demon.co.uk>
 
        * parse.y, semantics.c: Similarly.
 
-2001-12-04  Nathan Sidwell  <nathan@codesourcery.com>
+2001-12-09  Nathan Sidwell  <nathan@codesourcery.com>
 
        PR g++/87
        * cp-tree.h (DECL_COPY_CONSTRUCTOR_P): Use copy_fn_p.
index 26d3a2499edf132c082bdf22790b53cab1b6cb05..8bf940e4ffde160de1d8fce4734d16db59c94a52 100644 (file)
@@ -981,8 +981,12 @@ add_binding (id, decl)
   else if (TREE_CODE (BINDING_VALUE (binding)) == TYPE_DECL
           && TREE_CODE (decl) == TYPE_DECL
           && DECL_NAME (decl) == DECL_NAME (BINDING_VALUE (binding))
-          && same_type_p (TREE_TYPE (decl),
-                          TREE_TYPE (BINDING_VALUE (binding))))
+          && (same_type_p (TREE_TYPE (decl),
+                           TREE_TYPE (BINDING_VALUE (binding)))
+              /* If either type involves template parameters, we must
+                 wait until instantiation.  */
+              || uses_template_parms (TREE_TYPE (decl))
+              || uses_template_parms (TREE_TYPE (BINDING_VALUE (binding)))))
     /* We have two typedef-names, both naming the same type to have
        the same name.  This is OK because of:
 
index 9c774301cb92360eeb3ba7eff20278fc20b765ea..a7766e9538701da4de496e6e32303625bb779e54 100644 (file)
@@ -1,3 +1,7 @@
+2001-12-10  Nathan Sidwell  <nathan@codesourcery.com>
+
+       * g++.dg/template/typedef1.C: New test.
+
 2001-12-09  Nathan Sidwell  <nathan@codesourcery.com>
 
        * g++.dg/other/copy1.C: New test.
diff --git a/gcc/testsuite/g++.dg/template/typedef1.C b/gcc/testsuite/g++.dg/template/typedef1.C
new file mode 100644 (file)
index 0000000..0325757
--- /dev/null
@@ -0,0 +1,21 @@
+// { dg-do compile }
+
+// Copyright (C) 2001 Free Software Foundation, Inc.
+// Contributed by Nathan Sidwell 9 Dec 2001 <nathan@nathan@codesourcery.com>
+
+// PR 72
+
+template <typename T> struct A
+{
+  typedef T type;
+};
+
+template <typename T> struct B
+{
+  typedef int xxx;
+  typedef T xxx;
+  typedef typename A<T>::type xxx;
+  typedef A<int>::type xxx;
+};
+
+B<int> good;