pt.c (check_default_tmpl_args): Handle friends defined in the class just like member...
authorMark Mitchell <mark@codesourcery.com>
Wed, 14 Jul 1999 10:57:21 +0000 (10:57 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Wed, 14 Jul 1999 10:57:21 +0000 (10:57 +0000)
* pt.c (check_default_tmpl_args): Handle friends defined in the
class just like member functions defined in the class.

From-SVN: r28097

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

index 6edfa5f2a773afc75b6058ca1b8f74d4bdd36353..fdc4b70c348ad1870cb0390e026893a47c8e8bab 100644 (file)
@@ -1,3 +1,8 @@
+1999-07-14  Mark Mitchell  <mark@codesourcery.com>
+
+       * pt.c (check_default_tmpl_args): Handle friends defined in the
+       class just like member functions defined in the class.
+
 1999-07-09  Michael Tiemann  <tiemann@happy.cygnus.com>
            Jason Merrill  <jason@yorick.cygnus.com>
 
index d591c46a5259687aaf0c4252baeb7b10258dd3db..00e17be096b8894aa5d41d31ed35a0c5ba7296ca 100644 (file)
@@ -2211,12 +2211,17 @@ check_default_tmpl_args (decl, parms, is_primary, is_partial)
 
   if (current_class_type
       && !TYPE_BEING_DEFINED (current_class_type)
-      && DECL_REAL_CONTEXT (decl) == current_class_type
       && DECL_LANG_SPECIFIC (decl)
-      && DECL_DEFINED_IN_CLASS_P (decl)) 
+      /* If this is either a friend defined in the scope of the class
+        or a member function.  */
+      && DECL_CLASS_CONTEXT (decl) == current_class_type
+      /* And, if it was a member function, it really was defined in
+        the scope of the class.  */
+      && (!DECL_FUNCTION_MEMBER_P (decl) || DECL_DEFINED_IN_CLASS_P (decl)))
     /* We already checked these parameters when the template was
-       declared, so there's no need to do it again now.  This is an
-       inline member function definition.  */
+       declared, so there's no need to do it again now.  This function
+       was defined in class scope, but we're processing it's body now
+       that the class is complete.  */
     return;
 
   if (TREE_CODE (decl) != TYPE_DECL || is_partial || !is_primary)
diff --git a/gcc/testsuite/g++.old-deja/g++.pt/defarg9.C b/gcc/testsuite/g++.old-deja/g++.pt/defarg9.C
new file mode 100644 (file)
index 0000000..f9de4aa
--- /dev/null
@@ -0,0 +1,15 @@
+// Build don't link:
+// Origin: Mark Mitchell <mark@codesourcery.com>
+
+template <class T = int>
+struct S 
+{
+  void g () 
+    {
+    }
+  
+  friend void f (double) 
+    {
+    }
+};
+