* friend.c (do_friend): Don't resolve scopes when processing
authormmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 11 Jan 2000 08:54:28 +0000 (08:54 +0000)
committermmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 11 Jan 2000 08:54:28 +0000 (08:54 +0000)
template declarations, even if the qualifying scope doesn't
involve template parameters.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@31321 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cp/ChangeLog
gcc/cp/friend.c
gcc/testsuite/g++.old-deja/g++.pt/friend43.C [new file with mode: 0644]

index 310ca2f..f07e10f 100644 (file)
@@ -1,3 +1,9 @@
+2000-01-11  Mark Mitchell  <mark@codesourcery.com>
+
+       * friend.c (do_friend): Don't resolve scopes when processing
+       template declarations, even if the qualifying scope doesn't
+       involve template parameters.
+
 2000-01-10  Mark Mitchell  <mitchell@dumbledore.codesourcery.com>
 
        * class.c (dfs_modify_vtables_queue_p): Remove.
index d2325f3..aaeaa8f 100644 (file)
@@ -1,5 +1,5 @@
 /* Help friends in C++.
-   Copyright (C) 1997, 1998, 1999 Free Software Foundation, Inc.
+   Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
 
 This file is part of GNU CC.
 
@@ -402,7 +402,7 @@ do_friend (ctype, declarator, decl, parmdecls, attrlist,
       /* We can't do lookup in a type that involves template
         parameters.  Instead, we rely on tsubst_friend_function
         to check the validity of the declaration later.  */
-      if (uses_template_parms (ctype))
+      if (processing_template_decl)
        add_friend (current_class_type, decl);
       /* A nested class may declare a member of an enclosing class
         to be a friend, so we do lookup here even if CTYPE is in
diff --git a/gcc/testsuite/g++.old-deja/g++.pt/friend43.C b/gcc/testsuite/g++.old-deja/g++.pt/friend43.C
new file mode 100644 (file)
index 0000000..2597512
--- /dev/null
@@ -0,0 +1,19 @@
+// Build don't link:
+// Origin: Matt Austern <austern@isolde.engr.sgi.com>
+
+class A {
+public:
+  static void f();
+};
+
+template <class T>
+class B : public A {
+  friend void A::f();
+};
+
+template <class T>
+class C : public B<T>
+{
+};
+
+template class C<char>;