]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/6695 (Regression: template friend declaration doesn't work)
authorMark Mitchell <mark@codesourcery.com>
Thu, 27 Jun 2002 21:45:56 +0000 (21:45 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Thu, 27 Jun 2002 21:45:56 +0000 (21:45 +0000)
PR c++/6695
* pt.c (tsubst_friend_class): Substitute into the context of the
friend before using it.

PR c++/6695
* g++.dg/template/friend7.C: New file.

From-SVN: r55041

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

index 5f2a0b35c753fd297dac779e48fdb0d6c0b33662..d9f06b5a1ccae778fa4d09531acdb8229a416787 100644 (file)
@@ -1,3 +1,9 @@
+2002-06-27  Mark Mitchell  <mark@codesourcery.com>
+
+       PR c++/6695
+       * pt.c (tsubst_friend_class): Substitute into the context of the
+       friend before using it.
+
 2002-06-26  Mark Mitchell  <mark@codesourcery.com>
 
        * cp-tree.h (xref_tag): Change prototype.
index cdc1aa0358d0809bcd7c61450c67be16363820d5..46de8dac6f45448f2ad5593fae2d6fdcc2c91516 100644 (file)
@@ -4836,7 +4836,7 @@ tsubst_friend_class (friend_tmpl, args)
       if (TREE_CODE (context) == NAMESPACE_DECL)
        push_nested_namespace (context);
       else
-       push_nested_class (context, 2);
+       push_nested_class (tsubst (context, args, tf_none, NULL_TREE), 2);
     }
 
   /* First, we look for a class template.  */
index 55d809bb2d38b668eba72b80439f5c4f1b74949f..ed51574129872db95d92dd6ae2975ae529adfe27 100644 (file)
@@ -1,3 +1,8 @@
+2002-06-27  Mark Mitchell  <mark@codesourcery.com>
+
+       PR c++/6695
+       * g++.dg/template/friend7.C: New file.
+
 2002-06-27  Aldy Hernandez  <aldyh@redhat.com>
 
         * gcc.c-torture/execute/string-opt-8.c (strncmp): Fix typo in
diff --git a/gcc/testsuite/g++.dg/template/friend7.C b/gcc/testsuite/g++.dg/template/friend7.C
new file mode 100644 (file)
index 0000000..a954f89
--- /dev/null
@@ -0,0 +1,33 @@
+// { dg-do compile }
+
+template <typename V>
+struct b
+{
+  template <typename T>
+  class a
+  {
+    template <typename>
+    friend class a;
+
+    T t_;
+
+   public:
+    a() {}
+    a(a<T *> const &);
+  };
+};
+
+template <typename V>
+template <typename T>
+b<V>::a<T>::a(a<T *> const &rhs): t_(*rhs.t_)
+{}
+
+
+int
+f ()
+{
+  b<void *>::a<char *> q;
+  b<void *>::a<char> w(q);
+
+  return 0;
+}